95 lines
3.0 KiB
JavaScript
95 lines
3.0 KiB
JavaScript
|
/* eslint-disable prefer-const */
|
||
|
/* global artifacts */
|
||
|
|
||
|
module.exports = async function (deployer, network, accounts) {
|
||
|
const ERC1155DiamondFactory = artifacts.require('ERC1155DiamondFactory');
|
||
|
|
||
|
const FacetCutAction = {
|
||
|
Add: 0,
|
||
|
Replace: 1,
|
||
|
Remove: 2
|
||
|
}
|
||
|
|
||
|
function getSelectors (contract) {
|
||
|
const selectors = contract.abi.reduce((acc, val) => {
|
||
|
if (val.type === 'function') {
|
||
|
acc.push(val.signature)
|
||
|
return acc
|
||
|
} else {
|
||
|
return acc
|
||
|
}
|
||
|
}, [])
|
||
|
return selectors
|
||
|
}
|
||
|
|
||
|
let networkId = await web3.eth.net.getId();
|
||
|
let tokenAddress;
|
||
|
if (networkId == 8) {
|
||
|
// ubiq, production
|
||
|
tokenAddress = '0x0826180A4c981d5095Cb5c48BB2A098A44cf6f73'; // 10grans
|
||
|
}
|
||
|
else if (networkId == 1603119863616) {
|
||
|
// local, dev
|
||
|
tokenAddress = '0x03C907D1dc3cf1bCA7efB5214029848A86654a87';
|
||
|
}
|
||
|
else if (networkId == 4) {
|
||
|
// rinkeby, test
|
||
|
tokenAddress = '0xE4147d27F1f006206eb022511BcB352e19c011f3'; // fools grans
|
||
|
}
|
||
|
else {
|
||
|
console.error("No good network specified.");
|
||
|
process.exit(1);
|
||
|
}
|
||
|
|
||
|
console.log(`token address: ${tokenAddress}`);
|
||
|
|
||
|
const mothership = await ERC1155DiamondFactory.deployed();
|
||
|
|
||
|
console.log(`mothership address: ${mothership.address}`);
|
||
|
|
||
|
const initParams = {
|
||
|
creator: accounts[0],
|
||
|
mothership: mothership.address,
|
||
|
token: tokenAddress,
|
||
|
isERC1363Token: true,
|
||
|
fee: 2,
|
||
|
royalty: 8,
|
||
|
baseURI: 'ipfs://',
|
||
|
storeName: 'Dummy Store',
|
||
|
storeSymbol: 'DUMMY',
|
||
|
proxyRegistryAddress: '0x0000000000000000000000000000000000000000',
|
||
|
storeId: 1,
|
||
|
sendRightAway: true
|
||
|
}
|
||
|
|
||
|
//console.log(JSON.stringify(initParams, null, 4));
|
||
|
|
||
|
const DiamondCutFacet = artifacts.require('DiamondCutFacet');
|
||
|
const ERC1155Facet = artifacts.require('ERC1155Facet');
|
||
|
const SellableFacet = artifacts.require('SellableFacet');
|
||
|
const ControlFacet = artifacts.require('ControlFacet');
|
||
|
const ERC165Facet = artifacts.require('ERC165Facet');
|
||
|
const DiamondLoupeFacet = artifacts.require('DiamondLoupeFacet');
|
||
|
|
||
|
const DiamondCutFacetD = await DiamondCutFacet.deployed();
|
||
|
const ERC1155FacetD = await ERC1155Facet.deployed();
|
||
|
const SellableFacetD = await SellableFacet.deployed();
|
||
|
const ControlFacetD = await ControlFacet.deployed();
|
||
|
const ERC165FacetD = await ERC165Facet.deployed();
|
||
|
const DiamondLoupeFacetD = await DiamondLoupeFacet.deployed();
|
||
|
|
||
|
const diamondCut = [
|
||
|
[DiamondCutFacetD.address, FacetCutAction.Add, getSelectors(DiamondCutFacetD)],
|
||
|
[ERC1155FacetD.address, FacetCutAction.Add, getSelectors(ERC1155FacetD)],
|
||
|
[SellableFacetD.address, FacetCutAction.Add, getSelectors(SellableFacetD)],
|
||
|
[ControlFacetD.address, FacetCutAction.Add, getSelectors(ControlFacetD)],
|
||
|
[ERC165Facet.address, FacetCutAction.Add, getSelectors(ERC165FacetD)],
|
||
|
[DiamondLoupeFacet.address, FacetCutAction.Add, getSelectors(DiamondLoupeFacetD)]
|
||
|
]
|
||
|
|
||
|
//console.log(JSON.stringify(diamondCut, null, 4));
|
||
|
|
||
|
const result = await mothership.initialize(diamondCut, initParams);
|
||
|
// console.log(result);
|
||
|
}
|