Skip to content

Commit

Permalink
Merge pull request #5 from multiversx/fix-multisig
Browse files Browse the repository at this point in the history
fix multisig
  • Loading branch information
dorin-iancu authored Oct 12, 2023
2 parents 27505dd + b3893a2 commit 07ade42
Show file tree
Hide file tree
Showing 16 changed files with 323 additions and 585 deletions.
3 changes: 3 additions & 0 deletions bridged-tokens-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub trait BridgedTokensWrapper: multiversx_sc_modules::pause::PauseModule {
self.set_paused(true);
}

#[endpoint]
fn upgrade(&self) {}

#[only_owner]
#[endpoint(addWrappedToken)]
fn add_wrapped_token(&self, universal_bridged_token_ids: TokenIdentifier, num_decimals: u32) {
Expand Down
96 changes: 17 additions & 79 deletions bridged-tokens-wrapper/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 25 additions & 20 deletions bridged-tokens-wrapper/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,41 @@
////////////////////////////////////////////////////

// Init: 1
// Endpoints: 16
// Endpoints: 17
// Async Callback (empty): 1
// Total number of exported functions: 18
// Total number of exported functions: 19

#![no_std]
#![feature(alloc_error_handler, lang_items)]

// Configuration that works with rustc < 1.73.0.
// TODO: Recommended rustc version: 1.73.0 or newer.
#![feature(lang_items)]

multiversx_sc_wasm_adapter::allocator!();
multiversx_sc_wasm_adapter::panic_handler!();

multiversx_sc_wasm_adapter::endpoints! {
bridged_tokens_wrapper
(
addWrappedToken
updateWrappedToken
removeWrappedToken
whitelistToken
updateWhitelistedToken
blacklistToken
depositLiquidity
wrapTokens
unwrapToken
getUniversalBridgedTokenIds
getTokenLiquidity
getChainSpecificToUniversalMapping
getchainSpecificTokenIds
pause
unpause
isPaused
init => init
upgrade => upgrade
addWrappedToken => add_wrapped_token
updateWrappedToken => update_wrapped_token
removeWrappedToken => remove_wrapped_token
whitelistToken => whitelist_token
updateWhitelistedToken => update_whitelisted_token
blacklistToken => blacklist_token
depositLiquidity => deposit_liquidity
wrapTokens => wrap_tokens
unwrapToken => unwrap_token
getUniversalBridgedTokenIds => universal_bridged_token_ids
getTokenLiquidity => token_liquidity
getChainSpecificToUniversalMapping => chain_specific_to_universal_mapping
getchainSpecificTokenIds => chain_specific_token_ids
pause => pause_endpoint
unpause => unpause_endpoint
isPaused => paused_status
)
}

multiversx_sc_wasm_adapter::empty_callback! {}
multiversx_sc_wasm_adapter::async_callback_empty! {}
11 changes: 11 additions & 0 deletions esdt-safe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use transaction::{transaction_status::TransactionStatus, Transaction, TransferDa
const DEFAULT_MAX_TX_BATCH_SIZE: usize = 10;
const DEFAULT_MAX_TX_BATCH_BLOCK_DURATION: u64 = 100; // ~10 minutes
const MAX_TRANSFERS_PER_TX: usize = 10;
const MAX_GAS_LIMIT: u64 = 300_000_000;

#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, ManagedVecItem)]
pub struct NonceAmountPair<M: ManagedTypeApi> {
Expand Down Expand Up @@ -42,6 +43,9 @@ pub trait EsdtSafe:
self.set_paused(true);
}

#[endpoint]
fn upgrade(&self) {}

/// Sets the statuses for the transactions, after they were executed on the Sovereign side.
///
/// Only TransactionStatus::Executed (3) and TransactionStatus::Rejected (4) values are allowed.
Expand Down Expand Up @@ -158,6 +162,13 @@ pub trait EsdtSafe:
require!(!payments.is_empty(), "Nothing to transfer");
require!(payments.len() <= MAX_TRANSFERS_PER_TX, "Too many tokens");

if let OptionalValue::Some(transfer_data) = &opt_transfer_data {
require!(
transfer_data.gas_limit <= MAX_GAS_LIMIT,
"Gas limit too high"
);
}

let own_sc_address = self.blockchain().get_sc_address();
let mut all_token_data = ManagedVec::new();
for payment in &payments {
Expand Down
66 changes: 31 additions & 35 deletions esdt-safe/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,47 @@
////////////////////////////////////////////////////

// Init: 1
// Endpoints: 31
// Endpoints: 23
// Async Callback (empty): 1
// Total number of exported functions: 33
// Total number of exported functions: 25

#![no_std]
#![feature(alloc_error_handler, lang_items)]

// Configuration that works with rustc < 1.73.0.
// TODO: Recommended rustc version: 1.73.0 or newer.
#![feature(lang_items)]

multiversx_sc_wasm_adapter::allocator!();
multiversx_sc_wasm_adapter::panic_handler!();

multiversx_sc_wasm_adapter::endpoints! {
esdt_safe
(
setTransactionBatchStatus
addRefundBatch
createTransaction
claimRefund
getRefundAmounts
setFeeEstimatorContractAddress
setEthTxGasLimit
setDefaultPricePerGasUnit
setTokenTicker
calculateRequiredFee
getFeeEstimatorContractAddress
getDefaultPricePerGasUnit
getEthTxGasLimit
distributeFees
addTokenToWhitelist
removeTokenFromWhitelist
getAllKnownTokens
getAccumulatedTransactionFees
setMaxTxBatchSize
setMaxTxBatchBlockDuration
getCurrentTxBatch
getFirstBatchAnyStatus
getBatch
getBatchStatus
getFirstBatchId
getLastBatchId
setMaxBridgedAmount
getMaxBridgedAmount
pause
unpause
isPaused
init => init
upgrade => upgrade
setTransactionBatchStatus => set_transaction_batch_status
addRefundBatch => add_refund_batch
createTransaction => create_transaction
claimRefund => claim_refund
getRefundAmounts => get_refund_amounts
getSovereignTxGasLimit => sovereign_tx_gas_limit
addTokenToWhitelist => add_token_to_whitelist
removeTokenFromWhitelist => remove_token_from_whitelist
getAllKnownTokens => token_whitelist
setMaxTxBatchSize => set_max_tx_batch_size
setMaxTxBatchBlockDuration => set_max_tx_batch_block_duration
getCurrentTxBatch => get_current_tx_batch
getFirstBatchAnyStatus => get_first_batch_any_status
getBatch => get_batch
getBatchStatus => get_batch_status
getFirstBatchId => first_batch_id
getLastBatchId => last_batch_id
setMaxBridgedAmount => set_max_bridged_amount
getMaxBridgedAmount => max_bridged_amount
pause => pause_endpoint
unpause => unpause_endpoint
isPaused => paused_status
)
}

multiversx_sc_wasm_adapter::empty_callback! {}
multiversx_sc_wasm_adapter::async_callback_empty! {}
3 changes: 3 additions & 0 deletions multi-transfer-esdt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub trait MultiTransferEsdt:
self.last_batch_id().set_if_empty(1);
}

#[endpoint]
fn upgrade(&self) {}

#[only_owner]
#[endpoint(batchTransferEsdtToken)]
fn batch_transfer_esdt_token(
Expand Down
Loading

0 comments on commit 07ade42

Please sign in to comment.