diff --git a/common/changes/@cityofzion/wallet-connect-sdk-wallet-core/main_2024-07-18-19-07.json b/common/changes/@cityofzion/wallet-connect-sdk-wallet-core/main_2024-07-18-19-07.json new file mode 100644 index 0000000..774ca7d --- /dev/null +++ b/common/changes/@cityofzion/wallet-connect-sdk-wallet-core/main_2024-07-18-19-07.json @@ -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" +} \ No newline at end of file diff --git a/packages/wallet-connect-sdk-wallet-core/src/adapters/AbstractWalletConnectEIP155Adapter.ts b/packages/wallet-connect-sdk-wallet-core/src/adapters/AbstractWalletConnectEIP155Adapter.ts index e5247a8..eca6bd1 100644 --- a/packages/wallet-connect-sdk-wallet-core/src/adapters/AbstractWalletConnectEIP155Adapter.ts +++ b/packages/wallet-connect-sdk-wallet-core/src/adapters/AbstractWalletConnectEIP155Adapter.ts @@ -103,6 +103,17 @@ export abstract class AbstractWalletConnectEIP155Adapter { return undefined } + async calculateFee(args: TAdapterMethodParam): Promise { + 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 abstract getRPCUrl(args: TAdapterMethodParam): Promise