chore: update 1.10 contracts (#232)

This commit is contained in:
Adam Uhlíř 2022-12-14 01:49:32 -08:00 committed by GitHub
parent fa4533d2cc
commit 276f04265d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 38 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -29,8 +29,16 @@ function getPostageStampBin(tokenAddress) {
return bin + tokenAddress return bin + tokenAddress
} }
function getPriceOracleBin(price, chequeValueDeduction) { function getPostagePriceOracleBin(tokenAddress) {
const binPath = Path.join(__dirname, '..', 'contracts', 'PriceOracle.bytecode') const binPath = Path.join(__dirname, '..', 'contracts', 'PostagePriceOracle.bytecode')
const bin = FS.readFileSync(binPath, 'utf8').toString().trim()
tokenAddress = prefixedAddressParamToByteCode(tokenAddress)
//add tokenaddress for param to the end of the bytecode
return bin + tokenAddress
}
function getSwapPriceOracleBin(price, chequeValueDeduction) {
const binPath = Path.join(__dirname, '..', 'contracts', 'SwapPriceOracle.bytecode')
const bin = FS.readFileSync(binPath, 'utf8').toString().trim() const bin = FS.readFileSync(binPath, 'utf8').toString().trim()
const priceAbi = intToByteCode(price) const priceAbi = intToByteCode(price)
const chequeValueAbi = intToByteCode(chequeValueDeduction) const chequeValueAbi = intToByteCode(chequeValueDeduction)
@ -47,13 +55,14 @@ function getStakeRegistryBin(tokenAddress) {
return bin + tokenAddress + networkIdAbi return bin + tokenAddress + networkIdAbi
} }
function getRedistributionBin(stakingAddress, postageContractAddress) { function getRedistributionBin(stakingAddress, postageContractAddress, oracleContractAddress) {
const binPath = Path.join(__dirname, '..', 'contracts', 'Redistribution.bytecode') const binPath = Path.join(__dirname, '..', 'contracts', 'Redistribution.bytecode')
const bin = FS.readFileSync(binPath, 'utf8').toString().trim() const bin = FS.readFileSync(binPath, 'utf8').toString().trim()
stakingAddress = prefixedAddressParamToByteCode(stakingAddress) stakingAddress = prefixedAddressParamToByteCode(stakingAddress)
postageContractAddress = prefixedAddressParamToByteCode(postageContractAddress) postageContractAddress = prefixedAddressParamToByteCode(postageContractAddress)
//add staking address and postage address for param to the end of the bytecode oracleContractAddress = prefixedAddressParamToByteCode(oracleContractAddress)
return bin + stakingAddress + postageContractAddress //add staking address, postage address and oracle contract address for param to the end of the bytecode
return bin + stakingAddress + postageContractAddress + oracleContractAddress
} }
/** Returns back contract hash */ /** Returns back contract hash */
@ -74,7 +83,10 @@ async function createContract(contractName, data, creatorAccount, configName) {
`\tTransaction ID: ${transaction.transactionHash}\n` + `\tTransaction ID: ${transaction.transactionHash}\n` +
`\tContract ID: ${transaction.contractAddress}`, `\tContract ID: ${transaction.contractAddress}`,
) )
console.log(`::CONTRACT:${configName}:${transaction.contractAddress}\n`)
if (configName) {
console.log(`::CONTRACT:${configName}:${transaction.contractAddress}\n`)
}
return transaction.contractAddress return transaction.contractAddress
} }
@ -83,7 +95,7 @@ module.exports = function (deployer, network, accounts) {
const creatorAccount = accounts[0] const creatorAccount = accounts[0]
deployer.deploy(ERC20PresetMinterPauser, 'Swarm Token', 'BZZ').then(async () => { deployer.deploy(ERC20PresetMinterPauser, 'Swarm Token', 'BZZ').then(async () => {
await createContract('PriceOracle', getPriceOracleBin(100000, 100), creatorAccount, 'price-oracle-address') await createContract('SwapPriceOracle', getSwapPriceOracleBin(100000, 100), creatorAccount, 'price-oracle-address')
await createContract( await createContract(
'SimpleSwapFactory', 'SimpleSwapFactory',
getSimpleSwapFactoryBin(ERC20PresetMinterPauser.address), getSimpleSwapFactoryBin(ERC20PresetMinterPauser.address),
@ -98,16 +110,22 @@ module.exports = function (deployer, network, accounts) {
'postage-stamp-address', 'postage-stamp-address',
) )
const postagePriceOracleAddress = await createContract(
'PostagePriceOracle',
getPostagePriceOracleBin(ERC20PresetMinterPauser.address),
creatorAccount,
)
const stakeRegistryAddress = await createContract( const stakeRegistryAddress = await createContract(
'StakeRegistry', 'StakeRegistry',
getStakeRegistryBin(ERC20PresetMinterPauser.address, accounts[0]), getStakeRegistryBin(ERC20PresetMinterPauser.address),
creatorAccount, creatorAccount,
'staking-address', 'staking-address',
) )
await createContract( await createContract(
'Redistribution', 'Redistribution',
getRedistributionBin(stakeRegistryAddress, postageStampAddress), getRedistributionBin(stakeRegistryAddress, postageStampAddress, postagePriceOracleAddress),
creatorAccount, creatorAccount,
'redistribution-address', 'redistribution-address',
) )

View File

@ -9,7 +9,7 @@
"version": "0.0.1", "version": "0.0.1",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"@ethersphere/bee-js": "^5.0.0", "@ethersphere/bee-js": "^5.1.0",
"@ethersphere/swarm-cli": "^1.12.0", "@ethersphere/swarm-cli": "^1.12.0",
"@openzeppelin/contracts": "^3.1.0", "@openzeppelin/contracts": "^3.1.0",
"truffle": "^5.6.3" "truffle": "^5.6.3"
@ -207,9 +207,9 @@
} }
}, },
"node_modules/@ethersphere/bee-js": { "node_modules/@ethersphere/bee-js": {
"version": "5.0.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-5.0.0.tgz", "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-5.1.0.tgz",
"integrity": "sha512-Dr5Xon0UZvi37fvbyGj46kw3/0D8fydwfDtVtFHKi2p7mNEizG0uok2mXvwLZrMvUMOS8uXkFhbQjTFBjB+pWA==", "integrity": "sha512-DJERG2F0Qjxsu3gZ9e7w2yc83/EdvN+gRIKczkNW0arpXn6IBphK21esGURqkhasmrbgPPZ1pA178BIAIb6/hg==",
"dependencies": { "dependencies": {
"@ethersphere/swarm-cid": "^0.1.0", "@ethersphere/swarm-cid": "^0.1.0",
"@types/readable-stream": "^2.3.13", "@types/readable-stream": "^2.3.13",
@ -227,9 +227,9 @@
"ws": "^8.7.0" "ws": "^8.7.0"
}, },
"engines": { "engines": {
"bee": "1.7.0-bbf13011", "bee": "1.9.0-13a47043",
"beeApiVersion": "3.0.2", "beeApiVersion": "3.2.0",
"beeDebugApiVersion": "3.0.2", "beeDebugApiVersion": "3.2.0",
"node": ">=14.0.0", "node": ">=14.0.0",
"npm": ">=6.0.0" "npm": ">=6.0.0"
} }
@ -9556,9 +9556,9 @@
} }
}, },
"@ethersphere/bee-js": { "@ethersphere/bee-js": {
"version": "5.0.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-5.0.0.tgz", "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-5.1.0.tgz",
"integrity": "sha512-Dr5Xon0UZvi37fvbyGj46kw3/0D8fydwfDtVtFHKi2p7mNEizG0uok2mXvwLZrMvUMOS8uXkFhbQjTFBjB+pWA==", "integrity": "sha512-DJERG2F0Qjxsu3gZ9e7w2yc83/EdvN+gRIKczkNW0arpXn6IBphK21esGURqkhasmrbgPPZ1pA178BIAIb6/hg==",
"requires": { "requires": {
"@ethersphere/swarm-cid": "^0.1.0", "@ethersphere/swarm-cid": "^0.1.0",
"@types/readable-stream": "^2.3.13", "@types/readable-stream": "^2.3.13",

View File

@ -13,7 +13,7 @@
"gen:traffic": "node ./scripts/gen-traffic.js" "gen:traffic": "node ./scripts/gen-traffic.js"
}, },
"dependencies": { "dependencies": {
"@ethersphere/bee-js": "^5.0.0", "@ethersphere/bee-js": "^5.1.0",
"@ethersphere/swarm-cli": "^1.12.0", "@ethersphere/swarm-cli": "^1.12.0",
"@openzeppelin/contracts": "^3.1.0", "@openzeppelin/contracts": "^3.1.0",
"truffle": "^5.6.3" "truffle": "^5.6.3"

View File

@ -1,5 +1,5 @@
BEE_VERSION="1.9.0" BEE_VERSION="1.10.0-rc16"
BLOCKCHAIN_VERSION="1.3.0" BLOCKCHAIN_VERSION="1.3.1"
BEE_ENV_PREFIX="bee-factory" BEE_ENV_PREFIX="bee-factory"
BEE_IMAGE_PREFIX="ethersphere" BEE_IMAGE_PREFIX="ethersphere"
COMMIT_VERSION_TAG="false" COMMIT_VERSION_TAG="false"

View File

@ -90,6 +90,8 @@ async function genTrafficLoop(hosts, minCheques) {
const uploaderBee = new Bee(uploaderBeeUrl) const uploaderBee = new Bee(uploaderBeeUrl)
const uploaderBeeDebug = new BeeDebug(uploaderBeeDebugUrl) const uploaderBeeDebug = new BeeDebug(uploaderBeeDebugUrl)
console.log(`Depositing 10 BZZ to Chequebook on ${uploaderBeeDebugUrl}...`)
await uploaderBeeDebug.depositTokens('1000000000000000000')
console.log(`Creating postage stamp on ${uploaderBeeDebugUrl}...`) console.log(`Creating postage stamp on ${uploaderBeeDebugUrl}...`)
const postageBatchId = await uploaderBeeDebug.createPostageBatch(POSTAGE_STAMPS_AMOUNT, POSTAGE_STAMPS_DEPTH, { const postageBatchId = await uploaderBeeDebug.createPostageBatch(POSTAGE_STAMPS_AMOUNT, POSTAGE_STAMPS_DEPTH, {
waitForUsable: true, waitForUsable: true,

View File

@ -1,29 +1,28 @@
module.exports = { module.exports = {
networks: { networks: {
development: { development: {
host: "127.0.0.1", host: '127.0.0.1',
port: 9545, port: 9545,
network_id: "4020", network_id: '4020',
gasPrice: "10000000000", //10 gwei gasPrice: '10000000000', //10 gwei
} },
}, },
compilers: { compilers: {
solc: { solc: {
version: "0.6.12", // Fetch exact version from solc-bin (default: truffle's version) version: '0.6.12', // Fetch exact version from solc-bin (default: truffle's version)
docker: true, docker: true,
settings: { settings: {
optimizer: { optimizer: {
enabled: true, enabled: true,
runs: 200 // Optimize for how many times you intend to run the code runs: 200, // Optimize for how many times you intend to run the code
}, },
evmVersion: "istanbul" evmVersion: 'istanbul',
} },
} },
}, },
db: { db: {
enabled: true enabled: true,
} },
}; }