Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mega truffle upgrade (no contract changes) #264

Merged
merged 2 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM trufflesuite/ganache-cli:v6.4.2
FROM trufflesuite/ganache-cli:v6.10.2
COPY ["localchaindb", "dockerLocalchaindb"]
65 changes: 44 additions & 21 deletions migrations/1000_initialSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SafeMathTester = artifacts.require("./test/SafeMathTester.sol");

const localTest_initialSetup = artifacts.require("./SB_scripts/localTest/localTest_initialSetup.sol");

module.exports = function(deployer) {
module.exports = function (deployer) {
deployer
.deploy(
localTest_initialSetup,
Expand All @@ -27,31 +27,54 @@ module.exports = function(deployer) {
Exchange.address,
SafeMathTester.address
)
.then(async initialSetupScript => {
.then(async (initialSetupScript) => {
// StabilityBoard permissions
const rates = Rates.at(Rates.address);
const feeAccount = FeeAccount.at(FeeAccount.address);
const interestEarnedAccount = InterestEarnedAccount.at(InterestEarnedAccount.address);
const tokenAEur = TokenAEur.at(TokenAEur.address);
const augmintReserves = AugmintReserves.at(AugmintReserves.address);
const monetarySupervisor = MonetarySupervisor.at(MonetarySupervisor.address);
const loanManager = LoanManager.at(LoanManager.address);
const locker = Locker.at(Locker.address);
const exchange = Exchange.at(Exchange.address);
const [
rates,
feeAccount,
interestEarnedAccount,
tokenAEur,
augmintReserves,
monetarySupervisor,
loanManager,
locker,
exchange,
stabilityBoardProxy,
] = await Promise.all([
Rates.at(Rates.address),
FeeAccount.at(FeeAccount.address),
InterestEarnedAccount.at(InterestEarnedAccount.address),
TokenAEur.at(TokenAEur.address),
AugmintReserves.at(AugmintReserves.address),
MonetarySupervisor.at(MonetarySupervisor.address),
LoanManager.at(LoanManager.address),
Locker.at(Locker.address),
Exchange.at(Exchange.address),
StabilityBoardProxy.at(StabilityBoardProxy.address),
]);

await Promise.all([
rates.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
feeAccount.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
interestEarnedAccount.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
tokenAEur.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
augmintReserves.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
monetarySupervisor.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
loanManager.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
locker.grantPermission(StabilityBoardProxy.address, "PermissionGranter"),
exchange.grantPermission(StabilityBoardProxy.address, "PermissionGranter")
rates.grantPermission(StabilityBoardProxy.address, web3.utils.asciiToHex("PermissionGranter")),
feeAccount.grantPermission(StabilityBoardProxy.address, web3.utils.asciiToHex("PermissionGranter")),
interestEarnedAccount.grantPermission(
StabilityBoardProxy.address,
web3.utils.asciiToHex("PermissionGranter")
),
tokenAEur.grantPermission(StabilityBoardProxy.address, web3.utils.asciiToHex("PermissionGranter")),
augmintReserves.grantPermission(
StabilityBoardProxy.address,
web3.utils.asciiToHex("PermissionGranter")
),
monetarySupervisor.grantPermission(
StabilityBoardProxy.address,
web3.utils.asciiToHex("PermissionGranter")
),
loanManager.grantPermission(StabilityBoardProxy.address, web3.utils.asciiToHex("PermissionGranter")),
locker.grantPermission(StabilityBoardProxy.address, web3.utils.asciiToHex("PermissionGranter")),
exchange.grantPermission(StabilityBoardProxy.address, web3.utils.asciiToHex("PermissionGranter")),
]);

// run initial setup script
const stabilityBoardProxy = StabilityBoardProxy.at(StabilityBoardProxy.address);
await stabilityBoardProxy.sign(initialSetupScript.address);
const tx = await stabilityBoardProxy.execute(initialSetupScript.address);

Expand Down
10 changes: 6 additions & 4 deletions migrations/1001_topup_interestEarnedAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ const TokenAEur = artifacts.require("./TokenAEur.sol");
const LoanManager = artifacts.require("./LoanManager.sol");
const InterestEarnedAccount = artifacts.require("./InterestEarnedAccount.sol");

module.exports = function(deployer) {
module.exports = function (deployer) {
deployer.then(async () => {
const tokenAEur = TokenAEur.at(TokenAEur.address);
const loanManager = LoanManager.at(LoanManager.address);
const [tokenAEur, loanManager] = await Promise.all([
TokenAEur.at(TokenAEur.address),
LoanManager.at(LoanManager.address),
]);

await loanManager.newEthBackedLoan(0, 0, { value: web3.toWei(0.10845) }); // = 50 A-EUR
await loanManager.newEthBackedLoan(0, 0, { value: web3.utils.toWei("0.10845") }); // = 50 A-EUR

await tokenAEur.transferWithNarrative(
InterestEarnedAccount.address,
Expand Down
47 changes: 29 additions & 18 deletions migrations/1002_authorise_StabilityBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,39 @@ const LoanManager = artifacts.require("./LoanManager.sol");
const Locker = artifacts.require("./Locker.sol");
const Exchange = artifacts.require("./Exchange.sol");

module.exports = function(deployer, network, accounts) {
module.exports = function (deployer, network, accounts) {
deployer.then(async () => {
const stabilityBoardAccounts = [accounts[0]];

const feeAccount = FeeAccount.at(FeeAccount.address);
const augmintReserves = AugmintReserves.at(AugmintReserves.address);
const tokenAEur = TokenAEur.at(TokenAEur.address);
const interestEarnedAccount = InterestEarnedAccount.at(InterestEarnedAccount.address);
const monetarySupervisor = MonetarySupervisor.at(MonetarySupervisor.address);
const loanManager = LoanManager.at(LoanManager.address);
const locker = Locker.at(Locker.address);
const exchange = Exchange.at(Exchange.address);
const [
feeAccount,
augmintReserves,
tokenAEur,
interestEarnedAccount,
monetarySupervisor,
loanManager,
locker,
exchange,
] = await Promise.all([
FeeAccount.at(FeeAccount.address),
AugmintReserves.at(AugmintReserves.address),
TokenAEur.at(TokenAEur.address),
InterestEarnedAccount.at(InterestEarnedAccount.address),
MonetarySupervisor.at(MonetarySupervisor.address),
LoanManager.at(LoanManager.address),
Locker.at(Locker.address),
Exchange.at(Exchange.address),
]);

const grantTxs = stabilityBoardAccounts.map(acc => [
feeAccount.grantPermission(acc, "StabilityBoard"),
augmintReserves.grantPermission(acc, "StabilityBoard"),
tokenAEur.grantPermission(acc, "StabilityBoard"),
interestEarnedAccount.grantPermission(acc, "StabilityBoard"),
monetarySupervisor.grantPermission(acc, "StabilityBoard"),
locker.grantPermission(acc, "StabilityBoard"),
loanManager.grantPermission(acc, "StabilityBoard"),
exchange.grantPermission(acc, "StabilityBoard")
const grantTxs = stabilityBoardAccounts.map((acc) => [
feeAccount.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
augmintReserves.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
tokenAEur.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
interestEarnedAccount.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
monetarySupervisor.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
locker.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
loanManager.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
exchange.grantPermission(acc, web3.utils.asciiToHex("StabilityBoard")),
]);

await Promise.all(grantTxs);
Expand Down
36 changes: 19 additions & 17 deletions migrations/1003_add_legacyContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const Locker = artifacts.require("./Locker.sol");
const LoanManager_1_0_12 = artifacts.require("./legacy/1.0.12/LoanManager_1_0_12.sol");
const Exchange = artifacts.require("./Exchange.sol");

module.exports = async function(deployer, network, accounts) {
module.exports = async function (deployer, network, accounts) {
deployer.then(async () => {
const monetarySupervisor = MonetarySupervisor.at(MonetarySupervisor.address);
const feeAccount = FeeAccount.at(FeeAccount.address);
const [monetarySupervisor, feeAccount] = await Promise.all([
MonetarySupervisor.at(MonetarySupervisor.address),
FeeAccount.at(FeeAccount.address),
]);

const oldToken = await TokenAEur.new(accounts[0], FeeAccount.address);

Expand All @@ -25,32 +27,32 @@ module.exports = async function(deployer, network, accounts) {
const oldExchange = await Exchange.new(accounts[0], oldToken.address, Rates.address);

await Promise.all([
oldLoanManager.grantPermission(accounts[0], "StabilityBoard"),
oldLocker.grantPermission(accounts[0], "StabilityBoard"),
oldExchange.grantPermission(accounts[0], "StabilityBoard")
oldLoanManager.grantPermission(accounts[0], web3.utils.asciiToHex("StabilityBoard")),
oldLocker.grantPermission(accounts[0], web3.utils.asciiToHex("StabilityBoard")),
oldExchange.grantPermission(accounts[0], web3.utils.asciiToHex("StabilityBoard")),
]);

await Promise.all([
oldToken.grantPermission(MonetarySupervisor.address, "MonetarySupervisor"),
oldToken.grantPermission(MonetarySupervisor.address, web3.utils.asciiToHex("MonetarySupervisor")),

monetarySupervisor.setAcceptedLegacyAugmintToken(oldToken.address, true),

oldToken.grantPermission(accounts[0], "MonetarySupervisor"), // "hack" for test to issue
oldToken.grantPermission(accounts[0], web3.utils.asciiToHex("MonetarySupervisor")), // "hack" for test to issue

/* Locker permissions & products */
monetarySupervisor.grantPermission(oldLocker.address, "Locker"),
feeAccount.grantPermission(oldLocker.address, "NoTransferFee"),
monetarySupervisor.grantPermission(oldLocker.address, web3.utils.asciiToHex("Locker")),
feeAccount.grantPermission(oldLocker.address, web3.utils.asciiToHex("NoTransferFee")),
oldLocker.addLockProduct(80001, 31536000, 1000, true), // 365 days, 8% p.a.
oldLocker.addLockProduct(1, 60, 1000, true), // 1 minute for testing, ~69.15% p.a.

/* LoanManager permissions & products */
monetarySupervisor.grantPermission(oldLoanManager.address, "LoanManager"),
feeAccount.grantPermission(oldLoanManager.address, "NoTransferFee"),
monetarySupervisor.grantPermission(oldLoanManager.address, web3.utils.asciiToHex("LoanManager")),
feeAccount.grantPermission(oldLoanManager.address, web3.utils.asciiToHex("NoTransferFee")),
oldLoanManager.addLoanProduct(1, 999999, 990000, 1000, 50000, true), // defaults in 1 secs for testing ? p.a.
oldLoanManager.addLoanProduct(3600, 999989, 980000, 1000, 50000, true), // due in 1hr for testing repayments ? p.a.
oldLoanManager.addLoanProduct(31536000, 860000, 550000, 1000, 50000, true), // 365d, 14% p.a.
/* Exchange permissions */
feeAccount.grantPermission(oldExchange.address, "NoTransferFee")
feeAccount.grantPermission(oldExchange.address, web3.utils.asciiToHex("NoTransferFee")),
]);

await oldToken.issueTo(accounts[0], 20000); // issue some to account 0
Expand All @@ -59,12 +61,12 @@ module.exports = async function(deployer, network, accounts) {
oldToken.transferAndNotify(oldLocker.address, 1500, 0),
oldToken.transferAndNotify(oldLocker.address, 1600, 1),

oldLoanManager.newEthBackedLoan(0, { value: web3.toWei(0.1) }),
oldLoanManager.newEthBackedLoan(2, { value: web3.toWei(0.2) }),
oldLoanManager.newEthBackedLoan(0, { value: web3.utils.toWei("0.1") }),
oldLoanManager.newEthBackedLoan(2, { value: web3.utils.toWei("0.2") }),
oldToken.transferAndNotify(oldExchange.address, 2000, 1010000),
oldToken.transferAndNotify(oldExchange.address, 1100, 980000),
oldExchange.placeBuyTokenOrder(990000, { value: web3.toWei(0.01) }),
oldExchange.placeBuyTokenOrder(1020000, { value: web3.toWei(0.011) })
oldExchange.placeBuyTokenOrder(990000, { value: web3.utils.toWei("0.01") }),
oldExchange.placeBuyTokenOrder(1020000, { value: web3.utils.toWei("0.011") }),
]);

console.log(
Expand Down
12 changes: 6 additions & 6 deletions migrations/1004_add_test_preTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
\ */
const PreToken = artifacts.require("./PreToken.sol");

module.exports = function(deployer, network, accounts) {
module.exports = function (deployer, network, accounts) {
deployer.then(async () => {
const preToken = PreToken.at(PreToken.address);
await preToken.grantPermission(accounts[0], "PreTokenSigner"); // only on local test to allow issuance w/o MultiSig
const preToken = await PreToken.at(PreToken.address);
await preToken.grantPermission(accounts[0], web3.utils.asciiToHex("PreTokenSigner")); // only on local test to allow issuance w/o MultiSig
const AC0_AGREEMENT = "0xa100000000000000000000000000000000000000000000000000000000000001";
const AC1_AGREEMENT = "0xa200000000000000000000000000000000000000000000000000000000000002";
await Promise.all([
// addAgreement(owner, agreementHash, discount, valuationCap)
preToken.addAgreement(accounts[0], AC0_AGREEMENT, 800000, 30000000),
preToken.addAgreement(accounts[1], AC1_AGREEMENT, 850000, 40000000)
preToken.addAgreement(accounts[1], AC1_AGREEMENT, 850000, 40000000),
]);

await Promise.all([
preToken.issueTo(AC0_AGREEMENT, 10000),
preToken.issueTo(AC0_AGREEMENT, 9000),
preToken.issueTo(AC0_AGREEMENT, 8000),
preToken.issueTo(AC1_AGREEMENT, 7000)
preToken.issueTo(AC1_AGREEMENT, 7000),
]);

await Promise.all([
preToken.transfer(accounts[2], 7000, { from: accounts[1] }),
preToken.burnFrom(AC0_AGREEMENT, 1000)
preToken.burnFrom(AC0_AGREEMENT, 1000),
]);
});
};
8 changes: 4 additions & 4 deletions migrations/2000_setRateDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// run it with: "truffle migrate -f 2000 --to 2000" or "setrate:default"

const Rates = artifacts.require("./Rates.sol");
const newRate = 99800;
const newRate = "99800";

module.exports = function(deployer) {
module.exports = function (deployer) {
deployer.then(async () => {
const rates = Rates.at(Rates.address);
await rates.setRate("EUR", newRate);
const rates = await Rates.at(Rates.address);
await rates.setRate(web3.utils.asciiToHex("EUR"), newRate);
});
};
8 changes: 4 additions & 4 deletions migrations/2001_setRateLow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// run it with: "truffle migrate -f 2001 --to 2001" or "setrate:low"

const Rates = artifacts.require("./Rates.sol");
const newRate = 42500;
const newRate = "42500";

module.exports = function(deployer) {
module.exports = function (deployer) {
deployer.then(async () => {
const rates = Rates.at(Rates.address);
await rates.setRate("EUR", newRate);
const rates = await Rates.at(Rates.address);
await rates.setRate(web3.utils.asciiToHex("EUR"), newRate);
});
};
8 changes: 4 additions & 4 deletions migrations/2002_setRateHigh.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// run it with: "truffle migrate -f 2002 --to 2002" or "setrate:high"

const Rates = artifacts.require("./Rates.sol");
const newRate = 225000;
const newRate = "225000";

module.exports = function(deployer) {
module.exports = function (deployer) {
deployer.then(async () => {
const rates = Rates.at(Rates.address);
await rates.setRate("EUR", newRate);
const rates = await Rates.at(Rates.address);
await rates.setRate(web3.utils.asciiToHex("EUR"), newRate);
});
};
24 changes: 24 additions & 0 deletions migrations_null/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": ['eslint:recommended'],
"parserOptions": {
"ecmaVersion": 2017,
},
"env": {
"mocha": true,
"node": true,
"es6": true
},
"rules": {
"indent": ["warn", 4],
max-len: "off",
radix: "off",
no-unused-vars: "warn",
"no-console": "off"
},
"globals": {
"web3": false,
"assert": false,
"artifacts": false,
"contract": false
}
}
4 changes: 4 additions & 0 deletions migrations_null/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"tabWidth": 4
}
4 changes: 3 additions & 1 deletion migrations_null/.readme
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
An empty dir to speed up test by avoiding migrations running unnecessarily again
when yarn test runing on ganache docker container which already have all contracts
when ganache has all the contracts already (eg. yarn test running on ganache docker container)
This dir is set by default in truffle-config.js and --migrations_directory flag is used to override it
in packages.json scripts
see: https://ethereum.stackexchange.com/a/62918/7866
3 changes: 3 additions & 0 deletions migrations_null/1_no_migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (deployer) {
console.log("Skipping truffle migrations (migrations_null directory set)");
};
Loading