Skip to content

Commit 25bb824

Browse files
authored
fix: configurables constants on createTransactionRequest not been set (#3944)
1 parent e0e4422 commit 25bb824

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

.changeset/beige-days-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fuel-ts/contract": patch
3+
---
4+
5+
fix: configurables constants on createTransactionRequest not been set

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,5 @@ Forc.lock
169169
/blob-report/
170170
/playwright/.cache/
171171

172-
FUELS_VERSION
172+
FUELS_VERSION
173+
.aider*

packages/contract/src/contract-factory.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ export default class ContractFactory<TContract extends Contract = Contract> {
149149
);
150150
}
151151

152+
if (deployOptions?.configurableConstants) {
153+
this.setConfigurableConstants(deployOptions.configurableConstants);
154+
}
155+
152156
const bytecode = deployOptions?.bytecode || this.bytecode;
153157
const stateRoot = options.stateRoot || getContractStorageRoot(options.storageSlots);
154158
const contractId = getContractId(bytecode, options.salt, stateRoot);

packages/fuel-gauge/src/contract-factory.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Account, TransactionResult } from '@fuel-ts/account';
22
import { FuelError, ErrorCode } from '@fuel-ts/errors';
33
import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils';
4-
import { BN, bn, toHex, Interface, ContractFactory, arrayify, concat } from 'fuels';
4+
import { BN, bn, toHex, Interface, ContractFactory, arrayify, concat, ZeroBytes32 } from 'fuels';
55
import { launchTestNode } from 'fuels/test-utils';
66

77
import {
@@ -411,6 +411,32 @@ describe('Contract Factory', () => {
411411
expect(value).toBe(10);
412412
});
413413

414+
it('should return the same contract ID using deploy and createTransactionRequest', async () => {
415+
using launched = await launchTestNode();
416+
const [wallet] = launched.wallets;
417+
418+
const factory = new ConfigurableContractFactory(wallet);
419+
420+
const configurableConstants = {
421+
U8: 1,
422+
U16: 2,
423+
U32: 3,
424+
U64: 4,
425+
};
426+
427+
const salt = ZeroBytes32;
428+
429+
const { contractId } = factory.createTransactionRequest({ configurableConstants, salt });
430+
const deploy = await ConfigurableContractFactory.deploy(wallet, {
431+
configurableConstants,
432+
salt,
433+
});
434+
435+
const { contract } = await deploy.waitForResult();
436+
437+
expect(contract.id.b256Address).to.eq(contractId);
438+
});
439+
414440
it('deploys a large contract via deploy entrypoint', async () => {
415441
using launched = await launchTestNode({
416442
providerOptions: {

0 commit comments

Comments
 (0)