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

framework upgrade to 0.50.0 #39

Merged
merged 23 commits into from
May 20, 2024
Merged
Changes from 21 commits
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
3 changes: 1 addition & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -13,9 +13,8 @@ permissions:
jobs:
contracts:
name: Contracts
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v2.3.5
uses: multiversx/mx-sc-actions/.github/workflows/contracts.yml@v3.1.0
with:
rust-toolchain: nightly-2023-12-11
vmtools-version: v1.5.24
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
1,373 changes: 1,297 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[workspace]
resolver = "2"

members = [
"nft-minter",
"nft-minter/meta",
6 changes: 4 additions & 2 deletions esdt-system-sc-mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ publish = false

[lib]
path = "src/esdt_system_sc_mock.rs"

[dependencies.multiversx-sc]
version = "=0.41.3"
version = "=0.50.0"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.41.3"
version = "=0.50.0"
4 changes: 3 additions & 1 deletion esdt-system-sc-mock/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ version = "0.0.0"
authors = ["Dorin Marian Iancu <dorin.iancu@elrond.com>"]
edition = "2018"
publish = false

[dependencies.esdt-system-sc-mock]
path = ".."

[dependencies.multiversx-sc-meta]
version = "=0.41.3"
version = "=0.50.0"
default-features = false
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
}
},
"storage": {},
"code": "file:../output/esdt-system-sc-mock.wasm"
"code": "mxsc:../output/esdt-system-sc-mock.mxsc.json"
}
}
},
@@ -97,7 +97,7 @@
"storage": {
"str:nrIssuedTokens": "1"
},
"code": "file:../output/esdt-system-sc-mock.wasm"
"code": "mxsc:../output/esdt-system-sc-mock.mxsc.json"
}
}
},
8 changes: 7 additions & 1 deletion esdt-system-sc-mock/tests/esdt_system_sc_mock_go_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
ScenarioWorld::vm_go()
}

#[test]
fn issue_go() {
multiversx_sc_scenario::run_go("mandos/esdt_system_sc.scen.json");
world().run("scenarios/esdt_system_sc.scen.json");
}
4 changes: 2 additions & 2 deletions esdt-system-sc-mock/tests/esdt_system_sc_mock_rs_test.rs
Original file line number Diff line number Diff line change
@@ -4,13 +4,13 @@ fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("esdt-system-sc-mock");
blockchain.register_contract(
"file:output/esdt-system-sc-mock.wasm",
"mxsc:output/esdt-system-sc-mock.mxsc.json",
esdt_system_sc_mock::ContractBuilder,
);
blockchain
}

#[test]
fn issue_rs() {
multiversx_sc_scenario::run_rs("mandos/esdt_system_sc.scen.json", world());
world().run("scenarios/esdt_system_sc.scen.json");
}
105 changes: 21 additions & 84 deletions esdt-system-sc-mock/wasm/Cargo.lock
15 changes: 13 additions & 2 deletions esdt-system-sc-mock/wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
# Code generated by the multiversx-sc build system. DO NOT EDIT.

# ##########################################
# ############## AUTO-GENERATED #############
# ##########################################

[package]
name = "esdt-system-sc-mock-wasm"
version = "0.0.0"
authors = ["Dorin Marian Iancu <dorin.iancu@elrond.com>"]
edition = "2018"
publish = false

[lib]
crate-type = ["cdylib"]

[profile.release]
codegen-units = 1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = false

[profile.dev]
panic = "abort"

[dependencies.esdt-system-sc-mock]
path = ".."

[dependencies.multiversx-sc-wasm-adapter]
version = "=0.41.3"
version = "=0.50.0"

[workspace]
members = ["."]
18 changes: 9 additions & 9 deletions esdt-system-sc-mock/wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT.
// Code generated by the multiversx-sc build system. DO NOT EDIT.

////////////////////////////////////////////////////
////////////////// AUTO-GENERATED //////////////////
@@ -10,21 +10,21 @@
// Total number of exported functions: 8

#![no_std]
#![feature(lang_items)]

multiversx_sc_wasm_adapter::allocator!();
multiversx_sc_wasm_adapter::panic_handler!();

