-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathabiCheck.js
51 lines (35 loc) · 1.13 KB
/
abiCheck.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
const _ = require("lodash");
let Merger = require("./merger");
const fs = require('fs');
const assert = require('assert');
const path = require("path");
module.exports = class AbiCheck {
constructor(){
}
checkIfPathOrArray(value) {
return _.isString(value) ? require(value) : value;
}
getAbiContentFromEtherscanFormat(value){
if(_.isArray(value)) return value;
return value.abi || value.result;
}
runCheck(etherScan, submitted){
let authValue = this.checkIfPathOrArray(etherScan);
let subValue = this.checkIfPathOrArray(submitted);
let authority = this.getAbiContentFromEtherscanFormat(authValue);
let submision = this.getAbiContentFromEtherscanFormat(subValue);
let authFunctions = [];
let subFunctions = [];
for(let i=0; i<authority.length; i++){
if(authority[i].type === "function"){
authFunctions.push(authority[i].name);
}
}
for(let i=0; i<submision.length; i++){
if(submision[i].type === "function"){
subFunctions.push(submision[i].name);
}
}
return subFunctions.filter(entry => authFunctions.indexOf(entry) === -1);
}
}