Skip to content

Commit

Permalink
Merge pull request #222 from multiversx/create-mock-contracts
Browse files Browse the repository at this point in the history
Create mock contracts
  • Loading branch information
dragos-rebegea authored Oct 21, 2024
2 parents 6a0d1cc + 5c1acb8 commit eb7fa9d
Show file tree
Hide file tree
Showing 64 changed files with 9,098 additions and 83 deletions.
42 changes: 37 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
# Generated by Cargo
# will have compiled files and executables
/target/
**/target/**

# Remove Cargo.lock from the framework, but not from the wasm contracts.
# In contracts it helps with tracing builds.
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# The root Cargo.lock is kept for dependabot.
contracts/**/Cargo.lock
!contracts/**/wasm*/Cargo.lock
contracts/**/output*/
data/**/Cargo.lock
framework/**/Cargo.lock
sdk/**/Cargo.lock
tools/**/Cargo.lock
vm/**/Cargo.lock



# Coverage outputs
*.profraw
*.profdata
*.coverage
coverage.md

# These are backup files generated by rustfmt
**/*.rs.bk

# Local testnet files
**/deploy-testnet.interaction.json
# Editors config
.vscode
.zed
.idea

tags

# MultiversX IDE
**/node_modules
**/output/**
**/testnet/**
**/mxpy.data-storage.json
**/testnet/
**/deploy-child-sc-spam.json
**/*.interaction.json

# Python scripts
**/__pycache__/**
104 changes: 104 additions & 0 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ members = [
"bridged-tokens-wrapper",
"bridged-tokens-wrapper/meta",
"test-caller",
"test-caller/meta"
"test-caller/meta",
"common/mock-contracts/mock-price-aggregator/meta",
"common/mock-contracts/mock-multi-transfer-esdt/meta",
"common/mock-contracts/mock-bridge-proxy/meta",
"common/mock-contracts/mock-bridged-tokens-wrapper/meta",
"common/mock-contracts/mock-multisig/meta",
"common/mock-contracts/mock-esdt-safe/meta",
]
3 changes: 3 additions & 0 deletions bridge-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ path = "../esdt-safe"
[dependencies.bridged-tokens-wrapper]
path = "../bridged-tokens-wrapper"

[dependencies.mock-bridged-tokens-wrapper]
path = "../common/mock-contracts/mock-bridged-tokens-wrapper"

[dependencies.multiversx-sc]
version = "=0.53.2"

Expand Down
25 changes: 16 additions & 9 deletions bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MIN_GAS_TO_SAVE_PROGRESS: u64 = 100_000;

#[multiversx_sc::contract]
pub trait BridgeProxyContract:
config::ConfigModule
config::ConfigModule
+ multiversx_sc_modules::pause::PauseModule
+ multiversx_sc_modules::ongoing_operation::OngoingOperationModule
{
Expand Down Expand Up @@ -80,7 +80,10 @@ pub trait BridgeProxyContract:
}

let gas_left = self.blockchain().get_gas_left();
require!(gas_left > call_data.gas_limit + DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK, "Not enough gas to execute");
require!(
gas_left > call_data.gas_limit + DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK,
"Not enough gas to execute"
);

let tx_call = self
.tx()
Expand Down Expand Up @@ -135,11 +138,14 @@ pub trait BridgeProxyContract:
self.tx()
.to(esdt_safe_contract_address)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_transaction(tx.from, OptionalValue::Some(esdt_safe_proxy::RefundInfo {
address: tx.to,
initial_batch_id: batch_id,
initial_nonce: tx.tx_nonce,
}))
.create_transaction(
tx.from,
OptionalValue::Some(esdt_safe_proxy::RefundInfo {
address: tx.to,
initial_batch_id: batch_id,
initial_nonce: tx.tx_nonce,
}),
)
.single_esdt(
&unwrapped_token.token_identifier,
unwrapped_token.token_nonce,
Expand All @@ -151,10 +157,11 @@ pub trait BridgeProxyContract:
fn unwrap_token(&self, requested_token: &TokenIdentifier, tx_id: usize) -> EsdtTokenPayment {
let payment = self.payments(tx_id).get();
let bridged_tokens_wrapper_address = self.bridged_tokens_wrapper_address().get();

let transfers = self
.tx()
.to(bridged_tokens_wrapper_address) .typed(bridged_tokens_wrapper_proxy::BridgedTokensWrapperProxy)
.to(bridged_tokens_wrapper_address)
.typed(bridged_tokens_wrapper_proxy::BridgedTokensWrapperProxy)
.unwrap_token(requested_token)
.single_esdt(
&payment.token_identifier,
Expand Down
Loading

0 comments on commit eb7fa9d

Please sign in to comment.