Skip to content

Commit 3c25e10

Browse files
committed
chore: fix deployments
1 parent a756b43 commit 3c25e10

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

cli/commands/migrate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let allContracts = [
2626
'ServiceRegistry',
2727
'Curation',
2828
'SubgraphNFTDescriptor',
29+
'SubgraphNFT',
2930
'GNS',
3031
'Staking',
3132
'RewardsManager',
@@ -58,6 +59,7 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
5859
const deployContracts = contractName ? [contractName] : allContracts
5960
const pendingContractCalls = []
6061

62+
// Deploy contracts
6163
logger.info(`>>> Contracts deployment\n`)
6264
for (const name of deployContracts) {
6365
// Get address book info
@@ -80,7 +82,7 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
8082
}
8183

8284
// Get config and deploy contract
83-
const contractConfig = getContractConfig(graphConfig, cli.addressBook, name)
85+
const contractConfig = getContractConfig(graphConfig, cli.addressBook, name, cli)
8486
const deployFn = contractConfig.proxy ? deployContractWithProxyAndSave : deployContractAndSave
8587
const contract = await deployFn(
8688
name,
@@ -113,7 +115,7 @@ export const migrate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
113115
cli.wallet,
114116
entry.contract,
115117
call.fn,
116-
loadCallParams(call.params, cli.addressBook),
118+
loadCallParams(call.params, cli.addressBook, cli),
117119
)
118120
}
119121
logger.info('')

cli/config.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'fs'
22
import YAML from 'yaml'
33

44
import { AddressBook } from './address-book'
5+
import { CLIEnvironment } from './env'
56

67
const ABRefMatcher = /\${{([A-Z]\w.+)}}/
78

@@ -14,9 +15,9 @@ interface ContractConfig {
1415
proxy: boolean
1516
}
1617

17-
function parseConfigValue(value: string, addressBook: AddressBook) {
18+
function parseConfigValue(value: string, addressBook: AddressBook, cli: CLIEnvironment) {
1819
if (isAddressBookRef(value)) {
19-
return parseAddressBookRef(addressBook, value)
20+
return parseAddressBookRef(addressBook, value, cli)
2021
}
2122
return value
2223
}
@@ -25,9 +26,16 @@ function isAddressBookRef(value: string): boolean {
2526
return ABRefMatcher.test(value)
2627
}
2728

28-
function parseAddressBookRef(addressBook: AddressBook, value: string): string {
29+
function parseAddressBookRef(addressBook: AddressBook, value: string, cli: CLIEnvironment): string {
2930
const ref: string = ABRefMatcher.exec(value as string)[1]
3031
const [contractName, contractAttr] = ref.split('.')
32+
// This is a convention to use the inject CLI-env variables into the config
33+
if (contractName === 'Env') {
34+
if (contractAttr == 'deployer') {
35+
return cli.walletAddress
36+
}
37+
throw new Error('Attribute not found in the CLI env')
38+
}
3139
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3240
const entry = addressBook.getEntry(contractName) as { [key: string]: any }
3341
return entry[contractAttr]
@@ -42,14 +50,16 @@ export function readConfig(path: string): any {
4250
export function loadCallParams(
4351
values: Array<ContractCallParam>,
4452
addressBook: AddressBook,
53+
cli: CLIEnvironment,
4554
): Array<ContractCallParam> {
46-
return values.map((value) => parseConfigValue(value as string, addressBook))
55+
return values.map((value) => parseConfigValue(value as string, addressBook, cli))
4756
}
4857

4958
export function getContractConfig(
5059
config: any,
5160
addressBook: AddressBook,
5261
name: string,
62+
cli: CLIEnvironment,
5363
): ContractConfig {
5464
const contractConfig = config.contracts[name] || {}
5565
const contractParams: Array<ContractParam> = []
@@ -62,7 +72,10 @@ export function getContractConfig(
6272
if (name.startsWith('init')) {
6373
const initList = Object.entries(contractConfig.init) as Array<Array<string>>
6474
for (const [initName, initValue] of initList) {
65-
contractParams.push({ name: initName, value: parseConfigValue(initValue, addressBook) } as {
75+
contractParams.push({
76+
name: initName,
77+
value: parseConfigValue(initValue, addressBook, cli),
78+
} as {
6679
name: string
6780
value: string
6881
})

graph.config.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
general:
2-
arbitrator: &arbitrator "0xE1FDD398329C6b74C14cf19100316f0826a492d3"
2+
arbitrator: &arbitrator "0xE1FDD398329C6b74C14cf19100316f0826a492d3" # Arbitration Council
33
governor: &governor "0x48301Fe520f72994d32eAd72E2B6A8447873CF50" # Graph Council
44
authority: &authority "0x79fd74da4c906509862c8fe93e87a9602e370bc4" # Authority that signs payment vouchers
55

@@ -41,7 +41,7 @@ contracts:
4141
initialSupply: "10000000000000000000000000000" # 10,000,000,000 GRT
4242
calls:
4343
- fn: "addMinter"
44-
minter: "${{RewardsManager.address}}"
44+
minter: "${{RewardsManager.address}}"
4545
Curation:
4646
proxy: true
4747
init:
@@ -65,9 +65,15 @@ contracts:
6565
init:
6666
controller: "${{Controller.address}}"
6767
bondingCurve: "${{BancorFormula.address}}"
68-
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
68+
subgraphNFT: "${{SubgraphNFT.address}}"
6969
calls:
7070
- fn: "approveAll"
71+
SubgraphNFT:
72+
init:
73+
governor: "${{Env.deployer}}"
74+
calls:
75+
- fn: "setTokenDescriptor"
76+
tokenDescriptor: "${{SubgraphNFTDescriptor.address}}"
7177
Staking:
7278
proxy: true
7379
init:

test/curation/curation.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ describe('Curation', () => {
546546
})
547547

548548
it('should mint when using the edge case of linear function', async function () {
549+
this.timeout(60000) // increase timeout for test runner
550+
549551
// Setup edge case like linear function: 1 GRT = 1 GCS
550552
await curation.setMinimumCurationDeposit(toGRT('1'))
551553
await curation.setDefaultReserveRatio(1000000)

0 commit comments

Comments
 (0)