From 042f2f4dcc2e7530d855dc068893df11b0644bdf Mon Sep 17 00:00:00 2001 From: Dario Date: Fri, 6 Oct 2023 18:48:52 -0300 Subject: [PATCH 1/3] fix: update for new rsk-contract-parser's bridge abi handling --- src/services/classes/BcStats.js | 3 ++- src/services/classes/Contract.js | 10 +++++----- src/services/classes/Tx.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/services/classes/BcStats.js b/src/services/classes/BcStats.js index cb088482..367fb49d 100644 --- a/src/services/classes/BcStats.js +++ b/src/services/classes/BcStats.js @@ -26,7 +26,8 @@ export class BcStats extends BlocksBase { try { const { nod3, initConfig } = this const address = initConfig.nativeContracts.bridge - const abi = ABI.bridge + const bitcoinNetwork = this.net.id + const abi = ABI.bridge({ bitcoinNetwork }) const contract = Contract(abi, { address, nod3 }) const res = await contract.call(method, params) return res diff --git a/src/services/classes/Contract.js b/src/services/classes/Contract.js index 8a5471d6..2aef34c3 100644 --- a/src/services/classes/Contract.js +++ b/src/services/classes/Contract.js @@ -28,7 +28,7 @@ class Contract extends BcThing { try { let { deployedCode, fetched } = this if (fetched) return this.getData() - let contract = await this.setContract() + let contract = await this.setContract(this.block.number) if (!this.isNative) { // new contracts if (!this.data.contractInterfaces) { @@ -70,12 +70,12 @@ class Contract extends BcThing { } } - async getParser () { + async getParser (txBlockNumber) { try { let { nod3, initConfig, log } = this if (!this.parser) { let abi = await this.getAbi() - this.parser = new ContractParser({ abi, nod3, initConfig, log }) + this.parser = new ContractParser({ abi, nod3, initConfig, log, txBlockNumber }) } return this.parser } catch (err) { @@ -83,13 +83,13 @@ class Contract extends BcThing { } } - async setContract () { + async setContract (txBlockNumber) { try { let { address, contract } = this if (contract) return contract // get abi let abi = await this.getAbi() - let parser = await this.getParser() + let parser = await this.getParser(txBlockNumber) this.contract = parser.makeContract(address, abi) return this.contract } catch (err) { diff --git a/src/services/classes/Tx.js b/src/services/classes/Tx.js index 7050780e..5e27e0b1 100644 --- a/src/services/classes/Tx.js +++ b/src/services/classes/Tx.js @@ -193,7 +193,7 @@ export class Tx extends BcThing { events[index] = formatEvent(log, tx) } else { contracts[address] = contract - let parser = await contract.getParser() + let parser = await contract.getParser(tx.blockNumber) let [event] = parser.parseTxLogs([log]) events[index] = formatEvent(event, tx) const { _addresses } = event From 79895557bbb615166655947a56328a224010f3c1 Mon Sep 17 00:00:00 2001 From: Dario Date: Mon, 9 Oct 2023 16:43:55 -0300 Subject: [PATCH 2/3] update rsk-contract-parser version in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b1659b0..d2cecbec 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "homepage": "https://github.com/rsksmart/rsk-explorer-api", "dependencies": { "@rsksmart/nod3": "^0.5.0", - "@rsksmart/rsk-contract-parser": "^0.0.12", + "@rsksmart/rsk-contract-parser": "^1.0.0", "@rsksmart/rsk-js-cli": "^1.0.0", "@rsksmart/rsk-utils": "^1.1.0", "bignumber.js": "^7.2.1", From ba7f8d8348be7f2da1aab36c3c442c64932feb24 Mon Sep 17 00:00:00 2001 From: Dario Date: Mon, 9 Oct 2023 16:45:35 -0300 Subject: [PATCH 3/3] update dist changes --- dist/services/classes/BcStats.js | 3 ++- dist/services/classes/Contract.js | 10 +++++----- dist/services/classes/Tx.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dist/services/classes/BcStats.js b/dist/services/classes/BcStats.js index 86aa4e6f..b50d952c 100644 --- a/dist/services/classes/BcStats.js +++ b/dist/services/classes/BcStats.js @@ -26,7 +26,8 @@ class BcStats extends _BlocksBase.BlocksBase { try { const { nod3, initConfig } = this; const address = initConfig.nativeContracts.bridge; - const abi = _rskContractParser.abi.bridge; + const bitcoinNetwork = this.net.id; + const abi = _rskContractParser.abi.bridge({ bitcoinNetwork }); const contract = (0, _rskContractParser.Contract)(abi, { address, nod3 }); const res = await contract.call(method, params); return res; diff --git a/dist/services/classes/Contract.js b/dist/services/classes/Contract.js index f2b4b3c6..32f8411a 100644 --- a/dist/services/classes/Contract.js +++ b/dist/services/classes/Contract.js @@ -28,7 +28,7 @@ class Contract extends _BcThing.BcThing { try { let { deployedCode, fetched } = this; if (fetched) return this.getData(); - let contract = await this.setContract(); + let contract = await this.setContract(this.block.number); if (!this.isNative) { // new contracts if (!this.data.contractInterfaces) { @@ -70,12 +70,12 @@ class Contract extends _BcThing.BcThing { } } - async getParser() { + async getParser(txBlockNumber) { try { let { nod3, initConfig, log } = this; if (!this.parser) { let abi = await this.getAbi(); - this.parser = new _rskContractParser.default({ abi, nod3, initConfig, log }); + this.parser = new _rskContractParser.default({ abi, nod3, initConfig, log, txBlockNumber }); } return this.parser; } catch (err) { @@ -83,13 +83,13 @@ class Contract extends _BcThing.BcThing { } } - async setContract() { + async setContract(txBlockNumber) { try { let { address, contract } = this; if (contract) return contract; // get abi let abi = await this.getAbi(); - let parser = await this.getParser(); + let parser = await this.getParser(txBlockNumber); this.contract = parser.makeContract(address, abi); return this.contract; } catch (err) { diff --git a/dist/services/classes/Tx.js b/dist/services/classes/Tx.js index 23f0d854..c390e2bb 100644 --- a/dist/services/classes/Tx.js +++ b/dist/services/classes/Tx.js @@ -193,7 +193,7 @@ class Tx extends _BcThing.BcThing { events[index] = (0, _Event.formatEvent)(log, tx); } else { contracts[address] = contract; - let parser = await contract.getParser(); + let parser = await contract.getParser(tx.blockNumber); let [event] = parser.parseTxLogs([log]); events[index] = (0, _Event.formatEvent)(event, tx); const { _addresses } = event;