From 967dd6cbee22783a1f546a9fd2e2ef809eb2143a Mon Sep 17 00:00:00 2001 From: Raul Duarte Pereira Date: Mon, 4 Mar 2024 18:32:03 -0300 Subject: [PATCH 1/2] CU-86drt7tym - BSEthereum: Wrong estimated fee --- packages/bs-ethereum/src/BSEthereum.ts | 4 +++- packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/bs-ethereum/src/BSEthereum.ts b/packages/bs-ethereum/src/BSEthereum.ts index 21e0309..f1214f4 100644 --- a/packages/bs-ethereum/src/BSEthereum.ts +++ b/packages/bs-ethereum/src/BSEthereum.ts @@ -155,6 +155,8 @@ export class BSEthereum const provider = new ethers.providers.JsonRpcProvider(this.network.url) const wallet = new ethers.Wallet(senderAccount.key, provider) + const gasPrice = await provider.getGasPrice() + let estimated: ethers.BigNumber const isNative = NATIVE_ASSETS.some(asset => asset.hash === intent.tokenHash) @@ -176,7 +178,7 @@ export class BSEthereum }) } - return ethers.utils.formatEther(estimated) + return ethers.utils.formatEther(gasPrice.mul(estimated)) } async resolveNameServiceDomain(domainName: string): Promise { diff --git a/packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts b/packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts index 4d123a4..13a4b1a 100644 --- a/packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts +++ b/packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts @@ -89,7 +89,7 @@ describe('BSEthereum', () => { }, }) - expect(fee).toEqual(expect.any(Number)) + expect(fee).toEqual(expect.any(String)) }) it.skip('Should be able to transfer a native token', async () => { From 81eed3fd57bab54222ca79cdf47d735e37210b43 Mon Sep 17 00:00:00 2001 From: Raul Duarte Pereira Date: Mon, 4 Mar 2024 18:33:41 -0300 Subject: [PATCH 2/2] changes descriptions --- .../bs-ethereum/CU-86drt7tym_2024-03-04-21-33.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@cityofzion/bs-ethereum/CU-86drt7tym_2024-03-04-21-33.json diff --git a/common/changes/@cityofzion/bs-ethereum/CU-86drt7tym_2024-03-04-21-33.json b/common/changes/@cityofzion/bs-ethereum/CU-86drt7tym_2024-03-04-21-33.json new file mode 100644 index 0000000..5243795 --- /dev/null +++ b/common/changes/@cityofzion/bs-ethereum/CU-86drt7tym_2024-03-04-21-33.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@cityofzion/bs-ethereum", + "comment": "fix wrong calculated fee", + "type": "patch" + } + ], + "packageName": "@cityofzion/bs-ethereum" +} \ No newline at end of file