subquery-call-visitor
v1.2.7
Published
Easy traversing of nested Substrate calls in your SubQuery indexer
Downloads
6
Readme
SubQuery Call Visitor
Package that allows you to easily traverse nested Substrate calls
Getting started
Install package
yarn add subquery-call-visitor
yarn install
Setup visitor
const callWalk = CreateCallWalk()
const visitor = CreateCallVisitorBuilder()
.on("balances", "transfer", handleTransfer)
.ignoreFailedCalls(true)
.build()
async function handleTransfer(visitedCall: VisitedCall): Promise<void> {
// your logic
}
Register handlers
In order for SubQuery indexer to index nested calls you should add the following to your project
- Add a common handler
export async function handleNestedCalls(extrinsic: SubstrateExtrinsic): Promise<void> {
await callWalk.walk(extrinsic, visitor)
}
- Register common handler in
project.yaml
:
datasources:
mapping:
handlers:
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: proxy
method: proxy
# you may add success flag if you want to visit only success root extrinsics
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: proxy
method: proxyAnnounced
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: utility
method: batch
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: utility
method: batchAll
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: utility
method: forceBatch
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: multisig
method: asMulti
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: multisig
method: asMultiThreshold1
success: true
- handler: handleNestedCalls
kind: substrate/CallHandler
filter:
module: utility
method: asDerivative
success: true
Development
You can use following command to update package as dependency in another project.
Note that you should remove subquery-call-visitor
from package.json
first.
npm link /<path_to_visitor_package>
This will crete symlink to subquery-call-visitor
and allow applying changes in realtime
When you are done with development and want to switch back to remote version, run the following:
npm unlink /<path_to_visitor_package>
License
SubQuery Call Visitor is available under the Apache 2.0 license. See the LICENSE file for more info. © Novasama Technologies GmbH 2023