Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add enum in proxy #1482

Merged
merged 27 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d9114fc
add enum in proxy
BiancaIalangi Mar 18, 2024
0d81244
tx proxy gen - TypeAbi derive rust name fix
andrei-marinica Mar 19, 2024
1c0fc9d
tx proxy gen - extract attributes macro
BiancaIalangi Mar 19, 2024
37de8ba
tx proxy gen - add macro_attibutes in proxy for enum
BiancaIalangi Mar 19, 2024
775f0e8
tx proxy gen - add derive imports
BiancaIalangi Mar 20, 2024
5a3115f
Merge branch 'feat/unified' into struct-enum-in-proxy
BiancaIalangi Mar 20, 2024
4a06a1e
tx proxy gen - generate code for struct
BiancaIalangi Mar 20, 2024
1ca8287
tx proxy gen - cleanup
BiancaIalangi Mar 20, 2024
4a3fc93
Merge branch 'feat/unified' into struct-enum-in-proxy
andrei-marinica Mar 20, 2024
88eb1a4
proxy gen - multiple outputs
andrei-marinica Mar 20, 2024
2488db8
proxy gen - type fixes
andrei-marinica Mar 20, 2024
f86de72
abi tester proxy - initial commit
andrei-marinica Mar 20, 2024
b682d58
proxy gen - clean up imports
andrei-marinica Mar 21, 2024
8ee46b9
proxy gen - derive fix
andrei-marinica Mar 21, 2024
d7a541f
tx proxy gen - fixed tests
BiancaIalangi Mar 21, 2024
8f9fffe
tx proxy gen - fixed tests
BiancaIalangi Mar 21, 2024
e06e1d1
type_abi proc attribute instead of derive(TypeAbi)
andrei-marinica Mar 21, 2024
2591226
multisig - re-generated proxy
andrei-marinica Mar 21, 2024
0734745
type abi - type name rust in struct field description
andrei-marinica Mar 21, 2024
ba291bf
tx proxy gen - handle enum with tuple and struct variants
BiancaIalangi Mar 21, 2024
82133df
fix clippy
BiancaIalangi Mar 21, 2024
4b64a37
tx proxy gen - setup and call sc-meta proxy
BiancaIalangi Mar 21, 2024
8e1e668
tx proxy gen - fixed multisig
andrei-marinica Mar 21, 2024
a101ad3
tx proxy gen - blacklist of types from framework
andrei-marinica Mar 21, 2024
318070e
tx proxy gen - fix abi-tester
andrei-marinica Mar 21, 2024
87fd173
tx proxy gen - fixed test
BiancaIalangi Mar 21, 2024
10e8d93
tx proxy gen - revert template test
BiancaIalangi Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions contracts/examples/adder/src/adder_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#![allow(clippy::all)]

use multiversx_sc::imports::*;
use multiversx_sc::proxy_imports::*;

pub struct AdderProxy;

Expand Down Expand Up @@ -39,15 +39,26 @@ where
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
pub fn init<Arg0: CodecInto<BigUint<Env::Api>>>(
pub fn init<
Arg0: CodecInto<BigUint<Env::Api>>,
>(
self,
initial_value: Arg0,
) -> Tx<Env, From, (), (), Gas, DeployCall<Env, ()>, OriginalResultMarker<()>> {
) -> Tx<
Env,
From,
(),
(),
Gas,
DeployCall<Env, ()>,
OriginalResultMarker<()>,
> {
self.wrapped_tx
.raw_deploy()
.argument(&initial_value)
.original_result()
}

}
impl<Env, From, To, Gas> AdderProxyMethods<Env, From, To, Gas>
where
Expand All @@ -66,23 +77,34 @@ where
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<multiversx_sc::types::BigUint<Env::Api>>,
OriginalResultMarker<BigUint<Env::Api>>,
> {
self.wrapped_tx
.raw_call()
.function_name("getSum")
.original_result()
}

