ethershell 0.1.3-beta.0 → 0.1.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/package.json +1 -1
- package/src/services/addContracts.js +30 -25
- package/src/services/build.js +33 -80
- package/src/services/configSync.js +176 -0
- package/src/services/contracts.js +1 -1
- package/src/services/files.js +3 -3
- package/src/services/network.js +12 -42
- package/src/services/wallet.js +23 -36
- package/src/utils/accounter.js +5 -5
- package/src/utils/builder.js +64 -15
- package/src/utils/configFileUpdate.js +4 -1
- package/src/utils/contractLister.js +5 -5
- package/src/utils/contractProxy.js +56 -7
- package/src/utils/etherscan.txt +17 -0
- package/src/utils/event.js +22 -0
- package/src/utils/typeGenerator.js +1 -1
- package/src/services/config.js +0 -15
package/bin/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
|
|
38
38
|
import { deploy, add } from '../src/services/addContracts.js';
|
|
39
39
|
import { getContracts } from '../src/services/contracts.js';
|
|
40
|
-
import { getConfigInfo, getDefaultAccount } from '../src/services/
|
|
40
|
+
import { getConfigInfo, getDefaultAccount } from '../src/services/configSync.js';
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* REPL instance for EtherShell interactive environment
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ethershell",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5-beta.0",
|
|
5
5
|
"description": "Interactive JavaScript console for Ethereum smart contract management",
|
|
6
6
|
"author": "Alireza Kiakojouri (alirezaethdev@gmail.com)",
|
|
7
7
|
"repository": {
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
import { ethers } from 'ethers';
|
|
10
10
|
import fs from 'fs';
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
provider,
|
|
13
|
+
configFile
|
|
14
|
+
} from './configSync.js';
|
|
15
|
+
import { allAccounts } from './wallet.js';
|
|
13
16
|
import { LocalStorage } from 'node-localstorage';
|
|
14
17
|
import { r } from '../../bin/cli.js';
|
|
15
|
-
import { configFile } from './build.js';
|
|
16
18
|
import { createContractProxy } from '../utils/contractProxy.js';
|
|
19
|
+
import { eventOf } from '../utils/event.js';
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* Local storage instance for persisting contract metadata
|
|
@@ -88,16 +91,6 @@ export async function deploy(contractName, args, accIndex, chain, abiLoc, byteco
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
allAccounts[accIndex].contracts.push(contSpec);
|
|
91
|
-
|
|
92
|
-
const accountsIndex = accounts.findIndex(wallet => wallet.index == accIndex);
|
|
93
|
-
if(accountsIndex >= 0) {
|
|
94
|
-
accounts[accountsIndex].contracts.push(contSpec);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const hdIndex = hdAccounts.findIndex(wallet => wallet.index == accIndex);
|
|
98
|
-
if(hdIndex >= 0) {
|
|
99
|
-
hdAccounts[hdIndex].contracts.push(contSpec);
|
|
100
|
-
}
|
|
101
94
|
|
|
102
95
|
// Extend contract object
|
|
103
96
|
deployTx.index = Array.from(contracts.values()).length;
|
|
@@ -117,6 +110,13 @@ export async function deploy(contractName, args, accIndex, chain, abiLoc, byteco
|
|
|
117
110
|
// Wrap the contract instace with proxy
|
|
118
111
|
const proxiedContract = createContractProxy(contractInstance, currentProvider, allAccounts);
|
|
119
112
|
|
|
113
|
+
proxiedContract.contract_index = Array.from(contracts.values()).length;
|
|
114
|
+
proxiedContract.contract_name = contractName;
|
|
115
|
+
proxiedContract.contract_chain = connectedChain.name;
|
|
116
|
+
proxiedContract.contract_chainId = connectedChain.chainId;
|
|
117
|
+
proxiedContract.contract_deployType = 'ethershell-deployed';
|
|
118
|
+
proxiedContract.contract_provider = currentProvider;
|
|
119
|
+
|
|
120
120
|
// Add to REPL context with proxy
|
|
121
121
|
r.context[contractName] = proxiedContract;
|
|
122
122
|
contracts.set(contractName, proxiedContract);
|
|
@@ -127,14 +127,22 @@ export async function deploy(contractName, args, accIndex, chain, abiLoc, byteco
|
|
|
127
127
|
const tx = await provider.getTransaction(deployHash);
|
|
128
128
|
delete tx.data;
|
|
129
129
|
|
|
130
|
+
// Get event values
|
|
131
|
+
const tx1 = await provider.getTransactionReceipt(deployHash);
|
|
132
|
+
const eventValues = eventOf(contractInstance, tx1);
|
|
133
|
+
|
|
130
134
|
// Extend transaction object
|
|
131
135
|
tx.ethershellIndex = deployTx.index;
|
|
132
136
|
tx.address = deployTx.target;
|
|
133
137
|
tx.name = deployTx.name;
|
|
134
138
|
tx.chain = deployTx.chain;
|
|
135
139
|
tx.deployType = deployTx.deployType;
|
|
140
|
+
|
|
141
|
+
if(eventValues) {
|
|
142
|
+
tx.eventValues = eventValues;
|
|
143
|
+
}
|
|
136
144
|
|
|
137
|
-
|
|
145
|
+
return tx;
|
|
138
146
|
} catch(err) {
|
|
139
147
|
console.error(err);
|
|
140
148
|
}
|
|
@@ -185,6 +193,13 @@ export async function add(contractName, contractAddr, accIndex, abiLoc, chain) {
|
|
|
185
193
|
// Wrap the contract instace with proxy
|
|
186
194
|
const proxiedContract = createContractProxy(newContract, currentProvider, allAccounts);
|
|
187
195
|
|
|
196
|
+
proxiedContract.contract_index = Array.from(contracts.values()).length;
|
|
197
|
+
proxiedContract.contract_name = contractName;
|
|
198
|
+
proxiedContract.contract_chain = connectedChain.name;
|
|
199
|
+
proxiedContract.contract_chainId = connectedChain.chainId;
|
|
200
|
+
proxiedContract.contract_deployType = 'ethershell-deployed';
|
|
201
|
+
proxiedContract.contract_provider = currentProvider;
|
|
202
|
+
|
|
188
203
|
// Add to REPL context with proxy
|
|
189
204
|
r.context[contractName] = proxiedContract;
|
|
190
205
|
contracts.set(contractName, proxiedContract);
|
|
@@ -197,16 +212,6 @@ export async function add(contractName, contractAddr, accIndex, abiLoc, chain) {
|
|
|
197
212
|
}
|
|
198
213
|
|
|
199
214
|
allAccounts[accIndex].contracts.push(contSpec);
|
|
200
|
-
|
|
201
|
-
const accountsIndex = accounts.findIndex(wallet => wallet.index == accIndex);
|
|
202
|
-
if(accountsIndex >= 0) {
|
|
203
|
-
accounts[accountsIndex].contracts.push(contSpec);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const hdIndex = hdAccounts.findIndex(wallet => wallet.index == accIndex);
|
|
207
|
-
if(hdIndex >= 0) {
|
|
208
|
-
hdAccounts[hdIndex].contracts.push(contSpec);
|
|
209
|
-
}
|
|
210
215
|
|
|
211
216
|
// Extend contract object
|
|
212
217
|
newContract.index = Array.from(contracts.values()).length;
|
|
@@ -227,7 +232,7 @@ export async function add(contractName, contractAddr, accIndex, abiLoc, chain) {
|
|
|
227
232
|
provider: newContract.provider
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
|
|
235
|
+
return result;
|
|
231
236
|
} catch(err) {
|
|
232
237
|
console.error(err);
|
|
233
238
|
}
|
package/src/services/build.js
CHANGED
|
@@ -6,92 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
|
-
import solc from 'solc';
|
|
10
9
|
import { check, collectSolFiles } from '../utils/dir.js';
|
|
11
10
|
import {
|
|
12
11
|
setVersion,
|
|
13
12
|
build,
|
|
14
|
-
loadSolcVersion,
|
|
15
13
|
extractLoadableVersion
|
|
16
14
|
} from '../utils/builder.js';
|
|
17
15
|
import fs from 'fs';
|
|
18
16
|
import {
|
|
19
17
|
generateAllTypes,
|
|
20
18
|
} from '../utils/typeGenerator.js';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const configPath = './ethershell/config.json';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Global compiler configuration state
|
|
30
|
-
* @type {Object}
|
|
31
|
-
* @property {Object} currentSolcInstance - Current Solidity compiler instance
|
|
32
|
-
* @property {boolean} optimizer - Whether gas optimizer is enabled
|
|
33
|
-
* @property {number} optimizerRuns - Number of optimizer runs
|
|
34
|
-
* @property {boolean} viaIR - Whether to use IR-based code generation
|
|
35
|
-
*/
|
|
36
|
-
let compConfig = {};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* JSON file fields of compiler configuration
|
|
40
|
-
* @type {Object}
|
|
41
|
-
* @property {string} version - Current Solidity compiler version
|
|
42
|
-
* @property {boolean} optimizer - Whether gas optimizer is enabled
|
|
43
|
-
* @property {number} optimizerRuns - Number of optimizer runs
|
|
44
|
-
* @property {boolean} viaIR - Whether to use IR-based code generation
|
|
45
|
-
*/
|
|
46
|
-
export let configFile = {
|
|
47
|
-
providerEndpoint: '',
|
|
48
|
-
defaultWallet: {},
|
|
49
|
-
compiler: {}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Global compiler configuration state
|
|
54
|
-
* @type {Object}
|
|
55
|
-
* @property {boolean} optimizer - Whether gas optimizer is enabled
|
|
56
|
-
* @property {number} optimizerRuns - Number of optimizer runs
|
|
57
|
-
* @property {boolean} viaIR - Whether to use IR-based code generation
|
|
58
|
-
*/
|
|
59
|
-
let storedCompConfig;
|
|
60
|
-
|
|
61
|
-
// Load config file
|
|
62
|
-
if(fs.existsSync(configPath)){
|
|
63
|
-
storedCompConfig = JSON.parse(fs.readFileSync(configPath));
|
|
64
|
-
} else {
|
|
65
|
-
storedCompConfig = null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Initialize global configuration of compiler
|
|
69
|
-
if(storedCompConfig){
|
|
70
|
-
configFile.compiler = storedCompConfig.compiler;
|
|
71
|
-
console.info(`Compiler is loading ...`);
|
|
72
|
-
compConfig.currentSolcInstance = await loadSolcVersion(configFile.compiler.version);
|
|
73
|
-
console.info(`Loading done!`);
|
|
74
|
-
compConfig.optimizer = configFile.compiler.optimizer;
|
|
75
|
-
compConfig.viaIR = configFile.compiler.viaIR;
|
|
76
|
-
compConfig.optimizerRuns = configFile.compiler.optimizerRuns;
|
|
77
|
-
compConfig.compilePath = configFile.compiler.compilePath;
|
|
78
|
-
} else {
|
|
79
|
-
compConfig = {
|
|
80
|
-
currentSolcInstance: solc, // default local compiler
|
|
81
|
-
optimizer: false,
|
|
82
|
-
viaIR: false,
|
|
83
|
-
optimizerRuns: 200,
|
|
84
|
-
compilePath: './build'
|
|
85
|
-
}
|
|
86
|
-
configFile.compiler.version = extractLoadableVersion(compConfig.currentSolcInstance.version());
|
|
87
|
-
configFile.compiler.optimizer = compConfig.optimizer;
|
|
88
|
-
configFile.compiler.viaIR = compConfig.viaIR;
|
|
89
|
-
configFile.compiler.optimizerRuns = compConfig.optimizerRuns;
|
|
90
|
-
configFile.compiler.compilePath = compConfig.compilePath;
|
|
91
|
-
|
|
92
|
-
// Update config file
|
|
93
|
-
fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
|
|
94
|
-
}
|
|
19
|
+
import {
|
|
20
|
+
configPath,
|
|
21
|
+
configFile,
|
|
22
|
+
compConfig
|
|
23
|
+
} from './configSync.js';
|
|
95
24
|
|
|
96
25
|
/**
|
|
97
26
|
* Update the Solidity compiler to a specific version
|
|
@@ -110,6 +39,7 @@ export async function updateCompiler(version){
|
|
|
110
39
|
// Update config file
|
|
111
40
|
configFile.compiler.version = extractLoadableVersion(compConfig.currentSolcInstance.version());
|
|
112
41
|
fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
|
|
42
|
+
|
|
113
43
|
} catch(err) {
|
|
114
44
|
console.error(err);
|
|
115
45
|
}
|
|
@@ -203,6 +133,9 @@ export function compile(fullPath, selectedContracts, buildPath){
|
|
|
203
133
|
[buildPath].forEach(check);
|
|
204
134
|
}
|
|
205
135
|
|
|
136
|
+
// Aggregated ABI container: { [contractName]: abiArray }
|
|
137
|
+
const aggregatedAbis = {};
|
|
138
|
+
|
|
206
139
|
let fileExt;
|
|
207
140
|
if(!fullPath) {
|
|
208
141
|
fullPath = path.resolve('.', 'contracts');
|
|
@@ -211,25 +144,45 @@ export function compile(fullPath, selectedContracts, buildPath){
|
|
|
211
144
|
}
|
|
212
145
|
|
|
213
146
|
if(!fileExt){
|
|
147
|
+
// Directory: collect .sol files and compile each
|
|
214
148
|
const solFiles = collectSolFiles(fullPath);
|
|
215
149
|
|
|
216
150
|
if(!solFiles.length){
|
|
217
151
|
throw 'There is no smart contract in the directory!';
|
|
218
152
|
} else {
|
|
219
|
-
|
|
220
|
-
build(
|
|
221
|
-
|
|
153
|
+
solFiles.forEach((solFile) => {
|
|
154
|
+
const contractAbis = build(solFile, selectedContracts, buildPath);
|
|
155
|
+
// merge returned ABIs into aggregatedAbis
|
|
156
|
+
Object.assign(aggregatedAbis, contractAbis);
|
|
157
|
+
})
|
|
222
158
|
console.log(`Contracts compiled into ${path.resolve(buildPath)}`);
|
|
223
159
|
}
|
|
224
160
|
} else {
|
|
225
|
-
|
|
161
|
+
// Single file
|
|
162
|
+
const contractAbis = build(fullPath, selectedContracts, buildPath);
|
|
163
|
+
// merge returned ABIs into aggregatedAbis
|
|
164
|
+
Object.assign(aggregatedAbis, contractAbis);
|
|
226
165
|
console.log(`Contract compiled into ${path.resolve(buildPath)}`);
|
|
227
166
|
}
|
|
228
167
|
|
|
168
|
+
// Write aggregated ABI file
|
|
169
|
+
const abisDir = path.join(buildPath, 'abis');
|
|
170
|
+
check(abisDir); // ensure dir exists (same util as builder.js)
|
|
171
|
+
const aggregatedAbiPath = path.join(abisDir, 'aggregated.abi.json');
|
|
172
|
+
|
|
173
|
+
// aggregatedAbis is { ContractName: abiArray }
|
|
174
|
+
const flatAbi = Object.values(aggregatedAbis).flat();
|
|
175
|
+
|
|
176
|
+
// Format: { "ContractName": [ ...abi... ], ... }
|
|
177
|
+
fs.writeFileSync(aggregatedAbiPath, JSON.stringify(flatAbi, null, 2));
|
|
178
|
+
console.log('Aggregated ABI written to', path.resolve(aggregatedAbiPath));
|
|
179
|
+
|
|
229
180
|
// Generate TypeScript types
|
|
230
181
|
const typesOutputPath = path.join(buildPath, 'types');
|
|
231
182
|
generateAllTypes(buildPath, typesOutputPath);
|
|
232
183
|
console.log(`TypeScript types generated in ${path.resolve(typesOutputPath)}`);
|
|
184
|
+
|
|
185
|
+
console.log(`Standard JSON Input generated in ${path.resolve(buildPath, 'standard-json')}`);
|
|
233
186
|
} catch(err){
|
|
234
187
|
console.error(err);
|
|
235
188
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadSolcVersion,
|
|
3
|
+
extractLoadableVersion
|
|
4
|
+
} from '../utils/builder.js';
|
|
5
|
+
import { allAccounts } from './wallet.js';
|
|
6
|
+
import { serializeBigInts } from '../utils/serialize.js';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import { ethers } from 'ethers';
|
|
9
|
+
|
|
10
|
+
// Sync Config Memory with Storage Config:
|
|
11
|
+
/**
|
|
12
|
+
* Default JSON-RPC URL for local Ethereum node
|
|
13
|
+
* @constant {string}
|
|
14
|
+
*/
|
|
15
|
+
export const defaultUrl = 'http://127.0.0.1:8545' ;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Currently active network URL
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
export let currentUrl;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Ethers.js JSON-RPC provider instance
|
|
25
|
+
* @type {ethers.JsonRpcProvider}
|
|
26
|
+
*/
|
|
27
|
+
export let provider
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Stored config path
|
|
31
|
+
* @type {string}
|
|
32
|
+
*/
|
|
33
|
+
export const configPath = './ethershell/config.json';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Global compiler configuration state
|
|
37
|
+
* @type {Object}
|
|
38
|
+
* @property {Object} currentSolcInstance - Current Solidity compiler instance
|
|
39
|
+
* @property {boolean} optimizer - Whether gas optimizer is enabled
|
|
40
|
+
* @property {number} optimizerRuns - Number of optimizer runs
|
|
41
|
+
* @property {boolean} viaIR - Whether to use IR-based code generation
|
|
42
|
+
*/
|
|
43
|
+
export let compConfig = {};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* JSON file fields of compiler configuration
|
|
47
|
+
* @type {Object}
|
|
48
|
+
* @property {string} version - Current Solidity compiler version
|
|
49
|
+
* @property {boolean} optimizer - Whether gas optimizer is enabled
|
|
50
|
+
* @property {number} optimizerRuns - Number of optimizer runs
|
|
51
|
+
* @property {boolean} viaIR - Whether to use IR-based code generation
|
|
52
|
+
*/
|
|
53
|
+
export let configFile = {
|
|
54
|
+
providerEndpoint: '',
|
|
55
|
+
defaultWallet: {},
|
|
56
|
+
compiler: {}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Global compiler configuration state
|
|
61
|
+
* @type {Object}
|
|
62
|
+
* @property {boolean} optimizer - Whether gas optimizer is enabled
|
|
63
|
+
* @property {number} optimizerRuns - Number of optimizer runs
|
|
64
|
+
* @property {boolean} viaIR - Whether to use IR-based code generation
|
|
65
|
+
*/
|
|
66
|
+
let storedCompConfig;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Object containing properties of config file
|
|
70
|
+
* @type {Object}
|
|
71
|
+
*/
|
|
72
|
+
let configObj;
|
|
73
|
+
|
|
74
|
+
// 1) Load config file
|
|
75
|
+
if(!fs.existsSync(configPath)){
|
|
76
|
+
storedCompConfig = null;
|
|
77
|
+
} else {
|
|
78
|
+
configObj = JSON.parse(fs.readFileSync(configPath));
|
|
79
|
+
storedCompConfig = configObj;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 2) Set Provider to Memory:
|
|
83
|
+
// Initialize provider with default URL
|
|
84
|
+
/**
|
|
85
|
+
* The specific RPC endpoint URL saved on storage before.
|
|
86
|
+
* @type {string}
|
|
87
|
+
*/
|
|
88
|
+
const storedUrl = configObj.providerEndpoint;
|
|
89
|
+
if(storedUrl) {
|
|
90
|
+
provider = new ethers.JsonRpcProvider(storedUrl);
|
|
91
|
+
currentUrl = storedUrl;
|
|
92
|
+
configFile.providerEndpoint = storedUrl;
|
|
93
|
+
} else {
|
|
94
|
+
provider = new ethers.JsonRpcProvider(defaultUrl);
|
|
95
|
+
currentUrl = defaultUrl;
|
|
96
|
+
configFile.providerEndpoint = defaultUrl;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 3) Set Compiler to Memory:
|
|
100
|
+
// Initialize global configuration of compiler
|
|
101
|
+
if(storedCompConfig){
|
|
102
|
+
configFile.compiler = storedCompConfig.compiler;
|
|
103
|
+
console.info(`Compiler is loading ...`);
|
|
104
|
+
compConfig.currentSolcInstance = await loadSolcVersion(configFile.compiler.version);
|
|
105
|
+
console.info(`Loading done!`);
|
|
106
|
+
compConfig.optimizer = configFile.compiler.optimizer;
|
|
107
|
+
compConfig.viaIR = configFile.compiler.viaIR;
|
|
108
|
+
compConfig.optimizerRuns = configFile.compiler.optimizerRuns;
|
|
109
|
+
compConfig.compilePath = configFile.compiler.compilePath;
|
|
110
|
+
} else {
|
|
111
|
+
compConfig = {
|
|
112
|
+
currentSolcInstance: solc, // default local compiler
|
|
113
|
+
optimizer: false,
|
|
114
|
+
viaIR: false,
|
|
115
|
+
optimizerRuns: 200,
|
|
116
|
+
compilePath: './build'
|
|
117
|
+
}
|
|
118
|
+
configFile.compiler.version = extractLoadableVersion(compConfig.currentSolcInstance.version());
|
|
119
|
+
configFile.compiler.optimizer = compConfig.optimizer;
|
|
120
|
+
configFile.compiler.viaIR = compConfig.viaIR;
|
|
121
|
+
configFile.compiler.optimizerRuns = compConfig.optimizerRuns;
|
|
122
|
+
configFile.compiler.compilePath = compConfig.compilePath;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
// 4) Set Default Account:
|
|
127
|
+
// Set the default account from stored wallets
|
|
128
|
+
const defWallet = configObj.defaultWallet;
|
|
129
|
+
if(defWallet.address) {
|
|
130
|
+
configFile.defaultWallet = serializeBigInts(defWallet);
|
|
131
|
+
} else {
|
|
132
|
+
if(allAccounts && allAccounts.length > 0) {
|
|
133
|
+
configFile.defaultWallet = serializeBigInts(allAccounts[0]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 5) Update config file
|
|
138
|
+
fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Changes provider just in memory
|
|
142
|
+
* @param {Object} newProvider
|
|
143
|
+
*/
|
|
144
|
+
export function setProvider(newProvider) {
|
|
145
|
+
provider = new ethers.JsonRpcProvider(newProvider);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Changes provider just in memory
|
|
150
|
+
* @param {String} newUrl
|
|
151
|
+
*/
|
|
152
|
+
export function setCurrentUrl(newUrl) {
|
|
153
|
+
currentUrl = newUrl;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Changes configFile in memory
|
|
158
|
+
* @param {Object} newConfig
|
|
159
|
+
*/
|
|
160
|
+
export function setConfigFile(newConfig) {
|
|
161
|
+
configFile = newConfig;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Gets all fields of config file
|
|
166
|
+
*/
|
|
167
|
+
export function getConfigInfo() {
|
|
168
|
+
return configFile;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Gets just default account of config file
|
|
173
|
+
*/
|
|
174
|
+
export function getDefaultAccount() {
|
|
175
|
+
return configFile.defaultWallet;
|
|
176
|
+
}
|
package/src/services/files.js
CHANGED
|
@@ -23,17 +23,17 @@ export function deleteDirectory(dirPath){
|
|
|
23
23
|
}
|
|
24
24
|
// Check if the directory exists
|
|
25
25
|
if(!fs.existsSync(dirPath)){
|
|
26
|
-
console.
|
|
26
|
+
console.info('Path is not a directory');
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// For Node.js 14.14.0+ (recommended)
|
|
31
31
|
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
32
32
|
|
|
33
|
-
console.
|
|
33
|
+
console.info('Directory deleted successfully');
|
|
34
34
|
} catch (err) {
|
|
35
35
|
if (err.code === 'ENOENT') {
|
|
36
|
-
console.
|
|
36
|
+
console.info('Directory does not exist');
|
|
37
37
|
} else {
|
|
38
38
|
console.error('Error deleting directory:', err);
|
|
39
39
|
}
|
package/src/services/network.js
CHANGED
|
@@ -5,44 +5,14 @@
|
|
|
5
5
|
* @module network
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { ethers } from 'ethers';
|
|
9
|
-
import { configPath } from './build.js';
|
|
10
|
-
import fs from 'fs';
|
|
11
8
|
import { changeProvider } from '../utils/configFileUpdate.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Currently active network URL
|
|
21
|
-
* @type {string}
|
|
22
|
-
*/
|
|
23
|
-
export let currentUrl;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Ethers.js JSON-RPC provider instance
|
|
27
|
-
* @type {ethers.JsonRpcProvider}
|
|
28
|
-
*/
|
|
29
|
-
export let provider
|
|
30
|
-
|
|
31
|
-
// Initialize provider with default URL
|
|
32
|
-
/**
|
|
33
|
-
* The specific RPC endpoint URL saved on storage before.
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
36
|
-
const storedUrl = JSON.parse(fs.readFileSync(configPath)).providerEndpoint;
|
|
37
|
-
if(storedUrl) {
|
|
38
|
-
provider = new ethers.JsonRpcProvider(storedUrl);
|
|
39
|
-
currentUrl = storedUrl;
|
|
40
|
-
} else {
|
|
41
|
-
provider = new ethers.JsonRpcProvider(defaultUrl);
|
|
42
|
-
currentUrl = defaultUrl;
|
|
43
|
-
changeProvider(currentUrl);
|
|
44
|
-
}
|
|
45
|
-
|
|
9
|
+
import {
|
|
10
|
+
currentUrl,
|
|
11
|
+
setCurrentUrl,
|
|
12
|
+
provider,
|
|
13
|
+
setProvider,
|
|
14
|
+
defaultUrl
|
|
15
|
+
} from './configSync.js';
|
|
46
16
|
|
|
47
17
|
/**
|
|
48
18
|
* Set a new network provider
|
|
@@ -55,8 +25,8 @@ if(storedUrl) {
|
|
|
55
25
|
*/
|
|
56
26
|
export async function set(url){
|
|
57
27
|
try{
|
|
58
|
-
|
|
59
|
-
|
|
28
|
+
setProvider(url);
|
|
29
|
+
setCurrentUrl(url);
|
|
60
30
|
const result = await provider.getNetwork();
|
|
61
31
|
const network = {
|
|
62
32
|
URL: currentUrl,
|
|
@@ -64,7 +34,7 @@ export async function set(url){
|
|
|
64
34
|
chainId: result.chainId
|
|
65
35
|
}
|
|
66
36
|
changeProvider(currentUrl);
|
|
67
|
-
|
|
37
|
+
return network;
|
|
68
38
|
}catch(err){
|
|
69
39
|
console.error(err);
|
|
70
40
|
}
|
|
@@ -86,7 +56,7 @@ export async function get(){
|
|
|
86
56
|
name: result.name,
|
|
87
57
|
chainId: result.chainId
|
|
88
58
|
}
|
|
89
|
-
|
|
59
|
+
return network;
|
|
90
60
|
}catch(err){
|
|
91
61
|
console.error(err);
|
|
92
62
|
}
|
|
@@ -103,7 +73,7 @@ export function getDefault(){
|
|
|
103
73
|
const result = {
|
|
104
74
|
URL: defaultUrl
|
|
105
75
|
}
|
|
106
|
-
|
|
76
|
+
return result;
|
|
107
77
|
}catch(err){
|
|
108
78
|
console.error(err);
|
|
109
79
|
}
|
package/src/services/wallet.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ethers } from 'ethers';
|
|
10
|
-
import { provider } from './
|
|
10
|
+
import { provider } from './configSync.js';
|
|
11
11
|
import {
|
|
12
12
|
deleteByIndex,
|
|
13
13
|
deleteByIndexArr,
|
|
@@ -18,8 +18,6 @@ import {
|
|
|
18
18
|
updateAccountMemory,
|
|
19
19
|
setDefaultAccount
|
|
20
20
|
} from '../utils/accounter.js';
|
|
21
|
-
import { configPath } from './build.js';
|
|
22
|
-
import fs from 'fs';
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Array containing all accounts (imported, generated, HD, and node-managed)
|
|
@@ -27,17 +25,6 @@ import {
|
|
|
27
25
|
*/
|
|
28
26
|
export let allAccounts = getWalletJSON();
|
|
29
27
|
|
|
30
|
-
// Set the default account from stored wallets
|
|
31
|
-
const defWallet = JSON.parse(fs.readFileSync(configPath)).defaultWallet;
|
|
32
|
-
if(defWallet.address) {
|
|
33
|
-
setDefaultAccount(defWallet);
|
|
34
|
-
} else {
|
|
35
|
-
if(allAccounts && allAccounts.length > 0) {
|
|
36
|
-
setDefaultAccount(allAccounts[0]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
28
|
/**
|
|
42
29
|
* Array containing only regular accounts (imported and generated)
|
|
43
30
|
* @type {Array<Object>}
|
|
@@ -94,7 +81,7 @@ export function addAccounts(privKeyArr) {
|
|
|
94
81
|
updateWalletJSON(allAccounts);
|
|
95
82
|
newAccObj.index = allAccounts.length - 1;
|
|
96
83
|
accounts.push(newAccObj);
|
|
97
|
-
|
|
84
|
+
return allAccounts[newFrom];
|
|
98
85
|
}
|
|
99
86
|
|
|
100
87
|
if(Array.isArray(privKeyArr)){
|
|
@@ -112,7 +99,7 @@ export function addAccounts(privKeyArr) {
|
|
|
112
99
|
accounts.push(newAccObj);
|
|
113
100
|
});
|
|
114
101
|
|
|
115
|
-
|
|
102
|
+
return allAccounts.slice(newFrom);
|
|
116
103
|
}
|
|
117
104
|
setDefaultAccount(allAccounts[0]);
|
|
118
105
|
}
|
|
@@ -157,8 +144,8 @@ export function addHD(phrase, count = 10) {
|
|
|
157
144
|
}
|
|
158
145
|
updateWalletJSON(allAccounts);
|
|
159
146
|
setDefaultAccount(allAccounts[0]);
|
|
160
|
-
console.
|
|
161
|
-
|
|
147
|
+
console.info(`!WARNING!\n The generated accounts are NOT safe. Do NOT use them on main net!`);
|
|
148
|
+
return allAccounts.slice(newFrom);
|
|
162
149
|
}
|
|
163
150
|
|
|
164
151
|
/**
|
|
@@ -187,8 +174,8 @@ export function createAccounts(count = 1) {
|
|
|
187
174
|
}
|
|
188
175
|
updateWalletJSON(allAccounts);
|
|
189
176
|
setDefaultAccount(allAccounts[0]);
|
|
190
|
-
console.
|
|
191
|
-
|
|
177
|
+
console.info(`!WARNING!\n The generated accounts are NOT safe. Do NOT use them on main net!`);
|
|
178
|
+
return allAccounts.slice(newFrom);
|
|
192
179
|
}
|
|
193
180
|
|
|
194
181
|
/**
|
|
@@ -222,8 +209,8 @@ export function createHD(count = 10) {
|
|
|
222
209
|
}
|
|
223
210
|
updateWalletJSON(allAccounts);
|
|
224
211
|
setDefaultAccount(allAccounts[0]);
|
|
225
|
-
console.
|
|
226
|
-
|
|
212
|
+
console.info(`!WARNING!\n The generated accounts are NOT safe. Do NOT use them on main net!`);
|
|
213
|
+
return allAccounts.slice(newFrom);
|
|
227
214
|
}
|
|
228
215
|
|
|
229
216
|
/**
|
|
@@ -232,8 +219,8 @@ export function createHD(count = 10) {
|
|
|
232
219
|
* getAllAccounts();
|
|
233
220
|
*/
|
|
234
221
|
export function getAllAccounts() {
|
|
235
|
-
console.
|
|
236
|
-
|
|
222
|
+
console.info(`!WARNING!\n The generated accounts are NOT safe. Do NOT use them on main net!`);
|
|
223
|
+
return allAccounts;
|
|
237
224
|
}
|
|
238
225
|
|
|
239
226
|
/**
|
|
@@ -242,8 +229,8 @@ export function getAllAccounts() {
|
|
|
242
229
|
* getAccounts();
|
|
243
230
|
*/
|
|
244
231
|
export function getAccounts() {
|
|
245
|
-
console.
|
|
246
|
-
|
|
232
|
+
console.info(`!WARNING!\n The generated accounts are NOT safe. Do NOT use them on main net!`);
|
|
233
|
+
return accounts;
|
|
247
234
|
}
|
|
248
235
|
|
|
249
236
|
/**
|
|
@@ -252,8 +239,8 @@ export function getAccounts() {
|
|
|
252
239
|
* getHDAccounts();
|
|
253
240
|
*/
|
|
254
241
|
export function getHDAccounts() {
|
|
255
|
-
console.
|
|
256
|
-
|
|
242
|
+
console.info(`!WARNING!\n The generated accounts are NOT safe. Do NOT use them on main net!`);
|
|
243
|
+
return hdAccounts;
|
|
257
244
|
}
|
|
258
245
|
|
|
259
246
|
/**
|
|
@@ -269,12 +256,12 @@ export function getHDAccounts() {
|
|
|
269
256
|
export function deleteAccount(accPointer) {
|
|
270
257
|
if(!accPointer && accPointer !== 0) {
|
|
271
258
|
deleteByIndex(null);
|
|
272
|
-
|
|
259
|
+
return allAccounts;
|
|
273
260
|
}
|
|
274
261
|
|
|
275
262
|
if(typeof accPointer === 'number') {
|
|
276
263
|
deleteByIndex(accPointer);
|
|
277
|
-
|
|
264
|
+
return allAccounts;
|
|
278
265
|
}
|
|
279
266
|
|
|
280
267
|
if(ethers.isAddress(accPointer)) {
|
|
@@ -283,12 +270,12 @@ export function deleteAccount(accPointer) {
|
|
|
283
270
|
if(index !== -1) {
|
|
284
271
|
deleteByIndex(index);
|
|
285
272
|
}
|
|
286
|
-
|
|
273
|
+
return allAccounts;
|
|
287
274
|
}
|
|
288
275
|
|
|
289
276
|
if(Array.isArray(accPointer)) {
|
|
290
277
|
deleteByIndexArr(accPointer);
|
|
291
|
-
|
|
278
|
+
return allAccounts;
|
|
292
279
|
}
|
|
293
280
|
|
|
294
281
|
if(ethers.Mnemonic.isValidMnemonic(accPointer)) {
|
|
@@ -310,7 +297,7 @@ export function deleteAccount(accPointer) {
|
|
|
310
297
|
deleteByIndex(indicesToDelete[i]);
|
|
311
298
|
}
|
|
312
299
|
|
|
313
|
-
|
|
300
|
+
return allAccounts;
|
|
314
301
|
return;
|
|
315
302
|
}
|
|
316
303
|
}
|
|
@@ -364,16 +351,16 @@ export async function getWalletInfo(accPointer) {
|
|
|
364
351
|
|
|
365
352
|
if(typeof accPointer === 'number') {
|
|
366
353
|
const index = allAccounts.findIndex(wallet => wallet.index == accPointer);
|
|
367
|
-
await getAccountInfo(index);
|
|
354
|
+
return await getAccountInfo(index);
|
|
368
355
|
}
|
|
369
356
|
|
|
370
357
|
if(ethers.isAddress(accPointer)) {
|
|
371
358
|
const index = allAccounts.findIndex(wallet => wallet.address == accPointer);
|
|
372
|
-
await getAccountInfo(index);
|
|
359
|
+
return await getAccountInfo(index);
|
|
373
360
|
}
|
|
374
361
|
|
|
375
362
|
if(Array.isArray(accPointer)) {
|
|
376
|
-
await getAccountInfo(accPointer);
|
|
363
|
+
return await getAccountInfo(accPointer);
|
|
377
364
|
}
|
|
378
365
|
|
|
379
366
|
} catch(err) {
|
package/src/utils/accounter.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { allAccounts, accounts, hdAccounts } from '../services/wallet.js';
|
|
9
|
-
import { provider } from '../services/
|
|
9
|
+
import { provider } from '../services/configSync.js';
|
|
10
10
|
import fs from 'fs';
|
|
11
|
-
import { configFile, configPath } from '../services/
|
|
11
|
+
import { configFile, configPath } from '../services/configSync.js';
|
|
12
12
|
import { serializeBigInts } from './serialize.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -69,9 +69,9 @@ export function deleteByIndexArr(indices) {
|
|
|
69
69
|
*/
|
|
70
70
|
export async function getAccountInfo(index) {
|
|
71
71
|
if (Array.isArray(index)) {
|
|
72
|
-
await _getAccArrInfo(index);
|
|
72
|
+
return await _getAccArrInfo(index);
|
|
73
73
|
} else if (typeof index === 'number') {
|
|
74
|
-
await _getAccountInfo(index);
|
|
74
|
+
return await _getAccountInfo(index);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -182,7 +182,7 @@ async function _getAccountInfo(_index) {
|
|
|
182
182
|
accInfo.nonce = await provider.getTransactionCount(accInfo.address);
|
|
183
183
|
accInfo.balance = await provider.getBalance(accInfo.address);
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
return accInfo;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
package/src/utils/builder.js
CHANGED
|
@@ -82,15 +82,15 @@ export function build(fullPath, selectedContracts, buildPath){
|
|
|
82
82
|
// Get the directory containing the contract
|
|
83
83
|
const contractDir = path.dirname(fullPath);
|
|
84
84
|
const filename = path.basename(fullPath, '.sol');
|
|
85
|
-
const source = fs.readFileSync(fullPath, 'utf8');
|
|
85
|
+
// const source = fs.readFileSync(fullPath, 'utf8');
|
|
86
|
+
|
|
87
|
+
// Start collecting from the main contract
|
|
88
|
+
let allSources = {}
|
|
89
|
+
_collectSources(fullPath, allSources);
|
|
86
90
|
|
|
87
91
|
const input = {
|
|
88
92
|
language: 'Solidity',
|
|
89
|
-
sources:
|
|
90
|
-
[`${filename}`]: {
|
|
91
|
-
content: source,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
93
|
+
sources: allSources,
|
|
94
94
|
settings: {
|
|
95
95
|
outputSelection: {
|
|
96
96
|
'*': {
|
|
@@ -111,12 +111,9 @@ export function build(fullPath, selectedContracts, buildPath){
|
|
|
111
111
|
input.settings.viaIR = true;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
// Compile
|
|
114
|
+
// Compile without import callback
|
|
115
115
|
const output = JSON.parse(
|
|
116
|
-
solc.compile(
|
|
117
|
-
JSON.stringify(input),
|
|
118
|
-
{ import: (importPath) => findImports(importPath, contractDir) }
|
|
119
|
-
)
|
|
116
|
+
solc.compile(JSON.stringify(input))
|
|
120
117
|
);
|
|
121
118
|
|
|
122
119
|
if(output.errors) {
|
|
@@ -126,29 +123,45 @@ export function build(fullPath, selectedContracts, buildPath){
|
|
|
126
123
|
throw errors;
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
|
-
|
|
126
|
+
|
|
130
127
|
// Generate sub-paths of build
|
|
131
128
|
const artifacts = path.join(buildPath, 'artifacts');
|
|
132
129
|
const abis = path.join(buildPath, 'abis');
|
|
133
130
|
const bytecode = path.join(buildPath, 'bytecode');
|
|
134
131
|
const metadata = path.join(buildPath, 'metadata');
|
|
132
|
+
const standardJsonDir = path.join(buildPath, 'standard-json');
|
|
135
133
|
const subPaths = [
|
|
136
134
|
artifacts,
|
|
137
135
|
abis,
|
|
138
136
|
bytecode,
|
|
139
|
-
metadata
|
|
137
|
+
metadata,
|
|
138
|
+
standardJsonDir
|
|
140
139
|
];
|
|
140
|
+
subPaths.forEach(check);
|
|
141
|
+
|
|
142
|
+
// Save standard JSON input on standard-json
|
|
143
|
+
const jsonInputPath = path.join(standardJsonDir, `${filename}.standard.json`);
|
|
144
|
+
fs.writeFileSync(jsonInputPath, JSON.stringify(input, null, 2));
|
|
145
|
+
|
|
146
|
+
// Determine the correct key for the main contract in the output
|
|
147
|
+
const mainContractPath = path.relative(path.resolve('.'), path.resolve(fullPath)).split(path.sep).join('/');;
|
|
148
|
+
const contractsInFile = output.contracts[mainContractPath];
|
|
149
|
+
|
|
150
|
+
if (!contractsInFile) {
|
|
151
|
+
throw new Error(`Could not find compiled output for ${mainContractPath}`);
|
|
152
|
+
}
|
|
141
153
|
|
|
142
154
|
// Ensure all sub-paths exist
|
|
143
155
|
subPaths.forEach(check);
|
|
144
|
-
const allContracts = Object.keys(
|
|
156
|
+
const allContracts = Object.keys(contractsInFile);
|
|
145
157
|
const contractsToSave = selectedContracts.length > 0 ? allContracts.filter(
|
|
146
158
|
(contractName) => {
|
|
147
159
|
return selectedContracts.includes(contractName);
|
|
148
160
|
}
|
|
149
161
|
): allContracts;
|
|
162
|
+
const resultAbis = {}; // Collect ABIs to return
|
|
150
163
|
contractsToSave.forEach((contractName) => {
|
|
151
|
-
const contractsData =
|
|
164
|
+
const contractsData = contractsInFile[contractName];
|
|
152
165
|
// Save on artifacts
|
|
153
166
|
const artifactsPath = path.join(artifacts, `${contractName}.json`);
|
|
154
167
|
fs.writeFileSync(artifactsPath, JSON.stringify(contractsData, null, 2));
|
|
@@ -161,10 +174,19 @@ export function build(fullPath, selectedContracts, buildPath){
|
|
|
161
174
|
// Save on metadata
|
|
162
175
|
const metadataPath = path.join(metadata, `${contractName}.metadata.json`);
|
|
163
176
|
fs.writeFileSync(metadataPath, JSON.stringify(contractsData.metadata, null, 2));
|
|
177
|
+
|
|
164
178
|
// Store abis and bytecode on local storage
|
|
165
179
|
localStorage.setItem(`${contractName}_abi`, abisPath);
|
|
166
180
|
localStorage.setItem(`${contractName}_bytecode`, bytecodePath);
|
|
181
|
+
|
|
182
|
+
// Save ABI
|
|
183
|
+
const abi = contractsData.abi || [];
|
|
184
|
+
// Collect ABI in memory
|
|
185
|
+
resultAbis[contractName] = abi;
|
|
167
186
|
});
|
|
187
|
+
|
|
188
|
+
// Return map of contractName -> abi
|
|
189
|
+
return resultAbis;
|
|
168
190
|
}
|
|
169
191
|
|
|
170
192
|
/**
|
|
@@ -182,3 +204,30 @@ export function extractLoadableVersion(fullVersion) {
|
|
|
182
204
|
}
|
|
183
205
|
return `v${match[1]}+commit.${match[2]}`;
|
|
184
206
|
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Helper to recursively collect all imports into the sources object
|
|
210
|
+
*/
|
|
211
|
+
function _collectSources(filePath, allSourcesObj) {
|
|
212
|
+
const absolutePath = path.resolve(filePath);
|
|
213
|
+
|
|
214
|
+
// 1. Force POSIX style (forward slashes) for the map key
|
|
215
|
+
let relativePath = path.relative(path.resolve('.'), absolutePath);
|
|
216
|
+
relativePath = relativePath.split(path.sep).join('/');
|
|
217
|
+
|
|
218
|
+
if (allSourcesObj[relativePath]) return allSourcesObj;
|
|
219
|
+
|
|
220
|
+
const content = fs.readFileSync(absolutePath, 'utf8');
|
|
221
|
+
allSourcesObj[relativePath] = { content };
|
|
222
|
+
|
|
223
|
+
// 2. Resolve imports and recurse
|
|
224
|
+
const importRegex = /import\s+(?:\{[^}]*\}\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
225
|
+
let match;
|
|
226
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
227
|
+
const importPath = match[1];
|
|
228
|
+
const resolvedImportPath = path.resolve(path.dirname(absolutePath), importPath);
|
|
229
|
+
_collectSources(resolvedImportPath, allSourcesObj);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return allSourcesObj;
|
|
233
|
+
}
|
|
@@ -22,12 +22,12 @@ export async function getContArr() {
|
|
|
22
22
|
|
|
23
23
|
for (const x of contracts.values()) {
|
|
24
24
|
let contract = {
|
|
25
|
-
index: x.
|
|
26
|
-
name: x.
|
|
25
|
+
index: x.contract_index,
|
|
26
|
+
name: x.contract_name,
|
|
27
27
|
address: x.target,
|
|
28
|
-
chain: x.
|
|
29
|
-
chainId: x.
|
|
30
|
-
deployType: x.
|
|
28
|
+
chain: x.contract_chain,
|
|
29
|
+
chainId: x.contract_chainId,
|
|
30
|
+
deployType: x.contract_deployType,
|
|
31
31
|
balance: await x.provider.getBalance(x.target)
|
|
32
32
|
}
|
|
33
33
|
contractsArray.push(contract);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/utils/contractProxy.js
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
+
import { eventOf } from './event.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Creates a proxy wrapper for ethers.js Contract objects
|
|
@@ -25,8 +26,39 @@ import { ethers } from 'ethers';
|
|
|
25
26
|
export function createContractProxy(contract, provider, allAccounts) {
|
|
26
27
|
return new Proxy(contract, {
|
|
27
28
|
get(target, prop) {
|
|
28
|
-
//
|
|
29
|
-
if (
|
|
29
|
+
// Explicit passthroughs for known non-ABI properties
|
|
30
|
+
if (prop === 'provider') {
|
|
31
|
+
return provider;
|
|
32
|
+
}
|
|
33
|
+
if (prop === 'target') {
|
|
34
|
+
return target.target;
|
|
35
|
+
}
|
|
36
|
+
if (prop === 'interface') {
|
|
37
|
+
return target.interface;
|
|
38
|
+
}
|
|
39
|
+
if (prop === 'runner') {
|
|
40
|
+
return target.runner;
|
|
41
|
+
}
|
|
42
|
+
if (prop === 'connect') {
|
|
43
|
+
return target.connect.bind(target);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Allow internal metadata properties to pass through directly
|
|
47
|
+
if (typeof prop === 'string' && prop.startsWith('contract_')) {
|
|
48
|
+
return target[prop];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check if this prop is a contract ABI function
|
|
52
|
+
const isContractMethod =
|
|
53
|
+
target.interface &&
|
|
54
|
+
typeof prop === 'string' &&
|
|
55
|
+
(() => {
|
|
56
|
+
try { target.interface.getFunction(prop); return true; }
|
|
57
|
+
catch { return false; }
|
|
58
|
+
})();
|
|
59
|
+
|
|
60
|
+
// Pass through non-ABI, non-function properties (e.g. contract_name, contract_index)
|
|
61
|
+
if (!isContractMethod && typeof target[prop] !== 'function') {
|
|
30
62
|
return target[prop];
|
|
31
63
|
}
|
|
32
64
|
|
|
@@ -68,8 +100,9 @@ export function createContractProxy(contract, provider, allAccounts) {
|
|
|
68
100
|
|
|
69
101
|
const options = hasOptions ? args.pop() : null;
|
|
70
102
|
|
|
71
|
-
|
|
72
|
-
let
|
|
103
|
+
// Always resolve ABI methods via getFunction to avoid JS built-in property collisions
|
|
104
|
+
let contractTarget = target;
|
|
105
|
+
let method;
|
|
73
106
|
|
|
74
107
|
// Handle 'from' option - switch signer if specified
|
|
75
108
|
if (options && options.from) {
|
|
@@ -91,10 +124,16 @@ export function createContractProxy(contract, provider, allAccounts) {
|
|
|
91
124
|
|
|
92
125
|
// Create new signer with the specified account
|
|
93
126
|
const newSigner = new ethers.Wallet(account.privateKey, provider);
|
|
94
|
-
|
|
95
|
-
method = connectedContract[prop];
|
|
127
|
+
contractTarget = target.connect(newSigner);
|
|
96
128
|
}
|
|
97
129
|
|
|
130
|
+
// Use getFunction for ABI methods to bypass JS name collisions
|
|
131
|
+
method = isContractMethod
|
|
132
|
+
? contractTarget.getFunction(prop)
|
|
133
|
+
: contractTarget[prop];
|
|
134
|
+
|
|
135
|
+
let txOptions = {};
|
|
136
|
+
|
|
98
137
|
// Build transaction options object with all supported ethers.js v6 options
|
|
99
138
|
if (options) {
|
|
100
139
|
// Value (for payable functions)
|
|
@@ -155,12 +194,22 @@ export function createContractProxy(contract, provider, allAccounts) {
|
|
|
155
194
|
}
|
|
156
195
|
|
|
157
196
|
// Call the method with remaining args and tx options
|
|
158
|
-
const result = await method
|
|
197
|
+
const result = await method(...args);
|
|
159
198
|
|
|
160
199
|
// Check if result is a transaction response (has wait method)
|
|
161
200
|
if (result && typeof result.wait === 'function') {
|
|
162
201
|
// This is a transaction - wait for mining
|
|
163
202
|
const receipt = await result.wait();
|
|
203
|
+
|
|
204
|
+
// Get event values
|
|
205
|
+
const tx = await provider.getTransactionReceipt(receipt.hash);
|
|
206
|
+
const eventValues = eventOf(contract, tx);
|
|
207
|
+
|
|
208
|
+
// Extend transaction receipt with event values
|
|
209
|
+
if(eventValues) {
|
|
210
|
+
receipt.eventValues = eventValues;
|
|
211
|
+
}
|
|
212
|
+
|
|
164
213
|
return receipt;
|
|
165
214
|
}
|
|
166
215
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Bytecode (what we are looking for)
|
|
2
|
+
|
|
3
|
+
608060405234610370576114d58038038061001981610374565b9283398101906060818303126103705780516001600160401b0381116103705782610045918301610399565b60208201519092906001600160401b03811161037057604091610069918401610399565b91015160ff8116809103610370575f80546001600160a01b0319163317905582516001600160401b03811161028157600254600181811c91168015610366575b602082101461026357601f8111610303575b506020601f82116001146102a057819293945f92610295575b50508160011b915f199060031b1c1916176002555b81516001600160401b03811161028157600354600181811c91168015610277575b602082101461026357601f8111610200575b50602092601f821160011461019f57928192935f92610194575b50508160011b915f199060031b1c1916176003555b60ff1960045416176004557f82488d8ab594db2178e4a45b7106aaa804836e608f001b5d7fcb6c3514730b3e60408051308152336020820152a16040516110ea90816103eb8239f35b015190505f80610136565b601f1982169360035f52805f20915f5b8681106101e857508360019596106101d0575b505050811b0160035561014b565b01515f1960f88460031b161c191690555f80806101c2565b919260206001819286850151815501940192016101af565b60035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c81019160208410610259575b601f0160051c01905b81811061024e575061011c565b5f8155600101610241565b9091508190610238565b634e487b7160e01b5f52602260045260245ffd5b90607f169061010a565b634e487b7160e01b5f52604160045260245ffd5b015190505f806100d4565b601f1982169060025f52805f20915f5b8181106102eb575095836001959697106102d3575b505050811b016002556100e9565b01515f1960f88460031b161c191690555f80806102c5565b9192602060018192868b0151815501940192016102b0565b60025f527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace601f830160051c8101916020841061035c575b601f0160051c01905b81811061035157506100bb565b5f8155600101610344565b909150819061033b565b90607f16906100a9565b5f80fd5b6040519190601f01601f191682016001600160401b0381118382101761028157604052565b81601f82011215610370578051906001600160401b038211610281576103c8601f8301601f1916602001610374565b928284526020838301011161037057815f9260208093018386015e830101529056fe6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714610d765750806306fdde0314610ce4578063095ea7b314610bcd57806316dead1414610b7657806318160ddd14610b5957806323b872dd14610b02578063313ce56714610ae257806340c10f1914610a1c57806342966c68146109635780635353a2d81461074a57806362a09477146106c157806370a08231146106895780638da5cb5b1461066257806395d89b411461059b578063a3895fff1461036e578063a9059cbb14610287578063c112dfa31461021d578063c42069ec14610174578063dd62ed3e146101245763e30c3978146100f8575f80fd5b34610120575f366003190112610120576001546040516001600160a01b039091168152602090f35b5f80fd5b346101205760403660031901126101205761013d610df3565b610145610e09565b6001600160a01b039182165f908152600760209081526040808320949093168252928352819020549051908152f35b346101205760203660031901126101205761018d610df3565b5f546001600160a01b031633810361020757506001600160a01b031680156101f5576020817f7d5f578daab924f3f271d863dd8729e6970e9186812579e22f892146def80f67926bffffffffffffffffffffffff60a01b6001541617600155604051908152a1005b6334d7d10d60e21b5f5260045260245ffd5b63a3ee740f60e01b5f526004523360245260445ffd5b346101205760203660031901126101205760043560ff8116809103610120575f546001600160a01b0316338103610207577fa667a2c7cf0813fa2c1f7a0a0093db4cf6fc7e9c5264f29df1aa880b409a312e6020838060ff196004541617600455604051908152a1005b34610120576040366003190112610120576102a0610df3565b60243590336102bc576313053d9360e21b5f523360045260245ffd5b6001600160a01b031690816102de5750639cfea58360e01b5f5260045260245ffd5b335f908152600660205260409020548181106103555750815f52600660205261030b8160405f2054610ef1565b50335f52600660205260405f20818154039055815f52600660205260405f208181540190556040519081525f5160206110955f395f51905f5260203392a360405160018152602090f35b63db42144d60e01b5f523360045260245260445260645ffd5b346101205761037c36610e41565b5f546001600160a01b03163381036102075750805167ffffffffffffffff8111610587576103ab600354610eb9565b601f811161051f575b50602091601f82116001146104b4579181925f926104a9575b50508160011b915f199060031b1c1916176003555b604051602081525f6003546103f681610eb9565b908160208501526001811690815f14610487575060011461043d575b507fc5109575ebaf6138fc9735faca1c61ff8b7bf4f91870337266cc2bce01a75e15919081900390a1005b60035f9081525f5160206110755f395f51905f52939250905b80821061046c5750909150810160400181610412565b91926001816020925460408588010152019101909291610456565b60ff191660408086019190915291151560051b84019091019150829050610412565b0151905082806103cd565b601f1982169260035f525f5160206110755f395f51905f52915f5b858110610507575083600195106104ef575b505050811b016003556103e2565b01515f1960f88460031b161c191690558280806104e1565b919260206001819286850151815501940192016104cf565b60035f52601f820160051c5f5160206110755f395f51905f52019060208310610572575b601f0160051c5f5160206110755f395f51905f5201905b81811061056757506103b4565b5f815560010161055a565b5f5160206110755f395f51905f529150610543565b634e487b7160e01b5f52604160045260245ffd5b34610120575f366003190112610120576040515f6003546105bb81610eb9565b808452906001811690811561063e57506001146105f3575b6105ef836105e381850382610e1f565b60405191829182610dc9565b0390f35b91905060035f525f5160206110755f395f51905f52915f905b808210610624575090915081016020016105e36105d3565b91926001816020925483858801015201910190929161060c565b60ff191660208086019190915291151560051b840190910191506105e390506105d3565b34610120575f366003190112610120575f546040516001600160a01b039091168152602090f35b34610120576020366003190112610120576001600160a01b036106aa610df3565b165f526006602052602060405f2054604051908152f35b34610120575f366003190112610120576001546001600160a01b03811690338203610733575f80546001600160a01b0319908116841782559091166001556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91a1005b5063176f517960e01b5f526004523360245260445ffd5b346101205761075836610e41565b5f546001600160a01b03163381036102075750805167ffffffffffffffff811161058757610787600254610eb9565b601f81116108fb575b50602091601f8211600114610890579181925f92610885575b50508160011b915f199060031b1c1916176002555b604051602081525f6002546107d281610eb9565b908160208501526001811690815f146108635750600114610819575b507f2ae91ea06611bdd535a7ec999b4730beaa64fdbc044a50645c052153e55c3e2d919081900390a1005b60025f9081525f5160206110555f395f51905f52939250905b80821061084857509091508101604001816107ee565b91926001816020925460408588010152019101909291610832565b60ff191660408086019190915291151560051b840190910191508290506107ee565b0151905082806107a9565b601f1982169260025f525f5160206110555f395f51905f52915f5b8581106108e3575083600195106108cb575b505050811b016002556107be565b01515f1960f88460031b161c191690558280806108bd565b919260206001819286850151815501940192016108ab565b60025f52601f820160051c5f5160206110555f395f51905f5201906020831061094e575b601f0160051c5f5160206110555f395f51905f5201905b8181106109435750610790565b5f8155600101610936565b5f5160206110555f395f51905f52915061091f565b34610120576020366003190112610120576004353361098f576313053d9360e21b5f523360045260245ffd5b335f90815260066020526040902054818110610355575f826109b381600554611047565b6005553382526006602052604082206109cd828254611047565b90557f410c5c259085cde81fedf70c1aa308ec839373c26e9b7ada6560a2aca0254eb660406005548151908482526020820152a16040519081525f5160206110955f395f51905f5260203392a3005b3461012057604036600319011261012057610a35610df3565b5f5460243591906001600160a01b031633810361020757506001600160a01b03169081610a6f5750639cfea58360e01b5f5260045260245ffd5b5f5160206110955f395f51905f52602082610a8d5f94600554610ef1565b6005558484526006825260408420610aa6828254610ef1565b90557fcc9c58b575eabd3f6a1ee653e91fcea3ff546867ffc3782a3bbca1f9b6dbb8df604060055481519084825285820152a1604051908152a3005b34610120575f36600319011261012057602060ff60045416604051908152f35b34610120576060366003190112610120576020610b4f610b20610df3565b610b28610e09565b6044359160018060a01b0382165f5260068552610b498360405f2054610ef1565b50610f12565b6040519015158152f35b34610120575f366003190112610120576020600554604051908152f35b3461012057604036600319011261012057610b8f610df3565b610b97610e09565b9060018060a01b03165f52600860205260405f209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b3461012057604036600319011261012057610be6610df3565b6024359033610c02576322f051b160e21b5f523360045260245ffd5b6001600160a01b0316903382141580610cd0575b80610cc7575b15610cb457335f908152600660205260409020548181106103555750335f52600860205260405f20825f5260205260405f20600160ff19825416179055335f52600760205260405f20825f5260205260405f20610c7a828254610ef1565b90556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a360405160018152602090f35b5063270af7ed60e11b5f5260045260245ffd5b50811515610c1c565b505f546001600160a01b0316821415610c16565b34610120575f366003190112610120576040515f600254610d0481610eb9565b808452906001811690811561063e5750600114610d2b576105ef836105e381850382610e1f565b91905060025f525f5160206110555f395f51905f52915f905b808210610d5c575090915081016020016105e36105d3565b919260018160209254838588010152019101909291610d44565b34610120576020366003190112610120576004359063ffffffff60e01b8216809203610120576020916301ffc9a760e01b8114908115610db8575b5015158152f35b6336372b0760e01b14905083610db1565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b038216820361012057565b602435906001600160a01b038216820361012057565b90601f8019910116810190811067ffffffffffffffff82111761058757604052565b60206003198201126101205760043567ffffffffffffffff811161012057816023820112156101205780600401359067ffffffffffffffff82116105875760405192610e97601f8401601f191660200185610e1f565b8284526024838301011161012057815f92602460209301838601378301015290565b90600182811c92168015610ee7575b6020831014610ed357565b634e487b7160e01b5f52602260045260245ffd5b91607f1691610ec8565b91908201809211610efe57565b634e487b7160e01b5f52601160045260245ffd5b6001600160a01b0316908115611034576001600160a01b0316918215611021575f828152600660205260409020548181106103555750338203610f8f575b60205f5160206110955f395f51905f5291835f526006825260405f20818154039055845f526006825260405f20818154019055604051908152a3600190565b5f82815260086020908152604080832033845290915290205460ff161561100e575f828152600760209081526040808320338452909152902054818110610ff557505f828152600760209081526040808320338452909152902080548290039055610f50565b630c95cf2760e11b5f523360045260245260445260645ffd5b6313053d9360e21b5f523360045260245ffd5b82639cfea58360e01b5f5260045260245ffd5b506313053d9360e21b5f5260045260245ffd5b91908203918211610efe5756fe405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5acec2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85bddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212200a75d1a4c912be5dc2d821991e5c0ea3009115e80fb66c939e1f3ac47c98f47964736f6c634300081d0033000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000007506f6c79676f6e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003504f4c0000000000000000000000000000000000000000000000000000000000
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
- vs what we got -
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
We tried looking for a match from the list of compiled contract bytecode outputs (as listed below), but was unable to find an exact match.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
1) contracts/ERC20.sol:ERC20
|
|
16
|
+
|
|
17
|
+
608060405234610370576113eb8038038061001981610374565b9283398101906060818303126103705780516001600160401b0381116103705782610045918301610399565b60208201519092906001600160401b03811161037057604091610069918401610399565b91015160ff8116809103610370575f80546001600160a01b0319163317905582516001600160401b03811161028157600254600181811c91168015610366575b602082101461026357601f8111610303575b506020601f82116001146102a057819293945f92610295575b50508160011b915f199060031b1c1916176002555b81516001600160401b03811161028157600354600181811c91168015610277575b602082101461026357601f8111610200575b50602092601f821160011461019f57928192935f92610194575b50508160011b915f199060031b1c1916176003555b60ff1960045416176004557f82488d8ab594db2178e4a45b7106aaa804836e608f001b5d7fcb6c3514730b3e60408051308152336020820152a1604051610fe890816104038239f35b015190505f80610136565b601f1982169360035f52805f20915f5b8681106101e857508360019596106101d0575b505050811b0160035561014b565b01515f1960f88460031b161c191690555f80806101c2565b919260206001819286850151815501940192016101af565b60035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c81019160208410610259575b601f0160051c01905b81811061024e575061011c565b5f8155600101610241565b9091508190610238565b634e487b7160e01b5f52602260045260245ffd5b90607f169061010a565b634e487b7160e01b5f52604160045260245ffd5b015190505f806100d4565b601f1982169060025f52805f20915f5b8181106102eb575095836001959697106102d3575b505050811b016002556100e9565b01515f1960f88460031b161c191690555f80806102c5565b9192602060018192868b0151815501940192016102b0565b60025f527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace601f830160051c8101916020841061035c575b601f0160051c01905b81811061035157506100bb565b5f8155600101610344565b909150819061033b565b90607f16906100a9565b5f80fd5b6040519190601f01601f191682016001600160401b0381118382101761028157604052565b81601f82011215610370578051906001600160401b038211610281576103c8601f8301601f1916602001610374565b9282845260208383010111610370575f5b8281106103ed57505060205f918301015290565b806020809284010151828287010152016103d956fe6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714610b5b5750806306fdde0314610b38578063095ea7b314610a2157806316dead14146109ca57806318160ddd146109ad57806323b872dd14610956578063313ce5671461093657806340c10f191461087057806342966c68146107b75780635353a2d81461063057806362a09477146105a757806370a082311461056f5780638da5cb5b1461054857806395d89b411461050e578063a3895fff1461036e578063a9059cbb14610287578063c112dfa31461021d578063c42069ec14610174578063dd62ed3e146101245763e30c3978146100f8575f80fd5b34610120575f366003190112610120576001546040516001600160a01b039091168152602090f35b5f80fd5b346101205760403660031901126101205761013d610bf5565b610145610c0b565b6001600160a01b039182165f908152600760209081526040808320949093168252928352819020549051908152f35b346101205760203660031901126101205761018d610bf5565b5f546001600160a01b031633810361020757506001600160a01b031680156101f5576020817f7d5f578daab924f3f271d863dd8729e6970e9186812579e22f892146def80f67926bffffffffffffffffffffffff60a01b6001541617600155604051908152a1005b6334d7d10d60e21b5f5260045260245ffd5b63a3ee740f60e01b5f526004523360245260445ffd5b346101205760203660031901126101205760043560ff8116809103610120575f546001600160a01b0316338103610207577fa667a2c7cf0813fa2c1f7a0a0093db4cf6fc7e9c5264f29df1aa880b409a312e6020838060ff196004541617600455604051908152a1005b34610120576040366003190112610120576102a0610bf5565b60243590336102bc576313053d9360e21b5f523360045260245ffd5b6001600160a01b031690816102de5750639cfea58360e01b5f5260045260245ffd5b335f908152600660205260409020548181106103555750815f52600660205261030b8160405f2054610def565b50335f52600660205260405f20818154039055815f52600660205260405f208181540190556040519081525f516020610f935f395f51905f5260203392a360405160018152602090f35b63db42144d60e01b5f523360045260245260445260645ffd5b346101205761037c36610c43565b5f546001600160a01b03163381036102075750805167ffffffffffffffff81116104fa576103ab600354610cbb565b601f8111610492575b50602091601f8211600114610427579181925f9261041c575b50508160011b915f199060031b1c1916176003555b7fc5109575ebaf6138fc9735faca1c61ff8b7bf4f91870337266cc2bce01a75e15604051602081528061041760208201610d7f565b0390a1005b0151905082806103cd565b601f1982169260035f525f516020610f735f395f51905f52915f5b85811061047a57508360019510610462575b505050811b016003556103e2565b01515f1960f88460031b161c19169055828080610454565b91926020600181928685015181550194019201610442565b60035f52601f820160051c5f516020610f735f395f51905f520190602083106104e5575b601f0160051c5f516020610f735f395f51905f5201905b8181106104da57506103b4565b5f81556001016104cd565b5f516020610f735f395f51905f5291506104b6565b634e487b7160e01b5f52604160045260245ffd5b34610120575f366003190112610120576105446040516105388161053181610d7f565b0382610c21565b60405191829182610bae565b0390f35b34610120575f366003190112610120575f546040516001600160a01b039091168152602090f35b34610120576020366003190112610120576001600160a01b03610590610bf5565b165f526006602052602060405f2054604051908152f35b34610120575f366003190112610120576001546001600160a01b03811690338203610619575f80546001600160a01b0319908116841782559091166001556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91a1005b5063176f517960e01b5f526004523360245260445ffd5b346101205761063e36610c43565b5f546001600160a01b03163381036102075750805167ffffffffffffffff81116104fa5761066d600254610cbb565b601f811161074f575b50602091601f82116001146106e4579181925f926106d9575b50508160011b915f199060031b1c1916176002555b7f2ae91ea06611bdd535a7ec999b4730beaa64fdbc044a50645c052153e55c3e2d604051602081528061041760208201610cf3565b01519050828061068f565b601f1982169260025f525f516020610f535f395f51905f52915f5b8581106107375750836001951061071f575b505050811b016002556106a4565b01515f1960f88460031b161c19169055828080610711565b919260206001819286850151815501940192016106ff565b60025f52601f820160051c5f516020610f535f395f51905f520190602083106107a2575b601f0160051c5f516020610f535f395f51905f5201905b8181106107975750610676565b5f815560010161078a565b5f516020610f535f395f51905f529150610773565b3461012057602036600319011261012057600435336107e3576313053d9360e21b5f523360045260245ffd5b335f90815260066020526040902054818110610355575f8261080781600554610f45565b600555338252600660205260408220610821828254610f45565b90557f410c5c259085cde81fedf70c1aa308ec839373c26e9b7ada6560a2aca0254eb660406005548151908482526020820152a16040519081525f516020610f935f395f51905f5260203392a3005b3461012057604036600319011261012057610889610bf5565b5f5460243591906001600160a01b031633810361020757506001600160a01b031690816108c35750639cfea58360e01b5f5260045260245ffd5b5f516020610f935f395f51905f526020826108e15f94600554610def565b60055584845260068252604084206108fa828254610def565b90557fcc9c58b575eabd3f6a1ee653e91fcea3ff546867ffc3782a3bbca1f9b6dbb8df604060055481519084825285820152a1604051908152a3005b34610120575f36600319011261012057602060ff60045416604051908152f35b346101205760603660031901126101205760206109a3610974610bf5565b61097c610c0b565b6044359160018060a01b0382165f526006855261099d8360405f2054610def565b50610e10565b6040519015158152f35b34610120575f366003190112610120576020600554604051908152f35b34610120576040366003190112610120576109e3610bf5565b6109eb610c0b565b9060018060a01b03165f52600860205260405f209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b3461012057604036600319011261012057610a3a610bf5565b6024359033610a56576322f051b160e21b5f523360045260245ffd5b6001600160a01b0316903382141580610b24575b80610b1b575b15610b0857335f908152600660205260409020548181106103555750335f52600860205260405f20825f5260205260405f20600160ff19825416179055335f52600760205260405f20825f5260205260405f20610ace828254610def565b90556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a360405160018152602090f35b5063270af7ed60e11b5f5260045260245ffd5b50811515610a70565b505f546001600160a01b0316821415610a6a565b34610120575f366003190112610120576105446040516105388161053181610cf3565b34610120576020366003190112610120576004359063ffffffff60e01b8216809203610120576020916301ffc9a760e01b8114908115610b9d575b5015158152f35b6336372b0760e01b14905083610b96565b9190916020815282518060208301525f5b818110610bdf575060409293505f838284010152601f8019910116010190565b8060208092870101516040828601015201610bbf565b600435906001600160a01b038216820361012057565b602435906001600160a01b038216820361012057565b90601f8019910116810190811067ffffffffffffffff8211176104fa57604052565b60206003198201126101205760043567ffffffffffffffff811161012057816023820112156101205780600401359067ffffffffffffffff82116104fa5760405192610c99601f8401601f191660200185610c21565b8284526024838301011161012057815f92602460209301838601378301015290565b90600182811c92168015610ce9575b6020831014610cd557565b634e487b7160e01b5f52602260045260245ffd5b91607f1691610cca565b6002545f9291610d0282610cbb565b8082529160018116908115610d635750600114610d1d575050565b60025f9081529293509091905f516020610f535f395f51905f525b838310610d49575060209250010190565b600181602092949394548385870101520191019190610d38565b9050602093945060ff929192191683830152151560051b010190565b6003545f9291610d8e82610cbb565b8082529160018116908115610d635750600114610da9575050565b60035f9081529293509091905f516020610f735f395f51905f525b838310610dd5575060209250010190565b600181602092949394548385870101520191019190610dc4565b91908201809211610dfc57565b634e487b7160e01b5f52601160045260245ffd5b6001600160a01b0316908115610f32576001600160a01b0316918215610f1f575f828152600660205260409020548181106103555750338203610e8d575b60205f516020610f935f395f51905f5291835f526006825260405f20818154039055845f526006825260405f20818154019055604051908152a3600190565b5f82815260086020908152604080832033845290915290205460ff1615610f0c575f828152600760209081526040808320338452909152902054818110610ef357505f828152600760209081526040808320338452909152902080548290039055610e4e565b630c95cf2760e11b5f523360045260245260445260645ffd5b6313053d9360e21b5f523360045260245ffd5b82639cfea58360e01b5f5260045260245ffd5b506313053d9360e21b5f5260045260245ffd5b91908203918211610dfc5756fe405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5acec2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85bddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef{ipfs}64736f6c634300081b0033000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000007506f6c79676f6e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003504f4c0000000000000000000000000000000000000000000000000000000000
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns event values
|
|
3
|
+
* @param {Object} contract
|
|
4
|
+
* @param {Object} tx
|
|
5
|
+
* @returns {Array<Object>}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function eventOf(contract, tx){
|
|
9
|
+
const events = tx.logs.map(log => {
|
|
10
|
+
try {
|
|
11
|
+
return contract.interface.parseLog(log);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}).filter(log => log !== null);
|
|
16
|
+
|
|
17
|
+
const parsedEvents = events.map(e => ({
|
|
18
|
+
name: e.name,
|
|
19
|
+
values: e.args,
|
|
20
|
+
}));
|
|
21
|
+
return parsedEvents;
|
|
22
|
+
}
|
|
@@ -49,7 +49,7 @@ export function generateAllTypes(buildPath, typesOutputPath = './src/types') {
|
|
|
49
49
|
throw new Error(`ABIs directory not found at ${abisPath}`);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const abiFiles = fs.readdirSync(abisPath).filter(f => f.endsWith('.abi.json'));
|
|
52
|
+
const abiFiles = fs.readdirSync(abisPath).filter(f => f.endsWith('.abi.json') && f !== 'aggregated.abi.json');
|
|
53
53
|
const generatedFiles = [];
|
|
54
54
|
|
|
55
55
|
abiFiles.forEach(file => {
|
package/src/services/config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { configFile } from './build.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gets all fields of config file
|
|
5
|
-
*/
|
|
6
|
-
export function getConfigInfo() {
|
|
7
|
-
console.log(configFile);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Gets just default account of config file
|
|
12
|
-
*/
|
|
13
|
-
export function getDefaultAccount() {
|
|
14
|
-
console.log(configFile.defaultWallet);
|
|
15
|
-
}
|