Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added method to duplicate predicate #3395

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 60 additions & 48 deletions packages/account/src/predicate/predicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
bytes: Uint8Array;
predicateData: TData = [] as unknown as TData;
interface: Interface;
configurableConstants: TConfigurables = {} as TConfigurables;

/**
* Creates an instance of the Predicate class.
Expand All @@ -65,21 +66,31 @@
data,
configurableConstants,
}: PredicateParams<TData, TConfigurables>) {
const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
bytecode,
abi,
configurableConstants
);
const { predicateBytes, predicateInterface } = Predicate.processPredicateData(bytecode, abi);
const address = Address.fromB256(getPredicateRoot(predicateBytes));
super(address, provider);

this.bytes = predicateBytes;
this.interface = predicateInterface;
if (data !== undefined && data.length > 0) {

if (configurableConstants && Object.keys(configurableConstants).length) {
this.configurableConstants = configurableConstants;
}
if (data && data.length) {
this.predicateData = data;
}
}

/**
* Updates parameters of predicate
*
* @param params - Object containing optional new configurableConstants and data
*/
setParams(params: { configurableConstants?: TConfigurables; data?: TData }) {
this.predicateData = params.data ?? this.predicateData;
this.configurableConstants = params.configurableConstants ?? this.configurableConstants;
}

/**
* Populates the transaction data with predicate data.
*
Expand All @@ -100,7 +111,13 @@
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
if (isRequestInputResourceFromOwner(input, this.address)) {
// eslint-disable-next-line no-param-reassign
input.predicate = hexlify(this.bytes);
input.predicate = hexlify(
this.setConfigurableConstants(
this.bytes,
this.configurableConstants ?? {},
this.interface
)
);
// eslint-disable-next-line no-param-reassign
input.predicateData = hexlify(this.getPredicateData());
// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -152,15 +169,10 @@
*
* @param bytes - The bytes of the predicate.
* @param jsonAbi - The JSON ABI of the predicate.
* @param configurableConstants - Optional configurable constants for the predicate.
* @returns An object containing the new predicate bytes and interface.
*/
private static processPredicateData(
bytes: BytesLike,
jsonAbi: JsonAbi,
configurableConstants?: { [name: string]: unknown }
) {
private static processPredicateData(bytes: BytesLike, jsonAbi: JsonAbi) {
let predicateBytes = arrayify(bytes);

Check failure on line 175 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / Lint

'predicateBytes' is never reassigned. Use 'const' instead
const abiInterface: Interface = new Interface(jsonAbi);

if (abiInterface.functions.main === undefined) {
Expand All @@ -170,14 +182,6 @@
);
}

if (configurableConstants && Object.keys(configurableConstants).length) {
predicateBytes = Predicate.setConfigurableConstants(
predicateBytes,
configurableConstants,
abiInterface
);
}

return {
predicateBytes,
predicateInterface: abiInterface,
Expand All @@ -202,7 +206,9 @@
);
return resources.map((resource) => ({
...resource,
predicate: hexlify(this.bytes),
predicate: hexlify(
this.setConfigurableConstants(this.bytes, this.configurableConstants ?? {}, this.interface)
),
predicateData: hexlify(this.getPredicateData()),
}));
}
Expand All @@ -216,11 +222,41 @@
override generateFakeResources(coins: FakeResources[]): Array<Resource> {
return super.generateFakeResources(coins).map((coin) => ({
...coin,
predicate: hexlify(this.bytes),
predicate: hexlify(
this.setConfigurableConstants(this.bytes, this.configurableConstants ?? {}, this.interface)
),
predicateData: hexlify(this.getPredicateData()),
}));
}

/**
*
* @param account - The account used to pay the deployment costs.
* @returns The _blobId_ and a _waitForResult_ callback that returns the deployed predicate
* once the blob deployment transaction finishes.
*
* The returned loader predicate will have the same configurable constants
* as the original predicate which was used to generate the loader predicate.
*/
async deploy<T = this>(account: Account) {
return deployScriptOrPredicate<T>({
deployer: account,
abi: this.interface.jsonAbi,
bytecode: this.setConfigurableConstants(
this.bytes,
this.configurableConstants ?? {},
this.interface
),
loaderInstanceCallback: (loaderBytecode, newAbi) =>
new Predicate({
bytecode: loaderBytecode,
abi: newAbi,
provider: this.provider,
data: this.predicateData,
}) as T,
});
}

