-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathisTheSig.js
60 lines (57 loc) · 1.57 KB
/
isTheSig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const {web3Ws} = require('./providerWs.js')
const { simulate } = require('./simulate.js')
function isTheSig(arr,address){
const hash1 = web3Ws.eth.abi.encodeFunctionSignature('_transfer(address,address,uint256)')
const hash2 = web3Ws.eth.abi.encodeFunctionSignature('_approve(address,uint256,address)')
const hash3 = web3Ws.eth.abi.encodeFunctionSignature('_mint(address,uint256)')
const _mintAbi = {
"inputs":[
{
"name":"",
"type":"address"
},
{
"name":"",
"type":"uint256"
}
],
"name":"_mint"
}
// const _transferAbi = {
// "inputs":[
// {
// "name":"",
// "type":"address"
// },
// {
// "name":"",
// "type":"uint256"
// }
// ],
// "name":"_transfer"
// }
// const hash = web3Ws.eth.abi.encodeFunctionSignature(ABI[0])
// console.log(hash)
// return hash
if(isInArray(arr, hash1)){
console.log('_transfer()')
return true
}
if(isInArray(arr, hash2)){
console.log('_approve()')
return true
}
if(isInArray(arr, hash3)){
console.log('_mint()')
simulate(address,_mintAbi)
return true
}
return false
}
function isInArray(arr,val){
var testStr=','+arr.join(",")+",";
return testStr.indexOf(","+val+",")!=-1;
}
module.exports = {
isTheSig
}