Skip to content

Commit

Permalink
🐳 chore: deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry committed May 15, 2022
1 parent 24cacbd commit 2e516dd
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 93 deletions.
10 changes: 10 additions & 0 deletions contracts/tests/P12AssetFactoryUpgradableAlter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.13;

import '../sft-factory/P12AssetFactoryUpgradable.sol';

contract P12AssetFactoryUpgradableAlter is P12AssetFactoryUpgradable {
function setP12factory(address newAddr) public onlyOwner {
p12factory = newAddr;
}
}
16 changes: 0 additions & 16 deletions contracts/tests/P12AssetFactoryUpgradableAlternate.sol

This file was deleted.

11 changes: 11 additions & 0 deletions contracts/tests/P12MineUpgradeableAlter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.13;

import '../staking/P12MineUpgradeable.sol';

contract P12MineUpgradeableAlter is P12MineUpgradeable {
function setP12factory(address newAddr) public onlyOwner {
p12Factory = newAddr;
}
}
10 changes: 4 additions & 6 deletions contracts/tests/P12V0FactoryUpgradeable2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import '../factory/P12V0FactoryUpgradeable.sol';

// new contract for test
contract P12V0FactoryUpgradeable2 is P12V0FactoryUpgradeable {
string public name;

function setName(string memory _name) public {
name = _name;
function setUniswapFactory(address newAddr) public onlyOwner {
uniswapFactory = newAddr;
}

function getName() public view returns (string memory) {
return name;
function setUniswapRouter(address newAddr) public onlyOwner {
uniswapRouter = newAddr;
}
}
11 changes: 3 additions & 8 deletions contracts/tests/SecretShopUpgradableAlternate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
pragma solidity 0.8.13;

import '../secretShop/SecretShopUpgradable.sol';
import '../secretShop/interfaces/IWETHUpgradable.sol';

contract SecretShopUpgradableAlternative is SecretShopUpgradable {
string public name;

function setName(string memory _name) public {
name = _name;
}

function getName() public view returns (string memory) {
return name;
function setWETH(IWETHUpgradable newAddr) public onlyOwner {
weth = newAddr;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ const config: HardhatUserConfig = {
chainId: 44010,
accounts: accounts,
gas: 'auto',
gasPrice: 'auto',
gasPrice: 3000000000,
},
rinkeby: {
url: process.env.RINKEBY_URL || '',
chainId: 4,
accounts: accounts,
gas: 'auto',
gasPrice: 3000000000, // 3 Gwei
},
},
gasReporter: {
Expand Down
9 changes: 9 additions & 0 deletions remix-compiler.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
solidity: '0.8.13',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
};
20 changes: 16 additions & 4 deletions scripts/factory/deployP12FactoryUpgradeable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ import env, { ethers, upgrades } from 'hardhat';
async function main() {
if (env.network.name === 'p12TestNet') {
const P12V0FactoryUpgradeable = await ethers.getContractFactory('P12V0FactoryUpgradeable');
const p12Address = '0xeAc1F044C4b9B7069eF9F3eC05AC60Df76Fe6Cd0';
const uniswapV2Factory = '0x913d71546cC9FBB06b6F9d2ADEb0C58EFEF7a690';
const uniswapV2Router = '0x7320C150D5fd661Fb1fB7af19a6337F3d099b41f';
const p12Token = '0xeAc1F044C4b9B7069eF9F3eC05AC60Df76Fe6Cd0';
const uniswapV2Factory = '0x8C2543578eFEd64343C63e9075ed70F1d255D1c6';
const uniswapV2Router = '0x71A3B75A9A774EB793A44a36AF760ee2868912ac';
const p12V0FactoryUpgradeable = await upgrades.deployProxy(
P12V0FactoryUpgradeable,
[p12Address, uniswapV2Factory, uniswapV2Router, 86400, ethers.utils.randomBytes(32)],
[p12Token, uniswapV2Factory, uniswapV2Router, 86400, ethers.utils.randomBytes(32)],
{ kind: 'uups' },
);
console.log('proxy contract', p12V0FactoryUpgradeable.address);
} else if (env.network.name === 'rinkeby') {
const P12V0FactoryUpgradeable = await ethers.getContractFactory('P12V0FactoryUpgradeable');
const p12Token = '0x2844B158Bcffc0aD7d881a982D464c0ce38d8086';
const uniswapV2Factory = '0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f';
const uniswapV2Router = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D';
const p12V0FactoryUpgradeable = await upgrades.deployProxy(
P12V0FactoryUpgradeable,
[p12Token, uniswapV2Factory, uniswapV2Router, 86400, ethers.utils.randomBytes(32)],
{ kind: 'uups' },
);

console.log('proxy contract', p12V0FactoryUpgradeable.address);
}
}
Expand Down
29 changes: 29 additions & 0 deletions scripts/factory/deployUniswap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import env, { ethers } from 'hardhat';
import * as compiledUniswapFactory from '@uniswap/v2-core/build/UniswapV2Factory.json';
import * as compiledUniswapRouter from '@uniswap/v2-periphery/build/UniswapV2Router02.json';

async function main() {
if (env.network.name === 'p12TestNet') {
const admin = (await ethers.getSigners())[0];
const weth = '0x0EE3F0848cA07E6342390C34FcC7Ea9D0217a47d';
// deploy uniswap
const UNISWAPV2ROUTER = new ethers.ContractFactory(compiledUniswapRouter.abi, compiledUniswapRouter.bytecode, admin);
const UNISWAPV2FACTORY = new ethers.ContractFactory(
compiledUniswapFactory.interface,
compiledUniswapFactory.bytecode,
admin,
);
const uniswapV2Factory = await UNISWAPV2FACTORY.connect(admin).deploy(admin.address);

const uniswapV2Router02 = await UNISWAPV2ROUTER.connect(admin).deploy(uniswapV2Factory.address, weth);

console.log('uniswapV2Factory: ', uniswapV2Factory.address, 'uniswapV2Router: ', uniswapV2Router02.address);
} else if (env.network.name === 'rinkeby') {
console.log('nothing happened');
}
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
23 changes: 23 additions & 0 deletions scripts/factory/upgradeP12FactoryUpgradeable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import env, { ethers, upgrades } from 'hardhat';

async function main() {
if (env.network.name === 'p12TestNet') {
const P12V0FactoryUpgradeableF = await ethers.getContractFactory('P12V0FactoryUpgradeable2');

const proxyAddr = '0x3288095c0033E33DcD25bf2cf439B848b45DFB70';

// const p12Token = '0xeAc1F044C4b9B7069eF9F3eC05AC60Df76Fe6Cd0';
// const uniswapV2Factory = '0x8C2543578eFEd64343C63e9075ed70F1d255D1c6';
// const uniswapV2Router = '0x71A3B75A9A774EB793A44a36AF760ee2868912ac';
await upgrades.upgradeProxy(proxyAddr, P12V0FactoryUpgradeableF);

console.log('proxy contract', proxyAddr);
} else if (env.network.name === 'rinkeby') {
console.log('nothing happen');
}
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
1 change: 1 addition & 0 deletions scripts/secretShop/deployToP12TestNet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async function main() {
await ethers.getContractAt('SecretShopUpgradable', secretShop.address)
).updateDelegates([erc1155delegate.address], []);
// Add WhiteList
await (await ethers.getContractAt('SecretShopUpgradable', secretShop.address)).updateCurrencies([p12coin.address], []);
}
}

Expand Down
56 changes: 27 additions & 29 deletions scripts/secretShop/deployToRinkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,35 @@
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
import { ethers, upgrades } from 'hardhat';
import env, { ethers, upgrades } from 'hardhat';

async function main() {
const developer = (await ethers.getSigners())[0];

// console.log(developer.address);

const p12coin = await ethers.getContractAt('P12Coin', '0x2844B158Bcffc0aD7d881a982D464c0ce38d8086');
console.log('P12 Coin: ', p12coin.address);

const weth = await ethers.getContractAt('WETH9', '0xDf032Bc4B9dC2782Bb09352007D4C57B75160B15');

const SecretShopUpgradableF = await ethers.getContractFactory('SecretShopUpgradable');

const p12exchange = await upgrades.deployProxy(SecretShopUpgradableF, [0, weth.address], {
kind: 'uups',
});
const ERC1155DelegateF = await ethers.getContractFactory('ERC1155Delegate');

// deploy delegate
const erc1155delegate = await ERC1155DelegateF.deploy();
// Give Role to exchange contract
await erc1155delegate.grantRole(await erc1155delegate.DELEGATION_CALLER(), p12exchange.address);

// Give Role to developer
await erc1155delegate.grantRole(await erc1155delegate.DELEGATION_CALLER(), developer.address);

// Add delegate
await (
await ethers.getContractAt('SecretShopUpgradable', p12exchange.address)
).updateDelegates([erc1155delegate.address], []);
if (env.network.name === 'rinkeby') {
const developer = (await ethers.getSigners())[0];

const p12coin = await ethers.getContractAt('P12Token', '0x2844B158Bcffc0aD7d881a982D464c0ce38d8086');
const wethAddr = '0xc778417e063141139fce010982780140aa0cd5ab';

const SecretShopUpgradableF = await ethers.getContractFactory('SecretShopUpgradable');

const secretShop = await upgrades.deployProxy(SecretShopUpgradableF, [10n ** 5n, wethAddr], {
kind: 'uups',
});

console.log('SecretShop Proxy', secretShop.address);
const ERC1155DelegateF = await ethers.getContractFactory('ERC1155Delegate');
const erc1155delegate = await ERC1155DelegateF.deploy();
// Give delegate role to exchange contract
await erc1155delegate.grantRole(await erc1155delegate.DELEGATION_CALLER(), secretShop.address);
// Give pausable Role to developer
await erc1155delegate.grantRole(await erc1155delegate.PAUSABLE_CALLER(), developer.address);
// Add delegate
await (
await ethers.getContractAt('SecretShopUpgradable', secretShop.address)
).updateDelegates([erc1155delegate.address], []);
// Add WhiteList
await (await ethers.getContractAt('SecretShopUpgradable', secretShop.address)).updateCurrencies([p12coin.address], []);
}
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
22 changes: 12 additions & 10 deletions scripts/sft-factory/deployToRinkeby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
import { ethers, upgrades } from 'hardhat';
import env, { ethers, upgrades } from 'hardhat';

async function main() {
const developer = (await ethers.getSigners())[0];
console.log('developer: ', developer);
if (env.network.name === 'rinkeby') {
const developer = (await ethers.getSigners())[0];
console.log('developer: ', developer.address);

const p12factoryAddr = '0x395FAbef71433280f85f79ad43f99E3cC040af5C';
const p12factoryAddr = '0xA2C44E2d4DEC9B9e9C1AA2e508eD645EE3AE8dF7';

const P12AssetFactoryUpgradableF = await ethers.getContractFactory('P12AssetFactoryUpgradable');
const p12AssetFactoryAddr = await upgrades.deployProxy(P12AssetFactoryUpgradableF, [p12factoryAddr], {
kind: 'uups',
});
const p12AssetFactory = await ethers.getContractAt('P12AssetFactoryUpgradable', p12AssetFactoryAddr.address);
console.log('P12AssetFactory Address', p12AssetFactory.address);
const P12AssetFactoryUpgradableF = await ethers.getContractFactory('P12AssetFactoryUpgradable');
const p12AssetFactoryAddr = await upgrades.deployProxy(P12AssetFactoryUpgradableF, [p12factoryAddr], {
kind: 'uups',
});
const p12AssetFactory = await ethers.getContractAt('P12AssetFactoryUpgradable', p12AssetFactoryAddr.address);
console.log('p12AssetFactory proxy: ', p12AssetFactory.address);
}
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
28 changes: 28 additions & 0 deletions scripts/sft-factory/upgradeToP12TestNet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
import env, { ethers, upgrades } from 'hardhat';

async function main() {
if (env.network.name === 'p12TestNet') {
const P12AssetFactoryUpgradableF = await ethers.getContractFactory('P12AssetFactoryUpgradable');

const proxyAddr = '0x173e4D790A43E3016AAeD9Bbd0987CD760f0dB9F';

// const p12Token = '0xeAc1F044C4b9B7069eF9F3eC05AC60Df76Fe6Cd0';
// const uniswapV2Factory = '0x8C2543578eFEd64343C63e9075ed70F1d255D1c6';
// const uniswapV2Router = '0x71A3B75A9A774EB793A44a36AF760ee2868912ac';
await upgrades.upgradeProxy(proxyAddr, P12AssetFactoryUpgradableF);

console.log('proxy contract', proxyAddr);
}
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
45 changes: 33 additions & 12 deletions scripts/staking/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import { ethers, upgrades } from 'hardhat';
import env, { ethers, upgrades } from 'hardhat';

async function main() {
const p12factory = '0x588EC7f5f7AEe6c117bf924c6D1E9851582bA64c';
const reward = '0x2844B158Bcffc0aD7d881a982D464c0ce38d8086';
const timeStart = 10365707;
const delayK = 60;
const delayB = 60;
const P12MineUpgradeable = await ethers.getContractFactory('P12MineUpgradeable');
const p12MineUpgradeable = await upgrades.deployProxy(P12MineUpgradeable, [reward, p12factory, timeStart, delayK, delayB], {
kind: 'uups',
});
if (env.network.name === 'p12TestNet') {
const p12factory = '0x3288095c0033E33DcD25bf2cf439B848b45DFB70';
const reward = '0xeAc1F044C4b9B7069eF9F3eC05AC60Df76Fe6Cd0';
const blockStart = 638846;
const delayK = 60;
const delayB = 60;
const P12MineUpgradeable = await ethers.getContractFactory('P12MineUpgradeable');
const p12MineUpgradeable = await upgrades.deployProxy(
P12MineUpgradeable,
[reward, p12factory, blockStart, delayK, delayB],
{
kind: 'uups',
},
);
console.log('p12 Mine proxy contract', p12MineUpgradeable.address);
// 0xc0b26Ee84984dD839AeCa6Ecc3037E966F7D32Ca
} else if (env.network.name === 'rinkeby') {
const p12factory = '0xA2C44E2d4DEC9B9e9C1AA2e508eD645EE3AE8dF7';
const reward = '0x2844B158Bcffc0aD7d881a982D464c0ce38d8086';
const blockStart = 10680803;
const delayK = 1;
const delayB = 1;
const P12MineUpgradeable = await ethers.getContractFactory('P12MineUpgradeable');
const p12MineUpgradeable = await upgrades.deployProxy(
P12MineUpgradeable,
[reward, p12factory, blockStart, delayK, delayB],
{
kind: 'uups',
},
);

console.log('proxy contract', p12MineUpgradeable.address);
// 0xc0b26Ee84984dD839AeCa6Ecc3037E966F7D32Ca
console.log('p12 Mine proxy contract', p12MineUpgradeable.address);
}
}

main().catch((error) => {
Expand Down
Loading

0 comments on commit 2e516dd

Please sign in to comment.