From 32130b209a773f05869ad30e500f4e67ac9d697e Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Fri, 13 Jan 2023 11:59:12 +0200 Subject: [PATCH 1/5] framework update - 0.38 --- esdt-nft-marketplace/Cargo.toml | 6 +-- esdt-nft-marketplace/meta/Cargo.toml | 4 +- .../src/common_util_functions.rs | 4 -- esdt-nft-marketplace/wasm/Cargo.toml | 4 +- esdt-nft-marketplace/wasm/src/lib.rs | 37 +++++++++++-------- seller-contract-mock/Cargo.toml | 4 +- seller-contract-mock/meta/Cargo.toml | 4 +- seller-contract-mock/src/lib.rs | 5 ++- seller-contract-mock/wasm/Cargo.toml | 4 +- seller-contract-mock/wasm/src/lib.rs | 7 ++++ 10 files changed, 45 insertions(+), 34 deletions(-) diff --git a/esdt-nft-marketplace/Cargo.toml b/esdt-nft-marketplace/Cargo.toml index 2e9f717..66b75d0 100644 --- a/esdt-nft-marketplace/Cargo.toml +++ b/esdt-nft-marketplace/Cargo.toml @@ -9,10 +9,10 @@ publish = false path = "src/marketplace_main.rs" [dependencies.elrond-wasm] -version = "0.33.0" +version = "0.38.0" [dependencies.elrond-wasm-modules] -version = "0.33.0" +version = "0.38.0" [dev-dependencies.elrond-wasm-debug] -version = "0.33.0" +version = "0.38.0" diff --git a/esdt-nft-marketplace/meta/Cargo.toml b/esdt-nft-marketplace/meta/Cargo.toml index 59b196e..5db1419 100644 --- a/esdt-nft-marketplace/meta/Cargo.toml +++ b/esdt-nft-marketplace/meta/Cargo.toml @@ -9,7 +9,7 @@ publish = false path = ".." [dependencies.elrond-wasm] -version = "0.33.0" +version = "0.38.0" [dependencies.elrond-wasm-debug] -version = "0.33.0" +version = "0.38.0" diff --git a/esdt-nft-marketplace/src/common_util_functions.rs b/esdt-nft-marketplace/src/common_util_functions.rs index 0f13093..e7b0122 100644 --- a/esdt-nft-marketplace/src/common_util_functions.rs +++ b/esdt-nft-marketplace/src/common_util_functions.rs @@ -9,8 +9,4 @@ pub trait CommonUtilFunctions: elrond_wasm_modules::pause::PauseModule { nft_nonce, ) } - - fn require_not_paused(&self) { - require!(self.not_paused(), "Marketplace is paused"); - } } diff --git a/esdt-nft-marketplace/wasm/Cargo.toml b/esdt-nft-marketplace/wasm/Cargo.toml index 87a9705..c300ac2 100644 --- a/esdt-nft-marketplace/wasm/Cargo.toml +++ b/esdt-nft-marketplace/wasm/Cargo.toml @@ -19,10 +19,10 @@ panic = "abort" path = ".." [dependencies.elrond-wasm-node] -version = "0.33.0" +version = "0.38.0" [dependencies.elrond-wasm-output] -version = "0.33.0" +version = "0.38.0" features = ["wasm-output-mode"] [workspace] diff --git a/esdt-nft-marketplace/wasm/src/lib.rs b/esdt-nft-marketplace/wasm/src/lib.rs index f84599a..b1d01e3 100644 --- a/esdt-nft-marketplace/wasm/src/lib.rs +++ b/esdt-nft-marketplace/wasm/src/lib.rs @@ -1,35 +1,42 @@ +// Code generated by the elrond-wasm multi-contract system. DO NOT EDIT. + //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// //////////////////////////////////////////////////// +// Init: 1 +// Endpoints: 23 +// Async Callback (empty): 1 +// Total number of exported functions: 25 + #![no_std] elrond_wasm_node::wasm_endpoints! { esdt_nft_marketplace ( - acceptOffer - addTokensToWhitelist + setCutPercentage auctionToken - bid - buySft - claimTokens endAuction - getClaimableAmount + withdraw getFullAuctionData - getFullOfferData getLastValidAuctionId - getLastValidOfferId getMarketplaceCutPercentage + sendOffer + withdrawOffer + acceptOffer + withdrawAuctionAndAcceptOffer + getFullOfferData + getLastValidOfferId + bid + buySft + claimTokens + getClaimableAmount + addTokensToWhitelist + removeTokensFromWhitelist getWhitelistedTokens - isPaused pause - removeTokensFromWhitelist - sendOffer - setCutPercentage unpause - withdraw - withdrawAuctionAndAcceptOffer - withdrawOffer + isPaused ) } diff --git a/seller-contract-mock/Cargo.toml b/seller-contract-mock/Cargo.toml index dc41985..1df4e0d 100644 --- a/seller-contract-mock/Cargo.toml +++ b/seller-contract-mock/Cargo.toml @@ -9,10 +9,10 @@ publish = false path = "src/lib.rs" [dependencies.elrond-wasm] -version = "0.33.0" +version = "0.38.0" [dependencies.esdt-nft-marketplace] path = "../esdt-nft-marketplace" [dev-dependencies.elrond-wasm-debug] -version = "0.33.0" +version = "0.38.0" diff --git a/seller-contract-mock/meta/Cargo.toml b/seller-contract-mock/meta/Cargo.toml index 6c44501..5f4620f 100644 --- a/seller-contract-mock/meta/Cargo.toml +++ b/seller-contract-mock/meta/Cargo.toml @@ -11,7 +11,7 @@ authors = ["Dorin Iancu "] path = ".." [dependencies.elrond-wasm] -version = "0.33.0" +version = "0.38.0" [dependencies.elrond-wasm-debug] -version = "0.33.0" +version = "0.38.0" diff --git a/seller-contract-mock/src/lib.rs b/seller-contract-mock/src/lib.rs index 31eee33..4856919 100644 --- a/seller-contract-mock/src/lib.rs +++ b/seller-contract-mock/src/lib.rs @@ -20,9 +20,10 @@ pub trait Adder { let mut token_nonce_pairs = MultiValueEncoded::new(); token_nonce_pairs.push(MultiValue2::from((token_id, token_nonce))); - self.market_proxy(marketplace_sc_address) + let _: IgnoreValue = self + .market_proxy(marketplace_sc_address) .claim_tokens(caller, token_nonce_pairs) - .execute_on_dest_context_ignore_result(); + .execute_on_dest_context(); } #[proxy] diff --git a/seller-contract-mock/wasm/Cargo.toml b/seller-contract-mock/wasm/Cargo.toml index c830adf..906f4b2 100644 --- a/seller-contract-mock/wasm/Cargo.toml +++ b/seller-contract-mock/wasm/Cargo.toml @@ -24,8 +24,8 @@ panic = "abort" path = ".." [dependencies.elrond-wasm-node] -version = "0.33.0" +version = "0.38.0" [dependencies.elrond-wasm-output] -version = "0.33.0" +version = "0.38.0" features = [ "wasm-output-mode",] diff --git a/seller-contract-mock/wasm/src/lib.rs b/seller-contract-mock/wasm/src/lib.rs index de80106..79d3dc1 100644 --- a/seller-contract-mock/wasm/src/lib.rs +++ b/seller-contract-mock/wasm/src/lib.rs @@ -1,7 +1,14 @@ +// Code generated by the elrond-wasm multi-contract system. DO NOT EDIT. + //////////////////////////////////////////////////// ////////////////// AUTO-GENERATED ////////////////// //////////////////////////////////////////////////// +// Init: 1 +// Endpoints: 1 +// Async Callback (empty): 1 +// Total number of exported functions: 3 + #![no_std] elrond_wasm_node::wasm_endpoints! { From 73a118b65e81fe78081adc1851b75a7ad44b45c0 Mon Sep 17 00:00:00 2001 From: Claudiu-Marcel Bruda Date: Fri, 13 Jan 2023 12:17:06 +0200 Subject: [PATCH 2/5] update rust toolchain version --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 39dede4..ed5eb05 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -15,7 +15,7 @@ jobs: name: Contracts uses: ElrondNetwork/elrond-actions/.github/workflows/contracts.yml@v1 with: - rust-toolchain: nightly-2022-03-01 + rust-toolchain: nightly-2022-12-08 vmtools-version: v1.4.60 extra-build-args: --ignore-eei-checks secrets: From dfd9be1bee493385b68ea9df6260215ff1a06d64 Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Fri, 13 Jan 2023 12:17:18 +0200 Subject: [PATCH 3/5] small optimization --- esdt-nft-marketplace/src/token_distribution.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/esdt-nft-marketplace/src/token_distribution.rs b/esdt-nft-marketplace/src/token_distribution.rs index 48edf2c..fbbd858 100644 --- a/esdt-nft-marketplace/src/token_distribution.rs +++ b/esdt-nft-marketplace/src/token_distribution.rs @@ -29,12 +29,11 @@ pub trait TokenDistributionModule: for pair in token_nonce_pairs { let (token_id, token_nonce) = pair.into_tuple(); - let amount_mapper = self.claimable_amount(&caller, &token_id, token_nonce); - let amount = amount_mapper.get(); + let amount = self + .claimable_amount(&caller, &token_id, token_nonce) + .take(); if amount > 0 { - amount_mapper.clear(); - if token_id.is_egld() { egld_payment_amount = amount; } else { From f6a1926a91c0ce6cb6373da413170bb344be5d97 Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Fri, 13 Jan 2023 12:24:23 +0200 Subject: [PATCH 4/5] rustup update --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 39dede4..ed5eb05 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -15,7 +15,7 @@ jobs: name: Contracts uses: ElrondNetwork/elrond-actions/.github/workflows/contracts.yml@v1 with: - rust-toolchain: nightly-2022-03-01 + rust-toolchain: nightly-2022-12-08 vmtools-version: v1.4.60 extra-build-args: --ignore-eei-checks secrets: From 8ff40a75d9c8159d3c412607836613f69fdcfd70 Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Fri, 13 Jan 2023 12:32:43 +0200 Subject: [PATCH 5/5] code de-nesting --- .../src/token_distribution.rs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/esdt-nft-marketplace/src/token_distribution.rs b/esdt-nft-marketplace/src/token_distribution.rs index fbbd858..43ac8d1 100644 --- a/esdt-nft-marketplace/src/token_distribution.rs +++ b/esdt-nft-marketplace/src/token_distribution.rs @@ -32,17 +32,17 @@ pub trait TokenDistributionModule: let amount = self .claimable_amount(&caller, &token_id, token_nonce) .take(); - - if amount > 0 { - if token_id.is_egld() { - egld_payment_amount = amount; - } else { - output_payments.push(EsdtTokenPayment::new( - token_id.unwrap_esdt(), - token_nonce, - amount, - )); - } + if amount == 0 { + continue; + } + if token_id.is_egld() { + egld_payment_amount = amount; + } else { + output_payments.push(EsdtTokenPayment::new( + token_id.unwrap_esdt(), + token_nonce, + amount, + )); } }