Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["soroban", "transfer_state_machine"]
members = ["soroban", "transfer_state_machine", "escrow_contract"]
resolver = "2"

[profile.release]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ locking/escrow, operator rotation, and transfer state tracking.

## Workspace layout

This is a Cargo workspace with two members:
This is a Cargo workspace with the following members:

| Crate | Description |
| --- | --- |
| `soroban/` | Core Soroban contracts (access control, trusted sources, escrow, thresholds) |
| `soroban/` | Core Soroban contracts (access control, trusted sources, thresholds) |
| `escrow_contract/` | Time-locked escrow contract for bridge transfers |
| `transfer_state_machine/` | Transfer state-machine contract logic |
| `harness/` | Test harness and integration helpers |

Expand Down
19 changes: 19 additions & 0 deletions escrow_contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "escrow-contract"
version = "0.1.0"
edition = "2021"
description = "Soroban time-locked escrow contract for Swipely bridge transfers"
license = "MIT"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
soroban-sdk = { version = "22.0.10" }

[dev-dependencies]
soroban-sdk = { version = "22.0.10", features = ["testutils"] }

[[test]]
name = "escrow_contract_test"
path = "tests/escrow_contract.test.rs"
2 changes: 2 additions & 0 deletions soroban/src/escrow_contract.rs → escrow_contract/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![no_std]

use soroban_sdk::{
contract, contracterror, contractimpl, contracttype, symbol_short, Address, Env, String, Symbol,
Vec,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(test)]

use soroban_sdk::{testutils::{Address as _, Ledger}, Address, Env, String, contract, contractimpl, symbol_short, Vec};
use bridge_watch_contracts::escrow_contract::{TimeLockedEscrowContract, TimeLockedEscrowContractClient};
use escrow_contract::{TimeLockedEscrowContract, TimeLockedEscrowContractClient};

#[contract]
pub struct MockBridgeVerifier;
Expand Down
4 changes: 0 additions & 4 deletions soroban/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ path = "tests/asset_locking.test.rs"
name = "source_trust_test"
path = "tests/source_trust.test.rs"

[[test]]
name = "escrow_contract_test"
path = "tests/escrow_contract.test.rs"

[[test]]
name = "operator_rotation_test"
path = "tests/operator_rotation.test.rs"
Expand Down
4 changes: 2 additions & 2 deletions soroban/src/asset_deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl AssetDeprecationContract {
}

/// Get deprecation configuration for an asset
pub fn get_deprecation_config(
fn get_deprecation_config(
env: &Env,
asset_code: &String,
) -> Result<DeprecationConfig, DeprecationError> {
Expand All @@ -199,7 +199,7 @@ impl AssetDeprecationContract {
}

/// Guard function to check if write operations are allowed
pub fn check_write_allowed(
fn check_write_allowed(
env: &Env,
asset_code: &String,
) -> Result<(), DeprecationError> {
Expand Down
33 changes: 20 additions & 13 deletions soroban/src/batch_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! Allow querying multiple assets or bridges in one call to reduce overhead.
//! Provides deterministic output with comprehensive error handling and size limits.

use alloc::string::ToString;
use soroban_sdk::{
contract, contracterror, contractimpl, contracttype, symbol_short, Env, String, Vec,
};
Expand Down Expand Up @@ -39,7 +40,7 @@ pub enum QueryResult {
/// Successful query with data
Success(String),
/// Query failed with error message
Error(String),
Failure(String),
}

/// Batch query response with deterministic ordering
Expand Down Expand Up @@ -131,7 +132,7 @@ impl BatchQueryContract {
}
Err(e) => {
let error_msg = String::from_str(&env, e);
results.push_back(QueryResult::Error(error_msg));
results.push_back(QueryResult::Failure(error_msg));
error_count += 1;
}
}
Expand Down Expand Up @@ -172,7 +173,7 @@ impl BatchQueryContract {
}
Err(e) => {
let error_msg = String::from_str(&env, e);
results.push_back(QueryResult::Error(error_msg));
results.push_back(QueryResult::Failure(error_msg));
error_count += 1;
}
}
Expand Down Expand Up @@ -266,25 +267,31 @@ impl BatchQueryContract {

fn serialize_asset_data(env: &Env, data: &AssetData) -> String {
// Simple JSON-like serialization
let mut json = String::from_str(
String::from_str(
env,
&format!(
&alloc::format!(
"{{\"asset_code\":\"{}\",\"name\":\"{}\",\"symbol\":\"{}\",\"issuer\":\"{}\",\"status\":\"{}\"}}",
data.asset_code, data.name, data.symbol, data.issuer, data.status
data.asset_code.to_string(),
data.name.to_string(),
data.symbol.to_string(),
data.issuer.to_string(),
data.status.to_string()
),
);
json
)
}

fn serialize_bridge_data(env: &Env, data: &BridgeData) -> String {
// Simple JSON-like serialization
let mut json = String::from_str(
String::from_str(
env,
&format!(
&alloc::format!(
"{{\"bridge_id\":\"{}\",\"name\":\"{}\",\"source_chain\":\"{}\",\"dest_chain\":\"{}\",\"status\":\"{}\"}}",
data.bridge_id, data.name, data.source_chain, data.dest_chain, data.status
data.bridge_id.to_string(),
data.name.to_string(),
data.source_chain.to_string(),
data.dest_chain.to_string(),
data.status.to_string()
),
);
json
)
}
}
Loading
Loading