Skip to content

Commit a44d784

Browse files
authored
Merge pull request #190 from oceans404/fix/missing-constructor-args
fix: stabilize quickstart on OZ v0.6.0 — deps, contract code, and constructor args
2 parents 7c0d4a7 + 91deddc commit a44d784

File tree

5 files changed

+29
-37
lines changed

5 files changed

+29
-37
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ repository = "https://github.com/theahaco/scaffold-stellar"
1010
version = "0.0.1"
1111

1212
[workspace.dependencies.soroban-sdk]
13-
version = "23.1.0"
13+
version = "23.4.0"
1414

1515
[workspace.dependencies.stellar-access]
1616
git = "https://github.com/OpenZeppelin/stellar-contracts"
17-
tag = "v0.5.1"
17+
tag = "v0.6.0"
1818

1919
[workspace.dependencies.stellar-macros]
2020
git = "https://github.com/OpenZeppelin/stellar-contracts"
21-
tag = "v0.5.1"
21+
tag = "v0.6.0"
2222

2323
[workspace.dependencies.stellar-tokens]
2424
git = "https://github.com/OpenZeppelin/stellar-contracts"
25-
tag = "v0.5.1"
25+
tag = "v0.6.0"
2626

2727
[profile.release]
2828
opt-level = "z"

contracts/fungible-allowlist/src/contract.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
//! controlled token transfers by an admin who can allow or disallow specific
66
//! accounts.
77
8-
use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, String};
8+
use soroban_sdk::{
9+
contract, contractimpl, symbol_short, Address, Env, MuxedAddress, String, Symbol, Vec,
10+
};
911
use stellar_access::access_control::{self as access_control, AccessControl};
10-
use stellar_macros::{default_impl, only_role};
12+
use stellar_macros::only_role;
1113
use stellar_tokens::fungible::{
1214
allowlist::{AllowList, FungibleAllowList},
1315
burnable::FungibleBurnable,
@@ -19,18 +21,20 @@ pub struct ExampleContract;
1921

2022
#[contractimpl]
2123
impl ExampleContract {
22-
pub fn __constructor(e: &Env, admin: Address, manager: Address, initial_supply: i128) {
23-
Base::set_metadata(
24-
e,
25-
18,
26-
String::from_str(e, "AllowList Token"),
27-
String::from_str(e, "ALT"),
28-
);
24+
pub fn __constructor(
25+
e: &Env,
26+
name: String,
27+
symbol: String,
28+
admin: Address,
29+
manager: Address,
30+
initial_supply: i128,
31+
) {
32+
Base::set_metadata(e, 18, name, symbol);
2933

3034
access_control::set_admin(e, &admin);
3135

3236
// create a role "manager" and grant it to `manager`
33-
access_control::grant_role_no_auth(e, &admin, &manager, &symbol_short!("manager"));
37+
access_control::grant_role_no_auth(e, &manager, &symbol_short!("manager"), &admin);
3438

3539
// Allow the admin to transfer tokens
3640
AllowList::allow_user(e, &admin);
@@ -40,8 +44,7 @@ impl ExampleContract {
4044
}
4145
}
4246

43-
#[default_impl]
44-
#[contractimpl]
47+
#[contractimpl(contracttrait)]
4548
impl FungibleToken for ExampleContract {
4649
type ContractType = AllowList;
4750
}
@@ -62,10 +65,8 @@ impl FungibleAllowList for ExampleContract {
6265
}
6366
}
6467

65-
#[default_impl]
66-
#[contractimpl]
68+
#[contractimpl(contracttrait)]
6769
impl AccessControl for ExampleContract {}
6870

69-
#[default_impl]
70-
#[contractimpl]
71+
#[contractimpl(contracttrait)]
7172
impl FungibleBurnable for ExampleContract {}

contracts/nft-enumerable/src/contract.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! IDs owned by each account.
66
77
use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, String};
8-
use stellar_macros::default_impl;
98
use stellar_tokens::non_fungible::{
109
burnable::NonFungibleBurnable,
1110
enumerable::{Enumerable, NonFungibleEnumerable},
@@ -22,14 +21,9 @@ pub struct ExampleContract;
2221

2322
#[contractimpl]
2423
impl ExampleContract {
25-
pub fn __constructor(e: &Env, owner: Address) {
24+
pub fn __constructor(e: &Env, uri: String, name: String, symbol: String, owner: Address) {
2625
e.storage().instance().set(&DataKey::Owner, &owner);
27-
Base::set_metadata(
28-
e,
29-
String::from_str(e, "www.mytoken.com"),
30-
String::from_str(e, "My Token"),
31-
String::from_str(e, "TKN"),
32-
);
26+
Base::set_metadata(e, uri, name, symbol);
3327
}
3428

3529
pub fn mint(e: &Env, to: Address) -> u32 {
@@ -40,16 +34,13 @@ impl ExampleContract {
4034
}
4135
}
4236

43-
#[default_impl]
44-
#[contractimpl]
37+
#[contractimpl(contracttrait)]
4538
impl NonFungibleToken for ExampleContract {
4639
type ContractType = Enumerable;
4740
}
4841

49-
#[default_impl]
50-
#[contractimpl]
42+
#[contractimpl(contracttrait)]
5143
impl NonFungibleEnumerable for ExampleContract {}
5244

53-
#[default_impl]
54-
#[contractimpl]
45+
#[contractimpl(contracttrait)]
5546
impl NonFungibleBurnable for ExampleContract {}

environments.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ name = "me" # Required. Keys for this account will be saved to `./.stellar/ident
99
default = true # Optional. Whether to use this account as the `--source` for commands that need one.
1010

1111
[development.contracts]
12-
fungible_allowlist_example = { client = true, constructor_args = "--admin me --manager me --initial_supply 1000000000000000000000000" }
13-
nft_enumerable_example = { client = true, constructor_args = "--owner me" }
12+
fungible_allowlist_example = { client = true, constructor_args = "--name ExampleToken --symbol EXT --admin me --manager me --initial_supply 1000000000000000000000000" }
13+
nft_enumerable_example = { client = true, constructor_args = "--uri https://example.com/nft/ --name ExampleNFT --symbol ENFT --owner me" }
1414

1515
# Rather than in one list, TOML allows specifying contracts in their own "sections"
1616
[development.contracts.guess_the_number]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "npm start",
88
"start": "concurrently --kill-others-on-fail --names stellar,vite -c gray,green --pad-prefix \"stellar scaffold watch --build-clients\" \"vite\"",
99
"build": "tsc -b && vite build",
10-
"install:contracts": "npm install --workspace=packages && npm run build --workspace=packages",
10+
"install:contracts": "npm install --workspaces && npm run build --workspaces",
1111
"preview": "vite preview",
1212
"lint": "eslint .",
1313
"format": "prettier . --write",

0 commit comments

Comments
 (0)