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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ members = [
"contracts/sweep_controller",
"contracts/shared",
"contracts/reserve_contract",
"contracts/native_transfer",
]
1 change: 1 addition & 0 deletions contracts/ephemeral_account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bridgelet-shared = { path = "../shared", version = "0.1.0" }

[dev-dependencies]
soroban-sdk = { version = "22.0.0", features = ["testutils"] }
bridgelet-shared = { path = "../shared", features = ["testutils"] }

[profile.release]
opt-level = "z"
Expand Down
18 changes: 18 additions & 0 deletions contracts/native_transfer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "native-transfer"
version = "0.1.0"
edition = "2021"

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

[dependencies]
soroban-sdk = "22.0.0"
bridgelet-shared = { path = "../shared" }

[dev-dependencies]
soroban-sdk = { version = "22.0.0", features = ["testutils"] }
bridgelet-shared = { path = "../shared", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
8 changes: 8 additions & 0 deletions contracts/native_transfer/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use soroban_sdk::contracterror;

#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Error {
InvalidAmount = 1,
TransferFailed = 2,
}
14 changes: 14 additions & 0 deletions contracts/native_transfer/src/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use soroban_sdk::{contracttype, symbol_short, Address, Env};

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct NativeTransferExecuted {
pub from: Address,
pub to: Address,
pub amount: i128,
}

pub fn emit_native_transfer_executed(env: &Env, from: Address, to: Address, amount: i128) {
let event = NativeTransferExecuted { from, to, amount };
env.events().publish((symbol_short!("native_tx"),), event);
}
17 changes: 17 additions & 0 deletions contracts/native_transfer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![no_std]

mod errors;
mod events;

use soroban_sdk::{contract, contractimpl, Env};

pub use errors::Error;
pub use events::NativeTransferExecuted;

#[contract]
pub struct NativeTransferContract;

#[contractimpl]
impl NativeTransferContract {
// Implementation coming in a future issue
}
1 change: 1 addition & 0 deletions contracts/reserve_contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ soroban-sdk = "22.0.0"

[dev-dependencies]
soroban-sdk = { version = "22.0.0", features = ["testutils"] }
bridgelet-shared = { path = "../shared", features = ["testutils"] }

[profile.release]
opt-level = "z"
Expand Down
3 changes: 3 additions & 0 deletions contracts/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ edition = "2021"
[dependencies]
soroban-sdk = "22.0.0"

[features]
testutils = ["soroban-sdk/testutils"]

[lib]
crate-type = ["rlib"]
2 changes: 1 addition & 1 deletion contracts/shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Payment {
}
// The current status of an ephemeral account.
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq, Copy)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Copy)]
#[repr(u32)]
pub enum AccountStatus {
Active = 0,
Expand Down
1 change: 1 addition & 0 deletions contracts/sweep_controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ soroban-token-sdk = "22.0.0"

[dev-dependencies]
soroban-sdk = { version = "22.0.0", features = ["testutils"] }
bridgelet-shared = { path = "../shared", features = ["testutils"] }


[profile.release]
Expand Down
21 changes: 11 additions & 10 deletions contracts/sweep_controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mod authorization;
mod errors;
mod storage;
// mod transfers;
mod transfers;

use ephemeral_account::EphemeralAccountContractClient as EphemeralAccountClient;
use soroban_sdk::{contract, contractimpl, contracttype, Address, BytesN, Env};
Expand Down Expand Up @@ -115,15 +115,16 @@ impl SweepController {
return Err(Error::AccountNotReady);
}

// Execute the actual token transfer
// Note: In production, the ephemeral account would need to authorize this transfer
// let transfer_ctx = TransferContext::new(
// info.payment_asset,
// ephemeral_account.clone(),
// destination.clone(),
// amount,
// );
// transfer_ctx.execute(&env)?;
// Execute the actual token transfer for each payment asset
for payment in info.payments.iter() {
let transfer_ctx = transfers::TransferContext::new(
payment.asset.clone(),
ephemeral_account.clone(),
destination.clone(),
payment.amount,
);
transfer_ctx.execute(&env)?;
}

// Emit sweep executed event
emit_sweep_completed(&env, ephemeral_account, destination, amount);
Expand Down
Loading