multiversx_sc_wasm_adapter::endpoints! {
esdt_system_sc_mock
(
issue
issueNonFungible
issueSemiFungible
registerMetaESDT
setSpecialRole
registerAndSetAllRoles
init => init
issue => issue_fungible
issueNonFungible => issue_non_fungible
issueSemiFungible => issue_semi_fungible
registerMetaESDT => issue_meta_esdt
setSpecialRole => set_special_roles
registerAndSetAllRoles => register_and_set_all_roles
)
}

multiversx_sc_wasm_adapter::empty_callback! {}
multiversx_sc_wasm_adapter::async_callback_empty! {}
6 changes: 3 additions & 3 deletions nft-minter-deployer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ path = "src/lib.rs"
path = "../nft-minter"

[dependencies.multiversx-sc]
version = "=0.41.3"
version = "=0.50.0"

[dependencies.multiversx-sc-modules]
version = "=0.41.3"
version = "=0.50.0"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.41.3"
version = "=0.50.0"
4 changes: 3 additions & 1 deletion nft-minter-deployer/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ version = "0.0.0"
authors = ["MultiversX <contact@multiversx.com>"]
edition = "2021"
publish = false

[dependencies.nft-minter-deployer]
path = ".."

[dependencies.multiversx-sc-meta]
version = "=0.41.3"
version = "=0.50.0"
default-features = false
3 changes: 2 additions & 1 deletion nft-minter-deployer/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();

