diff --git a/common/changes/@cityofzion/bs-ethereum/CU-86duaznam-1_2024-08-09-20-02.json b/common/changes/@cityofzion/bs-ethereum/CU-86duaznam-1_2024-08-09-20-02.json new file mode 100644 index 0000000..5645945 --- /dev/null +++ b/common/changes/@cityofzion/bs-ethereum/CU-86duaznam-1_2024-08-09-20-02.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@cityofzion/bs-ethereum", + "comment": "Fix error when making a transaction with NeoX on TestNet", + "type": "patch" + } + ], + "packageName": "@cityofzion/bs-ethereum" +} \ No newline at end of file diff --git a/packages/bs-ethereum/src/BSEthereum.ts b/packages/bs-ethereum/src/BSEthereum.ts index 6857d06..bde2a93 100644 --- a/packages/bs-ethereum/src/BSEthereum.ts +++ b/packages/bs-ethereum/src/BSEthereum.ts @@ -173,22 +173,26 @@ export class BSEthereum const decimals = param.intent.tokenDecimals ?? 18 const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals) - let transactionParams: ethers.utils.Deferrable + const gasPrice = await provider.getGasPrice() + + let transactionParams: ethers.utils.Deferrable = { + gasPrice, + } const isNative = BSEthereumHelper.normalizeHash(this.feeToken.hash) === BSEthereumHelper.normalizeHash(param.intent.tokenHash) if (isNative) { - const gasPrice = await provider.getGasPrice() - transactionParams = { - to: param.intent.receiverAddress, - value: amount, - gasPrice, - } + transactionParams.to = param.intent.receiverAddress + transactionParams.value = amount } else { const contract = new ethers.Contract(param.intent.tokenHash, [ 'function transfer(address to, uint amount) returns (bool)', ]) - transactionParams = await contract.populateTransaction.transfer(param.intent.receiverAddress, amount) + const populatedTransaction = await contract.populateTransaction.transfer(param.intent.receiverAddress, amount) + transactionParams = { + ...populatedTransaction, + ...transactionParams, + } } const transaction = await signer.sendTransaction(transactionParams)