Skip to content

Commit

Permalink
Add contract that can transfer using the SAC
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Dec 14, 2023
1 parent 659067f commit 8c818c4
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 19 deletions.
2 changes: 2 additions & 0 deletions soroban-test-wasms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ mod curr {
include_bytes!("../wasm-workspace/opt/curr/test_conditional_account.wasm").as_slice();
pub const SAC_REENTRY_TEST_CONTRACT: &[u8] =
include_bytes!("../wasm-workspace/opt/curr/sac_reentry_account.wasm").as_slice();
pub const CONTRACT_SAC_TRANSFER_CONTRACT: &[u8] =
include_bytes!("../wasm-workspace/opt/curr/contract_sac_transfer.wasm").as_slice();
pub const RECURSIVE_ACCOUNT_CONTRACT: &[u8] =
include_bytes!("../wasm-workspace/opt/curr/recursive_account.wasm").as_slice();

Expand Down
48 changes: 32 additions & 16 deletions soroban-test-wasms/wasm-workspace/Cargo.lock

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

7 changes: 4 additions & 3 deletions soroban-test-wasms/wasm-workspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ members = [
"conditional_account",
"sac_reentry_account",
"recursive_account",
"hostile_large_val"
"hostile_large_val",
"contract_sac_transfer"
]
[profile.release]
opt-level = "z"
Expand All @@ -52,11 +53,11 @@ codegen-units = 1
lto = true

[workspace.dependencies.soroban-sdk]
version = "=20.0.0-rc2"
version = "=20.0.0"
git = "https://github.com/stellar/rs-soroban-sdk"

[workspace.dependencies.soroban-env-common]
version = "=20.0.0-rc2"
version = "=20.0.0"
git = "https://github.com/stellar/rs-soroban-env"

# Always build from the local instance of env as we need to rebuild test WASMs
Expand Down
18 changes: 18 additions & 0 deletions soroban-test-wasms/wasm-workspace/contract_sac_transfer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "contract_sac_transfer"
version = "0.0.0"
authors = ["Stellar Development Foundation <info@stellar.org>"]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.74"

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

[dependencies]
soroban-sdk = { workspace = true }
soroban-env-common = { workspace = true }

[features]
next = ["soroban-env-common/next"]
18 changes: 18 additions & 0 deletions soroban-test-wasms/wasm-workspace/contract_sac_transfer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![no_std]

use soroban_sdk::{contract, contractimpl, Env, symbol_short, IntoVal, Address,
};

#[contract]
struct SacTransfer;

#[contractimpl]
impl SacTransfer {
pub fn transfer_1(env: Env, sac_address: Address, to: Address) {
env.invoke_contract::<()>(&sac_address, &symbol_short!("transfer"),
(env.current_contract_address(),
to,
1_i128
).into_val(&env));
}
}
Binary file not shown.

0 comments on commit 8c818c4

Please sign in to comment.