-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a helper to deploy a new TradeEngine
- Loading branch information
Thomas Wiesner
authored and
Thomas Wiesner
committed
May 6, 2022
1 parent
86a2fdf
commit 6065e27
Showing
3 changed files
with
225 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,120 @@ | ||
{ | ||
"sidechain": { | ||
"lastEdit": "20210609", | ||
"contracts": { | ||
"MorpherState": { | ||
"address": "0xB4881186b9E52F8BD6EC5F19708450cE57b24370" | ||
}, | ||
"MorpherToken": { | ||
"address": "0xC44628734a9432a3DAA302E11AfbdFa8361424A5" | ||
}, | ||
"MorpherBridge": { | ||
"address": "0x43e3f95d110ad4aF1e24AAffA81351BD41C0A652" | ||
}, | ||
"MorpherAirdrop": { | ||
"address": "0x6306037eaD1FC236F4aabC8c826F351c9F45d409" | ||
}, | ||
"MorpherEscrow": { | ||
"address": "0x3CBC7e439FD0A98182622136d38EBa03Aac17A72" | ||
}, | ||
"MorpherAdmin": { | ||
"address": "0x62FE304514455dea2E74DEAbeF75bDe0e6f975f1" | ||
}, | ||
"MorpherStaking": { | ||
"address": "0x318Ea6e12A3e49703666C85eEF372644b4022C49" | ||
}, | ||
"MorpherTradeEngine": { | ||
"address": "0xD94F671bdDD63B87C5407Ffe8aC08B4f900bc876", | ||
"oldAddresses": [ | ||
{ | ||
"replacedOn": "20210609", | ||
"address": "0xcEFe3876e6c07F227ABD05f076AF6e7368C5cEB0" | ||
} | ||
] | ||
}, | ||
"MorpherOracle": { | ||
"address": "0xf8B5b1699A00EDfdB6F15524646Bd5071bA419Fb", | ||
"oldAddresses": [ | ||
{ | ||
"replacedOn": "20210609", | ||
"address": "0xce5414FBFCD421E9FCcAE8e09f1Bc9E3B76D0eb9" | ||
} | ||
] | ||
}, | ||
"MorpherMintingLimiter": { | ||
"address": "0x9c7d7Ce27Fff6014D791DC004E7Ce9DeD4E6bD1E" | ||
}, | ||
"MorpherUserBlocking": { | ||
"address": "0x96F9174332F8030A59986C07CdAe51Ba549eBE52" | ||
} | ||
}, | ||
"roles": { | ||
"owner": "0x51c5cE7C4926D5cA74f4824e11a062f1Ef491762", | ||
"administrator": "0xB59b29423e5Aa1E0E2cB8966DC14e553E580314D", | ||
"airdropAdministrator": "0x831A893730701D2a2865542b71b847f8259F797f", | ||
"sidechainOperator": "0x70Dcdb66E128738189012dee12d7e13b377A1D3B", | ||
"userBlockingAddress": "0x000029b476d99932660e1782d864a69e28f5f7af", | ||
"callbackAddress1": "0x4caD8E39530f2c356BFdB1C42605a7eEDC4b253F", | ||
"callbackAddress2": "0x5120219c545cFCC1f63ef1aC5f4777B92D93790f", | ||
"callbackAddress3": "0x6cf9aE55ba941AdD181A7c5b51f99733F2BeD7D0" | ||
}, | ||
"accounts": { | ||
"gasCollectionAddress": "0x7aE99ae2b89E4d5cBb2BA576B1824bE2fB29Bd91", | ||
"airdropColdTreasury": "0x20038dBd4a6C2fd9c7c1d490cF5471EBb67c82F9", | ||
"airdropHotTreasury": "0x0ff1ce7827efff8a12f00b63267d709d9bed0c80", | ||
"morpherHotTreasury": "0x42fBE5A98eb35b2eAF50e4aAfB086325Ed1A4148", | ||
"morpherColdTreasury": "0xE261D68bDa5BD518598E31320edE6E1E2d53682f", | ||
"morpherHotWallet": "0x00001a8ec45420e3366f8e020d2502b7a01a8935" | ||
} | ||
}, | ||
"mainchain": { | ||
"lastUpdate": "20210609", | ||
"contracts": { | ||
"MorpherState": { | ||
"address": "0x1f426C51F0Ef7655A6f4c3Eb58017d2F1c381bfF" | ||
}, | ||
"MorpherToken": { | ||
"address": "0x6369c3DadfC00054A42BA8B2c09c48131dd4Aa38" | ||
}, | ||
"MorpherStaking": { | ||
"address": "0xBaF121D02E6948D3A089F99dDc522eb2A4a1b1fE" | ||
}, | ||
"MorpherMintingLimiter": { | ||
"address": "0x30d90c8a36fff52f1c8c05b54d4ce79610431ec0" | ||
}, | ||
"MorpherTradeEngine": { | ||
"address": "0x62e26AB4444E24E42e63A0857bF56Ea1c70AAEc8" | ||
}, | ||
"MorpherBridge": { | ||
"address": "0xa937787581b17236f3efb2618c38270baac685ba" | ||
}, | ||
"MorpherGovernance": { | ||
"address": "0x51c5cE7C4926D5cA74f4824e11a062f1Ef491762" | ||
}, | ||
"MorpherAirdrop": { | ||
"address": "0x6306037eaD1FC236F4aabC8c826F351c9F45d409" | ||
}, | ||
"MorpherEscrow": { | ||
"address": "0x161Ba24A3F9f90b531f6C0a2E0abb392DDBb8f6c" | ||
}, | ||
"MorpherOracle": { | ||
"address": "0x73b7631c508db9E389edF6aBb3C4a48da0444553" | ||
} | ||
}, | ||
"roles": { | ||
"owner": "0x51c5cE7C4926D5cA74f4824e11a062f1Ef491762", | ||
"administrator": "0xB59b29423e5Aa1E0E2cB8966DC14e553E580314D", | ||
"airdropAdministrator": "0x831A893730701D2a2865542b71b847f8259F797f", | ||
"sidechainOperator": "0x70Dcdb66E128738189012dee12d7e13b377A1D3B", | ||
"callbackAddress1": "0x4caD8E39530f2c356BFdB1C42605a7eEDC4b253F", | ||
"callbackAddress2": "0x5120219c545cFCC1f63ef1aC5f4777B92D93790f", | ||
"callbackAddress3": "0x6cf9aE55ba941AdD181A7c5b51f99733F2BeD7D0" | ||
}, | ||
"accounts": { | ||
"gasCollectionAddress": "0x4caD8E39530f2c356BFdB1C42605a7eEDC4b253F", | ||
"airdropColdTreasury": "", | ||
"morpherHotTreasury": "0x42fBE5A98eb35b2eAF50e4aAfB086325Ed1A4148", | ||
"morpherColdTreasury": "0xE261D68bDa5BD518598E31320edE6E1E2d53682f" | ||
} | ||
} | ||
} |
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,105 @@ | ||
const MorpherState = artifacts.require("MorpherState"); | ||
const MorpherOracle = artifacts.require("MorpherOracle"); | ||
const MorpherTradeEngine = artifacts.require("MorpherTradeEngine"); | ||
const MorpherStaking = artifacts.require("MorpherStaking"); | ||
|
||
module.exports = async function (callback) { | ||
const addressesAndRoles = require("../docs/addressesAndRoles.json"); | ||
console.log("Deploying a new TradeEngine with Truffle Dashboard..."); | ||
|
||
const [, contracts, roles] = Object.values(addressesAndRoles.sidechain); | ||
|
||
|
||
/** | ||
* Owner Actions: | ||
* 1. Deploy new Trade Engine | ||
* 2. Set new Trade Engine in Oracle | ||
* 3. Set Minting Limiter on new Trade Engine | ||
*/ | ||
|
||
//select deployer account | ||
await waitForAccount(roles.owner); | ||
|
||
const deployedTimestamp = 1613399217; | ||
const newTradeEngine = await MorpherTradeEngine.new( | ||
contracts.MorpherState.address, | ||
roles.owner, | ||
contracts.MorpherStaking.address, | ||
true, | ||
deployedTimestamp, | ||
contracts.MorpherMintingLimiter.address | ||
); | ||
console.log("New Trade Engine", newTradeEngine.address); | ||
|
||
addressesAndRoles.sidechain.contracts.MorpherTradeEngine.oldAddresses.push({ | ||
address: contracts.MorpherTradeEngine.address, | ||
replacedOn: Date.now(), | ||
}); | ||
|
||
|
||
const morpherOracle = await MorpherOracle.at(contracts.MorpherOracle.address); | ||
await morpherOracle.setTradeEngineAddress(newTradeEngine.address); | ||
console.log("✅ Set new Trade Engine in Oracle"); | ||
|
||
const morpherMintingLimiter = await MorpherMintingLimiter.at( | ||
contracts.MorpherMintingLimiter.address | ||
); | ||
await morpherMintingLimiter.setTradeEngineAddress(newTradeEngine.address); //on dev not necessary | ||
|
||
|
||
/** | ||
* Administrative Actions: | ||
* 1. Remove Minting Limiter from Old Trade Engine | ||
* 2. Set Minting Limiter on New Trade Engine | ||
* 3. Grant Access | ||
* 4. Grant Transfers for new Trade Engine | ||
*/ | ||
await waitForAccount(roles.administrator); | ||
|
||
console.log("✅ Removing minting limiter from old tradeEngine"); | ||
let oldTradeEngine = await MorpherTradeEngine.at( | ||
contracts.MorpherTradeEngine.address | ||
); | ||
oldTradeEngine.setMintingLimiterAddress(contracts.MorpherState.address, { | ||
from: roles.administrator, | ||
}); | ||
|
||
const morpherState = await MorpherState.at(contracts.MorpherState.address); | ||
await morpherState.grantAccess(newTradeEngine.address, { from: roles.administrator }); | ||
console.log("✅ Granted access for new Trade Engine"); | ||
await morpherState.enableTransfers(newTradeEngine.address, { | ||
from: roles.administrator, | ||
}); | ||
console.log("✅ Granted Transfers for new Trade Engine"); | ||
|
||
//print the new addressesAndRoles object | ||
console.log(JSON.stringify(addressesAndRoles, undefined, 2)); | ||
return callback(); | ||
}; | ||
|
||
const keypress = async () => { | ||
process.stdin.setRawMode(true); | ||
return new Promise((resolve) => | ||
process.stdin.once("data", () => { | ||
process.stdin.setRawMode(false); | ||
resolve(); | ||
}) | ||
); | ||
}; | ||
|
||
const waitForAccount = async (account) => { | ||
let [currentAccount] = await web3.eth.getAccounts(); | ||
if (account != currentAccount) { | ||
console.log( | ||
"Please select account " + | ||
account + | ||
"! Current Account: " + | ||
currentAccount | ||
); | ||
await keypress(); | ||
[currentAccount] = await web3.eth.getAccounts(); | ||
if (account != currentAccount) { | ||
await waitForAccount(account); | ||
} | ||
} | ||
}; |