#[derive(TypeAbi, TopEncode)]
#[type_abi]
#[derive(TopEncode)]
pub struct CreateNftMinterEvent<M: ManagedTypeApi> {
royalties_claim_address: ManagedAddress<M>,
mint_payments_claim_address: ManagedAddress<M>,
40 changes: 20 additions & 20 deletions nft-minter-deployer/src/factory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();
pub use nft_minter;

#[multiversx_sc::module]
pub trait FactoryModule {
@@ -14,18 +15,21 @@ pub trait FactoryModule {
!self.nft_minter_template_address().is_empty(),
"Nft minter contract template is empty"
);
let (new_address, ()) = self
.nft_minter_contract_proxy()
let new_address = self
.tx()
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.init(
royalties_claim_address,
mint_payments_claim_address,
max_nfts_per_transaction,
OptionalValue::Some(admin.clone()),
)
.deploy_from_source(
&self.nft_minter_template_address().get(),
.code_metadata(
CodeMetadata::UPGRADEABLE | CodeMetadata::READABLE | CodeMetadata::PAYABLE_BY_SC,
);
)
.from_source(self.nft_minter_template_address().get())
.returns(ReturnsNewManagedAddress)
.sync_call();

self.user_nft_minter_contracts(&admin)
.insert(new_address.clone());
@@ -41,26 +45,22 @@ pub trait FactoryModule {
mint_payments_claim_address: ManagedAddress,
max_nfts_per_transaction: usize,
) {
self.nft_minter_contract_proxy()
.contract(nft_minter_address)
.init(
royalties_claim_address,
mint_payments_claim_address,
max_nfts_per_transaction,
self.tx()
.to(nft_minter_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.upgrade(
&royalties_claim_address,
&mint_payments_claim_address,
&max_nfts_per_transaction,
OptionalValue::None::<ManagedAddress>,
)
.upgrade_from_source(
&self.nft_minter_template_address().get(),
.code_metadata(
CodeMetadata::UPGRADEABLE | CodeMetadata::READABLE | CodeMetadata::PAYABLE_BY_SC,
);
)
.from_source(self.nft_minter_template_address().get())
.upgrade_async_call_and_exit();
}

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

#[proxy]
fn user_nft_minter_proxy(&self, to: ManagedAddress) -> nft_minter::Proxy<Self::Api>;

#[view(getUserNftMinterContracts)]
#[storage_mapper("userNftMinterContracts")]
fn user_nft_minter_contracts(
32 changes: 16 additions & 16 deletions nft-minter-deployer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -3,9 +3,6 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();

use multiversx_sc_modules::pause::ProxyTrait as _;
use nft_minter::admin_whitelist::ProxyTrait as _;

mod events;
pub mod factory;

@@ -95,10 +92,11 @@ pub trait NftMinterDeployer: factory::FactoryModule + events::EventsModule {
"NFT Minter contract does not exist"
);

let _: IgnoreValue = self
.user_nft_minter_proxy(nft_minter_address)
self.tx()
.to(nft_minter_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.pause_endpoint()
.execute_on_dest_context();
.sync_call();
}

#[only_owner]
@@ -110,10 +108,11 @@ pub trait NftMinterDeployer: factory::FactoryModule + events::EventsModule {
"NFT Minter contract does not exist"
);

let _: IgnoreValue = self
.user_nft_minter_proxy(nft_minter_address)
self.tx()
.to(nft_minter_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.unpause_endpoint()
.execute_on_dest_context();
.sync_call();
}

#[only_owner]
@@ -128,11 +127,11 @@ pub trait NftMinterDeployer: factory::FactoryModule + events::EventsModule {
.contains(&nft_minter_address),
"NFT Minter contract does not exist"
);

let _: IgnoreValue = self
.user_nft_minter_proxy(nft_minter_address)
self.tx()
.to(nft_minter_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.add_user_to_admin_list(admin_address)
.execute_on_dest_context();
.sync_call();
}

#[only_owner]
@@ -148,10 +147,11 @@ pub trait NftMinterDeployer: factory::FactoryModule + events::EventsModule {
"NFT Minter contract does not exist"
);

let _: IgnoreValue = self
.user_nft_minter_proxy(nft_minter_address)
self.tx()
.to(nft_minter_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.remove_user_from_admin_list(admin_address)
.execute_on_dest_context();
.sync_call();
}

#[only_owner]
109 changes: 23 additions & 86 deletions nft-minter-deployer/wasm/Cargo.lock
22 changes: 15 additions & 7 deletions nft-minter-deployer/wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# Code generated by the multiversx-sc build system. DO NOT EDIT.

# ##########################################
# ############## AUTO-GENERATED #############
# ##########################################

[package]
name = "nft-minter-deployer-wasm"
version = "0.0.0"
authors = ["MultiversX <contact@multiversx.com>"]
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]

[workspace]
members = ["."]

[dev-dependencies]
[profile.release]
codegen-units = 1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = false

[profile.dev]
panic = "abort"

[dependencies.nft-minter-deployer]
default-features = false
path = ".."

[dependencies.multiversx-sc-wasm-adapter]
version = "=0.41.3"
version = "=0.50.0"

[workspace]
members = ["."]
30 changes: 15 additions & 15 deletions nft-minter-deployer/wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT.
// Code generated by the multiversx-sc build system. DO NOT EDIT.

////////////////////////////////////////////////////
////////////////// AUTO-GENERATED //////////////////
@@ -10,27 +10,27 @@
// Total number of exported functions: 14

#![no_std]
#![feature(lang_items)]

multiversx_sc_wasm_adapter::allocator!();
multiversx_sc_wasm_adapter::panic_handler!();

multiversx_sc_wasm_adapter::endpoints! {
nft_minter_deployer
(
createNftMinter
upgradeNftMinter
pauseNftMinter
resumeNftMinter
addAdminToNftMinterContract
removeAdminToNftMinterContract
setNftMinterTemplateAddress
setNftMinterCreationEnabled
getUserNftMinterContracts
getAllNftMinterContracts
getNftMinterTemplateAddress
getNftMinterCreationEnabled
init => init
createNftMinter => create_nft_minter_endpoint
upgradeNftMinter => upgrade_nft_minter_endpoint
pauseNftMinter => pause_nft_minter
resumeNftMinter => resume_nft_minter
addAdminToNftMinterContract => add_admin_to_nft_minter_contract
removeAdminToNftMinterContract => remove_admin_to_nft_minter_contract
setNftMinterTemplateAddress => set_nft_minter_template_address
setNftMinterCreationEnabled => set_nft_minter_creation_enabled
getUserNftMinterContracts => user_nft_minter_contracts
getAllNftMinterContracts => all_nft_minter_contracts
getNftMinterTemplateAddress => nft_minter_template_address
getNftMinterCreationEnabled => nft_minter_creation_enabled
)
}

multiversx_sc_wasm_adapter::empty_callback! {}
multiversx_sc_wasm_adapter::async_callback_empty! {}
11 changes: 6 additions & 5 deletions nft-minter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,19 +7,20 @@ publish = false

[lib]
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.41.3"
version = "=0.50.0"

[dependencies.multiversx-sc-modules]
version = "=0.50.0"

[dev-dependencies]
num-bigint = "0.4.2"
num-traits = "0.2"
hex = "0.4"

[dependencies.multiversx-sc-modules]
version = "=0.41.3"

[dev-dependencies.esdt-system-sc-mock]
path = "../esdt-system-sc-mock"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.41.3"
version = "=0.50.0"
4 changes: 3 additions & 1 deletion nft-minter/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,8 +6,10 @@ publish = false
authors = ["Dorin Marian Iancu, dorin.iancu@elrond.com"]

[dev-dependencies]

[dependencies.nft-minter]
path = ".."

[dependencies.multiversx-sc-meta]
version = "=0.41.3"
version = "=0.50.0"
default-features = false
4 changes: 4 additions & 0 deletions nft-minter/sc-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]

[[proxy]]
path = "src/nft_minter_proxy.rs"
9 changes: 6 additions & 3 deletions nft-minter/src/common_storage.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@ pub type PaymentsVec<M> = ManagedVec<M, EsdtTokenPayment<M>>;
pub type EgldValuePaymentsVecPair<M> = MultiValue2<BigUint<M>, PaymentsVec<M>>;
pub type BrandId<M> = ManagedBuffer<M>;

#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
pub struct BrandInfo<M: ManagedTypeApi> {
pub collection_hash: CollectionHash<M>,
pub token_display_name: ManagedBuffer<M>,
@@ -20,13 +21,15 @@ pub struct BrandInfo<M: ManagedTypeApi> {
pub whitelist_expire_timestamp: u64,
}

#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
pub struct TimePeriod {
pub start: u64,
pub end: u64,
}

#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, Debug)]
pub struct MintPrice<M: ManagedTypeApi> {
pub token_id: EgldOrEsdtTokenIdentifier<M>,
pub amount: BigUint<M>,
3 changes: 2 additions & 1 deletion nft-minter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ pub mod common_storage;
pub mod events;
pub mod nft_attributes_builder;
pub mod nft_marketplace_interactor;
pub mod nft_minter_proxy;
pub mod nft_minting;
pub mod nft_tier;
pub mod royalties;
@@ -47,7 +48,7 @@ pub trait NftMinter:
}
}

#[endpoint]
#[upgrade]
fn upgrade(
&self,
royalties_claim_address: ManagedAddress,
605 changes: 605 additions & 0 deletions nft-minter/src/nft_minter_proxy.rs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions nft-minter/src/views.rs
Original file line number Diff line number Diff line change
@@ -7,15 +7,17 @@ use crate::{
nft_tier::{TierName, MAX_TIERS_PER_BRAND},
};

#[derive(TypeAbi, TopEncode, TopDecode)]
#[type_abi]
#[derive(TopEncode, TopDecode)]
pub struct BrandInfoViewResultType<M: ManagedTypeApi> {
pub brand_id: BrandId<M>,
pub nft_token_id: TokenIdentifier<M>,
pub brand_info: BrandInfo<M>,
pub tier_info_entries: ArrayVec<TierInfoEntry<M>, MAX_TIERS_PER_BRAND>,
}

#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, NestedDecode, Debug, PartialEq)]
#[type_abi]
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Debug, PartialEq)]
pub struct TierInfoEntry<M: ManagedTypeApi> {
pub tier: TierName<M>,
pub total_nfts: usize,
4 changes: 2 additions & 2 deletions nft-minter/tests/constants/mod.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub const FIRST_MINT_PRICE_TOKEN_ID: &[u8] = EGLD_TOKEN_ID;
pub const FIRST_MINT_PRICE_AMOUNT: u64 = 1_000;
pub const FIRST_TOKEN_DISPLAY_NAME: &[u8] = b"FirstToken";
pub const FIRST_TOKEN_TICKER: &[u8] = b"FIRST";
pub const FIRST_TOKEN_ID: &[u8] = b"FIRST-000000";
pub const FIRST_TOKEN_ID: &[u8] = b"FIRST-7afdf5";
pub const FIRST_TAGS: &[&[u8]] = &[b"funny", b"sad", b"memes"];
pub const FIRST_TIERS: &[&[u8]] = &[b"gold", b"silver", b"bronze"];
pub const FIRST_NFT_AMOUNTS: &[usize] = &[5, 10, 20];
@@ -34,7 +34,7 @@ pub const SECOND_MINT_PRICE_TOKEN_ID: &[u8] = EGLD_TOKEN_ID;
pub const SECOND_MINT_PRICE_AMOUNT: u64 = 100_000;
pub const SECOND_TOKEN_DISPLAY_NAME: &[u8] = b"SecondToken";
pub const SECOND_TOKEN_TICKER: &[u8] = b"SECOND";
pub const SECOND_TOKEN_ID: &[u8] = b"SECOND-111111";
pub const SECOND_TOKEN_ID: &[u8] = b"SECOND-7afdf5";
pub const SECOND_TAGS: &[&[u8]] = &[b"random", b"good", b"best"];
pub const SECOND_TIERS: &[&[u8]] = &[b"gold", b"silver", b"bronze"];
pub const SECOND_NFT_AMOUNTS: &[usize] = &[10, 15, 25];
7 changes: 3 additions & 4 deletions nft-minter/tests/nft_minter_interactor/mod.rs
Original file line number Diff line number Diff line change
@@ -4,10 +4,9 @@ use multiversx_sc::{
types::{Address, EsdtLocalRole, ManagedVec, MultiValueEncoded},
};
use multiversx_sc_scenario::{
managed_address, managed_biguint, managed_buffer, rust_biguint,
whitebox::TxResult,
whitebox::{BlockchainStateWrapper, ContractObjWrapper},
DebugApi,
imports::TxResult,
imports::{BlockchainStateWrapper, ContractObjWrapper},
managed_address, managed_biguint, managed_buffer, rust_biguint, DebugApi,
};
use nft_minter::brand_creation::BrandCreationModule;
use nft_minter::nft_attributes_builder::COLLECTION_HASH_LEN;
14 changes: 13 additions & 1 deletion nft-minter/tests/rust_test.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,9 @@ pub mod nft_minter_interactor;

use constants::*;
use multiversx_sc::types::{ManagedBuffer, ManagedByteArray, MultiValueEncoded};
use multiversx_sc_scenario::{managed_address, managed_biguint, managed_buffer, rust_biguint, DebugApi};
use multiversx_sc_scenario::{
managed_address, managed_biguint, managed_buffer, rust_biguint, DebugApi,
};
use nft_minter::brand_creation::BrandCreationModule;
use nft_minter::common_storage::{BrandInfo, MintPrice, TimePeriod};
use nft_minter::nft_attributes_builder::{NftAttributesBuilderModule, COLLECTION_HASH_LEN};
@@ -128,6 +130,16 @@ fn create_brands_test() {
);
})
.assert_ok();

nm_setup
.b_mock
.execute_query(&nm_setup.nm_wrapper, |sc| {
let result = sc.get_brand_info_view(managed_buffer!(SECOND_BRAND_ID));

let expected_token_id = managed_token_id!(SECOND_TOKEN_ID);
assert_eq!(result.nft_token_id, expected_token_id.unwrap_esdt());
})
.assert_ok();
}

