Skip to content

Commit

Permalink
pricing config
Browse files Browse the repository at this point in the history
  • Loading branch information
leecchh committed Oct 22, 2024
1 parent 3e90918 commit dec6acc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/suins/sources/suins.move
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/// the registry and the balance.
module suins::suins {
use sui::{balance::{Self, Balance}, coin::{Self, Coin}, dynamic_field as df, sui::SUI};
use suins::pricing::{Self, new_range};

/// Trying to withdraw from an empty balance.
const ENoProfits: u64 = 0;
Expand Down Expand Up @@ -201,6 +202,19 @@ module suins::suins {
200 * suins::constants::mist_per_sui(),
50 * suins::constants::mist_per_sui(),
));

let range1 = new_range(vector[3, 3]);
let range2 = new_range(vector[4, 4]);
let range3 = new_range(vector[5, 63]);
let prices = vector[
1200 * suins::constants::mist_per_sui(),
200 * suins::constants::mist_per_sui(),
50 * suins::constants::mist_per_sui()
];

let pricing_config = pricing::new<SUI>(vector[range1, range2, range3], prices);
add_config(&admin_cap, &mut suins, pricing_config);

transfer::transfer(admin_cap, tx_context::sender(ctx));
suins
}
Expand Down
2 changes: 1 addition & 1 deletion packages/suins/tests/register_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module suins::register_sample_tests {
let mut clock = test_scenario::take_shared<Clock>(scenario);

clock.increment_for_testing(clock_tick);
let nft = register(&mut suins, domain_name, no_years, payment, &clock, ctx(scenario));
let nft = register<SUI>(&mut suins, domain_name, no_years, payment, &clock, ctx(scenario));

test_scenario::return_shared(clock);
test_scenario::return_shared(suins);
Expand Down
2 changes: 1 addition & 1 deletion packages/suins/tests/v2/register.move
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module suins::register_sample {
assert!(0 < no_years && no_years <= 5, EInvalidYearsArgument);

let label = domain::sld(&domain);
let price = pricing::calculate_price(config, string::length(label));
let price = pricing::calculate_price(config, string::length(label)) * (no_years as u64);

assert!(coin::value(&payment) == price, EIncorrectAmount);

Expand Down

0 comments on commit dec6acc

Please sign in to comment.