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

Release v0.24.1 #316

Open
wants to merge 2 commits into
base: release
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ concurrency:
env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
RUST_VERSION: 1.80.1
FORC_VERSION: 0.63.3
CORE_VERSION: 0.34.0
RUST_VERSION: 1.83.0
FORC_VERSION: 0.66.2
CORE_VERSION: 0.40.0

jobs:
build-sway-lib:
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ name: Docs

on:
pull_request:
paths:
- docs/**

jobs:
test:
spell-check:
name: Spell Check
uses: FuelLabs/github-actions/.github/workflows/mdbook-docs.yml@master
with:
docs-src-path: 'docs/book/src'
spellcheck-config-path: 'docs/book/.spellcheck.yml'

docs-src-path: "docs/book/src"
spellcheck-config-path: "docs/book/.spellcheck.yml"

link-check:
name: Link Check
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- uses: gaurav-nelson/[email protected]
with:
configuration-path: "docs/book/.markdown-link-check.json"
6 changes: 3 additions & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on:
- v*

env:
RUST_VERSION: 1.80.1
FORC_VERSION: 0.63.3
CORE_VERSION: 0.34.0
RUST_VERSION: 1.83.0
FORC_VERSION: 0.66.2
CORE_VERSION: 0.40.0

jobs:
deploy-contributing:
Expand Down
31 changes: 28 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

Description of the upcoming release here.

### Added

- Something new here 1
Expand All @@ -24,11 +22,38 @@ Description of the upcoming release here.
- Some fix here 1
- Some fix here 2

#### Breaking
### Breaking

- Some breaking change here 1
- Some breaking change here 2

## [Version 0.24.1]

### Added v0.24.1

- [#309](https://github.com/FuelLabs/sway-libs/pull/309) Adds fallback function test cases to the Reentrancy Guard Library.
- [#310](https://github.com/FuelLabs/sway-libs/pull/310) Adds proxy tests cases to the Reentrancy Guard Library.

### Changed v0.24.1

- [#305](https://github.com/FuelLabs/sway-libs/pull/305) Updates to forc `v0.66.2`, fuel-core `v0.40.0`, and fuels-rs `v0.66.9`.
- [#306](https://github.com/FuelLabs/sway-libs/pull/306) Updates the SRC-7 naming to Onchain Native Asset Metadata Standard.
- [#308](https://github.com/FuelLabs/sway-libs/pull/308) Removes comments on Cross-Contract Reentrancy vulnerability.
- [#314](https://github.com/FuelLabs/sway-libs/pull/314) Prepares for the v0.24.1 release.
- [#317](https://github.com/FuelLabs/sway-libs/pull/317) Updates the CI rust version to v1.83.0.

### Fixed v0.24.1

- [#297](https://github.com/FuelLabs/sway-libs/pull/297) Fixes docs anchor in basic SRC-7 example.
- [#298](https://github.com/FuelLabs/sway-libs/pull/298) Fixes the README headers on Upgradability Libraries from an `h2` to an `h4`.
- [#302](https://github.com/FuelLabs/sway-libs/pull/302) Fixes typos in documentation.
- [#303](https://github.com/FuelLabs/sway-libs/pull/304) Fixes links in the Upgradability Library documenation.
- [#311](https://github.com/FuelLabs/sway-libs/pull/311) Fixes links in README.

#### Breaking v0.24.1

- None

## [Version 0.24.0]

### Added v0.24.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "sway-libs"
version = "0.24.0"
version = "0.24.1"
edition = "2021"
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ For implementation details on the libraries please see the [Sway Libs Docs](http

#### Math

- [Signed Integers](https://docs.fuel.network/docs/sway-libs/queue/) is an interface to implement signed integers.
- [Signed Integers](https://docs.fuel.network/docs/sway-libs/signed_integers/) is an interface to implement signed integers.

> **NOTE:**
> The Fixed Point Number library has been deprecated pending a re-write.
Expand All @@ -66,7 +66,7 @@ For implementation details on the libraries please see the [Sway Libs Docs](http

- [Queue](https://docs.fuel.network/docs/sway-libs/queue/) is a linear data structure that provides First-In-First-Out (FIFO) operations.

## Upgradability Libraries
#### Upgradability Libraries

- [Upgradability](https://docs.fuel.network/docs/sway-libs/upgradability/) provides functions that can be used to implement contract upgrades via simple upgradable proxies.

Expand All @@ -75,7 +75,7 @@ For implementation details on the libraries please see the [Sway Libs Docs](http
To import a library, the following dependency should be added to the project's `Forc.toml` file under `[dependencies]`.

```rust
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" }
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.1" }
```

> **NOTE:**
Expand All @@ -97,7 +97,7 @@ For more information about implementation please refer to the [Sway Libs Docs Hu

## Running Tests

There are two sets of tests that should be run: inline tests and sdk-harness tests. Please make sure you are using `forc v0.63.3` and `fuel-core v0.34.0`. You can check what version you are using by running the `fuelup show` command.
There are two sets of tests that should be run: inline tests and sdk-harness tests. Please make sure you are using `forc v0.66.2` and `fuel-core v0.40.0`. You can check what version you are using by running the `fuelup show` command.

Make sure you are in the source directory of this repository `sway-libs/<you are here>`.

Expand All @@ -119,7 +119,7 @@ forc test --path tests --release --locked && cargo test --manifest-path tests/Ca
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.63.3`, `fuels-rs v0.66.2` and `fuel-core v0.34.0`.
> All projects currently use `forc v0.66.2`, `fuels-rs v0.66.9` and `fuel-core v0.40.0`.

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion docs/book/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,5 @@ StorageMetadata
functionly
verifiably
upgradable
upgradability
upgradability
Onchain
2 changes: 1 addition & 1 deletion docs/book/src/asset/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following ABI and functions are also provided to set your [SRC-20](https://d

## Setting Up Storage

Once imported, the Asset Library's base functionality should be available. To use them, be sure to add the storage block bellow to your contract which enables the [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) standard.
Once imported, the Asset Library's base functionality should be available. To use them, be sure to add the storage block below to your contract which enables the [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) standard.

```sway
{{#include ../../../../examples/asset/base_docs/src/main.sw:src20_storage}}
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/asset/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ The [SRC-3; Mint and Burn Standard](https://docs.fuel.network/docs/sway-standard

## [SRC-7 Functionality](./metadata.md)

The [SRC-7; Arbitrary Asset Metadata Standard](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) prescribes an ABI for metadata associated with Native Assets on the Fuel Network. The Asset Library's [metadata](./metadata.md) section supports the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/)'s implementation.
The [SRC-7; Onchain Asset Metadata Standard](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) prescribes an ABI for stateful metadata associated with Native Assets on the Fuel Network. The Asset Library's [metadata](./metadata.md) section supports the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/)'s implementation.
68 changes: 3 additions & 65 deletions docs/book/src/asset/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To import the Asset Library Base Functionality and [SRC-7](https://docs.fuel.net

## Integration with the SRC-7 Standard

The [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) definition states that the following abi implementation is required for any Native Asset on Fuel:
The [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) definition states that the following abi implementation is required for any Native Asset on Fuel which uses stateful metadata:

```sway
{{#include ../../../../examples/asset/metadata_docs/src/main.sw:src7_abi}}
Expand All @@ -24,20 +24,9 @@ The Asset Library has the following complimentary data type for the [SRC-7](http

- `StorageMetadata`

The following additional functionality for the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/)'s `Metadata` type is provided:

- `as_string()`
- `is_string()`
- `as_u64()`
- `is_u64()`
- `as_bytes()`
- `is_bytes()`
- `as_b256()`
- `is_b256()`

## Setting Up Storage

Once imported, the Asset Library's metadata functionality should be available. To use them, be sure to add the storage block bellow to your contract which enables the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standard.
Once imported, the Asset Library's metadata functionality should be available. To use them, be sure to add the storage block below to your contract which enables the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standard.

```sway
{{#include ../../../../examples/asset/metadata_docs/src/main.sw:src7_storage}}
Expand All @@ -59,59 +48,8 @@ The `_set_metadata()` function follows the SRC-7 standard for logging and will e

### Implementing the SRC-7 Standard with StorageMetadata

To use the `StorageMetadata` type, simply get the stored metadata with the associated `key` and `AssetId`. The example below shows the implementation of the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standard in combination with the Asset Library's `StorageMetadata` type with no user defined restrictions or custom functionality.
To use the `StorageMetadata` type, simply get the stored metadata with the associated `key` and `AssetId` using the provided `_metadata()` convenience function. The example below shows the implementation of the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standard in combination with the Asset Library's `StorageMetadata` type and the `_metadata()` function with no user defined restrictions or custom functionality.

```sway
{{#include ../../../../examples/asset/basic_src7/src/main.sw:basic_src7}}
```

## Using the `Metadata` Extensions

The `Metadata` type defined by the [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standard can be one of 4 states:

```sway
pub enum Metadata {
B256: b256,
Bytes: Bytes,
Int: u64,
String: String,
}
```

The Asset Library enables the following functionality for the `Metadata` type:

### `is_b256()` and `as_b256()`

The `is_b256()` check enables checking whether the `Metadata` type is a `b256`.
The `as_b256()` returns the `b256` of the `Metadata` type.

```sway
{{#include ../../../../examples/asset/metadata_docs/src/main.sw:as_b256}}
```

### `is_bytes()` and `as_bytes()`

The `is_bytes()` check enables checking whether the `Metadata` type is a `Bytes`.
The `as_bytes()` returns the `Bytes` of the `Metadata` type.

```sway
{{#include ../../../../examples/asset/metadata_docs/src/main.sw:as_bytes}}
```

### `is_u64()` and `as_u64()`

The `is_u64()` check enables checking whether the `Metadata` type is a `u64`.
The `as_u64()` returns the `u64` of the `Metadata` type.

```sway
{{#include ../../../../examples/asset/metadata_docs/src/main.sw:as_u64}}
```

### `is_string()` and `as_string()`

The `is_string()` check enables checking whether the `Metadata` type is a `String`.
The `as_string()` returns the `String` of the `Metadata` type.

```sway
{{#include ../../../../examples/asset/basic_src7/src/main.sw:src7_metadata_convenience_function}}
```
4 changes: 2 additions & 2 deletions docs/book/src/asset/supply.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ The Asset Library has the following complimentary functions for each function in

## Setting Up Storage

Once imported, the Asset Library's supply functionality should be available. To use them, be sure to add the storage block bellow to your contract which enables the [SRC-3](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standard.
Once imported, the Asset Library's supply functionality should be available. To use them, be sure to add the storage block below to your contract which enables the [SRC-3](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standard.

```sway
{{#include ../../../../examples/asset/supply_docs/src/main.sw:src3_storage}}
```

## Implementing the SRC-3 Standard with the Asset Library

To use either function, simply pass the `StorageKey` from the prescribed storage block. The example below shows the implementation of the [SRC-3](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standard in combination with the Asset Library with no user defined restrictions or custom functionality. It is recommended that the [Ownership Library](../ownership/index.md) is used in conjunction with the Asset Library;s supply functionality to ensure only a single user has permissions to mint an Asset.
To use either function, simply pass the `StorageKey` from the prescribed storage block. The example below shows the implementation of the [SRC-3](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standard in combination with the Asset Library with no user defined restrictions or custom functionality. It is recommended that the [Ownership Library](../ownership/index.md) is used in conjunction with the Asset Library's supply functionality to ensure only a single user has permissions to mint an Asset.

The `_mint()` and `_burn()` functions follows the SRC-20 standard for logging and will emit the `TotalSupplyEvent` when called.

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/bytecode/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To verify a contract's bytecode root you may call `verify_bytecode_root()` or `v

### Computing the Address from Bytecode

To compute a predicates's address you may call the `compute_predicate_address()` or `compute_predicate_address_with_configurables()` functions.
To compute a predicate's address you may call the `compute_predicate_address()` or `compute_predicate_address_with_configurables()` functions.

```sway
{{#include ../../../../examples/bytecode/src/main.sw:compute_predicate_address}}
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
To import any library, the following dependency should be added to the project's `Forc.toml` file under `[dependencies]`.

```sway
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" }
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.1" }
```

For reference, here is a complete `Forc.toml` file:
Expand All @@ -18,7 +18,7 @@ license = "Apache-2.0"
name = "MyProject"

[dependencies]
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" }
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.1" }
```

> **NOTE:** Be sure to set the tag to the latest release.
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The purpose of Sway Libraries is to contain libraries which users can import and use that are not part of the standard library.

There are several types of libraries that Sway Libs encompases. These include libraries that provide convenience functions, [Sway-Standards](https://github.com/FuelLabs/sway-standards) supporting libraries, data type libraries, security functionality libraries, and other tools valuable to blockchain development.
There are several types of libraries that Sway Libs encompasses. These include libraries that provide convenience functions, [Sway-Standards](https://github.com/FuelLabs/sway-standards) supporting libraries, data type libraries, security functionality libraries, and other tools valuable to blockchain development.

For implementation details on the libraries please see the [Sway Libs Docs](https://fuellabs.github.io/sway-libs/master/sway_libs/).

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/pausable/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ When developing a contract, you may want to lock functions down to a specific st

It is highly recommended to integrate the [Ownership Library](../ownership/index.md) with the Pausable Library and apply restrictions the `pause()` and `unpause()` functions. This will ensure that only a single user may pause and unpause a contract in cause of emergency. Failure to apply this restriction will allow any user to obstruct a contract's functionality.

The follow example implements the `Pausable` abi and applies restrictions to it's pause/unpause functions. The owner of the contract must be set in an constructor defined by `MyConstructor` in this example.
The follow example implements the `Pausable` abi and applies restrictions to it's pause/unpause functions. The owner of the contract must be set in a constructor defined by `MyConstructor` in this example.

```sway
{{#include ../../../../examples/pausable/pausable_with_ownership/src/main.sw:impl_with_ownership}}
Expand Down
11 changes: 5 additions & 6 deletions docs/book/src/reentrancy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

The Reentrancy Guard Library provides an API to check for and disallow reentrancy on a contract. A reentrancy attack happens when a function is externally invoked during its execution, allowing it to be run multiple times in a single transaction.

The reentrancy check is used to check if a contract ID has been called more than
once in the current call stack.
The reentrancy check is used to check if a contract ID has been called more than once in the current call stack.

A reentrancy, or "recursive call" attack can cause some functions to behave in unexpected ways. This can be prevented by asserting a contract has not yet been called in the current transaction. An example can be found [here](https://swcregistry.io/docs/SWC-107).

For implementation details on the Reentrancy Guard Library please see the [Sway Libs Docs](https://fuellabs.github.io/sway-libs/master/sway_libs/reentrancy/index.html).

## Known Issues

While this can protect against both single-function reentrancy and cross-function reentrancy attacks, it WILL NOT PREVENT a cross-contract reentrancy attack.

## Importing the Reentrancy Guard Library

In order to use the Reentrancy Guard library, Sway Libs must be added to the `Forc.toml` file and then imported into your Sway project. To add Sway Libs as a dependency to the `Forc.toml` file in your project please see the [Getting Started](../getting_started/index.md).
Expand Down Expand Up @@ -45,3 +40,7 @@ To check if the current caller is a reentrant, you may call the `is_reentrant()`
```sway
{{#include ../../../../examples/reentrancy/src/main.sw:is_reentrant}}
```

## Cross Contract Reentrancy

Cross-Contract Reentrancy is not possible on Fuel due to the use of Native Assets. As such, no contract calls are performed when assets are transferred. However standard security practices when relying on other contracts for state should still be applied, especially when making external calls.
2 changes: 1 addition & 1 deletion docs/book/src/signed_integers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To import the Signed Integer Number Library to your Sway Smart Contract, add the
{{#include ../../../../examples/signed_integers/src/main.sw:import}}
```

In order to use the any of the Signed Integer types, import them into your Sway project like so:
In order to use any of the Signed Integer types, import them into your Sway project like so:

```sway
{{#include ../../../../examples/signed_integers/src/main.sw:import_8}}
Expand Down
Loading
Loading