Skip to content

feat: add support for dynamic configurables #3702

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

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6a0c413
chore: update version
petertonysmith94 Feb 5, 2025
cc2afe9
chore: updated templates
petertonysmith94 Feb 5, 2025
30d9b6e
chore: update types
petertonysmith94 Feb 6, 2025
b31a523
chore: added dynamic configurable test for predicates
petertonysmith94 Feb 7, 2025
4017959
chore: enable backwards compatible ABI
petertonysmith94 Feb 7, 2025
7d8c7a6
chore: added method to Interface to getCoder by concreteTypeId
petertonysmith94 Feb 7, 2025
e00ef7e
feat: added function for reading configurables
petertonysmith94 Feb 7, 2025
babab58
feat: added writer for direct configurables
petertonysmith94 Feb 7, 2025
749e5e1
feat: added configurables encapulation
petertonysmith94 Feb 12, 2025
97e1f67
feat: use configurables with predicate
petertonysmith94 Feb 12, 2025
71dc830
chore: shuffle around configurable wrapper
petertonysmith94 Feb 12, 2025
f1c7c9e
feat: implement contract configurables
petertonysmith94 Feb 12, 2025
89b2c89
feat: implement script configurables
petertonysmith94 Feb 12, 2025
38c6ce6
chore: added `isBytecodeLoader`
petertonysmith94 Feb 13, 2025
f7d0798
chore: refactor the loader instruction set
petertonysmith94 Feb 13, 2025
ea690e8
feat: added method to extract the correct data offset and blob ID
petertonysmith94 Feb 18, 2025
63e50ac
feat: use the correct data offset for configurables
petertonysmith94 Feb 18, 2025
105b0c7
chore: reintroduce configurable constant error handling
petertonysmith94 Feb 18, 2025
712e61d
WIP changes
petertonysmith94 Feb 18, 2025
b845d63
Merge branch 'master' of github.com:FuelLabs/fuels-ts into ps/feat/ad…
petertonysmith94 Jun 12, 2025
901f529
Removed sway patch
petertonysmith94 Jun 16, 2025
ca2a9d5
Updated typegen templates
petertonysmith94 Jun 16, 2025
bac6e16
Skip reverts
petertonysmith94 Jun 16, 2025
5454174
Fixing test cases
petertonysmith94 Jun 16, 2025
c3a1632
Moving tests to correct place
petertonysmith94 Jun 18, 2025
557f941
Added the ability to get all configurables from bytecode
petertonysmith94 Jun 18, 2025
4d7a490
lintfix
petertonysmith94 Jun 18, 2025
38dc85a
Removed empty test
petertonysmith94 Jun 18, 2025
819aa35
Use correct configurable constants
petertonysmith94 Jun 18, 2025
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
2 changes: 1 addition & 1 deletion internal/forc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.68.7
git:xunilrj/dynamic-types-configurables
23 changes: 10 additions & 13 deletions packages/abi-coder/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { arrayify } from '@fuel-ts/utils';

import { AbiCoder } from './AbiCoder';
import { FunctionFragment } from './FunctionFragment';
import type { DecodedValue, InputValue } from './encoding/coders/AbstractCoder';
import type { Coder, DecodedValue, InputValue } from './encoding/coders/AbstractCoder';
import type { JsonAbiArgument, JsonAbiOld } from './types/JsonAbi';
import type { Configurable, JsonAbi } from './types/JsonAbiNew';
import { type EncodingVersion } from './utils/constants';
Expand Down Expand Up @@ -88,26 +88,23 @@ export class Interface {
});
}

encodeType(concreteTypeId: string, value: InputValue): Uint8Array {
getCoder(concreteTypeId: string): Coder {
const typeArg = parseConcreteType(
this.jsonAbi,
this.jsonAbiOld.types,
concreteTypeId,
''
) as JsonAbiArgument;
return AbiCoder.encode(this.jsonAbiOld, typeArg, value, {
encoding: this.encoding,
});
return AbiCoder.getCoder(this.jsonAbiOld, typeArg, { encoding: this.encoding });
}

decodeType(concreteTypeId: string, data: Uint8Array): [DecodedValue | undefined, number] {
const typeArg = parseConcreteType(
this.jsonAbi,
this.jsonAbiOld.types,
concreteTypeId,
''
) as JsonAbiArgument;
encodeType(concreteTypeId: string, value: InputValue): Uint8Array {
const coder = this.getCoder(concreteTypeId);
return coder.encode(value);
}

return AbiCoder.decode(this.jsonAbiOld, typeArg, data, 0, { encoding: this.encoding });
decodeType(concreteTypeId: string, data: Uint8Array): [DecodedValue | undefined, number] {
const coder = this.getCoder(concreteTypeId);
return coder.decode(data, 0) as [DecodedValue | undefined, number];
}
}
1 change: 1 addition & 0 deletions packages/abi-coder/src/types/JsonAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ export interface JsonAbiConfigurable {
name: string;
configurableType: JsonAbiArgument;
offset: number;
indirect?: boolean;
}
1 change: 1 addition & 0 deletions packages/abi-coder/src/types/JsonAbiNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface Configurable {
readonly name: string;
readonly concreteTypeId: string;
readonly offset: number;
readonly indirect?: boolean;
}

export interface ErrorPosition {
Expand Down
1 change: 1 addition & 0 deletions packages/abi-coder/src/utils/transpile-abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function transpileAbi(abi) {
name: conf.name,
configurableType: parseConcreteType(abi, types, conf.concreteTypeId),
offset: conf.offset,
indirect: conf.indirect ?? false,
}));

// 5. loggedTypes
Expand Down
1 change: 1 addition & 0 deletions packages/abi-typegen/src/types/interfaces/JsonAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface JsonAbiConfigurable {
name: string;
configurableType: JsonAbiArgument;
offset: number;
indirect?: boolean;
}

export interface JsonAbiErrorCode {
Expand Down
1 change: 1 addition & 0 deletions packages/abi-typegen/src/types/interfaces/JsonAbiNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface Configurable {
readonly name: string;
readonly concreteTypeId: string;
readonly offset: number;
readonly indirect?: boolean;
}

export interface ErrorPosition {
Expand Down
1 change: 1 addition & 0 deletions packages/abi-typegen/src/utils/transpile-abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function transpileAbi(abi) {
name: conf.name,
configurableType: parseConcreteType(abi, types, conf.concreteTypeId),
offset: conf.offset,
indirect: conf.indirect ?? false,
}));

// 5. loggedTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ const abi = {
],
"functions": [
{
"name": "main",
"inputs": [
{
"name": "x",
Expand All @@ -150,6 +149,7 @@ const abi = {
"concreteTypeId": "338a25cb65b9251663dcce6362b744fe10aa849758299590f4efed5dd299bf50"
}
],
"name": "main",
"output": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903",
"attributes": null
}
Expand All @@ -175,8 +175,7 @@ const abi = {
"offset": 2384,
"indirect": false
}
],
"errorCodes": {}
]
};

const storageSlots: StorageSlot[] = [];
Expand Down
Loading
Loading