From 8511026ca9118c21f85ab916a0afebe56bacc8d5 Mon Sep 17 00:00:00 2001 From: AurelienFT <32803821+AurelienFT@users.noreply.github.com> Date: Tue, 9 Apr 2024 08:03:39 +0200 Subject: [PATCH] Add fee by default for readonly (#551) --- packages/massa-web3/src/web3/SmartContractsClient.ts | 4 +++- packages/massa-web3/test/web3/smartContractsClient.spec.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/massa-web3/src/web3/SmartContractsClient.ts b/packages/massa-web3/src/web3/SmartContractsClient.ts index eb128fed..87ed9d24 100644 --- a/packages/massa-web3/src/web3/SmartContractsClient.ts +++ b/packages/massa-web3/src/web3/SmartContractsClient.ts @@ -188,6 +188,8 @@ export class SmartContractsClient ) } + const minimalFees = await this.publicApiClient.getMinimalFees() + const data = { max_gas: readData.maxGas === null || readData.maxGas === undefined @@ -207,7 +209,7 @@ export class SmartContractsClient : undefined, fee: readData.fee ? toMAS(readData.fee).toFixed(MASSA_SCALING_FACTOR) - : undefined, + : toMAS(minimalFees).toFixed(MASSA_SCALING_FACTOR), } // returns operation ids diff --git a/packages/massa-web3/test/web3/smartContractsClient.spec.ts b/packages/massa-web3/test/web3/smartContractsClient.spec.ts index f6d69d7d..4e78d383 100644 --- a/packages/massa-web3/test/web3/smartContractsClient.spec.ts +++ b/packages/massa-web3/test/web3/smartContractsClient.spec.ts @@ -77,6 +77,9 @@ describe('SmartContractsClient', () => { mockPublicApiClient.getNodeStatus = jest .fn() .mockResolvedValue(mockNodeStatusInfo) + + // Mock the getMinimalFees function + mockPublicApiClient.getMinimalFees = jest.fn().mockResolvedValue(BigInt(0)) // Mock the getBaseAccount function mockWalletClient.getBaseAccount = jest .fn()