mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 20:47:56 +00:00
[NFTs] Add minting price to the pre-signed mint object (#14242)
* Add minting price to the pre-signed mint object * Box the param
This commit is contained in:
@@ -3146,13 +3146,14 @@ fn validate_signature() {
|
||||
let user_1_pair = sp_core::sr25519::Pair::from_string("//Alice", None).unwrap();
|
||||
let user_1_signer = MultiSigner::Sr25519(user_1_pair.public());
|
||||
let user_1 = user_1_signer.clone().into_account();
|
||||
let mint_data: PreSignedMint<u32, u32, AccountId, u32> = PreSignedMint {
|
||||
let mint_data: PreSignedMint<u32, u32, AccountId, u32, u64> = PreSignedMint {
|
||||
collection: 0,
|
||||
item: 0,
|
||||
attributes: vec![],
|
||||
metadata: vec![],
|
||||
only_account: None,
|
||||
deadline: 100000,
|
||||
mint_price: None,
|
||||
};
|
||||
let encoded_data = Encode::encode(&mint_data);
|
||||
let signature = MultiSignature::Sr25519(user_1_pair.sign(&encoded_data));
|
||||
@@ -3182,6 +3183,7 @@ fn pre_signed_mints_should_work() {
|
||||
metadata: vec![0, 1],
|
||||
only_account: None,
|
||||
deadline: 10000000,
|
||||
mint_price: Some(10),
|
||||
};
|
||||
let message = Encode::encode(&mint_data);
|
||||
let signature = MultiSignature::Sr25519(user_1_pair.sign(&message));
|
||||
@@ -3198,7 +3200,7 @@ fn pre_signed_mints_should_work() {
|
||||
|
||||
assert_ok!(Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_2.clone()),
|
||||
mint_data.clone(),
|
||||
Box::new(mint_data.clone()),
|
||||
signature.clone(),
|
||||
user_1.clone(),
|
||||
));
|
||||
@@ -3228,13 +3230,13 @@ fn pre_signed_mints_should_work() {
|
||||
assert_eq!(deposit.account, Some(user_2.clone()));
|
||||
assert_eq!(deposit.amount, 3);
|
||||
|
||||
assert_eq!(Balances::free_balance(&user_0), 100 - 2); // 2 - collection deposit
|
||||
assert_eq!(Balances::free_balance(&user_2), 100 - 1 - 3 - 6); // 1 - item deposit, 3 - metadata, 6 - attributes
|
||||
assert_eq!(Balances::free_balance(&user_0), 100 - 2 + 10); // 2 - collection deposit, 10 - mint price
|
||||
assert_eq!(Balances::free_balance(&user_2), 100 - 1 - 3 - 6 - 10); // 1 - item deposit, 3 - metadata, 6 - attributes, 10 - mint price
|
||||
|
||||
assert_noop!(
|
||||
Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_2.clone()),
|
||||
mint_data,
|
||||
Box::new(mint_data),
|
||||
signature.clone(),
|
||||
user_1.clone(),
|
||||
),
|
||||
@@ -3242,7 +3244,7 @@ fn pre_signed_mints_should_work() {
|
||||
);
|
||||
|
||||
assert_ok!(Nfts::burn(RuntimeOrigin::signed(user_2.clone()), 0, 0));
|
||||
assert_eq!(Balances::free_balance(&user_2), 100 - 6);
|
||||
assert_eq!(Balances::free_balance(&user_2), 100 - 6 - 10);
|
||||
|
||||
// validate the `only_account` field
|
||||
let mint_data = PreSignedMint {
|
||||
@@ -3252,13 +3254,14 @@ fn pre_signed_mints_should_work() {
|
||||
metadata: vec![],
|
||||
only_account: Some(account(2)),
|
||||
deadline: 10000000,
|
||||
mint_price: None,
|
||||
};
|
||||
|
||||
// can't mint with the wrong signature
|
||||
assert_noop!(
|
||||
Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_2.clone()),
|
||||
mint_data.clone(),
|
||||
Box::new(mint_data.clone()),
|
||||
signature.clone(),
|
||||
user_1.clone(),
|
||||
),
|
||||
@@ -3271,7 +3274,7 @@ fn pre_signed_mints_should_work() {
|
||||
assert_noop!(
|
||||
Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_3),
|
||||
mint_data.clone(),
|
||||
Box::new(mint_data.clone()),
|
||||
signature.clone(),
|
||||
user_1.clone(),
|
||||
),
|
||||
@@ -3283,7 +3286,7 @@ fn pre_signed_mints_should_work() {
|
||||
assert_noop!(
|
||||
Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_2.clone()),
|
||||
mint_data,
|
||||
Box::new(mint_data),
|
||||
signature,
|
||||
user_1.clone(),
|
||||
),
|
||||
@@ -3299,6 +3302,7 @@ fn pre_signed_mints_should_work() {
|
||||
metadata: vec![],
|
||||
only_account: Some(account(2)),
|
||||
deadline: 10000000,
|
||||
mint_price: None,
|
||||
};
|
||||
let message = Encode::encode(&mint_data);
|
||||
let signature = MultiSignature::Sr25519(user_1_pair.sign(&message));
|
||||
@@ -3306,7 +3310,7 @@ fn pre_signed_mints_should_work() {
|
||||
assert_noop!(
|
||||
Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_2.clone()),
|
||||
mint_data,
|
||||
Box::new(mint_data),
|
||||
signature,
|
||||
user_1.clone(),
|
||||
),
|
||||
@@ -3321,13 +3325,14 @@ fn pre_signed_mints_should_work() {
|
||||
metadata: vec![0, 1],
|
||||
only_account: None,
|
||||
deadline: 10000000,
|
||||
mint_price: None,
|
||||
};
|
||||
let message = Encode::encode(&mint_data);
|
||||
let signature = MultiSignature::Sr25519(user_1_pair.sign(&message));
|
||||
assert_noop!(
|
||||
Nfts::mint_pre_signed(
|
||||
RuntimeOrigin::signed(user_2),
|
||||
mint_data,
|
||||
Box::new(mint_data),
|
||||
signature,
|
||||
user_1.clone(),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user