/**
* Sets the configurable constants for the predicate.
*
Expand All @@ -229,7 +265,7 @@
* @param abiInterface - The ABI interface of the predicate.
* @returns The mutated bytes with the configurable constants set.
*/
private static setConfigurableConstants(
private setConfigurableConstants(
bytes: Uint8Array,
configurableConstants: { [name: string]: unknown },
abiInterface: Interface
Expand Down Expand Up @@ -259,7 +295,7 @@
mutatedBytes.set(encoded, offset);
});
} catch (err) {
throw new FuelError(

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

apps/demo-typegen/src/demo.test.ts > Example predicate

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ DemoPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ DemoPredicate.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ DemoPredicate.getTransactionCost packages/account/src/account.ts:594:66 ❯ DemoPredicate.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ DemoPredicate.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/blob-deploy.test.ts > deploying blobs > deploying existing predicate blob doesn't throw

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTrue.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ PredicateTrue.deploy packages/account/src/predicate/predicate.ts:245:22 ❯ packages/fuel-gauge/src/blob-deploy.test.ts:265:28 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/bytes.test.ts > Bytes Tests > should test bytes input [predicate-bytes]

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateBytes.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateBytes.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateBytes.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateBytes.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateBytes.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/contract.test.ts > Contract > should tranfer asset to a deployed contract just fine (FROM PREDICATE)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTrue.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateTrue.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateTrue.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateTrue.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateTrue.batchTransferToContracts packages/account/src/account.ts:485:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/doc-examples.test.ts > Doc Examples > can create a predicate and use

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTripleSig.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateTripleSig.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateTripleSig.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateTripleSig.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateTripleSig.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/edge-cases.test.ts > Edge Cases > Submitting a failing transaction via submitAndAwaitStatus subscription throws immediately

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateFalse.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateFalse.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateFalse.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateFalse.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateFalse.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/fee.test.ts > Fee > should ensure fee is properly calculated on transactions with predicate

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateU32.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateU32.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateU32.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateU32.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateU32.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/min-gas.test.ts > Minimum gas tests > sets gas requirements (predicate)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ ComplexPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ ComplexPredicate.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ ComplexPredicate.getTransactionCost packages/account/src/account.ts:594:66 ❯ packages/fuel-gauge/src/min-gas.test.ts:142:36 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@18

packages/fuel-gauge/src/min-gas.test.ts > Minimum gas tests > sets gas requirements (account and predicate with script)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ ComplexPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:210:14 ❯ ComplexPredicate.getResourcesToSpend packages/account/src/predicate/predicate.ts:207:22 ❯ packages/fuel-gauge/src/min-gas.test.ts:194:32 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

apps/demo-typegen/src/demo.test.ts > Example predicate

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ DemoPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ DemoPredicate.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ DemoPredicate.getTransactionCost packages/account/src/account.ts:594:66 ❯ DemoPredicate.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ DemoPredicate.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/blob-deploy.test.ts > deploying blobs > deploying existing predicate blob doesn't throw

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTrue.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ PredicateTrue.deploy packages/account/src/predicate/predicate.ts:245:22 ❯ packages/fuel-gauge/src/blob-deploy.test.ts:265:28 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/bytes.test.ts > Bytes Tests > should test bytes input [predicate-bytes]

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateBytes.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateBytes.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateBytes.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateBytes.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateBytes.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/contract.test.ts > Contract > should tranfer asset to a deployed contract just fine (FROM PREDICATE)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTrue.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateTrue.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateTrue.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateTrue.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateTrue.batchTransferToContracts packages/account/src/account.ts:485:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/doc-examples.test.ts > Doc Examples > can create a predicate and use

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTripleSig.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateTripleSig.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateTripleSig.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateTripleSig.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateTripleSig.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/edge-cases.test.ts > Edge Cases > Submitting a failing transaction via submitAndAwaitStatus subscription throws immediately

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateFalse.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateFalse.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateFalse.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateFalse.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateFalse.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/fee.test.ts > Fee > should ensure fee is properly calculated on transactions with predicate

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateU32.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateU32.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateU32.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateU32.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateU32.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/min-gas.test.ts > Minimum gas tests > sets gas requirements (predicate)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ ComplexPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ ComplexPredicate.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ ComplexPredicate.getTransactionCost packages/account/src/account.ts:594:66 ❯ packages/fuel-gauge/src/min-gas.test.ts:142:36 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@20

packages/fuel-gauge/src/min-gas.test.ts > Minimum gas tests > sets gas requirements (account and predicate with script)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ ComplexPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:210:14 ❯ ComplexPredicate.getResourcesToSpend packages/account/src/predicate/predicate.ts:207:22 ❯ packages/fuel-gauge/src/min-gas.test.ts:194:32 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

apps/demo-typegen/src/demo.test.ts > Example predicate

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ DemoPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ DemoPredicate.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ DemoPredicate.getTransactionCost packages/account/src/account.ts:594:66 ❯ DemoPredicate.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ DemoPredicate.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/blob-deploy.test.ts > deploying blobs > deploying existing predicate blob doesn't throw

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTrue.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ PredicateTrue.deploy packages/account/src/predicate/predicate.ts:245:22 ❯ packages/fuel-gauge/src/blob-deploy.test.ts:265:28 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/bytes.test.ts > Bytes Tests > should test bytes input [predicate-bytes]

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateBytes.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateBytes.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateBytes.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateBytes.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateBytes.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/contract.test.ts > Contract > should tranfer asset to a deployed contract just fine (FROM PREDICATE)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTrue.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateTrue.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateTrue.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateTrue.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateTrue.batchTransferToContracts packages/account/src/account.ts:485:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/doc-examples.test.ts > Doc Examples > can create a predicate and use

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateTripleSig.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateTripleSig.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateTripleSig.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateTripleSig.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateTripleSig.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/edge-cases.test.ts > Edge Cases > Submitting a failing transaction via submitAndAwaitStatus subscription throws immediately

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateFalse.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateFalse.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateFalse.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateFalse.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateFalse.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/fee.test.ts > Fee > should ensure fee is properly calculated on transactions with predicate

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ PredicateU32.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ PredicateU32.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ PredicateU32.getTransactionCost packages/account/src/account.ts:594:66 ❯ PredicateU32.estimateAndFundTransaction packages/account/src/account.ts:715:31 ❯ PredicateU32.createTransfer packages/account/src/account.ts:350:26 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/min-gas.test.ts > Minimum gas tests > sets gas requirements (predicate)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ ComplexPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:226:14 ❯ ComplexPredicate.generateFakeResources packages/account/src/predicate/predicate.ts:223:47 ❯ updateAssetInput packages/account/src/account.ts:584:16 ❯ packages/account/src/account.ts:595:7 ❯ ComplexPredicate.getTransactionCost packages/account/src/account.ts:594:66 ❯ packages/fuel-gauge/src/min-gas.test.ts:142:36 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }

Check failure on line 298 in packages/account/src/predicate/predicate.ts

View workflow job for this annotation

GitHub Actions / node@22

packages/fuel-gauge/src/min-gas.test.ts > Minimum gas tests > sets gas requirements (account and predicate with script)

FuelError: Error setting configurable constants: Predicate has no configurable constants to be set. ❯ ComplexPredicate.setConfigurableConstants packages/account/src/predicate/predicate.ts:298:13 ❯ packages/account/src/predicate/predicate.ts:210:14 ❯ ComplexPredicate.getResourcesToSpend packages/account/src/predicate/predicate.ts:207:22 ❯ packages/fuel-gauge/src/min-gas.test.ts:194:32 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { VERSIONS: { FORC: '0.66.4', FUEL_CORE: '0.40.1', FUELS: '0.97.0' }, metadata: {}, rawError: null, code: 'invalid-configurable-constants', toObject: 'Function<toObject>' }
ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
`Error setting configurable constants: ${(<Error>err).message}.`
);
Expand Down Expand Up @@ -306,28 +342,4 @@

