mirror of
https://github.com/logos-storage/codex-factory.git
synced 2026-01-02 13:03:07 +00:00
* feat: postage stamp * chore: remove empty postage stamp sol * fix: start the nodes with the new '--full-node' flag * chore: blockchain image 1.1.1 - updated factory bin (#29) * fix: add network id to the bee statup params * fix: change payment treshold limit to the possible min value * feat: add port-maps to the environment sh * fix: specify the same chainId as the networkId * feat: expose blockchain 9545 port to localhost * feat: extended postage stamp contract * refactor: remove price oracle setups * feat: updated the gen-traffic to work with postage stamps (#28) * feat: updated the gen-traffic to work with postage stamps * chore: update to latest bee-js version Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
const ERC20PresetMinterPauser = artifacts.require("ERC20PresetMinterPauser");
|
|
const FS = require('fs')
|
|
const Path = require('path')
|
|
|
|
function prefixedAddressParamToByteCode(address) {
|
|
// the first 2 chars removal removes 0x prefix
|
|
return address.substring(2).toLowerCase().padStart(64, '0')
|
|
}
|
|
|
|
function getSimpleSwapFactoryBin(tokenAddress) {
|
|
const binPath = Path.join(__dirname, '..', 'contracts', 'SimpleSwapFactory.bytecode')
|
|
const bin = FS.readFileSync(binPath, 'utf8').toString()
|
|
tokenAddress = prefixedAddressParamToByteCode(tokenAddress)
|
|
//add tokenaddress for param to the end of the bytecode
|
|
return bin + tokenAddress
|
|
}
|
|
|
|
function getPostageStampBin(tokenAddress) {
|
|
const binPath = Path.join(__dirname, '..', 'contracts', 'PostageStamp.bytecode')
|
|
const bin = FS.readFileSync(binPath, 'utf8').toString()
|
|
tokenAddress = prefixedAddressParamToByteCode(tokenAddress)
|
|
//add tokenaddress for param to the end of the bytecode
|
|
return bin + tokenAddress
|
|
}
|
|
|
|
/** Returns back contract hash */
|
|
async function createContract(contractName, data, creatorAccount) {
|
|
const transaction = await web3.eth.sendTransaction({
|
|
data: data,
|
|
gasLimit: 6721975,
|
|
gasPrice: web3.utils.toWei('10', 'gwei'),
|
|
from: creatorAccount
|
|
})
|
|
|
|
if(!transaction.status) {
|
|
console.error(`${contractName} contract creation Error`, error)
|
|
throw new Error(`Error happened at creating ${contractName} contract creation`)
|
|
}
|
|
console.log(`${contractName} contract creation was successful!\n`
|
|
+ `\tTransaction ID: ${transaction.transactionHash}\n`
|
|
+ `\tContract ID: ${transaction.contractAddress}`)
|
|
|
|
return transaction.contractAddress
|
|
}
|
|
|
|
async function createSimpleSwapFactoryContract(erc20ContractAddress, creatorAccount) {
|
|
return createContract('SimpleSwapFactory', getSimpleSwapFactoryBin(erc20ContractAddress), creatorAccount)
|
|
}
|
|
|
|
async function createPostageStampContract(erc20ContractAddress, creatorAccount) {
|
|
return createContract('PostageStamp', getPostageStampBin(erc20ContractAddress), creatorAccount)
|
|
}
|
|
|
|
module.exports = function (deployer, network, accounts) {
|
|
deployer.deploy(ERC20PresetMinterPauser, "Swarm Token", "BZZ").then(async () => {
|
|
await createSimpleSwapFactoryContract(ERC20PresetMinterPauser.address, accounts[0])
|
|
await createPostageStampContract(ERC20PresetMinterPauser.address, accounts[0])
|
|
});
|
|
};
|