This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add prod multi-sig wallets to owner whitelist * Fix broken error message * Add prod addresses to token transactor whitelist * Production-only migrations * Transfers ownership of marketplace & token contracts to multi-sig wallets * Transfers all OGN to token multi-sig wallet * Verifies state of token & marketplace contracts Resolves #547 * code review changes
- Loading branch information
Showing
6 changed files
with
181 additions
and
18 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,109 @@ | ||
const OriginToken = artifacts.require('./token/OriginToken.sol') | ||
const V00_Marketplace = artifacts.require('./V00_Marketplace.sol') | ||
|
||
const tokenMultiSig = '0xe011fa2a6df98c69383457d87a056ed0103aa352' | ||
const marketplaceMultiSig = '0x8a1a4f77f9f0eb35fb9930696038be6220986c1b' | ||
|
||
module.exports = function(deployer, network) { | ||
return deployer.then(() => { | ||
if (network === 'mainnet' || process.env['SIMULATE_MAINNET']) { | ||
return verifyMainnetContracts() | ||
} | ||
}) | ||
} | ||
|
||
async function verifyMainnetContracts() { | ||
await verifyTokenContract() | ||
await verifyMarketplaceContract() | ||
} | ||
|
||
async function verifyTokenContract() { | ||
const accounts = await new Promise((resolve, reject) => { | ||
web3.eth.getAccounts((error, result) => { | ||
if (error) { | ||
reject(error) | ||
} | ||
resolve(result) | ||
}) | ||
}) | ||
const oldOwner = accounts[0] | ||
const token = await OriginToken.deployed() | ||
const marketplace = await V00_Marketplace.deployed() | ||
|
||
console.log('Validating token contract') | ||
|
||
assertEquals(await token.name(), 'OriginToken', 'name') | ||
assertEquals(await token.decimals(), 18, 'decimals') | ||
assertEquals(await token.symbol(), 'OGN', 'symbol') | ||
assertEquals( | ||
(await token.owner()).toLowerCase(), | ||
tokenMultiSig.toLowerCase(), | ||
'owner' | ||
) | ||
assertEquals(await token.paused(), false, 'not paused') | ||
assertEquals( | ||
await token.callSpenderWhitelist(marketplace.address), | ||
true, | ||
'marketplace whitelisted for approveAndCallWithSender' | ||
) | ||
assertEquals( | ||
await token.allowedTransactors(oldOwner), | ||
false, | ||
'old owner not allowed to transfer tokens' | ||
) | ||
assertEquals( | ||
await token.allowedTransactors(marketplace.address), | ||
true, | ||
'marketplace allowed to transfer tokens' | ||
) | ||
assertEquals( | ||
await token.allowedTransactors(tokenMultiSig), | ||
true, | ||
'multi-sig allowed to transfer tokens' | ||
) | ||
assertEquals( | ||
await token.allowedTransactors('0x7aD0fa0E2380a5e0208B25AC69216Bd7Ff206bF8'), | ||
true, | ||
'other wallet allowed to transfer tokens' | ||
) | ||
assertEquals( | ||
await token.whitelistExpiration(), | ||
Date.parse('28 Feb 2019 00:00:00 PST') / 1000, | ||
'whitelist expires on 2/28/2019' | ||
) | ||
} | ||
|
||
async function verifyMarketplaceContract() { | ||
const token = await OriginToken.deployed() | ||
const marketplace = await V00_Marketplace.deployed() | ||
|
||
console.log('Validating marketplace contract') | ||
|
||
assertEquals( | ||
await marketplace.tokenAddr(), | ||
token.address, | ||
'marketplace tokenAddr points to OriginToken' | ||
) | ||
assertEquals( | ||
await marketplace.owner(), | ||
marketplaceMultiSig, | ||
'marketplace contract owned by multi-sig' | ||
) | ||
assertEquals( | ||
await marketplace.allowedAffiliates(marketplace.address), | ||
false, | ||
'marketplace affiliate whitelist enabled' | ||
) | ||
assertEquals( | ||
await marketplace.allowedAffiliates('0x7aD0fa0E2380a5e0208B25AC69216Bd7Ff206bF8'), | ||
true, | ||
'marketplace affiliate address is whitelisted' | ||
) | ||
} | ||
|
||
function assertEquals(got, expected, message) { | ||
if (got != expected) { | ||
throw new Error(`${message}: contract value ${got} != expected ${expected}`) | ||
} | ||
console.log(` * ${message}: pass`) | ||
} |
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
49 changes: 49 additions & 0 deletions
49
contracts/migrations/9_transfer_ownership_and_tokens_for_mainnet.js
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,49 @@ | ||
const OriginToken = artifacts.require('./token/OriginToken.sol') | ||
const V00_Marketplace = artifacts.require('./V00_Marketplace.sol') | ||
|
||
// TODO: extract these addresses into a common file that can be imported from | ||
// the various places that require these addresses | ||
const tokenMultiSig = '0xe011fa2a6df98c69383457d87a056ed0103aa352' | ||
const marketplaceMultiSig = '0x8a1a4f77f9f0eb35fb9930696038be6220986c1b' | ||
|
||
module.exports = function(deployer, network) { | ||
return deployer.then(() => { | ||
if (network === 'mainnet' || process.env['SIMULATE_MAINNET']) { | ||
return transferTokensAndContractsToMultiSig() | ||
} | ||
}) | ||
} | ||
|
||
async function transferTokensAndContractsToMultiSig() { | ||
const accounts = await new Promise((resolve, reject) => { | ||
web3.eth.getAccounts((error, result) => { | ||
if (error) { | ||
reject(error) | ||
} | ||
resolve(result) | ||
}) | ||
}) | ||
const owner = accounts[0] | ||
const token = await OriginToken.deployed() | ||
|
||
// Transfer all tokens to multi-sig wallet. | ||
const balance = await token.balanceOf(owner) | ||
const decimals = await token.decimals() | ||
await token.transfer(tokenMultiSig, balance, { from: owner }) | ||
const balanceTokens = balance / 10**decimals | ||
console.log(`transferred ${balanceTokens} OGN to ${tokenMultiSig}`) | ||
|
||
// Contract owner is a throwaway account, so remove it from the transactor | ||
// whitelist. | ||
await token.removeAllowedTransactor(owner, { from: owner }) | ||
|
||
// Transfer token contract to multi-sig wallet. | ||
await token.transferOwnership(tokenMultiSig, { from: owner }) | ||
console.log(`token contract owner set to ${tokenMultiSig}`) | ||
|
||
// Transfer marketplace contract to multi-sig wallet. | ||
const marketplace = await V00_Marketplace.deployed() | ||
await marketplace.transferOwnership(marketplaceMultiSig, { from: owner }) | ||
console.log(`marketplace contract owner set to ${marketplaceMultiSig}`) | ||
} | ||
|
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