Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate rewards distribution #1581

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions contracts/examples/rewards-distribution/sc-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[proxy]]
path = "src/rewards_distribution_proxy.rs"
[[proxy.path-rename]]
from = "multiversx_sc::types::io::operation_completion_status::"
to = ""
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ use multiversx_sc_modules::ongoing_operation::{
CONTINUE_OP, DEFAULT_MIN_GAS_TO_SAVE_PROGRESS, STOP_OP,
};

pub mod proxy;
pub mod rewards_distribution_proxy;
pub mod seed_nft_minter_proxy;
type Epoch = u64;

pub const EPOCHS_IN_WEEK: Epoch = 7;
pub const MAX_PERCENTAGE: u64 = 100_000; // 100%
pub const DIVISION_SAFETY_CONSTANT: u64 = 1_000_000_000_000;

#[derive(ManagedVecItem, NestedEncode, NestedDecode, TypeAbi)]
#[type_abi]
#[derive(ManagedVecItem, NestedEncode, NestedDecode)]
pub struct Bracket {
pub index_percent: u64,
pub bracket_reward_percent: u64,
}

#[derive(ManagedVecItem, NestedEncode, NestedDecode, TypeAbi)]
#[type_abi]
#[derive(ManagedVecItem, NestedEncode, NestedDecode)]
pub struct ComputedBracket<M: ManagedTypeApi> {
pub end_index: u64,
pub nft_reward_percent: BigUint<M>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
use multiversx_sc::proxy_imports::*;

pub struct MockSeedNftMinterProxy;

impl<Env, From, To, Gas> TxProxyTrait<Env, From, To, Gas> for MockSeedNftMinterProxy
where
Env: TxEnv,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
type TxProxyMethods = MockSeedNftMinterProxyMethods<Env, From, To, Gas>;

fn proxy_methods(self, tx: Tx<Env, From, To, (), Gas, (), ()>) -> Self::TxProxyMethods {
MockSeedNftMinterProxyMethods { wrapped_tx: tx }
}
}

pub struct MockSeedNftMinterProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
wrapped_tx: Tx<Env, From, To, (), Gas, (), ()>,
}

#[rustfmt::skip]
impl<Env, From, Gas> MockSeedNftMinterProxyMethods<Env, From, (), Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
pub fn init<
Arg0: CodecInto<TokenIdentifier<Env::Api>>,
>(
self,
nft_token_id: Arg0,
) -> TxProxyDeploy<Env, From, Gas, ()> {
self.wrapped_tx
.raw_deploy()
.argument(&nft_token_id)
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> MockSeedNftMinterProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn set_nft_count<
Arg0: CodecInto<u64>,
>(
self,
nft_count: Arg0,
) -> TxProxyCall<Env, From, To, Gas, ()> {
self.wrapped_tx
.raw_call("setNftCount")
.argument(&nft_count)
.original_result()
}
}
Loading
Loading