Skip to content

Commit de861b8

Browse files
authored
build: update migrate config to avoid conflict and improve logging (#257)
1 parent 469ad20 commit de861b8

File tree

6 files changed

+59
-45
lines changed

6 files changed

+59
-45
lines changed

graph.config.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,38 @@ general:
44

55
contracts:
66
Curation:
7-
token: "${{GraphToken.address}}"
8-
reserveRatio: 500000 # 50% bonding curve reserve ratio parameter
9-
minimumCurationStake: "100000000000000000000" # 100 GRT
10-
__proxy: true
11-
__calls:
7+
init:
8+
token: "${{GraphToken.address}}"
9+
reserveRatio: 500000 # 50% bonding curve reserve ratio parameter
10+
minimumCurationStake: "100000000000000000000" # 100 GRT
11+
proxy: true
12+
calls:
1213
- fn: "setWithdrawalFeePercentage"
1314
withdrawalFeePercentage: 50000 # 5% fee for redeeming signal
1415
DisputeManager:
15-
arbitrator: *arbitrator
16-
token: "${{GraphToken.address}}"
17-
staking: "${{Staking.address}}"
18-
minimumDeposit: "100000000000000000000" # 100 GRT
19-
fishermanRewardPercentage: 100000 # in basis points
20-
slashingPercentage: 50000 # in basis points
16+
init:
17+
arbitrator: *arbitrator
18+
token: "${{GraphToken.address}}"
19+
staking: "${{Staking.address}}"
20+
minimumDeposit: "100000000000000000000" # 100 GRT
21+
fishermanRewardPercentage: 100000 # in basis points
22+
slashingPercentage: 50000 # in basis points
2123
EpochManager:
22-
lengthInBlocks: 5760 # One day in blocks
23-
__proxy: true
24+
init:
25+
lengthInBlocks: 5760 # One day in blocks
26+
proxy: true
2427
GNS:
25-
didRegistry: "0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"
28+
init:
29+
didRegistry: "0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"
2630
GraphToken:
27-
initialSupply: "10000000000000000000000000" # 10000000 GRT
31+
init:
32+
initialSupply: "10000000000000000000000000" # 10000000 GRT
2833
Staking:
29-
token: "${{GraphToken.address}}"
30-
epochManager: "${{EpochManager.address}}"
31-
__proxy: true
32-
__calls:
34+
init:
35+
token: "${{GraphToken.address}}"
36+
epochManager: "${{EpochManager.address}}"
37+
proxy: true
38+
calls:
3339
- fn: "setCuration"
3440
curation: "${{Curation.address}}"
3541
- fn: "setChannelDisputeEpochs"
@@ -39,9 +45,10 @@ contracts:
3945
- fn: "setThawingPeriod"
4046
thawingPeriod: 20 # in blocks
4147
MinimumViableMultisig:
42-
node: *nodeSignerAddress
43-
staking: "${{Staking.address}}"
44-
CTDT: "${{IndexerCTDT.address}}"
45-
singleAssetInterpreter: "${{IndexerSingleAssetInterpreter.address}}"
46-
multiAssetInterpreter: "${{IndexerMultiAssetInterpreter.address}}"
47-
withdrawInterpreter: "${{IndexerWithdrawInterpreter.address}}"
48+
init:
49+
node: *nodeSignerAddress
50+
staking: "${{Staking.address}}"
51+
CTDT: "${{IndexerCTDT.address}}"
52+
singleAssetInterpreter: "${{IndexerSingleAssetInterpreter.address}}"
53+
multiAssetInterpreter: "${{IndexerMultiAssetInterpreter.address}}"
54+
withdrawInterpreter: "${{IndexerWithdrawInterpreter.address}}"

scripts/cli/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const deploy = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<voi
1212
const contractName = cliArgs.contract
1313
const initArgs = cliArgs.init
1414

15-
logger.info(`Deploying contract ${contractName}...`)
15+
logger.log(`Deploying contract ${contractName}...`)
1616

1717
// Deploy contract
1818
const contractArgs = initArgs ? initArgs.split(',') : []

scripts/cli/commands/migrate.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
3939
const force = cliArgs.force
4040
const contractName = cliArgs.contract
4141

42-
logger.info(`Migrating contracts...`)
42+
logger.log(`>>> Migrating contracts <<<\n`)
4343

4444
const graphConfig = readConfig(graphConfigPath)
4545

@@ -54,13 +54,13 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
5454
const deployContracts = contractName ? [contractName] : allContracts
5555
const pendingContractCalls = []
5656

57-
logger.log(`== Contracts deployment\n`)
57+
logger.log(`>>> Contracts deployment\n`)
5858
for (const name of deployContracts) {
5959
// Get address book info
6060
const addressEntry = cli.addressBook.getEntry(name)
6161
const savedAddress = addressEntry && addressEntry.address
6262

63-
logger.info(`Deploying ${name}...`)
63+
logger.info(`[Deploying ${name}]`)
6464

6565
// Check if contract already deployed
6666
const isDeployed = await isContractDeployed(
@@ -70,7 +70,7 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
7070
cli.wallet.provider,
7171
)
7272
if (!force && isDeployed) {
73-
logger.info(`${name} is up to date, no action required`)
73+
logger.log(`${name} is up to date, no action required`)
7474
logger.log(`Address: ${savedAddress}\n`)
7575
continue
7676
}
@@ -98,12 +98,12 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
9898
// Run contracts calls
9999

100100
logger.log('')
101-
logger.log(`== Contracts calls\n`)
101+
logger.log(`>>> Contracts calls\n`)
102102
if (pendingContractCalls.length > 0) {
103103
for (const entry of pendingContractCalls) {
104104
if (entry.calls.length == 0) continue
105105

106-
logger.info(`Configuring ${entry.name}...`)
106+
logger.info(`[Configuring ${entry.name}]`)
107107
for (const call of entry.calls) {
108108
await sendTransaction(cli.wallet, entry.contract, call.fn, ...call.params)
109109
}
@@ -116,7 +116,7 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
116116
////////////////////////////////////////
117117
// Print summary
118118
logger.log('')
119-
logger.log(`== Summary\n`)
119+
logger.log(`>>> Summary\n`)
120120
logger.success('All done!')
121121
const spent = formatEther(cli.balance.sub(await cli.wallet.getBalance()))
122122
const nTx = (await cli.wallet.getTransactionCount()) - cli.nonce

scripts/cli/commands/upgrade.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const upgrade = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
1313
const implAddress = cliArgs.impl
1414
const initArgs = cliArgs.init
1515

16-
logger.info(`Upgrading contract ${contractName}...`)
16+
logger.log(`Upgrading contract ${contractName}...`)
1717

1818
// Get address book info
1919
const addressEntry = cli.addressBook.getEntry(contractName)

scripts/cli/commands/verify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const coreContracts = [
2424
const logger = consola.create({})
2525

2626
export const verify = async (cli: CLIEnvironment): Promise<void> => {
27-
logger.info(`Verifying contracts for chainId ${cli.chainId}...`)
27+
logger.log(`Verifying contracts for chainId ${cli.chainId}...`)
2828

2929
for (const contractName of coreContracts) {
3030
const contract = cli.addressBook.getEntry(contractName)

scripts/cli/config.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,23 @@ export function getContractConfig(
4747
const contractCalls: ContractCalls = []
4848
let proxy = false
4949

50-
for (const [name, value] of Object.entries(contractConfig) as Array<Array<string>>) {
50+
const optsList = Object.entries(contractConfig) as Array<Array<string>>
51+
for (const [name, value] of optsList) {
52+
// Process constructor params
53+
if (name.startsWith('init')) {
54+
const initList = Object.entries(contractConfig.init) as Array<Array<string>>
55+
for (const [initName, initValue] of initList) {
56+
contractParams.push({ name: initName, value: parseConfigValue(initValue, addressBook) } as {
57+
name: string
58+
value: string
59+
})
60+
}
61+
continue
62+
}
63+
5164
// Process contract calls
52-
if (name.startsWith('__calls')) {
53-
for (const entry of contractConfig.__calls) {
65+
if (name.startsWith('calls')) {
66+
for (const entry of contractConfig.calls) {
5467
const fn = entry['fn']
5568
const params = Object.entries(entry)
5669
.slice(1) // skip fn
@@ -61,16 +74,10 @@ export function getContractConfig(
6174
}
6275

6376
// Process proxy
64-
if (name.startsWith('__proxy')) {
77+
if (name.startsWith('proxy')) {
6578
proxy = Boolean(value)
6679
continue
6780
}
68-
69-
// Process constructor params
70-
contractParams.push({ name, value: parseConfigValue(value, addressBook) } as {
71-
name: string
72-
value: string
73-
})
7481
}
7582

7683
return {

0 commit comments

Comments
 (0)