Skip to content

Commit

Permalink
Merge pull request #26 from juliancwirko/v1.3.0
Browse files Browse the repository at this point in the history
updates for v1.3.0
  • Loading branch information
juliancwirko authored Feb 6, 2022
2 parents afb9444 + 18ee077 commit 91556c7
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### [1.3.0](https://github.com/juliancwirko/elven-nft-minter-sc/releases/tag/v1.3.0) (2022-02-06)
- the `amount_of_tokens` for the `mint` endpoint is now mandatory. It cleans up the code a little bit and makes it less prone to bugs. CLI requires the amount anyway, the same with the `giveaway` endpoint. So it is now unified.

### [1.2.0](https://github.com/juliancwirko/elven-nft-minter-sc/releases/tag/v1.2.0) (2022-02-04)
- Metadata JSON file can be now attached also in the Assets/Uris section (some marketplaces require that).

- There will be no `ipfs://` schema-based Uri from the Assets/Uris. It is because there are usually gateway Uris only. It is still possible to add the ipfs schema-based Uri to the metadata JSON file.
- By default, the CLI tool will use the Smart Contract from a specific compatible version tag, not from the main branch. The version of the Smart Contract will be shown in the package.json file.

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elven-nft-minter"
version = "1.2.0"
version = "1.3.0"
authors = ["Julian Ćwirko <julian.cwirko@gmail.com>"]
edition = "2018"
publish = false
Expand Down
4 changes: 2 additions & 2 deletions meta/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elven-nft-minter-meta"
version = "1.2.0"
version = "1.3.0"
authors = ["Julian Ćwirko <julian.cwirko@gmail.com>"]
edition = "2018"
publish = false
Expand Down
7 changes: 3 additions & 4 deletions output/elven-nft-minter.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"contractCrate": {
"name": "elven-nft-minter",
"version": "1.2.0"
"version": "1.3.0"
},
"framework": {
"name": "elrond-wasm",
Expand Down Expand Up @@ -214,9 +214,8 @@
],
"inputs": [
{
"name": "token_amount",
"type": "optional<u32>",
"multi_arg": true
"name": "amount_of_tokens",
"type": "u32"
}
],
"outputs": []
Expand Down
Binary file modified output/elven-nft-minter.wasm
Binary file not shown.
66 changes: 32 additions & 34 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub trait ElvenTools {
#[var_args] file_extension: OptionalArg<ManagedBuffer>,
#[var_args] tags: OptionalArg<ManagedBuffer>,
#[var_args] provenance_hash: OptionalArg<ManagedBuffer>,
#[var_args] is_metadata_in_uris: OptionalArg<bool>
#[var_args] is_metadata_in_uris: OptionalArg<bool>,
) -> SCResult<()> {
require!(royalties <= ROYALTIES_MAX, "Royalties cannot exceed 100%!");
require!(
Expand All @@ -57,7 +57,8 @@ pub trait ElvenTools {
.into_option()
.unwrap_or_else(|| ManagedBuffer::new_from_bytes(DEFAULT_IMG_FILE_EXTENSION)),
);
self.is_metadata_in_uris().set(&is_metadata_in_uris.into_option().unwrap_or_default());
self.is_metadata_in_uris()
.set(&is_metadata_in_uris.into_option().unwrap_or_default());

let paused = true;
self.paused().set(&paused);
Expand Down Expand Up @@ -301,8 +302,21 @@ pub trait ElvenTools {
fn mint(
&self,
#[payment_amount] payment_amount: BigUint,
#[var_args] token_amount: OptionalArg<u32>,
amount_of_tokens: u32,
) -> SCResult<()> {
require!(
amount_of_tokens > 0,
"The number of tokens provided can't be less than 1!"
);
require!(!self.nft_token_id().is_empty(), "Token not issued!");

let token = self.nft_token_id().get();
let roles = self.blockchain().get_esdt_local_roles(&token);

require!(
roles.has_role(&EsdtLocalRole::NftCreate),
"ESDTNFTCreate role not set!"
);
require!(
self.initial_indexes_populate_done().get(),
"The indexes are not properly populated! Double check the deployment process and populateIndexes endpoint calls."
Expand All @@ -315,22 +329,10 @@ pub trait ElvenTools {
self.paused().is_empty(),
"The minting is paused or haven't started yet!"
);
require!(!self.nft_token_id().is_empty(), "Token not issued!");

let token = self.nft_token_id().get();

let roles = self.blockchain().get_esdt_local_roles(&token);

require!(
roles.has_role(&EsdtLocalRole::NftCreate),
"ESDTNFTCreate role not set!"
);

let mut tokens = token_amount.into_option().unwrap_or_default();

require!(
self.get_current_left_tokens_amount() >= tokens,
"All tokens have been minted already or the amount you want to mint is to much. Check limits! (totally or per drop)!"
self.get_current_left_tokens_amount() >= amount_of_tokens,
"All tokens have been minted already or the amount you want to mint is to much. Check limits (totally or per drop). You have to fit in limits with the whole amount."
);

let caller = self.blockchain().get_caller();
Expand All @@ -340,12 +342,8 @@ pub trait ElvenTools {

let tokens_left_to_mint = tokens_limit_per_address - minted_per_address;

if tokens < 1 {
tokens = 1
}

require!(
tokens_left_to_mint >= tokens,
tokens_left_to_mint >= amount_of_tokens,
"You can't mint such an amount of tokens. Check the limits by one address!"
);

Expand All @@ -361,20 +359,20 @@ pub trait ElvenTools {
tokens_limit_per_address_per_drop - minted_per_address_per_drop;

require!(
tokens_left_to_mint_per_drop >= tokens,
"You can't mint such an amount of tokens. Check the limits by one address per drop!"
);
tokens_left_to_mint_per_drop >= amount_of_tokens,
"You can't mint such an amount of tokens. Check the limits by one address! You have to fit in limits with the whole amount."
);
}

let single_payment_amount = payment_amount / tokens;
let single_payment_amount = payment_amount / amount_of_tokens;

let price_tag = self.selling_price().get();
require!(
single_payment_amount == price_tag,
"Invalid amount as payment"
);

for _ in 0..tokens {
for _ in 0..amount_of_tokens {
self.mint_single_nft(single_payment_amount.clone(), OptionalArg::None)
.unwrap();
}
Expand Down Expand Up @@ -570,13 +568,13 @@ pub trait ElvenTools {
uris.push(img_ipfs_gateway_uri);

if is_metadata_in_uris {
let mut ipfs_metadata_uri = ManagedBuffer::new_from_bytes(IPFS_GATEWAY_HOST);
ipfs_metadata_uri.append(&metadata_cid);
ipfs_metadata_uri.append(&uri_slash);
ipfs_metadata_uri.append(&file_index);
ipfs_metadata_uri.append(&metadata_file_extension);
uris.push(ipfs_metadata_uri);
let mut ipfs_metadata_uri = ManagedBuffer::new_from_bytes(IPFS_GATEWAY_HOST);
ipfs_metadata_uri.append(&metadata_cid);
ipfs_metadata_uri.append(&uri_slash);
ipfs_metadata_uri.append(&file_index);
ipfs_metadata_uri.append(&metadata_file_extension);

uris.push(ipfs_metadata_uri);
}

uris
Expand Down
4 changes: 2 additions & 2 deletions wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "elven-nft-minter-wasm"
version = "1.2.0"
version = "1.3.0"
authors = ["Julian Ćwirko <julian.cwirko@gmail.com>"]
edition = "2018"
publish = false
Expand Down

0 comments on commit 91556c7

Please sign in to comment.