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

Builtin func proxy migration #1537

Merged
merged 9 commits into from
Apr 9, 2024
9 changes: 5 additions & 4 deletions contracts/modules/src/claim_developer_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ multiversx_sc::imports!();
pub trait ClaimDeveloperRewardsModule {
#[endpoint(claimDeveloperRewards)]
fn claim_developer_rewards(&self, child_sc_address: ManagedAddress) {
let () = self
.send()
.claim_developer_rewards(child_sc_address)
.execute_on_dest_context();
self.tx()
.to(&child_sc_address)
.typed(system_proxy::UserBuiltinProxy)
.claim_developer_rewards()
.async_call_and_exit();
BiancaIalangi marked this conversation as resolved.
Show resolved Hide resolved
}
}
5 changes: 3 additions & 2 deletions framework/base/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod blockchain_api;
mod builtin_function_names;
mod call_value_api;
mod composite_api;
mod crypto_api;
Expand All @@ -16,7 +15,6 @@ pub mod uncallable;
mod vm_api;

pub use blockchain_api::*;
pub use builtin_function_names::*;
pub use call_value_api::*;
pub use composite_api::*;
pub use crypto_api::*;
Expand All @@ -30,3 +28,6 @@ pub use print_api::*;
pub use send_api::*;
pub use storage_api::*;
pub use vm_api::VMApi;

// Backwards compatibility.
pub use crate::types::system_proxy::builtin_func_names::*;
26 changes: 8 additions & 18 deletions framework/base/src/contract_base/wrappers/send_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use core::marker::PhantomData;
use crate::codec::Empty;

use crate::{
api::{
BlockchainApi, BlockchainApiImpl, CallTypeApi, StorageReadApi,
CHANGE_OWNER_BUILTIN_FUNC_NAME, CLAIM_DEVELOPER_REWARDS_FUNC_NAME,
ESDT_LOCAL_BURN_FUNC_NAME, ESDT_LOCAL_MINT_FUNC_NAME, ESDT_NFT_ADD_QUANTITY_FUNC_NAME,
ESDT_NFT_ADD_URI_FUNC_NAME, ESDT_NFT_BURN_FUNC_NAME, ESDT_NFT_CREATE_FUNC_NAME,
ESDT_NFT_UPDATE_ATTRIBUTES_FUNC_NAME,
},
api::{BlockchainApi, BlockchainApiImpl, CallTypeApi, StorageReadApi},
codec,
types::{
system_proxy, BigUint, ContractCall, ContractCallNoPayment, ESDTSystemSCAddress,
system_proxy,
system_proxy::builtin_func_names::{
CHANGE_OWNER_BUILTIN_FUNC_NAME, ESDT_LOCAL_BURN_FUNC_NAME, ESDT_LOCAL_MINT_FUNC_NAME,
ESDT_NFT_ADD_QUANTITY_FUNC_NAME, ESDT_NFT_ADD_URI_FUNC_NAME, ESDT_NFT_BURN_FUNC_NAME,
ESDT_NFT_CREATE_FUNC_NAME, ESDT_NFT_UPDATE_ATTRIBUTES_FUNC_NAME,
},
BigUint, ContractCall, ContractCallNoPayment, ESDTSystemSCAddress,
EgldOrEsdtTokenIdentifier, EsdtTokenPayment, GasLeft, ManagedAddress, ManagedArgBuffer,
ManagedBuffer, ManagedType, ManagedVec, ReturnsRawResult, ToSelf, TokenIdentifier, Tx,
TxScEnv,
Expand Down Expand Up @@ -358,16 +358,6 @@ where
.async_call_and_exit()
}

/// Creates a call to the `ClaimDeveloperRewards` builtin function.
///
/// In itself, this does nothing. You need to then call turn the contract call into an async call.
pub fn claim_developer_rewards(
andrei-marinica marked this conversation as resolved.
Show resolved Hide resolved
&self,
child_sc_address: ManagedAddress<A>,
) -> ContractCallNoPayment<A, ()> {
ContractCallNoPayment::new(child_sc_address, CLAIM_DEVELOPER_REWARDS_FUNC_NAME)
}

/// Creates a call to the `ChangeOwnerAddress` builtin function.
///
/// In itself, this does nothing. You need to then call turn the contract call into an async call.
Expand Down
1 change: 1 addition & 0 deletions framework/base/src/types/interaction/system_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod builtin_func_proxy;
mod esdt_system_sc_proxy;
mod legacy_system_sc_proxy;
pub(crate) mod token_properties;
pub mod builtin_func_names;

pub use builtin_func_proxy::*;
pub use esdt_system_sc_proxy::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use self::builtin_func_names::{
CHANGE_OWNER_BUILTIN_FUNC_NAME, CLAIM_DEVELOPER_REWARDS_FUNC_NAME, DELETE_USERNAME_FUNC_NAME,
ESDT_LOCAL_BURN_FUNC_NAME, ESDT_LOCAL_MINT_FUNC_NAME, ESDT_NFT_ADD_QUANTITY_FUNC_NAME,
ESDT_NFT_ADD_URI_FUNC_NAME, ESDT_NFT_BURN_FUNC_NAME, ESDT_NFT_CREATE_FUNC_NAME,
ESDT_NFT_UPDATE_ATTRIBUTES_FUNC_NAME, SET_USERNAME_FUNC_NAME,
};
use crate::proxy_imports::*;

/// Proxy describing the user builtin function signatures.
Expand Down Expand Up @@ -43,7 +49,7 @@ where
name: Arg0,
) -> TxProxyCall<Env, From, To, Gas, ()> {
self.wrapped_tx
.raw_call("SetUserName")
.raw_call(SET_USERNAME_FUNC_NAME)
.argument(&name)
.original_result()
}
Expand All @@ -52,7 +58,18 @@ where
self,
) -> TxProxyCall<Env, From, To, Gas, ()> {
self.wrapped_tx
.raw_call("DeleteUserName")
.raw_call(DELETE_USERNAME_FUNC_NAME)
.original_result()
}

/// Creates a call to the `ClaimDeveloperRewards` builtin function.
///
/// In itself, this does nothing. You need to then call turn the contract call into an async call.
pub fn claim_developer_rewards(
self,
) -> TxProxyCall<Env, From, To, Gas, ()> {
self.wrapped_tx
.raw_call(CLAIM_DEVELOPER_REWARDS_FUNC_NAME)
.original_result()
}
}
Loading