Skip to content

Commit

Permalink
feat(cactus-plugin-persistence-ethereum): use openapi ethereum connector
Browse files Browse the repository at this point in the history
- 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 <michal.bajer@fujitsu.com>
  • Loading branch information
outSH authored and petermetz committed Oct 17, 2023
1 parent 5ad0ebf commit b8f9b79
Show file tree
Hide file tree
Showing 17 changed files with 1,159 additions and 1,161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ export class PluginLedgerConnectorEthereum

const method = methodRef(...req.params);
if (req.invocationType === EthContractInvocationType.Call) {
contractInstance.methods[req.methodName];
const callOutput = await method.call();
const success = true;
return { success, callOutput };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ export class WatchBlocksV1Endpoint {
bytes: FMT_BYTES.HEX,
},
);

next = {
blockData: {
...web3BlockData,
// Return with full tx objects is not detected, must manually force correct type
transactions:
web3BlockData.transactions as unknown as Web3Transaction[],
transactions: (web3BlockData.transactions ??
[]) as unknown as Web3Transaction[],
},
};
} else {
Expand Down
21 changes: 11 additions & 10 deletions packages/cactus-plugin-persistence-ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,30 @@
"@ethersproject/abi": "5.7.0",
"@hyperledger/cactus-common": "2.0.0-alpha.2",
"@hyperledger/cactus-core": "2.0.0-alpha.2",
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"@hyperledger/cactus-plugin-ledger-connector-ethereum": "2.0.0-alpha.2",
"async-mutex": "0.4.0",
"fast-safe-stringify": "2.1.1",
"pg": "8.8.0",
"run-time-error": "1.4.0",
"sanitize-html": "2.7.0",
"uuid": "8.3.2",
"web3-utils": "1.6.1"
"web3-utils": "4.0.6",
"web3-validator": "2.0.2"
},
"devDependencies": {
"@hyperledger/cactus-api-client": "2.0.0-alpha.2",
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio": "2.0.0-alpha.2",
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-alpha.2",
"@hyperledger/cactus-test-geth-ledger": "2.0.0-alpha.2",
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@openapitools/openapi-generator-cli": "2.4.14",
"@types/express": "4.17.13",
"@types/pg": "8.6.5",
"@types/sanitize-html": "2.9.0",
"body-parser": "1.19.0",
"express": "4.17.1",
"jest-extended": "4.0.1",
"npm-run-all": "4.1.5",
"rxjs": "7.8.1",
"web3": "1.6.1",
"web3-core": "1.6.1",
"web3-eth": "1.6.1"
"socket.io": "4.5.4",
"web3": "4.0.3",
"web3-eth-accounts": "4.0.3"
},
"engines": {
"node": ">=10",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "ERC20",
"sourceName": "contracts/token/ERC20/ERC20.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "allowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientAllowance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "approver",
"type": "address"
}
],
"name": "ERC20InvalidApprover",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "ERC20InvalidReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "ERC20InvalidSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "ERC20InvalidSpender",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}
Loading

0 comments on commit b8f9b79

Please sign in to comment.