-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add integration test helper contract #273
Changes from 2 commits
a1aae0f
91f9a99
4e95867
8f248a6
2766212
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add .DS_Store to .gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target/ | ||
*/target/ | ||
|
||
/output*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "helper-contract" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
authors = ["you"] | ||
|
||
[lib] | ||
path = "src/helper_contract.rs" | ||
|
||
[dependencies.multiversx-sc] | ||
version = "0.55.0" | ||
|
||
[dependencies.transaction] | ||
path = "../common/transaction" | ||
|
||
[dependencies.sc-proxies] | ||
path = "../common/sc-proxies" | ||
|
||
[dev-dependencies] | ||
num-bigint = "0.4" | ||
|
||
[dev-dependencies.multiversx-sc-scenario] | ||
version = "0.55.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "helper-contract-meta" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies.helper-contract] | ||
path = ".." | ||
|
||
[dependencies.multiversx-sc-meta-lib] | ||
version = "0.55.0" | ||
default-features = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
multiversx_sc_meta_lib::cli_main::<helper_contract::AbiProvider>(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"language": "rust" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![no_std] | ||
|
||
#[allow(unused_imports)] | ||
use multiversx_sc::imports::*; | ||
|
||
use transaction::{EthTransaction, EthTxAsMultiValue}; | ||
use sc_proxies::bridge_proxy_contract_proxy; | ||
|
||
#[multiversx_sc::contract] | ||
pub trait HelperContract { | ||
#[init] | ||
fn init(&self) {} | ||
|
||
#[upgrade] | ||
fn upgrade(&self) {} | ||
|
||
#[view(getCalleeAddress)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Storage mapper usually go last. |
||
#[storage_mapper("callee_address")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name of storage mappers should be camelCase. In this case |
||
fn callee_address(&self) -> SingleValueMapper<ManagedAddress>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should actually be bridge proxy contract. Rename it accordingly |
||
|
||
#[endpoint(setCallee)] | ||
fn set_callee(&self, address: ManagedAddress) { | ||
self.callee_address().set(&address); | ||
} | ||
|
||
#[endpoint(callDeposit)] | ||
#[payable("*")] | ||
fn call_deposit(&self, batch_id: u64, eth_tx_multivalue: EthTxAsMultiValue<Self::Api>) { | ||
let callee = self.callee_address().get(); | ||
|
||
let (payment_token, payment_amount) = self.call_value().single_fungible_esdt(); | ||
|
||
let (from, to, token_id, amount, tx_nonce, call_data) = eth_tx_multivalue.into_tuple(); | ||
|
||
let eth_tx = EthTransaction { | ||
from, | ||
to, | ||
token_id, | ||
amount, | ||
tx_nonce, | ||
call_data, | ||
}; | ||
|
||
self.tx() | ||
.to(callee) | ||
.typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) | ||
.deposit(eth_tx, batch_id) | ||
.single_esdt(&payment_token, 0, &payment_amount) | ||
.sync_call(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be committed.