diff --git a/.github/workflows/cli-deploy.yml b/.github/workflows/cli-deploy.yml index a417eff..9a4db6a 100644 --- a/.github/workflows/cli-deploy.yml +++ b/.github/workflows/cli-deploy.yml @@ -22,12 +22,13 @@ on: # accessToken: # required: true +# permissions: +# contents: read +# issues: write + jobs: subql_deploy_workflow: runs-on: ubuntu-latest - defaults: - run: - working-directory: centrifuge env: SUBQL_INDEXER_VERSION: v3.2.0 SUBQL_QUERY_VERSION: v2.6.0 diff --git a/.gitignore b/.gitignore index 62c8935..5140c32 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,53 @@ -.idea/ \ No newline at end of file +# These are some examples of commonly ignored file patterns. +# You should customize this list as applicable to your project. +# Learn more about .gitignore: +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore + +# Node artifact files +node_modules/ +dist/ +yarn.lock + +# Compiled Java class files +*.class + +# Compiled Python bytecode +*.py[cod] + +# Log files +*.log + +# Package files +*.jar + +# Maven +target/ +dist/ +src/types + +# JetBrains IDE +.idea/ + +# Unit test reports +TEST*.xml + +# Generated by MacOS +.DS_Store + +# Generated by Windows +Thumbs.db + +# Applications +*.app +*.exe +*.war + +# Large media files +*.mp4 +*.tiff +*.avi +*.flv +*.mov +*.wmv + +.data \ No newline at end of file diff --git a/README.md b/README.md index 34788df..1237e25 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,28 @@ -# What is SubQuery? - -SubQuery powers the next generation of Polkadot dApps by allowing developers to extract, transform and query blockchain data in real time using GraphQL. In addition to this, SubQuery provides production quality hosting infrastructure to run these projects in. - -# What is SubQuery Dictionary +# SubQuery - Dictionary This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. -It scans over the network, and records the module and method for every event/extrinsic on each block. See the standard entities in the `schema.graphql` file within this project to see what fields are available. +It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. **If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** -# Getting Started - -### 1. Add the dictionary URL to your SubQuery project - +# Geting Started +### 1. Install dependencies ```shell -network: - endpoint: wss://polkadot.api.onfinality.io/public-ws - dictionary: https://api.subquery.network/sq/subquery/polkadot-dictionary +yarn ``` -# Understanding the dictionary - -Visit [How the dictionary works](https://academy.subquery.network/academy/tutorials_examples/dictionary.html#how-does-a-subquery-dictionary-work) for more information. +### 2. Generate types +```shell +yarn codegen +``` -# Adding your own dictionary +### 3. Build +```shell +yarn build +``` -1. Fork the repository. -2. Add your own dictionary project to the root directory. -3. To publish on our Managed Services, you can use the GitHub actions. - 1. Set a GitHub environment to `DEPLOYMENT`. - 2. Set a GitHub secret name to `SUBQL_ACCES_TOKEN` (Your token generated on https://project.subquery.network/ ) under the previously set environment. - 3. Create a project using the UI or the CLI. - 4. Navigate to GitHub actions in your forked repository and select the workflow `Deploy to Hosted Service`. - 1. Enter your dictionary directory name in the input field `Dictionary directory name` e.g.`acala`. - 2. For the input field `Project Name` enter the name of the project created earlier (If your project name uses spaces please replace them with `-` e.g. `perfect - dictionary` -> `perfect---dictionary`). +### 4. Run locally +```shell +yarn start:docker +``` diff --git a/acala/.gitignore b/acala/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/acala/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/acala/.project-cid b/acala/.project-cid deleted file mode 100644 index 47da9c0..0000000 --- a/acala/.project-cid +++ /dev/null @@ -1 +0,0 @@ -Qmarrhgrpqw5VK71rMtb4GARpPvq8ajMjAqnjnWZFLV61N \ No newline at end of file diff --git a/acala/.project-karura-cid b/acala/.project-karura-cid deleted file mode 100644 index 73a09c1..0000000 --- a/acala/.project-karura-cid +++ /dev/null @@ -1 +0,0 @@ -QmWumrabg4k6t4EUMhQg19xWwcxGq1hWbcmfmRYiy2Bod5 \ No newline at end of file diff --git a/acala/README.md b/acala/README.md deleted file mode 100644 index 1237e25..0000000 --- a/acala/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/acala/package.json b/acala/package.json deleted file mode 100644 index 68c2ce9..0000000 --- a/acala/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@acala-network/type-definitions": "latest", - "@polkadot/api": "10.1.4", - "@subql/cli": "latest", - "@subql/testing": "^2.0.1", - "@subql/types": "latest", - "typescript": "^4.1.3" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "dependencies": { - "@subql/acala-evm-processor": "^0.1.4", - "abab": "^2.0.6", - "lodash": "^4.17.21" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/acala/project-karura.yaml b/acala/project-karura.yaml deleted file mode 100644 index c36da24..0000000 --- a/acala/project-karura.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Karura -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xbaf5aabe40646d11f0ee8abbdc64f4a4b7674925cba08e4a05ff9ebed6e2126b' - endpoint: 'wss://karura.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/acala/project-mandala-tc7.yaml b/acala/project-mandala-tc7.yaml deleted file mode 100644 index 319700c..0000000 --- a/acala/project-mandala-tc7.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Acala -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x5c562e6300954998233c9a40b6b86f3028977e6d32d0da1af207738d19f98c1b' #mandala - endpoint: 'wss://node-6870830370282213376.rz.onfinality.io/ws?apikey=0f273197-e4d5-45e2-b23e-03b015cb7000' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/acala/project.yaml b/acala/project.yaml deleted file mode 100644 index 6f81b97..0000000 --- a/acala/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Acala -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c' - endpoint: 'wss://acala-polkadot.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/acala/schema.graphql b/acala/schema.graphql deleted file mode 100644 index 9d058b3..0000000 --- a/acala/schema.graphql +++ /dev/null @@ -1,50 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} - -type EvmTransaction @entity { - id: ID! - txHash: String! - """A lowercase address of the sender""" - from: String! @index - """A lowercase address. This will be null for contract creations""" - to: String @index - """A lowercased function sighash extracted from the data field""" - func: String @index - blockHeight: BigInt! @index - success: Boolean! -} - -type EvmLog @entity { - id: ID! - """The contract address that emitted the event. Lowercased""" - address: String! @index - blockHeight: BigInt! @index - """The lowercase event signature""" - topics0: String! @index - """The lowercase first indexed argument""" - topics1: String - """The lowercase second indexed argument""" - topics2: String - """The lowercase third indexed argument""" - topics3: String -} - diff --git a/acala/src/chaintypes.ts b/acala/src/chaintypes.ts deleted file mode 100644 index 2903691..0000000 --- a/acala/src/chaintypes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { typesBundleForPolkadot } from "@acala-network/type-definitions"; - -export default { typesBundle: typesBundleForPolkadot }; diff --git a/acala/src/index.ts b/acala/src/index.ts deleted file mode 100644 index 97e9f40..0000000 --- a/acala/src/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -//Exports all handler functions -import {atob} from 'abab'; -if (!global.atob) { - global.atob = atob; -} -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/acala/src/mappings/mappingHandlers.ts b/acala/src/mappings/mappingHandlers.ts deleted file mode 100644 index e70e9a0..0000000 --- a/acala/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,167 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock, SubstrateEvent } from "@subql/types"; -import { SpecVersion, Event, Extrinsic, EvmLog, EvmTransaction } from "../types"; -import acalaProcessor from '@subql/acala-evm-processor'; -import {hexDataSlice, stripZeros} from '@ethersproject/bytes'; -import { merge } from 'lodash'; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - const wrappedExtrinsics = wrapExtrinsics(block); - const wrappedEvents = wrapEvents(block.events, block, wrappedExtrinsics); - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - const evmLogs = await Promise.all( - wrappedEvents - .filter(evt => { - const baseFilter = acalaProcessor.handlerProcessors['substrate/AcalaEvmEvent'].baseFilter[0]; - return evt.event.section === baseFilter.module && evt.event.method === baseFilter.method; - }) - .map(evt => handleEvmLog(block.block.header.number.toString(), evt)) - ); - - // Process all calls in block - const calls = wrappedExtrinsics.map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - const evmTransactions = await Promise.all(wrappedExtrinsics - .filter(ex => { - const baseFilter = acalaProcessor.handlerProcessors['substrate/AcalaEvmCall'].baseFilter[0]; - return ex.extrinsic.method.section === baseFilter.module && ex.extrinsic.method.method === baseFilter.method && ex.success; - }) - .map(ex => handleEvmTransaction(ex.idx, ex)) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - store.bulkCreate("EvmLog", evmLogs.flat()), - store.bulkCreate("EvmTransaction", evmTransactions.flat()), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - txHash: extrinsic.extrinsic.hash.toString(), - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} - -function wrapEvents(events: EventRecord[], block: SubstrateBlock, extrinsics: SubstrateExtrinsic[]): SubstrateEvent[] { - return events.reduce((acc, event, idx) => { - const { phase } = event; - const wrappedEvent: SubstrateEvent = merge(event, { idx, block }); - if (phase.isApplyExtrinsic) { - wrappedEvent.extrinsic = extrinsics[phase.asApplyExtrinsic.toNumber()]; - } - acc.push(wrappedEvent); - return acc; - }, [] as SubstrateEvent[]); -} - - -async function handleEvmLog(blockNumber: string, event: SubstrateEvent): Promise { - - const evmLogs = await acalaProcessor.handlerProcessors['substrate/AcalaEvmEvent'].transformer({ - input: event, - ds: {} as any, - api: api as any, - }); - - return evmLogs.map(evt => EvmLog.create({ - id: `${blockNumber}-${event.idx}-${evt.logIndex}`, - address: evt.address, - blockHeight: BigInt(blockNumber), - topics0: evt.topics[0].toLowerCase(), - topics1: evt.topics[1]?.toLowerCase(), - topics2: evt.topics[2]?.toLowerCase(), - topics3: evt.topics[3]?.toLowerCase(), - })); -} - -async function handleEvmTransaction(idx: number, tx: SubstrateExtrinsic): Promise { - const calls = await acalaProcessor.handlerProcessors['substrate/AcalaEvmCall'].transformer({ - input: tx, - ds: {} as any, - api: api as any, - }); - - return calls.map((call, i) => EvmTransaction.create({ - id: `${call.blockNumber}-${idx}-${i}`, - txHash: call.hash, - from: call.from, - to: call.to, - func: isZero(call.data) ? undefined : inputToFunctionSighash(call.data).toLowerCase(), - blockHeight: BigInt(call.blockNumber), - success: tx.success, - })); -} - -export function inputToFunctionSighash(input: string): string { - return hexDataSlice(input, 0, 4); -} - -export function isZero(input: string): boolean { - return stripZeros(input).length === 0; -} - diff --git a/acala/src/test/evmTransaction.test.ts b/acala/src/test/evmTransaction.test.ts deleted file mode 100644 index b79fb79..0000000 --- a/acala/src/test/evmTransaction.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { subqlTest } from '@subql/testing'; -import { EvmTransaction } from '../types'; - -// test for correct Total_supply -subqlTest( - 'test collections entity', - 1102920, - [], - [ - EvmTransaction.create({ - id: '1102920-2-0', - txHash: '0xd0705329e0f6ea5cd5a7cb49bd5d8a25e990c61710a06bbfd594dbae75c8874d', - from: '0xffffd2ff9b840f6bd74f80df8e532b4d7886ffff', - to: undefined, - func: '0x60806040', - blockHeight: BigInt(1102920), - success: true, - }), - ], - 'handleBlock' -); - -// Test for correct new NFTs, metadata, Transfer - -// Test for correct updated NFTs with transfer - -// Correct updated Collections total_supply with increment ERC1155 - -// Correct update Collections total_supply with state update ERC721 diff --git a/acala/tsconfig.json b/acala/tsconfig.json deleted file mode 100644 index f2f01c2..0000000 --- a/acala/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/aleph-zero/.gitignore b/aleph-zero/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/aleph-zero/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/aleph-zero/README.md b/aleph-zero/README.md deleted file mode 100644 index b575b60..0000000 --- a/aleph-zero/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` - -### 4. Queries - -Event: - -``` -query { - events(first: 10, filter: {blockHeight : {equalTo:"50253705"}}) { - nodes { - id, - module, - event, - blockHeight - } - } -} -``` - -Extrinsic: - -``` -query { - extrinsics(first: 10, filter: {blockHeight : {equalTo:"50253705"}}) { - nodes { - id, - module, - call, - blockHeight, - success, - isSigned, - } - } -} -``` - -SpecVersion: - -``` -query { - specVersions(first: 10) { - nodes { - id, - blockHeight - } - } -} -``` \ No newline at end of file diff --git a/aleph-zero/docker-compose.yml b/aleph-zero/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/aleph-zero/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/aleph-zero/package.json b/aleph-zero/package.json deleted file mode 100644 index 105bf51..0000000 --- a/aleph-zero/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/cli": "latest", - "@subql/types": "latest", - "typescript": "^5.0.4" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - } -} diff --git a/aleph-zero/project.yaml b/aleph-zero/project.yaml deleted file mode 100644 index a9281ce..0000000 --- a/aleph-zero/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Aleph-Zero -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x70255b4d28de0fc4e1a193d7e175ad1ccef431598211c55538f1018651a0344e' - endpoint: 'wss://ws.azero.dev' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/aleph-zero/schema.graphql b/aleph-zero/schema.graphql deleted file mode 100644 index d93080a..0000000 --- a/aleph-zero/schema.graphql +++ /dev/null @@ -1,20 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} \ No newline at end of file diff --git a/aleph-zero/src/chaintypes.ts b/aleph-zero/src/chaintypes.ts deleted file mode 100644 index cf667cc..0000000 --- a/aleph-zero/src/chaintypes.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [{ - minmax: [3, undefined], - types: { - DispatchErrorModule: 'DispatchErrorModuleU8' - } - }] -} - -export default { typesBundle: { spec: { "aleph-node": definitions }}}; diff --git a/aleph-zero/src/mappings/mappingHandlers.ts b/aleph-zero/src/mappings/mappingHandlers.ts deleted file mode 100644 index cd0bcae..0000000 --- a/aleph-zero/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !( - evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess" - ) - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} \ No newline at end of file diff --git a/aleph-zero/tsconfig.json b/aleph-zero/tsconfig.json deleted file mode 100644 index 4146dec..0000000 --- a/aleph-zero/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} \ No newline at end of file diff --git a/altair/.gitignore b/altair/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/altair/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/altair/README.md b/altair/README.md deleted file mode 100644 index 1237e25..0000000 --- a/altair/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/altair/docker-compose.yml b/altair/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/altair/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/altair/package.json b/altair/package.json deleted file mode 100644 index 872075d..0000000 --- a/altair/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/altair/project.yaml b/altair/project.yaml deleted file mode 100644 index 19b6ee4..0000000 --- a/altair/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Altair -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xaa3876c1dc8a1afcc2e9a685a49ff7704cfd36ad8c90bf2702b9d1b00cc40011' - endpoint: 'wss://altair.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/altair/src/index.ts b/altair/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/altair/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/altair/src/mappings/mappingHandlers.ts b/altair/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/altair/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/astar/.gitignore b/astar/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/astar/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/astar/.project-cid b/astar/.project-cid deleted file mode 100644 index f746ab4..0000000 --- a/astar/.project-cid +++ /dev/null @@ -1 +0,0 @@ -QmUmnKPhcE6JwGMYvY3Yitb5j8qxbQBMxgpkHpVQuXqxDH \ No newline at end of file diff --git a/astar/.project_shiden-cid b/astar/.project_shiden-cid deleted file mode 100644 index 0dd8589..0000000 --- a/astar/.project_shiden-cid +++ /dev/null @@ -1 +0,0 @@ -QmRrdfmc1p5FYQovtTPK3twvW2woT3EukRo38kU8hMSsYg \ No newline at end of file diff --git a/astar/README.md b/astar/README.md deleted file mode 100644 index 1237e25..0000000 --- a/astar/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/astar/docker-compose.yml b/astar/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/astar/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/astar/package.json b/astar/package.json deleted file mode 100644 index 71436eb..0000000 --- a/astar/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "resolutions": { - "ipfs-unixfs": "6.0.6" - }, - "dependencies": { - "@subql/frontier-evm-processor": "^0.1.4", - "abab": "latest" - }, - "devDependencies": { - "@polkadot/api": "^10", - "@subql/cli": "latest", - "@subql/types": "latest", - "@types/lodash": "^4.14.195", - "typescript": "^5.1.3" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - } -} diff --git a/astar/project.yaml b/astar/project.yaml deleted file mode 100644 index 3f0878c..0000000 --- a/astar/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Astar -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '>=0.32.0' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x9eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6' - endpoint: 'wss://astar.api.onfinality.io/public-ws' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/astar/project_shibuya.yaml b/astar/project_shibuya.yaml deleted file mode 100644 index e1869ca..0000000 --- a/astar/project_shibuya.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Astar -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xddb89973361a170839f80f152d2e9e38a376a5a7eccefcade763f46a8e567019' - endpoint: 'wss://public-rpc.pinknode.io/shibuya' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/astar/project_shiden.yaml b/astar/project_shiden.yaml deleted file mode 100644 index 8256d27..0000000 --- a/astar/project_shiden.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Astar -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xf1cf9022c7ebb34b162d5b5e34e705a5a740b2d0ecc1009fb89023e62a488108' - endpoint: 'wss://shiden.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/astar/schema.graphql b/astar/schema.graphql deleted file mode 100644 index e41ddfa..0000000 --- a/astar/schema.graphql +++ /dev/null @@ -1,65 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} - -type EvmTransaction @entity { - id: ID! - txHash: String! - """A lowercase address of the sender""" - from: String! @index - """A lowercase address. This will be null for contract creations""" - to: String @index - """A lowercased function sighash extracted from the data field""" - func: String @index - blockHeight: BigInt! @index - success: Boolean! -} - -type EvmLog @entity { - id: ID! - """The contract address that emitted the event. Lowercased""" - address: String! @index - blockHeight: BigInt! @index - """The lowercase event signature""" - topics0: String! @index - """The lowercase first indexed argument""" - topics1: String - """The lowercase second indexed argument""" - topics2: String - """The lowercase third indexed argument""" - topics3: String -} - -type ContractsCall @entity { - id: ID! - from: String! @index - dest: String! @index #contract address - selector: String! @index - blockHeight: BigInt! @index - success: Boolean! -} - -type ContractEmitted @entity { - id: ID! - contract: String! @index - from: String !@index - eventIndex: Int! @index - blockHeight: BigInt! @index -} diff --git a/astar/src/chaintypes.ts b/astar/src/chaintypes.ts deleted file mode 100644 index 33bf6ad..0000000 --- a/astar/src/chaintypes.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - Keys: 'AccountId', - Address: 'MultiAddress', - LookupSource: 'MultiAddress', - AmountOf: 'Amount', - Amount: 'i128', - SmartContract: { - _enum: { - Evm: 'H160', - Wasm: 'AccountId' - } - }, - EraStakingPoints: { - total: 'Balance', - stakers: 'BTreeMap', - formerStakedEra: 'EraIndex', - claimedRewards: 'Balance' - }, - PalletDappsStakingEraStakingPoints: { - total: 'Balance', - stakers: 'BTreeMap', - formerStakedEra: 'EraIndex', - claimedRewards: 'Balance' - }, - EraRewardAndStake: { - rewards: 'Balance', - staked: 'Balance' - }, - PalletDappsStakingEraRewardAndStake: { - rewards: 'Balance', - staked: 'Balance' - }, - EraIndex: 'u32', - // TODO awaiting an error at a future spec version to figure out the end range [3,undefined] - DispatchErrorModule: { - index: 'u8', - error: 'u8', - } - } - }, - { - minmax: [14, undefined], - types: { - EthTransaction: 'LegacyTransaction', - } - } - ] -} - -export default { typesBundle: { spec: { "shiden": definitions }}}; diff --git a/astar/src/index.ts b/astar/src/index.ts deleted file mode 100644 index cf0b705..0000000 --- a/astar/src/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -//Exports all handler functions -import {atob} from 'abab'; -if (!global.atob) { - (global as any).atob = atob; -} -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/astar/src/mappings/mappingHandlers.ts b/astar/src/mappings/mappingHandlers.ts deleted file mode 100644 index 9a5a677..0000000 --- a/astar/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,182 +0,0 @@ -import assert from 'assert'; -import {Bytes} from '@polkadot/types'; -const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000'; -import {TransactionV2, EthTransaction ,AccountId, Address, EvmLog} from "@polkadot/types/interfaces" -import {SubstrateExtrinsic,SubstrateBlock,SubstrateEvent} from "@subql/types"; -import { - SpecVersion, - Event, - Extrinsic, - EvmTransaction, - ContractEmitted, - ContractsCall, - EvmLog as EvmLogModel -} from "../types"; -import FrontierEvmDatasourcePlugin, { FrontierEvmCall } from "@subql/frontier-evm-processor/"; -import {inputToFunctionSighash, isZero, getSelector, wrapExtrinsics, wrapEvents} from "../utils"; -import {ApiPromise} from "@polkadot/api"; - - -let specVersion: SpecVersion | undefined; - -export type ContractEmittedResult = [AccountId, Bytes] - -export async function handleBlock(block: SubstrateBlock): Promise { - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - if(!specVersion || specVersion.id !== block.specVersion.toString()){ - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - - await specVersion.save(); - } - const wrappedCalls = wrapExtrinsics(block); - const wrappedEvents = wrapEvents(wrappedCalls,block.events.filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ),block) - let events: Event[] =[] - let contractEmittedEvents: ContractEmitted[] =[]; - let evmLogs: EvmLogModel[] =[]; - wrappedEvents.filter(evt => evt.event.section!=='system' && evt.event.method!=='ExtrinsicSuccess').map(event=>{ - events.push(handleEvent(event)) - if (event.event.section === 'contracts' && (event.event.method === 'ContractEmitted' || event.event.method === 'ContractExecution')) { - contractEmittedEvents.push(handleContractsEmitted(event)); - } - if(event.event.section === 'evm' && event.event.method === 'Log'){ - evmLogs.push(handleEvmEvent(event)); - } - }) - - let calls: Extrinsic[] =[] - let contractCalls: ContractsCall[] =[]; - let evmTransactions: EvmTransaction[] =[]; - - await Promise.all(wrappedCalls.map(async call => { - calls.push(handleCall(call)) - if (call.extrinsic.method.section === 'contracts' && call.extrinsic.method.method === 'call') { - contractCalls.push(handleContractCalls(call)); - } - try { - if (call.extrinsic.method.section === 'ethereum' && call.extrinsic.method.method === 'transact') { - const [frontierEvmCall] = await FrontierEvmDatasourcePlugin.handlerProcessors['substrate/FrontierEvmCall'].transformer({ - input: call as SubstrateExtrinsic<[TransactionV2 | EthTransaction]>, - ds: {} as any, - filter: undefined, - api: api as ApiPromise - }) - evmTransactions.push(handleEvmTransaction(call.idx.toString(),frontierEvmCall)) - } - } catch (e) { - logger.warn(e, 'Failed to transform ethereum transaction, skipping'); - // Failed evm transaction skipped - } - })); - - // seems there is a concurrent limitation for promise.all and bulkCreate work together, - // the last entity upsertion are missed - // We will put them into two promise for now. - await Promise.all([ - store.bulkCreate('Event', events), - store.bulkCreate('ContractEmitted', contractEmittedEvents), - store.bulkCreate('EvmLog', evmLogs), - ]); - await Promise.all([ - store.bulkCreate('Extrinsic', calls), - store.bulkCreate('ContractsCall', contractCalls), - store.bulkCreate('EvmTransaction', evmTransactions) - ]); -} - -export function handleEvent(event: SubstrateEvent): Event { - return Event.create({ - id: `${event.block.block.header.number.toString()}-${event.idx}`, - blockHeight: event.block.block.header.number.toBigInt(), - module: event.event.section, - event: event.event.method, - }); -} - -export function handleCall(extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: `${extrinsic.block.block.header.number.toString()}-${extrinsic.idx.toString()}`, - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function handleEvmEvent(event: SubstrateEvent): EvmLogModel { - let address; - // let data; - let topics; - const [log] = event.event.data as unknown as [{log:EvmLog} | EvmLog]; - - if((log as EvmLog).address){ - address = (log as EvmLog).address - topics = (log as EvmLog).topics - }else{ - address = (log as {log: EvmLog}).log.address; - topics = (log as {log: EvmLog}).log.topics; - } - return EvmLogModel.create({ - id: `${event.block.block.header.number.toString()}-${event.idx}`, - address: address.toString(), - blockHeight:event.block.block.header.number.toBigInt(), - topics0:topics[0].toHex().toLowerCase(), - topics1:topics[1]?.toHex().toLowerCase(), - topics2:topics[2]?.toHex().toLowerCase(), - topics3:topics[3]?.toHex().toLowerCase(), - }); -} - -export function handleEvmTransaction(idx: string, tx: FrontierEvmCall): EvmTransaction { - if (!tx.hash || !tx.blockNumber) { - throw new Error('Invalid evm transaction'); - } - const func = isZero(tx.data) ? undefined : inputToFunctionSighash(tx.data).toLowerCase(); - return EvmTransaction.create({ - id: `${tx.blockNumber.toString()}-${idx}`, - txHash: tx.hash, - from: tx.from.toLowerCase(), - // @ts-ignore - to: tx.to?.toLowerCase(), - func: func, - blockHeight: BigInt(tx.blockNumber.toString()), - success: tx.success, - }); -} - -export function handleContractCalls(call: SubstrateExtrinsic): ContractsCall { - const [dest,,,, data] = call.extrinsic.method.args; - assert(call.extrinsic.isSigned, "Contract calls must be signed"); - - return ContractsCall.create({ - id: `${call.block.block.header.number.toString()}-${call.idx}`, - from: call.extrinsic.signer.toString(), - success: !call.events.find( - (evt) => evt.event.section === 'system' && evt.event.method === 'ExtrinsicFailed' - ), - dest: (dest as Address).toString(), - blockHeight: call.block.block.header.number.toBigInt(), - selector: getSelector(data.toU8a()), - }); -} - -export function handleContractsEmitted(event: SubstrateEvent):ContractEmitted{ - const [contract, data] = event.event.data as unknown as ContractEmittedResult; - - return ContractEmitted.create({ - id: `${event.block.block.header.number.toString()}-${event.idx}`, - blockHeight: event.block.block.header.number.toBigInt(), - contract: contract.toString(), - from: event.extrinsic?.extrinsic.isSigned ? event.extrinsic.extrinsic.signer.toString(): EMPTY_ADDRESS, - eventIndex: data[0], - }); -} diff --git a/astar/src/utils.ts b/astar/src/utils.ts deleted file mode 100644 index 409bb07..0000000 --- a/astar/src/utils.ts +++ /dev/null @@ -1,72 +0,0 @@ -import {hexDataSlice, stripZeros} from '@ethersproject/bytes'; -import {EventRecord} from "@polkadot/types/interfaces" -import {SubstrateBlock, SubstrateEvent, SubstrateExtrinsic} from "@subql/types"; -import {compactStripLength, u8aToHex} from '@polkadot/util'; -import { merge } from 'lodash'; - -export function inputToFunctionSighash(input: string): string { - return hexDataSlice(input, 0, 4); -} - -export function isZero(input: string): boolean { - return stripZeros(input).length === 0; -} - -function filterExtrinsicEvents( - extrinsicIdx: number, - events: EventRecord[], -): EventRecord[] { - return events.filter( - ({ phase }) => - phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(extrinsicIdx), - ); -} - -export function wrapExtrinsics( - wrappedBlock: SubstrateBlock, -): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = filterExtrinsicEvents(idx, wrappedBlock.events); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: getExtrinsicSuccess(events), - }; - }); -} - -function getExtrinsicSuccess(events: EventRecord[]): boolean { - return ( - events.findIndex((evt) => evt.event.method === 'ExtrinsicSuccess') > -1 - ); -} - -export function getSelector(data: Uint8Array): string { - //This should align with https://github.com/polkadot-js/api/blob/0b6f7861080c920407a346e2a3dbe64adcb07a1e/packages/api-contract/src/Abi/index.ts#L249 - try { - const [, trimmed] = compactStripLength(data); - return u8aToHex(trimmed.subarray(0, 4)); - } catch { - return u8aToHex(data.subarray(0, 4)) - } -} - - - -export function wrapEvents( - extrinsics: SubstrateExtrinsic[], - events: EventRecord[], - block: SubstrateBlock, -): SubstrateEvent[] { - return events.reduce((acc, event, idx) => { - const { phase } = event; - const wrappedEvent: SubstrateEvent = merge(event, { idx, block }); - if (phase.isApplyExtrinsic) { - wrappedEvent.extrinsic = extrinsics[phase.asApplyExtrinsic.toNumber()]; - } - acc.push(wrappedEvent); - return acc; - }, [] as SubstrateEvent[]); -} diff --git a/astar/tsconfig.json b/astar/tsconfig.json deleted file mode 100644 index 450689b..0000000 --- a/astar/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true, - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/automata/.gitignore b/automata/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/automata/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/automata/README.md b/automata/README.md deleted file mode 100644 index 1237e25..0000000 --- a/automata/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/automata/docker-compose.yml b/automata/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/automata/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/automata/package.json b/automata/package.json deleted file mode 100644 index 872075d..0000000 --- a/automata/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/automata/project.yaml b/automata/project.yaml deleted file mode 100644 index 491c660..0000000 --- a/automata/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Automata Network -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xc8eda34601b5a48c73f47ee39a3a86a858c34f044185b17dc7d5ad155813dc63' - endpoint: 'wss://automata.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/automata/schema.graphql b/automata/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/automata/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/automata/src/chaintypes.ts b/automata/src/chaintypes.ts deleted file mode 100644 index 299ab74..0000000 --- a/automata/src/chaintypes.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - ResourceId: '[u8; 32]', - DepositNonce: 'u64', - ProposalStatus: { - _enum: [ - 'Initiated', - 'Approved', - 'Rejected' - ] - }, - ProposalVotes: { - votes_for: 'Vec', - votes_against: 'Vec', - status: 'ProposalStatus' - }, - BridgeTokenId: 'U256', - BridgeChainId: 'u8', - VestingPlan: { - start_time: 'u64', - cliff_duration: 'u64', - total_duration: 'u64', - interval: 'u64', - initial_amount: 'Balance', - total_amount: 'Balance', - vesting_during_cliff: 'bool' - } - } - } - ] -}; - -export default { typesBundle: definitions }; diff --git a/automata/src/index.ts b/automata/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/automata/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/automata/src/mappings/mappingHandlers.ts b/automata/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/automata/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/automata/tsconfig.json b/automata/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/automata/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/basilisk/.gitignore b/basilisk/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/basilisk/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/basilisk/README.md b/basilisk/README.md deleted file mode 100644 index 1237e25..0000000 --- a/basilisk/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/basilisk/docker-compose.yml b/basilisk/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/basilisk/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/basilisk/package.json b/basilisk/package.json deleted file mode 100644 index 872075d..0000000 --- a/basilisk/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/basilisk/project.yaml b/basilisk/project.yaml deleted file mode 100644 index 06e4ccc..0000000 --- a/basilisk/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Basilisk -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xa85cfb9b9fd4d622a5b28289a02347af987d8f73fa3108450e2b4a11c1ce5755' - endpoint: 'wss://rpc.basilisk.cloud' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/basilisk/schema.graphql b/basilisk/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/basilisk/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/basilisk/src/chaintypes.ts b/basilisk/src/chaintypes.ts deleted file mode 100644 index 4fcff1a..0000000 --- a/basilisk/src/chaintypes.ts +++ /dev/null @@ -1,94 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - alias: { tokens: { AccountData: 'OrmlAccountData' } }, - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - AssetPair: { asset_in: 'AssetId', asset_out: 'AssetId' }, - Amount: 'i128', - AmountOf: 'Amount', - Address: 'AccountId', - OrmlAccountData: { free: 'Balance', frozen: 'Balance', reserved: 'Balance' }, - Fee: { numerator: 'u32', denominator: 'u32' }, - BalanceInfo: { amount: 'Balance', assetId: 'AssetId' }, - Chain: { genesisHash: 'Vec', lastBlockHash: 'Vec' }, - Currency: 'AssetId', - CurrencyId: 'AssetId', - CurrencyIdOf: 'AssetId', - Intention: { - who: 'AccountId', - asset_sell: 'AssetId', - asset_buy: 'AssetId', - amount: 'Balance', - discount: 'bool', - sell_or_buy: 'IntentionType' - }, - IntentionId: 'Hash', - IntentionType: { _enum: ['SELL', 'BUY'] }, - LookupSource: 'AccountId', - Price: 'Balance', - ClassId: 'u64', - TokenId: 'u64', - ClassData: { is_pool: 'bool' }, - TokenData: { locked: 'bool' }, - ClassInfo: { metadata: 'Vec', total_issuance: 'TokenId', owner: 'AccountId', data: 'ClassData' }, - TokenInfo: { metadata: 'Vec', owner: 'AccountId', data: 'TokenData' }, - ClassInfoOf: 'ClassInfo', - TokenInfoOf: 'TokenInfo', - ClassIdOf: 'ClassId', - TokenIdOf: 'TokenId', - OrderedSet: 'Vec', - VestingSchedule: { - start: 'BlockNumber', - period: 'BlockNumber', - period_count: 'u32', - per_period: 'Compact' - }, - VestingScheduleOf: 'VestingSchedule', - LBPWeight: 'u32', - WeightCurveType: { _enum: ['Linear'] }, - PoolId: 'AccountId', - BalanceOf: 'Balance', - AssetType: { - _enum: { - Token: 'Null', - PoolShare: '(AssetId,AssetId)' - } - }, - Pool: { - owner: 'AccountId', - start: 'BlockNumber', - end: 'BlockNumber', - assets: 'AssetPair', - initial_weights: 'LBPWeight', - final_weights: 'LBPWeight', - weight_curve: 'WeightCurveType', - pausable: 'bool', - paused: 'bool', - fee: 'Fee', - fee_receiver: 'AccountId' - }, - AssetDetails: { - name: 'Vec', - asset_type: 'AssetType', - existential_deposit: 'Balance', - locked: 'bool' - }, - AssetDetailsT: 'AssetDetails', - AssetMetadata: { symbol: 'Vec', decimals: 'u8' }, - AssetInstance: 'AssetInstanceV1', - MultiLocation: 'MultiLocationV1', - MultiAsset: 'MultiAssetV1', - Xcm: 'XcmV1', - XcmOrder: 'XcmOrderV1' - } - } - ] -}; - -export default { typesBundle: { spec: { basilisk : definitions }}}; diff --git a/basilisk/src/index.ts b/basilisk/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/basilisk/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/basilisk/src/mappings/mappingHandlers.ts b/basilisk/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/basilisk/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/basilisk/tsconfig.json b/basilisk/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/basilisk/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/bifrost-parachain/.gitignore b/bifrost-parachain/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/bifrost-parachain/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/bifrost-parachain/.project-cid b/bifrost-parachain/.project-cid deleted file mode 100644 index 5a9e3cd..0000000 --- a/bifrost-parachain/.project-cid +++ /dev/null @@ -1 +0,0 @@ -QmX5dnwJsZf1nvVTNwJKQBpsNmzRCAZRrQfPFT283Zm3i2 \ No newline at end of file diff --git a/bifrost-parachain/README.md b/bifrost-parachain/README.md deleted file mode 100644 index 1237e25..0000000 --- a/bifrost-parachain/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/bifrost-parachain/docker-compose.yml b/bifrost-parachain/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/bifrost-parachain/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/bifrost-parachain/package.json b/bifrost-parachain/package.json deleted file mode 100644 index a3dbdf2..0000000 --- a/bifrost-parachain/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@bifrost-finance/type-definitions": "latest", - "@polkadot/api": "^10.9.1", - "@subql/cli": "latest", - "@subql/types": "latest", - "typescript": "^5.1.6" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - }, - "dependencies": { - "@open-web3/orml-type-definitions": "^2.0.1" - } -} diff --git a/bifrost-parachain/project.yaml b/bifrost-parachain/project.yaml deleted file mode 100644 index 2a9c6cd..0000000 --- a/bifrost-parachain/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Bifrost (Kusama) -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x9f28c6a68e0fc9646eff64935684f6eeeece527e37bbe1f213d22caa1d9d6bed' - endpoint: 'wss://bifrost-parachain.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/bifrost-parachain/schema.graphql b/bifrost-parachain/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/bifrost-parachain/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/bifrost-parachain/src/chaintypes.ts b/bifrost-parachain/src/chaintypes.ts deleted file mode 100644 index c3648f8..0000000 --- a/bifrost-parachain/src/chaintypes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { typesBundleForPolkadot } from '@bifrost-finance/type-definitions'; - -export default { typesBundle: typesBundleForPolkadot }; diff --git a/bifrost-parachain/src/index.ts b/bifrost-parachain/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/bifrost-parachain/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/bifrost-parachain/src/mappings/mappingHandlers.ts b/bifrost-parachain/src/mappings/mappingHandlers.ts deleted file mode 100644 index f5761d1..0000000 --- a/bifrost-parachain/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - txHash: extrinsic.extrinsic.hash.toString(), - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/bifrost-parachain/tsconfig.json b/bifrost-parachain/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/bifrost-parachain/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/bitcountry-pioneer/.gitignore b/bitcountry-pioneer/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/bitcountry-pioneer/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/bitcountry-pioneer/README.md b/bitcountry-pioneer/README.md deleted file mode 100644 index 1237e25..0000000 --- a/bitcountry-pioneer/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/bitcountry-pioneer/docker-compose.yml b/bitcountry-pioneer/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/bitcountry-pioneer/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/bitcountry-pioneer/package.json b/bitcountry-pioneer/package.json deleted file mode 100644 index 2fd8a9c..0000000 --- a/bitcountry-pioneer/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest", - "@metaverse-network-sdk/type-definitions": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/bitcountry-pioneer/project.yaml b/bitcountry-pioneer/project.yaml deleted file mode 100644 index 5a38684..0000000 --- a/bitcountry-pioneer/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Bit.Country Pioneer -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xf22b7850cdd5a7657bbfd90ac86441275bbc57ace3d2698a740c7b0ec4de5ec3' - endpoint: 'wss://pioneer.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/bitcountry-pioneer/schema.graphql b/bitcountry-pioneer/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/bitcountry-pioneer/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/bitcountry-pioneer/src/chaintypes.ts b/bitcountry-pioneer/src/chaintypes.ts deleted file mode 100644 index a98f8ee..0000000 --- a/bitcountry-pioneer/src/chaintypes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { types } from '@metaverse-network-sdk/type-definitions'; - -export default { typesBundle: types }; diff --git a/bitcountry-pioneer/src/index.ts b/bitcountry-pioneer/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/bitcountry-pioneer/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/bitcountry-pioneer/src/mappings/mappingHandlers.ts b/bitcountry-pioneer/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/bitcountry-pioneer/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/bitcountry-pioneer/tsconfig.json b/bitcountry-pioneer/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/bitcountry-pioneer/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/calamari/.gitignore b/calamari/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/calamari/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/calamari/README.md b/calamari/README.md deleted file mode 100644 index 1237e25..0000000 --- a/calamari/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/calamari/docker-compose.yml b/calamari/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/calamari/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/calamari/package.json b/calamari/package.json deleted file mode 100644 index 872075d..0000000 --- a/calamari/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/calamari/project.yaml b/calamari/project.yaml deleted file mode 100644 index 97d2aa8..0000000 --- a/calamari/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Calamari -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x4ac80c99289841dd946ef92765bf659a307d39189b3ce374a92b5f0415ee17a1' - endpoint: 'wss://ws.calamari.systems/' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/calamari/schema.graphql b/calamari/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/calamari/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/calamari/src/chaintypes.ts b/calamari/src/chaintypes.ts deleted file mode 100644 index 5363c62..0000000 --- a/calamari/src/chaintypes.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: - { - CurrencyId: { - _enum: [ - 'MA' - ] - }, - CurrencyIdOf: 'CurrencyId', - Amount: 'i128', - AmountOf: 'Amount', - AccountInfo: 'AccountInfoWithDualRefCount' - } - } - ] -}; - -export default { typesBundle: definitions }; diff --git a/calamari/src/index.ts b/calamari/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/calamari/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/calamari/src/mappings/mappingHandlers.ts b/calamari/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/calamari/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/calamari/tsconfig.json b/calamari/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/calamari/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/centrifuge/.gitignore b/centrifuge/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/centrifuge/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/centrifuge/README.md b/centrifuge/README.md deleted file mode 100644 index 1237e25..0000000 --- a/centrifuge/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/centrifuge/docker-compose.yml b/centrifuge/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/centrifuge/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/centrifuge/schema.graphql b/centrifuge/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/centrifuge/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/centrifuge/src/chaintypes.ts b/centrifuge/src/chaintypes.ts deleted file mode 100644 index b875f70..0000000 --- a/centrifuge/src/chaintypes.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - ParachainAccountIdOf: 'AccountId', - Proof: { - leafHash: 'Hash', - sortedHashes: 'Vec' - }, - ProxyType: { - _enum: [ - 'Any', - 'NonTransfer', - 'Governance', - '_Staking', - 'NonProxy' - ] - }, - RelayChainAccountId: 'AccountId', - RootHashOf: 'Hash' - } - } - ] -}; - -export default { typesBundle: { spec: { altair: definitions }}}; diff --git a/centrifuge/src/index.ts b/centrifuge/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/centrifuge/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/centrifuge/tsconfig.json b/centrifuge/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/centrifuge/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/clover/.gitignore b/clover/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/clover/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/clover/README.md b/clover/README.md deleted file mode 100644 index 1237e25..0000000 --- a/clover/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/clover/docker-compose.yml b/clover/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/clover/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/clover/package.json b/clover/package.json deleted file mode 100644 index 872075d..0000000 --- a/clover/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/clover/project.yaml b/clover/project.yaml deleted file mode 100644 index a5eb7ad..0000000 --- a/clover/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Clover -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x5c7bd13edf349b33eb175ffae85210299e324d852916336027391536e686f267' - endpoint: 'wss://clover.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/clover/schema.graphql b/clover/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/clover/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/clover/src/chaintypes.ts b/clover/src/chaintypes.ts deleted file mode 100644 index e743b33..0000000 --- a/clover/src/chaintypes.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { OverrideBundleDefinition } from "@polkadot/types/types"; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - Amount: "i128", - Keys: "SessionKeys4", - AmountOf: "Amount", - Balance: "u128", - Rate: "FixedU128", - Ratio: "FixedU128", - EcdsaSignature: "[u8; 65]", - EvmAddress: "H160", - EthereumTxHash: "H256", - BridgeNetworks: { - _enum: ["BSC", "Ethereum", "CloverPara"], - }, - }, - }, - ], -}; - -export default { typesBundle: definitions }; diff --git a/clover/src/index.ts b/clover/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/clover/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/clover/src/mappings/mappingHandlers.ts b/clover/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/clover/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/clover/tsconfig.json b/clover/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/clover/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/contextfree/.gitignore b/contextfree/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/contextfree/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/contextfree/README.md b/contextfree/README.md deleted file mode 100644 index 1237e25..0000000 --- a/contextfree/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/contextfree/docker-compose.yml b/contextfree/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/contextfree/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/contextfree/package.json b/contextfree/package.json deleted file mode 100644 index 8b197c9..0000000 --- a/contextfree/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "8.12.2", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/contextfree/project.yaml b/contextfree/project.yaml deleted file mode 100644 index 565803b..0000000 --- a/contextfree/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - ContextFree Network -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x6254c948b5eb7199a112cb308be3385c39c8c942625540ac749c77fe2aebc299' - endpoint: 'wss://contextfree.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/contextfree/schema.graphql b/contextfree/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/contextfree/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/contextfree/src/chaintypes.ts b/contextfree/src/chaintypes.ts deleted file mode 100644 index 97b48b2..0000000 --- a/contextfree/src/chaintypes.ts +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2017-2022 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - DispatchErrorModule: { - index: "u8", - error: "u8" - }, - ResourceId: "[u8; 32]", - DepositNonce: "u64", - ProposalStatus: { - _enum: [ - "Initiated", - "Approved", - "Rejected" - ] - }, - ProposalVotes: { - votes_for: "Vec", - votes_against: "Vec", - status: "ProposalStatus" - }, - BridgeTokenId: "U256", - BridgeChainId: "u8", - ProposalId: "u32", - ProjectId: "u32", - ChainIndex: "u32", - Protocol: { - _enum: [ - "Solidity", - "Substrate" - ] - }, - Chain: { - _protocol: "Protocol" - }, - CrossChainAccount: { - _enum: { - Solidity: "H160", - Substrate: "AccountId" - } - }, - IpfsHash: "Text", - SolidityStrategy: { - _enum: { - ERC20Balance: "H160", - Custom: "(IpfsHash, Vec)" - } - }, - SubstrateStrategy: { - _enum: { - NativeBalance: "Null", - Custom: "(IpfsHash, Vec)" - } - }, - Strategy: { - _enum: { - Solidity: "SolidityStrategy", - Substrate: "SubstrateStrategy" - } - }, - Workspace: { - _chain: "ChainIndex", - strategies: "Vec" - }, - UserGroup: { - owner: "CrossChainAccount", - admins: "Vec", - maintainers: "Vec", - proposers: "Option>" - }, - Project: { - usergroup: "UserGroup", - data: "IpfsHash", - workspaces: "Vec" - }, - VotingFormat: { - _enum: [ - "SingleChoice", - "SplitVote" - ] - }, - OptionIndex: "u8", - PrivacyLevel: { - _enum: { - Opaque: "u8", - Rank: "Null", - Private: "Null", - Public: "Null", - Mixed: "Null" - } - }, - VotingPower: "U256", - DAOProposalState: { - finalized: "bool", - snapshots: "Vec", - blacklisted: "bool", - votes: "Vec", - pub_voters: "Option", - updates: "u32" - }, - DAOProposal: { - _author: "CrossChainAccount", - _voting_format: "VotingFormat", - _option_count: "OptionIndex", - _data: "IpfsHash", - _privacy: "PrivacyLevel", - _start: "u64", - _end: "u64", - _frequency: "Option", - state: "DAOProposalState" - }, - VoteUpdate: { - project: "ProjectId", - proposal: "ProposalId", - votes: "Vec", - pub_voters: "Option" - }, - GmetadataNamespaceName: "Text", - GmetadataNamespaceInfo: { - id: "u32", - name: "Vec", - owners: "Vec" - }, - GmetadataValueInfo: { - data: "Vec", - update_time: "u64" - }, - GmetadataIndexInfo: { - data: "Vec>", - update_time: "u64" - }, - GmetadataKey: { - ns: "u32", - table: "Vec", - pk: "Vec" - }, - GmetadataWriteOp: { - _enum: { - SetValue: "(GmetadataKey, Vec)", - RemoveValue: "GmetadataKey", - AddIndex: "(GmetadataKey, Vec)", - RemoveIndex: "(GmetadataKey, Vec)" - } - } - } - } - ] -}; - -export default { typesBundle: { spec: { "contextfree": definitions }}}; diff --git a/contextfree/src/index.ts b/contextfree/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/contextfree/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/contextfree/src/mappings/mappingHandlers.ts b/contextfree/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/contextfree/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/contextfree/tsconfig.json b/contextfree/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/contextfree/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/acala/docker-compose.yml b/docker-compose.yml similarity index 100% rename from acala/docker-compose.yml rename to docker-compose.yml diff --git a/khala/.gitignore b/khala/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/khala/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/khala/.project-cid b/khala/.project-cid deleted file mode 100644 index 376ca24..0000000 --- a/khala/.project-cid +++ /dev/null @@ -1 +0,0 @@ -QmYCAns2cunZKJFU85KNK8CvL2ATAmCFVZRdBf963GqWYs \ No newline at end of file diff --git a/khala/README.md b/khala/README.md deleted file mode 100644 index 1237e25..0000000 --- a/khala/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/khala/docker-compose.yml b/khala/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/khala/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/khala/package.json b/khala/package.json deleted file mode 100644 index 93b7c25..0000000 --- a/khala/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest", - "@phala/typedefs": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/khala/project.yaml b/khala/project.yaml deleted file mode 100644 index 0eeb231..0000000 --- a/khala/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Khala -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xd43540ba6d3eb4897c28a77d48cb5b729fea37603cbbfc7a86a73b72adb3be8d' - endpoint: 'wss://khala.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/khala/schema.graphql b/khala/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/khala/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/khala/src/chaintypes.ts b/khala/src/chaintypes.ts deleted file mode 100644 index 72c1484..0000000 --- a/khala/src/chaintypes.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { OverrideBundleType } from '@polkadot/types/types'; - -import { versionedKhala } from '@phala/typedefs'; - -export default { typesBundle: {spec: { khala: {types: versionedKhala }}} as OverrideBundleType}; \ No newline at end of file diff --git a/khala/src/index.ts b/khala/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/khala/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/khala/src/mappings/mappingHandlers.ts b/khala/src/mappings/mappingHandlers.ts deleted file mode 100644 index 16c64f5..0000000 --- a/khala/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - txHash: extrinsic.extrinsic.hash.toString(), - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/khala/tsconfig.json b/khala/tsconfig.json deleted file mode 100644 index 2394621..0000000 --- a/khala/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/kusama/.gitignore b/kusama/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/kusama/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/kusama/README.md b/kusama/README.md deleted file mode 100644 index 1237e25..0000000 --- a/kusama/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/kusama/docker-compose.yml b/kusama/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/kusama/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/kusama/package.json b/kusama/package.json deleted file mode 100644 index 45c7272..0000000 --- a/kusama/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/kusama/project.yaml b/kusama/project.yaml deleted file mode 100644 index 4e6d3b1..0000000 --- a/kusama/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Kusama -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe' - endpoint: 'wss://kusama.api.onfinality.io/public-ws' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/kusama/schema.graphql b/kusama/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/kusama/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/kusama/src/index.ts b/kusama/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/kusama/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/kusama/src/mappings/mappingHandlers.ts b/kusama/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/kusama/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/kusama/tsconfig.json b/kusama/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/kusama/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/moonbeam-evm/.gitignore b/moonbeam-evm/.gitignore deleted file mode 100644 index cd0be5a..0000000 --- a/moonbeam-evm/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -.data - -# Log files -*.log - -# JetBrains IDE -.idea/ - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Generated files -src/types - -yarn.lock \ No newline at end of file diff --git a/moonbeam-evm/.project-cid b/moonbeam-evm/.project-cid deleted file mode 100644 index de4d623..0000000 --- a/moonbeam-evm/.project-cid +++ /dev/null @@ -1 +0,0 @@ -QmXL6FCTopEVJLWYKdncCQGQvfCt6faBUFN4MkcLtWvKVt \ No newline at end of file diff --git a/moonbeam-evm/.project_moonriver-cid b/moonbeam-evm/.project_moonriver-cid deleted file mode 100644 index 829d8d4..0000000 --- a/moonbeam-evm/.project_moonriver-cid +++ /dev/null @@ -1 +0,0 @@ -QmXCr6uZFdY1YcGTa4u6ZieQPXK4VHE1Pjy7CBr7ubFwKR \ No newline at end of file diff --git a/moonbeam-evm/LICENSE b/moonbeam-evm/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/moonbeam-evm/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/moonbeam-evm/README.md b/moonbeam-evm/README.md deleted file mode 100644 index e21cd2b..0000000 --- a/moonbeam-evm/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# SubQuery - Starter Package - - -The Starter Package is an example that you can use as a starting point for developing your SubQuery project. -A SubQuery package defines which data The SubQuery will index from the Substrate blockchain, and how it will store it. - -## Preparation - -#### Environment - -- [Typescript](https://www.typescriptlang.org/) are required to compile project and define types. - -- Both SubQuery CLI and generated Project have dependencies and require [Node](https://nodejs.org/en/). - - -#### Install the SubQuery CLI - -Install SubQuery CLI globally on your terminal by using NPM: - -``` -npm install -g @subql/cli -``` - -Run help to see available commands and usage provide by CLI -``` -subql help -``` - -## Initialize the starter package - -Inside the directory in which you want to create the SubQuery project, simply replace `project-name` with your project name and run the command: -``` -subql init --starter project-name -``` -Then you should see a folder with your project name has been created inside the directory, you can use this as the start point of your project. And the files should be identical as in the [Directory Structure](https://doc.subquery.network/directory_structure.html). - -Last, under the project directory, run following command to install all the dependency. -``` -yarn install -``` - - -## Configure your project - -In the starter package, we have provided a simple example of project configuration. You will be mainly working on the following files: - -- The Manifest in `project.yaml` -- The GraphQL Schema in `schema.graphql` -- The Mapping functions in `src/mappings/` directory - -For more information on how to write the SubQuery, -check out our doc section on [Define the SubQuery](https://doc.subquery.network/define_a_subquery.html) - -#### Code generation - -In order to index your SubQuery project, it is mandatory to build your project first. -Run this command under the project directory. - -```` -yarn codegen -```` - -## Build the project - -In order to deploy your SubQuery project to our hosted service, it is mandatory to pack your configuration before upload. -Run pack command from root directory of your project will automatically generate a `your-project-name.tgz` file. - -``` -yarn build -``` - -## Indexing and Query - -#### Run required systems in docker - - -Under the project directory run following command: - -``` -docker-compose pull && docker-compose up -``` -#### Query the project - -Open your browser and head to `http://localhost:3000`. - -Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query. - -For the `subql-starter` project, you can try to query with the following code to get a taste of how it works. - -````graphql -{ - query{ - starterEntities(first:10){ - nodes{ - field1, - field2, - field3 - } - } - } -} -```` diff --git a/moonbeam-evm/docker-compose.yml b/moonbeam-evm/docker-compose.yml deleted file mode 100644 index ed1450c..0000000 --- a/moonbeam-evm/docker-compose.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - - "subquery-node" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground - - --indexer=http://subquery-node:3000 diff --git a/moonbeam-evm/package.json b/moonbeam-evm/package.json deleted file mode 100644 index 6b21cf5..0000000 --- a/moonbeam-evm/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "moonbeam-dictionary", - "version": "0.1.0", - "description": "subquery diction for moonbase-alpha and moonriver", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans", - "test": "subql build && subql-node test" - }, - "homepage": "https://github.com/subquery/moonbeam-dictionary", - "repository": "github:subquery/moonbeam-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "author": "Ian He", - "license": "Apache-2.0", - "resolutions": { - "ipfs-unixfs": "6.0.6" - }, - "devDependencies": { - "@polkadot/api": "^9", - "@subql/cli": "latest", - "@subql/frontier-evm-processor": "^0.1.4", - "@subql/testing": "^2.0.1", - "@subql/types": "latest", - "abab": "latest", - "moonbeam-types-bundle": "^2.0.7", - "typescript": "^4.6.2" - } -} diff --git a/moonbeam-evm/project.yaml b/moonbeam-evm/project.yaml deleted file mode 100644 index 66d7f66..0000000 --- a/moonbeam-evm/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Moonbeam -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xfe58ea77779b7abda7da4ec526d14db9b1e9cd40a217c34892af80a9b332b76d' - endpoint: 'wss://moonbeam.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/moonbeam-evm/project_moonbeam-alpha.yaml b/moonbeam-evm/project_moonbeam-alpha.yaml deleted file mode 100644 index 42b4c4b..0000000 --- a/moonbeam-evm/project_moonbeam-alpha.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Moonbase Alpha -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x91bc6e169807aaa54802737e1c504b2577d4fafedd5a02c10293b1cd60e39527' - endpoint: 'wss://moonbeam-alpha.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/moonbeam-evm/project_moonriver.yaml b/moonbeam-evm/project_moonriver.yaml deleted file mode 100644 index 6bf3b6d..0000000 --- a/moonbeam-evm/project_moonriver.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Moonriver -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x401a1f9dca3da46f5c4091016c8a2f26dcea05865116b286f60f668207d1474b' - endpoint: 'wss://moonriver.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/moonbeam-evm/schema.graphql b/moonbeam-evm/schema.graphql deleted file mode 100644 index 37557d1..0000000 --- a/moonbeam-evm/schema.graphql +++ /dev/null @@ -1,48 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} - -type EvmTransaction @entity { - id: ID! - txHash: String! - """A lowercase address of the sender""" - from: String! @index - """A lowercase address. This will be null for contract creations""" - to: String @index - """A lowercased function sighash extracted from the data field""" - func: String @index - blockHeight: BigInt! @index - success: Boolean! -} - -type EvmLog @entity { - id: ID! - """The contract address that emitted the event. Lowercased""" - address: String! @index - blockHeight: BigInt! @index - """The lowercase event signature""" - topics0: String! @index - """The lowercase first indexed argument""" - topics1: String - """The lowercase second indexed argument""" - topics2: String - """The lowercase third indexed argument""" - topics3: String -} diff --git a/moonbeam-evm/src/chaintypes.ts b/moonbeam-evm/src/chaintypes.ts deleted file mode 100644 index 8f6229e..0000000 --- a/moonbeam-evm/src/chaintypes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import {typesBundlePre900} from 'moonbeam-types-bundle'; - -export default {typesBundle: typesBundlePre900}; diff --git a/moonbeam-evm/src/index.ts b/moonbeam-evm/src/index.ts deleted file mode 100644 index 7d1d562..0000000 --- a/moonbeam-evm/src/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -//Exports all handler functions -import {atob} from 'abab'; - -if (!global.atob) { - global.atob = atob; -} -export * from './mappings/mappingHandlers' -import "@polkadot/api-augment" diff --git a/moonbeam-evm/src/mappings/mappingHandlers.ts b/moonbeam-evm/src/mappings/mappingHandlers.ts deleted file mode 100644 index 4fe819e..0000000 --- a/moonbeam-evm/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,105 +0,0 @@ -import {EventRecord, EvmLog,TransactionV2, EthTransaction ,AccountId, Address} from "@polkadot/types/interfaces" -import {SubstrateExtrinsic,SubstrateBlock} from "@subql/types"; -import { SpecVersion, Event, Extrinsic, EvmLog as EvmLogModel, EvmTransaction } from "../types"; -import FrontierEvmDatasourcePlugin, { FrontierEvmCall } from "@subql/frontier-evm-processor/"; -import { inputToFunctionSighash, isZero, wrapExtrinsics } from "../utils"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - if(!specVersion || specVersion.id !== block.specVersion.toString()){ - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - const eventData = block.events.filter(evt => evt.event.section!=='system' && evt.event.method!=='ExtrinsicSuccess').map((evt, idx)=>handleEvent(block.block.header.number.toString(), idx, evt)); - const events = eventData.map(([evt])=>evt); - const logs = eventData.map(([_,log])=>log).filter(log=>log); - const calls = wrapExtrinsics(block).map((ext,idx)=>handleCall(`${block.block.header.number.toString()}-${idx}`,ext)); - const evmCalls = await Promise.all(wrapExtrinsics(block).filter(ext => ext.extrinsic.method.section === 'ethereum' && ext.extrinsic.method.method === 'transact').map( (ext) => FrontierEvmDatasourcePlugin.handlerProcessors['substrate/FrontierEvmCall'].transformer({ - input: ext as SubstrateExtrinsic<[TransactionV2 | EthTransaction]>, - ds:{} as any, - filter: undefined, - api: undefined} - ))) as [FrontierEvmCall][]; - await Promise.all([ - store.bulkCreate('Event', events), - store.bulkCreate('EvmLog', logs), - store.bulkCreate('Extrinsic', calls), - store.bulkCreate('EvmTransaction', evmCalls - .map((call,idx)=>handleEvmTransaction(`${block.block.header.number.toString()}-${idx}`,call)) - .filter(tx=>tx) - ), - ]); -} - -export function handleEvent(blockNumber: string, eventIdx: number, event: EventRecord): [Event, EvmLogModel] { - const newEvent = Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); - const ret: [Event, EvmLogModel] = [newEvent, undefined]; - if (event.event.section === 'evm' && event.event.method === 'Log') { - ret[1] = handleEvmEvent(blockNumber, eventIdx, event); - } - return ret; -} - -export function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function handleEvmEvent(blockNumber: string, eventIdx: number, event: EventRecord): EvmLogModel { - let address; - let data; - let topics; - const [log] = event.event.data as unknown as [{log:EvmLog} | EvmLog] - - if((log as EvmLog).address){ - address = (log as EvmLog).address - topics = (log as EvmLog).topics - }else{ - address = (log as {log: EvmLog}).log.address; - topics = (log as {log: EvmLog}).log.topics; - } - return EvmLogModel.create({ - id: `${blockNumber}-${eventIdx}`, - address: address.toString(), - blockHeight: BigInt(blockNumber), - topics0: topics[0]?.toHex().toLowerCase(), - topics1: topics[1]?.toHex().toLowerCase(), - topics2: topics[2]?.toHex().toLowerCase(), - topics3: topics[3]?.toHex().toLowerCase(), - }); -} - -export function handleEvmTransaction(idx: string, transaction: [FrontierEvmCall]): EvmTransaction { - const [tx] = transaction - if (!tx.hash) { - return; - } - const func = isZero(tx.data) ? undefined : inputToFunctionSighash(tx.data).toLowerCase(); - return EvmTransaction.create({ - id: idx, - txHash: tx.hash, - from: tx.from.toLowerCase(), - to: tx.to?.toLowerCase(), - func, - blockHeight: BigInt(tx.blockNumber.toString()), - success: tx.success, - }); -} diff --git a/moonbeam-evm/src/tests/moonbeam.test.ts b/moonbeam-evm/src/tests/moonbeam.test.ts deleted file mode 100644 index bc9f80d..0000000 --- a/moonbeam-evm/src/tests/moonbeam.test.ts +++ /dev/null @@ -1,28 +0,0 @@ - - - -import { subqlTest } from '@subql/testing'; -import { EvmTransaction} from '../types'; - - -// https://moonbeam.moonscan.io/txs?block=2847447 -// https://moonbeam.subscan.io/block/2847447 -const blockNumber = 2847447; - -subqlTest( - 'Contract Creation', - blockNumber, - [], - [ - EvmTransaction.create({ - id: `${blockNumber}-${5}`, - from: '0x16f615a38528764eea9c6388a8c4e1fc8305cbb3', - to: null, - blockHeight: BigInt(blockNumber), - func:'0x600d805', - success: true, - txHash: '0x24bef923522a4d6a79f9ab9242a74fb987dce94002c0f107c2a7d0b7e24bcf05' - }) - ], - 'handleBlock' -); diff --git a/moonbeam-evm/src/utils.ts b/moonbeam-evm/src/utils.ts deleted file mode 100644 index 9e35d24..0000000 --- a/moonbeam-evm/src/utils.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {hexDataSlice, stripZeros} from '@ethersproject/bytes'; -import {EventRecord} from "@polkadot/types/interfaces" -import { SubstrateBlock, SubstrateExtrinsic } from "@subql/types"; - -export function inputToFunctionSighash(input: string): string { - return hexDataSlice(input, 0, 4); -} - -export function isZero(input: string): boolean { - return stripZeros(input).length === 0; -} - -function filterExtrinsicEvents( - extrinsicIdx: number, - events: EventRecord[], -): EventRecord[] { - return events.filter( - ({ phase }) => - phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(extrinsicIdx), - ); -} - -export function wrapExtrinsics( - wrappedBlock: SubstrateBlock, -): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = filterExtrinsicEvents(idx, wrappedBlock.events); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: getExtrinsicSuccess(events), - }; - }); -} - -function getExtrinsicSuccess(events: EventRecord[]): boolean { - return ( - events.findIndex((evt) => evt.event.method === 'ExtrinsicSuccess') > -1 - ); -} diff --git a/moonbeam-evm/tsconfig.json b/moonbeam-evm/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/moonbeam-evm/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/neumann/.gitignore b/neumann/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/neumann/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/neumann/README.md b/neumann/README.md deleted file mode 100644 index 1237e25..0000000 --- a/neumann/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/neumann/docker-compose.yml b/neumann/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/neumann/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/neumann/package.json b/neumann/package.json deleted file mode 100644 index 872075d..0000000 --- a/neumann/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/neumann/project.yaml b/neumann/project.yaml deleted file mode 100644 index 4c2305d..0000000 --- a/neumann/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Neumann Network -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x42e75532d6809775cef4b9ca8e4bb49be2dc1e87c9ff1ba299e78481b5cb3047' - endpoint: 'wss://neumann.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/neumann/schema.graphql b/neumann/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/neumann/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/neumann/src/chaintypes.ts b/neumann/src/chaintypes.ts deleted file mode 100644 index fca86d9..0000000 --- a/neumann/src/chaintypes.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - Contribution: { - account_id: 'AccountId', - value: 'Balance' - }, - Grant: { - contributions: 'Vec', - is_approved: 'bool', - is_canceled: 'bool', - is_withdrawn: 'bool', - matching_fund: 'Balance', - project_index: 'ProjectIndex', - withdrawal_expiration: 'BlockNumber' - }, - Project: { - create_block_number: 'BlockNumber', - description: 'Vec', - logo: 'Vec', - name: 'Vec', - owner: 'AccountId', - website: 'Vec' - }, - ProjectIndex: 'u32', - ProjectOf: 'Project', - Round: { - end: 'BlockNumber', - grants: 'Vec', - is_canceled: 'bool', - is_finalized: 'bool', - matching_fund: 'Balance', - start: 'BlockNumber' - }, - RoundIndex: 'u32', - RoundOf: 'Round' - } - } - ] -}; - -export default { typesBundle: definitions }; diff --git a/neumann/src/index.ts b/neumann/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/neumann/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/neumann/src/mappings/mappingHandlers.ts b/neumann/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/neumann/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/neumann/tsconfig.json b/neumann/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/neumann/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/nodle-parachain/.gitignore b/nodle-parachain/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/nodle-parachain/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/nodle-parachain/.project-cid b/nodle-parachain/.project-cid deleted file mode 100644 index 1d55c8f..0000000 --- a/nodle-parachain/.project-cid +++ /dev/null @@ -1 +0,0 @@ -QmQtmsHoJEYUcxKE4tBqr9Z8kudcgkczQPfhkAxVExQX5y \ No newline at end of file diff --git a/nodle-parachain/README.md b/nodle-parachain/README.md deleted file mode 100644 index 1237e25..0000000 --- a/nodle-parachain/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/nodle-parachain/docker-compose.yml b/nodle-parachain/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/nodle-parachain/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/nodle-parachain/package.json b/nodle-parachain/package.json deleted file mode 100644 index 647b042..0000000 --- a/nodle-parachain/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/nodle-parachain/project.yaml b/nodle-parachain/project.yaml deleted file mode 100644 index 6010815..0000000 --- a/nodle-parachain/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Nodle Chain Network -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x97da7ede98d7bad4e36b4d734b6055425a3be036da2a332ea5a7037656427a21' - endpoint: 'wss://nodle-parachain.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/nodle-parachain/schema.graphql b/nodle-parachain/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/nodle-parachain/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/nodle-parachain/src/chaintypes.ts b/nodle-parachain/src/chaintypes.ts deleted file mode 100644 index e18d0fd..0000000 --- a/nodle-parachain/src/chaintypes.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - Amendment: 'Call', - Application: { - candidate: 'AccountId', - candidate_deposit: 'Balance', - challenged_block: 'BlockNumber', - challenger: 'Option', - challenger_deposit: 'Option', - created_block: 'BlockNumber', - metadata: 'Vec', - voters_against: 'Vec<(AccountId, Balance)>', - voters_for: 'Vec<(AccountId, Balance)>', - votes_against: 'Option', - votes_for: 'Option' - }, - CertificateId: 'AccountId', - RootCertificate: { - child_revocations: 'Vec', - created: 'BlockNumber', - key: 'CertificateId', - owner: 'AccountId', - renewed: 'BlockNumber', - revoked: 'bool', - validity: 'BlockNumber' - }, - VestingSchedule: { - start: 'BlockNumber', - period: 'BlockNumber', - period_count: 'u32', - per_period: 'Balance' - }, - VestingScheduleOf: 'VestingSchedule' - } - } - ] -}; - -export default { typesBundle: {spec: {"nodle-parachain": definitions}}}; diff --git a/nodle-parachain/src/index.ts b/nodle-parachain/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/nodle-parachain/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/nodle-parachain/src/mappings/mappingHandlers.ts b/nodle-parachain/src/mappings/mappingHandlers.ts deleted file mode 100644 index 16c64f5..0000000 --- a/nodle-parachain/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - txHash: extrinsic.extrinsic.hash.toString(), - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/nodle-parachain/tsconfig.json b/nodle-parachain/tsconfig.json deleted file mode 100644 index 450689b..0000000 --- a/nodle-parachain/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true, - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/centrifuge/package.json b/package.json similarity index 100% rename from centrifuge/package.json rename to package.json diff --git a/parallel-heiko/.gitignore b/parallel-heiko/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/parallel-heiko/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/parallel-heiko/README.md b/parallel-heiko/README.md deleted file mode 100644 index 1237e25..0000000 --- a/parallel-heiko/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/parallel-heiko/docker-compose.yml b/parallel-heiko/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/parallel-heiko/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/parallel-heiko/package.json b/parallel-heiko/package.json deleted file mode 100644 index 942e0f7..0000000 --- a/parallel-heiko/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest", - "@parallel-finance/type-definitions": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/parallel-heiko/project.yaml b/parallel-heiko/project.yaml deleted file mode 100644 index aec7836..0000000 --- a/parallel-heiko/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Parallel Heiko -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x64a1c658a48b2e70a7fb1ad4c39eea35022568c20fc44a6e2e3d0a57aee6053b' - endpoint: 'wss://parallel-heiko.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/parallel-heiko/schema.graphql b/parallel-heiko/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/parallel-heiko/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/parallel-heiko/src/chaintypes.ts b/parallel-heiko/src/chaintypes.ts deleted file mode 100644 index 29905de..0000000 --- a/parallel-heiko/src/chaintypes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { typesBundleForPolkadot } from '@parallel-finance/type-definitions'; - -export default { typesBundle: typesBundleForPolkadot }; diff --git a/parallel-heiko/src/index.ts b/parallel-heiko/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/parallel-heiko/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/parallel-heiko/src/mappings/mappingHandlers.ts b/parallel-heiko/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/parallel-heiko/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/parallel-heiko/tsconfig.json b/parallel-heiko/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/parallel-heiko/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/parallel/.gitignore b/parallel/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/parallel/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/parallel/README.md b/parallel/README.md deleted file mode 100644 index 1237e25..0000000 --- a/parallel/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/parallel/docker-compose.yml b/parallel/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/parallel/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/parallel/package.json b/parallel/package.json deleted file mode 100644 index 942e0f7..0000000 --- a/parallel/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest", - "@parallel-finance/type-definitions": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/parallel/project.yaml b/parallel/project.yaml deleted file mode 100644 index a949f37..0000000 --- a/parallel/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Parallel Finance -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xe61a41c53f5dcd0beb09df93b34402aada44cb05117b71059cce40a2723a4e97' - endpoint: 'wss://parallel.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/parallel/schema.graphql b/parallel/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/parallel/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/parallel/src/chaintypes.ts b/parallel/src/chaintypes.ts deleted file mode 100644 index 4da807a..0000000 --- a/parallel/src/chaintypes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { typesBundleForPolkadot } from "@parallel-finance/type-definitions"; - -export default { typesBundle: typesBundleForPolkadot }; diff --git a/parallel/src/index.ts b/parallel/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/parallel/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/parallel/src/mappings/mappingHandlers.ts b/parallel/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/parallel/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/parallel/tsconfig.json b/parallel/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/parallel/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/polkadex/.gitignore b/polkadex/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/polkadex/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/polkadex/README.md b/polkadex/README.md deleted file mode 100644 index 47cb1f5..0000000 --- a/polkadex/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` - -### 4. Queries - -Event: - -``` -query { - events(first: 10, filter: {blockHeight : {equalTo:"4515186"}}) { - nodes { - id, - module, - event, - blockHeight - } - } -} -``` - -Extrinsic: - -``` -query { - extrinsics(first: 10, filter: {blockHeight : {equalTo:"4515186"}}) { - nodes { - id, - module, - call, - blockHeight, - success, - isSigned, - } - } -} -``` - -SpecVersion: - -``` -query { - specVersions(first: 10) { - nodes { - id, - blockHeight - } - } -} -``` \ No newline at end of file diff --git a/polkadex/docker-compose.yml b/polkadex/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/polkadex/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/polkadex/package.json b/polkadex/package.json deleted file mode 100644 index 105bf51..0000000 --- a/polkadex/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/cli": "latest", - "@subql/types": "latest", - "typescript": "^5.0.4" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - } -} diff --git a/polkadex/project.yaml b/polkadex/project.yaml deleted file mode 100644 index 3cd1033..0000000 --- a/polkadex/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Polkadex -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x3920bcb4960a1eef5580cd5367ff3f430eef052774f78468852f7b9cb39f8a3c' - endpoint: 'wss://polkadex.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/polkadex/schema.graphql b/polkadex/schema.graphql deleted file mode 100644 index d93080a..0000000 --- a/polkadex/schema.graphql +++ /dev/null @@ -1,20 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} \ No newline at end of file diff --git a/polkadex/src/chainTypes.ts b/polkadex/src/chainTypes.ts deleted file mode 100644 index 1c808af..0000000 --- a/polkadex/src/chainTypes.ts +++ /dev/null @@ -1,16 +0,0 @@ - -import type { OverrideBundleDefinition } from '@polkadot/types/types'; - -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [{ - minmax: [0, undefined], - types: { - DispatchErrorModule: 'DispatchErrorModuleU8' - } - }] -} - -export default { typesBundle: { spec: { "node": definitions }}}; diff --git a/polkadex/src/index.ts b/polkadex/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/polkadex/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/polkadex/src/mappings/mappingHandlers.ts b/polkadex/src/mappings/mappingHandlers.ts deleted file mode 100644 index cd0bcae..0000000 --- a/polkadex/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !( - evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess" - ) - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} \ No newline at end of file diff --git a/polkadex/tsconfig.json b/polkadex/tsconfig.json deleted file mode 100644 index 4146dec..0000000 --- a/polkadex/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} \ No newline at end of file diff --git a/polkadot/.gitignore b/polkadot/.gitignore deleted file mode 100644 index 7bc6395..0000000 --- a/polkadot/.gitignore +++ /dev/null @@ -1,54 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data - diff --git a/polkadot/README.md b/polkadot/README.md deleted file mode 100644 index 1237e25..0000000 --- a/polkadot/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/polkadot/docker-compose.yml b/polkadot/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/polkadot/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/polkadot/package.json b/polkadot/package.json deleted file mode 100644 index b70977b..0000000 --- a/polkadot/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^10", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/polkadot/project.yaml b/polkadot/project.yaml deleted file mode 100644 index f73ce32..0000000 --- a/polkadot/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Polkadot -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3' - endpoint: 'wss://polkadot.api.onfinality.io/public-ws' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/polkadot/schema.graphql b/polkadot/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/polkadot/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/polkadot/src/index.ts b/polkadot/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/polkadot/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/polkadot/src/mappings/mappingHandlers.ts b/polkadot/src/mappings/mappingHandlers.ts deleted file mode 100644 index ca0b625..0000000 --- a/polkadot/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString(),block.block.header.number.toBigInt()); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`,event.event.section,event.event.method,BigInt(blockNumber)); - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic( - idx, - extrinsic.extrinsic.hash.toString(), - extrinsic.extrinsic.method.section, - extrinsic.extrinsic.method.method, - extrinsic.block.block.header.number.toBigInt(), - extrinsic.success, - extrinsic.extrinsic.isSigned - ); - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/polkadot/tsconfig.json b/polkadot/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/polkadot/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/centrifuge/project.yaml b/project.yaml similarity index 100% rename from centrifuge/project.yaml rename to project.yaml diff --git a/quartz/.gitignore b/quartz/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/quartz/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/quartz/README.md b/quartz/README.md deleted file mode 100644 index 1237e25..0000000 --- a/quartz/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/quartz/docker-compose.yml b/quartz/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/quartz/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/quartz/package.json b/quartz/package.json deleted file mode 100644 index 61954ea..0000000 --- a/quartz/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest", - "@unique-nft/types": "latest" - }, - "exports": { - "chaintypes": "src/chaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/quartz/project.yaml b/quartz/project.yaml deleted file mode 100644 index dbfbd3c..0000000 --- a/quartz/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - QUARTZ by UNIQUE -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xcd4d732201ebe5d6b014edda071c4203e16867305332301dc8d092044b28e554' - endpoint: 'wss://quartz.api.onfinality.io/public-ws' - chaintypes: - file: ./dist/chaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/quartz/schema.graphql b/quartz/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/quartz/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/quartz/src/chaintypes.ts b/quartz/src/chaintypes.ts deleted file mode 100644 index e810c0a..0000000 --- a/quartz/src/chaintypes.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { OverrideBundleDefinition } from "@polkadot/types/types"; - -import { unique } from "@unique-nft/types/definitions"; - -export default { - typesBundle: { - rpc: { unique: unique.rpc }, - } as OverrideBundleDefinition, -}; diff --git a/quartz/src/index.ts b/quartz/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/quartz/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/quartz/src/mappings/mappingHandlers.ts b/quartz/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/quartz/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/quartz/tsconfig.json b/quartz/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/quartz/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/altair/schema.graphql b/schema.graphql similarity index 100% rename from altair/schema.graphql rename to schema.graphql diff --git a/altair/src/chaintypes.ts b/src/chaintypes.ts similarity index 100% rename from altair/src/chaintypes.ts rename to src/chaintypes.ts diff --git a/aleph-zero/src/index.ts b/src/index.ts similarity index 100% rename from aleph-zero/src/index.ts rename to src/index.ts diff --git a/centrifuge/src/mappings/mappingHandlers.ts b/src/mappings/mappingHandlers.ts similarity index 100% rename from centrifuge/src/mappings/mappingHandlers.ts rename to src/mappings/mappingHandlers.ts diff --git a/statemine/.gitignore b/statemine/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/statemine/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/statemine/README.md b/statemine/README.md deleted file mode 100644 index 1237e25..0000000 --- a/statemine/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/statemine/docker-compose.yml b/statemine/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/statemine/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/statemine/package.json b/statemine/package.json deleted file mode 100644 index 45c7272..0000000 --- a/statemine/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/statemine/project.yaml b/statemine/project.yaml deleted file mode 100644 index b043de0..0000000 --- a/statemine/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Statemine -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a' - endpoint: 'wss://statemine.api.onfinality.io/public-ws' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/statemine/schema.graphql b/statemine/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/statemine/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/statemine/src/index.ts b/statemine/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/statemine/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/statemine/src/mappings/mappingHandlers.ts b/statemine/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/statemine/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/statemine/tsconfig.json b/statemine/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/statemine/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/statemint/.gitignore b/statemint/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/statemint/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/statemint/README.md b/statemint/README.md deleted file mode 100644 index 1237e25..0000000 --- a/statemint/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/statemint/docker-compose.yml b/statemint/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/statemint/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/statemint/package.json b/statemint/package.json deleted file mode 100644 index 45c7272..0000000 --- a/statemint/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "^9", - "@subql/types": "latest", - "typescript": "^4.1.3", - "@subql/cli": "latest" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/statemint/project.yaml b/statemint/project.yaml deleted file mode 100644 index f6e1f76..0000000 --- a/statemint/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Statemint -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f' - endpoint: 'wss://statemint.api.onfinality.io/public-ws' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/statemint/schema.graphql b/statemint/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/statemint/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/statemint/src/index.ts b/statemint/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/statemint/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/statemint/src/mappings/mappingHandlers.ts b/statemint/src/mappings/mappingHandlers.ts deleted file mode 100644 index 22cccff..0000000 --- a/statemint/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString()); - specVersion.blockHeight = block.block.header.number.toBigInt(); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`); - newEvent.blockHeight = BigInt(blockNumber); - newEvent.module = event.event.section; - newEvent.event = event.event.method; - return newEvent; -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - const newExtrinsic = new Extrinsic(idx); - newExtrinsic.txHash = extrinsic.extrinsic.hash.toString(); - newExtrinsic.module = extrinsic.extrinsic.method.section; - newExtrinsic.call = extrinsic.extrinsic.method.method; - newExtrinsic.blockHeight = extrinsic.block.block.header.number.toBigInt(); - newExtrinsic.success = extrinsic.success; - newExtrinsic.isSigned = extrinsic.extrinsic.isSigned; - return newExtrinsic; -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/statemint/tsconfig.json b/statemint/tsconfig.json deleted file mode 100644 index 9b95212..0000000 --- a/statemint/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017" - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/altair/tsconfig.json b/tsconfig.json similarity index 100% rename from altair/tsconfig.json rename to tsconfig.json diff --git a/turing/.gitignore b/turing/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/turing/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/turing/README.md b/turing/README.md deleted file mode 100644 index d0b6db2..0000000 --- a/turing/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` - -### 4. Queries - -Event: - -``` -query { - events(first: 10, filter: {blockHeight : {equalTo:"2804408"}}) { - nodes { - id, - module, - event, - blockHeight - } - } -} -``` - -Extrinsic: - -``` -query { - extrinsics(first: 10, filter: {blockHeight : {equalTo:"2804408"}}) { - nodes { - id, - module, - call, - blockHeight, - success, - isSigned, - } - } -} -``` - -SpecVersion: - -``` -query { - specVersions(first: 10) { - nodes { - id, - blockHeight - } - } -} -``` \ No newline at end of file diff --git a/turing/docker-compose.yml b/turing/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/turing/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/turing/package.json b/turing/package.json deleted file mode 100644 index 1558687..0000000 --- a/turing/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/cli": "latest", - "@subql/types": "latest", - "typescript": "^5.0.4" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} \ No newline at end of file diff --git a/turing/project.yaml b/turing/project.yaml deleted file mode 100644 index 214cb99..0000000 --- a/turing/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Turing -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x0f62b701fb12d02237a33b84818c11f621653d2b1614c777973babf4652b535d' - endpoint: 'wss://turing-rpc.dwellir.com' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/turing/schema.graphql b/turing/schema.graphql deleted file mode 100644 index d93080a..0000000 --- a/turing/schema.graphql +++ /dev/null @@ -1,20 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} \ No newline at end of file diff --git a/turing/src/index.ts b/turing/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/turing/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/turing/src/mappings/mappingHandlers.ts b/turing/src/mappings/mappingHandlers.ts deleted file mode 100644 index cd0bcae..0000000 --- a/turing/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !( - evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess" - ) - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} \ No newline at end of file diff --git a/turing/tsconfig.json b/turing/tsconfig.json deleted file mode 100644 index 4146dec..0000000 --- a/turing/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} \ No newline at end of file diff --git a/westend/.gitignore b/westend/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/westend/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/westend/.project-cid b/westend/.project-cid deleted file mode 100644 index f3e2403..0000000 --- a/westend/.project-cid +++ /dev/null @@ -1 +0,0 @@ -Qma6BeSQGHrhP5aydmkQcJCR25TEwuNMogS5boovBBwoeW \ No newline at end of file diff --git a/westend/README.md b/westend/README.md deleted file mode 100644 index 1237e25..0000000 --- a/westend/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` diff --git a/westend/docker-compose.yml b/westend/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/westend/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/westend/package.json b/westend/package.json deleted file mode 100644 index c224403..0000000 --- a/westend/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/cli": "latest", - "@subql/types": "latest", - "typescript": "^5.0.4" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} diff --git a/westend/project.yaml b/westend/project.yaml deleted file mode 100644 index 530040a..0000000 --- a/westend/project.yaml +++ /dev/null @@ -1,27 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Westend -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e' - endpoint: 'wss://westend.api.onfinality.io/public-ws' -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/westend/schema.graphql b/westend/schema.graphql deleted file mode 100644 index 3c0fd50..0000000 --- a/westend/schema.graphql +++ /dev/null @@ -1,21 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - txHash: String! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} diff --git a/westend/src/index.ts b/westend/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/westend/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/westend/src/mappings/mappingHandlers.ts b/westend/src/mappings/mappingHandlers.ts deleted file mode 100644 index 16c64f5..0000000 --- a/westend/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !(evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess") - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - txHash: extrinsic.extrinsic.hash.toString(), - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} diff --git a/westend/tsconfig.json b/westend/tsconfig.json deleted file mode 100644 index 2394621..0000000 --- a/westend/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "target": "es2017", - "strict": true - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} diff --git a/zeitgeist/.gitignore b/zeitgeist/.gitignore deleted file mode 100644 index 5140c32..0000000 --- a/zeitgeist/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ -yarn.lock - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ -src/types - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -.data \ No newline at end of file diff --git a/zeitgeist/README.md b/zeitgeist/README.md deleted file mode 100644 index 082a688..0000000 --- a/zeitgeist/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# SubQuery - Dictionary - -This special SubQuery Project provides a dictionary of data that pre-indexes events on chain to dramatically improve indexing the performance of your own SubQuery Project, sometimes up to 10x faster. - -It scans over the network, and simply records the module and method for every event/extrinsic on each block - please see the standard entities in `schema.graphql`. - -**If you want to create your SubQuery Dictionary to speed up indexing of your own Substrate chain, fork this project and let us know** - -# Geting Started -### 1. Install dependencies -```shell -yarn -``` - -### 2. Generate types -```shell -yarn codegen -``` - -### 3. Build -```shell -yarn build -``` - -### 4. Run locally -```shell -yarn start:docker -``` - -### 4. Queries - -Event: - -``` -query { - events(first: 10, filter: {blockHeight : {equalTo:"3185132"}}) { - nodes { - id, - module, - event, - blockHeight - } - } -} -``` - -Extrinsic: - -``` -query { - extrinsics(first: 10, filter: {blockHeight : {equalTo:"3185132"}}) { - nodes { - id, - module, - call, - blockHeight, - success, - isSigned, - } - } -} -``` - -SpecVersion: - -``` -query { - specVersions(first: 10) { - nodes { - id, - blockHeight - } - } -} -``` \ No newline at end of file diff --git a/zeitgeist/chainTypes/zeitgeistChaintypes.ts b/zeitgeist/chainTypes/zeitgeistChaintypes.ts deleted file mode 100644 index b84e929..0000000 --- a/zeitgeist/chainTypes/zeitgeistChaintypes.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { OverrideBundleType } from '@polkadot/types/types'; -import * as typeDefs from '@zeitgeistpm/type-defs'; - -export function typesFromDefs (definitions: Record }>): Record { - return Object - .values(definitions) - .reduce((res: Record, { types }): Record => ({ - ...res, - ...types - }), {}); -} - - -const types = { - alias: { - tokens: { - AccountData: 'TokensAccountData' - } - }, - types: [{ - minmax: [0, undefined], - types: { - // the cast here is needed to make the build happy, - // however the output is actually correct as well... - // in ts: ...typesFromDefs(typeDefs as unknown as Record }>), - ...typesFromDefs(typeDefs), - TokensAccountData: { - free: 'Balance', - frozen: 'Balance', - reserved: 'Balance' - }, - // Fixed from block 1 to 166730 - RegistrationInfo: { - account: "AccountId", - deposit: "Balance" - }, - AuthorId: "AccountId" - } - }] -}; - -const typesBundle: OverrideBundleType = { - spec: { - zeitgeist: types, - }, -} - -export default { - types: { - }, - typesBundle -}; \ No newline at end of file diff --git a/zeitgeist/docker-compose.yml b/zeitgeist/docker-compose.yml deleted file mode 100644 index ba1834d..0000000 --- a/zeitgeist/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:12-alpine - ports: - - 5432:5432 - volumes: - - .data/postgres:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgres - - subquery-node: - image: onfinality/subql-node:latest - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - volumes: - - ./:/app - command: - - -f=/app - - --disable-historical=true - - graphql-engine: - image: onfinality/subql-query:latest - ports: - - 3000:3000 - depends_on: - - "postgres" - restart: always - environment: - DB_USER: postgres - DB_PASS: postgres - DB_DATABASE: postgres - DB_HOST: postgres - DB_PORT: 5432 - command: - - --name=app - - --playground diff --git a/zeitgeist/package.json b/zeitgeist/package.json deleted file mode 100644 index abcd639..0000000 --- a/zeitgeist/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "subql-dictionary", - "version": "1.0.0", - "description": "A SubQuery Dictionary Project that provides increased indexing speed to all projects", - "main": "dist/index.js", - "scripts": { - "build": "subql build", - "prepack": "rm -rf dist && npm build", - "test": "jest", - "codegen": "./node_modules/.bin/subql codegen", - "start:docker": "docker-compose pull && docker-compose up --remove-orphans" - }, - "homepage": "https://github.com/subquery/subql-dictionary", - "repository": "github:subquery/subql-dictionary", - "files": [ - "dist", - "schema.graphql", - "project.yaml" - ], - "author": "SubQuery Network", - "license": "Apache-2.0", - "devDependencies": { - "@polkadot/api": "10.1.4", - "@subql/cli": "latest", - "@subql/types": "latest", - "typescript": "^5.0.4", - "@zeitgeistpm/type-defs": "^0.8.0" - }, - "exports": { - "zeitgeistChaintypes": "./chainTypes/zeitgeistChaintypes.ts" - }, - "resolutions": { - "ipfs-unixfs": "6.0.6" - } -} \ No newline at end of file diff --git a/zeitgeist/project.yaml b/zeitgeist/project.yaml deleted file mode 100644 index 3f6ad92..0000000 --- a/zeitgeist/project.yaml +++ /dev/null @@ -1,29 +0,0 @@ -specVersion: 1.0.0 -name: SubQuery Dictionary - Zeitgeist -version: 1.0.0 -runner: - node: - name: '@subql/node' - version: '*' - query: - name: '@subql/query' - version: '*' -description: >- - A SubQuery Dictionary Project that provides increased indexing speed to all - projects -repository: 'https://github.com/subquery/subql-dictionary' -schema: - file: ./schema.graphql -network: - chainId: '0x1bf2a2ecb4a868de66ea8610f2ce7c8c43706561b6476031315f6640fe38e060' - endpoint: 'wss://zeitgeist-rpc.dwellir.com' - chaintypes: - file: ./dist/zeitgeistChaintypes.js -dataSources: - - kind: substrate/Runtime - startBlock: 1 - mapping: - file: ./dist/index.js - handlers: - - handler: handleBlock - kind: substrate/BlockHandler diff --git a/zeitgeist/schema.graphql b/zeitgeist/schema.graphql deleted file mode 100644 index d93080a..0000000 --- a/zeitgeist/schema.graphql +++ /dev/null @@ -1,20 +0,0 @@ -type SpecVersion @entity { - id: ID! #specVersion - blockHeight: BigInt! -} - -type Event @entity { - id: ID! - module: String! @index - event: String! @index - blockHeight: BigInt! @index -} - -type Extrinsic @entity { - id: ID! - module: String! @index - call: String! @index - blockHeight: BigInt! @index - success: Boolean! - isSigned: Boolean! -} \ No newline at end of file diff --git a/zeitgeist/src/index.ts b/zeitgeist/src/index.ts deleted file mode 100644 index 5091615..0000000 --- a/zeitgeist/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -//Exports all handler functions -export * from "./mappings/mappingHandlers"; -import "@polkadot/api-augment"; diff --git a/zeitgeist/src/mappings/mappingHandlers.ts b/zeitgeist/src/mappings/mappingHandlers.ts deleted file mode 100644 index cd0bcae..0000000 --- a/zeitgeist/src/mappings/mappingHandlers.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; -import { SpecVersion, Event, Extrinsic } from "../types"; - -let specVersion: SpecVersion | undefined; -export async function handleBlock(block: SubstrateBlock): Promise { - // Initialise Spec Version - if (!specVersion) { - specVersion = await SpecVersion.get(block.specVersion.toString()); - } - - // Check for updates to Spec Version - if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = SpecVersion.create({ - id: block.specVersion.toString(), - blockHeight: block.block.header.number.toBigInt(), - }); - await specVersion.save(); - } - - // Process all events in block - const events = block.events - .filter( - (evt) => - !( - evt.event.section === "system" && - evt.event.method === "ExtrinsicSuccess" - ) - ) - .map((evt, idx) => - handleEvent(block.block.header.number.toString(), idx, evt) - ); - - // Process all calls in block - const calls = wrapExtrinsics(block).map((ext, idx) => - handleCall(`${block.block.header.number.toString()}-${idx}`, ext) - ); - - // Save all data - await Promise.all([ - store.bulkCreate("Event", events), - store.bulkCreate("Extrinsic", calls), - ]); -} - -function handleEvent( - blockNumber: string, - eventIdx: number, - event: EventRecord -): Event { - return Event.create({ - id: `${blockNumber}-${eventIdx}`, - blockHeight: BigInt(blockNumber), - module: event.event.section, - event: event.event.method, - }); -} - -function handleCall(idx: string, extrinsic: SubstrateExtrinsic): Extrinsic { - return Extrinsic.create({ - id: idx, - module: extrinsic.extrinsic.method.section, - call: extrinsic.extrinsic.method.method, - blockHeight: extrinsic.block.block.header.number.toBigInt(), - success: extrinsic.success, - isSigned: extrinsic.extrinsic.isSigned, - }); -} - -function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { - return wrappedBlock.block.extrinsics.map((extrinsic, idx) => { - const events = wrappedBlock.events.filter( - ({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(idx) - ); - return { - idx, - extrinsic, - block: wrappedBlock, - events, - success: - events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, - }; - }); -} \ No newline at end of file diff --git a/zeitgeist/tsconfig.json b/zeitgeist/tsconfig.json deleted file mode 100644 index 2502cf2..0000000 --- a/zeitgeist/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "declaration": true, - "importHelpers": true, - "resolveJsonModule": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": ".", - "target": "es2017", - "strict": true - }, - "include": [ - "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} \ No newline at end of file