Skip to content

Commit eeee812

Browse files
committed
fix: auto balance set in local network
Signed-off-by: Tomás Migone <[email protected]>
1 parent d52644a commit eeee812

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/hardhat-graph-protocol/src/accounts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Accounts = {
2222
getTestAccounts: () => ReturnType<typeof getTestAccounts>
2323
}
2424

25-
export function getAccounts(provider: HardhatEthersProvider, chainId: number, grtTokenAddress: string | Addressable): Accounts {
25+
export function getAccounts(provider: HardhatEthersProvider, chainId: number, grtTokenAddress: string | Addressable | undefined): Accounts {
2626
return {
2727
getAccounts: async () => {
2828
const accounts = await getAccountsToolshed(provider)
@@ -77,8 +77,8 @@ export function getAccounts(provider: HardhatEthersProvider, chainId: number, gr
7777
}
7878
}
7979

80-
async function setBalanceIfLocal(provider: HardhatEthersProvider, chainId: number, grtTokenAddress: string | Addressable, account: HardhatEthersSigner) {
81-
if ([1337, 31337].includes(chainId)) {
80+
async function setBalanceIfLocal(provider: HardhatEthersProvider, chainId: number, grtTokenAddress: string | Addressable | undefined, account: HardhatEthersSigner) {
81+
if (grtTokenAddress && [1337, 31337].includes(chainId)) {
8282
await setGRTBalance(provider, grtTokenAddress, account.address, TEN_MILLION)
8383
}
8484
}

packages/hardhat-graph-protocol/src/gre.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path'
33

44
import { loadGraphHorizon, loadSubgraphService } from '@graphprotocol/toolshed/deployments'
55
import { logDebug, logError } from './logger'
6+
import { getAccounts } from './accounts'
67
import { getAddressBookPath } from './config'
78
import { GraphPluginError } from './error'
89
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider'
@@ -12,7 +13,6 @@ import { lazyFunction } from 'hardhat/plugins'
1213
import type { HardhatConfig, HardhatRuntimeEnvironment, HardhatUserConfig } from 'hardhat/types'
1314
import type { GraphDeployments } from '@graphprotocol/toolshed/deployments'
1415
import type { GraphRuntimeEnvironmentOptions } from './types'
15-
import { getAccounts } from './accounts'
1616

1717
export const greExtendConfig = (config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
1818
const userPath = userConfig.paths?.graph
@@ -50,7 +50,7 @@ export const greExtendEnvironment = (hre: HardhatRuntimeEnvironment) => {
5050

5151
// Build the Graph Runtime Environment (GRE) for each deployment
5252
const provider = new HardhatEthersProvider(hre.network.provider, hre.network.name)
53-
const greDeployments: GraphDeployments = {} as GraphDeployments
53+
const greDeployments = {} as GraphDeployments
5454

5555
for (const deployment of deployments) {
5656
logDebug(`== Initializing deployment: ${deployment} ==`)
@@ -82,7 +82,7 @@ export const greExtendEnvironment = (hre: HardhatRuntimeEnvironment) => {
8282
}
8383

8484
// Accounts
85-
const accounts = getAccounts(provider, chainId, greDeployments.horizon?.contracts?.GraphToken?.target)
85+
const accounts = getAccounts(provider, chainId, greDeployments.horizon.contracts.GraphToken.target)
8686

8787
logDebug('GRE initialized successfully!')
8888

0 commit comments

Comments
 (0)