Skip to content

Commit

Permalink
readonly: keep blank the optional parameters (#535)
Browse files Browse the repository at this point in the history
* readonly: keep blank the optional parameters

* refactor parameters of readSmartContract rpc call
  • Loading branch information
Thykof authored Feb 21, 2024
1 parent 9c17cf0 commit 22e6bc8
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/massa-web3/src/web3/SmartContractsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}

Expand Down

0 comments on commit 22e6bc8

Please sign in to comment.