Skip to content

Commit

Permalink
Bump repo (#128)
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:

- Bumped Libs to forc v0.37.0
- Bumped Standards to forc v0.37.0
- Bumped Tests to forc v0.37.0
- Bumped Contributing Book to forc v0.37.0
- Bumped CI to forc v0.37.0
- Bumped CI to rust v1.68.2

## Notes

- Please note the restructuring that has occurred due to the
implementation of `mod` over `dep`, specifically in the NFT and
Ownership libraries.
- Due to FuelLabs/sway#4408 portions of the
tests for the String library have been commented out.

## Related Issues

<!--Delete everything after the "#" symbol and replace it with a number.
No spaces between hash and number-->

Closes #127

---------

Co-authored-by: bitzoic <[email protected]>
  • Loading branch information
bitzoic and bitzoic authored Apr 11, 2023
1 parent 2e25453 commit f6bb5c2
Show file tree
Hide file tree
Showing 66 changed files with 614 additions and 504 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library bad_documentation;
library;

// ANCHOR: data_structures
// This is bad. It's repeating the names of the fields which can be easily read
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library data_structures;
library;

pub struct Game {
player_one: Player,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library errors;
library;

// ANCHOR: error
pub enum MoveError {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library events;
library;

// ANCHOR: event
pub struct WinnerEvent {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// ANCHOR: interface
library interface;
library;

dep data_structures;

use data_structures::{Game, Player};
use ::data_structures::{Game, Player};

abi ConnectFour {
/// Creates a new game
Expand Down
4 changes: 2 additions & 2 deletions .docs/contributing-book/src/code/connect_four/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
contract;

dep data_structures;
dep interface;
mod data_structures;
mod interface;

use data_structures::{Game, Player};
use interface::ConnectFour;
Expand Down
6 changes: 2 additions & 4 deletions .docs/contributing-book/src/code/connect_four/src/utils.sw
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
library utils;
library;

dep data_structures;

use data_structures::Game;
use ::data_structures::Game;

pub fn validate_move(column: u64, game: Game) -> bool {
true
Expand Down
2 changes: 1 addition & 1 deletion .docs/contributing-book/src/code/style_guide/src/lib.sw
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ANCHOR: module
library style_guide;
library;
// ANCHOR_END: module
// ANCHOR: const
const MAXIMUM_DEPOSIT = 10;
Expand Down
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.67.0
FORC_VERSION: 0.35.3
CORE_VERSION: 0.17.3
RUST_VERSION: 1.68.2
FORC_VERSION: 0.37.0
CORE_VERSION: 0.17.8
PATH_TO_SCRIPTS: .github/scripts

jobs:
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.35.3" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.35.3-orange" />
<a href="https://crates.io/crates/forc/0.37.0" alt="forc">
<img src="https://img.shields.io/badge/forc-v0.37.0-orange" />
</a>
<a href="./LICENSE" alt="forc">
<img src="https://img.shields.io/github/license/FuelLabs/sway-libs" />
Expand Down Expand Up @@ -87,7 +87,7 @@ 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.35.3`, `fuels-rs v0.36.1` and `fuel-core 0.17.3`.
> All projects currently use `forc v0.37.0`, `fuels-rs v0.36.1` and `fuel-core 0.17.8`.
## Contributing

Expand Down
2 changes: 1 addition & 1 deletion libs/fixed_point/src/ifp128.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library ifp128;
library;
// A wrapper library around the type for mathematical functions operating with signed 128-bit fixed point numbers.
use std::math::{Exponent, Power, Root};
use ::ufp64::UFP64;
Expand Down
2 changes: 1 addition & 1 deletion libs/fixed_point/src/ifp256.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library ifp256;
library;
// A wrapper library around the type for mathematical functions operating with signed 256-bit fixed point numbers.
use std::math::{Exponent, Power, Root};
use ::ufp128::UFP128;
Expand Down
2 changes: 1 addition & 1 deletion libs/fixed_point/src/ifp64.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library ifp64;
library;
// A wrapper library around the u32 type for mathematical functions operating with signed 64-bit fixed point numbers.
use std::math::*;
use ::ufp32::UFP32;
Expand Down
14 changes: 7 additions & 7 deletions libs/fixed_point/src/lib.sw
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
library fixed_point;
library;

dep ufp32;
dep ufp64;
dep ufp128;
mod ufp32;
mod ufp64;
mod ufp128;

dep ifp64;
dep ifp128;
dep ifp256;
mod ifp64;
mod ifp128;
mod ifp256;
2 changes: 1 addition & 1 deletion libs/fixed_point/src/ufp128.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library ufp128;
library;
// A wrapper around U128 type for a library for Sway for mathematical functions operating with signed 64.64-bit fixed point numbers.
use std::{math::{Exponent, Power, Root}, u128::U128, u256::U256};

Expand Down
4 changes: 2 additions & 2 deletions libs/fixed_point/src/ufp32.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library ufp32;
library;
// A wrapper library around the u32 type for mathematical functions operating with signed 32-bit fixed point numbers.
use std::math::*;

Expand Down Expand Up @@ -211,7 +211,7 @@ impl Root for UFP32 {
/// Sqaure root for UFP32
fn sqrt(self) -> Self {
let nominator_root = self.value.sqrt();
// Need to multiply over 2 ^ 16, as the square root of the denominator
// Need to multiply over 2 ^ 16, as the square root of the denominator
// is also taken and we need to ensure that the denominator is constant
let nominator = nominator_root << 16;
Self {
Expand Down
4 changes: 2 additions & 2 deletions libs/fixed_point/src/ufp64.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library ufp64;
library;
// A wrapper library around the u64 type for mathematical functions operating with signed 64-bit fixed point numbers.
use std::{math::{Exponent, Power, Root}, u128::U128};

Expand Down Expand Up @@ -211,7 +211,7 @@ impl Root for UFP64 {
/// Sqaure root for UFP64
fn sqrt(self) -> Self {
let nominator_root = self.value.sqrt();
// Need to multiply over 2 ^ 16, as the square root of the denominator
// Need to multiply over 2 ^ 16, as the square root of the denominator
// is also taken and we need to ensure that the denominator is constant
let nominator = nominator_root << 16;
Self {
Expand Down
2 changes: 1 addition & 1 deletion libs/merkle_proof/src/binary_merkle_proof.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library binary_merkle_proof;
library;

use std::{bytes::Bytes, hash::sha256};

Expand Down
4 changes: 2 additions & 2 deletions libs/merkle_proof/src/lib.sw
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library merkle_proof;
library;

dep binary_merkle_proof;
mod binary_merkle_proof;
6 changes: 6 additions & 0 deletions libs/nft/src/extensions.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library;

mod administrator;
mod burnable;
mod supply;
mod token_metadata;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
library administrator;
library;

dep administrator_errors;
dep administrator_events;
mod administrator_errors;
mod administrator_events;

use administrator_errors::AdminError;
use administrator_events::AdminEvent;
use ::nft_storage::ADMIN;
use std::{auth::msg_sender, logging::log, storage::{get, store}};
use ::nft_core::nft_storage::ADMIN;
use std::{auth::msg_sender, storage::{get, store}};

abi Administrator {
#[storage(read)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library administrator_errors;
library;

pub enum AdminError {
SenderNotAdmin: (),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library administrator_events;
library;

pub struct AdminEvent {
/// The user which is now the admin of this contract.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
library burnable;
library;

dep burnable_events;
mod burnable_events;

use burnable_events::BurnEvent;
use ::{errors::{AccessError, InputError}, nft_core::NFTCore, nft_storage::{BALANCES, TOKENS}};
use std::{auth::msg_sender, hash::sha256, logging::log, storage::{get, store}};
use ::nft_core::{errors::{AccessError, InputError}, nft_storage::{BALANCES, TOKENS}, NFTCore};
use std::{auth::msg_sender, hash::sha256, storage::{get, store}};

abi Burn {
#[storage(read, write)]
Expand Down
2 changes: 1 addition & 1 deletion libs/nft/src/extensions/burnable/burnable_events.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library burnable_events;
library;

pub struct BurnEvent {
/// The user that has burned their token.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
library supply;
library;

dep supply_errors;
dep supply_events;
mod supply_errors;
mod supply_events;

use ::nft_storage::MAX_SUPPLY;
use std::{logging::log, storage::{get, store}};
use ::nft_core::nft_storage::MAX_SUPPLY;
use std::storage::{get, store};
use supply_errors::SupplyError;
use supply_events::SupplyEvent;

Expand Down
2 changes: 1 addition & 1 deletion libs/nft/src/extensions/supply/supply_errors.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library supply_errors;
library;

pub enum SupplyError {
CannotReinitializeSupply: (),
Expand Down
2 changes: 1 addition & 1 deletion libs/nft/src/extensions/supply/supply_events.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library supply_events;
library;

pub struct SupplyEvent {
/// The new supply amount that has been set.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
library token_metadata;
library;

dep token_metadata_structures;
mod token_metadata_structures;

use token_metadata_structures::NFTMetadata;
use ::{errors::InputError, nft_core::NFTCore, nft_storage::{TOKEN_METADATA, TOKENS}};
use ::nft_core::{errors::InputError, nft_storage::{TOKEN_METADATA, TOKENS}, NFTCore};
use std::{hash::sha256, storage::{get, store}};

pub trait TokenMetadata<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library token_metadata_structures;
library;

pub struct NFTMetadata {
// This is left as an example. Support for StorageVec in struct is needed here.
Expand Down
31 changes: 16 additions & 15 deletions libs/nft/src/lib.sw
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
library nft;
library;

// TODO: Move these into alphabetical order once https://github.com/FuelLabs/sway/issues/409 is resolved
dep nft_storage;
dep nft_core;
dep errors;
dep events;
dep extensions/administrator/administrator;
dep extensions/burnable/burnable;
dep extensions/token_metadata/token_metadata;
dep extensions/supply/supply;

use errors::InputError;
use events::OperatorEvent;
use nft_core::NFTCore;
use nft_storage::{BALANCES, OPERATOR_APPROVAL, TOKENS, TOKENS_MINTED};
use std::{auth::msg_sender, hash::sha256, logging::log, storage::{get, store}};
mod nft_core;
mod extensions;

use nft_core::{
errors::InputError,
events::OperatorEvent,
nft_storage::{
BALANCES,
OPERATOR_APPROVAL,
TOKENS,
TOKENS_MINTED,
},
NFTCore,
};
use std::{auth::msg_sender, hash::sha256, storage::{get, store}};

abi NFT {
#[storage(read, write)]
Expand Down
10 changes: 5 additions & 5 deletions libs/nft/src/nft_core.sw
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
library nft_core;
library;

dep errors;
dep events;
dep nft_storage;
mod errors;
mod events;
mod nft_storage;

use errors::{AccessError, InputError};
use events::{ApprovalEvent, MintEvent, OperatorEvent, TransferEvent};
use std::{auth::msg_sender, hash::sha256, logging::log, storage::{get, store}};
use std::{auth::msg_sender, hash::sha256, storage::{get, store}};
use nft_storage::{BALANCES, OPERATOR_APPROVAL, TOKENS, TOKENS_MINTED};

pub struct NFTCore {
Expand Down
2 changes: 1 addition & 1 deletion libs/nft/src/errors.sw → libs/nft/src/nft_core/errors.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library errors;
library;

pub enum AccessError {
OwnerDoesNotExist: (),
Expand Down
2 changes: 1 addition & 1 deletion libs/nft/src/events.sw → libs/nft/src/nft_core/events.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library events;
library;

pub struct ApprovalEvent {
/// The user that has gotten approval to transfer the specified token.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library nft_storage;
library;

// TODO: These are temporary storage keys for manual storage management. These should be removed once
// https://github.com/FuelLabs/sway/issues/2585 is resolved.
Expand Down
2 changes: 1 addition & 1 deletion libs/ownership/Forc.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "lib.sw"
entry = "ownable.sw"
license = "Apache-2.0"
name = "ownership"
2 changes: 1 addition & 1 deletion libs/ownership/src/data_structures.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library data_structures;
library;

pub enum State {
Uninitialized: (),
Expand Down
2 changes: 1 addition & 1 deletion libs/ownership/src/errors.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library errors;
library;

pub enum AccessError {
CannotReinitialized: (),
Expand Down
2 changes: 1 addition & 1 deletion libs/ownership/src/events.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library events;
library;

pub struct OwnershipRenounced {
previous_owner: Identity,
Expand Down
3 changes: 0 additions & 3 deletions libs/ownership/src/lib.sw

This file was deleted.

Loading

0 comments on commit f6bb5c2

Please sign in to comment.