diff --git a/.changeset/three-dolls-melt.md b/.changeset/three-dolls-melt.md new file mode 100644 index 00000000000..ca7ae2cf27d --- /dev/null +++ b/.changeset/three-dolls-melt.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/program": minor +--- + +made prop transactionRequest protected on BaseInvocationScope in favor of getTransactionRequest diff --git a/packages/fuel-gauge/src/contract.test.ts b/packages/fuel-gauge/src/contract.test.ts index fb1e08f9dc6..02efe8acc3e 100644 --- a/packages/fuel-gauge/src/contract.test.ts +++ b/packages/fuel-gauge/src/contract.test.ts @@ -248,12 +248,14 @@ describe('Contract', () => { const scope = contract.multiCall(calls).addContracts([otherContract]); - expect(scope.transactionRequest.getContractInputs()).toEqual([ + const transactionRequest = await scope.getTransactionRequest(); + + expect(transactionRequest.getContractInputs()).toEqual([ { contractId: contract.id.toB256(), type: 1, txPointer }, { contractId: otherContract.id.toB256(), type: 1, txPointer }, ]); - expect(scope.transactionRequest.getContractOutputs()).toEqual([ + expect(transactionRequest.getContractOutputs()).toEqual([ { type: 1, inputIndex: 0 }, { type: 1, inputIndex: 1 }, ]); @@ -343,12 +345,14 @@ describe('Contract', () => { const scope = contract.multiCall([contract.functions.foo(1336)]).addContracts([otherContract]); - expect(scope.transactionRequest.getContractInputs()).toEqual([ + const transactionRequest = await scope.getTransactionRequest(); + + expect(transactionRequest.getContractInputs()).toEqual([ { contractId: contract.id.toB256(), type: 1, txPointer }, { contractId: otherContract.id.toB256(), type: 1, txPointer }, ]); - expect(scope.transactionRequest.getContractOutputs()).toEqual([ + expect(transactionRequest.getContractOutputs()).toEqual([ { type: 1, inputIndex: 0 }, { type: 1, inputIndex: 1 }, ]); diff --git a/packages/program/src/functions/base-invocation-scope.ts b/packages/program/src/functions/base-invocation-scope.ts index e69aacb7b53..13a9ab2dd5c 100644 --- a/packages/program/src/functions/base-invocation-scope.ts +++ b/packages/program/src/functions/base-invocation-scope.ts @@ -3,7 +3,7 @@ import type { InputValue } from '@fuel-ts/abi-coder'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import type { AbstractContract, AbstractProgram } from '@fuel-ts/interfaces'; import { bn, toNumber } from '@fuel-ts/math'; -import type { Provider, CoinQuantity, TransactionRequest } from '@fuel-ts/providers'; +import type { Provider, CoinQuantity } from '@fuel-ts/providers'; import { transactionRequestify, ScriptTransactionRequest } from '@fuel-ts/providers'; import { InputType } from '@fuel-ts/transactions'; import type { BaseWalletUnlocked } from '@fuel-ts/wallet'; @@ -46,7 +46,7 @@ function createContractCall(funcScope: InvocationScopeLike, offset: number): Con * Base class for managing invocation scopes and preparing transactions. */ export class BaseInvocationScope { - transactionRequest: ScriptTransactionRequest; + protected transactionRequest: ScriptTransactionRequest; protected program: AbstractProgram; protected functionInvocationScopes: Array = []; protected txParameters?: TxParams; @@ -277,7 +277,7 @@ export class BaseInvocationScope { * * @returns The prepared transaction request. */ - async getTransactionRequest(): Promise { + async getTransactionRequest(): Promise { await this.prepareTransaction(); return this.transactionRequest; }