difftreelog
Merge remote-tracking branch 'origin/feature/NFTPAR-373_chain_extensions' into feature/NFTPAR-366_upstream_updates
in: master
8 files changed
.devcontainer/Dockerfilediffbeforeafterboth--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -3,6 +3,9 @@
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install --no-install-recommends libssl-dev pkg-config libclang-dev clang
+RUN curl -L -o- https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz | \
+ tar xz --strip-components=1 -C /usr
+
USER vscode
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash && \
@@ -14,4 +17,4 @@
rustup default nightly-2021-05-30 && \
rustup target add wasm32-unknown-unknown && \
rustup component add rustfmt clippy && \
- cargo install cargo-expand cargo-edit
+ cargo install cargo-expand cargo-edit cargo-contract
runtime/src/chain_extension.rsdiffbeforeafterboth--- a/runtime/src/chain_extension.rs
+++ b/runtime/src/chain_extension.rs
@@ -97,7 +97,7 @@
let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;
pallet_nft::Module::<C>::transfer_internal(
- &C::CrossAccountId::from_sub(env.ext().caller().clone()),
+ &C::CrossAccountId::from_sub(env.ext().address().clone()),
&C::CrossAccountId::from_sub(input.recipient),
&collection,
input.token_id,
smart_contracs/transfer/Cargo.tomldiffbeforeafterboth--- a/smart_contracs/transfer/Cargo.toml
+++ b/smart_contracs/transfer/Cargo.toml
@@ -4,15 +4,17 @@
authors = ["[Greg Zaitsev] <[your_email]>"]
edition = "2018"
+[workspace]
+
[dependencies]
-ink_primitives = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
-ink_metadata = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false, features = ["derive"], optional = true }
-ink_env = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
-ink_storage = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
-ink_lang = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
+ink_primitives = { default-features = false }
+ink_metadata = { default-features = false, features = ["derive"], optional = true }
+ink_env = { default-features = false }
+ink_storage = { default-features = false }
+ink_lang = { default-features = false }
-scale = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive"] }
-scale-info = { version = "0.4.1", default-features = false, features = ["derive"], optional = true }
+scale = { package = "parity-scale-codec", version = "2.1.1", default-features = false, features = ["derive"] }
+scale-info = { version = "0.6.0", default-features = false, features = ["derive"] }
[lib]
name = "nft_transfer"
@@ -28,6 +30,7 @@
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
+ "ink_lang/std",
"ink_primitives/std",
"scale/std",
"scale-info/std",
smart_contracs/transfer/lib.rsdiffbeforeafterboth--- a/smart_contracs/transfer/lib.rs
+++ b/smart_contracs/transfer/lib.rs
@@ -1,4 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
+extern crate alloc;
+use alloc::vec::Vec;
use ink_lang as ink;
use ink_env::{Environment, DefaultEnvironment};
@@ -36,6 +38,24 @@
}
}
+#[derive(scale::Encode, scale::Decode, scale_info::TypeInfo)]
+pub enum CreateItemData {
+ Nft {
+ const_data: Vec<u8>,
+ variable_data: Vec<u8>,
+ },
+ Fungible {
+ value: u128,
+ },
+ ReFungible {
+ const_data: Vec<u8>,
+ variable_data: Vec<u8>,
+ pieces: u128,
+ },
+}
+
+type DefaultAccountId = <DefaultEnvironment as Environment>::AccountId;
+
#[ink::chain_extension]
pub trait NftChainExtension {
type ErrorCode = NftErrorCode;
@@ -43,11 +63,26 @@
/// Transfer one NFT token from sender
///
#[ink(extension = 0, returns_result = false)]
- fn transfer(recipient: <DefaultEnvironment as Environment>::AccountId, collection_id: u32, token_id: u32, amount: u128);
+ fn transfer(recipient: DefaultAccountId, collection_id: u32, token_id: u32, amount: u128);
+ #[ink(extension = 1, returns_result = false)]
+ fn create_item(owner: DefaultAccountId, collection_id: u32, data: CreateItemData);
+ #[ink(extension = 2, returns_result = false)]
+ fn create_multiple_items(owner: DefaultAccountId, collection_id: u32, data: Vec<CreateItemData>);
+ #[ink(extension = 3, returns_result = false)]
+ fn approve(spender: DefaultAccountId, collection_id: u32, item_id: u32, amount: u128);
+ #[ink(extension = 4, returns_result = false)]
+ fn transfer_from(owner: DefaultAccountId, recipient: DefaultAccountId, collection_id: u32, item_id: u32, amount: u128);
+ #[ink(extension = 5, returns_result = false)]
+ fn set_variable_meta_data(collection_id: u32, item_id: u32, data: Vec<u8>);
+ #[ink(extension = 6, returns_result = false)]
+ fn toggle_white_list(collection_id: u32, address: DefaultAccountId, whitelisted: bool);
}
-#[ink::contract(env = crate::NftEnvironment)]
+#[ink::contract(env = crate::NftEnvironment, dynamic_storage_allocator = true)]
mod nft_transfer {
+ use alloc::vec::Vec;
+ // use ink_storage::Vec;
+ use crate::CreateItemData;
#[ink(storage)]
pub struct NftTransfer {
@@ -69,6 +104,42 @@
.extension()
.transfer(recipient, collection_id, token_id, amount);
}
+ #[ink(message)]
+ pub fn create_item(&mut self, recipient: AccountId, collection_id: u32, data: CreateItemData) {
+ let _ = self.env()
+ .extension()
+ .create_item(recipient, collection_id, data);
+ }
+ #[ink(message)]
+ pub fn create_multiple_items(&mut self, owner: AccountId, collection_id: u32, data: Vec<CreateItemData>) {
+ let _ = self.env()
+ .extension()
+ .create_multiple_items(owner, collection_id, data);
+ }
+ #[ink(message)]
+ pub fn approve(&mut self, spender: AccountId, collection_id: u32, item_id: u32, amount: u128) {
+ let _ = self.env()
+ .extension()
+ .approve(spender, collection_id, item_id, amount);
+ }
+ #[ink(message)]
+ pub fn transfer_from(&mut self, owner: AccountId, recipient: AccountId, collection_id: u32, item_id: u32, amount: u128) {
+ let _ = self.env()
+ .extension()
+ .transfer_from(owner, recipient, collection_id, item_id, amount);
+ }
+ #[ink(message)]
+ pub fn set_variable_meta_data(&mut self, collection_id: u32, item_id: u32, data: Vec<u8>) {
+ let _ = self.env()
+ .extension()
+ .set_variable_meta_data(collection_id, item_id, data);
+ }
+ #[ink(message)]
+ pub fn toggle_white_list(&mut self, collection_id: u32, address: AccountId, whitelisted: bool) {
+ let _ = self.env()
+ .extension()
+ .toggle_white_list(collection_id, address, whitelisted);
+ }
}
tests/src/contracts.test.tsdiffbeforeafterboth16} from "./util/contracthelpers";16} from "./util/contracthelpers";171718import {18import {19 addToWhiteListExpectSuccess,20 approveExpectSuccess,19 createCollectionExpectSuccess,21 createCollectionExpectSuccess,20 createItemExpectSuccess,22 createItemExpectSuccess,23 enablePublicMintingExpectSuccess,24 enableWhiteListExpectSuccess,21 getGenericResult,25 getGenericResult,22 normalizeAccountId26 normalizeAccountId,27 isWhitelisted,28 transferFromExpectSuccess23} from "./util/helpers";29} from "./util/helpers";2430253126chai.use(chaiAsPromised);32chai.use(chaiAsPromised);27const expect = chai.expect;33const expect = chai.expect;283429const value = 0;35const value = 0;30const gasLimit = 3000n * 1000000n;36const gasLimit = 9000n * 1000000n;31const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';37const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';3839describe('Contracts', () => {40 it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {41 await usingApi(async api => {42 const [contract, deployer] = await deployFlipper(api);43 const initialGetResponse = await getFlipValue(contract, deployer);4445 const bob = privateKey("//Bob");46 const flip = contract.tx.flip(value, gasLimit);47 await submitTransactionAsync(bob, flip);4849 const afterFlipGetResponse = await getFlipValue(contract, deployer);50 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');51 });52 });5354 it('Can initialize contract instance', async () => {55 await usingApi(async (api) => {56 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));57 const abi = new Abi(metadata);58 const newContractInstance = new Contract(api, abi, marketContractAddress);59 expect(newContractInstance).to.have.property('address');60 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);61 });62 });63});326433describe('Contracts', () => {65describe.only('Chain extensions', () => {34 it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {66 it('Transfer CE', async () => {35 await usingApi(async api => {67 await usingApi(async api => {68 const alice = privateKey("//Alice");69 const bob = privateKey("//Bob");7071 // Prep work72 const collectionId = await createCollectionExpectSuccess();73 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');36 const [contract, deployer] = await deployFlipper(api);74 const [contract, deployer] = await deployTransferContract(api);37 const initialGetResponse = await getFlipValue(contract, deployer);75 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);76 await submitTransactionAsync(alice, changeAdminTx);387739 const bob = privateKey("//Bob");78 const tokenBefore: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();79 80 // Transfer40 const flip = contract.tx.flip(value, gasLimit);81 const transferTx = contract.tx.transfer(value, gasLimit, bob.address, collectionId, tokenId, 1);41 await submitTransactionAsync(bob, flip);82 const events = await submitTransactionAsync(alice, transferTx);4283 const result = getGenericResult(events);43 const afterFlipGetResponse = await getFlipValue(contract, deployer);84 const tokenAfter: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();8586 // tslint:disable-next-line:no-unused-expression87 expect(result.success).to.be.true;44 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');88 expect(tokenBefore.Owner).to.be.deep.equal(normalizeAccountId(alice.address));89 expect(tokenAfter.Owner).to.be.deep.equal(normalizeAccountId(bob.address));45 });90 });46 });91 });9293 it('Mint CE', async () => {94 await usingApi(async api => {95 const alice = privateKey('//Alice');96 const bob = privateKey('//Bob');9798 const collectionId = await createCollectionExpectSuccess();99 const [contract, deployer] = await deployTransferContract(api);100 await enablePublicMintingExpectSuccess(alice, collectionId);101 await enableWhiteListExpectSuccess(alice, collectionId);102 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);103 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);104105 const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, { Nft: {const_data: '0x010203', variable_data: '0x020304' }});106 const events = await submitTransactionAsync(alice, transferTx);107 const result = getGenericResult(events);108 expect(result.success).to.be.true;109110 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any).map((kv: any) => kv[1].toJSON());111 expect(tokensAfter).to.be.deep.equal([112 {113 Owner: bob.address,114 ConstData: '0x010203',115 VariableData: '0x020304',116 },117 ]);118 });119 });120121 it('Bulk mint CE', async () => {122 await usingApi(async api => {123 const alice = privateKey('//Alice');124 const bob = privateKey('//Bob');125126 const collectionId = await createCollectionExpectSuccess();127 const [contract, deployer] = await deployTransferContract(api);128 await enablePublicMintingExpectSuccess(alice, collectionId);129 await enableWhiteListExpectSuccess(alice, collectionId);130 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);131 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);132133 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [134 { Nft: { const_data: '0x010203', variable_data: '0x020304' } },135 { Nft: { const_data: '0x010204', variable_data: '0x020305' } },136 { Nft: { const_data: '0x010205', variable_data: '0x020306' } }137 ]);138 const events = await submitTransactionAsync(alice, transferTx);139 const result = getGenericResult(events);140 expect(result.success).to.be.true;141142 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any)143 .map((kv: any) => kv[1].toJSON())144 .sort((a: any, b: any) => a.ConstData.localeCompare(b.ConstData));145 expect(tokensAfter).to.be.deep.equal([146 {147 Owner: bob.address,148 ConstData: '0x010203',149 VariableData: '0x020304',150 },151 {152 Owner: bob.address,153 ConstData: '0x010204',154 VariableData: '0x020305',155 },156 {157 Owner: bob.address,158 ConstData: '0x010205',159 VariableData: '0x020306',160 },161 ]);162 });163 });4716448 it('Can initialize contract instance', async () => {165 it('Approve CE', async () => {49 await usingApi(async (api) => {166 await usingApi(async api => {167 const alice = privateKey('//Alice');168 const bob = privateKey('//Bob');169 const charlie = privateKey('//Charlie');170171 const collectionId = await createCollectionExpectSuccess();172 const [contract, deployer] = await deployTransferContract(api);50 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));173 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());17451 const abi = new Abi(metadata);175 const transferTx = contract.tx.approve(value, gasLimit, bob.address, collectionId, tokenId, 1);52 const newContractInstance = new Contract(api, abi, marketContractAddress);176 const events = await submitTransactionAsync(alice, transferTx);177 const result = getGenericResult(events);53 expect(newContractInstance).to.have.property('address');178 expect(result.success).to.be.true;17954 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);180 await transferFromExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), charlie, 1, 'NFT');55 });181 });56 });182 });5718358 it('Can transfer NFT using smart contract.', async () => {184 it('TransferFrom CE', async () => {59 await usingApi(async api => {185 await usingApi(async api => {60 const alice = privateKey("//Alice");186 const alice = privateKey('//Alice');61 const bob = privateKey("//Bob");187 const bob = privateKey('//Bob');6263 // Prep work64 const collectionId = await createCollectionExpectSuccess();188 const charlie = privateKey('//Charlie');18965 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');190 const collectionId = await createCollectionExpectSuccess();66 const [contract, deployer] = await deployTransferContract(api);191 const [contract, deployer] = await deployTransferContract(api);67 const tokenBefore: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();192 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);68 193 await approveExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), 1);69 // Transfer19470 const transferTx = contract.tx.transfer(value, gasLimit, bob.address, collectionId, tokenId, 1);195 const transferTx = contract.tx.transferFrom(value, gasLimit, bob.address, charlie.address, collectionId, tokenId, 1);71 const events = await submitTransactionAsync(alice, transferTx);196 const events = await submitTransactionAsync(alice, transferTx);72 const result = getGenericResult(events);197 const result = getGenericResult(events);198 expect(result.success).to.be.true;19973 const tokenAfter: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();200 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap()7475 // tslint:disable-next-line:no-unused-expression76 expect(result.success).to.be.true;77 expect(tokenBefore.Owner).to.be.deep.equal(normalizeAccountId(alice.address));201 expect(token.Owner.toString()).to.be.equal(charlie.address);78 expect(tokenAfter.Owner).to.be.deep.equal(normalizeAccountId(bob.address));79 });202 });80 });203 });204205 it('SetVariableMetaData CE', async () => {206 await usingApi(async api => {207 const alice = privateKey('//Alice');208209 const collectionId = await createCollectionExpectSuccess();210 const [contract, deployer] = await deployTransferContract(api);211 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());212213 const transferTx = contract.tx.setVariableMetaData(value, gasLimit, collectionId, tokenId, '0x121314');214 const events = await submitTransactionAsync(alice, transferTx);215 const result = getGenericResult(events);216 expect(result.success).to.be.true;217218 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap()219 expect(token.VariableData.toString()).to.be.equal('0x121314');220 });221 });222223 it('ToggleWhiteList CE', async () => {224 await usingApi(async api => {225 const alice = privateKey('//Alice');226 const bob = privateKey('//Bob');227228 const collectionId = await createCollectionExpectSuccess();229 const [contract, deployer] = await deployTransferContract(api);230 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);231 await submitTransactionAsync(alice, changeAdminTx); 232233 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;234235 {236 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, true);237 const events = await submitTransactionAsync(alice, transferTx);238 const result = getGenericResult(events);239 expect(result.success).to.be.true;240241 expect(await isWhitelisted(collectionId, bob.address)).to.be.true;242 }243 {244 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, false);245 const events = await submitTransactionAsync(alice, transferTx);246 const result = getGenericResult(events);247 expect(result.success).to.be.true;248249 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;250 }251 });252 });81});253});82254tests/src/transfer_contract/metadata.jsondiffbeforeafterboth--- a/tests/src/transfer_contract/metadata.json
+++ b/tests/src/transfer_contract/metadata.json
@@ -1,9 +1,9 @@
{
"metadataVersion": "0.1.0",
"source": {
- "hash": "0xfbbc0729acefed9d99f93f6cbb751d12e317958fd0fe183f5781329b37f1bf6e",
- "language": "ink! 3.0.0-rc2",
- "compiler": "rustc 1.51.0-nightly"
+ "hash": "0xc6c3f47adeafe86d1674ed72c7179605787842f2f05a2d7da0dbabf3c4fa1aa8",
+ "language": "ink! 3.0.0-rc3",
+ "compiler": "rustc 1.52.0-nightly"
},
"contract": {
"name": "nft_transfer",
@@ -24,7 +24,7 @@
"name": [
"default"
],
- "selector": "0x6a3712e2"
+ "selector": "0xed4b9d1b"
}
],
"docs": [],
@@ -78,7 +78,268 @@
],
"payable": false,
"returnType": null,
- "selector": "0xfae3a09d"
+ "selector": "0x84a15da1"
+ },
+ {
+ "args": [
+ {
+ "name": "recipient",
+ "type": {
+ "displayName": [
+ "AccountId"
+ ],
+ "type": 1
+ }
+ },
+ {
+ "name": "collection_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "data",
+ "type": {
+ "displayName": [
+ "CreateItemData"
+ ],
+ "type": 6
+ }
+ }
+ ],
+ "docs": [],
+ "mutates": true,
+ "name": [
+ "create_item"
+ ],
+ "payable": false,
+ "returnType": null,
+ "selector": "0xd7c3f083"
+ },
+ {
+ "args": [
+ {
+ "name": "owner",
+ "type": {
+ "displayName": [
+ "AccountId"
+ ],
+ "type": 1
+ }
+ },
+ {
+ "name": "collection_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "data",
+ "type": {
+ "displayName": [
+ "Vec"
+ ],
+ "type": 8
+ }
+ }
+ ],
+ "docs": [],
+ "mutates": true,
+ "name": [
+ "create_multiple_items"
+ ],
+ "payable": false,
+ "returnType": null,
+ "selector": "0x15f9a1eb"
+ },
+ {
+ "args": [
+ {
+ "name": "spender",
+ "type": {
+ "displayName": [
+ "AccountId"
+ ],
+ "type": 1
+ }
+ },
+ {
+ "name": "collection_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "item_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "amount",
+ "type": {
+ "displayName": [
+ "u128"
+ ],
+ "type": 5
+ }
+ }
+ ],
+ "docs": [],
+ "mutates": true,
+ "name": [
+ "approve"
+ ],
+ "payable": false,
+ "returnType": null,
+ "selector": "0x681266a0"
+ },
+ {
+ "args": [
+ {
+ "name": "owner",
+ "type": {
+ "displayName": [
+ "AccountId"
+ ],
+ "type": 1
+ }
+ },
+ {
+ "name": "recipient",
+ "type": {
+ "displayName": [
+ "AccountId"
+ ],
+ "type": 1
+ }
+ },
+ {
+ "name": "collection_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "item_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "amount",
+ "type": {
+ "displayName": [
+ "u128"
+ ],
+ "type": 5
+ }
+ }
+ ],
+ "docs": [],
+ "mutates": true,
+ "name": [
+ "transfer_from"
+ ],
+ "payable": false,
+ "returnType": null,
+ "selector": "0x0b396f18"
+ },
+ {
+ "args": [
+ {
+ "name": "collection_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "item_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "data",
+ "type": {
+ "displayName": [
+ "Vec"
+ ],
+ "type": 7
+ }
+ }
+ ],
+ "docs": [],
+ "mutates": true,
+ "name": [
+ "set_variable_meta_data"
+ ],
+ "payable": false,
+ "returnType": null,
+ "selector": "0xb0b26da2"
+ },
+ {
+ "args": [
+ {
+ "name": "collection_id",
+ "type": {
+ "displayName": [
+ "u32"
+ ],
+ "type": 4
+ }
+ },
+ {
+ "name": "address",
+ "type": {
+ "displayName": [
+ "AccountId"
+ ],
+ "type": 1
+ }
+ },
+ {
+ "name": "whitelisted",
+ "type": {
+ "displayName": [
+ "bool"
+ ],
+ "type": 9
+ }
+ }
+ ],
+ "docs": [],
+ "mutates": true,
+ "name": [
+ "toggle_white_list"
+ ],
+ "payable": false,
+ "returnType": null,
+ "selector": "0x98574dac"
}
]
},
@@ -93,7 +354,8 @@
"composite": {
"fields": [
{
- "type": 2
+ "type": 2,
+ "typeName": "[u8; 32]"
}
]
}
@@ -126,6 +388,82 @@
"def": {
"primitive": "u128"
}
+ },
+ {
+ "def": {
+ "variant": {
+ "variants": [
+ {
+ "fields": [
+ {
+ "name": "const_data",
+ "type": 7,
+ "typeName": "Vec<u8>"
+ },
+ {
+ "name": "variable_data",
+ "type": 7,
+ "typeName": "Vec<u8>"
+ }
+ ],
+ "name": "Nft"
+ },
+ {
+ "fields": [
+ {
+ "name": "value",
+ "type": 5,
+ "typeName": "u128"
+ }
+ ],
+ "name": "Fungible"
+ },
+ {
+ "fields": [
+ {
+ "name": "const_data",
+ "type": 7,
+ "typeName": "Vec<u8>"
+ },
+ {
+ "name": "variable_data",
+ "type": 7,
+ "typeName": "Vec<u8>"
+ },
+ {
+ "name": "pieces",
+ "type": 5,
+ "typeName": "u128"
+ }
+ ],
+ "name": "ReFungible"
+ }
+ ]
+ }
+ },
+ "path": [
+ "nft_transfer",
+ "CreateItemData"
+ ]
+ },
+ {
+ "def": {
+ "sequence": {
+ "type": 3
+ }
+ }
+ },
+ {
+ "def": {
+ "sequence": {
+ "type": 6
+ }
+ }
+ },
+ {
+ "def": {
+ "primitive": "bool"
+ }
}
]
}
\ No newline at end of file
tests/src/transfer_contract/nft_transfer.wasmdiffbeforeafterbothbinary blob — no preview
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -677,7 +677,7 @@
transferFromExpectSuccess(collectionId: number,
tokenId: number,
accountApproved: IKeyringPair,
- accountFrom: IKeyringPair,
+ accountFrom: IKeyringPair | CrossAccountId,
accountTo: IKeyringPair | CrossAccountId,
value: number | bigint = 1,
type: string = 'NFT') {
@@ -688,7 +688,7 @@
balanceBefore = await api.query.nft.balance(collectionId, toSubstrateAddress(to)) as unknown as BN;
}
const transferFromTx = api.tx.nft.transferFrom(
- normalizeAccountId(accountFrom.address), to, collectionId, tokenId, value);
+ normalizeAccountId(accountFrom), to, collectionId, tokenId, value);
const events = await submitTransactionAsync(accountApproved, transferFromTx);
const result = getCreateItemResult(events);
// tslint:disable-next-line:no-unused-expression
@@ -950,7 +950,7 @@
return whitelisted;
}
-export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {
+export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {
await usingApi(async (api) => {
const whiteListedBefore = (await api.query.nft.whiteList(collectionId, address)).toJSON();