Skip to content

Commit a5d9d28

Browse files
SwayStar123sdankelironcev
authored
Merge std and core libraries (#6729)
## Description Merges the two libraries. They were initially separate to separate the core logic and fuel vm specific functionality, but that separation is no longer maintained so having a merged library is better. Closes #6708 ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Sophie <47993817+sdankel@users.noreply.github.com> Co-authored-by: Igor Rončević <ironcev@hotmail.com>
1 parent a165145 commit a5d9d28

File tree

1,357 files changed

+4400
-6659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,357 files changed

+4400
-6659
lines changed

.github/CODEOWNERS

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
# Sway files and standard library
88
/examples/ @FuelLabs/sway-compiler @FuelLabs/swayex
9-
/sway-lib-core/ @FuelLabs/sway-compiler @FuelLabs/swayex
109
/sway-lib-std/ @FuelLabs/sway-compiler @FuelLabs/swayex
1110

1211
# Tooling

.github/workflows/ci.yml

-45
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ env:
2121
jobs:
2222
verifications-complete:
2323
needs:
24-
- build-sway-lib-core
2524
- build-sway-lib-std
2625
- build-sway-examples
2726
- build-reference-examples
28-
- forc-fmt-check-sway-lib-core
2927
- forc-fmt-check-sway-lib-std
3028
- forc-fmt-check-sway-examples
3129
- forc-fmt-check-panic
@@ -76,22 +74,6 @@ jobs:
7674
version=$(toml get Cargo.toml workspace.dependencies.fuel-core-client.version | tr -d '"')
7775
echo "version=$version" >> "$GITHUB_OUTPUT"
7876
79-
build-sway-lib-core:
80-
runs-on: buildjet-4vcpu-ubuntu-2204
81-
steps:
82-
- uses: actions/checkout@v3
83-
- name: Install toolchain
84-
uses: dtolnay/rust-toolchain@master
85-
with:
86-
toolchain: ${{ env.RUST_VERSION }}
87-
- uses: Swatinem/rust-cache@v2
88-
with:
89-
cache-provider: "buildjet"
90-
- name: Install Forc
91-
run: cargo install --locked --debug --path ./forc
92-
- name: Build sway-lib-core
93-
run: forc build --path sway-lib-core
94-
9577
build-sway-lib-std:
9678
runs-on: buildjet-4vcpu-ubuntu-2204
9779
steps:
@@ -136,20 +118,6 @@ jobs:
136118
- name: Build Sway examples workspace
137119
run: cargo run --locked -p forc -- build --locked --path ./docs/reference/src/code/Forc.toml
138120

139-
forc-fmt-check-sway-lib-core:
140-
runs-on: buildjet-4vcpu-ubuntu-2204
141-
steps:
142-
- uses: actions/checkout@v3
143-
- name: Install toolchain
144-
uses: dtolnay/rust-toolchain@master
145-
with:
146-
toolchain: ${{ env.RUST_VERSION }}
147-
- uses: Swatinem/rust-cache@v2
148-
with:
149-
cache-provider: "buildjet"
150-
- name: Check Sway sway-lib-core formatting
151-
run: cargo run --locked -p forc-fmt -- --check --path ./sway-lib-core
152-
153121
forc-fmt-check-sway-lib-std:
154122
runs-on: buildjet-4vcpu-ubuntu-2204
155123
steps:
@@ -553,16 +521,6 @@ jobs:
553521
cache-provider: "buildjet"
554522
- name: Install Forc
555523
run: cargo install --locked --debug --path ./forc
556-
- name: Run Core Unit Tests
557-
run: forc build --path sway-lib-core && forc test --path sway-lib-core
558-
- name: Run Core Unit Tests - Experimental feature 'storage_domains'
559-
run: forc build --experimental storage_domains --path sway-lib-core && forc test --experimental storage_domains --path sway-lib-core
560-
- name: Run Core Unit Tests - Experimental feature 'error_type'
561-
run: forc build --experimental error_type --path sway-lib-core && forc test --experimental error_type --path sway-lib-core
562-
- name: Run Core Unit Tests - Experimental feature 'partial_eq'
563-
run: forc build --experimental partial_eq --path sway-lib-core && forc test --experimental partial_eq --path sway-lib-core
564-
- name: Run Core Unit Tests - Experimental feature 'try_from_bytes_for_b256'
565-
run: forc build --experimental try_from_bytes_for_b256 --path sway-lib-core && forc test --experimental try_from_bytes_for_b256 --path sway-lib-core
566524
- name: Run Std Unit Tests
567525
run: forc build --path sway-lib-std && forc test --path sway-lib-std
568526
- name: Run Std Unit Tests - Experimental feature 'storage_domains'
@@ -744,7 +702,6 @@ jobs:
744702
[
745703
build-forc-test-project,
746704
build-sway-examples,
747-
build-sway-lib-core,
748705
build-sway-lib-std,
749706
cargo-build-workspace,
750707
cargo-clippy,
@@ -809,7 +766,6 @@ jobs:
809766
[
810767
build-forc-test-project,
811768
build-sway-examples,
812-
build-sway-lib-core,
813769
build-sway-lib-std,
814770
cargo-build-workspace,
815771
cargo-clippy,
@@ -858,7 +814,6 @@ jobs:
858814
[
859815
build-forc-test-project,
860816
build-sway-examples,
861-
build-sway-lib-core,
862817
build-sway-lib-std,
863818
cargo-build-workspace,
864819
cargo-clippy,

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ target
99
# These are backup files generated by rustfmt
1010
**/*.rs.bk
1111

12-
# `core` and `std` are libs, no need to commit their lock files.
13-
sway-lib-core/Forc.lock
12+
# `std` is a lib, no need to commit its lock file.
1413
sway-lib-std/Forc.lock
1514

1615
# Forc's build directory

ci_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ cargo install --locked --debug --path ./forc-plugins/forc-client &&
3131
cargo install --locked --debug --path ./forc-plugins/forc-tx &&
3232
cargo install --locked --debug forc-explore &&
3333
cargo install --locked --debug --path ./scripts/mdbook-forc-documenter &&
34-
forc build --path sway-lib-core &&
35-
forc test --path sway-lib-core &&
3634
forc build --path sway-lib-std &&
3735
forc test --path sway-lib-std &&
3836
cargo run --locked -p forc -- build --locked --path ./examples/Forc.toml &&

docs/book/spell-check-custom-words.txt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ BrowserStack
1313
CLI
1414
Deserialization
1515
deserializing
16+
deserialization
1617
DApp
1718
intrinsics
1819
Intrinsics

docs/book/src/SUMMARY.md

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
- [The Fuel Toolchain](./introduction/fuel_toolchain.md)
88
- [A Forc Project](./introduction/forc_project.md)
99
- [Standard Library](./introduction/standard_library.md)
10-
- [Core Library](./introduction/core_library.md)
1110
- [Sway Language Standards](./introduction/sway_standards.md)
1211
- [Examples](./examples/index.md)
1312
- [Counter](./examples/counter.md)

docs/book/src/advanced/traits.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The above snippet declares all of the methods in the trait `Compare` for the typ
3535
## Supertraits
3636

3737
When using multiple traits, scenarios often come up where one trait may require functionality from another trait. This is where supertraits come in as they allow you to require a trait when implementing another trait, i.e., a trait with a trait.
38-
A good example of this is the `Ord` trait of the `core` library of Sway. The `Ord` trait requires the `Eq` trait, so `Eq` is kept as a separate trait as one may decide to implement `Eq`
38+
A good example of this is the `Ord` trait of the `std` library of Sway. The `Ord` trait requires the `Eq` trait, so `Eq` is kept as a separate trait as one may decide to implement `Eq`
3939
without implementing other parts of the `Ord` trait.
4040

4141
```sway
@@ -169,7 +169,7 @@ fn panic_with_error<E>(err: E) where E: Error {
169169

170170
> **Note** `panic` expression and error types [have not yet been implemented](https://github.com/FuelLabs/sway/issues/6765)
171171
172-
All marker traits are defined in the `core::marker` module.
172+
All marker traits are defined in the `std::marker` module.
173173

174174
## Use Cases
175175

docs/book/src/forc/manifest_reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ In the example above, `std` is patched with the `test` branch from `std` repo. Y
238238
std = { path = "/path/to/local_std_version" }
239239
```
240240

241-
Just like `std` or `core` you can also patch dependencies you declared with a git repo.
241+
Just like `std` you can also patch dependencies you declared with a git repo.
242242

243243
```toml
244244
[project]

docs/book/src/introduction/core_library.md

-30
This file was deleted.

docs/book/src/introduction/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ To get started with Forc and Sway smart contract development, install the Fuel t
66
- [The Fuel Toolchain](./fuel_toolchain.md)
77
- [A Forc Project](./forc_project.md)
88
- [Standard Library](./standard_library.md)
9-
- [Core Library](./core_library.md)
109
- [Sway Language Standards](./sway_standards.md)

docs/book/src/introduction/standard_library.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The current version of the prelude lives in [`std::prelude`](https://github.com/
3535
- [`std::contract_id::ContractId`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/contract_id.sw), a wrapper around the `b256` type representing the ID of a contract.
3636
- [`std::identity::Identity`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/identity.sw), an enum with two possible variants: `Address: Address` and `ContractId: ContractId`.
3737
- [`std::vec::Vec`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/vec.sw), a growable, heap-allocated vector.
38-
- [`std::storage::storage_key::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage/storage_key.sw), contains the API for accessing a `core::storage::StorageKey` which describes a location in storage.
38+
- [`std::storage::storage_key::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage/storage_key.sw), contains the API for accessing a `std::storage::StorageKey` which describes a location in storage.
3939
- [`std::storage::storage_map::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage/storage_map.sw), a key-value mapping in contract storage.
4040
- [`std::option::Option`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/option.sw), an enum which expresses the presence or absence of a value.
4141
- [`std::result::Result`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/result.sw), an enum for functions that may succeed or fail.
@@ -46,4 +46,11 @@ The current version of the prelude lives in [`std::prelude`](https://github.com/
4646
- [`std::revert::revert`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/revert.sw), a function that reverts the VM.
4747
- [`std::logging::log`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/logging.sw), a function that logs arbitrary stack types.
4848
- [`std::auth::msg_sender`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/auth.sw), a function that gets the `Identity` from which a call was made.
49+
- [`std::primitives::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/primitives.sw), methods on primitive types.
50+
- [`std::primitive_conversions::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/primitive_conversions.sw), methods for converting between primitive types.
51+
- [`std::raw_ptr::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/raw_ptr.sw), functions for working with raw pointers.
52+
- [`std::raw_slice::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/raw_slice.sw), functions for working with raw slices.
53+
- [`std::ops::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/ops.sw), mathematical operations such as addition, subtraction, multiplication, and division.
54+
- [`std::str::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/str.sw), methods for working with strings.
55+
- [`std::codec::*`](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/codec.sw), automatic serialization and deserialization of types.
4956
<!-- prelude:example:end -->

docs/book/src/testing/testing-with-rust.md

-2
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,8 @@ ABI, storage and bytecode artifacts are available. We can do so with `forc build
9898
```console
9999
$ forc build
100100
Creating a new `Forc.lock` file. (Cause: lock file did not exist)
101-
Adding core
102101
Adding std git+https://github.com/fuellabs/sway?tag=v0.24.5#e695606d8884a18664f6231681333a784e623bc9
103102
Created new lock file at /home/user/path/to/my-fuel-project/Forc.lock
104-
Compiled library "core".
105103
Compiled library "std".
106104
Compiled contract "my-fuel-project".
107105
Bytecode size is 60 bytes.

docs/book/src/testing/unit-testing.md

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ forc test
3333
The output should look similar to this:
3434

3535
```console
36-
Compiled library "core".
3736
Compiled library "std".
3837
Compiled library "lib_single_test".
3938
Bytecode size is 92 bytes.

docs/reference/src/code/Forc.lock

+2-13
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ name = "control_flow"
7070
source = "member"
7171
dependencies = ["std"]
7272

73-
[[package]]
74-
name = "core"
75-
source = "path+from-root-0F28276288D2432C"
76-
7773
[[package]]
7874
name = "counter"
7975
source = "member"
@@ -127,10 +123,7 @@ dependencies = ["std"]
127123
[[package]]
128124
name = "intermediate_variables"
129125
source = "member"
130-
dependencies = [
131-
"core",
132-
"std",
133-
]
126+
dependencies = ["std"]
134127

135128
[[package]]
136129
name = "letter_casing"
@@ -163,10 +156,7 @@ dependencies = ["std"]
163156
[[package]]
164157
name = "namespace"
165158
source = "member"
166-
dependencies = [
167-
"core",
168-
"std",
169-
]
159+
dependencies = ["std"]
170160

171161
[[package]]
172162
name = "numerics"
@@ -201,7 +191,6 @@ dependencies = ["std"]
201191
[[package]]
202192
name = "std"
203193
source = "path+from-root-0F28276288D2432C"
204-
dependencies = ["core"]
205194

206195
[[package]]
207196
name = "storage_init"

docs/reference/src/code/language/control_flow/src/lib.sw

-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ fn nested_match(input: TopLevel) -> u64 {
151151
// ANCHOR_END: nested_enum_match
152152

153153
// ANCHOR: complex_multi_arg_enum_match
154-
use core::ops::Eq;
155-
156154
enum Binary {
157155
True: (),
158156
False: (),

docs/reference/src/code/language/style-guide/intermediate_variables/Forc.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ license = "Apache-2.0"
55
name = "intermediate_variables"
66

77
[dependencies]
8-
core = { path = "../../../../../../../sway-lib-core" }
98
std = { path = "../../../../../../../sway-lib-std" }

docs/reference/src/code/operations/namespace/Forc.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ license = "Apache-2.0"
55
name = "namespace"
66

77
[dependencies]
8-
core = { path = "../../../../../../sway-lib-core" }
98
std = { path = "../../../../../../sway-lib-std" }

docs/slides/encoding.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contract.some_method(0);
3131
Compiler will desugar this into
3232

3333
```rust
34-
core::codec::contract_call(
34+
std::codec::contract_call(
3535
CONTRACT_ID,
3636
"some_method",
3737
(0,),
@@ -108,9 +108,9 @@ Compiler will desugar this into:
108108

109109
```rust
110110
pub fn __entry() {
111-
let method_name = core::codec::decode_first_param::<str>();
111+
let method_name = std::codec::decode_first_param::<str>();
112112
if method_name == "some_method" {
113-
let mut buffer = core::codec::BufferReader::from_second_parameter();
113+
let mut buffer = std::codec::BufferReader::from_second_parameter();
114114
let args: (u64,) = buffer.decode::<(u64,)>();
115115
let result: () = __contract_entry_some_method(args.0);
116116
let result: raw_slice = encode::<()>(result);
@@ -398,7 +398,7 @@ will be desugared into something like
398398
const SOMETHING: u64;
399399

400400
fn __entry() -> raw_slice {
401-
core::codec::abi_decode_in_place(&mut SOMETHING, 7104, 8);
401+
std::codec::abi_decode_in_place(&mut SOMETHING, 7104, 8);
402402
encode(main())
403403
}
404404

0 commit comments

Comments
 (0)