Skip to content

Commit 0f9a108

Browse files
authored
Merge pull request #52 from freespek/igor/setter-populate
Add a script to populate the Setter contract
2 parents 539ab72 + f314fb1 commit 0f9a108

File tree

5 files changed

+91
-4
lines changed

5 files changed

+91
-4
lines changed

.github/workflows/main.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,23 @@ jobs:
5757
- uses: actions/checkout@v3
5858
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
5959
- run: rustup target add wasm32-unknown-unknown
60-
- uses: stellar/binaries@v16
60+
- uses: stellar/binaries@v22
6161
with:
6262
name: soroban-cli
63-
version: 0.8.7
63+
version: '20.0.0-rc.4.1'
64+
# version 21 is not available in stellar/binaries yet
65+
#version: '21.0.0-preview.1'
6466
- name: build
6567
run: cd ContractExamples && cargo build --verbose
6668
- name: unit tests
67-
run: cd ContractExamples && cargo test --verbose
69+
run: cd ContractExamples && cargo test --verbose
70+
# v21 is not available in stellar/binaries yet
71+
#- name: populating Setter
72+
# run: |
73+
# soroban network add \
74+
# --global testnet \
75+
# --rpc-url https://soroban-testnet.stellar.org:443 \
76+
# --network-passphrase "Test SDF Network ; September 2015"
77+
# soroban keys generate --global alice --network testnet
78+
# cd ContractExamples
79+
# ./scripts/setter-populate.sh

ContractExamples/contracts/setter/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fetcher.
44

55
## How to use
66

7-
1. Make sure that you have installed Soroban by following the [Getting Started]
7+
1. Make sure that you have installed Soroban by following the [Getting Started][]
88
guide.
99

1010
1. Deploy the setter contract:

ContractExamples/contracts/setter/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#![no_std]
2+
/**
3+
* A test contract for better understanding of the ledger layout of Soroban contracts.
4+
*
5+
* Igor Konnov, 2024.
6+
*
7+
* @license
8+
* [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)
9+
*/
210

311
use soroban_sdk::{contract, contractimpl, contracttype, log, symbol_short, vec, Address, Bytes, BytesN, Env, Map, Symbol, Vec};
412

ContractExamples/contracts/setter/src/test.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#![cfg(test)]
2+
/**
3+
* Unit tests for Setter.
4+
*
5+
* Igor Konnov, 2024.
6+
*
7+
* @license
8+
* [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)
9+
*/
210

311
use super::*;
412
use soroban_sdk::{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Deploy the setter contract and populate its state with data.
4+
#
5+
# Igor Konnov, 2024
6+
#
7+
# @license
8+
# [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)
9+
10+
11+
set -e
12+
13+
dir=$(cd `dirname $0`; pwd -P)
14+
15+
cd ${dir}/..
16+
17+
NET=testnet
18+
(soroban network ls | grep -q $NET) || (echo "add testnet via soroban network"; exit 1)
19+
20+
ACCOUNT=alice
21+
soroban keys address $ACCOUNT || (echo "add the account $ALICE via soroban keys generate"; exit 1)
22+
23+
24+
set -x
25+
26+
soroban contract build
27+
soroban contract deploy --wasm target/wasm32-unknown-unknown/release/setter.wasm \
28+
--source $ACCOUNT --network $NET | tee >.setter.id
29+
30+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
31+
-- set_bool --v true
32+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
33+
-- set_u32 --v 42
34+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
35+
-- set_i32 --v '-42'
36+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
37+
-- set_u64 --v 42
38+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
39+
-- set_i64 --v '-42'
40+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
41+
-- set_u128 --v 42
42+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
43+
-- set_i128 --v '-42'
44+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
45+
-- set_sym --v hello
46+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
47+
-- set_bytes --v beef
48+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
49+
-- set_bytes32 --v beef0123456789beef0123456789beef0123456789ab
50+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
51+
-- set_vec --v '[ 1, -2, 3 ]'
52+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
53+
-- set_map --v '{ "2": 3, "4": 5 }'
54+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
55+
-- set_address --v GDIY6AQQ75WMD4W46EYB7O6UYMHOCGQHLAQGQTKHDX4J2DYQCHVCR4W4
56+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
57+
-- set_my_struct --v '{ "a": 1, "b": "-100" }'
58+
soroban contract invoke --id $(cat .setter.id) --source $ACCOUNT --network $NET \
59+
-- set_my_enum --v A

0 commit comments

Comments
 (0)