Skip to content

Commit b8f9b79

Browse files
outSHpetermetz
authored andcommitted
feat(cactus-plugin-persistence-ethereum): use openapi ethereum connector
- Refactor persistence ethereum plugin to use openapi ethereum connector instead of ethereum-socketio. - Upgrade web3js to 4.X in both persistence plugin and its tests. - Update persistence plugin dependency list. - Recompile base token contracts in persistence plugin to match format required by ethereum connector (full compilation output, not just ABI) - Minor fix in ethereum connector to return empty transactions array instead of undefined. - Fix minor runtime issues in geth-test-ledger Depends on #2631 Signed-off-by: Michal Bajer <[email protected]>
1 parent 5ad0ebf commit b8f9b79

File tree

17 files changed

+1159
-1161
lines changed

17 files changed

+1159
-1161
lines changed

packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts

-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ export class PluginLedgerConnectorEthereum
636636

637637
const method = methodRef(...req.params);
638638
if (req.invocationType === EthContractInvocationType.Call) {
639-
contractInstance.methods[req.methodName];
640639
const callOutput = await method.call();
641640
const success = true;
642641
return { success, callOutput };

packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/watch-blocks-v1-endpoint.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,12 @@ export class WatchBlocksV1Endpoint {
8080
bytes: FMT_BYTES.HEX,
8181
},
8282
);
83-
8483
next = {
8584
blockData: {
8685
...web3BlockData,
8786
// Return with full tx objects is not detected, must manually force correct type
88-
transactions:
89-
web3BlockData.transactions as unknown as Web3Transaction[],
87+
transactions: (web3BlockData.transactions ??
88+
[]) as unknown as Web3Transaction[],
9089
},
9190
};
9291
} else {

packages/cactus-plugin-persistence-ethereum/package.json

+11-10
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,30 @@
6060
"@ethersproject/abi": "5.7.0",
6161
"@hyperledger/cactus-common": "2.0.0-alpha.2",
6262
"@hyperledger/cactus-core": "2.0.0-alpha.2",
63+
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
64+
"@hyperledger/cactus-plugin-ledger-connector-ethereum": "2.0.0-alpha.2",
6365
"async-mutex": "0.4.0",
64-
"fast-safe-stringify": "2.1.1",
6566
"pg": "8.8.0",
6667
"run-time-error": "1.4.0",
67-
"sanitize-html": "2.7.0",
6868
"uuid": "8.3.2",
69-
"web3-utils": "1.6.1"
69+
"web3-utils": "4.0.6",
70+
"web3-validator": "2.0.2"
7071
},
7172
"devDependencies": {
72-
"@hyperledger/cactus-api-client": "2.0.0-alpha.2",
73-
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
74-
"@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio": "2.0.0-alpha.2",
73+
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-alpha.2",
74+
"@hyperledger/cactus-test-geth-ledger": "2.0.0-alpha.2",
7575
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
7676
"@openapitools/openapi-generator-cli": "2.4.14",
7777
"@types/express": "4.17.13",
7878
"@types/pg": "8.6.5",
79-
"@types/sanitize-html": "2.9.0",
79+
"body-parser": "1.19.0",
80+
"express": "4.17.1",
8081
"jest-extended": "4.0.1",
8182
"npm-run-all": "4.1.5",
8283
"rxjs": "7.8.1",
83-
"web3": "1.6.1",
84-
"web3-core": "1.6.1",
85-
"web3-eth": "1.6.1"
84+
"socket.io": "4.5.4",
85+
"web3": "4.0.3",
86+
"web3-eth-accounts": "4.0.3"
8687
},
8788
"engines": {
8889
"node": ">=10",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
{
2+
"_format": "hh-sol-artifact-1",
3+
"contractName": "ERC20",
4+
"sourceName": "contracts/token/ERC20/ERC20.sol",
5+
"abi": [
6+
{
7+
"inputs": [
8+
{
9+
"internalType": "address",
10+
"name": "spender",
11+
"type": "address"
12+
},
13+
{
14+
"internalType": "uint256",
15+
"name": "allowance",
16+
"type": "uint256"
17+
},
18+
{
19+
"internalType": "uint256",
20+
"name": "needed",
21+
"type": "uint256"
22+
}
23+
],
24+
"name": "ERC20InsufficientAllowance",
25+
"type": "error"
26+
},
27+
{
28+
"inputs": [
29+
{
30+
"internalType": "address",
31+
"name": "sender",
32+
"type": "address"
33+
},
34+
{
35+
"internalType": "uint256",
36+
"name": "balance",
37+
"type": "uint256"
38+
},
39+
{
40+
"internalType": "uint256",
41+
"name": "needed",
42+
"type": "uint256"
43+
}
44+
],
45+
"name": "ERC20InsufficientBalance",
46+
"type": "error"
47+
},
48+
{
49+
"inputs": [
50+
{
51+
"internalType": "address",
52+
"name": "approver",
53+
"type": "address"
54+
}
55+
],
56+
"name": "ERC20InvalidApprover",
57+
"type": "error"
58+
},
59+
{
60+
"inputs": [
61+
{
62+
"internalType": "address",
63+
"name": "receiver",
64+
"type": "address"
65+
}
66+
],
67+
"name": "ERC20InvalidReceiver",
68+
"type": "error"
69+
},
70+
{
71+
"inputs": [
72+
{
73+
"internalType": "address",
74+
"name": "sender",
75+
"type": "address"
76+
}
77+
],
78+
"name": "ERC20InvalidSender",
79+
"type": "error"
80+
},
81+
{
82+
"inputs": [
83+
{
84+
"internalType": "address",
85+
"name": "spender",
86+
"type": "address"
87+
}
88+
],
89+
"name": "ERC20InvalidSpender",
90+
"type": "error"
91+
},
92+
{
93+
"anonymous": false,
94+
"inputs": [
95+
{
96+
"indexed": true,
97+
"internalType": "address",
98+
"name": "owner",
99+
"type": "address"
100+
},
101+
{
102+
"indexed": true,
103+
"internalType": "address",
104+
"name": "spender",
105+
"type": "address"
106+
},
107+
{
108+
"indexed": false,
109+
"internalType": "uint256",
110+
"name": "value",
111+
"type": "uint256"
112+
}
113+
],
114+
"name": "Approval",
115+
"type": "event"
116+
},
117+
{
118+
"anonymous": false,
119+
"inputs": [
120+
{
121+
"indexed": true,
122+
"internalType": "address",
123+
"name": "from",
124+
"type": "address"
125+
},
126+
{
127+
"indexed": true,
128+
"internalType": "address",
129+
"name": "to",
130+
"type": "address"
131+
},
132+
{
133+
"indexed": false,
134+
"internalType": "uint256",
135+
"name": "value",
136+
"type": "uint256"
137+
}
138+
],
139+
"name": "Transfer",
140+
"type": "event"
141+
},
142+
{
143+
"inputs": [
144+
{
145+
"internalType": "address",
146+
"name": "owner",
147+
"type": "address"
148+
},
149+
{
150+
"internalType": "address",
151+
"name": "spender",
152+
"type": "address"
153+
}
154+
],
155+
"name": "allowance",
156+
"outputs": [
157+
{
158+
"internalType": "uint256",
159+
"name": "",
160+
"type": "uint256"
161+
}
162+
],
163+
"stateMutability": "view",
164+
"type": "function"
165+
},
166+
{
167+
"inputs": [
168+
{
169+
"internalType": "address",
170+
"name": "spender",
171+
"type": "address"
172+
},
173+
{
174+
"internalType": "uint256",
175+
"name": "value",
176+
"type": "uint256"
177+
}
178+
],
179+
"name": "approve",
180+
"outputs": [
181+
{
182+
"internalType": "bool",
183+
"name": "",
184+
"type": "bool"
185+
}
186+
],
187+
"stateMutability": "nonpayable",
188+
"type": "function"
189+
},
190+
{
191+
"inputs": [
192+
{
193+
"internalType": "address",
194+
"name": "account",
195+
"type": "address"
196+
}
197+
],
198+
"name": "balanceOf",
199+
"outputs": [
200+
{
201+
"internalType": "uint256",
202+
"name": "",
203+
"type": "uint256"
204+
}
205+
],
206+
"stateMutability": "view",
207+
"type": "function"
208+
},
209+
{
210+
"inputs": [],
211+
"name": "decimals",
212+
"outputs": [
213+
{
214+
"internalType": "uint8",
215+
"name": "",
216+
"type": "uint8"
217+
}
218+
],
219+
"stateMutability": "view",
220+
"type": "function"
221+
},
222+
{
223+
"inputs": [],
224+
"name": "name",
225+
"outputs": [
226+
{
227+
"internalType": "string",
228+
"name": "",
229+
"type": "string"
230+
}
231+
],
232+
"stateMutability": "view",
233+
"type": "function"
234+
},
235+
{
236+
"inputs": [],
237+
"name": "symbol",
238+
"outputs": [
239+
{
240+
"internalType": "string",
241+
"name": "",
242+
"type": "string"
243+
}
244+
],
245+
"stateMutability": "view",
246+
"type": "function"
247+
},
248+
{
249+
"inputs": [],
250+
"name": "totalSupply",
251+
"outputs": [
252+
{
253+
"internalType": "uint256",
254+
"name": "",
255+
"type": "uint256"
256+
}
257+
],
258+
"stateMutability": "view",
259+
"type": "function"
260+
},
261+
{
262+
"inputs": [
263+
{
264+
"internalType": "address",
265+
"name": "to",
266+
"type": "address"
267+
},
268+
{
269+
"internalType": "uint256",
270+
"name": "value",
271+
"type": "uint256"
272+
}
273+
],
274+
"name": "transfer",
275+
"outputs": [
276+
{
277+
"internalType": "bool",
278+
"name": "",
279+
"type": "bool"
280+
}
281+
],
282+
"stateMutability": "nonpayable",
283+
"type": "function"
284+
},
285+
{
286+
"inputs": [
287+
{
288+
"internalType": "address",
289+
"name": "from",
290+
"type": "address"
291+
},
292+
{
293+
"internalType": "address",
294+
"name": "to",
295+
"type": "address"
296+
},
297+
{
298+
"internalType": "uint256",
299+
"name": "value",
300+
"type": "uint256"
301+
}
302+
],
303+
"name": "transferFrom",
304+
"outputs": [
305+
{
306+
"internalType": "bool",
307+
"name": "",
308+
"type": "bool"
309+
}
310+
],
311+
"stateMutability": "nonpayable",
312+
"type": "function"
313+
}
314+
],
315+
"bytecode": "0x",
316+
"deployedBytecode": "0x",
317+
"linkReferences": {},
318+
"deployedLinkReferences": {}
319+
}

0 commit comments

Comments
 (0)