Skip to content

Commit

Permalink
clippy, compilation, proxy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Nov 25, 2024
1 parent 82684b2 commit c7f9490
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 843 deletions.
19 changes: 19 additions & 0 deletions common/sc-proxies/src/esdt_safe_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,17 @@ where
/// Useful for knowing which token IDs to pass to the claimRefund endpoint.
pub fn get_refund_amounts<
Arg0: ProxyArg<ManagedAddress<Env::Api>>,
Arg1: ProxyArg<OptionalValue<MultiValueEncoded<Env::Api, TokenIdentifier<Env::Api>>>>,
>(
self,
address: Arg0,
opt_tokens: Arg1,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, MultiValueEncoded<Env::Api, MultiValue2<TokenIdentifier<Env::Api>, BigUint<Env::Api>>>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getRefundAmounts")
.argument(&address)
.argument(&opt_tokens)
.original_result()
}

Expand Down Expand Up @@ -374,14 +377,17 @@ where
/// where percentages must add up to the PERCENTAGE_TOTAL constant
pub fn distribute_fees<
Arg0: ProxyArg<ManagedVec<Env::Api, token_module::AddressPercentagePair<Env::Api>>>,
Arg1: ProxyArg<OptionalValue<MultiValueEncoded<Env::Api, TokenIdentifier<Env::Api>>>>,
>(
self,
address_percentage_pairs: Arg0,
opt_tokens_to_distribute: Arg1,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("distributeFees")
.argument(&address_percentage_pairs)
.argument(&opt_tokens_to_distribute)
.original_result()
}

Expand Down Expand Up @@ -568,6 +574,19 @@ where
.original_result()
}

pub fn supply_mint_burn_initialized<
Arg0: ProxyArg<TokenIdentifier<Env::Api>>,
>(
self,
token_id: Arg0,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, bool> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getsupplyMintBurnInitialized")
.argument(&token_id)
.original_result()
}

pub fn set_max_tx_batch_size<
Arg0: ProxyArg<usize>,
>(
Expand Down
156 changes: 156 additions & 0 deletions common/sc-proxies/src/mock_multisig_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Code generated by the multiversx-sc proxy generator. DO NOT EDIT.

////////////////////////////////////////////////////
////////////////// AUTO-GENERATED //////////////////
////////////////////////////////////////////////////

#![allow(dead_code)]
#![allow(clippy::all)]

use multiversx_sc::proxy_imports::*;

pub struct MockMultisigProxy;

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

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

pub struct MockMultisigProxyMethods<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> MockMultisigProxyMethods<Env, From, (), Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
pub fn init<
Arg0: ProxyArg<ManagedAddress<Env::Api>>,
Arg1: ProxyArg<ManagedAddress<Env::Api>>,
Arg2: ProxyArg<ManagedAddress<Env::Api>>,
Arg3: ProxyArg<ManagedAddress<Env::Api>>,
Arg4: ProxyArg<ManagedAddress<Env::Api>>,
Arg5: ProxyArg<BigUint<Env::Api>>,
Arg6: ProxyArg<BigUint<Env::Api>>,
Arg7: ProxyArg<usize>,
Arg8: ProxyArg<MultiValueEncoded<Env::Api, ManagedAddress<Env::Api>>>,
>(
self,
esdt_safe_sc_address: Arg0,
multi_transfer_sc_address: Arg1,
proxy_sc_address: Arg2,
bridged_tokens_wrapper_sc_address: Arg3,
price_aggregator_sc_address: Arg4,
_required_stake: Arg5,
_slash_amount: Arg6,
_quorum: Arg7,
_board: Arg8,
) -> TxTypedDeploy<Env, From, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_deploy()
.argument(&esdt_safe_sc_address)
.argument(&multi_transfer_sc_address)
.argument(&proxy_sc_address)
.argument(&bridged_tokens_wrapper_sc_address)
.argument(&price_aggregator_sc_address)
.argument(&_required_stake)
.argument(&_slash_amount)
.argument(&_quorum)
.argument(&_board)
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> MockMultisigProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn upgrade(
self,
) -> TxTypedUpgrade<Env, From, To, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_upgrade()
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> MockMultisigProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn esdt_safe_address(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ManagedAddress<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getEsdtSafeAddress")
.original_result()
}

pub fn multi_transfer_esdt_address(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ManagedAddress<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getMultiTransferEsdtAddress")
.original_result()
}

pub fn proxy_address(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ManagedAddress<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getProxyAddress")
.original_result()
}

pub fn bridged_tokens_wrapper_address(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ManagedAddress<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getBridgedTokensWrapperAddress")
.original_result()
}

pub fn fee_estimator_address(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ManagedAddress<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getFeeEstimatorAddress")
.original_result()
}
}
9 changes: 2 additions & 7 deletions common/sc-proxies/src/multisig_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,18 @@ where
pub fn upgrade_child_contract_from_source<
Arg0: ProxyArg<ManagedAddress<Env::Api>>,
Arg1: ProxyArg<ManagedAddress<Env::Api>>,
Arg2: ProxyArg<bool>,
Arg3: ProxyArg<MultiValueEncoded<Env::Api, ManagedBuffer<Env::Api>>>,
Arg2: ProxyArg<MultiValueEncoded<Env::Api, ManagedBuffer<Env::Api>>>,
>(
self,
child_sc_address: Arg0,
source_address: Arg1,
is_payable: Arg2,
init_args: Arg3,
init_args: Arg2,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("upgradeChildContractFromSource")
.argument(&child_sc_address)
.argument(&source_address)
.argument(&is_payable)
.argument(&init_args)
.original_result()
}
Expand Down Expand Up @@ -887,8 +884,6 @@ where
.original_result()
}

