Skip to content

Commit

Permalink
feat: optionally override address book
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Nov 14, 2023
1 parent 3743257 commit 05d5547
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/indexer-agent/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ export const start = {
default: true,
group: 'Cost Models',
})
.option('address-book', {
description: 'Graph contracts address book file path',
type: 'string',
required: false,
})
.option('dai-contract', {
description:
'Address of the DAI or USDC contract to use for the --inject-dai conversion rate',
Expand Down Expand Up @@ -421,6 +426,7 @@ export async function createNetworkSpecification(
transactionMonitoring,
subgraphs,
networkProvider,
addressBook: argv.addressBook,
dai,
})
} catch (parsingError) {
Expand Down
1 change: 1 addition & 0 deletions packages/indexer-common/src/network-specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const NetworkSpecification = z
transactionMonitoring: TransactionMonitoring,
subgraphs: ProtocolSubgraphs,
networkProvider: NetworkProvider,
addressBook: z.string().optional(),
dai: Dai,
})
.strict()
Expand Down
4 changes: 3 additions & 1 deletion packages/indexer-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class Network {
wallet,
specification.networkIdentifier,
logger,
specification.addressBook,
)

// * -----------------------------------------------------------------------
Expand Down Expand Up @@ -436,6 +437,7 @@ async function connectToProtocolContracts(
wallet: Wallet,
networkIdentifier: string,
logger: Logger,
addressBook?: string,
): Promise<NetworkContracts> {
const numericNetworkId = parseInt(networkIdentifier.split(':')[1])

Expand All @@ -450,7 +452,7 @@ async function connectToProtocolContracts(

let contracts
try {
contracts = await connectContracts(wallet, numericNetworkId)
contracts = await connectContracts(wallet, numericNetworkId, addressBook)
} catch (error) {
const errorMessage =
'Failed to connect to contracts, please ensure you are using the intended protocol network.'
Expand Down
11 changes: 10 additions & 1 deletion packages/indexer-service/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ export default {
default: DEFAULT_SUBGRAPH_FRESHNESS_SLEEP_MILLISECONDS,
group: 'Protocol',
})
.option('address-book', {
description: 'Graph contracts address book file path',
type: 'string',
required: false,
})

.check(argv => {
if (!argv['network-subgraph-endpoint'] && !argv['network-subgraph-deployment']) {
Expand Down Expand Up @@ -393,7 +398,11 @@ export default {

let contracts = undefined
try {
contracts = await connectContracts(networkProvider, networkIdentifier.chainId)
contracts = await connectContracts(
networkProvider,
networkIdentifier.chainId,
argv.addressBook,
)
} catch (error) {
logger.error(
`Failed to connect to contracts, please ensure you are using the intended Ethereum Network`,
Expand Down

0 comments on commit 05d5547

Please sign in to comment.