From 10d61f415a1f176218cb00368d85262aaae05313 Mon Sep 17 00:00:00 2001 From: vovunku Date: Thu, 25 Jan 2024 07:22:48 +0100 Subject: [PATCH 1/3] added polimec project using moonbeam --- docker-compose.yml | 27 ++++++++++++++++++++++++ ipfs-cids/.project-multichain-cid | 2 +- project-polimec.yaml | 35 +++++++++++++++++++++++++++++++ subquery-multichain.yaml | 1 + 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 project-polimec.yaml diff --git a/docker-compose.yml b/docker-compose.yml index 2e7ac30..4b80c99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/ipfs-cids/.project-multichain-cid b/ipfs-cids/.project-multichain-cid index b06f424..f321437 100644 --- a/ipfs-cids/.project-multichain-cid +++ b/ipfs-cids/.project-multichain-cid @@ -1 +1 @@ -QmVxvbGE8TeMh4M6eYDZTiMXnbDDmaZjDpcnQdqXvyPtkF \ No newline at end of file +QmV9r4eoUGGrCURQxDuDiqGu7sxoHWK7hvgXUBVyVMri7T \ No newline at end of file diff --git a/project-polimec.yaml b/project-polimec.yaml new file mode 100644 index 0000000..3cf4772 --- /dev/null +++ b/project-polimec.yaml @@ -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: "git@github.com: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: handleMoonbeamNewEra + kind: substrate/EventHandler + filter: + module: parachainStaking + method: NewRound + + - handler: handleMoonbeamStakingReward + kind: substrate/EventHandler + filter: + module: parachainStaking + method: Rewarded diff --git a/subquery-multichain.yaml b/subquery-multichain.yaml index aed94bb..94b79e2 100644 --- a/subquery-multichain.yaml +++ b/subquery-multichain.yaml @@ -8,6 +8,7 @@ projects: - project-kusama.yaml - project-moonbeam.yaml - project-moonriver.yaml + - project-polimec.yaml - project-polkadex.yaml - project-polkadot.yaml - project-ternoa.yaml From 309ce8c71eb7422628bdc4063732254bfcbe06fc Mon Sep 17 00:00:00 2001 From: vovunku Date: Thu, 25 Jan 2024 07:25:45 +0100 Subject: [PATCH 2/3] fixed multichain cid --- ipfs-cids/.project-multichain-cid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipfs-cids/.project-multichain-cid b/ipfs-cids/.project-multichain-cid index f321437..0f392fc 100644 --- a/ipfs-cids/.project-multichain-cid +++ b/ipfs-cids/.project-multichain-cid @@ -1 +1 @@ -QmV9r4eoUGGrCURQxDuDiqGu7sxoHWK7hvgXUBVyVMri7T \ No newline at end of file +QmebHq47errFRvoYQbz4uzGYv6oKSgw4CK6Hp2dVXT9sZj \ No newline at end of file From 2482615623bf9fee2950988678d7d1a544496d0b Mon Sep 17 00:00:00 2001 From: vovunku Date: Thu, 25 Jan 2024 18:25:21 +0100 Subject: [PATCH 3/3] fixed polimec inner handlers, added manta project, redeployed --- docker-compose.yml | 27 ++++++++++++++++++++++++ ipfs-cids/.project-multichain-cid | 2 +- project-manta.yaml | 35 +++++++++++++++++++++++++++++++ project-polimec.yaml | 4 ++-- src/index.ts | 2 ++ src/mappings/manta.ts | 27 ++++++++++++++++++++++++ src/mappings/polimec.ts | 27 ++++++++++++++++++++++++ subquery-multichain.yaml | 1 + 8 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 project-manta.yaml create mode 100644 src/mappings/manta.ts create mode 100644 src/mappings/polimec.ts diff --git a/docker-compose.yml b/docker-compose.yml index 4b80c99..370b07f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -98,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: diff --git a/ipfs-cids/.project-multichain-cid b/ipfs-cids/.project-multichain-cid index 0f392fc..3f443c4 100644 --- a/ipfs-cids/.project-multichain-cid +++ b/ipfs-cids/.project-multichain-cid @@ -1 +1 @@ -QmebHq47errFRvoYQbz4uzGYv6oKSgw4CK6Hp2dVXT9sZj \ No newline at end of file +QmWS7DE27CzG4SUTjpKhb7eeNbYBm4jL39udBPCrtRBoD7 \ No newline at end of file diff --git a/project-manta.yaml b/project-manta.yaml new file mode 100644 index 0000000..3c383d0 --- /dev/null +++ b/project-manta.yaml @@ -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: "git@github.com: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 diff --git a/project-polimec.yaml b/project-polimec.yaml index 3cf4772..77e1a3c 100644 --- a/project-polimec.yaml +++ b/project-polimec.yaml @@ -22,13 +22,13 @@ dataSources: mapping: file: ./dist/index.js handlers: - - handler: handleMoonbeamNewEra + - handler: handlePolimecNewEra kind: substrate/EventHandler filter: module: parachainStaking method: NewRound - - handler: handleMoonbeamStakingReward + - handler: handlePolimecStakingReward kind: substrate/EventHandler filter: module: parachainStaking diff --git a/src/index.ts b/src/index.ts index 5607e38..bb0b047 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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"; diff --git a/src/mappings/manta.ts b/src/mappings/manta.ts new file mode 100644 index 0000000..6145421 --- /dev/null +++ b/src/mappings/manta.ts @@ -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 { + 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 { + await handleParachainStakingReward(event, MANTA_GENESIS, STAKING_TYPE) +} \ No newline at end of file diff --git a/src/mappings/polimec.ts b/src/mappings/polimec.ts new file mode 100644 index 0000000..91e6cfc --- /dev/null +++ b/src/mappings/polimec.ts @@ -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 { + 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 { + await handleParachainStakingReward(event, POLIMEC_GENESIS, STAKING_TYPE) +} \ No newline at end of file diff --git a/subquery-multichain.yaml b/subquery-multichain.yaml index 94b79e2..0d392c3 100644 --- a/subquery-multichain.yaml +++ b/subquery-multichain.yaml @@ -6,6 +6,7 @@ projects: - project-aleph-zero.yaml - project-calamari.yaml - project-kusama.yaml + - project-manta.yaml - project-moonbeam.yaml - project-moonriver.yaml - project-polimec.yaml