#[test]
109 changes: 23 additions & 86 deletions nft-minter/wasm/Cargo.lock
21 changes: 15 additions & 6 deletions nft-minter/wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# Code generated by the multiversx-sc build system. DO NOT EDIT.

# ##########################################
# ############## AUTO-GENERATED #############
# ##########################################

[package]
name = "nft-minter-wasm"
version = "0.0.0"
authors = ["Dorin Marian Iancu, dorin.iancu@elrond.com"]
edition = "2018"
publish = false

[lib]
crate-type = ["cdylib"]

[workspace]
members = ["."]

[dev-dependencies]
[profile.release]
codegen-units = 1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = false

[profile.dev]
panic = "abort"

[dependencies.nft-minter]
path = ".."

[dependencies.multiversx-sc-wasm-adapter]
version = "=0.41.3"
version = "=0.50.0"

[workspace]
members = ["."]
78 changes: 40 additions & 38 deletions nft-minter/wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT.
// Code generated by the multiversx-sc build system. DO NOT EDIT.

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

// Init: 1
// Endpoints: 34
// Upgrade: 1
// Endpoints: 33
// Async Callback: 1
// Total number of exported functions: 36

#![no_std]
#![feature(lang_items)]

multiversx_sc_wasm_adapter::allocator!();
multiversx_sc_wasm_adapter::panic_handler!();

