Skip to content

Commit

Permalink
import contracts correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Sep 20, 2022
1 parent 4dd2f16 commit e053cfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion contracts/crowdfund/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ testutils = ["soroban-sdk/testutils", "soroban-auth/testutils", "soroban-token-c
[dependencies]
soroban-sdk = { version = "0.0.4" }
soroban-auth = { version = "0.0.4" }
soroban-token-contract = { git = "https://github.com/stellar/soroban-examples", rev = "821dd95", default-features = false }
stellar-xdr = { version = "0.0.1", features = ["next", "std"], optional = true }
ed25519-dalek = { version = "1.0.1", optional = true }
sha2 = { version = "0.10.2", optional = true }

[target.'cfg(not(target_family="wasm"))'.dependencies]
soroban-token-contract = { git = "https://github.com/stellar/soroban-examples", rev = "821dd95", default-features = false, optional = true }

[dev_dependencies]
soroban-sdk = { version = "0.0.4", features = ["testutils"] }
soroban-auth = { version = "0.0.4", features = ["testutils"] }
soroban-token-contract = { git = "https://github.com/stellar/soroban-examples", rev = "821dd95", default-features = false, features = ["testutils"] }
soroban-crowdfund-contract = { path = ".", default-features = false, features = ["testutils"] }
rand = { version = "0.7.3" }
11 changes: 7 additions & 4 deletions contracts/crowdfund/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#![no_std]
use soroban_auth::{Identifier, Signature};
use soroban_sdk::{contractimpl, contracttype, BigInt, BytesN, Env, IntoVal, RawVal};
use soroban_token_contract::TokenClient;

mod token {
soroban_sdk::contractimport!(file = "../token/soroban_token_contract.wasm");
}

mod test;
pub mod testutils;
Expand Down Expand Up @@ -67,7 +70,7 @@ fn get_user_deposited(e: &Env, user: &Identifier) -> BigInt {
}

fn get_balance(e: &Env, contract_id: BytesN<32>) -> BigInt {
let client = TokenClient::new(&e, &contract_id);
let client = token::ContractClient::new(&e, &contract_id);
client.balance(&get_contract_id(e))
}

Expand All @@ -93,7 +96,7 @@ fn set_user_deposited(e: &Env, user: &Identifier, amount: BigInt) {

fn transfer(e: &Env, contract_id: BytesN<32>, to: &Identifier, amount: &BigInt) {
let nonce: BigInt = BigInt::zero(&e);
let client = TokenClient::new(&e, &contract_id);
let client = token::ContractClient::new(&e, &contract_id);
client.xfer(&Signature::Contract, &nonce, to, amount);
}

Expand Down Expand Up @@ -169,7 +172,7 @@ impl Crowdfund {
set_user_deposited(&e, &user, balance + amount.clone());

let nonce = BigInt::zero(&e);
let client = TokenClient::new(&e, &get_token(&e));
let client = token::ContractClient::new(&e, &get_token(&e));
client.xfer_from(
&Signature::Contract,
&nonce,
Expand Down

0 comments on commit e053cfe

Please sign in to comment.