Skip to content

Commit

Permalink
Merge pull request #43 from novasamatech/feature/add_polimec
Browse files Browse the repository at this point in the history
Add polimec and manta staking
  • Loading branch information
ERussel authored Jan 25, 2024
2 parents 75cc9dc + 2482615 commit f8c8330
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 1 deletion.
54 changes: 54 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ services:
timeout: 5s
retries: 5

subquery-node-polimec:
image: onfinality/subql-node:v2.2.1
depends_on:
"postgres":
condition: service_healthy
restart: always
environment:
DB_USER: postgres
DB_PASS: postgres
DB_DATABASE: postgres
DB_HOST: postgres
DB_PORT: 5432
volumes:
- ./:/app
command:
- -f=/app/project-polimec.yaml
- --multi-chain
- --db-schema=app
- --disable-historical
- --query-limit=1000000
- --batch-size=30
healthcheck:
test: [ "CMD", "curl", "-f", "http://subquery-node-polimec:3000/ready" ]
interval: 3s
timeout: 5s
retries: 10

subquery-node-polkadot:
image: onfinality/subql-node:v2.2.1
depends_on:
Expand Down Expand Up @@ -71,6 +98,33 @@ services:
timeout: 5s
retries: 10

subquery-node-manta:
image: onfinality/subql-node:v2.2.1
depends_on:
"postgres":
condition: service_healthy
restart: always
environment:
DB_USER: postgres
DB_PASS: postgres
DB_DATABASE: postgres
DB_HOST: postgres
DB_PORT: 5432
volumes:
- ./:/app
command:
- -f=/app/project-manta.yaml
- --multi-chain
- --db-schema=app
- --disable-historical
- --query-limit=1000000
- --batch-size=30
healthcheck:
test: [ "CMD", "curl", "-f", "http://subquery-node-manta:3000/ready" ]
interval: 3s
timeout: 5s
retries: 10

subquery-node-moonbeam:
image: onfinality/subql-node:v2.2.1
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion ipfs-cids/.project-multichain-cid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
QmVxvbGE8TeMh4M6eYDZTiMXnbDDmaZjDpcnQdqXvyPtkF
QmWS7DE27CzG4SUTjpKhb7eeNbYBm4jL39udBPCrtRBoD7
35 changes: 35 additions & 0 deletions project-manta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
specVersion: 1.0.0
name: nova-wallet-staking
version: 0.0.1
runner:
node:
name: "@subql/node"
version: ">=1.0.0"
query:
name: "@subql/query"
version: "*"
description: >-
Project that provides up-to-date information about on-chain staking APY
repository: "[email protected]:nova-wallet/subquery-staking.git"
schema:
file: ./schema.graphql
network:
chainId: "0xf3c7ad88f6a80f366c4be216691411ef0622e8b809b1046ea297ef106058d4eb"
endpoint: "wss://ws.manta.systems"
dataSources:
- kind: substrate/Runtime
startBlock: 2192400
mapping:
file: ./dist/index.js
handlers:
- handler: handleMantaNewEra
kind: substrate/EventHandler
filter:
module: parachainStaking
method: NewRound

- handler: handleMantaStakingReward
kind: substrate/EventHandler
filter:
module: parachainStaking
method: Rewarded
35 changes: 35 additions & 0 deletions project-polimec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
specVersion: 1.0.0
name: nova-wallet-staking
version: 0.0.1
runner:
node:
name: "@subql/node"
version: ">=1.0.0"
query:
name: "@subql/query"
version: "*"
description: >-
Project that provides up-to-date information about on-chain staking APY
repository: "[email protected]:nova-wallet/subquery-staking.git"
schema:
file: ./schema.graphql
network:
chainId: "0x7eb9354488318e7549c722669dcbdcdc526f1fef1420e7944667212f3601fdbd"
endpoint: "wss://rpc.polimec.org"
dataSources:
- kind: substrate/Runtime
startBlock: 1
mapping:
file: ./dist/index.js
handlers:
- handler: handlePolimecNewEra
kind: substrate/EventHandler
filter:
module: parachainStaking
method: NewRound

- handler: handlePolimecStakingReward
kind: substrate/EventHandler
filter:
module: parachainStaking
method: Rewarded
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//Exports all handler functions
export * from "./mappings/polimec";
export * from "./mappings/polkadot";
export * from "./mappings/kusama";
export * from "./mappings/manta";
export * from "./mappings/moonbeam";
export * from "./mappings/moonriver";
export * from "./mappings/aleph-zero";
Expand Down
27 changes: 27 additions & 0 deletions src/mappings/manta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {SubstrateEvent} from "@subql/types";
import {handleNewEra} from "./common";
import {ParachainRewardCalculator} from "./rewards/Parachain";
import {CollatorEraInfoDataSource} from "./era/CollatorEraInfoDataSource";
import {Codec} from "@polkadot/types/types";
import {INumber} from "@polkadot/types-codec/types/interfaces";
import {handleParachainStakingReward} from "./rewards/history/parachain";

const MANTA_GENESIS = "0xf3c7ad88f6a80f366c4be216691411ef0622e8b809b1046ea297ef106058d4eb"
const STAKING_TYPE = "parachain"

export async function handleMantaNewEra(event: SubstrateEvent): Promise<void> {
let eraInfoDataSource = new CollatorEraInfoDataSource();

await handleNewEra(
eraInfoDataSource,
await ParachainRewardCalculator(eraInfoDataSource),
MANTA_GENESIS,
STAKING_TYPE
)
}

export async function handleMantaStakingReward(
event: SubstrateEvent<[accountId: Codec, reward: INumber]>,
): Promise<void> {
await handleParachainStakingReward(event, MANTA_GENESIS, STAKING_TYPE)
}
27 changes: 27 additions & 0 deletions src/mappings/polimec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {SubstrateEvent} from "@subql/types";
import {handleNewEra} from "./common";
import {ParachainRewardCalculator} from "./rewards/Parachain";
import {CollatorEraInfoDataSource} from "./era/CollatorEraInfoDataSource";
import {Codec} from "@polkadot/types/types";
import {INumber} from "@polkadot/types-codec/types/interfaces";
import {handleParachainStakingReward} from "./rewards/history/parachain";

const POLIMEC_GENESIS = "0x7eb9354488318e7549c722669dcbdcdc526f1fef1420e7944667212f3601fdbd"
const STAKING_TYPE = "parachain"

export async function handlePolimecNewEra(event: SubstrateEvent): Promise<void> {
let eraInfoDataSource = new CollatorEraInfoDataSource();

await handleNewEra(
eraInfoDataSource,
await ParachainRewardCalculator(eraInfoDataSource),
POLIMEC_GENESIS,
STAKING_TYPE
)
}

export async function handlePolimecStakingReward(
event: SubstrateEvent<[accountId: Codec, reward: INumber]>,
): Promise<void> {
await handleParachainStakingReward(event, POLIMEC_GENESIS, STAKING_TYPE)
}
2 changes: 2 additions & 0 deletions subquery-multichain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ projects:
- project-aleph-zero.yaml
- project-calamari.yaml
- project-kusama.yaml
- project-manta.yaml
- project-moonbeam.yaml
- project-moonriver.yaml
- project-polimec.yaml
- project-polkadex.yaml
- project-polkadot.yaml
- project-ternoa.yaml
Expand Down

0 comments on commit f8c8330

Please sign in to comment.