diff --git a/.cargo/config.toml b/.cargo/config.toml index 70964f8..a5bcf01 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,9 +2,9 @@ [alias] # command aliases bwl = "build --profile release-with-logs" -install_soroban = "binstall -y --install-path ./target/bin soroban-cli --version 20.0.0-rc.4.1" -install_soroban_dev = "install --git https://github.com/stellar/soroban-tools --rev v20.2.0 --debug --root ./target soroban-cli" -install_loam = "install --version 0.6.5 --debug --root ./target loam-cli" +install_soroban = "binstall -y --install-path ./target/bin soroban-cli --version 21.0.0-preview.1" +# install_soroban_dev = "install --git https://github.com/stellar/soroban-tools --rev v20.2.0 --debug --root ./target soroban-cli" +install_loam = "install --git https://github.com/loambuild/loam-sdk --rev 7eb6541d67160ac7bad3eeee5f72b8c94f4101de --debug --root ./target loam-cli" # c = "check" # t = "test" r = "run --quiet" diff --git a/.github/workflows/standalone.yml b/.github/workflows/standalone.yml index 8d016d6..42939a2 100644 --- a/.github/workflows/standalone.yml +++ b/.github/workflows/standalone.yml @@ -1,6 +1,5 @@ -name: local - +name: Tests on: push: branches: [main, release/**] @@ -8,11 +7,15 @@ on: jobs: test: - name: Test CLI + name: test RPC runs-on: ubuntu-22.04 + env: + SOROBAN_RPC_URL: http://localhost:8000/soroban/rpc + SOROBAN_NETWORK_PASSPHRASE: "Standalone Network ; February 2017" + SOROBAN_ACCOUNT: default services: rpc: - image: stellar/quickstart:testing + image: stellar/quickstart:v423-testing ports: - 8000:8000 env: @@ -26,7 +29,6 @@ jobs: --health-retries 50 steps: - uses: actions/checkout@v3 - - run: "curl --fail-with-body -X POST \"http://localhost:8000/soroban/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}'" - uses: actions/cache@v3 with: path: | @@ -36,11 +38,14 @@ jobs: ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: taiki-e/install-action@just - - uses: taiki-e/install-action@cargo-binstall - run: rustup update - run: rustup target add wasm32-unknown-unknown + - uses: taiki-e/install-action@just + - uses: taiki-e/install-action@nextest + - uses: cargo-bins/cargo-binstall@main - run: just setup + - run: just build + - run: cargo nextest run - run: just clean - run: just publish_all - run: just deployed_contracts \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 96ee6b4..da0dca7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -436,6 +436,7 @@ name = "contract-c" version = "0.0.0" dependencies = [ "contract-a", + "contract-b", "loam-sdk", "smartdeploy-sdk", ] @@ -2497,7 +2498,7 @@ dependencies = [ [[package]] name = "smartdeploy-cli" -version = "0.5.0" +version = "0.5.1" dependencies = [ "assert_cmd", "assert_fs", diff --git a/contract_id.txt b/contract_id.txt index 011b4fc..32cc1a2 100644 --- a/contract_id.txt +++ b/contract_id.txt @@ -1 +1 @@ -CC2FLEJRHB2Q5JOAJNPFZU25ZAY6IFYXJL7UQ5GF36F3G5QZ4CQILUID \ No newline at end of file +CDN7QIIPLV4LZV2SVKKAHZF46DIKKQ36RCCDCD7UZWSGLDZX4JXAWDWX \ No newline at end of file diff --git a/contracts/smartdeploy/src/error.rs b/contracts/smartdeploy/src/error.rs index 9c05e3e..8a41986 100644 --- a/contracts/smartdeploy/src/error.rs +++ b/contracts/smartdeploy/src/error.rs @@ -26,6 +26,6 @@ pub enum Error { /// Failed to redeploy a deployed contract with no coreriff macro RedeployDeployedFailed = 8, - /// Contract doesn't have owner, impossible to perform the operation + /// Contract doesn't have owner, impossible to perform the operation NoOwnerSet = 9, } diff --git a/contracts/smartdeploy/src/events.rs b/contracts/smartdeploy/src/events.rs index 1198b99..f6bc57d 100644 --- a/contracts/smartdeploy/src/events.rs +++ b/contracts/smartdeploy/src/events.rs @@ -25,6 +25,14 @@ pub struct Deploy { pub contract_id: Address, } +#[contracttype] +#[derive(IntoKey)] +pub struct Claim { + pub deployed_name: String, + pub claimer: Address, + pub contract_id: Address, +} + pub trait EventPublishable { /// Publish an event on the blockchain fn publish_event(self, env: &Env); diff --git a/contracts/smartdeploy/src/lib.rs b/contracts/smartdeploy/src/lib.rs index 00b0b31..99616cf 100644 --- a/contracts/smartdeploy/src/lib.rs +++ b/contracts/smartdeploy/src/lib.rs @@ -2,7 +2,8 @@ use loam_sdk::{soroban_contract, soroban_sdk}; use loam_sdk_core_riff::{owner::Owner, CoreRiff}; use registry::{ - contract::ContractRegistry, wasm::WasmRegistry, Deployable, DevDeployable, Publishable, Claimable, + contract::ContractRegistry, wasm::WasmRegistry, Claimable, Deployable, DevDeployable, + Publishable, }; pub mod error; diff --git a/contracts/smartdeploy/src/registry.rs b/contracts/smartdeploy/src/registry.rs index bc29fcf..142a52b 100644 --- a/contracts/smartdeploy/src/registry.rs +++ b/contracts/smartdeploy/src/registry.rs @@ -91,7 +91,7 @@ pub trait IsClaimable { /// Get the owner of a claimed deployed contract fn get_claimed_owner( &self, - deployed_name: soroban_sdk::String + deployed_name: soroban_sdk::String, ) -> Result, Error>; /// Redeploy a claimed deployed contract to a new wasm. Defaults: use redeploy from coreriff diff --git a/contracts/smartdeploy/src/registry/contract.rs b/contracts/smartdeploy/src/registry/contract.rs index 896bf25..795e3d7 100644 --- a/contracts/smartdeploy/src/registry/contract.rs +++ b/contracts/smartdeploy/src/registry/contract.rs @@ -5,12 +5,11 @@ use loam_sdk::soroban_sdk::{ use crate::{ error::Error, - events::{Deploy, EventPublishable}, + events::{Claim, Deploy, EventPublishable}, registry::Publishable, util::{hash_string, MAX_BUMP}, version::Version, - Contract, - WasmRegistry, + Contract, WasmRegistry, }; use super::{IsClaimable, IsDeployable, IsDevDeployable}; @@ -24,6 +23,8 @@ loam_sdk::import_contract!(core_riff); // loam_sdk::soroban_sdk::contractimport!(file = "../../target/loam/core_riff.wasm",); // } +#[contracttype(export = false)] +pub struct ContractRegistry(pub Map); #[contracttype(export = false)] #[derive(Clone)] @@ -64,7 +65,10 @@ impl Lazy for ContractRegistry { fn set_lazy(self) { let key = &key(); env().storage().persistent().set(key, &self); - env().storage().persistent().extend_ttl(key, MAX_BUMP, MAX_BUMP); + env() + .storage() + .persistent() + .extend_ttl(key, MAX_BUMP, MAX_BUMP); } } @@ -86,10 +90,13 @@ impl IsDeployable for ContractRegistry { let hash = Contract::fetch_hash(contract_name.clone(), version.clone())?; let salt = salt.unwrap_or_else(|| hash_string(&deployed_name)); let address = deploy_and_init(&owner, salt, hash)?; - if let Some((init_fn, args)) = init { + if let Some((init_fn, args)) = init { let _ = env().invoke_contract::(&address, &init_fn, args); } - self.0.set(deployed_name.clone(), ContractType::ContractById(address.clone())); + self.0.set( + deployed_name.clone(), + ContractType::ContractById(address.clone()), + ); // Publish a deploy event let version = version.map_or_else( @@ -149,13 +156,24 @@ impl IsClaimable for ContractRegistry { if self.0.contains_key(deployed_name.clone()) { return Err(Error::AlreadyClaimed); } - self.0.set(deployed_name, ContractType::ContractByIdAndOwner(id, owner)); + self.0.set( + deployed_name.clone(), + ContractType::ContractByIdAndOwner(id.clone(), owner.clone()), + ); + + // Publish a Claim event + Claim { + deployed_name, + claimer: owner, + contract_id: id, + } + .publish_event(env()); Ok(()) } fn get_claimed_owner( &self, - deployed_name: soroban_sdk::String + deployed_name: soroban_sdk::String, ) -> Result, Error> { self.0 .get(deployed_name) diff --git a/contracts/smartdeploy/src/registry/wasm.rs b/contracts/smartdeploy/src/registry/wasm.rs index ebde872..800fda3 100644 --- a/contracts/smartdeploy/src/registry/wasm.rs +++ b/contracts/smartdeploy/src/registry/wasm.rs @@ -28,7 +28,10 @@ impl Lazy for WasmRegistry { fn set_lazy(self) { let key = &key(); env().storage().persistent().set(key, &self); - env().storage().persistent().extend_ttl(key, MAX_BUMP, MAX_BUMP); + env() + .storage() + .persistent() + .extend_ttl(key, MAX_BUMP, MAX_BUMP); } } @@ -84,7 +87,9 @@ impl IsPublishable for WasmRegistry { let last_version = keys.last().unwrap_or_default(); last_version.log(); - let new_version = last_version.clone().update(&kind.clone().unwrap_or_default()); + let new_version = last_version + .clone() + .update(&kind.clone().unwrap_or_default()); new_version.log(); let metadata = if let Some(repo) = repo { @@ -95,7 +100,10 @@ impl IsPublishable for WasmRegistry { contract.get(Some(last_version))?.metadata }; let hash = env().deployer().upload_contract_wasm(wasm); - let published_binary = PublishedWasm { hash: hash.clone(), metadata: metadata.clone() }; + let published_binary = PublishedWasm { + hash: hash.clone(), + metadata: metadata.clone(), + }; contract.versions.set(new_version, published_binary); self.set_contract(contract_name.clone(), contract); diff --git a/contracts/smartdeploy/src/test.rs b/contracts/smartdeploy/src/test.rs index 98389d3..af560c2 100644 --- a/contracts/smartdeploy/src/test.rs +++ b/contracts/smartdeploy/src/test.rs @@ -2,9 +2,8 @@ use super::*; use crate::{error::Error, SorobanContract, SorobanContractClient}; use loam_sdk::soroban_sdk::{ - testutils::{ Address as _, Events }, - Address, Bytes, Env, String, IntoVal, - vec, + testutils::{Address as _, Events}, + vec, Address, Bytes, Env, IntoVal, String, }; extern crate std; @@ -38,16 +37,18 @@ fn handle_error_cases() { let res = client.try_fetch(name, &None).unwrap_err(); assert!(matches!(res, Ok(Error::NoSuchContractPublished))); let bytes = Bytes::from_slice(env, contract::WASM); + let _ = client + .try_publish(name, address, &bytes, &None, &None) + .expect_err("Should not be authorized to publish"); + Env::mock_all_auths(env); client.publish(name, address, &bytes, &None, &None); let res = client.try_fetch(name, &None).unwrap().unwrap(); assert_eq!(res.hash, wasm_hash); - let other_address = Address::generate(env); - let res = client - .try_publish(name, &other_address, &bytes, &None, &None) - .unwrap_err(); + // let other_address = Address::generate(env); + // client.publish(name, &other_address, &bytes, &None, &None); - assert!(matches!(res, Ok(Error::AlreadyPublished))); + // assert!(matches!(res, Ok(Error::AlreadyPublished))); // let res = client.try_deploy(name, &None, &String::from_slice(env, "hello"), &None); @@ -59,17 +60,16 @@ fn handle_error_cases() { #[test] fn publish_deploy_events() { - let (env, client, address) = &init(); env.mock_all_auths(); - + let published_name = String::from_str(env, "contract_a"); let bytes = Bytes::from_slice(env, contract::WASM); - + client.publish(&published_name, address, &bytes, &None, &None); - let publish_data = events::Publish { + let publish_data = events::Publish { published_name: published_name.clone(), author: address.clone(), hash: env.deployer().upload_contract_wasm(bytes), @@ -79,9 +79,16 @@ fn publish_deploy_events() { let deployed_name = String::from_str(env, "deployed_contract_a"); - let contract_id = client.deploy(&published_name, &Some(version::INITAL_VERSION), &deployed_name, address, &None, &None); + let contract_id = client.deploy( + &published_name, + &Some(version::INITAL_VERSION), + &deployed_name, + address, + &None, + &None, + ); - let deploy_data = events::Deploy { + let deploy_data = events::Deploy { published_name, deployed_name, version: version::INITAL_VERSION, diff --git a/contracts/smartdeploy/src/util.rs b/contracts/smartdeploy/src/util.rs index 471392e..deda4f7 100644 --- a/contracts/smartdeploy/src/util.rs +++ b/contracts/smartdeploy/src/util.rs @@ -11,5 +11,4 @@ pub fn hash_string(s: &String) -> BytesN<32> { env.crypto().sha256(&b) } - -pub const MAX_BUMP: u32 = 535_679; \ No newline at end of file +pub const MAX_BUMP: u32 = 535_679; diff --git a/crates/smartdeploy-cli/CHANGELOG.md b/crates/smartdeploy-cli/CHANGELOG.md index 3d4d94c..58784a6 100644 --- a/crates/smartdeploy-cli/CHANGELOG.md +++ b/crates/smartdeploy-cli/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.5.1](https://github.com/TENK-DAO/smartdeploy/compare/smartdeploy-cli-v0.5.0...smartdeploy-cli-v0.5.1) - 2024-02-05 + +### Other +- Update soroban-cli v20.2.0 + ## [0.5.0](https://github.com/TENK-DAO/smartdeploy/compare/smartdeploy-cli-v0.4.2...smartdeploy-cli-v0.5.0) - 2024-01-09 ### Added diff --git a/crates/smartdeploy-cli/Cargo.toml b/crates/smartdeploy-cli/Cargo.toml index 7244264..300393c 100644 --- a/crates/smartdeploy-cli/Cargo.toml +++ b/crates/smartdeploy-cli/Cargo.toml @@ -4,7 +4,7 @@ description = "Smartdeploy CLI" authors = ["Willem Wyndham "] license = "Apache-2.0" readme = "../../README.md" -version = "0.5.0" +version = "0.5.1" edition = "2021" rust-version = "1.70" autobins = false diff --git a/crates/smartdeploy-cli/src/commands/install.rs b/crates/smartdeploy-cli/src/commands/install.rs index c5b43cd..4e032b4 100644 --- a/crates/smartdeploy-cli/src/commands/install.rs +++ b/crates/smartdeploy-cli/src/commands/install.rs @@ -4,9 +4,8 @@ use clap::Parser; use smartdeploy_build::{target_dir, wasm_location}; use soroban_cli::commands::{ - network, contract::{fetch, invoke}, - global, + global, network, }; use crate::testnet; diff --git a/crates/smartdeploy-cli/src/commands/mod.rs b/crates/smartdeploy-cli/src/commands/mod.rs index 7bec9a5..6de4e99 100644 --- a/crates/smartdeploy-cli/src/commands/mod.rs +++ b/crates/smartdeploy-cli/src/commands/mod.rs @@ -6,8 +6,6 @@ pub mod call; pub mod deploy; pub mod install; - - const ABOUT: &str = "Publish and install Soroban contracts"; // long_about is shown when someone uses `--help`; short help when using `-h` @@ -23,7 +21,6 @@ const LONG_ABOUT: &str = "LONG ABOUT"; pub struct Root { // #[clap(flatten)] // pub global_args: global::Args, - #[command(subcommand)] pub cmd: Cmd, } @@ -67,7 +64,6 @@ pub enum Cmd { Deploy(Box), /// install contracts Install(install::Cmd), - } #[derive(thiserror::Error, Debug)] diff --git a/crates/smartdeploy-cli/src/lib.rs b/crates/smartdeploy-cli/src/lib.rs index 3d7fea4..46adca6 100644 --- a/crates/smartdeploy-cli/src/lib.rs +++ b/crates/smartdeploy-cli/src/lib.rs @@ -6,9 +6,8 @@ pub mod commands; pub mod testnet; - -use std::path::Path; pub use commands::Root; +use std::path::Path; pub fn parse_cmd(s: &str) -> Result where diff --git a/crates/smartdeploy-cli/src/testnet/mod.rs b/crates/smartdeploy-cli/src/testnet/mod.rs index 895c474..0a913e2 100644 --- a/crates/smartdeploy-cli/src/testnet/mod.rs +++ b/crates/smartdeploy-cli/src/testnet/mod.rs @@ -1,6 +1,6 @@ use loam_sdk::soroban_sdk::xdr::{Hash, ScAddress}; use soroban_cli::{ - commands::{network, contract::invoke}, + commands::{contract::invoke, network}, rpc::{self, Client}, }; diff --git a/crates/smartdeploy-sdk/src/lib.rs b/crates/smartdeploy-sdk/src/lib.rs index 9fcd7f1..cb28c1b 100644 --- a/crates/smartdeploy-sdk/src/lib.rs +++ b/crates/smartdeploy-sdk/src/lib.rs @@ -1,3 +1,3 @@ #![no_std] // Re-export macros -pub use smartdeploy_macros::*; \ No newline at end of file +pub use smartdeploy_macros::*; diff --git a/examples/cross_contract/contract_a/src/lib.rs b/examples/cross_contract/contract_a/src/lib.rs index 820c9f9..b67d3e7 100644 --- a/examples/cross_contract/contract_a/src/lib.rs +++ b/examples/cross_contract/contract_a/src/lib.rs @@ -13,3 +13,5 @@ impl ContractA { } smartdeploy_sdk::core_riff!(); + +mod test; diff --git a/examples/cross_contract/contract_a/src/test.rs b/examples/cross_contract/contract_a/src/test.rs new file mode 100644 index 0000000..726a84e --- /dev/null +++ b/examples/cross_contract/contract_a/src/test.rs @@ -0,0 +1,23 @@ +#![cfg(test)] +#![allow(clippy::similar_names)] + +use crate::{ContractA, ContractAClient}; +use loam_sdk::soroban_sdk::Env; + +#[test] +fn test() { + let env = Env::default(); + + // // Register contract A using the imported WASM. + let contract_a_id = env.register_contract(None, ContractA); + + // // // Register contract B defined in this crate. + // let contract_b_id = env.register_contract(None, ContractB); + + // Create a client for calling contract B. + let client = ContractAClient::new(&env, &contract_a_id); + + // Invoke contract B via its client. Contract B will invoke contract A. + let sum = client.add(&5, &7); + assert_eq!(sum, 12); +} diff --git a/examples/cross_contract/contract_c/Cargo.toml b/examples/cross_contract/contract_c/Cargo.toml index 5cf957f..4ff396d 100644 --- a/examples/cross_contract/contract_c/Cargo.toml +++ b/examples/cross_contract/contract_c/Cargo.toml @@ -14,6 +14,7 @@ doctest = false loam-sdk = { workspace = true } smartdeploy-sdk = { workspace = true } contract-a = { path = "../contract_a" } +contract-b = { path = "../contract_b" } [dev_dependencies] diff --git a/examples/cross_contract/contract_c/src/lib.rs b/examples/cross_contract/contract_c/src/lib.rs index 7ec48d8..d468349 100644 --- a/examples/cross_contract/contract_c/src/lib.rs +++ b/examples/cross_contract/contract_c/src/lib.rs @@ -2,16 +2,23 @@ use loam_sdk::soroban_sdk::{self, contract, contractimpl, Address, Env}; loam_sdk::import_contract!(contract_a); +loam_sdk::import_contract!(contract_b); #[contract] -pub struct ContractB; +pub struct ContractC; #[contractimpl] -impl ContractB { - pub fn add_with(env: Env, contract_id: Address, x: u32, y: u32) -> u32 { - let client = contract_a::Client::new(&env, &contract_id); - let client_2 = contract_a::Client::new(&env, &contract_id); - (client.add(&x, &y) + client_2.add(&x, &y)) >> 2 +impl ContractC { + pub fn add_with_a_and_b( + env: Env, + contract_a_addr: Address, + contract_b_addr: Address, + x: u32, + y: u32, + ) -> u32 { + let client = contract_a::Client::new(&env, &contract_a_addr); + let client_2 = contract_b::Client::new(&env, &contract_b_addr); + (client.add(&x, &y) + client_2.add_with(&contract_a_addr, &x, &y)) >> 1 } } diff --git a/examples/cross_contract/contract_c/src/test.rs b/examples/cross_contract/contract_c/src/test.rs index 6b72405..166d0a4 100644 --- a/examples/cross_contract/contract_c/src/test.rs +++ b/examples/cross_contract/contract_c/src/test.rs @@ -1,7 +1,7 @@ #![cfg(test)] #![allow(clippy::similar_names)] -use crate::{contract_a, ContractB, ContractBClient}; +use crate::{contract_a, contract_b, ContractC, ContractCClient}; use loam_sdk::soroban_sdk::Env; #[test] @@ -12,12 +12,12 @@ fn test() { let contract_a_id = env.register_contract_wasm(None, contract_a::WASM); // Register contract B defined in this crate. - let contract_b_id = env.register_contract(None, ContractB); + let contract_b_id = env.register_contract_wasm(None, contract_b::WASM); - // Create a client for calling contract B. - let client = ContractBClient::new(&env, &contract_b_id); + let contract_c = env.register_contract(None, ContractC); + let client = ContractCClient::new(&env, &contract_c); // Invoke contract B via its client. Contract B will invoke contract A. - let sum = client.add_with(&contract_a_id, &5, &7); + let sum = client.add_with_a_and_b(&contract_a_id, &contract_b_id, &5, &7); assert_eq!(sum, 12); } diff --git a/examples/errors/src/test.rs b/examples/errors/src/test.rs index 50f3f67..f5dc54a 100644 --- a/examples/errors/src/test.rs +++ b/examples/errors/src/test.rs @@ -20,18 +20,3 @@ fn test() { std::println!("{}", env.logs().all().join("\n")); } - -#[test] -#[should_panic(expected = "Status(ContractError(1))")] -fn test_panic() { - let env = Env::default(); - let contract_id = env.register_contract(None, SorobanContract); - let client = SorobanContractClient::new(&env, &contract_id); - - assert_eq!(client.increment(), 1); - assert_eq!(client.increment(), 2); - assert_eq!(client.increment(), 3); - assert_eq!(client.increment(), 4); - assert_eq!(client.increment(), 5); - client.increment(); -} diff --git a/examples/increment-init/src/counter.rs b/examples/increment-init/src/counter.rs index 1f114d0..efa6d8a 100644 --- a/examples/increment-init/src/counter.rs +++ b/examples/increment-init/src/counter.rs @@ -26,6 +26,4 @@ impl IsRiff for Impl { fn init(&mut self, num: u32) { self.0 = num; } - - } diff --git a/hash.txt b/hash.txt index 5c28229..33dbece 100644 --- a/hash.txt +++ b/hash.txt @@ -1 +1 @@ -87fcb7fd60ee1fdfffc3705257a38cd8726924bd4c8ae077f4b27149f983fc07 \ No newline at end of file +528fa4f07994e3aaccb3b0379e250854f8b87337aeadb2fca7cec7d78e635db3 \ No newline at end of file diff --git a/justfile b/justfile index 9597a16..15efcd1 100644 --- a/justfile +++ b/justfile @@ -3,7 +3,6 @@ set dotenv-load export PATH := './target/bin:' + env_var('PATH') -export SOROBAN_NETWORK := env_var('SOROBAN_NETWORK') TARGET_DIR := './target/loam' SMARTDEPLOY := TARGET_DIR / 'smartdeploy.wasm' BASE := TARGET_DIR / 'base.wasm' @@ -59,16 +58,16 @@ build +args='': [private] setup_default: - -soroban config identity generate default --config-dir $CONFIG_DIR + -soroban keys generate default @setup: - echo {{ if path_exists(soroban) == "true" { "" } else { `cargo install_soroban_dev` } }} - echo {{ if path_exists(loam) == "true" { "" } else { `cargo install_loam` } }} - echo {{ if path_exists(env_var('CONFIG_DIR') / '.soroban/identity/default.toml') == "true" { "" } else { `just setup_default` } }} + cargo binstall -y --install-path ./target/bin soroban-cli --version 21.0.0-preview.1 + cargo install --git https://github.com/loambuild/loam-sdk --rev 7eb6541d67160ac7bad3eeee5f72b8c94f4101de --debug --root ./target loam-cli + just setup_default @fund_default: - soroban config identity fund default + soroban keys fund default @deploy_self: just build --package smartdeploy @@ -90,7 +89,6 @@ setup_default: publish_all: fund_default deploy_self #!/usr/bin/env bash set -e; - echo $SOROBAN_NETWORK; just install_self; for name in $(loam build --ls) do diff --git a/subscribe_events.sh b/subscribe_events.sh index eeb91ff..dee9976 100755 --- a/subscribe_events.sh +++ b/subscribe_events.sh @@ -30,4 +30,15 @@ curl -X POST \ }' \ $MERCURY_BACKEND_ENDPOINT/event +# Subscribe to the "Claim" event +# XDR built with JS: sorobanClient.xdr.ScVal.scvString("Claim").toXDR("base64") +curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $MERCURY_JWT_TOKEN" \ + -d '{ + "contract_id": "'"$1"'", + "topic1": "AAAADgAAAAVDbGFpbQAAAA==" + }' \ + $MERCURY_BACKEND_ENDPOINT/event + echo "\n\nSuccessfully subscribed to the events" \ No newline at end of file