Skip to content

Commit

Permalink
Update to forc v0.60.0 (#250)
Browse files Browse the repository at this point in the history
## Type of change

<!--Delete points that do not apply-->

- Improvement (refactoring, restructuring repository, cleaning tech
debt, ...)

## Changes

The following changes have been made:

- Updates the repository to use forc v0.60.0
- Makes fields in signed integers and fixed point numbers private
- Adds `Self::zero()`, `self::is_zero()`, and `self::underlying()` to
signed integers and fixed point numbers

# Breaking Changes

Public struct fields are now PRIVATE in the `fixed_point` and
`signed_integers` libraries. If the fields are needed, they can be
fetched with a corresponding `my_type.underlying()` function. For
example, `I8`'s underlying `u8` may be fetched with:

```sway
let my_i8: I8 = I8::zero();
let underlying: u8 = my_i8.underlying();
```

For types that have a `non_negative` field, the same applies:

```sway
let my_ifp64: IFP64 = IFP64::zero();
let non_negative: bool = my_ifp64.non_negative();
```
  • Loading branch information
bitzoic authored May 31, 2024
1 parent 26eb820 commit cc09dae
Show file tree
Hide file tree
Showing 62 changed files with 1,037 additions and 502 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
RUST_VERSION: 1.77.0
FORC_VERSION: 0.56.0
CORE_VERSION: 0.24.2
FORC_VERSION: 0.60.0
CORE_VERSION: 0.26.0

jobs:
build-sway-lib:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:

env:
RUST_VERSION: 1.77.0
FORC_VERSION: 0.56.0
CORE_VERSION: 0.24.2
FORC_VERSION: 0.60.0
CORE_VERSION: 0.26.0

jobs:
deploy-contributing:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<a href="https://github.com/FuelLabs/sway-libs/actions/workflows/ci.yml" alt="CI">
<img src="https://github.com/FuelLabs/sway-libs/actions/workflows/ci.yml/badge.svg" />
</a>
<a href="https://crates.io/crates/forc/0.49.1" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.49.1-orange" />
<a href="https://crates.io/crates/forc/0.60.0" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.60.0-orange" />
</a>
<a href="./LICENSE" alt="forc">
<img src="https://img.shields.io/github/license/FuelLabs/sway-libs" />
Expand Down Expand Up @@ -115,7 +115,7 @@ forc test && cargo test
Any instructions related to using a specific library should be found within the README.md of that library.

> **NOTE:**
> All projects currently use `forc v0.53.0`, `fuels-rs v0.53.0` and `fuel-core 0.23.0`.
> All projects currently use `forc v0.60.0`, `fuels-rs v0.62.0` and `fuel-core 0.26.0`.
## Contributing

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sway_libs::ownership::only_owner;
```

> **NOTE:**
> All projects currently use `forc v0.50.0`, `fuels-rs v0.53.0` and `fuel-core 0.22.0`.
> All projects currently use `forc v0.60.0`, `fuels-rs v0.62.0` and `fuel-core 0.26.0`.
## Using Sway Libs

Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "Apache-2.0"
[dependencies]
fuel-merkle = { version = "0.49.0" }
sha2 = { version = "0.10" }
fuels = { version = "0.58.0", features = ["fuel-core-lib"] }
fuels = { version = "0.62.0", features = ["fuel-core-lib"] }
tokio = { version = "1.12", features = ["rt", "macros"] }

[[test]]
Expand Down
2 changes: 1 addition & 1 deletion examples/admin/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "admin_examples"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/base_docs/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "base_docs"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/basic_src20/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "basic_src20"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/basic_src3/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "basic_src3"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/basic_src7/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "basic_src7"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/metadata_docs/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "metadata_docs"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/setting_src20_attributes/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "setting_src20_attributes"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/setting_src7_attributes/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "setting_src7_attributes"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/asset/supply_docs/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "supply_docs"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../../libs" }
2 changes: 1 addition & 1 deletion examples/merkle/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ANCHOR: import
use fuel_merkle::{binary::in_memory::MerkleTree, common::Bytes32};
use fuel_merkle::binary::in_memory::MerkleTree;
// ANCHOR_END: import
use fuels::{prelude::*, types::Bits256};
use sha2::{Digest, Sha256};
Expand Down
2 changes: 1 addition & 1 deletion examples/ownership/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ license = "Apache-2.0"
name = "ownership_examples"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
sway_libs = { path = "../../libs" }
2 changes: 1 addition & 1 deletion libs/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "sway_libs"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
4 changes: 2 additions & 2 deletions libs/src/asset/metadata.sw
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl Metadata {
/// # Examples
///
/// ```sway
/// use std::{constants::ZERO_B256, string::String};
/// use std::string::String;
/// use sway_libs::asset::metadata::*;
/// use standards::src7::{SRC7, Metadata};
///
Expand All @@ -358,7 +358,7 @@ impl Metadata {
/// let metadata = metadata_abi.metadata(asset, key);
///
/// let val = metadata.unwrap().as_b256();
/// assert(val != ZERO_B256);
/// assert(val != b256::zero());
/// }
/// ```
pub fn as_b256(self) -> Option<b256> {
Expand Down
10 changes: 5 additions & 5 deletions libs/src/asset/supply.sw
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ use std::{
///
/// ```sway
/// use sway_libs::asset::supply::_mint;
/// use std::{constants::ZERO_B256, context::balance_of};
/// use std::context::balance_of;
///
/// storage {
/// total_assets: u64 = 0,
/// total_supply: StorageMap<AssetId, u64> = StorageMap {},
/// }
///
/// fn foo(recipient: Identity) {
/// let recipient = Identity::ContractId(ContractId::from(ZERO_B256));
/// let asset_id = _mint(storage.total_assets, storage.total_supply, recipient, ZERO_B256, 100);
/// let recipient = Identity::ContractId(ContractId::zero());
/// let asset_id = _mint(storage.total_assets, storage.total_supply, recipient, SubId::zero(), 100);
/// assert(balance_of(recipient.as_contract_id(), asset_id), 100);
/// }
/// ```
Expand Down Expand Up @@ -106,15 +106,15 @@ pub fn _mint(
///
/// ```sway
/// use sway_libs::asset::supply::_burn;
/// use std::{call_frames::contract_id, constants::ZERO_B256, context::balance_of};
/// use std::{call_frames::contract_id, context::balance_of};
///
/// storage {
/// total_supply: StorageMap<AssetId, u64> = StorageMap {},
/// }
///
/// fn foo(asset_id: AssetId) {
/// assert(balance_of(contract_id(), asset_id) == 100);
/// _burn(storage.total_supply, ZERO_B256, 100);
/// _burn(storage.total_supply, SubId::zero(), 100);
/// assert(balance_of(contract_id(), asset_id) == 0);
/// }
/// ```
Expand Down
15 changes: 5 additions & 10 deletions libs/src/bytecode.sw
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use ::bytecode::utils::{_compute_bytecode_root, _predicate_address_from_root, _s
/// # Examples
///
/// ```sway
/// use std::constants::ZERO_B256;
/// use sway_libs::bytecode::compute_bytecode_root;
///
/// fn foo(my_bytecode: Vec<u8>) {
/// let bytecode_root = compute_bytecode_root(my_bytecode);
/// assert(bytecode_root != ZERO_B256);
/// assert(bytecode_root != b256::zero());
/// }
/// ```
pub fn compute_bytecode_root(bytecode: Vec<u8>) -> b256 {
Expand All @@ -45,13 +44,12 @@ pub fn compute_bytecode_root(bytecode: Vec<u8>) -> b256 {
/// # Examples
///
/// ```sway
/// use std::constants::ZERO_B256;
/// use sway_libs::bytecode::compute_bytecode_root_with_configurables;
///
/// fn foo(my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
/// let mut my_bytecode = my_bytecode;
/// let bytecode_root = compute_bytecode_root_with_configurables(my_bytecode, my_configurables);
/// assert(bytecode_root != ZERO_B256);
/// assert(bytecode_root != b256::zero());
/// }
/// ```
pub fn compute_bytecode_root_with_configurables(
Expand All @@ -76,12 +74,11 @@ pub fn compute_bytecode_root_with_configurables(
/// # Examples
///
/// ```sway
/// use std::constants::ZERO_B256;
/// use sway_libs::bytecode::compute_predicate_address;
///
/// fn foo(my_bytecode: Vec<u8>) {
/// let predicate_address = compute_predicate_address(my_bytecode);
/// assert(predicate_address != Address::from(ZERO_B256));
/// assert(predicate_address != Address::zero());
/// }
/// ```
pub fn compute_predicate_address(bytecode: Vec<u8>) -> Address {
Expand All @@ -103,13 +100,12 @@ pub fn compute_predicate_address(bytecode: Vec<u8>) -> Address {
/// # Examples
///
/// ```sway
/// use std::constants::ZERO_B256;
/// use sway_libs::bytecode::compute_predicate_address;
///
/// fn foo(my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
/// let mut my_bytecode = my_bytecode;
/// let predicate_address = compute_predicate_address(my_bytecode, my_configurables);
/// assert(predicate_address != Address::from(ZERO_B256));
/// assert(predicate_address != Address::zero());
/// }
/// ```
pub fn compute_predicate_address_with_configurables(
Expand All @@ -135,12 +131,11 @@ pub fn compute_predicate_address_with_configurables(
/// # Examples
///
/// ```sway
/// use std::constants::ZERO_B256;
/// use sway_libs::bytecode::predicate_address_from_root;
///
/// fn foo(predicate_bytecode_root: b256) {
/// let predicate_address = predicate_address_from_root(predicate_bytecode_root);
/// assert(predicate_address != Address::from(ZERO_B256));
/// assert(predicate_address != Address::zero());
/// }
/// ```
pub fn predicate_address_from_root(bytecode_root: b256) -> Address {
Expand Down
Loading

0 comments on commit cc09dae

Please sign in to comment.