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

encode error from basic features migration to new proxy and unified syntax #1516

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod crypto_features;
pub mod echo;
pub mod echo_managed;
pub mod elliptic_curve_features;
pub mod encode_error_proxy;
pub mod event_features;
pub mod macro_features;
pub mod managed_address_features;
Expand Down
30 changes: 8 additions & 22 deletions contracts/feature-tests/basic-features/src/codec_err_test.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
multiversx_sc::imports!();
use crate::types::CodecErrorTestType;

mod encode_err_proxy {
multiversx_sc::imports!();
use crate::types::CodecErrorTestType;

#[multiversx_sc::proxy]
pub trait EncodeErrorProxy {
#[init]
fn init(&self, error_arg: CodecErrorTestType);

#[endpoint]
fn encode_error_method(&self, error_arg: CodecErrorTestType);
}
}
use crate::{encode_error_proxy, types::CodecErrorTestType};

/// Test various serialization errors.
#[multiversx_sc::module]
Expand Down Expand Up @@ -62,24 +48,24 @@ pub trait CodecErrorTest {
fn codec_err_event_data(&self) {
self.event_err_data(CodecErrorTestType);
}

#[proxy]
fn encode_err_proxy(&self) -> encode_err_proxy::Proxy<Self::Api>;

/// Never actually calls any deploy/upgrade, so it is appropriate in this contract.
/// It just covers contract init serialization errors.
#[endpoint]
fn codec_err_contract_init(&self) {
let _ = self.encode_err_proxy().init(CodecErrorTestType);
let _ = self
.tx()
.typed(encode_error_proxy::EncodeErrorProxy)
.init(CodecErrorTestType);
}

/// Never actually calls any async/sync call, so it is appropriate in this contract.
/// It just covers contract call serialization errors.
#[endpoint]
fn codec_err_contract_call(&self) {
let _ = self
.encode_err_proxy()
.contract(ManagedAddress::zero())
.tx()
.to(&ManagedAddress::zero())
.typed(encode_error_proxy::EncodeErrorProxy)
.encode_error_method(CodecErrorTestType);
andrei-marinica marked this conversation as resolved.
Show resolved Hide resolved
}
}
100 changes: 100 additions & 0 deletions contracts/feature-tests/basic-features/src/encode_error_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Code generated by the multiversx-sc proxy generator. DO NOT EDIT.

////////////////////////////////////////////////////
////////////////// AUTO-GENERATED //////////////////
////////////////////////////////////////////////////

#![allow(dead_code)]
#![allow(clippy::all)]

use multiversx_sc::proxy_imports::*;

use crate::types::CodecErrorTestType;

pub struct EncodeErrorProxy;

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

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

pub struct EncodeErrorProxyMethods<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> EncodeErrorProxyMethods<Env, From, (), Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
Gas: TxGas<Env>,
{
pub fn init<
Arg0: CodecInto<CodecErrorTestType>,
>(
self,
error_arg: Arg0,
) -> TxProxyDeploy<Env, From, Gas, ()> {
self.wrapped_tx
.raw_deploy()
.argument(&error_arg)
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> EncodeErrorProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn upgrade(
self,
) -> TxProxyUpgrade<Env, From, To, Gas, ()> {
self.wrapped_tx
.raw_upgrade()
.original_result()
}
}

#[rustfmt::skip]
impl<Env, From, To, Gas> EncodeErrorProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
pub fn encode_error_method<
Arg0: CodecInto<CodecErrorTestType>,
>(
self,
error_arg: Arg0,
) -> TxProxyCall<Env, From, To, Gas, ()> {
self.wrapped_tx
.raw_call()
.function_name("encode_error_method")
.argument(&error_arg)
.original_result()
}
}
Loading