diff --git a/packages/relay/src/lib/precheck.ts b/packages/relay/src/lib/precheck.ts index a8acf1273b..d4e7701dcc 100644 --- a/packages/relay/src/lib/precheck.ts +++ b/packages/relay/src/lib/precheck.ts @@ -20,6 +20,7 @@ import { ethers, Transaction } from 'ethers'; import { Logger } from 'pino'; + import { prepend0x } from '../formatters'; import { MirrorNodeClient } from './clients'; import constants from './constants'; @@ -384,7 +385,7 @@ export class Precheck { */ async receiverAccount(tx: Transaction, requestDetails: RequestDetails) { if (tx.to) { - const verifyAccount = await this.mirrorNodeClient.getAccount(tx.to!, requestDetails); + const verifyAccount = await this.mirrorNodeClient.getAccount(tx.to, requestDetails); // When `receiver_sig_required` is set to true, the receiver's account must sign all incoming transactions. if (verifyAccount !== null && verifyAccount.receiver_sig_required === true) { diff --git a/packages/server/tests/acceptance/rpc_batch1.spec.ts b/packages/server/tests/acceptance/rpc_batch1.spec.ts index 354eb8402d..0309aa1fc7 100644 --- a/packages/server/tests/acceptance/rpc_batch1.spec.ts +++ b/packages/server/tests/acceptance/rpc_batch1.spec.ts @@ -1612,15 +1612,11 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () { const toAddress = Utils.idToEvmAddress(receipt.accountId.toString()); const tx = { + ...defaultLegacyTransactionData, + chainId: Number(CHAIN_ID), nonce: await accounts[0].wallet.getNonce(), - chainId: CHAIN_ID, to: toAddress, from: accounts[0].address, - value: '0x2E90EDD000', - gasLimit: defaultGasLimit, - accessList: [], - maxPriorityFeePerGas: defaultGasPrice, - maxFeePerGas: defaultGasPrice, }; const signedTx = await accounts[0].wallet.signTransaction(tx); @@ -1633,6 +1629,39 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () { requestDetails, ]); }); + + it('should execute "eth_sendRawTransaction" if receiver\'s account has receiver_sig_required disabled', async function () { + const newPrivateKey = PrivateKey.generateED25519(); + const newAccount = await new AccountCreateTransaction() + .setKey(newPrivateKey.publicKey) + .setInitialBalance(100) + .setReceiverSignatureRequired(false) + .freezeWith(servicesNode.client) + .sign(newPrivateKey); + + const transaction = await newAccount.execute(servicesNode.client); + const receipt = await transaction.getReceipt(servicesNode.client); + + if (!receipt.accountId) { + throw new Error('Failed to create new account - accountId is null'); + } + + const toAddress = Utils.idToEvmAddress(receipt.accountId.toString()); + const tx = { + ...defaultLegacyTransactionData, + chainId: Number(CHAIN_ID), + nonce: await accounts[0].wallet.getNonce(), + to: toAddress, + from: accounts[0].address, + }; + + const signedTx = await accounts[0].wallet.signTransaction(tx); + const transactionHash = await relay.sendRawTransaction(signedTx, requestId); + const info = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId); + + expect(info).to.exist; + expect(info.result).to.equal('SUCCESS'); + }); }); it('@release should execute "eth_getTransactionByHash" for existing transaction', async function () {