graphprotocol / graphprotocol/indexer
Agent: Add env variable for operator address
Open
Nobody has claimed this yet.
enhancement
indexer-agent
p3
- Dominant language
- TypeScript
- Stars
- 262
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
Indexer agent currently only derives the first wallet of the mnemonic.
A loop until a derived wallet is found would be pretty nice.
# start.ts
const network = await Network.create(
logger,
ethereum,
argv.mnemonic,
argv.indexerAddress,
argv.publicIndexerUrl,
argv.graphNodeQueryEndpoint,
argv.indexerGeoCoordinates,
argv.operatorAddress, // <=
networkSubgraph,
)
# network.ts
static async create(
parentLogger: Logger,
ethereum: providers.JsonRpcProvider,
mnemonic: string,
indexerAddress: Address,
indexerUrl: string,
indexerQueryEndpoint: string,
geoCoordinates: [string, string],
operatorAddress: Address, // <=
networkSubgraph: Client | SubgraphDeploymentID,
): Promise<Network> {
const subgraph =
networkSubgraph instanceof Client
? networkSubgraph
: createClient({
url: new URL(
`/subgraphs/id/${networkSubgraph.ipfsHash}`,
indexerQueryEndpoint,
).toString(),
fetch,
requestPolicy: 'network-only',
})
const network = await ethereum.getNetwork()
let logger = parentLogger.child({
component: 'Network',
indexer: indexerAddress.toString(),
})
logger.info(`Create wallet`, {
network: network.name,
chainId: network.chainId,
})
##############################################################################################
// Just an idea how to do
Wallet wallet;
if(operatorAddress){
string path = "m/44'/60'/0'/0/" //hdnode_1.defaultPath; "m/44'/60'/0'/0/0" ... "m/44'/60'/0'/0/1" ... "m/44'/60'/0'/0/2"
for(let i=0 ; i< 9 ; i++){
wallet = Wallet.fromMnemonic(mnemonic,(path + i.toString());
if(operatorAddress == wallet.getAddress()){
break;
}
}
}
else{
// Always m/44'/60'/0'/0/0
wallet = Wallet.fromMnemonic(mnemonic)
}
// Continue as usual
###############################################################################################
...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at start.ts where Network.create receives the indexer settings, then inspect Network.create in network.ts and its current mnemonic wallet setup. Clarify how operatorAddress should select a derived wallet and preserve the existing default when it is absent. Done means the configured operator address can identify the wallet used by the agent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100