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

Feat/tx with sc call #153

Merged
merged 61 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
96a8b26
Add data and gasLimit
CostinCarabas Jul 10, 2023
9516111
Add bridge proxy to execute SC calls from Eth
CostinCarabas Jul 11, 2023
e373415
MultiTransfer: deposit funds and tx from Eth
CostinCarabas Jul 11, 2023
b345340
Framework update
CostinCarabas Jul 11, 2023
e924486
Bridge-proxy & Multi-Transfer
CostinCarabas Jul 12, 2023
76a97e6
Tests fix
CostinCarabas Aug 9, 2023
e70cd37
Test fix
CostinCarabas Aug 9, 2023
492ee3a
Fix tests
CostinCarabas Aug 9, 2023
f29acbf
Fix tests
CostinCarabas Aug 10, 2023
32224fc
Test fix
CostinCarabas Aug 10, 2023
3a42445
Tests fix
CostinCarabas Aug 11, 2023
07fb466
Framework upgrade 0.42
CostinCarabas Aug 11, 2023
864bcf0
bridge-proxy: Add tests
CostinCarabas Aug 13, 2023
b22ab53
Rename mandos -> scenarios
CostinCarabas Aug 13, 2023
b8e9086
Refactor bridge-proxy deposit test
CostinCarabas Aug 14, 2023
4c8596a
Add MultiTransferEsdt rust test
CostinCarabas Aug 14, 2023
deccdcd
Merge pull request #146 from multiversx/enable-tx-to-SC
CostinCarabas Aug 16, 2023
fbddf00
Merge pull request #149 from multiversx/add-tests-for-tx-with-SC
CostinCarabas Aug 16, 2023
2bc968b
fix MultiTransferEsdt init arguments
dragos-rebegea Oct 16, 2023
55142c7
remove MultiTransferEsdt init arguments
dragos-rebegea Oct 16, 2023
7231845
Merge pull request #152 from multiversx/fix-init-arguments
dragos-rebegea Oct 16, 2023
196565e
Merge pull request #150 from multiversx/bridge-proxy-tests
CostinCarabas Oct 17, 2023
743facd
add mintBurn or locking functionality
dragos-rebegea Oct 25, 2023
fc41c0d
fix proxytrait and always wrap tokens
dragos-rebegea Oct 26, 2023
1414d36
Merge branch 'feat/tx-with-SC-call' into mintBurn-or-locking
CostinCarabas Oct 27, 2023
dc4f12d
Fix compiling issues
CostinCarabas Oct 27, 2023
f85a3db
Fix clippy
CostinCarabas Oct 27, 2023
c6079b6
Fix dependencies
CostinCarabas Oct 27, 2023
ea878b3
Add blackbox test for Multi Transfer SC
CostinCarabas Oct 30, 2023
f90ac87
Add check storage for test
CostinCarabas Oct 30, 2023
23260b3
Fix compilation issues
CostinCarabas Nov 9, 2023
13c9034
add accumulated burned tokens
dragos-rebegea Nov 27, 2023
3228628
Framework upgrade 0.45.1
CostinCarabas Dec 5, 2023
da8fcec
Fixed after reviews
CostinCarabas Dec 20, 2023
b10b80c
add snippets for tx-with-SC-call
dragos-rebegea Dec 27, 2023
41522c5
Merge remote-tracking branch 'origin/main' into feat/tx-with-SC-call
dragos-rebegea Dec 27, 2023
3557b6e
Merge remote-tracking branch 'origin/feat/tx-with-SC-call' into mintB…
dragos-rebegea Dec 27, 2023
6c43b9d
Fixes after review
CostinCarabas Dec 27, 2023
dbf6668
Framework upgrade bridge-proxy to 0.45.2
CostinCarabas Dec 27, 2023
b249789
Merge branch 'feat/tx-with-SC-call' into mintBurn-or-locking
CostinCarabas Dec 27, 2023
3743ad0
Merge remote-tracking branch 'origin/mintBurn-or-locking' into mintBu…
CostinCarabas Dec 27, 2023
a93762f
Comiling fixes
CostinCarabas Dec 27, 2023
a9b512c
Actions: checks trigger also on feat branches
CostinCarabas Dec 27, 2023
531c35b
Merge pull request #158 from multiversx/actions-trigger-on-feat-branches
dragos-rebegea Dec 27, 2023
d1767c5
Multi transfer: Batch Transfer blackbox test
CostinCarabas Dec 29, 2023
1185594
Fix go tests - replace mandos -> scenarios
CostinCarabas Dec 29, 2023
37772a6
Fix mandos tests
CostinCarabas Dec 29, 2023
a40c1c0
Update price-aggregator to 0.45.2
CostinCarabas Jan 3, 2024
b9958ac
price-aggregator scenarios:Submit correctly prices
CostinCarabas Jan 4, 2024
455aaeb
Fix tests
CostinCarabas Jan 5, 2024
40d7189
Update Rust toolchain
CostinCarabas Jan 5, 2024
b7717ae
Rebranding elrond -> MultiversX
CostinCarabas Jan 5, 2024
d6d2ff2
Framework upgrade 0.46
CostinCarabas Jan 5, 2024
fb20be9
esdt-safe: tests: ix roles
CostinCarabas Jan 5, 2024
ba6292b
Bridge-proxy: Add option for args + tests
CostinCarabas Jan 9, 2024
8c54750
Bridge-proxy: transform args to ManagedVec
CostinCarabas Jan 10, 2024
a6c8ae1
Update common/token-module/src/lib.rs
CostinCarabas Jan 12, 2024
58546e3
Multi-transfer: Add new test
CostinCarabas Jan 12, 2024
40dc6ea
Framework upgrade 0.46.1
CostinCarabas Jan 19, 2024
12ea6db
Test fix
CostinCarabas Jan 19, 2024
bae95ea
Merge pull request #154 from multiversx/mintBurn-or-locking
sasurobert Jan 22, 2024
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
11 changes: 7 additions & 4 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on:
push:
branches:
- main
- feat/*
pull_request:
branches: [ main ]
branches:
- main
- feat/*

permissions:
checks: write
Expand All @@ -14,9 +17,9 @@ permissions:
jobs:
contracts:
name: Contracts
uses: multiversx/mx-sc-actions/.github/workflows/[email protected].0
uses: multiversx/mx-sc-actions/.github/workflows/[email protected].5
with:
rust-toolchain: nightly-2023-04-24
vmtools-version: v1.4.60
rust-toolchain: nightly-2023-12-11
vmtools-version: v1.5.19
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[workspace]
members = [
"bridge-proxy",
"bridge-proxy/meta",
"esdt-safe",
"esdt-safe/meta",
"multi-transfer-esdt",
Expand Down
7 changes: 7 additions & 0 deletions bridge-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
*/target/

