Skip to content

Commit

Permalink
Merge pull request #384 from Phoenix-Protocol-Group/soroban-sdk-21-6-…
Browse files Browse the repository at this point in the history
…0-update

Soroban sdk 21 6 0 update
  • Loading branch information
ueco-jb authored Aug 21, 2024
2 parents b81a8c6 + c43955a commit 0107460
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 231 deletions.
353 changes: 205 additions & 148 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ phoenix = { path = "./packages/phoenix" }
num-integer = { version = "0.1.45", default-features = false, features = [
"i128",
] }
soroban-sdk = "20.5.0"
soroban-token-sdk = "20.5.0"
soroban-sdk = "21.6.0"
soroban-token-sdk = "21.6.0"
test-case = "3.3"
pretty_assertions = "1.4.0"

Expand Down
8 changes: 7 additions & 1 deletion contracts/factory/src/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use soroban_sdk::{
fn factory_successfully_inits_itself() {
let env = Env::default();
let admin = Address::generate(&env);
env.budget().reset_unlimited();

let factory = deploy_factory_contract(&env, Some(admin.clone()));

Expand All @@ -27,14 +28,15 @@ fn factory_successfully_inits_itself() {
fn factory_successfully_inits_multihop() {
let env = Env::default();
env.mock_all_auths();
env.budget().reset_unlimited();

let admin = Address::generate(&env);

let factory = deploy_factory_contract(&env, Some(admin.clone()));

let multihop_address = factory.get_config().multihop_address;

assert!(multihop_address.to_string().len() != 0);
assert!(!multihop_address.to_string().is_empty());
}

#[test]
Expand Down Expand Up @@ -260,6 +262,7 @@ fn factory_fails_to_init_lp_when_no_whitelisted_accounts() {
fn successfully_updates_new_list_of_whitelisted_accounts() {
let env = Env::default();
env.mock_all_auths();
env.budget().reset_unlimited();

let admin = Address::generate(&env);
let first_wl_addr = Address::generate(&env);
Expand Down Expand Up @@ -289,6 +292,7 @@ fn successfully_updates_new_list_of_whitelisted_accounts() {
fn doesn_not_change_whitelisted_accounts_when_removing_non_existent() {
let env = Env::default();
env.mock_all_auths();
env.budget().reset_unlimited();

let admin = Address::generate(&env);

Expand All @@ -309,6 +313,7 @@ fn doesn_not_change_whitelisted_accounts_when_removing_non_existent() {
fn fails_to_update_whitelisted_accounts_when_not_authorized() {
let env = Env::default();
env.mock_all_auths();
env.budget().reset_unlimited();

let admin = Address::generate(&env);
let first_wl_addr = Address::generate(&env);
Expand All @@ -328,6 +333,7 @@ fn fails_to_update_whitelisted_accounts_when_not_authorized() {
fn test_add_vec_with_duplicates_should_be_handled_correctly() {
let env = Env::default();
env.mock_all_auths();
env.budget().reset_unlimited();

let admin = Address::generate(&env);
let first_wl_addr = Address::generate(&env);
Expand Down
75 changes: 55 additions & 20 deletions contracts/factory/src/tests/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ fn test_deploy_multiple_liquidity_pools() {
#[test]
fn test_queries_by_tuple() {
let env = Env::default();
env.budget().reset_unlimited();
let admin = Address::generate(&env);
let user = Address::generate(&env);

Expand Down Expand Up @@ -427,6 +428,7 @@ fn test_queries_by_tuple() {
#[should_panic(expected = "Factory: query_for_pool_by_token_pair failed: No liquidity pool found")]
fn test_queries_by_tuple_errors() {
let env = Env::default();
env.budget().reset_unlimited();
let admin = Address::generate(&env);
let factory = deploy_factory_contract(&env, Some(admin.clone()));

Expand All @@ -436,21 +438,34 @@ fn test_queries_by_tuple_errors() {
#[test]
fn test_query_user_portfolio_with_stake() {
let env = Env::default();
env.budget().reset_unlimited();

let admin = Address::generate(&env);
let fee_recipient = Address::generate(&env);
let manager = Address::generate(&env);
let user_1 = Address::generate(&env);
let user_2 = Address::generate(&env);

let mut token1 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token2 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token3 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token4 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token1 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token2 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token3 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token4 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);

env.mock_all_auths();
env.budget().reset_unlimited();
Expand Down Expand Up @@ -672,20 +687,33 @@ fn test_query_user_portfolio_with_stake() {
#[test]
fn test_query_user_portfolio_with_multiple_users_staking_in_multiple_liquidity_pools() {
let env = Env::default();
env.budget().reset_unlimited();
let admin = Address::generate(&env);
let fee_recipient = Address::generate(&env);
let manager = Address::generate(&env);
let user_1 = Address::generate(&env);
let user_2 = Address::generate(&env);

let mut token1 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token2 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token3 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token4 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token1 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token2 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token3 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token4 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);

env.mock_all_auths();
env.budget().reset_unlimited();
Expand Down Expand Up @@ -1196,16 +1224,23 @@ fn test_query_user_portfolio_with_multiple_users_staking_in_multiple_liquidity_p
#[test]
fn test_query_user_portfolio_without_stake() {
let env = Env::default();
env.budget().reset_unlimited();

let admin = Address::generate(&env);
let fee_recipient = Address::generate(&env);
let manager = Address::generate(&env);
let user_1 = Address::generate(&env);

let mut token1 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token2 =
token_contract::Client::new(&env, &env.register_stellar_asset_contract(admin.clone()));
let mut token1 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);
let mut token2 = token_contract::Client::new(
&env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
);

env.mock_all_auths();
env.budget().reset_unlimited();
Expand Down
6 changes: 5 additions & 1 deletion contracts/multihop/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ pub fn install_token_wasm(env: &Env) -> BytesN<32> {
}

pub fn deploy_token_contract<'a>(env: &Env, admin: &Address) -> token_contract::Client<'a> {
token_contract::Client::new(env, &env.register_stellar_asset_contract(admin.clone()))
token_contract::Client::new(
env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
)
}

#[allow(clippy::too_many_arguments)]
Expand Down
6 changes: 5 additions & 1 deletion contracts/pool/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use crate::{
use phoenix::utils::{LiquidityPoolInitInfo, StakeInitInfo, TokenInitInfo};

pub fn deploy_token_contract<'a>(env: &Env, admin: &Address) -> token_contract::Client<'a> {
token_contract::Client::new(env, &env.register_stellar_asset_contract(admin.clone()))
token_contract::Client::new(
env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
)
}

pub fn install_token_wasm(env: &Env) -> BytesN<32> {
Expand Down
6 changes: 5 additions & 1 deletion contracts/pool_stable/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use crate::{
use phoenix::utils::{LiquidityPoolInitInfo, StakeInitInfo, TokenInitInfo};

pub fn deploy_token_contract<'a>(env: &Env, admin: &Address) -> token_contract::Client<'a> {
token_contract::Client::new(env, &env.register_stellar_asset_contract(admin.clone()))
token_contract::Client::new(
env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
)
}

pub fn install_token_wasm(env: &Env) -> BytesN<32> {
Expand Down
6 changes: 5 additions & 1 deletion contracts/stake/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ use crate::{
};

pub fn deploy_token_contract<'a>(env: &Env, admin: &Address) -> token_contract::Client<'a> {
token_contract::Client::new(env, &env.register_stellar_asset_contract(admin.clone()))
token_contract::Client::new(
env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
)
}

#[allow(clippy::too_many_arguments)]
Expand Down
6 changes: 5 additions & 1 deletion contracts/stake_rewards/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ use crate::{
};

pub fn deploy_token_contract<'a>(env: &Env, admin: &Address) -> token_contract::Client<'a> {
token_contract::Client::new(env, &env.register_stellar_asset_contract(admin.clone()))
token_contract::Client::new(
env,
&env.register_stellar_asset_contract_v2(admin.clone())
.address(),
)
}

const MIN_BOND: i128 = 1000;
Expand Down
Loading

0 comments on commit 0107460

Please sign in to comment.