diff --git a/Cargo.toml b/Cargo.toml index aae4e3a..7c17ff4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,19 +10,19 @@ repository = "https://github.com/theahaco/scaffold-stellar" version = "0.0.1" [workspace.dependencies.soroban-sdk] -version = "23.1.0" +version = "23.4.0" [workspace.dependencies.stellar-access] git = "https://github.com/OpenZeppelin/stellar-contracts" -tag = "v0.5.1" +tag = "v0.6.0" [workspace.dependencies.stellar-macros] git = "https://github.com/OpenZeppelin/stellar-contracts" -tag = "v0.5.1" +tag = "v0.6.0" [workspace.dependencies.stellar-tokens] git = "https://github.com/OpenZeppelin/stellar-contracts" -tag = "v0.5.1" +tag = "v0.6.0" [profile.release] opt-level = "z" diff --git a/contracts/fungible-allowlist/src/contract.rs b/contracts/fungible-allowlist/src/contract.rs index 42c8a80..007ef12 100644 --- a/contracts/fungible-allowlist/src/contract.rs +++ b/contracts/fungible-allowlist/src/contract.rs @@ -5,9 +5,11 @@ //! controlled token transfers by an admin who can allow or disallow specific //! accounts. -use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, String}; +use soroban_sdk::{ + contract, contractimpl, symbol_short, Address, Env, MuxedAddress, String, Symbol, Vec, +}; use stellar_access::access_control::{self as access_control, AccessControl}; -use stellar_macros::{default_impl, only_role}; +use stellar_macros::only_role; use stellar_tokens::fungible::{ allowlist::{AllowList, FungibleAllowList}, burnable::FungibleBurnable, @@ -19,18 +21,20 @@ pub struct ExampleContract; #[contractimpl] impl ExampleContract { - pub fn __constructor(e: &Env, admin: Address, manager: Address, initial_supply: i128) { - Base::set_metadata( - e, - 18, - String::from_str(e, "AllowList Token"), - String::from_str(e, "ALT"), - ); + pub fn __constructor( + e: &Env, + name: String, + symbol: String, + admin: Address, + manager: Address, + initial_supply: i128, + ) { + Base::set_metadata(e, 18, name, symbol); access_control::set_admin(e, &admin); // create a role "manager" and grant it to `manager` - access_control::grant_role_no_auth(e, &admin, &manager, &symbol_short!("manager")); + access_control::grant_role_no_auth(e, &manager, &symbol_short!("manager"), &admin); // Allow the admin to transfer tokens AllowList::allow_user(e, &admin); @@ -40,8 +44,7 @@ impl ExampleContract { } } -#[default_impl] -#[contractimpl] +#[contractimpl(contracttrait)] impl FungibleToken for ExampleContract { type ContractType = AllowList; } @@ -62,10 +65,8 @@ impl FungibleAllowList for ExampleContract { } } -#[default_impl] -#[contractimpl] +#[contractimpl(contracttrait)] impl AccessControl for ExampleContract {} -#[default_impl] -#[contractimpl] +#[contractimpl(contracttrait)] impl FungibleBurnable for ExampleContract {} diff --git a/contracts/nft-enumerable/src/contract.rs b/contracts/nft-enumerable/src/contract.rs index 3a2fd22..94b0a6e 100644 --- a/contracts/nft-enumerable/src/contract.rs +++ b/contracts/nft-enumerable/src/contract.rs @@ -5,7 +5,6 @@ //! IDs owned by each account. use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, String}; -use stellar_macros::default_impl; use stellar_tokens::non_fungible::{ burnable::NonFungibleBurnable, enumerable::{Enumerable, NonFungibleEnumerable}, @@ -22,14 +21,9 @@ pub struct ExampleContract; #[contractimpl] impl ExampleContract { - pub fn __constructor(e: &Env, owner: Address) { + pub fn __constructor(e: &Env, uri: String, name: String, symbol: String, owner: Address) { e.storage().instance().set(&DataKey::Owner, &owner); - Base::set_metadata( - e, - String::from_str(e, "www.mytoken.com"), - String::from_str(e, "My Token"), - String::from_str(e, "TKN"), - ); + Base::set_metadata(e, uri, name, symbol); } pub fn mint(e: &Env, to: Address) -> u32 { @@ -40,16 +34,13 @@ impl ExampleContract { } } -#[default_impl] -#[contractimpl] +#[contractimpl(contracttrait)] impl NonFungibleToken for ExampleContract { type ContractType = Enumerable; } -#[default_impl] -#[contractimpl] +#[contractimpl(contracttrait)] impl NonFungibleEnumerable for ExampleContract {} -#[default_impl] -#[contractimpl] +#[contractimpl(contracttrait)] impl NonFungibleBurnable for ExampleContract {} diff --git a/environments.toml b/environments.toml index 4011dad..c672b27 100644 --- a/environments.toml +++ b/environments.toml @@ -9,8 +9,8 @@ name = "me" # Required. Keys for this account will be saved to `./.stellar/ident default = true # Optional. Whether to use this account as the `--source` for commands that need one. [development.contracts] -fungible_allowlist_example = { client = true, constructor_args = "--admin me --manager me --initial_supply 1000000000000000000000000" } -nft_enumerable_example = { client = true, constructor_args = "--owner me" } +fungible_allowlist_example = { client = true, constructor_args = "--name ExampleToken --symbol EXT --admin me --manager me --initial_supply 1000000000000000000000000" } +nft_enumerable_example = { client = true, constructor_args = "--uri https://example.com/nft/ --name ExampleNFT --symbol ENFT --owner me" } # Rather than in one list, TOML allows specifying contracts in their own "sections" [development.contracts.guess_the_number] diff --git a/package.json b/package.json index 4add4b6..52a9ce9 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "npm start", "start": "concurrently --kill-others-on-fail --names stellar,vite -c gray,green --pad-prefix \"stellar scaffold watch --build-clients\" \"vite\"", "build": "tsc -b && vite build", - "install:contracts": "npm install --workspace=packages && npm run build --workspace=packages", + "install:contracts": "npm install --workspaces && npm run build --workspaces", "preview": "vite preview", "lint": "eslint .", "format": "prettier . --write",