Skip to content

Commit

Permalink
Merge pull request #83 from Itheum/d-damian
Browse files Browse the repository at this point in the history
Feature: Allow Optional Extra assets on minted tokens
  • Loading branch information
newbreedofgeek authored Apr 8, 2024
2 parents ac2c954 + 480c222 commit 7503c8c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub trait EventsModule {
#[indexed] token: &EgldOrEsdtTokenIdentifier,
#[indexed] price: &BigUint,
#[indexed] bond_amount: &BigUint,
#[indexed] extra_assets: &ManagedVec<ManagedBuffer>
);

#[event("setWithdrawalAddress")]
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub trait DataNftMint:
title: ManagedBuffer,
description: ManagedBuffer,
lock_period_sec: u64,
extra_assets: MultiValueEncoded<ManagedBuffer>,
) -> DataNftAttributes<Self::Api> {
self.require_ready_for_minting_and_burning();
require!(!data_stream.is_empty(), ERR_DATA_STREAM_IS_EMPTY);
Expand Down Expand Up @@ -205,13 +206,14 @@ pub trait DataNftMint:
};

let token_identifier = self.token_id().get_token_id();

let extra_assets_vec = extra_assets.into_vec_of_buffers();
self.mint_event(
&caller,
&one_token,
&payment.token_identifier,
&price,
&payment.amount,
&extra_assets_vec
);

let nonce = self.send().esdt_nft_create(
Expand All @@ -221,7 +223,7 @@ pub trait DataNftMint:
&royalties,
&self.create_hash_buffer(&data_marshal, &data_stream),
&attributes,
&self.create_uris(media, metadata),
&self.create_uris(media, metadata, extra_assets_vec),
);

self.send_bond(
Expand Down
2 changes: 2 additions & 0 deletions src/nft_mint_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ pub trait NftMintUtils: crate::storage::StorageModule {
&self,
media: ManagedBuffer,
metadata: ManagedBuffer,
extra_assets: ManagedVec<ManagedBuffer>,
) -> ManagedVec<ManagedBuffer> {
let mut uris = ManagedVec::new();
uris.push(media);
uris.push(metadata);
uris.append_vec(extra_assets);
uris
}
}
1 change: 1 addition & 0 deletions tests/minter_state/minter_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ impl ContractsState {
title,
description,
lock_period,
MultiValueEncoded::new()
))
.expect(expect.unwrap_or(TxExpect::ok())),
);
Expand Down

0 comments on commit 7503c8c

Please sign in to comment.