return index;
}

/**
*
* @param account - The account used to pay the deployment costs.
* @returns The _blobId_ and a _waitForResult_ callback that returns the deployed predicate
* once the blob deployment transaction finishes.
*
* The returned loader predicate will have the same configurable constants
* as the original predicate which was used to generate the loader predicate.
*/
async deploy<T = this>(account: Account) {
return deployScriptOrPredicate<T>({
deployer: account,
abi: this.interface.jsonAbi,
bytecode: this.bytes,
loaderInstanceCallback: (loaderBytecode, newAbi) =>
new Predicate({
bytecode: loaderBytecode,
abi: newAbi,
provider: this.provider,
data: this.predicateData,
}) as T,
});
}
}
8 changes: 7 additions & 1 deletion packages/account/test/fixtures/predicate-abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ export const predicateAbi: JsonAbi = {
],
loggedTypes: [],
messagesTypes: [],
configurables: [],
configurables: [
{
name: 'value',
concreteTypeId: 'b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903',
offset: 0,
},
],
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { InputValue, BigNumberish, WalletUnlocked, Predicate } from 'fuels';
import { ScriptTransactionRequest, BN } from 'fuels';

export const fundPredicate = async <T extends InputValue[]>(
export const fundPredicate = async <
T extends InputValue[] = InputValue[],
C extends { [name: string]: unknown } | undefined = { [name: string]: unknown },
>(
wallet: WalletUnlocked,
predicate: Predicate<T>,
predicate: Predicate<T, C>,
amountToPredicate: BigNumberish,
utxosAmount: number = 1
): Promise<BN> => {
Expand Down
2 changes: 1 addition & 1 deletion templates/nextjs/src/components/Predicate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function Predicate() {
successNotification,
} = useNotification();
useNotification();
const [predicate, setPredicate] = useState<FuelPredicate<InputValue[]>>();
const [predicate, setPredicate] = useState<FuelPredicate<InputValue[], undefined>>();
const [predicatePin, setPredicatePin] = useState<string>();
const [isLoading, setIsLoading] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion templates/vite/src/components/Predicate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Predicate() {
transactionSuccessNotification,
successNotification,
} = useNotification();
const [predicate, setPredicate] = useState<FuelPredicate<InputValue[]>>();
const [predicate, setPredicate] = useState<FuelPredicate<InputValue[], undefined>>();
const [predicatePin, setPredicatePin] = useState<string>();
const [isLoading, setIsLoading] = useState(false);

Expand Down
Loading