multiversx_sc_wasm_adapter::endpoints! {
nft_minter
(
upgrade
setMaxNftsPerTransaction
getMaxNftsPerTransaction
getRegisterdCollectionHashes
getRegisteredBrands
getNftTokenIdForBrand
getPriceForTier
getTagsForBrand
getMintWhitelist
addUserToAdminList
removeUserFromAdminList
issueTokenForBrand
addToWhitelist
removeFromWhitelist
setMintWhitelistExpireTimestamp
buyRandomNft
giveawayNfts
getNftTiersForBrand
nftIdOffsetForTier
setRoyaltiesClaimAddress
changeRoyaltiesForBrand
setMintPaymentsClaimAddress
claimRoyalties
claimMintPayments
getRoyaltiesClaimAddress
getMintPaymentsClaimAddress
getAccumulatedRoyalties
getAccumulatedMintPayments
claimRoyaltiesFromMarketplace
getBrandInfo
getAllBrandsInfo
pause
unpause
isPaused
callBack
init => init
upgrade => upgrade
setMaxNftsPerTransaction => set_max_nfts_per_transaction
getMaxNftsPerTransaction => max_nfts_per_transaction
getRegisterdCollectionHashes => registered_collection_hashes
getRegisteredBrands => registered_brands
getNftTokenIdForBrand => nft_token
getPriceForTier => price_for_tier
getTagsForBrand => tags_for_brand
getMintWhitelist => mint_whitelist
addUserToAdminList => add_user_to_admin_list
removeUserFromAdminList => remove_user_from_admin_list
issueTokenForBrand => issue_token_for_brand
addToWhitelist => add_to_whitelist
removeFromWhitelist => remove_from_whitelist
setMintWhitelistExpireTimestamp => set_mint_whitelist_expire_timestamp
buyRandomNft => buy_random_nft
giveawayNfts => giveaway_nfts
getNftTiersForBrand => nft_tiers_for_brand
nftIdOffsetForTier => nft_id_offset_for_tier
setRoyaltiesClaimAddress => set_royalties_claim_address
changeRoyaltiesForBrand => change_royalties_for_brand
setMintPaymentsClaimAddress => set_mint_payments_claim_address
claimRoyalties => claim_royalties
claimMintPayments => claim_mint_payments
getRoyaltiesClaimAddress => royalties_claim_address
getMintPaymentsClaimAddress => mint_payments_claim_address
getAccumulatedRoyalties => accumulated_royalties
getAccumulatedMintPayments => accumulated_mint_payments
claimRoyaltiesFromMarketplace => claim_royalties_from_marketplace
getBrandInfo => get_brand_info_view
getAllBrandsInfo => get_all_brands_info
pause => pause_endpoint
unpause => unpause_endpoint
isPaused => paused_status
)
}

