40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
|
module.exports = async function(callback) {
|
||
|
const ERC1155DiamondFactory = artifacts.require('ERC1155DiamondFactory');
|
||
|
const factory = await ERC1155DiamondFactory.deployed();
|
||
|
|
||
|
console.log("Finding first store:");
|
||
|
const newStoreEvents = await factory.getPastEvents('NewStore', { fromBlock: 'earliest' })
|
||
|
const storeAddress = newStoreEvents[0].args.store;
|
||
|
|
||
|
const IERC1155DiamondAll = artifacts.require('IERC1155DiamondAll');
|
||
|
const store = await IERC1155DiamondAll.at(storeAddress);
|
||
|
|
||
|
console.log(`store address: ${storeAddress}`);
|
||
|
console.log(`store creator: ${await store.creator()}`);
|
||
|
|
||
|
const accounts = await web3.eth.getAccounts();
|
||
|
console.log(`minting to account: ${accounts[0]}`);
|
||
|
|
||
|
const nfts = [
|
||
|
{ owner: accounts[0], price: 100, tokenPrice: 0, forSale: 0, tokenForSale: 1, metadataIpfsHash: 'Qmc34V17a7xH3QUU265PHxHBFVZS4z4S4crKd9zJHU43kT', dataLocked: true },
|
||
|
{ owner: accounts[0], price: 0, tokenPrice: 100, forSale: 1, tokenForSale: 0, metadataIpfsHash: 'Qmc34V17a7xH3QUU265PHxHBFVZS4z4S4crKd9zJHU43kT', dataLocked: true }
|
||
|
]
|
||
|
|
||
|
try {
|
||
|
const ret1 = await store.mintNonFungible(false, nfts);
|
||
|
let ids = ret1.logs.find(log => log.event === 'TransferBatch');
|
||
|
if (ids) ids = ids.args.ids.map(id => id.toString());
|
||
|
else {
|
||
|
ids = ret1.logs.filter(log => log.event === 'TransferSingle');
|
||
|
if (ids.length > 0) ids = ids.map(id => id.args.id.toString());
|
||
|
else ids = 'none';
|
||
|
}
|
||
|
console.log("IDs:", ids);
|
||
|
}
|
||
|
catch (e) {
|
||
|
console.error("Failed to mint", e);
|
||
|
}
|
||
|
|
||
|
callback();
|
||
|
}
|