diff --git a/Cargo.toml b/Cargo.toml index 72f4598..8b7b7c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ description = "Sway token standard SRC-20 rust sdk" [dependencies] dotenv = "0.15.0" -fuels = { version = "0.55.0", features = ["fuel-core-lib"] } +fuels = { version = "0.60.0", features = ["fuel-core-lib"] } rand = "0.8.5" serde = "1.0.197" serde_json = "1.0.114" diff --git a/contract/Forc.lock b/contract/Forc.lock index 380cec9..b698b31 100644 --- a/contract/Forc.lock +++ b/contract/Forc.lock @@ -1,41 +1,35 @@ -[[package]] -name = "asset" -source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.19.0#dcbbec000a9051e71c0c21f4b720eebbb55c199a" -dependencies = [ - "src7", - "std", -] - [[package]] name = "core" -source = "path+from-root-566CA1D5F8BEAFBF" +source = "path+from-root-CC7184DF2EE4172B" [[package]] -name = "src20" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd" +name = "standards" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.1#0a6f3ba0bce036a0ce61f15ed4480c71af32d3aa" dependencies = ["std"] [[package]] -name = "src3" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd" -dependencies = ["std"] - -[[package]] -name = "src7" -source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd" +name = "standards" +source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2" dependencies = ["std"] [[package]] name = "std" -source = "git+https://github.com/fuellabs/sway?tag=v0.49.3#0dc6570377ee9c4a6359ade597fa27351e02a728" +source = "git+https://github.com/fuellabs/sway?rev#850a2c48ddac019aa04bf7f5c1319381edc53fea" dependencies = ["core"] +[[package]] +name = "sway_libs" +source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.21.0#6a227ed34c86fe1ebd334dbdfeccf66c43e3915b" +dependencies = [ + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2", + "std", +] + [[package]] name = "token" source = "member" dependencies = [ - "asset", - "src20", - "src3", + "standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.1#0a6f3ba0bce036a0ce61f15ed4480c71af32d3aa", "std", + "sway_libs", ] diff --git a/contract/Forc.toml b/contract/Forc.toml index cc880b7..6474823 100644 --- a/contract/Forc.toml +++ b/contract/Forc.toml @@ -5,6 +5,5 @@ license = "Apache-2.0" name = "token" [dependencies] -asset = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.19.0" } -src20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3" } -src3 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3"} +sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" } +standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.1" } diff --git a/contract/out/debug/token-abi.json b/contract/out/debug/token-abi.json index 1576f2b..b308e43 100644 --- a/contract/out/debug/token-abi.json +++ b/contract/out/debug/token-abi.json @@ -1,4 +1,5 @@ { + "encoding": "1", "types": [ { "typeId": 0, @@ -77,7 +78,7 @@ "type": "struct Address", "components": [ { - "name": "value", + "name": "bits", "type": 1, "typeArguments": null } @@ -89,7 +90,7 @@ "type": "struct AssetId", "components": [ { - "name": "value", + "name": "bits", "type": 1, "typeArguments": null } @@ -118,7 +119,7 @@ "type": "struct ContractId", "components": [ { - "name": "value", + "name": "bits", "type": 1, "typeArguments": null } @@ -321,6 +322,10 @@ "typeArguments": null }, "attributes": [ + { + "name": "payable", + "arguments": [] + }, { "name": "storage", "arguments": [ @@ -373,6 +378,14 @@ "type": 2, "typeArguments": [] } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } } ], "messagesTypes": [], diff --git a/contract/out/debug/token.bin b/contract/out/debug/token.bin index 43e4ddc..7098714 100644 Binary files a/contract/out/debug/token.bin and b/contract/out/debug/token.bin differ diff --git a/contract/src/main.sw b/contract/src/main.sw index 5bb9df8..42c313a 100644 --- a/contract/src/main.sw +++ b/contract/src/main.sw @@ -1,15 +1,15 @@ contract; -use asset::base::{ +use sway_libs::asset::base::{ _total_assets, _total_supply, _name, _symbol, _decimals }; -use asset::mint::{_mint, _burn}; -use src20::SRC20; -use src3::SRC3; +use sway_libs::asset::supply::{_mint, _burn}; +use standards::src20::SRC20; +use standards::src3::SRC3; use std::{hash::{Hash, sha256}, string::String, storage::storage_string::*}; storage { total_assets: u64 = 0, @@ -52,6 +52,7 @@ impl SRC3 for Contract { let _asset_id = _mint(storage.total_assets, storage.total_supply, recipient, sub_id, amount); } + #[payable] #[storage(read, write)] fn burn(sub_id: SubId, amount: u64) { _burn(storage.total_supply, sub_id, amount); diff --git a/src/constants.rs b/src/constants.rs index 6f9d16e..7fa100d 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,4 +1,4 @@ -pub const RPC: &str = "beta-5.fuel.network"; +pub const RPC: &str = "devnet.fuel.network"; pub const TOKEN_CONTRACT_ID: &str = "0x6bd9643c9279204b474a778dea7f923226060cb94a4c61c5aae015cf96b5aad2"; \ No newline at end of file diff --git a/src/token_utils.rs b/src/token_utils.rs index dae6be3..2a60c76 100644 --- a/src/token_utils.rs +++ b/src/token_utils.rs @@ -26,7 +26,7 @@ pub struct Asset { pub asset_id: AssetId, pub decimals: u64, pub symbol: String, - pub token_contract_instance: Option>, + pub token_contract: TokenContract, } impl Asset { @@ -36,13 +36,11 @@ impl Asset { amount: u64, ) -> Result, fuels::types::errors::Error> { let symbol_hash = get_symbol_hash(&self.symbol); - self.token_contract_instance - .as_ref() - .unwrap() + self.token_contract .methods() .mint(Identity::Address(recipient), symbol_hash, amount) .append_variable_outputs(1) - .with_tx_policies(TxPolicies::default().with_gas_price(1)) + .with_tx_policies(TxPolicies::default().with_tip(1)) .call() .await } @@ -69,7 +67,7 @@ impl Asset { asset_id, decimals: config.decimals, symbol: config.symbol, - token_contract_instance: Option::Some(instance), + token_contract: instance, } } } @@ -83,7 +81,7 @@ pub async fn deploy_token_contract(wallet: &WalletUnlocked) -> TokenContract