Skip to content

Commit

Permalink
update contracts
Browse files Browse the repository at this point in the history
First:

    rm -rf contracts && \
    stellar contract init --with-example atomic_swap auth errors hello_world increment token

Then, update versions in Cargo.toml
  • Loading branch information
chadoh committed Jul 13, 2024
1 parent e44650e commit 3cbbcc2
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 89 deletions.
225 changes: 176 additions & 49 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [
]

[workspace.dependencies]
soroban-sdk = "20.0.0"
soroban-sdk = "21.1.1"

[profile.release]
opt-level = "z"
Expand Down
7 changes: 2 additions & 5 deletions contracts/atomic_swap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[package]
name = "soroban-atomic-swap-contract"
version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.74.0"
publish = false

[lib]
Expand All @@ -14,5 +11,5 @@ doctest = false
[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true }
[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
5 changes: 2 additions & 3 deletions contracts/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "soroban-auth-contract"
version = "0.0.0"
edition = "2021"
rust-version = "1.74.0"
publish = false

[lib]
Expand All @@ -11,5 +10,5 @@ crate-type = ["cdylib"]
[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true }
[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
7 changes: 2 additions & 5 deletions contracts/errors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[package]
name = "soroban-errors-contract"
version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.74.0"
publish = false

[lib]
Expand All @@ -14,5 +11,5 @@ doctest = false
[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true }
[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
9 changes: 3 additions & 6 deletions contracts/hello_world/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[package]
name = "soroban-hello-world-contract"
name = "hello-world"
version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.74.0"
publish = false

[lib]
Expand All @@ -14,5 +11,5 @@ doctest = false
[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true }
[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
7 changes: 2 additions & 5 deletions contracts/increment/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[package]
name = "soroban-increment-contract"
version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.74.0"
publish = false

[lib]
Expand All @@ -14,5 +11,5 @@ doctest = false
[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true }
[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
7 changes: 3 additions & 4 deletions contracts/token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name = "soroban-token-contract"
description = "Soroban standard token contract"
version = "0.0.6"
edition = "2021"
rust-version = "1.74.0"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { workspace = true }
soroban-token-sdk = { version = "20.2.0" }
soroban-token-sdk = { version = "21.1.1" }

[dev_dependencies]
soroban-sdk = { workspace = true }
[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
4 changes: 2 additions & 2 deletions contracts/token/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ impl Token {
panic!("already initialized")
}
write_administrator(&e, &admin);
if decimal > u8::MAX.into() {
panic!("Decimal must fit in a u8");
if decimal > 18 {
panic!("Decimal must not be greater than 18");
}

write_metadata(
Expand Down
1 change: 0 additions & 1 deletion contracts/token/src/storage_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub struct AllowanceValue {
pub enum DataKey {
Allowance(AllowanceDataKey),
Balance(Address),
Nonce(Address),
State(Address),
Admin,
}
11 changes: 3 additions & 8 deletions contracts/token/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,12 @@ fn initialize_already_initialized() {
}

#[test]
#[should_panic(expected = "Decimal must fit in a u8")]
fn decimal_is_over_max() {
#[should_panic(expected = "Decimal must not be greater than 18")]
fn decimal_is_over_eighteen() {
let e = Env::default();
let admin = Address::generate(&e);
let token = TokenClient::new(&e, &e.register_contract(None, Token {}));
token.initialize(
&admin,
&(u32::from(u8::MAX) + 1),
&"name".into_val(&e),
&"symbol".into_val(&e),
);
token.initialize(&admin, &19, &"name".into_val(&e), &"symbol".into_val(&e));
}

#[test]
Expand Down

0 comments on commit 3cbbcc2

Please sign in to comment.