-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copying in the example from https://github.com/stellar/stellar-cli/pull/1574/files#diff-0d743a0fa81fee10cf91dbf7fb7480daa248d14468d1cecfa24577ef00597f5b Also: - add a test for it - upgrade to p22 for whole workspace - gitignore test_snapshots We can circle back and use this repo as a submodule in the CLI once this is merged, as we do already in js-stellar-sdk.
- Loading branch information
Showing
12 changed files
with
63 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "constructor-args" | ||
version = "21.5.0" | ||
authors = ["Stellar Development Foundation <[email protected]>"] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
doctest = false | ||
|
||
[dependencies] | ||
soroban-sdk = { workspace = true } | ||
|
||
[dev-dependencies] | ||
soroban-sdk = { workspace = true, features = ["testutils"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![no_std] | ||
use soroban_sdk::{contract, contractimpl, symbol_short, Env, Symbol}; | ||
|
||
#[contract] | ||
pub struct ImmutableCounter; | ||
const COUNTER: Symbol = symbol_short!("COUNTER"); | ||
|
||
#[contractimpl] | ||
impl ImmutableCounter { | ||
/// Example constructor | ||
pub fn __constructor(env: Env, counter: u32) { | ||
env.storage().persistent().set(&COUNTER, &counter); | ||
} | ||
/// Counter value | ||
pub fn counter(env: Env) -> u32 { | ||
env.storage().persistent().get(&COUNTER).unwrap() | ||
} | ||
} | ||
|
||
mod test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![cfg(test)] | ||
|
||
use super::*; | ||
use soroban_sdk::{vec, xdr::ScVal, Env}; | ||
|
||
#[test] | ||
fn constructor_args() { | ||
let env = Env::default(); | ||
let contract_id = env.register(ImmutableCounter, vec![&env, ScVal::U32(42)]); | ||
let client = ImmutableCounterClient::new(&env, &contract_id); | ||
assert_eq!(42u32, client.counter()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters