Skip to content

Commit

Permalink
forwarder setup, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Dec 9, 2024
1 parent a2e6d34 commit 46a476d
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 66 deletions.
1 change: 0 additions & 1 deletion chain/core/src/builtin_func_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub const SET_USERNAME_FUNC_NAME: &str = "SetUserName";
pub const MIGRATE_USERNAME_FUNC_NAME: &str = "migrateUserName";
pub const DELETE_USERNAME_FUNC_NAME: &str = "DeleteUserName";
pub const UPGRADE_CONTRACT_FUNC_NAME: &str = "upgradeContract";
pub const ESDT_SET_TOKEN_TYPE_FUNC_NAME: &str = "ESDTSetTokenType";
pub const ESDT_MODIFY_ROYALTIES_FUNC_NAME: &str = "ESDTModifyRoyalties";
pub const ESDT_SET_NEW_URIS_FUNC_NAME: &str = "ESDTSetNewURIs";
pub const ESDT_MODIFY_CREATOR_FUNC_NAME: &str = "ESDTModifyCreator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod fwd_call_sync;
pub mod fwd_call_transf_exec;
pub mod fwd_change_owner;
pub mod fwd_deploy;
pub mod fwd_dynamic;
pub mod fwd_esdt;
pub mod fwd_nft;
pub mod fwd_roles;
Expand All @@ -31,6 +32,7 @@ pub trait Forwarder:
+ fwd_sft::ForwarderSftModule
+ fwd_nft::ForwarderNftModule
+ fwd_roles::ForwarderRolesModule
+ fwd_dynamic::ForwarderDynamicModule
+ fwd_storage::ForwarderStorageModule
{
#[init]
Expand Down
120 changes: 120 additions & 0 deletions contracts/feature-tests/composability/forwarder/src/fwd_dynamic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
use crate::fwd_nft::{CallbackProxy, Color};

multiversx_sc::imports!();

#[multiversx_sc::module]
pub trait ForwarderDynamicModule:
crate::fwd_nft::ForwarderNftModule + crate::fwd_storage::ForwarderStorageModule
{
#[payable["EGLD"]]
#[endpoint]
fn issue_dynamic_token(
&self,
token_display_name: ManagedBuffer,
token_ticker: ManagedBuffer,
token_type: EsdtTokenType,
num_decimals: usize,
) {
let issue_cost = self.call_value().egld_value().clone_value();
let caller = self.blockchain().get_caller();

self.send()
.esdt_system_sc_proxy()
.issue_dynamic(
issue_cost,
token_display_name,
token_ticker,
token_type,
num_decimals,
)
.callback(self.callbacks().nft_issue_callback(&caller))
.async_call_and_exit();
}

#[endpoint]
fn change_to_dynamic(&self, token_id: TokenIdentifier) {
self.send()
.esdt_system_sc_proxy()
.change_to_dynamic(token_id)
.sync_call();
}

#[endpoint]
fn update_token(&self, token_id: TokenIdentifier) {
self.send()
.esdt_system_sc_proxy()
.update_token(token_id)
.sync_call();
}

#[endpoint]
fn modify_royalties(&self, token_id: TokenIdentifier, nonce: u64, new_royalty: u64) {
self.send()
.esdt_modify_royalties(&token_id, nonce, new_royalty);
}

#[endpoint]
fn set_new_uris(
&self,
token_id: TokenIdentifier,
nonce: u64,
new_uris: MultiValueEncoded<ManagedBuffer>,
) {
let new_uris = new_uris.to_vec();
self.send()
.esdt_nft_set_new_uris(&token_id, nonce, &new_uris);
}

#[endpoint]
fn modify_creator(&self, token_id: TokenIdentifier, nonce: u64) {
self.send().esdt_nft_modify_creator(&token_id, nonce);
}

#[endpoint]
fn metadata_recreate(
&self,
token_id: TokenIdentifier,
nonce: u64,
name: ManagedBuffer,
royalties: u64,
hash: ManagedBuffer,
new_attributes: Color,
uris: MultiValueEncoded<ManagedBuffer>,
) {
let uris = uris.to_vec();

self.send().esdt_metadata_recreate(
token_id,
nonce,
name,
royalties,
hash,
&new_attributes,
uris,
);
}

#[endpoint]
fn metadata_update(
&self,
token_id: TokenIdentifier,
nonce: u64,
name: ManagedBuffer,
royalties: u64,
hash: ManagedBuffer,
new_attributes: Color,
uris: MultiValueEncoded<ManagedBuffer>,
) {
let uris = uris.to_vec();

self.send().esdt_metadata_update(
token_id,
nonce,
name,
royalties,
hash,
&new_attributes,
uris,
);
}
}
12 changes: 10 additions & 2 deletions contracts/feature-tests/composability/forwarder/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
////////////////////////////////////////////////////

// Init: 1
// Endpoints: 69
// Endpoints: 77
// Async Callback: 1
// Total number of exported functions: 71
// Total number of exported functions: 79

#![no_std]

Expand Down Expand Up @@ -85,6 +85,14 @@ multiversx_sc_wasm_adapter::endpoints! {
create_and_send => create_and_send
setLocalRoles => set_local_roles
unsetLocalRoles => unset_local_roles
issue_dynamic_token => issue_dynamic_token
change_to_dynamic => change_to_dynamic
update_token => update_token
modify_royalties => modify_royalties
set_new_uris => set_new_uris
modify_creator => modify_creator
metadata_recreate => metadata_recreate
metadata_update => metadata_update
lastIssuedToken => last_issued_token
lastErrorMessage => last_error_message
)
Expand Down
2 changes: 0 additions & 2 deletions framework/base/src/types/interaction/system_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
mod builtin_func_proxy;
mod esdt_system_sc_proxy;
mod legacy_system_sc_proxy;
mod system_sc_proxy;
pub(crate) mod token_properties;

pub use builtin_func_proxy::*;
pub use esdt_system_sc_proxy::{ESDTSystemSCProxy, ESDTSystemSCProxyMethods, IssueCall};
pub use legacy_system_sc_proxy::ESDTSystemSmartContractProxy;
pub use system_sc_proxy::{SystemSCProxy, SystemSCProxyMethods};
pub use token_properties::*;

This file was deleted.

0 comments on commit 46a476d

Please sign in to comment.