/// Actions are cleared after execution, so an empty entry means the action was executed already
/// Returns "false" if the action ID is invalid
pub fn was_action_executed<
Arg0: ProxyArg<usize>,
>(
Expand Down
2 changes: 1 addition & 1 deletion common/token-module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub trait TokenModule:
) {
self.require_token_in_whitelist(token_id);
require!(
self.supply_mint_burn_initialized(token_id).get() == false,
!self.supply_mint_burn_initialized(token_id).get(),
"Token already initialized"
);
require!(
Expand Down
6 changes: 4 additions & 2 deletions esdt-safe/tests/esdt_safe_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,14 @@ fn claim_refund_test() {
state.single_transaction_should_work(MINT_BURN_TOKEN, 1000u64);
state.set_transaction_batch_status_should_work(1, tx_statuses.clone());

let opt_tokens: OptionalValue<MultiValueEncoded<StaticApi, TokenIdentifier<StaticApi>>> =
OptionalValue::None;
let refund = state
.world
.query()
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.get_refund_amounts(MULTISIG_ADDRESS)
.get_refund_amounts(MULTISIG_ADDRESS, opt_tokens.clone())
.returns(ReturnsResult)
.run();

Expand All @@ -1150,7 +1152,7 @@ fn claim_refund_test() {
.query()
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.get_refund_amounts(OWNER_ADDRESS)
.get_refund_amounts(OWNER_ADDRESS, opt_tokens)
.returns(ReturnsResult)
.run();
assert!(refund_after.is_empty());
Expand Down
5 changes: 3 additions & 2 deletions esdt-safe/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 44
// Endpoints: 45
// Async Callback (empty): 1
// Total number of exported functions: 47
// Total number of exported functions: 48

#![no_std]

Expand Down Expand Up @@ -51,6 +51,7 @@ multiversx_sc_wasm_adapter::endpoints! {
getTotalBalances => total_balances
getMintBalances => mint_balances
getBurnBalances => burn_balances
getsupplyMintBurnInitialized => supply_mint_burn_initialized
setMaxTxBatchSize => set_max_tx_batch_size
setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration
getCurrentTxBatch => get_current_tx_batch
Expand Down
2 changes: 1 addition & 1 deletion multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl MultiTransferTestState {
.account(USER2_ADDRESS)
.nonce(1);

let roles = vec![
let roles = [
"ESDTRoleLocalMint".to_string(),
"ESDTRoleLocalBurn".to_string(),
];
Expand Down
Loading

0 comments on commit c7f9490

Please sign in to comment.