Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
9879875
update fuel-abi-types
hal3e Dec 5, 2024
2ab1409
update
hal3e Dec 5, 2024
0f32147
Work in progress
hal3e Dec 6, 2024
8715d1c
feat!: add support for dynamic configurables
hal3e Dec 9, 2024
82412bc
update ciyml
hal3e Dec 10, 2024
4675e3f
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Dec 11, 2024
542d272
merge master
hal3e Dec 16, 2024
54a7842
refactor code
hal3e Dec 18, 2024
1fb0acb
refactor code
hal3e Dec 18, 2024
9f34af8
Work in progress
hal3e Jan 7, 2025
606d9fe
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Jan 7, 2025
692edea
fix fmt
hal3e Jan 7, 2025
3253173
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Jan 9, 2025
e42c91a
bump fuel-abi-types
hal3e Jan 16, 2025
94efe89
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Jan 16, 2025
9d8e166
forc fmt
hal3e Jan 16, 2025
1f3989d
fix typos
hal3e Jan 16, 2025
9decbcf
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Jan 27, 2025
b37ed25
updates
hal3e Jan 28, 2025
2991da7
fix todos
hal3e Jan 28, 2025
45238c2
small improvements
hal3e Jan 28, 2025
c5da416
merge master
hal3e Jan 28, 2025
1fdb690
Work in progress
hal3e Jan 29, 2025
b14b1c9
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Feb 3, 2025
a0aeffe
add tests
hal3e Feb 6, 2025
186137f
var names
hal3e Feb 6, 2025
11334ca
add documentation
hal3e Feb 6, 2025
9305b02
mdbook fix error
hal3e Feb 6, 2025
bd18d82
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Feb 6, 2025
58dc776
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Feb 10, 2025
033c4b4
feat: switch blob ID calculation from data offset to configurable off…
Salka1988 Feb 14, 2025
71c5f92
chore: update `forc` to `0.66.7` (#1596)
hal3e Feb 17, 2025
11d08e1
chore: update sway's counter example (#1601)
hal3e Feb 17, 2025
e1095cd
chore!: bump `fuel-core-*` versions (#1600)
segfault-magnet Feb 17, 2025
77fb33a
merge master
hal3e Feb 18, 2025
685e5dd
PR comments 1st version
hal3e Feb 18, 2025
3b64c60
refactor
hal3e Feb 18, 2025
110ae71
Merge branch 'master' into hal3e/dynamic-configurables
MujkicA Feb 24, 2025
dd0bc27
merge master
hal3e Feb 27, 2025
6d607cd
fix fee todos
hal3e Feb 27, 2025
b6dbd0a
remove dbg
hal3e Feb 27, 2025
fc9fc4e
Apply suggestions from code review
hal3e Feb 27, 2025
40afe0e
add fn docstring
hal3e Feb 27, 2025
da65b6c
merge master
hal3e Apr 11, 2025
b382e17
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Apr 11, 2025
7d1ee87
Merge branch 'master' into hal3e/dynamic-configurables
hal3e Apr 14, 2025
97fd0b8
work in progress
hal3e Apr 11, 2025
70c0be8
merge master
hal3e May 14, 2025
040a4d0
Merge branch 'master' into hal3e/dynamic-configurables
hal3e May 14, 2025
398588e
Merge branch 'master' into hal3e/dynamic-configurables
hal3e May 15, 2025
13d2317
add documentation
hal3e May 26, 2025
fa7cc9c
add docstring
hal3e May 26, 2025
5ca433d
pr comments
hal3e May 26, 2025
bf24659
fix spelling
hal3e May 26, 2025
1e0dc14
cargo fmt
hal3e May 26, 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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
FUEL_CORE_PATCH_REVISION: ""
RUST_VERSION: 1.85.0
FORC_VERSION: 0.68.0
FORC_PATCH_BRANCH: "ironcev/error-codes-in-abi-json"
FORC_PATCH_BRANCH: "xunilrj/dynamic-types-configurables"
FORC_PATCH_REVISION: ""
NEXTEST_HIDE_PROGRESS_BAR: "true"
NEXTEST_STATUS_LEVEL: "fail"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"examples/predicates",
"examples/providers",
"examples/rust_bindings",
"examples/scripts",
"examples/types",
"examples/wallets",
"packages/fuels",
Expand Down
22 changes: 21 additions & 1 deletion docs/src/deploying/configurable-constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,25 @@ In Sway, you can define `configurable` constants which can be changed during the
Each of the configurable constants will get a dedicated `with` method in the SDK. For example, the constant `STR_4` will get the `with_STR_4` method which accepts the same type as defined in the contract code. Below is an example where we chain several `with` methods and deploy the contract with the new constants.

```rust,ignore
{{#include ../../../e2e/tests/configurables.rs:contract_configurables}}
{{#include ../../../examples/contracts/src/lib.rs:contract_configurables}}
```

In addition to writing, you are able to read the configurable constants directly from the binary:

```rust,ignore
{{#include ../../../examples/contracts/src/lib.rs:contract_configurables_reader}}
```

If you need to manually read the configurable constants, you can use helper functions provided by the SDK.

```rust,ignore
{{#include ../../../e2e/tests/configurables.rs:manual_configurables}}
```

Similarly, you can read the configurable constants at runtime.

```rust,ignore
{{#include ../../../e2e/tests/configurables.rs:manual_runtime_configurables}}
```

> **Note:** when manually reading configurable constants make sure to call the appropriate method when dealing with static or dynamic configurables. For dynamic configurables use the `indirect` methods.
6 changes: 6 additions & 0 deletions docs/src/predicates/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ Each configurable constant will get a dedicated `with` method in the SDK. For ex
```rust,ignore
{{#include ../../../e2e/tests/predicates.rs:predicate_configurables}}
```

In addition to writing, you are able to read the configurable constants directly from the binary:

```rust,ignore
{{#include ../../../examples/predicates/src/lib.rs:predicate_configurables_reader}}
```
8 changes: 7 additions & 1 deletion docs/src/running-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ Same as contracts, you can define `configurable` constants in `scripts` which ca
Each configurable constant will get a dedicated `with` method in the SDK. For example, the constant `STR_4` will get the `with_STR_4` method which accepts the same type defined in sway. Below is an example where we chain several `with` methods and execute the script with the new constants.

```rust,ignore
{{#include ../../e2e/tests/configurables.rs:script_configurables}}
{{#include ../../examples/scripts/src/lib.rs:script_configurables}}
```

In addition to writing, you are able to read the configurable constants directly from the binary:

```rust,ignore
{{#include ../../examples/scripts/src/lib.rs:script_configurables_reader}}
```
2 changes: 2 additions & 0 deletions e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ fuel-tx = { workspace = true }
# used in test assertions
tai64 = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }
test-case = { workspace = true }

[build-dependencies]
anyhow = { workspace = true, features = ["std"] }
Expand Down
6 changes: 5 additions & 1 deletion e2e/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
'sway/contracts/auth_testing_abi',
'sway/contracts/auth_testing_contract',
'sway/contracts/block_timestamp',
'sway/contracts/dyn_configurables',
'sway/contracts/configurables',
'sway/contracts/contract_test',
'sway/contracts/huge_contract',
Expand Down Expand Up @@ -40,6 +41,7 @@ members = [
'sway/logs/script_with_contract_logs',
'sway/predicates/basic_predicate',
'sway/predicates/predicate_blobs',
'sway/predicates/predicate_dyn_configurables',
'sway/predicates/predicate_configurables',
'sway/predicates/predicate_witnesses',
'sway/predicates/signatures',
Expand All @@ -53,6 +55,7 @@ members = [
'sway/scripts/script_array',
'sway/scripts/script_asserts',
'sway/scripts/script_blobs',
'sway/scripts/script_dyn_configurables',
'sway/scripts/script_configurables',
'sway/scripts/script_enum',
'sway/scripts/script_needs_custom_decoder',
Expand Down Expand Up @@ -119,5 +122,6 @@ members = [
'sway/types/scripts/script_vectors',
]

#TODO: [issue](https://github.com/FuelLabs/fuels-rs/issues/1610)
[patch.'https://github.com/fuellabs/sway']
std = { git = "https://github.com/fuellabs/sway", branch = "ironcev/error-codes-in-abi-json" }
std = { git = "https://github.com/fuellabs/sway", branch = "xunilrj/dynamic-types-configurables" }
8 changes: 4 additions & 4 deletions e2e/sway/contracts/configurables/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ configurable {
U64: u64 = 63,
U256: u256 = 0x0000000000000000000000000000000000000000000000000000000000000008u256,
B256: b256 = 0x0101010101010101010101010101010101010101010101010101010101010101,
STR_4: str[4] = __to_str_array("fuel"),
STR: str = "fuel",
TUPLE: (u8, bool) = (8, true),
ARRAY: [u32; 3] = [253, 254, 255],
STRUCT: StructWithGeneric<u8> = StructWithGeneric {
Expand All @@ -31,11 +31,11 @@ configurable {
//U128: u128 = 128, //TODO: add once https://github.com/FuelLabs/sway/issues/5356 is done

abi TestContract {
fn return_configurables() -> (bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], StructWithGeneric<u8>, EnumWithGeneric<bool>);
fn return_configurables() -> (bool, u8, u16, u32, u64, u256, b256, str, (u8, bool), [u32; 3], StructWithGeneric<u8>, EnumWithGeneric<bool>);
}

impl TestContract for Contract {
fn return_configurables() -> (bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], StructWithGeneric<u8>, EnumWithGeneric<bool>) {
(BOOL, U8, U16, U32, U64, U256, B256, STR_4, TUPLE, ARRAY, STRUCT, ENUM)
fn return_configurables() -> (bool, u8, u16, u32, u64, u256, b256, str, (u8, bool), [u32; 3], StructWithGeneric<u8>, EnumWithGeneric<bool>) {
(BOOL, U8, U16, U32, U64, U256, B256, STR, TUPLE, ARRAY, STRUCT, ENUM)
}
}
5 changes: 5 additions & 0 deletions e2e/sway/contracts/dyn_configurables/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
name = "dyn_configurables"
20 changes: 20 additions & 0 deletions e2e/sway/contracts/dyn_configurables/src/main.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
contract;

configurable {
BOOL: bool = true,
U8: u8 = 8,
STR: str = "sway",
STR_2: str = "forc",
STR_3: str = "fuel",
LAST_U8: u8 = 16,
}

abi TestContract {
fn return_configurables() -> (bool, u8, str, str, str, u8);
}

impl TestContract for Contract {
fn return_configurables() -> (bool, u8, str, str, str, u8) {
(BOOL, U8, STR, STR_2, STR_3, LAST_U8)
}
}
5 changes: 5 additions & 0 deletions e2e/sway/predicates/predicate_dyn_configurables/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
name = "predicate_dyn_configurables"
21 changes: 21 additions & 0 deletions e2e/sway/predicates/predicate_dyn_configurables/src/main.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
predicate;

configurable {
BOOL: bool = true,
U8: u8 = 8,
STR: str = "sway",
STR_2: str = "forc",
STR_3: str = "fuel",
LAST_U8: u8 = 16,
}

fn main(
some_bool: bool,
some_u8: u8,
some_str: str,
some_str_2: str,
some_str_3: str,
some_last_u8: u8,
) -> bool {
some_bool == BOOL && some_u8 == U8 && some_str == STR && some_str_2 == STR_2 && some_str_3 == STR_3 && some_last_u8 == LAST_U8
}
5 changes: 5 additions & 0 deletions e2e/sway/scripts/script_dyn_configurables/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
name = "script_dyn_configurables"
14 changes: 14 additions & 0 deletions e2e/sway/scripts/script_dyn_configurables/src/main.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
script;

configurable {
BOOL: bool = true,
U8: u8 = 8,
STR: str = "sway",
STR_2: str = "forc",
STR_3: str = "fuel",
LAST_U8: u8 = 16,
}

fn main() -> (bool, u8, str, str, str, u8) {
(BOOL, U8, STR, STR_2, STR_3, LAST_U8)
}
2 changes: 2 additions & 0 deletions e2e/sway/scripts/script_struct/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ configurable {
number: 10,
boolean: true,
},
A_STR: str = "fuel",
A_NUMBER: u64 = 11,
}

Expand All @@ -15,5 +16,6 @@ struct MyStruct {

fn main(arg: MyStruct) -> u64 {
let _calc = MY_STRUCT.number + A_NUMBER;
let _b = A_STR;
if arg.boolean { arg.number } else { 0 }
}
Loading
Loading