Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Koi staking reward query #154

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "yarn@1.22.22+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
Loading