()
| 1074 | } |
| 1075 | |
| 1076 | parseActionScriptDefinitions() { |
| 1077 | const definitions = this.actionScript.definitions || []; |
| 1078 | |
| 1079 | this.targetContracts = {}; |
| 1080 | this.targetFunctions = { |
| 1081 | transfer: "transfer", |
| 1082 | transferFrom: "transferFrom", |
| 1083 | balanceOf: "balanceOf", |
| 1084 | approve: "approve", |
| 1085 | totalSupply: "totalSupply", |
| 1086 | allowance: "allowance", |
| 1087 | }; |
| 1088 | |
| 1089 | for (let definition of definitions) { |
| 1090 | const splitDefinition = definition.split(" "); // Contract | Token | Function | Action |
| 1091 | |
| 1092 | const splitDefinitionByOutputs = definition.split(" => "); |
| 1093 | |
| 1094 | const outputDefinitions = |
| 1095 | splitDefinitionByOutputs.length > 1 |
| 1096 | ? splitDefinitionByOutputs[1].split(" ") |
| 1097 | : []; |
| 1098 | const type = splitDefinition[0]; |
| 1099 | |
| 1100 | let name; |
| 1101 | let address; |
| 1102 | let functionName; |
| 1103 | let contractName; |
| 1104 | let candidateAddress; |
| 1105 | |
| 1106 | switch (type) { |
| 1107 | case "Contract": |
| 1108 | name = splitDefinition[1]; |
| 1109 | |
| 1110 | candidateAddress = splitDefinition[2]; |
| 1111 | |
| 1112 | if (candidateAddress in this.variables) { |
| 1113 | // TODO validate 'address' type: |
| 1114 | address = this.variables[candidateAddress]; |
| 1115 | } else { |
| 1116 | address = candidateAddress; |
| 1117 | } |
| 1118 | |
| 1119 | this.targetContracts[name] = { |
| 1120 | address, |
| 1121 | abi: [], |
| 1122 | namedFunctions: {}, |
| 1123 | }; |
| 1124 | break; |
| 1125 | case "Token": |
| 1126 | name = splitDefinition[1]; |
| 1127 | |
| 1128 | candidateAddress = splitDefinition[2]; |
| 1129 | |
| 1130 | if (candidateAddress in this.variables) { |
| 1131 | // TODO validate 'address' type: |
| 1132 | address = this.variables[candidateAddress]; |
| 1133 | } else { |
no outgoing calls
no test coverage detected