/// Add desired amount to the storage variable.
pub fn add<Arg0: CodecInto<BigUint<Env::Api>>>(
/// Add desired amount to the storage variable.
pub fn add<
Arg0: CodecInto<BigUint<Env::Api>>,
>(
self,
value: Arg0,
) -> Tx<Env, From, To, (), Gas, FunctionCall<Env::Api>, OriginalResultMarker<()>> {
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<()>,
> {
self.wrapped_tx
.raw_call()
.function_name("add")
.argument(&value)
.original_result()
}

}
2 changes: 2 additions & 0 deletions contracts/examples/crowdfunding-esdt/sc-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
proxy-paths = ["src/crowdfunding_esdt_proxy.rs"]
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#![no_std]

use multiversx_sc::{derive_imports::*, imports::*};
pub mod crowdfunding_esdt_proxy;

#[derive(TopEncode, TopDecode, TypeAbi, PartialEq, Eq, Clone, Copy, Debug)]
#[type_abi]
#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy, Debug)]
pub enum Status {
FundingPeriod,
Successful,
Expand Down
224 changes: 224 additions & 0 deletions contracts/examples/crowdfunding-esdt/src/crowdfunding_esdt_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
////////////////////////////////////////////////////
////////////////// AUTO-GENERATED //////////////////
////////////////////////////////////////////////////

#![allow(clippy::all)]

use multiversx_sc::proxy_imports::*;

pub struct CrowdfundingProxy;

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

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

pub struct CrowdfundingProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
wrapped_tx: Tx<Env, From, To, (), Gas, (), ()>,
}

impl<Env, From, Gas> CrowdfundingProxyMethods<Env, From, (), Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
pub fn init<
Arg0: CodecInto<BigUint<Env::Api>>,
Arg1: CodecInto<u64>,
Arg2: CodecInto<EgldOrEsdtTokenIdentifier<Env::Api>>,
>(
self,
target: Arg0,
deadline: Arg1,
token_identifier: Arg2,
) -> Tx<
Env,
From,
(),
(),
Gas,
DeployCall<Env, ()>,
OriginalResultMarker<()>,
> {
self.wrapped_tx
.raw_deploy()
.argument(&target)
.argument(&deadline)
.argument(&token_identifier)
.original_result()
}

}
impl<Env, From, To, Gas> CrowdfundingProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn fund(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<()>,
> {
self.wrapped_tx
.raw_call()
.function_name("fund")
.original_result()
}

pub fn status(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<Status>,
> {
self.wrapped_tx
.raw_call()
.function_name("status")
.original_result()
}

pub fn get_current_funds(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<BigUint<Env::Api>>,
> {
self.wrapped_tx
.raw_call()
.function_name("getCurrentFunds")
.original_result()
}

pub fn claim(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<()>,
> {
self.wrapped_tx
.raw_call()
.function_name("claim")
.original_result()
}

pub fn target(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<BigUint<Env::Api>>,
> {
self.wrapped_tx
.raw_call()
.function_name("getTarget")
.original_result()
}

pub fn deadline(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<u64>,
> {
self.wrapped_tx
.raw_call()
.function_name("getDeadline")
.original_result()
}

pub fn deposit<
Arg0: CodecInto<ManagedAddress<Env::Api>>,
>(
self,
donor: Arg0,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<BigUint<Env::Api>>,
> {
self.wrapped_tx
.raw_call()
.function_name("getDeposit")
.argument(&donor)
.original_result()
}

pub fn cf_token_identifier(
self,
) -> Tx<
Env,
From,
To,
(),
Gas,
FunctionCall<Env::Api>,
OriginalResultMarker<EgldOrEsdtTokenIdentifier<Env::Api>>,
> {
self.wrapped_tx
.raw_call()
.function_name("getCrowdfundingTokenIdentifier")
.original_result()
}

}
#[derive(TopEncode, TopDecode, PartialEq, Eq, Clone, Copy, Debug)]
pub enum Status {
FundingPeriod,
Successful,
Failed,
}

2 changes: 2 additions & 0 deletions contracts/examples/crypto-zombies/sc-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
proxy-paths = ["src/proxy_crypto_zombies.rs"]
1 change: 1 addition & 0 deletions contracts/examples/crypto-zombies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use multiversx_sc::imports::*;

mod crypto_kitties_proxy;
pub mod proxy_crypto_zombies;
mod storage;
mod zombie;
mod zombie_attack;
Expand Down
Loading
Loading