From 22e6bc8fd603de44c769116875c8527fa94c6c1d Mon Sep 17 00:00:00 2001 From: Nathan Seva Date: Wed, 21 Feb 2024 10:05:30 +0100 Subject: [PATCH] readonly: keep blank the optional parameters (#535) * readonly: keep blank the optional parameters * refactor parameters of readSmartContract rpc call --- .../src/web3/SmartContractsClient.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/massa-web3/src/web3/SmartContractsClient.ts b/packages/massa-web3/src/web3/SmartContractsClient.ts index e6fd5e5d..51a7e2d4 100644 --- a/packages/massa-web3/src/web3/SmartContractsClient.ts +++ b/packages/massa-web3/src/web3/SmartContractsClient.ts @@ -178,25 +178,21 @@ export class SmartContractsClient ) } - if (readData.maxGas === null || readData.maxGas === undefined) { - readData.maxGas = BigInt(MAX_GAS_CALL) - } - - if (readData.parameter instanceof Args) - readData.parameter = readData.parameter.serialize() - - // request data - let baseAccountSignerAddress: string | null = null - if (this.walletClient.getBaseAccount()) { - baseAccountSignerAddress = this.walletClient.getBaseAccount().address() - } const data = { - max_gas: Number(readData.maxGas), + max_gas: + readData.maxGas === null || readData.maxGas === undefined + ? Number(MAX_GAS_CALL) + : Number(readData.maxGas), target_address: readData.targetAddress, target_function: readData.targetFunction, - parameter: readData.parameter, - caller_address: readData.callerAddress || baseAccountSignerAddress, - coins: toMAS(readData.coins || BigInt(0)).toString(), + parameter: + readData.parameter instanceof Args + ? readData.parameter.serialize() + : readData.parameter, + caller_address: readData.callerAddress + ? readData.callerAddress + : this.walletClient.getBaseAccount()?.address(), + coins: readData.coins ? toMAS(readData.coins).toString() : undefined, fee: readData.fee?.toString(), }