Skip to content

Commit

Permalink
Merge pull request #125 from CityOfZion/CU-86du17cj2
Browse files Browse the repository at this point in the history
#86du17cj2 - Ethereum Adapter - Calculate transaction fee
  • Loading branch information
raulduartep authored Jul 22, 2024
2 parents f6bf387 + 0461fc4 commit 7612271
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/wallet-connect-sdk-wallet-core",
"comment": "Added calculateFee method to AbstractWalletConnectEIP155Adapter",
"type": "minor"
}
],
"packageName": "@cityofzion/wallet-connect-sdk-wallet-core"
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ export abstract class AbstractWalletConnectEIP155Adapter {
return undefined
}

async calculateFee(args: TAdapterMethodParam): Promise<string> {
const param = this.resolveParams(args.request.params.request.params[0])
const { wallet, provider } = await this.getServices(args)
const connectedWallet = wallet.connect(provider)

const gasPrice = await provider.getGasPrice()
const estimated = await connectedWallet.estimateGas(param)

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

abstract getAccountString(args: TAdapterMethodParam): Promise<string>

abstract getRPCUrl(args: TAdapterMethodParam): Promise<string>
Expand Down

0 comments on commit 7612271

Please sign in to comment.