Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a script to populate the Setter contract #52

Merged
merged 8 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
15 changes: 12 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,20 @@ jobs:
- uses: actions/checkout@v3
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: rustup target add wasm32-unknown-unknown
- uses: stellar/binaries@v16
- uses: stellar/binaries@v22
with:
name: soroban-cli
version: 0.8.7
version: '21.0.0-preview.1'
- name: build
run: cd ContractExamples && cargo build --verbose
- name: unit tests
run: cd ContractExamples && cargo test --verbose
run: cd ContractExamples && cargo test --verbose
- name: populating Setter
run: |
soroban network add \
--global testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015"
soroban keys generate --global alice --network testnet
cd ContractExamples
./scripts/setter-populate.sh
2 changes: 1 addition & 1 deletion ContractExamples/contracts/setter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fetcher.

## How to use

1. Make sure that you have installed Soroban by following the [Getting Started]
1. Make sure that you have installed Soroban by following the [Getting Started][]
guide.

1. Deploy the setter contract:
Expand Down
8 changes: 8 additions & 0 deletions ContractExamples/contracts/setter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#![no_std]
/**
* A test contract for better understanding of the ledger layout of Soroban contracts.
*
* Igor Konnov, 2024.
*
* @license
* [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)
*/

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

Expand Down
8 changes: 8 additions & 0 deletions ContractExamples/contracts/setter/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#![cfg(test)]
/**
* Unit tests for Setter.
*
* Igor Konnov, 2024.
*
* @license
* [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)
*/

use super::*;
use soroban_sdk::{
Expand Down
52 changes: 52 additions & 0 deletions ContractExamples/scripts/setter-populate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Deploy the setter contract and populate its state with data.
#
# Igor Konnov, 2024
#
# @license
# [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)


set -e

dir=$(cd `dirname $0`; pwd -P)

cd ${dir}/..

set -x

soroban contract build
soroban contract deploy --wasm target/wasm32-unknown-unknown/release/setter.wasm \
--source alice --network testnet | tee >.setter.id

soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_bool --v true
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_u32 --v 42
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_i32 --v -42
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_u64 --v 42
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_i64 --v -42
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_u128 --v 42
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_i128 --v -42
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_sym --v hello
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_bytes --v beef
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_bytes32 --v beef0123456789beef0123456789beef0123456789ab
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_vec --v '[ 1, -2, 3 ]'
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_map --v '{ "2": 3, "4": 5 }'
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_address --v GDIY6AQQ75WMD4W46EYB7O6UYMHOCGQHLAQGQTKHDX4J2DYQCHVCR4W4
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_my_struct --v '{ "a": 1, "b": "-100" }'
soroban contract invoke --id $(cat .setter.id) --source alice --network testnet \
-- set_my_enum --v A
Loading