From aa57c41fefb59364aa5c4859b8b053c54d487137 Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 12:38:38 +0545 Subject: [PATCH 1/7] Update to use Sway-Standards v0.6.1 --- NFT/NFT-contract/Forc.toml | 4 +-- NFT/NFT-contract/src/errors.sw | 1 + NFT/NFT-contract/src/main.sw | 28 +++++++++++++++--- NFT/NFT-contract/tests/utils/interface.rs | 2 +- fractional-NFT/f-NFT-contract/Forc.toml | 2 +- fractional-NFT/f-NFT-contract/src/main.sw | 29 +++++++++++++++++-- native-asset/native-asset-contract/Forc.toml | 4 +-- .../native-asset-contract/src/errors.sw | 1 + .../native-asset-contract/src/main.sw | 14 +++++++-- .../tests/utils/interface.rs | 2 +- 10 files changed, 70 insertions(+), 17 deletions(-) diff --git a/NFT/NFT-contract/Forc.toml b/NFT/NFT-contract/Forc.toml index badb84b1e..e0409639f 100644 --- a/NFT/NFT-contract/Forc.toml +++ b/NFT/NFT-contract/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "NFT-contract" [dependencies] -standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" } -sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" } +standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.1" } +sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" } diff --git a/NFT/NFT-contract/src/errors.sw b/NFT/NFT-contract/src/errors.sw index cecb62f39..52bc31177 100644 --- a/NFT/NFT-contract/src/errors.sw +++ b/NFT/NFT-contract/src/errors.sw @@ -4,6 +4,7 @@ pub enum MintError { CannotMintMoreThanOneNFTWithSubId: (), MaxNFTsMinted: (), NFTAlreadyMinted: (), + SubIdNone: (), } pub enum SetError { diff --git a/NFT/NFT-contract/src/main.sw b/NFT/NFT-contract/src/main.sw index 876c1e7ff..a89b62cf4 100644 --- a/NFT/NFT-contract/src/main.sw +++ b/NFT/NFT-contract/src/main.sw @@ -5,7 +5,7 @@ mod interface; use errors::{MintError, SetError}; use interface::Constructor; -use standards::{src20::SRC20, src3::SRC3, src5::{SRC5, State}, src7::{Metadata, SRC7},}; +use standards::{src20::{SetDecimalsEvent, SRC20}, src3::SRC3, src5::{SRC5, State}, src7::{Metadata, SRC7},}; use sway_libs::{ asset::{ base::{ @@ -232,12 +232,13 @@ impl SRC3 for Contract { /// # Arguments /// /// * `recipient`: [Identity] - The user to which the newly minted assets are transferred to. - /// * `sub_id`: [SubId] - The sub-identifier of the newly minted asset. + /// * `sub_id`: [Option] - The sub-identifier of the newly minted asset. /// * `amount`: [u64] - The quantity of coins to mint. /// /// # Reverts /// /// * When the contract is paused. + /// * When the `sub_id` is `None`. /// * When amount is greater than one. /// * When the asset has already been minted. /// * When more than the MAX_SUPPLY NFTs have been minted. @@ -258,11 +259,12 @@ impl SRC3 for Contract { /// } /// ``` #[storage(read, write)] - fn mint(recipient: Identity, sub_id: SubId, amount: u64) { + fn mint(recipient: Identity, sub_id: Option, amount: u64) { require_not_paused(); // Checks to ensure this is a valid mint. - let asset = AssetId::new(ContractId::this(), sub_id); + require(sub_id.is_some(), MintError::SubIdNone); + let asset = AssetId::new(ContractId::this(), sub_id.unwrap()); require(amount == 1, MintError::CannotMintMoreThanOneNFTWithSubId); require( storage @@ -281,6 +283,7 @@ impl SRC3 for Contract { ); // Mint the NFT + // NOTE: TotalSupplyEvent is emitted by _mint() let _ = _mint( storage .total_assets, @@ -331,6 +334,7 @@ impl SRC3 for Contract { #[storage(read, write)] fn burn(sub_id: SubId, amount: u64) { require_not_paused(); + // NOTE: TotalSupplyEvent is emitted by _burn() _burn(storage.total_supply, sub_id, amount); } } @@ -446,6 +450,7 @@ impl SetAssetAttributes for Contract { .is_none(), SetError::ValueAlreadySet, ); + // NOTE: SetNameEvent is emitted by _set_name() _set_name(storage.name, asset, name); } @@ -492,6 +497,7 @@ impl SetAssetAttributes for Contract { .is_none(), SetError::ValueAlreadySet, ); + // NOTE: SetSymbolEvent is emitted by _set_symbol() _set_symbol(storage.symbol, asset, symbol); } @@ -552,6 +558,7 @@ impl SetAssetMetadata for Contract { .is_none(), SetError::ValueAlreadySet, ); + // NOTE: SetMetadataEvent is emitted by _set_metadata() _set_metadata(storage.metadata, asset, key, metadata); } } @@ -673,3 +680,16 @@ impl Constructor for Contract { initialize_ownership(owner); } } + +abi EmitSRC20Events { + fn emit_src20_events(asset: AssetId); +} + +impl EmitSRC20Events for Contract { + fn emit_src20_events(asset: AssetId) { + // Metadata that is stored as a configurable should only be emitted once. + let sender = msg_sender().unwrap(); + + SetDecimalsEvent::new(asset, DECIMALS, sender).log(); + } +} diff --git a/NFT/NFT-contract/tests/utils/interface.rs b/NFT/NFT-contract/tests/utils/interface.rs index e796b2515..7c7c19b88 100644 --- a/NFT/NFT-contract/tests/utils/interface.rs +++ b/NFT/NFT-contract/tests/utils/interface.rs @@ -51,7 +51,7 @@ pub(crate) async fn mint( ) -> FuelCallResponse<()> { contract .methods() - .mint(recipient, sub_id, amount) + .mint(recipient, Some(sub_id), amount) .append_variable_outputs(1) .call() .await diff --git a/fractional-NFT/f-NFT-contract/Forc.toml b/fractional-NFT/f-NFT-contract/Forc.toml index 3bbc2fdd9..e7cb07066 100644 --- a/fractional-NFT/f-NFT-contract/Forc.toml +++ b/fractional-NFT/f-NFT-contract/Forc.toml @@ -5,4 +5,4 @@ license = "Apache-2.0" name = "f-NFT-contract" [dependencies] -standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" } +standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.1" } diff --git a/fractional-NFT/f-NFT-contract/src/main.sw b/fractional-NFT/f-NFT-contract/src/main.sw index 3c26ecefc..9e81ec9f5 100644 --- a/fractional-NFT/f-NFT-contract/src/main.sw +++ b/fractional-NFT/f-NFT-contract/src/main.sw @@ -89,19 +89,21 @@ impl SRC6 for Contract { #[payable] #[storage(read, write)] fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 { - require(vault_sub_id == ZERO_B256, SubIdError::InvalidSubId); + require(vault_sub_id == SubId::zero(), SubIdError::InvalidSubId); require(msg_amount() == 1, DepositError::InvalidSRC20NFT); let nft = msg_asset_id(); let f_nft_asset_sub_id = sha256((nft, vault_sub_id)); let f_nft_asset = AssetId::new(ContractId::this(), f_nft_asset_sub_id); + let sender = msg_sender().unwrap(); storage.total_assets.write(storage.total_assets.read() + 1); storage.vault_asset.insert(f_nft_asset, true); mint_to(receiver, f_nft_asset_sub_id, SHARES); + TotalSupplyEvent::new(f_nft_asset, SHARES, sender).log(); log(Deposit { - caller: msg_sender().unwrap(), + caller: sender, receiver: receiver, underlying_asset: nft, vault_sub_id: vault_sub_id, @@ -159,6 +161,7 @@ impl SRC6 for Contract { require(vault_sub_id == ZERO_B256, SubIdError::InvalidSubId); let sent_amount = msg_amount(); + let sender = msg_sender().unwrap(); require(sent_amount == SHARES, WithdrawError::AllSharesNotReturned); let f_nft_asset_sub_id = sha256((underlying_asset, vault_sub_id)); @@ -166,10 +169,12 @@ impl SRC6 for Contract { require(msg_asset_id() == f_nft_asset, WithdrawError::InvalidAsset); burn(f_nft_asset_sub_id, SHARES); + TotalSupplyEvent::new(f_nft_asset, 0, sender).log(); + transfer(receiver, underlying_asset, 1); log(Withdraw { - caller: msg_sender().unwrap(), + caller: sender, receiver, underlying_asset, vault_sub_id, @@ -468,3 +473,21 @@ impl SRC20 for Contract { } } } + +abi EmitSRC20Events { + fn emit_src20_events(); +} + +impl EmitSRC20Events for Contract { + fn emit_src20_events(asset: AssetId) { + // Metadata that is stored as a configurable should only be emitted once. + let sender = msg_sender().unwrap(); + let name = Some(String::from_ascii_str(from_str_array(NAME))); + let symbol = Some(String::from_ascii_str(from_str_array(SYMBOL))); + + SetNameEvent::new(asset, name, sender).log(); + SetSymbolEvent::new(asset, symbol, sender).log(); + SetDecimalsEvent::new(asset, DECIMALS, sender).log(); + TotalSupplyEvent::new(asset, SHARES, sender).log(); + } +} diff --git a/native-asset/native-asset-contract/Forc.toml b/native-asset/native-asset-contract/Forc.toml index b605401f9..fffeb2136 100644 --- a/native-asset/native-asset-contract/Forc.toml +++ b/native-asset/native-asset-contract/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "native-asset-contract" [dependencies] -standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.3" } -sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" } +standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.1" } +sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" } diff --git a/native-asset/native-asset-contract/src/errors.sw b/native-asset/native-asset-contract/src/errors.sw index d03988591..56b6f0113 100644 --- a/native-asset/native-asset-contract/src/errors.sw +++ b/native-asset/native-asset-contract/src/errors.sw @@ -6,6 +6,7 @@ pub enum AmountError { pub enum MintError { MaxMinted: (), + SubIdNone: (), } pub enum SetError { diff --git a/native-asset/native-asset-contract/src/main.sw b/native-asset/native-asset-contract/src/main.sw index f0fb1202b..0540256e1 100644 --- a/native-asset/native-asset-contract/src/main.sw +++ b/native-asset/native-asset-contract/src/main.sw @@ -221,6 +221,7 @@ impl SRC3 for Contract { /// # Reverts /// /// * When the caller is not the contract owner. + /// * When `sub_id` is `None`. /// * When more than 100,000,000 coins have been minted. /// /// # Number of Storage Accesses @@ -240,10 +241,11 @@ impl SRC3 for Contract { /// } /// ``` #[storage(read, write)] - fn mint(recipient: Identity, sub_id: SubId, amount: u64) { + fn mint(recipient: Identity, sub_id: Option, amount: u64) { only_owner(); - let asset = AssetId::new(ContractId::this(), sub_id); + require(sub_id.is_some(), MintError::SubIdNone); + let asset = AssetId::new(ContractId::this(), sub_id.unwrap()); let cumulative_supply = storage.cumulative_supply.get(asset).try_read().unwrap_or(0); require( cumulative_supply + amount <= MAX_SUPPLY, @@ -252,13 +254,15 @@ impl SRC3 for Contract { storage .cumulative_supply .insert(asset, cumulative_supply + amount); + + // NOTE: TotalSupplyEvent is emitted by _mint() let _ = _mint( storage .total_assets, storage .total_supply, recipient, - sub_id, + sub_id.unwrap(), amount, ); } @@ -303,6 +307,7 @@ impl SRC3 for Contract { #[storage(read, write)] fn burn(sub_id: SubId, amount: u64) { require(msg_amount() == amount, AmountError::AmountMismatch); + // NOTE: TotalSupplyEvent is emitted by _burn() _burn(storage.total_supply, sub_id, amount); } } @@ -383,6 +388,7 @@ impl SetAssetAttributes for Contract { .is_none(), SetError::ValueAlreadySet, ); + // NOTE: SetNameEvent is emitted by _set_name() _set_name(storage.name, asset, name); } @@ -430,6 +436,7 @@ impl SetAssetAttributes for Contract { .is_none(), SetError::ValueAlreadySet, ); + // NOTE: SetSymbolEvent is emitted by _set_symbol() _set_symbol(storage.symbol, asset, symbol); } @@ -476,6 +483,7 @@ impl SetAssetAttributes for Contract { .is_none(), SetError::ValueAlreadySet, ); + // NOTE: SetDecimalsEvent is emitted by _set_decimals() _set_decimals(storage.decimals, asset, decimals); } } diff --git a/native-asset/native-asset-contract/tests/utils/interface.rs b/native-asset/native-asset-contract/tests/utils/interface.rs index 6676674d3..a9f278eca 100644 --- a/native-asset/native-asset-contract/tests/utils/interface.rs +++ b/native-asset/native-asset-contract/tests/utils/interface.rs @@ -57,7 +57,7 @@ pub(crate) async fn mint( ) -> FuelCallResponse<()> { contract .methods() - .mint(recipient, sub_id, amount) + .mint(recipient, Some(sub_id), amount) .append_variable_outputs(1) .call() .await From 2f9927d884df721e653c4d67d3a3029278272e74 Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 12:39:00 +0545 Subject: [PATCH 2/7] Update README to use docs hub over github links --- NFT/README.md | 10 +++++----- fractional-NFT/README.md | 4 ++-- native-asset/README.md | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/NFT/README.md b/NFT/README.md index 163386e0d..7ceea9d0b 100644 --- a/NFT/README.md +++ b/NFT/README.md @@ -22,15 +22,15 @@ In this barebones NFT example project, there are a maximum of 100,000 NFTs that ## Standards Implementations -The project implements and follows the [SRC-20; Native Asset](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md), [SRC-3; Mint and Burn](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-3.md), and [SRC-7; Metadata](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-7.md) standards. It also uses the [Native Asset Library](https://fuellabs.github.io/sway-libs/book/asset/index.html) to implement the basic functionality behind the standards. +The project implements and follows the [SRC-20; Native Asset](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/), [SRC-3; Mint and Burn](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/), and [SRC-7; Metadata](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standards. It also uses the [Native Asset Library](https://docs.fuel.network/docs/sway-libs/asset/) to implement the basic functionality behind the standards. ### SRC-20 -The [SRC-20](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) standard requires that there is a maximum number of one coin per NFT asset. It also states that the decimals must be `0u8` for any NFT. This project conforms to both these restrictions and thus can be deemed an NFT on the Fuel Network. +The [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) standard requires that there is a maximum number of one coin per NFT asset. It also states that the decimals must be `0u8` for any NFT. This project conforms to both these restrictions and thus can be deemed an NFT on the Fuel Network. Set functions for name and symbol have been provided to the user. While traditionally name and symbol are written into the contract rather than storage, this contract is open to mint new types of assets. This means that every NFT minted by this contract may contain a different name and symbol. -The [SRC-20](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) ABI defined below has also been implemented. +The [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) ABI defined below has also been implemented. ```sway abi SRC20 { @@ -49,7 +49,7 @@ abi SRC20 { ### SRC-3 -The [SRC-3](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-3.md) standard defines the ABI for minting and burning. This has been properly implemented. +The [SRC-3](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standard defines the ABI for minting and burning. This has been properly implemented. ```sway abi SRC3 { @@ -62,7 +62,7 @@ abi SRC3 { ### SRC-7 -The [SRC-7](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-7.md) standard defines the ABI for retrieving metadata. This has been properly implemented. +The [SRC-7](https://docs.fuel.network/docs/sway-standards/src-7-asset-metadata/) standard defines the ABI for retrieving metadata. This has been properly implemented. A set function that uses storage has been provided to allow the user to set their own desired metadata. There is no limit or restrictions to what and the amount of metadata an asset may have. diff --git a/fractional-NFT/README.md b/fractional-NFT/README.md index 4ef196389..846d484b1 100644 --- a/fractional-NFT/README.md +++ b/fractional-NFT/README.md @@ -22,7 +22,7 @@ In this barebones F-NFT example project, where locking a NFT into the vault will ## Standards Implementations -The project implements and follows the [SRC-6; Vault](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-6.md) and [SRC-20; Native Asset](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) standards. +The project implements and follows the [SRC-6; Vault](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-6.md) and [SRC-20; Native Asset](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) standards. ### SRC-6 @@ -47,7 +47,7 @@ abi SRC6 { ### SRC-20 -The [SRC-20](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) standard has been implemented for the resulting minted shares when a NFT is locked in the vault. Information on the share assets can be queried with the [SRC-20](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) standard. +The [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) standard has been implemented for the resulting minted shares when a NFT is locked in the vault. Information on the share assets can be queried with the [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) standard. ```sway abi SRC20 { diff --git a/native-asset/README.md b/native-asset/README.md index 34a3e0a5f..1e9a7145e 100644 --- a/native-asset/README.md +++ b/native-asset/README.md @@ -22,13 +22,13 @@ In this project, there are a maximum of 100,000,000 coins for each asset that ma ## Standards Implementations -The project implements and follows the [SRC-20; Native Asset](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) and [SRC-3; Mint and Burn](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-3.md) standards. It also uses the [Native Asset Library](https://fuellabs.github.io/sway-libs/book/asset/index.html) to implement the basic functionality behind the standards. +The project implements and follows the [SRC-20; Native Asset](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) and [SRC-3; Mint and Burn](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standards. It also uses the [Native Asset Library](https://docs.fuel.network/docs/sway-libs/asset/) to implement the basic functionality behind the standards. ### SRC-20 Set functions for name, symbol, and decimals have been provided to the user. While traditionally name, symbol, and decimals are written into the contract rather than storage, this contract is open to mint new types of assets. This means that every asset minted by this contract may contain a different name and symbol. -The [SRC-20](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-20.md) ABI defined below has also been implemented. +The [SRC-20](https://docs.fuel.network/docs/sway-standards/src-20-native-asset/) ABI defined below has also been implemented. ```sway abi SRC20 { @@ -47,7 +47,7 @@ abi SRC20 { ### SRC-3 -The [SRC-3](https://github.com/FuelLabs/sway-standards/blob/master/SRCs/src-3.md) standard defines the ABI for minting and burning. This has been properly implemented. +The [SRC-3](https://docs.fuel.network/docs/sway-standards/src-3-minting-and-burning/) standard defines the ABI for minting and burning. This has been properly implemented. ```sway abi SRC3 { From ef02ce05f5d46cd2b1ab9132b682086d5119fd33 Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 12:46:34 +0545 Subject: [PATCH 3/7] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1033b169..111d81091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ Description of the upcoming release here. ### Changed - [#809](https://github.com/FuelLabs/sway-applications/issues/809) Set Devrel team as codeowners -- Something changed here 2 +- [#811](https://github.com/FuelLabs/sway-applications/pull/811) Updates the NFT, Fractional NFT, and Native Asset apps to the latest SRC-20 and SRC-3 specs. ### Fixed From 419c100a294a9b9284183ebd4a67e0981f61af64 Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 12:48:15 +0545 Subject: [PATCH 4/7] Format NFT app contract --- NFT/NFT-contract/src/main.sw | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/NFT/NFT-contract/src/main.sw b/NFT/NFT-contract/src/main.sw index a89b62cf4..c9b05d309 100644 --- a/NFT/NFT-contract/src/main.sw +++ b/NFT/NFT-contract/src/main.sw @@ -5,7 +5,21 @@ mod interface; use errors::{MintError, SetError}; use interface::Constructor; -use standards::{src20::{SetDecimalsEvent, SRC20}, src3::SRC3, src5::{SRC5, State}, src7::{Metadata, SRC7},}; +use standards::{ + src20::{ + SetDecimalsEvent, + SRC20, + }, + src3::SRC3, + src5::{ + SRC5, + State, + }, + src7::{ + Metadata, + SRC7, + }, +}; use sway_libs::{ asset::{ base::{ From ca1d9fa732f3b4180f58091897137a344f38fc03 Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 12:58:16 +0545 Subject: [PATCH 5/7] Fix compile errors --- NFT/Forc.lock | 13 +++++++++---- NFT/NFT-contract/src/main.sw | 5 +++-- fractional-NFT/Forc.lock | 7 ++++++- fractional-NFT/f-NFT-contract/src/main.sw | 17 +++++++++++++++-- .../f-NFT-contract/tests/utils/setup.rs | 4 ++-- fractional-NFT/test-artifacts/Forc.toml | 4 ++-- fractional-NFT/test-artifacts/src/main.sw | 4 ++-- native-asset/Forc.lock | 13 +++++++++---- native-asset/native-asset-contract/src/main.sw | 3 ++- 9 files changed, 50 insertions(+), 20 deletions(-) diff --git a/NFT/Forc.lock b/NFT/Forc.lock index 71bc95c23..1f33175aa 100644 --- a/NFT/Forc.lock +++ b/NFT/Forc.lock @@ -2,7 +2,7 @@ name = "NFT-contract" source = "member" dependencies = [ - "standards", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5", "std", "sway_libs", ] @@ -13,7 +13,12 @@ source = "path+from-root-E19CE48B3E858B72" [[package]] name = "standards" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c" +dependencies = ["std"] + +[[package]] +name = "standards" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5" dependencies = ["std"] [[package]] @@ -23,8 +28,8 @@ dependencies = ["core"] [[package]] name = "sway_libs" -source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.21.0#6a227ed34c86fe1ebd334dbdfeccf66c43e3915b" +source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.24.0#e19f96f85ae12426d20adc176b70aa38fd9a2a5b" dependencies = [ - "standards", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c", "std", ] diff --git a/NFT/NFT-contract/src/main.sw b/NFT/NFT-contract/src/main.sw index c9b05d309..d9719e016 100644 --- a/NFT/NFT-contract/src/main.sw +++ b/NFT/NFT-contract/src/main.sw @@ -304,7 +304,8 @@ impl SRC3 for Contract { storage .total_supply, recipient, - sub_id, + sub_id + .unwrap(), amount, ); } @@ -704,6 +705,6 @@ impl EmitSRC20Events for Contract { // Metadata that is stored as a configurable should only be emitted once. let sender = msg_sender().unwrap(); - SetDecimalsEvent::new(asset, DECIMALS, sender).log(); + SetDecimalsEvent::new(asset, 0u8, sender).log(); } } diff --git a/fractional-NFT/Forc.lock b/fractional-NFT/Forc.lock index b7282783e..143b54a9c 100644 --- a/fractional-NFT/Forc.lock +++ b/fractional-NFT/Forc.lock @@ -15,7 +15,7 @@ source = "path+from-root-E19CE48B3E858B72" name = "f-NFT-contract" source = "member" dependencies = [ - "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5", "std", ] @@ -29,6 +29,11 @@ name = "standards" source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae" dependencies = ["std"] +[[package]] +name = "standards" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5" +dependencies = ["std"] + [[package]] name = "std" source = "git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6" diff --git a/fractional-NFT/f-NFT-contract/src/main.sw b/fractional-NFT/f-NFT-contract/src/main.sw index 9e81ec9f5..7981b048d 100644 --- a/fractional-NFT/f-NFT-contract/src/main.sw +++ b/fractional-NFT/f-NFT-contract/src/main.sw @@ -3,7 +3,20 @@ contract; mod errors; use errors::{DepositError, SubIdError, WithdrawError}; -use standards::{src20::SRC20, src6::{Deposit, SRC6, Withdraw}}; +use standards::{ + src20::{ + SetDecimalsEvent, + SetNameEvent, + SetSymbolEvent, + SRC20, + TotalSupplyEvent, + }, + src6::{ + Deposit, + SRC6, + Withdraw, + }, +}; use std::{ asset::{ burn, @@ -475,7 +488,7 @@ impl SRC20 for Contract { } abi EmitSRC20Events { - fn emit_src20_events(); + fn emit_src20_events(asset: AssetId); } impl EmitSRC20Events for Contract { diff --git a/fractional-NFT/f-NFT-contract/tests/utils/setup.rs b/fractional-NFT/f-NFT-contract/tests/utils/setup.rs index 0aa201bd0..c6a982a06 100644 --- a/fractional-NFT/f-NFT-contract/tests/utils/setup.rs +++ b/fractional-NFT/f-NFT-contract/tests/utils/setup.rs @@ -144,13 +144,13 @@ pub(crate) async fn setup_nft( let _ = nft .methods() - .mint(identity, Bits256(*sub_id_1), 1) + .mint(identity, Some(Bits256(*sub_id_1)), 1) .append_variable_outputs(1) .call() .await; let _ = nft .methods() - .mint(identity, Bits256(*sub_id_2), 1) + .mint(identity, Some(Bits256(*sub_id_2)), 1) .append_variable_outputs(1) .call() .await; diff --git a/fractional-NFT/test-artifacts/Forc.toml b/fractional-NFT/test-artifacts/Forc.toml index ddc83dd2e..e0409639f 100644 --- a/fractional-NFT/test-artifacts/Forc.toml +++ b/fractional-NFT/test-artifacts/Forc.toml @@ -5,5 +5,5 @@ license = "Apache-2.0" name = "NFT-contract" [dependencies] -standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" } -sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" } +standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.6.1" } +sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.24.0" } diff --git a/fractional-NFT/test-artifacts/src/main.sw b/fractional-NFT/test-artifacts/src/main.sw index fb209ddbc..a93a73888 100644 --- a/fractional-NFT/test-artifacts/src/main.sw +++ b/fractional-NFT/test-artifacts/src/main.sw @@ -228,8 +228,8 @@ impl SRC3 for Contract { /// } /// ``` #[storage(read, write)] - fn mint(recipient: Identity, sub_id: SubId, amount: u64) { - let asset = AssetId::new(ContractId::this(), sub_id); + fn mint(recipient: Identity, sub_id: Option, amount: u64) { + let asset = AssetId::new(ContractId::this(), sub_id.unwrap()); require(amount == 1, MintError::CannotMintMoreThanOneNFTWithSubId); require( storage diff --git a/native-asset/Forc.lock b/native-asset/Forc.lock index 03ddef3e3..20722c1a1 100644 --- a/native-asset/Forc.lock +++ b/native-asset/Forc.lock @@ -6,14 +6,19 @@ source = "path+from-root-E19CE48B3E858B72" name = "native-asset-contract" source = "member" dependencies = [ - "standards", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5", "std", "sway_libs", ] [[package]] name = "standards" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c" +dependencies = ["std"] + +[[package]] +name = "standards" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5" dependencies = ["std"] [[package]] @@ -23,8 +28,8 @@ dependencies = ["core"] [[package]] name = "sway_libs" -source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.21.0#6a227ed34c86fe1ebd334dbdfeccf66c43e3915b" +source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.24.0#e19f96f85ae12426d20adc176b70aa38fd9a2a5b" dependencies = [ - "standards", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c", "std", ] diff --git a/native-asset/native-asset-contract/src/main.sw b/native-asset/native-asset-contract/src/main.sw index 0540256e1..3ffe276e7 100644 --- a/native-asset/native-asset-contract/src/main.sw +++ b/native-asset/native-asset-contract/src/main.sw @@ -262,7 +262,8 @@ impl SRC3 for Contract { storage .total_supply, recipient, - sub_id.unwrap(), + sub_id + .unwrap(), amount, ); } From 43386b511e6d7ad43bec5ab4e909f2acfe9e532a Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 13:01:55 +0545 Subject: [PATCH 6/7] Update test artifact to latest sway-standards --- fractional-NFT/Forc.lock | 13 ++++--------- fractional-NFT/test-artifacts/src/main.sw | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/fractional-NFT/Forc.lock b/fractional-NFT/Forc.lock index 143b54a9c..3a9f26bf4 100644 --- a/fractional-NFT/Forc.lock +++ b/fractional-NFT/Forc.lock @@ -2,7 +2,7 @@ name = "NFT-contract" source = "member" dependencies = [ - "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.1#792639cdf391565e6e6a02482ea8a46d9604a6f5", "std", "sway_libs", ] @@ -21,12 +21,7 @@ dependencies = [ [[package]] name = "standards" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2" -dependencies = ["std"] - -[[package]] -name = "standards" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c" dependencies = ["std"] [[package]] @@ -41,8 +36,8 @@ dependencies = ["core"] [[package]] name = "sway_libs" -source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.21.0#6a227ed34c86fe1ebd334dbdfeccf66c43e3915b" +source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.24.0#e19f96f85ae12426d20adc176b70aa38fd9a2a5b" dependencies = [ - "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.6.0#65e09f95ea8b9476b171a66c8a47108f352fa32c", "std", ] diff --git a/fractional-NFT/test-artifacts/src/main.sw b/fractional-NFT/test-artifacts/src/main.sw index a93a73888..b6bfb3c58 100644 --- a/fractional-NFT/test-artifacts/src/main.sw +++ b/fractional-NFT/test-artifacts/src/main.sw @@ -252,7 +252,7 @@ impl SRC3 for Contract { storage .total_supply, recipient, - sub_id, + sub_id.unwrap(), amount, ); } From 567f2cb17c3132d5fd511c51bfcd49390f49101b Mon Sep 17 00:00:00 2001 From: bitzoic Date: Tue, 10 Sep 2024 13:09:38 +0545 Subject: [PATCH 7/7] Format test artifact --- fractional-NFT/test-artifacts/src/main.sw | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fractional-NFT/test-artifacts/src/main.sw b/fractional-NFT/test-artifacts/src/main.sw index b6bfb3c58..f79098cbb 100644 --- a/fractional-NFT/test-artifacts/src/main.sw +++ b/fractional-NFT/test-artifacts/src/main.sw @@ -252,7 +252,8 @@ impl SRC3 for Contract { storage .total_supply, recipient, - sub_id.unwrap(), + sub_id + .unwrap(), amount, ); }