-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: New release with stamp rc6 (#202)
- Loading branch information
1 parent
671087a
commit 9f309b9
Showing
7 changed files
with
589 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'hardhat-deploy-ethers'; | ||
import '@nomiclabs/hardhat-etherscan'; | ||
import { ethers, network } from 'hardhat'; | ||
import hre from 'hardhat'; | ||
|
||
async function main() { | ||
// Order of contracts and how should they be deployed, testnet addresses | ||
const currentPostage = '0xF5147D56502C80004f91FB4112d6812CddE8eDE3'; | ||
const currentOracle = '0xd41A47fCaa67945A11a398F00D5f7F130aF03733'; | ||
const currentStaking = '0xCb07bf0603da228C8ec602bf12b973b8A94f9bac'; // old staking | ||
const currentRedis = '0x264079eeF0CE42D790e3FA7DF8D0cfA675ef6504'; | ||
|
||
// Change roles on current stamp contract | ||
const stamp = await ethers.getContractAt('PostageStamp', currentPostage); | ||
const redistributorRole = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('REDISTRIBUTOR_ROLE')); | ||
const tx = await stamp.grantRole(redistributorRole, currentRedis); | ||
console.log('Changed REDISTRIBUTOR ROLE at : ', tx.hash); | ||
|
||
const oracleRole = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('PRICE_ORACLE_ROLE')); | ||
const tx2 = await stamp.grantRole(oracleRole, currentOracle); | ||
console.log('Changed ORACLE ROLE at : ', tx2.hash); | ||
|
||
// Change roles on current oracle contract | ||
const oracle = await ethers.getContractAt('PriceOracle', currentOracle); | ||
const updaterRole = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('PRICE_UPDATER_ROLE')); | ||
const tx3 = await oracle.grantRole(updaterRole, currentRedis); | ||
console.log('Changed UPDATER ROLE at : ', tx3.hash); | ||
|
||
// Change roles on current staking contract | ||
const stake = await ethers.getContractAt('StakeRegistry', currentStaking); | ||
const tx4 = await stake.grantRole(redistributorRole, currentRedis); | ||
console.log('Changed REDISTRIBUTOR ROLE at : ', tx4.hash); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import 'hardhat-deploy-ethers'; | ||
import '@nomiclabs/hardhat-etherscan'; | ||
import { ethers, network } from 'hardhat'; | ||
import verify from '../utils/verify'; | ||
import hre from 'hardhat'; | ||
import * as fs from 'fs'; | ||
|
||
interface DeployedContract { | ||
abi: Array<unknown>; | ||
bytecode: string; | ||
address: string; | ||
block: number; | ||
url: string; | ||
} | ||
|
||
interface DeployedData { | ||
chainId: number; | ||
swarmNetworkId: number; | ||
contracts: { | ||
bzzToken: DeployedContract; | ||
staking: DeployedContract; | ||
postageStamp: DeployedContract; | ||
priceOracle: DeployedContract; | ||
redistribution: DeployedContract; | ||
}; | ||
} | ||
|
||
interface ChainConfig { | ||
chainId?: number; | ||
swarmNetworkId?: number; | ||
networkName: string; | ||
deployedData: DeployedData; | ||
url: string; | ||
} | ||
|
||
let networkDeployedData: DeployedData; | ||
try { | ||
networkDeployedData = require('../' + network.name + '_deployed.json'); | ||
} catch (e) { | ||
networkDeployedData = { | ||
chainId: 0, | ||
swarmNetworkId: 0, | ||
contracts: { | ||
bzzToken: {} as DeployedContract, | ||
staking: {} as DeployedContract, | ||
postageStamp: {} as DeployedContract, | ||
priceOracle: {} as DeployedContract, | ||
redistribution: {} as DeployedContract, | ||
}, | ||
} as DeployedData; | ||
} | ||
|
||
const configs: Record<string, ChainConfig> = { | ||
testnet: { | ||
chainId: network.config.chainId, | ||
swarmNetworkId: networkDeployedData.swarmNetworkId ? networkDeployedData.swarmNetworkId : 10, | ||
networkName: network.name, | ||
deployedData: networkDeployedData, | ||
url: hre.config.etherscan.customChains[1]['urls']['browserURL'].toString(), | ||
}, | ||
mainnet: { | ||
chainId: network.config.chainId, | ||
swarmNetworkId: networkDeployedData.swarmNetworkId ? networkDeployedData.swarmNetworkId : 1, | ||
networkName: network.name, | ||
deployedData: networkDeployedData, | ||
url: hre.config.etherscan.customChains[2]['urls']['browserURL'].toString(), | ||
}, | ||
}; | ||
|
||
const config: ChainConfig = configs[network.name] | ||
? configs[network.name] | ||
: ({ | ||
chainId: network.config.chainId, | ||
swarmNetworkId: networkDeployedData.swarmNetworkId ? networkDeployedData.swarmNetworkId : network.config.chainId, | ||
networkName: network.name, | ||
deployedData: networkDeployedData, | ||
url: '', | ||
} as ChainConfig); | ||
|
||
async function main() { | ||
// This is deployer script for emergency deployment of only the postagestamp contract with some quick fixes | ||
let args: string[] = []; | ||
let waitTime = 6; | ||
let currentRedis = ''; | ||
let currentOracle = ''; | ||
if (network.name == 'mainnet') { | ||
// BZZ Token address, minimumBucketDepth, multisig | ||
args = ['0xb1C7F17Ed88189Abf269Bf68A3B2Ed83C5276aAe', '16', '0xb1C7F17Ed88189Abf269Bf68A3B2Ed83C5276aAe']; | ||
currentRedis = ''; | ||
currentOracle = ''; | ||
} else if (network.name == 'testnet') { | ||
args = ['0x0b2bbcbe94d5d4bb782713b137c85d29aa609a13', '16', '0xb1C7F17Ed88189Abf269Bf68A3B2Ed83C5276aAe']; | ||
currentRedis = '0x9e3BDb0c69838CC06D85409d4AD6245e54F70F1d'; | ||
currentOracle = '0xefC5Ead3188402eCC951DB45827F6e0F99B67a25'; | ||
} else if (network.name == 'localhost') { | ||
args = ['0x942C6684eB9874C63d4ed26Ab0623F951D253081', '16', '0x3c8F39EE625fCF97cB6ee22bCe25BE1F1E5A5dE8']; | ||
currentRedis = '0xDF64aed195102E644ad6A0204eD5377589b29618'; | ||
currentOracle = '0xF52458e65b8e3B69d93DD3803d8ef934c75E0022'; | ||
waitTime = 1; | ||
} | ||
|
||
// Deploy the contract | ||
const stampFactory = await ethers.getContractFactory('PostageStamp'); | ||
console.log('Deploying contract...'); | ||
const stamp = await stampFactory.deploy(...args); | ||
await stamp.deployed(); | ||
console.log(`Deployed contract to: ${stamp.address}`); | ||
const deploymentReceipt = await stamp.deployTransaction.wait(waitTime); | ||
|
||
// Add metadata for Bee Node | ||
const deployed = await JSON.parse(JSON.stringify(config.deployedData).toString()); | ||
const stampABI = await require('../artifacts/src/PostageStamp.sol/PostageStamp.json'); | ||
deployed['contracts']['postageStamp']['abi'] = stampABI.abi; | ||
deployed['contracts']['postageStamp']['bytecode'] = stampABI.bytecode.toString(); | ||
deployed['contracts']['postageStamp']['address'] = stamp.address; | ||
deployed['contracts']['postageStamp']['block'] = deploymentReceipt.blockNumber; | ||
deployed['contracts']['postageStamp']['url'] = config.url + stamp.address; | ||
|
||
// We need to first deploy this contract and then use this address and deploy with it redistribution | ||
// After that we can add here redis role | ||
|
||
// Change roles on current staking contract | ||
const redistributorRole = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('REDISTRIBUTOR_ROLE')); | ||
const tx2 = await stamp.grantRole(redistributorRole, currentRedis); | ||
console.log('Changed REDISTRIBUTOR ROLE at : ', tx2.hash); | ||
|
||
const oracleRole = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('PRICE_ORACLE_ROLE')); | ||
const tx3 = await stamp.grantRole(oracleRole, currentOracle); | ||
console.log('Changed ORACLE ROLE at : ', tx3.hash); | ||
|
||
fs.writeFileSync(config.networkName + '_deployed.json', JSON.stringify(deployed, null, '\t')); | ||
|
||
if ((process.env.MAINNET_ETHERSCAN_KEY || process.env.TESTNET_ETHERSCAN_KEY) && network.name != 'localhost') { | ||
console.log('Verifying...'); | ||
await verify(stamp.address, args); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.