Skip to content

Commit

Permalink
feat: update to newest loam and add CI test
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Aug 25, 2023
1 parent 68d5029 commit cf8a18c
Show file tree
Hide file tree
Showing 22 changed files with 225 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xtask = "run --package xtask --"
bwl = "build --profile release-with-logs"
install_soroban = "binstall -y --install-path ./target/bin soroban-cli --version 0.8.7"
install_soroban_dev = "install --git https://github.com/ahalabs/soroban-tools --rev 2966e7ac9cbcc9f408b80f4aa21c3b76ccf064c6 --debug --root ./target soroban-cli"
install_loam = "install --git https://github.com/loambuild/loam-sdk --rev 9e8773367fae11dfe6dfe6277de9ff3b771faa2a --debug --root ./target loam-cli"
install_soroban_dev = "install --git https://github.com/ahalabs/soroban-tools --rev 5e28f84861e3d031dd23d3dcd964bbe13f876511 --debug --root ./target soroban-cli"
install_loam = "install --git https://github.com/loambuild/loam-sdk --rev ee47f39b270569ce25eaead80da4a9859ee21868 --debug --root ./target loam-cli"
# c = "check"
# t = "test"
# r = "run"
Expand Down
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SOROBAN_CONTRACT_ID=a0ac4c26215ee63cbf9084ae2aa369df3808cf4a2a3f57a1da07956562791258
SOROBAN_NETWORK=standalone
SOROBAN_ACCOUNT=default
CONFIG_DIR=.
39 changes: 39 additions & 0 deletions .github/workflows/standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: standalone RPC

on: [push]

jobs:
test:
name: test generated libraries
runs-on: ubuntu-20.04
services:
rpc:
image: stellar/quickstart:soroban-dev@sha256:a6b03cf6b0433c99f2f799b719f0faadbb79684b1b763e7674ba749fb0f648ee
ports:
- 8000:8000
env:
ENABLE_LOGS: true
NETWORK: standalone
ENABLE_SOROBAN_RPC: true
options: >-
--health-cmd "curl -X POST \"http://localhost:8000/soroban/rpc\""
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: rustup update
- run: rustup target add wasm32-unknown-unknown
- run: just setup
- run: just clean
- run: just publish_all
- run: just deployed_contracts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target/
.soroban
!./.soroban/network/standalone.toml

2 changes: 2 additions & 0 deletions .soroban/network/standalone.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rpc_url = "http://localhost:8000/soroban/rpc"
network_passphrase = "Standalone Network ; February 2017"
20 changes: 15 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ lto = true


[workspace.dependencies]
# loam-sdk = { path = "../../loam/crates/loam" }
# loam-sdk = { path = "../../loam/crates/loam-sdk" }
# loam-sdk-core-riff = { path = "../../loam/crates/loam-core" }
loam-sdk = { git = "https://github.com/loambuild/loam-sdk", tag = "v0.5.0" }
loam-sdk-core-riff = { git = "https://github.com/loambuild/loam-sdk", tag = "v0.5.0" }
loam-sdk = { git = "https://github.com/loambuild/loam-sdk", tag = "v0.6.1" }
loam-sdk-core-riff = { git = "https://github.com/loambuild/loam-sdk", tag = "v0.6.1" }
clap = { version = "4.1.8", features = [
"derive",
"env",
"deprecated",
"string",
] }
base64 = "0.13.0"
thiserror = "1.0.31"
serde = "1.0.82"
serde_derive = "1.0.82"
Expand All @@ -59,6 +58,6 @@ serde-aux = "4.1.2"
hex = "0.4.3"
num-bigint = "0.4"
tokio = { version = "1", features = ["full"] }
soroban-cli = "0.8.7"
soroban-cli = "0.9.4"
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,8 @@ To deploy your own Smartdeploy first run:
```bash
just clean
```

Then you can deploy it:

```bash
just deploy_self
```

### Publish and deploy all the finished example contracts

Once Smartdeploy is deployed

```bash
just publish_all
Expand Down
2 changes: 1 addition & 1 deletion contract_id.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CBEBBQOYOWPVAOZ3BAIVVHPRLJSOB5OICXC7HNKTJNMLTPAWILQHR6SM
CAES56G5MJQW6UJAYIHQLH3B7N3UP6WPOHUFQ6SKHGBX47RV4AAG5NMN
23 changes: 23 additions & 0 deletions contracts/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "core-riff"
description = "Smallest Redeployable Contract"
version = "0.0.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false

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

[dependencies]
loam-sdk = { workspace = true, features = ["loam-soroban-sdk"] }
loam-sdk-core-riff = { workspace = true }


[dev_dependencies]
loam-sdk = { workspace = true, features = ["soroban-sdk-testutils"] }

[package.metadata.loam]
contract = true
11 changes: 11 additions & 0 deletions contracts/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_std]
use loam_sdk::{soroban_contract, soroban_sdk};
use loam_sdk_core_riff::{owner::Owner, CoreRiff};

pub struct Contract;

impl CoreRiff for Contract {
type Impl = Owner;
}

soroban_contract!();
6 changes: 5 additions & 1 deletion contracts/smartdeploy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ doctest = false
[dependencies]
loam-sdk = { workspace = true }
loam-sdk-core-riff = { workspace = true }
core-riff = { path = "../core" }

[dev_dependencies]
loam-sdk = { workspace = true, features = ["soroban-sdk-testutils"] }

[package.metadata.loam]
contract = true
contract = true

# should add this here
#[package.metadata.loam.dependencies]
3 changes: 3 additions & 0 deletions contracts/smartdeploy/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ pub enum Error {

/// Contract already claimed
AlreadyClaimed = 6,

/// Failed to initialize contract
InitFailed = 7,
}
10 changes: 8 additions & 2 deletions contracts/smartdeploy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![no_std]
use loam_sdk::{soroban_contract, soroban_sdk};
use loam_sdk_core_riff::{owner::Owner, CoreRiff};
use registry::{contract::ContractRegistry, wasm::WasmRegistry, Deployable, Publishable};
use registry::{
contract::ContractRegistry, wasm::WasmRegistry, Deployable, DevDeployable, Publishable,
};

pub mod error;
pub mod metadata;
Expand All @@ -22,11 +24,15 @@ impl Deployable for Contract {
type Impl = ContractRegistry;
}

impl DevDeployable for Contract {
type Impl = ContractRegistry;
}

impl CoreRiff for Contract {
type Impl = Owner;
}

soroban_contract!();
soroban_contract!(WasmRegistry impl Publishable, Deployable = ContractRegistry, CoreRiff = Owner);

#[cfg(test)]
mod test;
14 changes: 13 additions & 1 deletion contracts/smartdeploy/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait IsPublishable {
&mut self,
contract_name: soroban_sdk::String,
author: soroban_sdk::Address,
bytes: soroban_sdk::Bytes,
wasm: soroban_sdk::Bytes,
repo: Option<soroban_sdk::String>,
kind: Option<version::Update>,
) -> Result<(), Error>;
Expand Down Expand Up @@ -79,3 +79,15 @@ pub trait IsDeployable {
limit: Option<u32>,
) -> Result<soroban_sdk::Vec<(soroban_sdk::String, soroban_sdk::Address)>, Error>;
}


#[riff]
pub trait IsDevDeployable {
/// Skips the publish step to deploy a contract directly, keeping the name
fn dev_deploy(
&mut self,
name: soroban_sdk::String,
owner: soroban_sdk::Address,
wasm: soroban_sdk::Bytes,
) -> Result<soroban_sdk::Address, Error>;
}
Loading

0 comments on commit cf8a18c

Please sign in to comment.