Skip to content

Commit

Permalink
fix: setting gasLimit to 0 when creating `CreateTransactionReques…
Browse files Browse the repository at this point in the history
…t` on `ContractFactory` (#1381)
  • Loading branch information
Torres-ssf authored Oct 27, 2023
1 parent 0d12dc0 commit 37673aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-mirrors-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/contract": minor
---

set gas limit to 0 when creating a CreateTransactionRequest on ContractFactory
3 changes: 1 addition & 2 deletions packages/contract/src/contract-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions packages/fuel-gauge/src/contract-factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 37673aa

Please sign in to comment.