Skip to content

Commit

Permalink
Merge pull request #1890 from multiversx/payable-blackbox
Browse files Browse the repository at this point in the history
unified - payable blackbox
  • Loading branch information
BiancaIalangi authored Dec 3, 2024
2 parents 320a314 + 1401103 commit d64d688
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"name": "payable",
"gasSchedule": "v3",
"steps": [
{
"step": "setState",
"accounts": {
"sc:payable-features": {
"nonce": "0",
"balance": "0",
"code": "mxsc:../output/payable-features.mxsc.json",
"codeMetadata": "0x0000"
},
"address:an-account": {
"nonce": "0",
"balance": "1,000,000,000,000",
"esdt": {
"str:PAYABLE-FEATURES-TOKEN": "1,000,000,000,000",
"str:OTHER-TOKEN": "1,000,000,000,000"
}
}
}
},
{
"step": "scCall",
"id": "payable_token_1.1",
"tx": {
"from": "address:an-account",
"to": "sc:payable-features",
"function": "payable_token_1",
"arguments": [],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:function expects single ESDT payment",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "payable_token_1.2",
"tx": {
"from": "address:an-account",
"to": "sc:payable-features",
"egldValue": "5",
"function": "payable_token_1",
"arguments": [],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:function expects single ESDT payment",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "payable_token_1.3",
"tx": {
"from": "address:an-account",
"to": "sc:payable-features",
"esdtValue": [
{
"tokenIdentifier": "str:PAYABLE-FEATURES-TOKEN",
"value": "100"
}
],
"function": "payable_token_1",
"arguments": [],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x64",
"0x50415941424c452d46454154555245532d544f4b454e"
],
"status": "0",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "payable_token_1.4",
"tx": {
"from": "address:an-account",
"to": "sc:payable-features",
"esdtValue": [
{
"tokenIdentifier": "str:OTHER-TOKEN",
"value": "100"
}
],
"function": "payable_token_1",
"arguments": [],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:bad call value token provided",
"logs": "*",
"gas": "*",
"refund": "*"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![no_std]
#![allow(clippy::type_complexity)]

multiversx_sc::imports!();
use multiversx_sc::imports::*;

pub mod payable_features_proxy;

/// Contract that only tests the call value features,
/// i.e. the framework/Arwen functionality for accepting EGLD and ESDT payments.
Expand Down
184 changes: 184 additions & 0 deletions contracts/feature-tests/payable-features/src/payable_features_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// 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 PayableFeaturesProxy;

impl<Env, From, To, Gas> TxProxyTrait<Env, From, To, Gas> for PayableFeaturesProxy
where
Env: TxEnv,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
type TxProxyMethods = PayableFeaturesProxyMethods<Env, From, To, Gas>;

fn proxy_methods(self, tx: Tx<Env, From, To, (), Gas, (), ()>) -> Self::TxProxyMethods {
PayableFeaturesProxyMethods { wrapped_tx: tx }
}
}

pub struct PayableFeaturesProxyMethods<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> PayableFeaturesProxyMethods<Env, From, (), Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
pub fn init(
self,
) -> TxTypedDeploy<Env, From, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_deploy()
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> PayableFeaturesProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn echo_call_value(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, ManagedVec<Env::Api, EsdtTokenPayment<Env::Api>>>> {
self.wrapped_tx
.raw_call("echo_call_value")
.original_result()
}

pub fn payment_multiple(
self,
) -> TxTypedCall<Env, From, To, (), Gas, ManagedVec<Env::Api, EsdtTokenPayment<Env::Api>>> {
self.wrapped_tx
.raw_call("payment_multiple")
.original_result()
}

pub fn payment_array_3(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue3<EsdtTokenPayment<Env::Api>, EsdtTokenPayment<Env::Api>, EsdtTokenPayment<Env::Api>>> {
self.wrapped_tx
.raw_call("payment_array_3")
.original_result()
}

pub fn payable_any_1(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_any_1")
.original_result()
}

pub fn payable_any_2(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_any_2")
.original_result()
}

pub fn payable_any_3(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_any_3")
.original_result()
}

pub fn payable_any_4(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_any_4")
.original_result()
}

pub fn payable_egld_1(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_egld_1")
.original_result()
}

pub fn payable_egld_2(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_egld_2")
.original_result()
}

pub fn payable_egld_3(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_egld_3")
.original_result()
}

pub fn payable_egld_4(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_egld_4")
.original_result()
}

pub fn payable_token_1(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_token_1")
.original_result()
}

pub fn payable_token_2(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, TokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_token_2")
.original_result()
}

pub fn payable_token_3(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, EgldOrEsdtTokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_token_3")
.original_result()
}

pub fn payable_token_4(
self,
) -> TxTypedCall<Env, From, To, (), Gas, MultiValue2<BigUint<Env::Api>, TokenIdentifier<Env::Api>>> {
self.wrapped_tx
.raw_call("payable_token_4")
.original_result()
}
}
Loading

0 comments on commit d64d688

Please sign in to comment.