Skip to content

Commit 20ed976

Browse files
[protocol3.6] migration scripts refine (#1744)
1 parent 12a1a97 commit 20ed976

File tree

12 files changed

+194
-327
lines changed

12 files changed

+194
-327
lines changed

packages/hebao_v1/migrations/10_summary.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,42 @@ const WalletFactory = artifacts.require("WalletFactory");
1111
const FinalCoreModule = artifacts.require("FinalCoreModule");
1212
const FinalSecurityModule = artifacts.require("FinalSecurityModule");
1313
const FinalTransferModule = artifacts.require("FinalTransferModule");
14+
const AddOfficialGuardianModule = artifacts.require(
15+
"AddOfficialGuardianModule"
16+
);
1417

1518
const DappAddressStore = artifacts.require("DappAddressStore");
1619
const HashStore = artifacts.require("HashStore");
1720
const NonceStore = artifacts.require("NonceStore");
1821
const QuotaStore = artifacts.require("QuotaStore");
1922
const SecurityStore = artifacts.require("SecurityStore");
2023
const WhitelistStore = artifacts.require("WhitelistStore");
24+
const OfficialGuardian = artifacts.require("OfficialGuardian");
2125

2226
module.exports = function(deployer, network, accounts) {
23-
console.log("SignedRequest", SignedRequest.address);
24-
console.log("WalletRegistryImpl", WalletRegistryImpl.address);
25-
console.log("ModuleRegistryImpl", ModuleRegistryImpl.address);
26-
console.log("FinalCoreModule", FinalCoreModule.address);
27-
console.log("ControllerImpl", ControllerImpl.address);
28-
console.log("WalletImpl", WalletImpl.address);
29-
console.log("WalletFactory", WalletFactory.address);
30-
console.log("FinalSecurityModule", FinalSecurityModule.address);
31-
console.log("FinalTransferModule", FinalTransferModule.address);
32-
console.log("DappAddressStore", DappAddressStore.address);
33-
console.log("HashStore", HashStore.address);
34-
console.log("NonceStore", NonceStore.address);
35-
console.log("QuotaStore", QuotaStore.address);
36-
console.log("SecurityStore", SecurityStore.address);
37-
console.log("WhitelistStore", WhitelistStore.address);
27+
let ensManagerAddr = process.env.ENSManager || "";
28+
if (!web3.utils.isAddress(ensManagerAddr.toLowerCase())) {
29+
ensManagerAddr = BaseENSManager.address;
30+
}
31+
console.log("- ensManagerAddr:", ensManagerAddr);
32+
console.log("- SignedRequest:", SignedRequest.address);
33+
console.log("- WalletRegistryImpl:", WalletRegistryImpl.address);
34+
console.log("- ModuleRegistryImpl:", ModuleRegistryImpl.address);
35+
console.log("- ControllerImpl:", ControllerImpl.address);
36+
console.log("- WalletImpl:", WalletImpl.address);
37+
console.log("- WalletFactory:", WalletFactory.address);
38+
console.log("- DappAddressStore:", DappAddressStore.address);
39+
console.log("- HashStore:", HashStore.address);
40+
console.log("- NonceStore:", NonceStore.address);
41+
console.log("- QuotaStore:", QuotaStore.address);
42+
console.log("- SecurityStore:", SecurityStore.address);
43+
console.log("- WhitelistStore:", WhitelistStore.address);
44+
console.log("- OfficialGuardian:", OfficialGuardian.address);
45+
console.log("- FinalCoreModule:", FinalCoreModule.address);
46+
console.log("- FinalSecurityModule:", FinalSecurityModule.address);
47+
console.log("- FinalTransferModule:", FinalTransferModule.address);
48+
console.log(
49+
"- AddOfficialGuardianModule:",
50+
AddOfficialGuardianModule.address
51+
);
3852
};

packages/hebao_v1/migrations/4_deploy_tokens.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ module.exports = function(deployer, network, accounts) {
1414
network != "goerli" &&
1515
network != "goerli-fork"
1616
) {
17-
deployer.then(() => {
18-
return Promise.all([
19-
deployer.deploy(GTOToken),
20-
deployer.deploy(INDAToken),
21-
deployer.deploy(INDBToken),
22-
deployer.deploy(LRCToken),
23-
deployer.deploy(RDNToken),
24-
deployer.deploy(REPToken),
25-
deployer.deploy(WETHToken)
26-
]);
17+
deployer.then(async () => {
18+
await deployer.deploy(GTOToken);
19+
await deployer.deploy(INDAToken);
20+
await deployer.deploy(INDBToken);
21+
await deployer.deploy(LRCToken);
22+
await deployer.deploy(RDNToken);
23+
await deployer.deploy(REPToken);
24+
await deployer.deploy(WETHToken);
2725
});
2826
}
2927
};

packages/hebao_v1/migrations/9_modules.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ const BaseENSManager = artifacts.require("BaseENSManager");
77
const ControllerImpl = artifacts.require("ControllerImpl");
88
const WalletImpl = artifacts.require("WalletImpl");
99

10+
const OfficialGuardian = artifacts.require("OfficialGuardian");
11+
1012
const WalletFactory = artifacts.require("WalletFactory");
1113
const FinalCoreModule = artifacts.require("FinalCoreModule");
1214
const FinalSecurityModule = artifacts.require("FinalSecurityModule");
1315
const FinalTransferModule = artifacts.require("FinalTransferModule");
16+
const AddOfficialGuardianModule = artifacts.require(
17+
"AddOfficialGuardianModule"
18+
);
1419

1520
module.exports = function(deployer, network, accounts) {
1621
const guardianPendingPeriod =
@@ -26,6 +31,8 @@ module.exports = function(deployer, network, accounts) {
2631
const ensManagerAddr = process.env.ENSManager || "";
2732

2833
deployer.then(async () => {
34+
await deployer.deploy(OfficialGuardian);
35+
2936
const dest = [FinalCoreModule, FinalSecurityModule, FinalTransferModule];
3037
await deployer.link(SignedRequest, dest);
3138
await deployer.deploy(FinalCoreModule, ControllerImpl.address);
@@ -44,6 +51,13 @@ module.exports = function(deployer, network, accounts) {
4451
quotaDelayPeriod
4552
);
4653

54+
await deployer.deploy(
55+
AddOfficialGuardianModule,
56+
ControllerImpl.address,
57+
OfficialGuardian.address,
58+
11
59+
);
60+
4761
const moduleRegistry = await ModuleRegistryImpl.deployed();
4862
const walletRegistry = await WalletRegistryImpl.deployed();
4963
const walletFactory = await WalletFactory.deployed();
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
var Migrations = artifacts.require("Migrations");
22

33
module.exports = function(deployer, network, accounts) {
4-
console.log("deploying to network: " + network);
5-
deployer
6-
.then(() => {
7-
return Promise.all([deployer.deploy(Migrations)]);
8-
})
9-
.then(() => {
10-
console.log(">>>>>>>> contracts deployed by initial_migration:");
11-
console.log("Migrations:", Migrations.address);
12-
console.log("");
13-
});
4+
deployer.then(async () => {
5+
await deployer.deploy(Migrations);
6+
});
147
};

packages/loopring_v3/migrations/2_deploy_thirdparty.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,8 @@ const Cloneable = artifacts.require("Cloneable");
22
const BatchVerifier = artifacts.require("BatchVerifier");
33

44
module.exports = function(deployer, network, accounts) {
5-
console.log("deploying to network: " + network);
6-
var deployer_ = deployer;
7-
8-
// common deployment
9-
10-
deployer_
11-
.then(() => {
12-
return Promise.all([
13-
deployer.deploy(Cloneable),
14-
deployer.deploy(BatchVerifier)
15-
]);
16-
})
17-
.then(() => {
18-
console.log(">>>>>>>> contracts deployed by deploy_thirdparty:");
19-
console.log("Cloneable:", Cloneable.address);
20-
console.log("BatchVerifier:", BatchVerifier.address);
21-
console.log("");
22-
});
5+
deployer.then(async () => {
6+
await deployer.deploy(Cloneable);
7+
await deployer.deploy(BatchVerifier);
8+
});
239
};
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
// Deploy tokens for testing purposes
22

3-
module.exports = function(deployer, network, accounts) {
4-
console.log("deploying to network: " + network);
5-
6-
if (network != "live" && network != "live-fork") {
7-
const LRCToken = artifacts.require("./test/tokens/LRC.sol");
8-
const GTOToken = artifacts.require("./test/tokens/GTO.sol");
9-
const RDNToken = artifacts.require("./test/tokens/RDN.sol");
10-
const REPToken = artifacts.require("./test/tokens/REP.sol");
11-
const WETHToken = artifacts.require("./test/tokens/WETH.sol");
12-
const TESTToken = artifacts.require("./test/tokens/TEST.sol");
13-
const INDAToken = artifacts.require("./test/tokens/INDA.sol");
14-
const INDBToken = artifacts.require("./test/tokens/INDB.sol");
3+
const LRCToken = artifacts.require("./test/tokens/LRC.sol");
4+
const GTOToken = artifacts.require("./test/tokens/GTO.sol");
5+
const RDNToken = artifacts.require("./test/tokens/RDN.sol");
6+
const REPToken = artifacts.require("./test/tokens/REP.sol");
7+
const WETHToken = artifacts.require("./test/tokens/WETH.sol");
8+
const TESTToken = artifacts.require("./test/tokens/TEST.sol");
9+
const INDAToken = artifacts.require("./test/tokens/INDA.sol");
10+
const INDBToken = artifacts.require("./test/tokens/INDB.sol");
1511

16-
deployer.deploy(LRCToken);
17-
deployer.deploy(GTOToken);
18-
deployer.deploy(RDNToken);
19-
deployer.deploy(REPToken);
20-
deployer.deploy(WETHToken);
21-
deployer.deploy(TESTToken);
22-
deployer.deploy(INDAToken);
23-
deployer.deploy(INDBToken);
12+
module.exports = function(deployer, network, accounts) {
13+
if (
14+
network != "live" &&
15+
network != "live-fork" &&
16+
network != "goerli" &&
17+
network != "goerli-fork"
18+
) {
19+
deployer.then(async () => {
20+
await deployer.deploy(LRCToken);
21+
await deployer.deploy(GTOToken);
22+
await deployer.deploy(RDNToken);
23+
await deployer.deploy(REPToken);
24+
await deployer.deploy(WETHToken);
25+
await deployer.deploy(TESTToken);
26+
await deployer.deploy(INDAToken);
27+
await deployer.deploy(INDBToken);
28+
});
2429
}
2530
};
Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,15 @@
11
// Deploy UniversalRegistry
2-
3-
var lrcAddress = "0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD";
2+
const LRCToken = artifacts.require("LRC");
3+
const UniversalRegistry = artifacts.require("UniversalRegistry");
44

55
module.exports = function(deployer, network, accounts) {
6-
console.log("deploying to network: " + network);
7-
var deployer_ = deployer;
6+
let lrcAddress = "0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD";
87

98
if (network != "live" && network != "live-fork") {
10-
const LRCToken = artifacts.require("./test/tokens/LRC.sol");
11-
const WETHToken = artifacts.require("./test/tokens/WETH.sol");
12-
13-
deployer_.then(() => {
14-
return Promise.all([
15-
LRCToken.deployed().then(c => {
16-
lrcAddress = c.address;
17-
})
18-
]);
19-
});
9+
lrcAddress = LRCToken.address;
2010
}
2111

22-
// common deployment
23-
24-
const UniversalRegistry = artifacts.require("UniversalRegistry");
25-
26-
deployer_
27-
.then(() => {
28-
return Promise.all([deployer.deploy(UniversalRegistry, lrcAddress)]);
29-
})
30-
.then(() => {
31-
console.log(">>>>>>>> contracts deployed by deploy_registry:");
32-
console.log("lrcAddress:", lrcAddress);
33-
console.log("UniversalRegistry:", UniversalRegistry.address);
34-
console.log("");
35-
});
12+
deployer.then(async () => {
13+
await deployer.deploy(UniversalRegistry, lrcAddress);
14+
});
3615
};

packages/loopring_v3/migrations/5_deploy_auxiliaries.js

Lines changed: 11 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,21 @@
22
// or UniversalRegistry.
33

44
const ProtocolFeeVault = artifacts.require("ProtocolFeeVault");
5-
6-
var UniswapTokenSeller = artifacts.require("UniswapTokenSeller");
7-
var lrcAddress = "0xBBbbCA6A901c926F240b89EacB641d8Aec7AEafD";
8-
var protocolFeeValutAddress = "0xa8b6A3EFBcdd578154a913F33dc9949808B7A9f4";
9-
var userStakingPoolAddress = "[undeployed]";
10-
var uniswapTokenSellerAddress = "[undeployed]";
5+
const UserStakingPool = artifacts.require("UserStakingPool");
6+
const UniswapTokenSeller = artifacts.require("UniswapTokenSeller");
7+
const BatchVerifier = artifacts.require("BatchVerifier");
8+
const BlockVerifier = artifacts.require("BlockVerifier");
9+
const LRCToken = artifacts.require("./test/tokens/LRC.sol");
10+
const WETHToken = artifacts.require("./test/tokens/WETH.sol");
1111

1212
module.exports = function(deployer, network, accounts) {
13-
console.log("deploying to network: " + network);
14-
var deployer_ = deployer;
15-
1613
if (network != "live" && network != "live-fork") {
17-
const LRCToken = artifacts.require("./test/tokens/LRC.sol");
18-
const WETHToken = artifacts.require("./test/tokens/WETH.sol");
19-
20-
deployer_ = deployer_
21-
.then(() => {
22-
return Promise.all([
23-
LRCToken.deployed().then(c => {
24-
lrcAddress = c.address;
25-
})
26-
]);
27-
})
28-
.then(() => {
29-
const UserStakingPool = artifacts.require("UserStakingPool");
30-
return Promise.all([
31-
deployer.deploy(UserStakingPool, lrcAddress).then(c => {
32-
userStakingPoolAddress = c.address;
33-
})
34-
]);
35-
})
36-
.then(() => {
37-
return Promise.all([
38-
deployer.deploy(ProtocolFeeVault, lrcAddress).then(c => {
39-
protocolFeeValutAddress = c.address;
40-
})
41-
]);
42-
});
43-
}
14+
deployer.then(async () => {
15+
await deployer.deploy(UserStakingPool, LRCToken.address);
16+
await deployer.deploy(ProtocolFeeVault, LRCToken.address);
4417

45-
if (network === "live" || network === "rinkeby") {
46-
const factoryAddress =
47-
network === "live"
48-
? "0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95"
49-
: "0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36";
50-
51-
deployer_.then(() => {
52-
return Promise.all([
53-
deployer
54-
.deploy(UniswapTokenSeller, factoryAddress, protocolFeeValutAddress)
55-
.then(c => {
56-
uniswapTokenSellerAddress = c.address;
57-
})
58-
]);
18+
await deployer.link(BatchVerifier, BlockVerifier);
19+
await deployer.deploy(BlockVerifier);
5920
});
6021
}
61-
62-
const BatchVerifier = artifacts.require("BatchVerifier");
63-
const BlockVerifier = artifacts.require("BlockVerifier");
64-
65-
deployer_
66-
.then(() => {
67-
return Promise.all([BatchVerifier.deployed()]);
68-
})
69-
.then(() => {
70-
return Promise.all([deployer.link(BatchVerifier, BlockVerifier)]);
71-
})
72-
.then(() => {
73-
return Promise.all([deployer.deploy(BlockVerifier)]);
74-
})
75-
.then(() => {
76-
console.log(">>>>>>>> contracts deployed by deploy_aux:");
77-
console.log("lrcAddress:", lrcAddress);
78-
console.log("protocolFeeValutAddress:", protocolFeeValutAddress);
79-
console.log("userStakingPoolAddress:", userStakingPoolAddress);
80-
console.log("uniswapTokenSellerAddress:", uniswapTokenSellerAddress);
81-
console.log("BlockVerifier:", BlockVerifier.address);
82-
console.log("");
83-
});
8422
};

0 commit comments

Comments
 (0)