diff --git a/.cargo/config.toml b/.cargo/config.toml index 0de47a0..c6820d7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,10 +1,2 @@ [build] -target = "wasm32-unknown-unknown" - -[target.wasm32-unknown-unknown] -rustflags = [ - "-C", "opt-level=z", - "-C", "codegen-units=1", - "-C", "strip=symbols", -] - +target = "wasm32v1-none" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3053e54 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: + pull_request: + branches: [main] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32v1-none + components: rustfmt, clippy + + - run: cargo fmt --all --check + + - run: cargo clippy --all-targets --target x86_64-unknown-linux-gnu -- -D warnings + + - run: cargo test --all --target x86_64-unknown-linux-gnu + + - name: WASM build + run: cargo build --target wasm32v1-none --release --all + + - name: Report contract sizes + run: | + find target/wasm32v1-none/release -maxdepth 1 -name "*.wasm" \ + -exec sh -c 'echo "$(basename $1): $(wc -c < $1) bytes"' _ {} \; diff --git a/Cargo.toml b/Cargo.toml index 2163f35..2bd07ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,10 @@ [workspace] resolver = "2" members = [ - "crates/contracts/core", - "crates/tools", + "campaign", + "token-bridge", + "common", ] -[workspace.package] -version = "0.1.0" -edition = "2021" -rust-version = "1.78" -license = "MIT" - [workspace.dependencies] -soroban-sdk = "21.0.0" -stellar-strkey = "0.0.8" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -tokio = { version = "1.0", features = ["full"] } -anyhow = "1.0" -dotenv = "0.15" +soroban-sdk = { version = "26.0.1" } diff --git a/campaign/Cargo.toml b/campaign/Cargo.toml new file mode 100644 index 0000000..3d3f70c --- /dev/null +++ b/campaign/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "campaign" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +soroban-sdk = { workspace = true } +common = { path = "../common" } + +[dev-dependencies] +soroban-sdk = { version = "26.0.1", features = ["testutils"] } diff --git a/campaign/src/lib.rs b/campaign/src/lib.rs new file mode 100644 index 0000000..b8586af --- /dev/null +++ b/campaign/src/lib.rs @@ -0,0 +1,12 @@ +#![no_std] +use soroban_sdk::{contract, contractimpl, Env}; + +#[contract] +pub struct CampaignContract; + +#[contractimpl] +impl CampaignContract { + pub fn hello(env: Env) -> soroban_sdk::Symbol { + soroban_sdk::Symbol::new(&env, "campaign") + } +} diff --git a/common/Cargo.toml b/common/Cargo.toml new file mode 100644 index 0000000..817633d --- /dev/null +++ b/common/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "common" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +soroban-sdk = { workspace = true } + +[dev-dependencies] +soroban-sdk = { version = "26.0.1", features = ["testutils"] } diff --git a/common/src/lib.rs b/common/src/lib.rs new file mode 100644 index 0000000..92a5077 --- /dev/null +++ b/common/src/lib.rs @@ -0,0 +1,9 @@ +#![no_std] +use soroban_sdk::contracterror; + +#[contracterror] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Error { + NotInitialized = 1, + AlreadyInitialized = 2, +} diff --git a/token-bridge/Cargo.toml b/token-bridge/Cargo.toml new file mode 100644 index 0000000..be67087 --- /dev/null +++ b/token-bridge/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "token-bridge" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +soroban-sdk = { workspace = true } +common = { path = "../common" } + +[dev-dependencies] +soroban-sdk = { version = "26.0.1", features = ["testutils"] } diff --git a/token-bridge/src/lib.rs b/token-bridge/src/lib.rs new file mode 100644 index 0000000..dddd4af --- /dev/null +++ b/token-bridge/src/lib.rs @@ -0,0 +1,12 @@ +#![no_std] +use soroban_sdk::{contract, contractimpl, Env}; + +#[contract] +pub struct TokenBridgeContract; + +#[contractimpl] +impl TokenBridgeContract { + pub fn hello(env: Env) -> soroban_sdk::Symbol { + soroban_sdk::Symbol::new(&env, "token_bridge") + } +}