Skip to content
Merged
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
33 changes: 17 additions & 16 deletions contracts/fungible-allowlist/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -40,8 +44,7 @@ impl ExampleContract {
}
}

#[default_impl]
#[contractimpl]
#[contractimpl(contracttrait)]
impl FungibleToken for ExampleContract {
type ContractType = AllowList;
}
Expand All @@ -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 {}
19 changes: 5 additions & 14 deletions contracts/nft-enumerable/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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 {
Expand All @@ -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 {}
4 changes: 2 additions & 2 deletions environments.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading