-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
404eea6
commit e417051
Showing
4 changed files
with
268 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
263 changes: 263 additions & 0 deletions
263
contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters