Skip to content

Commit

Permalink
Merge pull request #39 from CityOfZion/CU-86drt7tym
Browse files Browse the repository at this point in the history
CU-86drt7tym - BSEthereum: Wrong estimated fee
  • Loading branch information
yumiuehara authored Mar 4, 2024
2 parents ff6b150 + 81eed3f commit ff66462
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-ethereum",
"comment": "fix wrong calculated fee",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-ethereum"
}
4 changes: 3 additions & 1 deletion packages/bs-ethereum/src/BSEthereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export class BSEthereum<BSCustomName extends string = string>
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)
Expand All @@ -176,7 +178,7 @@ export class BSEthereum<BSCustomName extends string = string>
})
}

return ethers.utils.formatEther(estimated)
return ethers.utils.formatEther(gasPrice.mul(estimated))
}

async resolveNameServiceDomain(domainName: string): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit ff66462

Please sign in to comment.