Skip to content

Commit

Permalink
use dot-crypto config
Browse files Browse the repository at this point in the history
  • Loading branch information
aquiladev committed Jun 16, 2021
1 parent e3cf757 commit 90bfa5b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 95 deletions.
7 changes: 0 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
CNS_ADMIN_PRIVATE_KEY=
CNS_REGISTRY=
CNS_MINTING_CONTROLLER=
CNS_URI_CONTROLLER=
CNS_RESOLVER=
UNS_REGISTRY_PROXY=
UNS_MINTING_MANAGERE_PROXY=
UNS_PROXY_READER=
UNS_WORKER_PRIVATE_KEY=
19 changes: 19 additions & 0 deletions network-config/uns-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "0.1.0",
"networks": {
"4": {
"Registry": {
"address": ""
},
"MintingManager": {
"address": ""
},
"ProxyReader": {
"address": ""
},
"ProxyAdmin": {
"address": ""
}
}
}
}
37 changes: 22 additions & 15 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { ethers, upgrades } = require('hardhat');
const { ethers, upgrades, network } = require('hardhat');
const NetworkConfig = require('dot-crypto/src/network-config/network-config.json');

const argv = require('yargs/yargs')()
.env('')
.boolean('proxy')
Expand Down Expand Up @@ -35,16 +37,21 @@ async function main() {
const CryptoMintingController = await ethers.getContractFactory('contracts/cns/CryptoMintingController.sol:CryptoMintingController');
const CryptoURIPrefixController = await ethers.getContractFactory('contracts/cns/CryptoURIPrefixController.sol:CryptoURIPrefixController');

const { CNS_ADMIN_PRIVATE_KEY } = process.env;

const cnsConfig = NetworkConfig.networks[network.config.chainId];
if(!cnsConfig) {
throw `CNS config not found for network ${network.config.chainId}`;
}

const {
HARDHAT_NETWORK,
CNS_ADMIN_PRIVATE_KEY,
CNS_MINTING_CONTROLLER,
CNS_URI_CONTROLLER,
CNS_RESOLVER,
CNS_REGISTRY
} = process.env;
Registry: CnsRegistry,
Resolver: CnsResolver,
MintingController: CnsMintingController,
URIPrefixController: CnsURIPrefixController,
} = cnsConfig.contracts;

console.log('Network', HARDHAT_NETWORK);
console.log('Network', network.name);

let registry, mintingManager;
if (argv.proxy) {
Expand All @@ -66,28 +73,28 @@ async function main() {

const mintingManagerInitTx = await mintingManager.initialize(
registry.address,
CNS_MINTING_CONTROLLER,
CNS_URI_CONTROLLER,
CNS_RESOLVER
CnsMintingController.address,
CnsURIPrefixController.address,
CnsResolver.address
);
await mintingManagerInitTx.wait();

await mintingManager.addMinters([...rinkebyAccounts.workers, ...rinkebyAccounts.priorityWorkers]);

// CNS configuration
const cnsAdmin = new ethers.Wallet(CNS_ADMIN_PRIVATE_KEY, ethers.provider);
const cnsMintingController = await CryptoMintingController.attach(CNS_MINTING_CONTROLLER).connect(cnsAdmin);
const cnsMintingController = await CryptoMintingController.attach(CnsMintingController.address).connect(cnsAdmin);
if(!(await cnsMintingController.isMinter(mintingManager.address))) {
await cnsMintingController.addMinter(mintingManager.address);
}

const cnsURIPrefixController = await CryptoURIPrefixController.attach(CNS_URI_CONTROLLER).connect(cnsAdmin);
const cnsURIPrefixController = await CryptoURIPrefixController.attach(CnsURIPrefixController.address).connect(cnsAdmin);
if(!(await cnsURIPrefixController.isWhitelisted(mintingManager.address))) {
await cnsURIPrefixController.addWhitelisted(mintingManager.address);
}

// Deploy ProxyReader
const proxyReader = await ProxyReader.deploy(registry.address, CNS_REGISTRY);
const proxyReader = await ProxyReader.deploy(registry.address, CnsRegistry.address);
console.log('ProxyReader deployed to:', proxyReader.address);

console.log('Migrated!');
Expand Down
55 changes: 0 additions & 55 deletions scripts/predeploy.js

This file was deleted.

28 changes: 11 additions & 17 deletions scripts/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
const { ethers } = require('hardhat');
const argv = require('yargs/yargs')()
.env('')
.string('proxyAddress')
.argv;
const { ethers, network } = require('hardhat');
const NetworkConfig = require('./../network-config/uns-config.json');

async function main() {
const {
UNS_REGISTRY_PROXY,
UNS_MINTING_MANAGERE_PROXY
} = process.env;

if (!UNS_REGISTRY_PROXY) {
throw 'Registry proxy address (UNS_REGISTRY_PROXY) should be set explicitly';
const unsConfig = NetworkConfig.networks[network.config.chainId];
if(!unsConfig) {
throw `UNS config not found for network ${network.config.chainId}`;
}

if (!UNS_MINTING_MANAGERE_PROXY) {
throw 'MintingManager proxy address (UNS_MINTING_MANAGERE_PROXY) should be set explicitly';
}
const {
Registry: UnsRegistry,
MintingManager: UnsMintingManager
} = cnsConfig.contracts;

const Registry = await ethers.getContractFactory('contracts/Registry.sol:Registry');
const MintingManager = await ethers.getContractFactory('contracts/MintingManager.sol:MintingManager');

const registry = await upgrades.upgradeProxy(UNS_REGISTRY_PROXY, Registry);
const registry = await upgrades.upgradeProxy(UnsRegistry.address, Registry);
console.log('Registry PROXY upgraded:', registry.address);

mintingManager = await await upgrades.upgradeProxy(UNS_MINTING_MANAGERE_PROXY, MintingManager);
mintingManager = await await upgrades.upgradeProxy(UnsMintingManager.address, MintingManager);
console.log('MintingManager PROXY upgraded:', mintingManager.address);
}

Expand Down
3 changes: 2 additions & 1 deletion test/e2e.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { ethers } = require('hardhat');
const { utils, BigNumber } = ethers;

describe.skip('E2E', () => {
Expand Down Expand Up @@ -160,7 +161,7 @@ describe.skip('E2E', () => {
assert.equal(await cryptoRegistry.ownerOf(tokenId_crypto), coinbase.address);
})

it.only('should burn .wallet domain through oll metatx(For)', async () => {
it('should burn .wallet domain through oll metatx(For)', async () => {
const _domainName = `${domainPrefix}_test_e2e_wallet_974`;

// mint
Expand Down

0 comments on commit 90bfa5b

Please sign in to comment.