From d05ba858a0ea38236f19306c3c955d092c4812a6 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Tue, 3 Dec 2024 17:21:21 +0200 Subject: [PATCH 1/2] ping-pong - remove unnecessary proxy --- .../src/ping_pong_egld_proxy.rs | 263 ------------------ 1 file changed, 263 deletions(-) delete mode 100644 contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs 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 deleted file mode 100644 index ad8944411b..0000000000 --- a/contracts/examples/ping-pong-egld/src/ping_pong_egld_proxy.rs +++ /dev/null @@ -1,263 +0,0 @@ -// 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, -} From a84f76c9e2aef539ef18fb2fa05e1e1f2b4238c8 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Tue, 3 Dec 2024 17:22:35 +0200 Subject: [PATCH 2/2] ping-pong - rename proxy --- contracts/examples/ping-pong-egld/sc-config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/examples/ping-pong-egld/sc-config.toml b/contracts/examples/ping-pong-egld/sc-config.toml index 2a4a6ee147..bb96777b61 100644 --- a/contracts/examples/ping-pong-egld/sc-config.toml +++ b/contracts/examples/ping-pong-egld/sc-config.toml @@ -1,2 +1,2 @@ [[proxy]] -path = "src/ping_pong_egld_proxy.rs" +path = "src/proxy_ping_pong_egld.rs"