multiversx_sc_wasm_adapter::async_callback! { nft_minter }
5 changes: 3 additions & 2 deletions royalties-handler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,11 +7,12 @@ publish = false

[lib]
path = "src/lib.rs"

[dependencies.nft-minter]
path = "../nft-minter"

[dependencies.multiversx-sc]
version = "=0.41.3"
version = "=0.50.0"

[dev-dependencies]
num-bigint = "0.4.2"
@@ -22,4 +23,4 @@ hex = "0.4"
path = "../esdt-system-sc-mock"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.41.3"
version = "=0.50.0"
4 changes: 3 additions & 1 deletion royalties-handler/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,8 +6,10 @@ publish = false
authors = ["Dorin Marian Iancu, dorin.iancu@elrond.com"]

[dev-dependencies]

[dependencies.royalties-handler]
path = ".."

[dependencies.multiversx-sc-meta]
version = "=0.41.3"
version = "=0.50.0"
default-features = false
13 changes: 7 additions & 6 deletions royalties-handler/src/nft_minter_interactor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
multiversx_sc::imports!();

use nft_minter::{common_storage::EgldValuePaymentsVecPair, royalties::ProxyTrait as _};
use nft_minter::common_storage::EgldValuePaymentsVecPair;

#[multiversx_sc::module]
pub trait NftMinterInteractorModule:
@@ -31,7 +31,9 @@ pub trait NftMinterInteractorModule:
&self,
sc_address: ManagedAddress,
) -> EgldValuePaymentsVecPair<Self::Api> {
self.nft_minter_proxy(sc_address)
self.tx()
.to(sc_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.claim_royalties()
.execute_on_dest_context()
alyn509 marked this conversation as resolved.
Show resolved Hide resolved
}
@@ -40,14 +42,13 @@ pub trait NftMinterInteractorModule:
&self,
sc_address: ManagedAddress,
) -> EgldValuePaymentsVecPair<Self::Api> {
self.nft_minter_proxy(sc_address)
self.tx()
.to(sc_address)
.typed(nft_minter::nft_minter_proxy::NftMinterProxy)
.claim_mint_payments()
.execute_on_dest_context()
alyn509 marked this conversation as resolved.
Show resolved Hide resolved
alyn509 marked this conversation as resolved.
Show resolved Hide resolved
}

