Skip to content

Commit

Permalink
Merge pull request #259 from multiversx/remove-sc-call-create-transac…
Browse files Browse the repository at this point in the history
…tion

esdt-safe: Remove create_transaction with sc_call
  • Loading branch information
CostinCarabas authored Dec 3, 2024
2 parents c198c69 + ed91e16 commit ea7ea9b
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 118 deletions.
12 changes: 12 additions & 0 deletions bridge-proxy/wasm/Cargo.lock

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

4 changes: 2 additions & 2 deletions bridge-proxy/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

// Init: 1
// Upgrade: 1
// Endpoints: 9
// Endpoints: 8
// Async Callback (empty): 1
// Promise callbacks: 1
// Total number of exported functions: 13
// Total number of exported functions: 12

#![no_std]

Expand Down
10 changes: 10 additions & 0 deletions bridged-tokens-wrapper/wasm/Cargo.lock

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

18 changes: 18 additions & 0 deletions common/mock-contracts/mock-esdt-safe/wasm/Cargo.lock

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

2 changes: 1 addition & 1 deletion common/mock-contracts/mock-esdt-safe/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ panic = "abort"
path = ".."

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

[workspace]
members = ["."]
5 changes: 3 additions & 2 deletions common/mock-contracts/mock-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: 0
// Endpoints: 1
// Async Callback (empty): 1
// Total number of exported functions: 3
// Total number of exported functions: 4

#![no_std]

Expand All @@ -20,6 +20,7 @@ multiversx_sc_wasm_adapter::endpoints! {
(
init => init
upgrade => upgrade
createTransaction => create_transaction
)
}

Expand Down
18 changes: 0 additions & 18 deletions common/sc-proxies/src/esdt_safe_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,6 @@ where
.original_result()
}

pub fn create_transaction_sc_call<
Arg0: ProxyArg<eth_address::EthAddress<Env::Api>>,
Arg1: ProxyArg<ManagedBuffer<Env::Api>>,
Arg2: ProxyArg<OptionalValue<RefundInfo<Env::Api>>>,
>(
self,
to: Arg0,
data: Arg1,
opt_refund_info: Arg2,
) -> TxTypedCall<Env, From, To, (), Gas, ()> {
self.wrapped_tx
.raw_call("createTransactionSCCall")
.argument(&to)
.argument(&data)
.argument(&opt_refund_info)
.original_result()
}

/// Claim funds for failed MultiversX -> Ethereum transactions.
/// These are not sent automatically to prevent the contract getting stuck.
/// For example, if the receiver is a SC, a frozen account, etc.
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()
}
}
39 changes: 0 additions & 39 deletions esdt-safe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,45 +382,6 @@ pub trait EsdtSafe:
}
}

#[payable("*")]
#[endpoint(createTransactionSCCall)]
fn create_transaction_sc_call(
&self,
to: EthAddress<Self::Api>,
data: ManagedBuffer<Self::Api>,
opt_refund_info: OptionalValue<RefundInfo<Self::Api>>,
) {
let transaction_details = self.create_transaction_common(to, opt_refund_info);

if !transaction_details.is_refund_tx {
self.create_transaction_sc_call_event(
transaction_details.batch_id,
transaction_details.tx_nonce,
transaction_details.payment_token,
transaction_details.actual_bridged_amount,
transaction_details.required_fee,
transaction_details
.refund_info
.address
.as_managed_buffer()
.clone(),
transaction_details.to_address,
data,
);
} else {
self.create_refund_transaction_sc_call_event(
transaction_details.batch_id,
transaction_details.tx_nonce,
transaction_details.payment_token,
transaction_details.actual_bridged_amount,
transaction_details.required_fee,
transaction_details.refund_info.initial_batch_id,
transaction_details.refund_info.initial_nonce,
data,
);
}
}

/// Claim funds for failed MultiversX -> Ethereum transactions.
/// These are not sent automatically to prevent the contract getting stuck.
/// For example, if the receiver is a SC, a frozen account, etc.
Expand Down
Loading

0 comments on commit ea7ea9b

Please sign in to comment.