diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b66228b..34a3c91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - "packages/snap": "2.3.12", + "packages/snap": "2.3.13", "packages/types": "2.1.3", "packages/adapter": "2.1.3" } \ No newline at end of file diff --git a/packages/snap/CHANGELOG.md b/packages/snap/CHANGELOG.md index a89249d..e2b9ba8 100644 --- a/packages/snap/CHANGELOG.md +++ b/packages/snap/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.3.13](https://github.com/ChainSafe/filsnap/compare/filsnap-v2.3.12...filsnap-v2.3.13) (2023-03-27) + + +### Bug Fixes + +* gaslimit ([#254](https://github.com/ChainSafe/filsnap/issues/254)) ([067fce8](https://github.com/ChainSafe/filsnap/commit/067fce8c736b76a5d73e73a500fe1b1d1b00c7cd)) + ## [2.3.12](https://github.com/ChainSafe/filsnap/compare/filsnap-v2.3.11...filsnap-v2.3.12) (2023-03-03) diff --git a/packages/snap/package.json b/packages/snap/package.json index 5ccf14d..85a0603 100644 --- a/packages/snap/package.json +++ b/packages/snap/package.json @@ -1,6 +1,6 @@ { "name": "@chainsafe/filsnap", - "version": "2.3.12", + "version": "2.3.13", "license": "(Apache-2.0 AND MIT)", "description": "Filsnap - Metamask snap to interact with Filecoin dapps.", "main": "build/index.js", diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index bfb5938..e1d1856 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -1,5 +1,5 @@ { - "version": "2.3.12", + "version": "2.3.13", "proposedName": "Filsnap", "description": "The Filecoin snap.", "repository": { diff --git a/packages/snap/src/rpc/estimateMessageGas.ts b/packages/snap/src/rpc/estimateMessageGas.ts index 4acf5e8..85f9c90 100644 --- a/packages/snap/src/rpc/estimateMessageGas.ts +++ b/packages/snap/src/rpc/estimateMessageGas.ts @@ -24,8 +24,6 @@ export async function estimateMessageGas( method: 0, // code for basic transaction nonce: 0, // dummy nonce just for gas calculation }; - // estimate gas usage - const gasLimit = await api.gasEstimateGasLimit(message, null); // set max fee to 0.1 FIL if not set const maxFeeAttoFil = maxFee ? maxFee @@ -37,7 +35,7 @@ export async function estimateMessageGas( ); return { gasfeecap: messageEstimate.GasFeeCap, - gaslimit: gasLimit, + gaslimit: messageEstimate.GasLimit, gaspremium: messageEstimate.GasPremium, maxfee: maxFeeAttoFil, }; diff --git a/packages/snap/src/rpc/signMessage.ts b/packages/snap/src/rpc/signMessage.ts index 5681edc..d373abb 100644 --- a/packages/snap/src/rpc/signMessage.ts +++ b/packages/snap/src/rpc/signMessage.ts @@ -59,12 +59,12 @@ export async function signMessage( message.gasfeecap === "0" && message.gaspremium === "0" ) { - message.gaslimit = await api.gasEstimateGasLimit(message, null); const messageEstimate = await api.gasEstimateMessageGas( message, { MaxFee: "0" }, null ); + message.gaslimit = messageEstimate.GasLimit; message.gaspremium = messageEstimate.GasPremium; message.gasfeecap = messageEstimate.GasFeeCap; } diff --git a/packages/snap/test/unit/rpc/signMessage.test.ts b/packages/snap/test/unit/rpc/signMessage.test.ts index a019028..8e5ffbd 100644 --- a/packages/snap/test/unit/rpc/signMessage.test.ts +++ b/packages/snap/test/unit/rpc/signMessage.test.ts @@ -49,10 +49,10 @@ describe("Test rpc handler function: signMessage", function () { walletStub.prepareFoKeyPair(); apiStub.mpoolGetNonce.returns("0"); - apiStub.gasEstimateGasLimit.returns(1000); apiStub.gasEstimateMessageGas.returns({ GasPremium: "10", GasFeeCap: "10", + GasLimit: 1000, }); const response = await signMessage(walletStub, apiStub, messageRequest); @@ -61,7 +61,6 @@ describe("Test rpc handler function: signMessage", function () { expect(walletStub.rpcStubs.snap_getBip44Entropy).to.have.been.calledOnce; expect(walletStub.rpcStubs.snap_manageState).to.have.been.calledOnce; expect(apiStub.mpoolGetNonce).to.have.been.calledOnce; - expect(apiStub.gasEstimateGasLimit).to.have.been.calledOnce; expect(apiStub.gasEstimateMessageGas).to.have.been.calledOnce; expect(response.signedMessage.message).to.be.deep.eq(fullMessage); expect(response.signedMessage.signature.data).to.not.be.empty; @@ -103,10 +102,10 @@ describe("Test rpc handler function: signMessage", function () { walletStub.rpcStubs.snap_confirm.resolves(true); walletStub.prepareFoKeyPair(); apiStub.mpoolGetNonce.returns("0"); - apiStub.gasEstimateGasLimit.returns(1000); apiStub.gasEstimateMessageGas.returns({ GasFeeCap: "10", GasPremium: "10", + GasLimit: 1000, }); const messageRequestWithCustomParams: MessageRequest = { @@ -123,7 +122,6 @@ describe("Test rpc handler function: signMessage", function () { expect(walletStub.rpcStubs.snap_getBip44Entropy).to.have.been.calledOnce; expect(walletStub.rpcStubs.snap_manageState).to.have.been.calledOnce; expect(apiStub.mpoolGetNonce).to.have.been.calledOnce; - expect(apiStub.gasEstimateGasLimit).to.have.been.calledOnce; expect(apiStub.gasEstimateMessageGas).to.have.been.calledOnce; expect(response.signedMessage.message).to.be.deep.eq(paramsMessage); expect(response.signedMessage.signature.data).to.not.be.empty;