From e417051c3295a8b823a9364c0f4486e78f8f2551 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 22 Nov 2024 17:03:44 +0200 Subject: [PATCH] proxies re-generated --- .../examples/multisig/src/multisig_proxy.rs | 2 +- .../multisig/src/multisig_view_proxy.rs | 2 +- .../src/ping_pong_egld_proxy.rs | 263 ++++++++++++++++++ .../feature-tests/abi-tester/src/abi_proxy.rs | 6 +- 4 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs diff --git a/contracts/examples/multisig/src/multisig_proxy.rs b/contracts/examples/multisig/src/multisig_proxy.rs index 6e4b78df16..b4b691f91f 100644 --- a/contracts/examples/multisig/src/multisig_proxy.rs +++ b/contracts/examples/multisig/src/multisig_proxy.rs @@ -458,7 +458,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)] pub enum UserRole { None, Proposer, diff --git a/contracts/examples/multisig/src/multisig_view_proxy.rs b/contracts/examples/multisig/src/multisig_view_proxy.rs index f17bdc4212..6235f6dbbb 100644 --- a/contracts/examples/multisig/src/multisig_view_proxy.rs +++ b/contracts/examples/multisig/src/multisig_view_proxy.rs @@ -212,7 +212,7 @@ where } #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(TopEncode, TopDecode, Clone, Copy, PartialEq, Eq, Debug)] pub enum UserRole { None, Proposer, diff --git a/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs b/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs new file mode 100644 index 0000000000..ad8944411b --- /dev/null +++ b/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs @@ -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 TxProxyTrait for PingPongProxy +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + type TxProxyMethods = PingPongProxyMethods; + + fn proxy_methods(self, tx: Tx) -> Self::TxProxyMethods { + PingPongProxyMethods { wrapped_tx: tx } + } +} + +pub struct PingPongProxyMethods +where + Env: TxEnv, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + wrapped_tx: Tx, +} + +#[rustfmt::skip] +impl PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + Gas: TxGas, +{ + /// 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>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + ping_amount: Arg0, + duration_in_seconds: Arg1, + opt_activation_timestamp: Arg2, + max_funds: Arg3, + ) -> TxTypedDeploy { + 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 PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + pub fn upgrade< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg>, + Arg3: ProxyArg>>, + >( + self, + ping_amount: Arg0, + duration_in_seconds: Arg1, + opt_activation_timestamp: Arg2, + max_funds: Arg3, + ) -> TxTypedUpgrade { + 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 PingPongProxyMethods +where + Env: TxEnv, + Env::Api: VMApi, + From: TxFrom, + To: TxTo, + Gas: TxGas, +{ + /// 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, + >( + self, + _data: Arg0, + ) -> TxTypedCall { + 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 { + 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 { + 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>> { + 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> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getContractState") + .original_result() + } + + pub fn ping_amount( + self, + ) -> TxTypedCall> { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getPingAmount") + .original_result() + } + + pub fn deadline( + self, + ) -> TxTypedCall { + 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 { + self.wrapped_tx + .payment(NotPayable) + .raw_call("getActivationTimestamp") + .original_result() + } + + /// Optional funding cap. + pub fn max_funds( + self, + ) -> TxTypedCall>> { + 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, + >( + self, + user_id: Arg0, + ) -> TxTypedCall { + 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 { + self.wrapped_tx + .payment(NotPayable) + .raw_call("pongAllLastUser") + .original_result() + } +} + +#[type_abi] +#[derive(TopEncode, TopDecode, Default)] +pub struct ContractState +where + Api: ManagedTypeApi, +{ + pub ping_amount: BigUint, + pub deadline: u64, + pub activation_timestamp: u64, + pub max_funds: Option>, + pub pong_all_last_user: usize, +} + +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy)] +pub enum UserStatus { + New, + Registered, + Withdrawn, +} diff --git a/contracts/feature-tests/abi-tester/src/abi_proxy.rs b/contracts/feature-tests/abi-tester/src/abi_proxy.rs index c13a4a4e2d..69fdfb2319 100644 --- a/contracts/feature-tests/abi-tester/src/abi_proxy.rs +++ b/contracts/feature-tests/abi-tester/src/abi_proxy.rs @@ -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), @@ -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, @@ -564,7 +564,7 @@ pub enum ExplicitDiscriminant { #[rustfmt::skip] #[type_abi] -#[derive(TopEncode, TopDecode)] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)] pub enum ExplicitDiscriminantMixed { Zero, Unit,