# The mxpy output
/output*/
28 changes: 28 additions & 0 deletions bridge-proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "bridge-proxy"
version = "0.0.0"
authors = ["Costin Carabaș <[email protected]>"]
edition = "2018"
publish = false

[lib]
path = "src/bridge-proxy.rs"

[dependencies.transaction]
path = "../common/transaction"

[dependencies.eth-address]
path = "../common/eth-address"

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

[dependencies.adder]
git = "https://github.com/multiversx/mx-contracts-rs"
rev = "64e8926"

[dev-dependencies]
num-bigint = "0.4.2"

[dev-dependencies.multiversx-sc-scenario]
version = "0.46.1"
14 changes: 14 additions & 0 deletions bridge-proxy/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "bridge-proxy-meta"
version = "0.0.0"
edition = "2018"
publish = false
authors = ["you"]

[dev-dependencies]

[dependencies.bridge-proxy]
path = ".."

[dependencies.multiversx-sc-meta]
version = "0.46.1"
3 changes: 3 additions & 0 deletions bridge-proxy/meta/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
multiversx_sc_meta::cli_main::<bridge_proxy::AbiProvider>();
}
3 changes: 3 additions & 0 deletions bridge-proxy/multiversx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "rust"
}
78 changes: 78 additions & 0 deletions bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#![no_std]

multiversx_sc::imports!();
multiversx_sc::derive_imports!();

pub mod config;

use transaction::{EthTransaction, EthTransactionPayment};

#[multiversx_sc::contract]
pub trait BridgeProxyContract: config::ConfigModule {
#[init]
fn init(&self, opt_multi_transfer_address: OptionalValue<ManagedAddress>) {
self.set_multi_transfer_contract_address(opt_multi_transfer_address);
}

#[payable("*")]
#[endpoint]
fn deposit(&self, eth_tx: EthTransaction<Self::Api>) {
let (token_id, nonce, amount) = self.call_value().single_esdt().into_tuple();
self.eth_transaction_list()
.push_back(EthTransactionPayment {
token_id,
nonce,
amount,
eth_tx,
});
}

#[endpoint(executeWithAsnyc)]
fn execute_with_async(&self, tx_id: u32) {
let tx_node = self
.eth_transaction_list()
.remove_node_by_id(tx_id)
.unwrap_or_else(|| sc_panic!("Invalid ETH transaction!"));
let tx = tx_node.get_value_as_ref();

self.send()
.contract_call::<IgnoreValue>(tx.eth_tx.to.clone(), tx.eth_tx.data.clone())
.with_raw_arguments(tx.eth_tx.args.clone().into())
.with_esdt_transfer((tx.token_id.clone(), tx.nonce, tx.amount.clone()))
.with_gas_limit(tx.eth_tx.gas_limit)
.async_call()
.with_callback(self.callbacks().failed_execution_callback(tx))
.call_and_exit();
}

#[callback]
fn failed_execution_callback(&self, tx: &EthTransactionPayment<Self::Api>) {
self.eth_failed_transaction_list().push_back(tx.clone());
}

#[endpoint(refundTransactions)]
fn refund_transactions(&self) -> MultiValueEncoded<EthTransactionPayment<Self::Api>> {
// Send Failed Tx Structure
let mut result = MultiValueEncoded::new();
for tx_loop in self.eth_failed_transaction_list().iter() {
let tx = tx_loop.get_value_cloned();
result.push(tx);
}

// Send Funds
let mut all_payments = ManagedVec::new();
for failed_tx_loop in self.eth_failed_transaction_list().into_iter() {
let failed_tx = failed_tx_loop.get_value_as_ref();

all_payments.push(EsdtTokenPayment::new(
failed_tx.token_id.clone(),
failed_tx.nonce,
failed_tx.amount.clone(),
));
}
self.send()
.direct_multi(&self.multi_transfer_address().get(), &all_payments);

result
}
}
46 changes: 46 additions & 0 deletions bridge-proxy/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();

use transaction::{EthTransaction, EthTransactionPayment};

#[multiversx_sc::module]
pub trait ConfigModule {
#[only_owner]
#[endpoint(setupMultiTransfer)]
fn set_multi_transfer_contract_address(
&self,
opt_multi_transfer_address: OptionalValue<ManagedAddress>,
) {
match opt_multi_transfer_address {
OptionalValue::Some(sc_addr) => {
require!(
self.blockchain().is_smart_contract(&sc_addr),
"Invalid multi-transfer address"
);
self.multi_transfer_address().set(&sc_addr);
}
OptionalValue::None => self.multi_transfer_address().clear(),
}
}

#[view(getEthTransactionById)]
fn get_eth_transaction_by_id(&self, id: u32) -> EthTransaction<Self::Api> {
let eth_tx_list = self.eth_transaction_list();
match eth_tx_list.get_node_by_id(id) {
Some(tx) => tx.get_value_cloned().eth_tx,
None => sc_panic!("No transaction with this id!"),
}
}

#[view(getMultiTransferAddress)]
#[storage_mapper("multiTransferAddress")]
fn multi_transfer_address(&self) -> SingleValueMapper<ManagedAddress>;

#[view(getEthTransactionList)]
#[storage_mapper("eth_transaction_list")]
fn eth_transaction_list(&self) -> LinkedListMapper<EthTransactionPayment<Self::Api>>;

#[view(getEthFailedTransactionList)]
#[storage_mapper("eth_failed_transaction_list")]
fn eth_failed_transaction_list(&self) -> LinkedListMapper<EthTransactionPayment<Self::Api>>;
}
Loading