From 37673aa40f70d82351e0996ee81b9f4ca29e695f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Fri, 27 Oct 2023 06:34:18 -0300 Subject: [PATCH] fix: setting `gasLimit` to `0` when creating `CreateTransactionRequest` on `ContractFactory` (#1381) --- .changeset/chatty-mirrors-return.md | 5 +++++ packages/contract/src/contract-factory.ts | 3 +-- packages/fuel-gauge/src/contract-factory.test.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .changeset/chatty-mirrors-return.md diff --git a/.changeset/chatty-mirrors-return.md b/.changeset/chatty-mirrors-return.md new file mode 100644 index 00000000000..c768b4ff248 --- /dev/null +++ b/.changeset/chatty-mirrors-return.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/contract": minor +--- + +set gas limit to 0 when creating a CreateTransactionRequest on ContractFactory diff --git a/packages/contract/src/contract-factory.ts b/packages/contract/src/contract-factory.ts index 68f75ddd479..93d9a1c3974 100644 --- a/packages/contract/src/contract-factory.ts +++ b/packages/contract/src/contract-factory.ts @@ -110,12 +110,11 @@ export default class ContractFactory { ); } - const { maxGasPerTx } = this.provider.getGasConfig(); const stateRoot = options.stateRoot || getContractStorageRoot(options.storageSlots); const contractId = getContractId(this.bytecode, options.salt, stateRoot); const transactionRequest = new CreateTransactionRequest({ gasPrice: 0, - gasLimit: maxGasPerTx, + gasLimit: 0, bytecodeWitnessIndex: 0, witnesses: [this.bytecode], ...options, diff --git a/packages/fuel-gauge/src/contract-factory.test.ts b/packages/fuel-gauge/src/contract-factory.test.ts index 257c539bfca..2bfd7e353df 100644 --- a/packages/fuel-gauge/src/contract-factory.test.ts +++ b/packages/fuel-gauge/src/contract-factory.test.ts @@ -152,6 +152,14 @@ describe('Contract Factory', () => { ); }); + it('should ensure transaction request is created with gas limit sets to 0', async () => { + const factory = await createContractFactory(); + + const { transactionRequest } = factory.createTransactionRequest(); + + expect(transactionRequest.gasLimit.toNumber()).toBe(0); + }); + it('Creates a contract with initial storage (dynamic key)', async () => { const factory = await createContractFactory(); const b256 = '0x626f0c36909faecc316056fca8be684ab0cd06afc63247dc008bdf9e433f927a';