https://github.com/novasamatech/subquery-call-visitor
https://github.com/novasamatech/subquery-call-visitor
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/novasamatech/subquery-call-visitor
- Owner: novasamatech
- License: apache-2.0
- Created: 2023-05-03T05:52:56.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T10:33:18.000Z (3 months ago)
- Last Synced: 2025-03-14T13:44:23.037Z (3 months ago)
- Language: TypeScript
- Size: 118 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# SubQuery Call Visitor

Package that allows you to easily traverse nested Substrate calls
## Getting started
## Install package
``` shell
yarn add subquery-call-visitor
yarn install
```## Setup visitor
```typescript
const callWalk = CreateCallWalk()const visitor = CreateCallVisitorBuilder()
.on("balances", "transfer", handleTransfer)
.ignoreFailedCalls(true)
.build()async function handleTransfer(visitedCall: VisitedCall): Promise {
// your logic
}
```## Register handlers
In order for SubQuery indexer to index nested calls you should add the following
to your project1. Add a common handler
```typescript
export async function handleNestedCalls(extrinsic: SubstrateExtrinsic): Promise {
await callWalk.walk(extrinsic, visitor)
}
```2. Register common handler in `project.yaml`:
```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.
```shell
npm link /
```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:
``` shell
npm unlink /
```## License
SubQuery Call Visitor is available under the Apache 2.0 license. See the LICENSE file for more info.
© Novasama Technologies GmbH 2023