Skip to content

Commit

Permalink
proxies re-generated
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Nov 22, 2024
1 parent 404eea6 commit e417051
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/examples/multisig/src/multisig_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ where
}

#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)]
pub enum UserRole {
None,
Proposer,
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/multisig/src/multisig_view_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ where
}

#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)]
pub enum UserRole {
None,
Proposer,
Expand Down
263 changes: 263 additions & 0 deletions contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
// 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 PingPongProxy;

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

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

pub struct PingPongProxyMethods<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> PingPongProxyMethods<Env, From, (), Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
/// Necessary configuration when deploying:
/// `ping_amount` - the exact EGLD amount that needs to be sent when `ping`-ing.
/// `duration_in_seconds` - how much time (in seconds) until contract expires.
/// `opt_activation_timestamp` - optionally specify the contract to only activate at a later date.
/// `max_funds` - optional funding cap, no more funds than this can be added to the contract.
pub fn init<
Arg0: ProxyArg<BigUint<Env::Api>>,
Arg1: ProxyArg<u64>,
Arg2: ProxyArg<Option<u64>>,
Arg3: ProxyArg<OptionalValue<BigUint<Env::Api>>>,
>(
self,
ping_amount: Arg0,
duration_in_seconds: Arg1,
opt_activation_timestamp: Arg2,
max_funds: Arg3,
) -> TxTypedDeploy<Env, From, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_deploy()
.argument(&ping_amount)
.argument(&duration_in_seconds)
.argument(&opt_activation_timestamp)
.argument(&max_funds)
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> PingPongProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn upgrade<
Arg0: ProxyArg<BigUint<Env::Api>>,
Arg1: ProxyArg<u64>,
Arg2: ProxyArg<Option<u64>>,
Arg3: ProxyArg<OptionalValue<BigUint<Env::Api>>>,
>(
self,
ping_amount: Arg0,
duration_in_seconds: Arg1,
opt_activation_timestamp: Arg2,
max_funds: Arg3,
) -> TxTypedUpgrade<Env, From, To, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_upgrade()
.argument(&ping_amount)
.argument(&duration_in_seconds)
.argument(&opt_activation_timestamp)
.argument(&max_funds)
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> PingPongProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
/// User sends some EGLD to be locked in the contract for a period of time.
/// Optional `_data` argument is ignored.
pub fn ping<
Arg0: ProxyArg<IgnoreValue>,
>(
self,
_data: Arg0,
) -> TxTypedCall<Env, From, To, (), Gas, ()> {
self.wrapped_tx
.raw_call("ping")
.argument(&_data)
.original_result()
}

/// User can take back funds from the contract.
/// Can only be called after expiration.
pub fn pong(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("pong")
.original_result()
}

/// Send back funds to all users who pinged.
/// Returns
/// - `completed` if everything finished
/// - `interrupted` if run out of gas midway.
/// Can only be called after expiration.
pub fn pong_all(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, OperationCompletionStatus> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("pongAll")
.original_result()
}

/// Lists the addresses of all users that have `ping`-ed,
/// in the order they have `ping`-ed
pub fn get_user_addresses(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, MultiValueEncoded<Env::Api, ManagedAddress<Env::Api>>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getUserAddresses")
.original_result()
}

/// Returns the current contract state as a struct
/// for faster fetching from external parties
pub fn get_contract_state(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ContractState<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getContractState")
.original_result()
}

pub fn ping_amount(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, BigUint<Env::Api>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getPingAmount")
.original_result()
}

pub fn deadline(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, u64> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getDeadline")
.original_result()
}

/// Block timestamp of the block where the contract got activated.
/// If not specified in the constructor it is the the deploy block timestamp.
pub fn activation_timestamp(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, u64> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getActivationTimestamp")
.original_result()
}

/// Optional funding cap.
pub fn max_funds(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, Option<BigUint<Env::Api>>> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getMaxFunds")
.original_result()
}

/// State of user funds.
/// 0 - user unknown, never `ping`-ed
/// 1 - `ping`-ed
/// 2 - `pong`-ed
pub fn user_status<
Arg0: ProxyArg<usize>,
>(
self,
user_id: Arg0,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, UserStatus> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("getUserStatus")
.argument(&user_id)
.original_result()
}

/// Part of the `pongAll` status, the last user to be processed.
/// 0 if never called `pongAll` or `pongAll` completed.
pub fn pong_all_last_user(
self,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, usize> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("pongAllLastUser")
.original_result()
}
}

#[type_abi]
#[derive(TopEncode, TopDecode, Default)]
pub struct ContractState<Api>
where
Api: ManagedTypeApi,
{
pub ping_amount: BigUint<Api>,
pub deadline: u64,
pub activation_timestamp: u64,
pub max_funds: Option<BigUint<Api>>,
pub pong_all_last_user: usize,
}

#[type_abi]
#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)]
pub enum UserStatus {
New,
Registered,
Withdrawn,
}
6 changes: 3 additions & 3 deletions contracts/feature-tests/abi-tester/src/abi_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ pub struct OnlyShowsUpAsNested02 {

#[rustfmt::skip]
#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub enum AbiEnum {
Nothing,
Something(i32),
Expand Down Expand Up @@ -553,7 +553,7 @@ pub struct OnlyShowsUpInEsdtAttr {
pub struct OnlyShowsUpAsNested10 {}

#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub enum ExplicitDiscriminant {
Zero,
Thirty,
Expand All @@ -564,7 +564,7 @@ pub enum ExplicitDiscriminant {

#[rustfmt::skip]
#[type_abi]
#[derive(TopEncode, TopDecode)]
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub enum ExplicitDiscriminantMixed {
Zero,
Unit,
Expand Down

0 comments on commit e417051

Please sign in to comment.