#[proxy]
fn nft_minter_proxy(&self, sc_address: ManagedAddress) -> nft_minter::Proxy<Self::Api>;

#[view(getNftMinterScAddress)]
#[storage_mapper("nftMinterScAddress")]
fn nft_minter_sc_address(&self) -> SingleValueMapper<ManagedAddress>;
3 changes: 2 additions & 1 deletion royalties-handler/src/reward_entries.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@ use nft_minter::common_storage::PaymentsVec;

pub const FIRST_ENTRY_ID: usize = 1;

#[derive(TypeAbi, TopEncode, TopDecode, PartialEq, Debug)]
#[type_abi]
#[derive(TopEncode, TopDecode, PartialEq, Debug)]
pub struct RewardEntry<M: ManagedTypeApi> {
pub egld_amount: BigUint<M>,
pub esdt_payments: PaymentsVec<M>,
2 changes: 1 addition & 1 deletion royalties-handler/tests/constants/mod.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub const FIRST_MINT_PRICE_TOKEN_ID: &[u8] = EGLD_TOKEN_ID;
pub const FIRST_MINT_PRICE_AMOUNT: u64 = 1_000;
pub const FIRST_TOKEN_DISPLAY_NAME: &[u8] = b"FirstToken";
pub const FIRST_TOKEN_TICKER: &[u8] = b"FIRST";
pub const FIRST_TOKEN_ID: &[u8] = b"FIRST-000000";
pub const FIRST_TOKEN_ID: &[u8] = b"FIRST-7afdf5";
pub const FIRST_TAGS: &[&[u8]] = &[b"funny", b"sad", b"memes"];
pub const FIRST_TIERS: &[&[u8]] = &[b"gold", b"silver", b"bronze"];
pub const FIRST_NFT_AMOUNTS: &[usize] = &[5, 10, 20];
22 changes: 10 additions & 12 deletions royalties-handler/tests/nft_minter_setup/mod.rs
Original file line number Diff line number Diff line change
@@ -4,10 +4,8 @@ use multiversx_sc::{
types::{Address, EsdtLocalRole, ManagedVec, MultiValueEncoded},
};
use multiversx_sc_scenario::{
managed_address, managed_biguint, managed_buffer, rust_biguint,
whitebox::TxResult,
whitebox::{BlockchainStateWrapper, ContractObjWrapper},
DebugApi,
imports::{BlockchainStateWrapper, ContractObjWrapper, TxResult},
managed_address, managed_biguint, managed_buffer, rust_biguint, DebugApi,
};
use nft_minter::brand_creation::BrandCreationModule;
use nft_minter::nft_attributes_builder::COLLECTION_HASH_LEN;
@@ -52,14 +50,14 @@ where
let nm_wrapper =
b_mock.create_sc_account(&rust_zero, Some(&owner_address), builder, "nft minter path");

// init ESDT System SC mock
b_mock.create_sc_account_fixed_address(
&Address::from(ESDT_SYSTEM_SC_ADDRESS_ARRAY),
&rust_zero,
None,
esdt_system_sc_mock::contract_obj,
"ESDT system SC mock path",
);
// // init ESDT System SC mock
andrei-marinica marked this conversation as resolved.
Show resolved Hide resolved
// b_mock.create_sc_account_fixed_address(
// &Address::from(ESDT_SYSTEM_SC_ADDRESS_ARRAY),
// &rust_zero,
// None,
// esdt_system_sc_mock::contract_obj,
// "ESDT system SC mock path",
// );

b_mock
.execute_tx(&owner_address, &nm_wrapper, &rust_zero, |sc| {
7 changes: 3 additions & 4 deletions royalties-handler/tests/royalties_handler_setup/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::nft_minter_setup::NftMinterSetup;
use multiversx_sc::types::{Address, MultiValueEncoded};
use multiversx_sc_scenario::{
managed_address, rust_biguint,
whitebox::{BlockchainStateWrapper, ContractObjWrapper},
whitebox::TxResult,
DebugApi,
imports::TxResult,
imports::{BlockchainStateWrapper, ContractObjWrapper},
managed_address, rust_biguint, DebugApi,
};
use nft_minter::royalties::RoyaltiesModule;
use royalties_handler::nft_minter_interactor::NftMinterInteractorModule;
109 changes: 23 additions & 86 deletions royalties-handler/wasm/Cargo.lock
21 changes: 15 additions & 6 deletions royalties-handler/wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# Code generated by the multiversx-sc build system. DO NOT EDIT.

# ##########################################
# ############## AUTO-GENERATED #############
# ##########################################

[package]
name = "royalties-handler-wasm"
version = "0.0.0"
authors = ["Dorin Marian Iancu, dorin.iancu@elrond.com"]
edition = "2018"
publish = false

[lib]
crate-type = ["cdylib"]

[workspace]
members = ["."]

[dev-dependencies]
[profile.release]
codegen-units = 1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = false

[profile.dev]
panic = "abort"

[dependencies.royalties-handler]
path = ".."

[dependencies.multiversx-sc-wasm-adapter]
version = "=0.41.3"
version = "=0.50.0"

[workspace]
members = ["."]
34 changes: 17 additions & 17 deletions royalties-handler/wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by the multiversx-sc multi-contract system. DO NOT EDIT.
// Code generated by the multiversx-sc build system. DO NOT EDIT.

////////////////////////////////////////////////////
////////////////// AUTO-GENERATED //////////////////
@@ -10,29 +10,29 @@
// Total number of exported functions: 16

#![no_std]
#![feature(lang_items)]

multiversx_sc_wasm_adapter::allocator!();
multiversx_sc_wasm_adapter::panic_handler!();

multiversx_sc_wasm_adapter::endpoints! {
royalties_handler
(
getLastClaimEpoch
getShareholders
claimNftMinterPaymentsAndRoyalties
getNftMinterScAddress
addShareholders
removeShareholders
claimRewards
getClaimableEntryIdsForAddress
claimableTokensForRewardEntry
createNewRewardEntry
getLastRewardEntryEpoch
getLastEntryId
getClaimWhitelistForEntry
getTokenBalances
init => init
getLastClaimEpoch => last_claim_epoch
getShareholders => shareholders
claimNftMinterPaymentsAndRoyalties => claim_nft_minter_payments_and_royalties
getNftMinterScAddress => nft_minter_sc_address
addShareholders => add_shareholders
removeShareholders => remove_shareholders
claimRewards => claim_rewards
getClaimableEntryIdsForAddress => get_claimable_entry_ids_for_address
claimableTokensForRewardEntry => get_claimable_tokens_for_reward_entry
createNewRewardEntry => create_new_reward_entry
getLastRewardEntryEpoch => last_reward_entry_epoch
getLastEntryId => last_entry_id
getClaimWhitelistForEntry => claim_whitelist_for_entry
getTokenBalances => get_token_balances
)
}

multiversx_sc_wasm_adapter::empty_callback! {}
multiversx_sc_wasm_adapter::async_callback_empty! {}