diff --git a/contracts/balanced_doller/Cargo.toml b/contracts/balanced_dollar/Cargo.toml similarity index 100% rename from contracts/balanced_doller/Cargo.toml rename to contracts/balanced_dollar/Cargo.toml diff --git a/contracts/balanced_doller/src/allowance.rs b/contracts/balanced_dollar/src/allowance.rs similarity index 100% rename from contracts/balanced_doller/src/allowance.rs rename to contracts/balanced_dollar/src/allowance.rs diff --git a/contracts/balanced_doller/src/balance.rs b/contracts/balanced_dollar/src/balance.rs similarity index 100% rename from contracts/balanced_doller/src/balance.rs rename to contracts/balanced_dollar/src/balance.rs diff --git a/contracts/balanced_doller/src/balanced_dollar.rs b/contracts/balanced_dollar/src/balanced_dollar.rs similarity index 86% rename from contracts/balanced_doller/src/balanced_dollar.rs rename to contracts/balanced_dollar/src/balanced_dollar.rs index f1d7570..895dd21 100644 --- a/contracts/balanced_doller/src/balanced_dollar.rs +++ b/contracts/balanced_dollar/src/balanced_dollar.rs @@ -1,4 +1,5 @@ use crate::balance::{receive_balance, spend_balance}; +use crate::storage_types::{get_icon_bnusd, get_xcall, get_xcall_manager}; use soroban_sdk::{xdr::ToXdr, Address, Bytes, Env, String, Vec}; mod xcall { soroban_sdk::contractimport!(file = "../../wasm/xcall.wasm"); @@ -6,11 +7,7 @@ mod xcall { use crate::contract; use crate::errors::ContractError; -use crate::states::read_administrator; -use crate::{ - config::{get_config, set_config, ConfigData}, - xcall_manager_interface::XcallManagerClient, -}; +use crate::xcall_manager_interface::XcallManagerClient; use soroban_rlp::balanced::address_utils::is_valid_bytes_address; use soroban_rlp::balanced::messages::{ cross_transfer::CrossTransfer, cross_transfer_revert::CrossTransferRevert, @@ -20,9 +17,6 @@ use xcall::{AnyMessage, CallMessageWithRollback, Client, Envelope}; const CROSS_TRANSFER: &str = "xCrossTransfer"; const CROSS_TRANSFER_REVERT: &str = "xCrossTransferRevert"; -pub fn configure(env: Env, config: ConfigData) { - set_config(&env, config); -} pub fn _cross_transfer( e: Env, @@ -38,13 +32,12 @@ pub fn _cross_transfer( } let xcall_message = CrossTransfer::new(from.clone().to_string(), to, amount, data); let rollback = CrossTransferRevert::new(from.clone(), amount); - let config = get_config(&e); - let icon_bn_usd = config.icon_bn_usd; + let icon_bn_usd = get_icon_bnusd(&e)?; let rollback_bytes = rollback.encode(&e, String::from_str(&e, CROSS_TRANSFER_REVERT)); let message_bytes = xcall_message.encode(&e, String::from_str(&e, CROSS_TRANSFER)); - let (sources, destinations) = xcall_manager_client(&e, &config.xcall_manager).get_protocols(); + let (sources, destinations) = xcall_manager_client(&e, &get_xcall_manager(&e)?).get_protocols(); let message = AnyMessage::CallMessageWithRollback(CallMessageWithRollback { data: message_bytes, @@ -57,7 +50,7 @@ pub fn _cross_transfer( }; let current_address = e.current_contract_address(); - xcall_client(&e, &config.xcall).send_call(&from, ¤t_address, envelope, &icon_bn_usd); + xcall_client(&e, &get_xcall(&e)?).send_call(&from, ¤t_address, envelope, &icon_bn_usd); Ok(()) } @@ -79,12 +72,11 @@ pub fn _handle_call_message( data: Bytes, protocols: Vec, ) -> Result<(), ContractError> { - let config: ConfigData = get_config(&e); - let xcall = config.xcall; + let xcall = get_xcall(&e)?; xcall.require_auth(); let method = CrossTransfer::get_method(&e, data.clone()); - let icon_bn_usd: String = config.icon_bn_usd; + let icon_bn_usd: String = get_icon_bnusd(&e)?; if method == String::from_str(&e, &CROSS_TRANSFER) { if from != icon_bn_usd { return Err(ContractError::OnlyIconBnUSD); @@ -110,7 +102,7 @@ pub fn _handle_call_message( } else { return Err(ContractError::UnknownMessageType); } - verify_protocol(&e, &config.xcall_manager, protocols)?; + verify_protocol(&e, &get_xcall_manager(&e)?, protocols)?; Ok(()) } @@ -150,8 +142,7 @@ pub fn get_address(network_address: String, env: &Env) -> Result u8::MAX.into() { - panic_with_error!(e, ContractError::DecimalMustFitInAu8) - } - write_metadata( &e, TokenMetadata { @@ -47,19 +40,10 @@ impl BalancedDollar { symbol, }, ); - balanced_dollar::configure(e, config); - } - - pub fn set_admin(e: Env, new_admin: Address) { - let admin = read_administrator(&e); - admin.require_auth(); - - write_administrator(&e, &new_admin); - TokenUtils::new(&e).events().set_admin(admin, new_admin); - } - - pub fn get_admin(e: Env) -> Address { - read_administrator(&e) + set_xcall(&e, xcall); + set_icon_bnusd(&e, icon_bnusd); + set_xcall_manager(&e, xcall_manager); + set_upgrade_authority(&e, upgrade_auth); } pub fn cross_transfer( @@ -84,22 +68,18 @@ impl BalancedDollar { } pub fn is_initialized(e: Env) -> bool { - has_administrator(&e) + storage_types::has_upgrade_auth(&e) } - pub fn set_upgrade_authority(e: Env, upgrade_authority: Address) { - let mut config = config::get_config(&e); - - config.upgrade_authority.require_auth(); - - config.upgrade_authority = upgrade_authority; - config::set_config(&e, config); + pub fn set_upgrade_authority(e: Env, new_upgrade_authority: Address) { + let upgrade_authority = get_upgrade_authority(&e).unwrap(); + upgrade_authority.require_auth(); + set_upgrade_authority(&e, new_upgrade_authority); } pub fn upgrade(e: Env, new_wasm_hash: BytesN<32>) { - let config = config::get_config(&e); - config.upgrade_authority.require_auth(); - + let upgrade_authority = get_upgrade_authority(&e).unwrap(); + upgrade_authority.require_auth(); e.deployer().update_current_contract_wasm(new_wasm_hash); } @@ -159,4 +139,13 @@ impl BalancedDollar { pub fn symbol(e: Env) -> String { read_symbol(&e) } + + pub fn xcall_manager(e: Env) -> Address { + storage_types::get_xcall_manager(&e).unwrap() + + } + + pub fn xcall(e: Env) -> Address { + storage_types::get_xcall(&e).unwrap() + } } diff --git a/contracts/balanced_doller/src/errors.rs b/contracts/balanced_dollar/src/errors.rs similarity index 90% rename from contracts/balanced_doller/src/errors.rs rename to contracts/balanced_dollar/src/errors.rs index 539d47f..83f5266 100644 --- a/contracts/balanced_doller/src/errors.rs +++ b/contracts/balanced_dollar/src/errors.rs @@ -14,5 +14,6 @@ pub enum ContractError { InvalidAddress = 8, InvalidNetworkAddressLength = 9, InvalidNetworkAddress = 10, - InvalidAmount = 11 + InvalidAmount = 11, + Uninitialized = 12 } diff --git a/contracts/balanced_doller/src/lib.rs b/contracts/balanced_dollar/src/lib.rs similarity index 87% rename from contracts/balanced_doller/src/lib.rs rename to contracts/balanced_dollar/src/lib.rs index 7948e23..01ec4d2 100644 --- a/contracts/balanced_doller/src/lib.rs +++ b/contracts/balanced_dollar/src/lib.rs @@ -3,11 +3,9 @@ mod allowance; mod balance; pub mod balanced_dollar; -mod config; pub mod contract; mod errors; mod metadata; -mod states; mod storage_types; mod tests; mod xcall_manager_interface; diff --git a/contracts/balanced_doller/src/metadata.rs b/contracts/balanced_dollar/src/metadata.rs similarity index 100% rename from contracts/balanced_doller/src/metadata.rs rename to contracts/balanced_dollar/src/metadata.rs diff --git a/contracts/balanced_dollar/src/storage_types.rs b/contracts/balanced_dollar/src/storage_types.rs new file mode 100644 index 0000000..7f33015 --- /dev/null +++ b/contracts/balanced_dollar/src/storage_types.rs @@ -0,0 +1,87 @@ +use soroban_sdk::{contracttype, Address, Env, String}; + +use crate::errors::ContractError; + +pub(crate) const DAY_IN_LEDGERS: u32 = 17280; +pub(crate) const INSTANCE_BUMP_AMOUNT: u32 = 7 * DAY_IN_LEDGERS; +pub(crate) const INSTANCE_LIFETIME_THRESHOLD: u32 = INSTANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; + +pub(crate) const BALANCE_BUMP_AMOUNT: u32 = 30 * DAY_IN_LEDGERS; +pub(crate) const BALANCE_LIFETIME_THRESHOLD: u32 = BALANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; + +#[derive(Clone)] +#[contracttype] +pub struct AllowanceDataKey { + pub from: Address, + pub spender: Address, +} + +#[contracttype] +pub struct AllowanceValue { + pub amount: i128, + pub expiration_ledger: u32, +} + +#[derive(Clone)] +#[contracttype] +pub enum DataKey { + Allowance(AllowanceDataKey), + Balance(Address), + XcallManager, + XCall, + IconBnusd, + UpgradeAuthority +} + +pub fn set_xcall_manager(e: &Env, value: Address) { + e.storage().instance().set(&DataKey::XcallManager, &value); +} + +pub fn set_xcall(e: &Env, value: Address) { + e.storage().instance().set(&DataKey::XCall, &value); +} + +pub fn set_icon_bnusd(e: &Env, value: String) { + e.storage().instance().set(&DataKey::IconBnusd, &value); +} + +pub fn set_upgrade_authority(e: &Env, value: Address) { + e.storage().instance().set(&DataKey::UpgradeAuthority, &value); +} + +pub fn has_upgrade_auth(e: &Env) -> bool { + let key = DataKey::UpgradeAuthority; + e.storage().instance().has(&key) +} + +pub fn get_xcall_manager(e: &Env) -> Result { + let key = DataKey::XcallManager; + e.storage() + .instance() + .get(&key) + .ok_or(ContractError::Uninitialized)} + +pub fn get_xcall(e: &Env) -> Result { + let key = DataKey::XCall; + e.storage() + .instance() + .get(&key) + .ok_or(ContractError::Uninitialized)} + +pub fn get_icon_bnusd(e: &Env) -> Result { + let key = DataKey::IconBnusd; + e.storage() + .instance() + .get(&key) + .ok_or(ContractError::Uninitialized)} + +pub fn get_upgrade_authority(e: &Env) -> Result { + let key = DataKey::UpgradeAuthority; + e.storage() + .instance() + .get(&key) + .ok_or(ContractError::Uninitialized)} + + + + diff --git a/contracts/balanced_doller/src/tests/balanced_dollar_test.rs b/contracts/balanced_dollar/src/tests/balanced_dollar_test.rs similarity index 93% rename from contracts/balanced_doller/src/tests/balanced_dollar_test.rs rename to contracts/balanced_dollar/src/tests/balanced_dollar_test.rs index 0bc4a54..3643020 100644 --- a/contracts/balanced_doller/src/tests/balanced_dollar_test.rs +++ b/contracts/balanced_dollar/src/tests/balanced_dollar_test.rs @@ -1,14 +1,13 @@ #![cfg(test)] extern crate std; -use crate::{config, contract::BalancedDollarClient}; +use crate::{contract::BalancedDollarClient, storage_types::get_upgrade_authority}; use super::setup::*; use soroban_rlp::balanced::messages::{ cross_transfer::CrossTransfer, cross_transfer_revert::CrossTransferRevert, }; use soroban_sdk::{ - symbol_short, testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation}, Address, Bytes, IntoVal, String, Symbol, Vec, }; @@ -24,31 +23,6 @@ fn test_initialize() { assert_eq!(initialized, true) } -#[test] -fn test_set_admin() { - let ctx = TestContext::default(); - let client = BalancedDollarClient::new(&ctx.env, &ctx.registry); - ctx.init_context(&client); - - let new_admin: Address = Address::generate(&ctx.env); - client.set_admin(&new_admin); - assert_eq!( - ctx.env.auths(), - std::vec![( - ctx.admin.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - ctx.registry.clone(), - symbol_short!("set_admin"), - (&new_admin,).into_val(&ctx.env) - )), - sub_invocations: std::vec![] - } - )] - ); - assert_eq!(client.get_admin(), new_admin); -} - #[test] fn test_cross_transfer_with_to_and_data() { let ctx = TestContext::default(); @@ -398,7 +372,7 @@ fn test_set_upgrade_authority() { ); ctx.env.as_contract(&client.address, || { - let config = config::get_config(&ctx.env); - assert_eq!(config.upgrade_authority, new_upgrade_authority) + let upgrade_authority = get_upgrade_authority(&ctx.env).unwrap(); + assert_eq!(upgrade_authority, new_upgrade_authority) }); } diff --git a/contracts/balanced_doller/src/tests/mod.rs b/contracts/balanced_dollar/src/tests/mod.rs similarity index 100% rename from contracts/balanced_doller/src/tests/mod.rs rename to contracts/balanced_dollar/src/tests/mod.rs diff --git a/contracts/balanced_doller/src/tests/setup.rs b/contracts/balanced_dollar/src/tests/setup.rs similarity index 94% rename from contracts/balanced_doller/src/tests/setup.rs rename to contracts/balanced_dollar/src/tests/setup.rs index 51eb5b0..5bcfb03 100644 --- a/contracts/balanced_doller/src/tests/setup.rs +++ b/contracts/balanced_dollar/src/tests/setup.rs @@ -3,8 +3,6 @@ extern crate std; use crate::contract::{BalancedDollar, BalancedDollarClient}; -use crate::config::ConfigData; - use soroban_sdk::{testutils::Address as _, token, Address, Env, String, Vec}; mod xcall { @@ -34,20 +32,23 @@ pub struct TestContext { pub xcall_manager: Address, pub icon_bn_usd: String, pub icon_governance: String, - pub token: Address, pub centralized_connection: Address, pub nid: String, pub native_token: Address, pub xcall_client: xcall::Client<'static>, } +pub struct ConfigData { + pub xcall: Address, + pub xcall_manager: Address, + pub icon_bn_usd: String, + pub upgrade_authority: Address, +} + impl TestContext { pub fn default() -> Self { let env = Env::default(); let token_admin = Address::generate(&env); - let token = env - .register_stellar_asset_contract_v2(token_admin.clone()) - .address(); let balanced_dollar = env.register_contract(None, BalancedDollar); let centralized_connection = env.register_contract_wasm(None, connection::WASM); let xcall_manager = env.register_contract_wasm(None, xcall_manager::WASM); @@ -67,7 +68,6 @@ impl TestContext { xcall_manager, icon_bn_usd: String::from_str(&env, "icon01/hxjnfh4u"), icon_governance: String::from_str(&env, "icon01/kjdnoi"), - token, centralized_connection, nid: String::from_str(&env, "stellar"), native_token: env @@ -85,11 +85,10 @@ impl TestContext { let config = ConfigData { xcall: self.xcall.clone(), xcall_manager: self.xcall_manager.clone(), - nid: self.nid.clone(), icon_bn_usd: self.icon_bn_usd.clone(), upgrade_authority: self.upgrade_authority.clone(), }; - client.initialize(&self.admin, &config); + client.initialize(&config.xcall, &config.xcall_manager, &config.icon_bn_usd, &config.upgrade_authority); } pub fn init_xcall_manager_context(&self) { diff --git a/contracts/balanced_doller/src/xcall_manager_interface.rs b/contracts/balanced_dollar/src/xcall_manager_interface.rs similarity index 100% rename from contracts/balanced_doller/src/xcall_manager_interface.rs rename to contracts/balanced_dollar/src/xcall_manager_interface.rs diff --git a/contracts/balanced_doller/src/config.rs b/contracts/balanced_doller/src/config.rs deleted file mode 100644 index 3d90e4c..0000000 --- a/contracts/balanced_doller/src/config.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::storage_types::DataKey; -use soroban_sdk::{contracttype, unwrap::UnwrapOptimized, Address, Env, String}; - -#[derive(Clone)] -#[contracttype] -pub struct ConfigData { - pub xcall: Address, - pub xcall_manager: Address, - pub nid: String, - pub icon_bn_usd: String, - pub upgrade_authority: Address, -} - -pub fn set_config(e: &Env, config: ConfigData) { - e.storage().instance().set(&DataKey::Config, &config); -} - -pub fn get_config(e: &Env) -> ConfigData { - let key = DataKey::Config; - e.storage().instance().get(&key).unwrap_optimized() -} diff --git a/contracts/balanced_doller/src/states.rs b/contracts/balanced_doller/src/states.rs deleted file mode 100644 index a820bf0..0000000 --- a/contracts/balanced_doller/src/states.rs +++ /dev/null @@ -1,18 +0,0 @@ -use soroban_sdk::{Address, Env}; - -use crate::storage_types::DataKey; - -pub fn has_administrator(e: &Env) -> bool { - let key = DataKey::Admin; - e.storage().instance().has(&key) -} - -pub fn read_administrator(e: &Env) -> Address { - let key = DataKey::Admin; - e.storage().instance().get(&key).unwrap() -} - -pub fn write_administrator(e: &Env, id: &Address) { - let key = DataKey::Admin; - e.storage().instance().set(&key, id); -} diff --git a/contracts/balanced_doller/src/storage_types.rs b/contracts/balanced_doller/src/storage_types.rs deleted file mode 100644 index 069bbab..0000000 --- a/contracts/balanced_doller/src/storage_types.rs +++ /dev/null @@ -1,30 +0,0 @@ -use soroban_sdk::{contracttype, Address}; - -pub(crate) const DAY_IN_LEDGERS: u32 = 17280; -pub(crate) const INSTANCE_BUMP_AMOUNT: u32 = 7 * DAY_IN_LEDGERS; -pub(crate) const INSTANCE_LIFETIME_THRESHOLD: u32 = INSTANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; - -pub(crate) const BALANCE_BUMP_AMOUNT: u32 = 30 * DAY_IN_LEDGERS; -pub(crate) const BALANCE_LIFETIME_THRESHOLD: u32 = BALANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; - -#[derive(Clone)] -#[contracttype] -pub struct AllowanceDataKey { - pub from: Address, - pub spender: Address, -} - -#[contracttype] -pub struct AllowanceValue { - pub amount: i128, - pub expiration_ledger: u32, -} - -#[derive(Clone)] -#[contracttype] -pub enum DataKey { - Allowance(AllowanceDataKey), - Balance(Address), - Admin, - Config, -} diff --git a/contracts/balanced_doller/src/tests/test.rs b/contracts/balanced_doller/src/tests/test.rs deleted file mode 100644 index 264425a..0000000 --- a/contracts/balanced_doller/src/tests/test.rs +++ /dev/null @@ -1,219 +0,0 @@ -// #![cfg(test)] -// extern crate std; - -// use crate::contract::BalancedDollarClient; - - -// use soroban_sdk::{ -// symbol_short, -// testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation}, -// Address, IntoVal, Symbol, -// }; - -// use super::setup::*; - -// #[test] -// fn test() { -// let ctx = TestContext::default(); -// let client = BalancedDollarClient::new(&ctx.env, &ctx.registry); -// let e = &ctx.env; -// e.mock_all_auths(); -// ctx.init_context(&client); - - -// let admin2 = Address::generate(&e); -// let user1 = Address::generate(&e); -// let user2 = Address::generate(&e); -// let user3 = Address::generate(&e); - -// client.mint(&ctx.admin, &1000); -// assert_eq!( -// e.auths(), -// std::vec![( -// ctx.admin.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// symbol_short!("mint"), -// (&ctx.admin, 1000_i128).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); -// assert_eq!(client.balance(&ctx.admin), 1000); - -// client.approve(&ctx.admin, &user3, &500, &200); -// assert_eq!( -// e.auths(), -// std::vec![( -// ctx.admin.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// symbol_short!("approve"), -// (&ctx.admin, &user3, 500_i128, 200_u32).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); -// assert_eq!(client.allowance(&ctx.admin, &user3), 500); - -// client.transfer(&ctx.admin, &user2, &600); -// assert_eq!( -// e.auths(), -// std::vec![( -// ctx.admin.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// symbol_short!("transfer"), -// (&ctx.admin, &user2, 600_i128).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); -// assert_eq!(client.balance(&ctx.admin), 400); -// assert_eq!(client.balance(&user2), 600); - -// client.transfer_from(&user3, &ctx.admin, &user1, &400); -// assert_eq!( -// e.auths(), -// std::vec![( -// user3.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// Symbol::new(&e, "transfer_from"), -// (&user3, &ctx.admin, &user1, 400_i128).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); -// assert_eq!(client.balance(&user1), 400); -// assert_eq!(client.balance(&user2), 600); - -// client.transfer(&user1, &user3, &300); -// assert_eq!(client.balance(&user1), 100); -// assert_eq!(client.balance(&user3), 300); - -// client.set_admin(&admin2); -// assert_eq!( -// e.auths(), -// std::vec![( -// ctx.admin.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// symbol_short!("set_admin"), -// (&admin2,).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); - -// // Increase to 500 -// client.approve(&user2, &user3, &500, &200); -// assert_eq!(client.allowance(&user2, &user3), 500); -// client.approve(&user2, &user3, &0, &200); -// assert_eq!( -// e.auths(), -// std::vec![( -// user2.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// symbol_short!("approve"), -// (&user2, &user3, 0_i128, 200_u32).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); -// assert_eq!(client.allowance(&user2, &user3), 0); -// } - -// #[test] -// fn test_burn() { -// let ctx = TestContext::default(); -// let client = BalancedDollarClient::new(&ctx.env, &ctx.registry); -// let e = &ctx.env; -// e.mock_all_auths(); -// ctx.init_context(&client); - - -// let user2 = Address::generate(&e); - -// client.mint(&ctx.admin, &1000); -// assert_eq!(client.balance(&ctx.admin), 1000); - -// client.approve(&ctx.admin, &user2, &500, &200); -// assert_eq!(client.allowance(&ctx.admin, &user2), 500); - -// client.burn_from(&user2, &ctx.admin, &500); -// assert_eq!( -// e.auths(), -// std::vec![( -// user2.clone(), -// AuthorizedInvocation { -// function: AuthorizedFunction::Contract(( -// client.address.clone(), -// symbol_short!("burn_from"), -// (&user2, &ctx.admin, 500_i128).into_val(e), -// )), -// sub_invocations: std::vec![] -// } -// )] -// ); - -// assert_eq!(client.allowance(&ctx.admin, &user2), 0); -// assert_eq!(client.balance(&ctx.admin), 500); -// assert_eq!(client.balance(&user2), 0); - -// client.burn(&ctx.admin, &500); - -// assert_eq!(client.balance(&ctx.admin), 0); -// assert_eq!(client.balance(&user2), 0); -// } - -// #[test] -// #[should_panic(expected = "insufficient balance")] -// fn transfer_insufficient_balance() { -// let ctx = TestContext::default(); -// let client = BalancedDollarClient::new(&ctx.env, &ctx.registry); -// let e = &ctx.env; -// e.mock_all_auths(); -// ctx.init_context(&client); -// e.mock_all_auths(); -// let user2 = Address::generate(&e); - -// client.mint(&ctx.admin, &1000); -// assert_eq!(client.balance(&ctx.admin), 1000); - -// client.transfer(&ctx.admin, &user2, &1001); -// } - -// #[test] -// #[should_panic(expected = "insufficient allowance")] -// fn transfer_from_insufficient_allowance() { -// let ctx = TestContext::default(); -// let client = BalancedDollarClient::new(&ctx.env, &ctx.registry); -// let e = &ctx.env; -// e.mock_all_auths(); -// ctx.init_context(&client); -// let user2 = Address::generate(&e); -// let user3 = Address::generate(&e); - -// client.mint(&ctx.admin, &1000); -// assert_eq!(client.balance(&ctx.admin), 1000); - -// client.approve(&ctx.admin, &user3, &100, &200); -// assert_eq!(client.allowance(&ctx.admin, &user3), 100); - -// client.transfer_from(&user3, &ctx.admin, &user2, &101); -// } - diff --git a/script/optimize-stellar.sh b/script/optimize-stellar.sh deleted file mode 100755 index b0fe64a..0000000 --- a/script/optimize-stellar.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -build_directory="target/wasm32-unknown-unknown/release" -artifacts_directory="artifacts/stellar" - -mkdir -p "$artifacts_directory" - -cargo clean -cargo build --target wasm32-unknown-unknown --release - -for WASM in $build_directory/*.wasm; do - NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm - echo "Optimizing $NAME ... $WASM" - stellar contract optimize --wasm "$WASM" -done - -for WASM in $build_directory/*.optimized.wasm; do - NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm - - mv "$WASM" "$artifacts_directory/$NAME" -done - - - diff --git a/scripts/optimize-stellar.sh b/scripts/optimize-stellar.sh index b0fe64a..223e369 100755 --- a/scripts/optimize-stellar.sh +++ b/scripts/optimize-stellar.sh @@ -10,7 +10,7 @@ cargo build --target wasm32-unknown-unknown --release for WASM in $build_directory/*.wasm; do NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm echo "Optimizing $NAME ... $WASM" - stellar contract optimize --wasm "$WASM" + /usr/local/bin/stellar contract optimize --wasm "$WASM" done for WASM in $build_directory/*.optimized.wasm; do