Skip to content

Commit

Permalink
Support Koi staking reward query (#154)
Browse files Browse the repository at this point in the history
* Support Koi staking reward query

* Fix handler
  • Loading branch information
JayJay1024 authored Sep 20, 2024
1 parent 9b6bf93 commit ea36d80
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 2 deletions.
2 changes: 2 additions & 0 deletions subql/common/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export function activeChain(envChain): Chain {
return Chain.Rococo;
case 'moonbase':
return Chain.Moonbase;
case 'koi':
return Chain.Koi;
default:
throw new Error(`Unsupported chain: ${envChain}`)
}
Expand Down
2 changes: 1 addition & 1 deletion subql/common/src/types/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export enum Chain {
Kusama = 'kusama',
Polkadot = 'polkadot',
Moonbase = 'moonbase',

Koi = 'koi',
}
3 changes: 2 additions & 1 deletion subql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"devDependencies": {
"lerna": "^5.5.2",
"nx": "^14.4.3"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
37 changes: 37 additions & 0 deletions subql/packages/apps/project/koi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
specVersion: 1.0.0
name: index-subql
version: 1.0.0
runner:
node:
name: "@subql/node"
version: "*"
query:
name: "@subql/query"
version: "*"
description: Koi index
repository: "https://github.com/darwinia-network/indexer"
schema:
file: ./schema.graphql
network:
chainId: "0xce663480d55121504f3faf403756ac2b2d9f9870135b6f10222c848db45ded58"
endpoint: "wss://koi-rpc.darwinia.network"
dataSources:
- name: main
kind: substrate/Runtime
startBlock: 1
mapping:
file: ./dist/index.js
handlers:
- handler: handleBlock
kind: substrate/BlockHandler

- handler: handleCall
kind: substrate/CallHandler

################# Staking Events Start Here #################
- handler: handleEvent
kind: substrate/EventHandler
filter:
module: darwiniaStaking
method: Payout
################# Staking Events End Here #################
1 change: 1 addition & 0 deletions subql/packages/apps/schema/relation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"pangolin": ["feemarket", "staking", "account-migration"],
"pangoro": ["feemarket", "staking", "account-migration"],
"crab": ["feemarket", "staking", "account-migration"],
"koi": ["feemarket", "staking", "account-migration"],
"kusama": [],
"rococo": []
}
Expand Down
12 changes: 12 additions & 0 deletions subql/packages/apps/src/handler/chain/impls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,15 @@ export class RococoHandler extends BasicChainHandler {
];
}
}

export class KoiHandler extends BasicChainHandler {
constructor() {
super('koi');
}

handlers(): Array<IndexHandler> {
return [
new GenericStakingHandler(Chain.Koi),
];
}
}
3 changes: 3 additions & 0 deletions subql/packages/apps/src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {activeChain, Chain, FastBlock, FastEvent, FastExtrinsic, IndexHandler} f
import {
CrabHandler,
DarwiniaHandler,
KoiHandler,
KusamaHandler,
PangolinHandler,
PangoroHandler,
Expand Down Expand Up @@ -37,6 +38,8 @@ function indexHandler(): IndexHandler | undefined {
return new KusamaHandler();
case Chain.Rococo:
return new RococoHandler();
case Chain.Koi:
return new KoiHandler();
default:
logger.warn(`Can not support current chain: ${chain}`);
return;
Expand Down
12 changes: 12 additions & 0 deletions subql/packages/template/src/handler/chain/impls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ export class RococoHandler extends BasicChainHandler {
];
}
}

export class KoiHandler extends BasicChainHandler {
constructor() {
super('koi');
}

handlers(): Array<IndexHandler> {
return [
new GenericBlockHandler(Chain.Koi),
];
}
}
3 changes: 3 additions & 0 deletions subql/packages/template/src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {activeChain, Chain, FastBlock, FastEvent, FastExtrinsic, IndexHandler} f
import {
CrabHandler,
DarwiniaHandler,
KoiHandler,
KusamaHandler,
PangolinHandler,
PangolinParachainHandler,
Expand Down Expand Up @@ -38,6 +39,8 @@ function indexHandler(): IndexHandler | undefined {
return new KusamaHandler();
case Chain.Rococo:
return new RococoHandler();
case Chain.Koi:
return new KoiHandler();
default:
logger.warn(`Can not support current chain: ${chain}`);
return;
Expand Down

0 comments on commit ea36d80

Please sign in to comment.