-
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.
- Loading branch information
1 parent
60aa0ab
commit daa7171
Showing
43 changed files
with
6,606 additions
and
1,141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { deploy, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
let token = null; | ||
|
||
const argsToken = ['TEST', 'TST', '1249989122910552325012092', deployer]; | ||
|
||
token = await deploy('TestToken', { | ||
from: deployer, | ||
args: argsToken, | ||
log: true, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['testToken', 'contracts']; |
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,23 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network, ethers }) { | ||
const { deploy, log, get } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const token = await get('TestToken'); | ||
|
||
const argsStamp = [token.address, 16, networkConfig[network.name]?.multisig]; | ||
|
||
await deploy('PostageStamp', { | ||
from: deployer, | ||
args: argsStamp, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 1, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['postageStamp', 'contracts']; |
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,20 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { | ||
const { deploy, get, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const args = [(await get('PostageStamp')).address, networkConfig[network.name]?.multisig]; | ||
await deploy('PriceOracle', { | ||
from: deployer, | ||
args: args, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 1, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['oracle', 'contracts']; |
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,23 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network, ethers }) { | ||
const { deploy, get, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const swarmNetworkID = networkConfig[network.name]?.swarmNetworkId; | ||
|
||
const token = await get('TestToken'); | ||
|
||
const args = [token.address, swarmNetworkID, networkConfig[network.name]?.multisig]; | ||
await deploy('StakeRegistry', { | ||
from: deployer, | ||
args: args, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 1, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['staking', 'contracts']; |
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,26 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { | ||
const { deploy, get, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const args = [ | ||
(await get('StakeRegistry')).address, | ||
(await get('PostageStamp')).address, | ||
(await get('PriceOracle')).address, | ||
networkConfig[network.name]?.multisig, | ||
]; | ||
|
||
await deploy('Redistribution', { | ||
from: deployer, | ||
args: args, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 1, | ||
}); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['redistribution', 'contracts']; |
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,27 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { get, read, execute, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
log('Setting PostageStamps roles'); | ||
|
||
const priceOracleRole = await read('PostageStamp', 'PRICE_ORACLE_ROLE'); | ||
await execute('PostageStamp', { from: deployer }, 'grantRole', priceOracleRole, (await get('PriceOracle')).address); | ||
|
||
const redistributorRole = await read('PostageStamp', 'REDISTRIBUTOR_ROLE'); | ||
await execute( | ||
'PostageStamp', | ||
{ from: deployer }, | ||
'grantRole', | ||
redistributorRole, | ||
( | ||
await get('Redistribution') | ||
).address | ||
); | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['postageStamp_roles', 'roles']; |
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,9 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function () { | ||
// Currently we dont need to set any roles on Redistribution contract, they are all set on Constructor | ||
// This is used just as placeholder for future possible settings | ||
}; | ||
|
||
export default func; | ||
func.tags = ['redistribution_roles', 'roles']; |
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,17 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { get, read, execute, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
log('Setting Staking roles'); | ||
|
||
const redisAddress = (await get('Redistribution')).address; | ||
|
||
const redisRole = await read('StakeRegistry', 'REDISTRIBUTOR_ROLE'); | ||
await execute('StakeRegistry', { from: deployer }, 'grantRole', redisRole, redisAddress); | ||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['staking_roles', 'roles']; |
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,17 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) { | ||
const { get, read, execute, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
log('Setting Oracles roles'); | ||
|
||
const redisAddress = (await get('Redistribution')).address; | ||
|
||
const updaterRole = await read('PriceOracle', 'PRICE_UPDATER_ROLE'); | ||
await execute('PriceOracle', { from: deployer }, 'grantRole', updaterRole, redisAddress); | ||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['oracle_roles', 'roles']; |
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,103 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
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: { | ||
postageStamp: DeployedContract; | ||
redistribution: DeployedContract; | ||
staking: DeployedContract; | ||
priceOracle: DeployedContract; | ||
bzzToken: DeployedContract; | ||
}; | ||
} | ||
|
||
const func: DeployFunction = async function ({ deployments, network, config }) { | ||
const { get, log } = deployments; | ||
|
||
const deployedData = { | ||
chainId: network.config.chainId, | ||
swarmNetworkId: networkConfig[network.name]?.swarmNetworkId || 1, | ||
contracts: { | ||
bzzToken: {} as DeployedContract, | ||
staking: {} as DeployedContract, | ||
postageStamp: {} as DeployedContract, | ||
priceOracle: {} as DeployedContract, | ||
redistribution: {} as DeployedContract, | ||
}, | ||
} as DeployedData; | ||
|
||
async function writeResult(deployedData: DeployedData) { | ||
let fileName = ''; | ||
|
||
if (fileName.length == 0 || !fs.existsSync(fileName)) { | ||
fileName = network.name + '_deployed.json'; | ||
} | ||
|
||
fs.writeFileSync(fileName, JSON.stringify(deployedData, null, '\t') + '\n'); | ||
log('Data saved to ' + fileName); | ||
} | ||
|
||
const stampsContract = await get('PostageStamp'); | ||
const oracleContract = await get('PriceOracle'); | ||
const stakingContract = await get('StakeRegistry'); | ||
const redisContract = await get('Redistribution'); | ||
const browserURL = config.etherscan.customChains.find((chain) => chain.network === network.name)?.urls.browserURL; | ||
|
||
// Token data for dev chains | ||
const tokenContract = await get('TestToken'); | ||
deployedData['contracts']['bzzToken']['abi'] = tokenContract.abi; | ||
deployedData['contracts']['bzzToken']['bytecode'] = tokenContract.bytecode ? tokenContract.bytecode : ''; | ||
deployedData['contracts']['bzzToken']['address'] = tokenContract.address; | ||
deployedData['contracts']['bzzToken']['block'] = | ||
tokenContract.receipt && tokenContract.receipt.blockNumber ? tokenContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['bzzToken']['url'] = browserURL + tokenContract.address; | ||
|
||
// PostageStamp data | ||
deployedData['contracts']['postageStamp']['abi'] = stampsContract.abi; | ||
deployedData['contracts']['postageStamp']['bytecode'] = stampsContract.bytecode ? stampsContract.bytecode : ''; | ||
deployedData['contracts']['postageStamp']['address'] = stampsContract.address; | ||
deployedData['contracts']['postageStamp']['block'] = | ||
stampsContract.receipt && stampsContract.receipt.blockNumber ? stampsContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['postageStamp']['url'] = browserURL + stampsContract.address; | ||
|
||
// Redistribution data | ||
deployedData['contracts']['redistribution']['abi'] = redisContract.abi; | ||
deployedData['contracts']['redistribution']['bytecode'] = redisContract.bytecode ? redisContract.bytecode : ''; | ||
deployedData['contracts']['redistribution']['address'] = redisContract.address; | ||
deployedData['contracts']['redistribution']['block'] = | ||
redisContract.receipt && redisContract.receipt.blockNumber ? redisContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['redistribution']['url'] = browserURL + redisContract.address; | ||
|
||
// Staking data | ||
deployedData['contracts']['staking']['abi'] = stakingContract.abi; | ||
deployedData['contracts']['staking']['bytecode'] = stakingContract.bytecode ? stakingContract.bytecode : ''; | ||
deployedData['contracts']['staking']['address'] = stakingContract.address; | ||
deployedData['contracts']['staking']['block'] = | ||
stakingContract.receipt && stakingContract.receipt.blockNumber ? stakingContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['staking']['url'] = browserURL + stakingContract.address; | ||
|
||
// Oracle data | ||
deployedData['contracts']['priceOracle']['abi'] = oracleContract.abi; | ||
deployedData['contracts']['priceOracle']['bytecode'] = oracleContract.bytecode ? oracleContract.bytecode : ''; | ||
deployedData['contracts']['priceOracle']['address'] = oracleContract.address; | ||
deployedData['contracts']['priceOracle']['block'] = | ||
oracleContract.receipt && oracleContract.receipt.blockNumber ? oracleContract.receipt.blockNumber : 0; | ||
deployedData['contracts']['priceOracle']['url'] = browserURL + oracleContract.address; | ||
|
||
await writeResult(deployedData); | ||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['data']; |
4 changes: 2 additions & 2 deletions
4
deploy/000_deploy_test_token.ts → deploy/main/000_deploy_test_token.ts
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
2 changes: 1 addition & 1 deletion
2
deploy/001_deploy_postage.ts → deploy/main/001_deploy_postage.ts
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
2 changes: 1 addition & 1 deletion
2
deploy/003_deploy_staking.ts → deploy/main/003_deploy_staking.ts
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
2 changes: 1 addition & 1 deletion
2
deploy/004_deploy_redistribution.ts → deploy/main/004_deploy_redistribution.ts
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
deploy/009_deploy_local_data.ts → deploy/main/009_deploy_local_data.ts
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
4 changes: 2 additions & 2 deletions
4
deploy/010_deploy_verify.ts → deploy/main/010_deploy_verify.ts
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,29 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { networkConfig } from '../../helper-hardhat-config'; | ||
|
||
const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { | ||
const { deploy, log, getOrNull } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
let token = null; | ||
|
||
if (network.name == 'testnet') { | ||
// We deploy new token if there is no token | ||
if (!(token = await getOrNull('TestToken'))) { | ||
const argsToken = ['gBZZ', 'gBZZ', '1250000000000000000000000', networkConfig[network.name]?.multisig]; | ||
token = await deploy('TestToken', { | ||
from: deployer, | ||
args: argsToken, | ||
log: true, | ||
waitConfirmations: networkConfig[network.name]?.blockConfirmations || 6, | ||
}); | ||
} else { | ||
log('Using already deployed token at', token.address); | ||
} | ||
} | ||
|
||
log('----------------------------------------------------'); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['testToken', 'contracts']; |
Oops, something went wrong.