Skip to content

Commit

Permalink
Make functions entry and add init_setup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vusirikala committed Jan 11, 2024
1 parent 3a289a6 commit 7a476d0
Show file tree
Hide file tree
Showing 7 changed files with 2,011 additions and 1,945 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ impl EntryPoints {
Some(EntryPoints::InitializeVectorPicture { length: *length })
},
EntryPoints::SmartTablePicture { .. } => Some(EntryPoints::InitializeSmartTablePicture),
EntryPoints::EconiaRegisterMarketUser => Some(EntryPoints::EconiaRegisterMarket),
_ => None,
}
}
Expand Down
3,885 changes: 1,949 additions & 1,936 deletions crates/transaction-generator-lib/src/publishing/raw_module_data.rs

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions testsuite/module-publish/src/packages/econia/sources/assets.move
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ module econia::assets {
coin::destroy_mint_cap(mint_cap);
}

/// Wrapper for `init_module()`
/// Similarly initializes the Aptos coin, destroying capabilities.
public fun init_coin_types_setup(publisher: &signer) {
// Initialize Econia test coin types.
init_module(publisher);
// // Initialize Aptos coin type, storing capabilities.
// let (burn_cap, mint_cap) = aptos_coin::initialize_for_test(
// &account::create_signer_with_capability(
// &account::create_test_signer_cap(@aptos_framework)));
// // Destroy Aptos coin burn capability.
// coin::destroy_burn_cap(burn_cap);
// // Destroy Aptos coin mint capability.
// coin::destroy_mint_cap(mint_cap);
}

#[test_only]
/// Wrapper for `mint()`, not requiring signature.
public fun mint_test<CoinType>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ module econia::incentives {

#[test_only]
use aptos_framework::account;
#[test_only]

use econia::assets::{Self, QC, UC};

// Test-only uses <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Expand Down Expand Up @@ -2268,6 +2268,31 @@ module econia::incentives {
TAKER_FEE_DIVISOR, &integrator_fee_store_tiers, false);
}

/// Initialize incentives with `UC` utility coin type.
public fun init_setup(publisher: &signer)
acquires
IncentiveParameters
{
assets::init_coin_types_setup(publisher); // Initialize coin types.
// Vectorize fee store tier parameters.
let integrator_fee_store_tiers = vector[
vector[
FEE_SHARE_DIVISOR_0,
TIER_ACTIVATION_FEE_0,
WITHDRAWAL_FEE_0
],
vector[
FEE_SHARE_DIVISOR_1,
TIER_ACTIVATION_FEE_1,
WITHDRAWAL_FEE_1
]
];
// Initialize incentives with mock utility coin.
set_incentive_parameters<UC>(publisher, MARKET_REGISTRATION_FEE,
UNDERWRITER_REGISTRATION_FEE, CUSTODIAN_REGISTRATION_FEE,
TAKER_FEE_DIVISOR, &integrator_fee_store_tiers, false);
}

#[test_only]
/// Return `true` if `integrator` has an `IntegratorFeeStore` for
/// given `QuoteCoinType` and `market_id`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4905,6 +4905,11 @@ module econia::market {
init_module(&econia); // Init module.
}

public fun init_setup(publisher: &signer) {
registry::init_setup(publisher); // Init registry.
init_module(publisher)
}

#[test_only]
/// Initialize test markets, users, and an integrator, returning
/// user signers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,12 @@ module econia::registry {
econia // Return signer.
}

/// Initialize registry for testing.
public fun init_setup(publisher: &signer) {
init_module(publisher); // Init registry.
incentives::init_setup(publisher); // Init incentives.
}

#[test_only]
/// Register pure coin and generic markets, returning market info.
public fun register_markets_test(): (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module econia::txn_generator_utils {
use econia::incentives;
use econia::assets::{Self, BC, QC, UC};
use econia::user;
use aptos_framework::coin;
use aptos_framework::coin::{Coin, Self};
use aptos_framework::signer;
// use aptos_framework::account;

Expand All @@ -29,31 +29,32 @@ module econia::txn_generator_utils {
const CANCEL_MAKER: u8 = 2;


public fun register_market(publisher: &signer) {
public entry fun register_market(publisher: &signer) {
market::init_setup(publisher);
// Get market registration fee.
let fee = incentives::get_market_registration_fee();
// Register publisher coin store.
coin::register<UC>(publisher);
// // Register publisher coin store.
// coin::register<APT>(publisher);
// Register pure coin market.
market::register_market_base_coin<BC, QC, UC>(
LOT_SIZE_COIN, TICK_SIZE_COIN, MIN_SIZE_COIN,
assets::mint(publisher, fee));
}

public fun register_market_accounts(user: &signer) {
public entry fun register_market_accounts(user: &signer) {
user::register_market_account<BC, QC>(user, MARKET_ID_COIN, NO_CUSTODIAN);
}

public fun deposit_coins(user: &signer) {
public entry fun deposit_coins(user: &signer) {
user::deposit_coins<QC>(signer::address_of(user), MARKET_ID_COIN, NO_CUSTODIAN, assets::mint<QC>(user, 1000));
user::deposit_coins<BC>(signer::address_of(user), MARKET_ID_COIN, NO_CUSTODIAN, assets::mint<BC>(user, 1000));
}

public fun place_bid_limit_order(user: &signer, price: u64) {
public entry fun place_bid_limit_order(user: &signer, price: u64) {
market::place_limit_order_user<BC, QC>(user, MARKET_ID_COIN, @econia, BID, 3, price, 2, CANCEL_MAKER);
}

public fun place_ask_limit_order(user: &signer, price: u64) {
public entry fun place_ask_limit_order(user: &signer, price: u64) {
market::place_limit_order_user<BC, QC>(user, MARKET_ID_COIN, @econia, ASK, 3, price, 2, CANCEL_MAKER);
}
}
Expand Down

0 comments on commit 7a476d0

Please sign in to comment.