Skip to content

Commit

Permalink
Merge pull request #264 from multiversx/new-endpoint-in-test-caller
Browse files Browse the repository at this point in the history
Added new endpoint in test caller
  • Loading branch information
iulianpascalau authored Dec 13, 2024
2 parents e3fed00 + 060b253 commit 7eb68ea
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
6 changes: 4 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: 1
// Endpoints: 3
// Async Callback (empty): 1
// Total number of exported functions: 4
// Total number of exported functions: 6

#![no_std]

Expand All @@ -21,6 +21,8 @@ multiversx_sc_wasm_adapter::endpoints! {
init => init
upgrade => upgrade
createTransaction => create_transaction
withdrawTransactionFees => withdraw_transaction_fees
withdrawRefundFeesForEthereum => withdraw_refund_fees_for_ethereum
)
}

Expand Down
3 changes: 3 additions & 0 deletions multisig/wasm/Cargo.lock

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

21 changes: 21 additions & 0 deletions test-caller/src/test-caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct CalledData<M: ManagedTypeApi> {
pub size: u64,
pub address: ManagedAddress<M>,
pub token_identifier: TokenIdentifier<M>,
pub buff: ManagedBuffer<M>,
}

#[multiversx_sc::contract]
Expand Down Expand Up @@ -41,6 +42,26 @@ pub trait TestCallerContract {
size,
address,
token_identifier,
buff: ManagedBuffer::new(),
};

_ = self.called_data_params().push(&data);
}

#[payable("*")]
#[view(callPayableWithBuff)]
fn call_payable_with_buff(
&self,
buff: ManagedBuffer,
) {
let payment = self.call_value().single_esdt();
let token_identifier = payment.token_identifier;

let data = CalledData{
size: 0,
address: ManagedAddress::zero(),
token_identifier,
buff,
};

_ = self.called_data_params().push(&data);
Expand Down
5 changes: 3 additions & 2 deletions test-caller/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: 4
// Endpoints: 5
// Async Callback (empty): 1
// Total number of exported functions: 7
// Total number of exported functions: 8

#![no_std]

Expand All @@ -23,6 +23,7 @@ multiversx_sc_wasm_adapter::endpoints! {
callPayable => call_payable
callNonPayable => call_non_payable
callPayableWithParams => call_payable_with_params
callPayableWithBuff => call_payable_with_buff
getCalledDataParams => get_called_data_params
)
}
Expand Down

0 comments on commit 7eb68ea

Please sign in to comment.