Skip to content

Release alpha changes to master #303

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '22.x'
cache: 'yarn'
- name: install dependencies
run: yarn --frozen-lockfile
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '22.x'
cache: 'yarn'
- name: install dependencies
run: yarn --frozen-lockfile
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ tsconfig.tsbuildinfo

metadata.json
.history
.project-cid
.project-cid

.env
13 changes: 11 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
"vscode-extension",
".git/objects",
".vscode",
".eslintrc",
".eslintrc"
],
"cSpell.ignoreRegExpList": [
"/from\\s+(['\"]).*\\1/", // ignore imports
"/\/\/ TODO @\\w+/", // ignore github handles in TODOs
"/// TODO @\\w+/", // ignore github handles in TODOs
"/0x.+/" // ignore hex values
],
"cSpell.words": [
"Capitaldistribution",
"cddserviceproviders",
"chaintypes",
"codegen",
"Compliancemanager",
Expand All @@ -30,13 +31,21 @@
"Externalagents",
"extrinsics",
"fundings",
"healthcheck",
"isready",
"onfinality",
"Permissioned",
"Polkadot",
"Polymesh",
"Polyx",
"Prefs",
"signedbyAddress",
"snapshotted",
"subql",
"Subquery",
"Timelock",
"tini",
"transactionpayment",
"Unbonded"
]
}
31 changes: 31 additions & 0 deletions db/migrations/5_add_enum_text_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- add unknown to CallIdEnum
alter type "0bf3c7d4ef" add value if not exists 'unknown' after 'set_proposal_duration';

-- add unknown to EventIdEnum
alter type "8f5a39c8ee" add value if not exists 'Unknown' after 'VoteRejectReferendum';

-- add unknown to ModuleIdEnum
alter type "7a0b4cc03e" add value if not exists 'unknown' after 'stocapped';

alter table events
add column if not exists module_id_text text,
add column if not exists event_id_text text;

alter table extrinsics
add column if not exists module_id_text text,
add column if not exists call_id_text text;

alter table polyx_transactions
add column if not exists event_id_text text,
add column if not exists call_id_text text,
add column if not exists module_id_text text;

update events set event_id_text = event_id where event_id_text is null;
update events set module_id_text = module_id where module_id_text is null;

update extrinsics set call_id_text = call_id where call_id_text is null;
update extrinsics set module_id_text = module_id where module_id_text is null;

update polyx_transactions set event_id_text = event_id where event_id_text is null;
update polyx_transactions set call_id_text = call_id where call_id_text is null;
update polyx_transactions set module_id_text = module_id where module_id_text is null;
12 changes: 6 additions & 6 deletions db/schemaMigrations.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { randomUUID } from 'crypto';
import { readdirSync, readFileSync } from 'fs';
import { Connection } from 'typeorm';
import { DataSource } from 'typeorm';
import { version as latestVersion } from '../package.json';
import { getPostgresConnection } from './utils';
import { randomUUID } from 'crypto';
import { getPostgresDataSource } from './utils';

const getLastMigrationFromDB = (postgres: Connection) => {
const getLastMigrationFromDB = (postgres: DataSource) => {
return postgres
.createQueryBuilder()
.select('number', 'lastMigration')
Expand Down Expand Up @@ -33,8 +33,8 @@ VALUES ('${
id || migrationNumber
}', '${randomUUID()}', ${migrationNumber},'${latestVersion}', 1, 0, '[1,)');`;

export const schemaMigrations = async (connection?: Connection): Promise<void> => {
const postgres = await (connection ?? getPostgresConnection());
export const schemaMigrations = async (dataSource?: DataSource): Promise<void> => {
const postgres = await (dataSource ?? getPostgresDataSource());

let lastMigration = 0;
try {
Expand Down
26 changes: 13 additions & 13 deletions db/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as dotenv from 'dotenv';
import { chdir, env } from 'process';
import { Connection, createConnection } from 'typeorm';
import { DataSource } from 'typeorm';

chdir(__dirname);

Expand Down Expand Up @@ -28,28 +28,28 @@ export const retry = async <T>(
throw err;
};

export const getPostgresConnection = async (): Promise<Connection> => {
export const getPostgresDataSource = async (): Promise<DataSource> => {
const maxAttempts = env.NODE_ENV === 'local' ? 10 : 1;
const dataSource = new DataSource({
type: 'postgres',
host: env.DB_HOST,
port: Number(env.DB_PORT),
username: env.DB_USER,
password: env.DB_PASS,
database: env.DB_DATABASE,
name: 'postgres',
});
return retry(
maxAttempts,
1000,
async () =>
await createConnection({
type: 'postgres',
host: env.DB_HOST,
port: Number(env.DB_PORT),
username: env.DB_USER,
password: env.DB_PASS,
database: env.DB_DATABASE,
name: 'postgres',
}),
async () => await dataSource.initialize(),
() => {
console.log('Database connection not ready, retrying in 1s');
}
);
};

export const dbIsReady = (postgres: Connection, retryAttempts = 100): Promise<void> => {
export const dbIsReady = (postgres: DataSource, retryAttempts = 100): Promise<void> => {
return retry(
retryAttempts,
1000,
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: ./docker/pg-Dockerfile
ports:
- 5432:5432
- 5678:5432
volumes:
- db-data:/var/lib/postgresql/data
environment:
Expand Down Expand Up @@ -69,7 +69,7 @@ services:
start_period: 30s

graphql-engine:
image: onfinality/subql-query:v2.8.0
image: onfinality/subql-query:v2.21.0
ports:
- 3001:3000
depends_on:
Expand Down
6 changes: 3 additions & 3 deletions docker/pg-Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM postgres:12-alpine

# Variables needed at runtime to configure postgres and run the initdb scripts
ENV POSTGRES_DB 'postgres'
ENV POSTGRES_USER 'postgres'
ENV POSTGRES_PASSWORD 'postgres'
ENV POSTGRES_DB='postgres'
ENV POSTGRES_USER='postgres'
ENV POSTGRES_PASSWORD='postgres'

# Copy in the load-extensions script
COPY docker/load-extensions.sh /docker-entrypoint-initdb.d/
Expand Down
2 changes: 1 addition & 1 deletion docker/sq-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN yarn --frozen-lockfile \
&& rm -rf /root/.npm /root/.cache

# Stage 2: Production Stage
FROM onfinality/subql-node:v4.6.5 AS production
FROM onfinality/subql-node:v5.11.2 AS production

USER root

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymesh-subquery",
"version": "19.1.0",
"version": "19.2.0",
"author": "Polymesh Association",
"license": "Apache-2.0",
"description": "A Polymesh Chain Indexer, providing a GraphQL interface",
Expand Down Expand Up @@ -30,12 +30,12 @@
"project.yaml"
],
"dependencies": {
"@polkadot/api": "^11.2.1",
"@polkadot/types-support": "^11.2.1",
"@polymeshassociation/polymesh-types": "^5.14.0",
"@subql/cli": "4.14.0",
"@subql/types": "3.6.1",
"@subql/types-core": "^0.7.0",
"@polkadot/api": "^15.8.1",
"@polkadot/types-support": "^15.8.1",
"@polymeshassociation/polymesh-types": "^5.15.0",
"@subql/cli": "^5.7.0",
"@subql/types": "^3.12.1",
"@subql/types-core": "^2.0.2",
"bignumber.js": "^9.0.2",
"pg": "^8.11.5",
"typeorm": "^0.3.20"
Expand All @@ -46,12 +46,12 @@
"@babel/preset-env": "^7.24.4",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@polkadot/typegen": "^10.9.1",
"@polkadot/typegen": "^15.8.1",
"@polymeshassociation/polymesh-local": "^5.13.0-alpha.3",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/npm": "^11.0.0",
"@subql/node": "4.6.5",
"@subql/node": "^5.11.2",
"@types/bn.js": "^4.11.6",
"@types/jest": "^29.5.4",
"@types/js-yaml": "^4.0.3",
Expand Down Expand Up @@ -91,7 +91,7 @@
},
"resolutions": {
"ipfs-unixfs": "6.0.6",
"@polkadot/util": "12.6.2"
"@polkadot/util": "13.4.3"
},
"config": {
"commitizen": {
Expand Down
18 changes: 15 additions & 3 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,27 @@ const handlers: SubstrateEventHandler[] = [];
const eventSpecificHandlers: SubstrateEventHandler[] = [];

Object.keys(filters).forEach(module => {
Object.keys(filters[module]).forEach(method => {
if (module !== 'system') {
handlers.push({
kind: SubstrateHandlerKind.Event,
handler: 'handleEvent',
filter: {
module,
method,
},
} as SubstrateEventHandler);
}

Object.keys(filters[module]).forEach(method => {
if (module === 'system') {
handlers.push({
kind: SubstrateHandlerKind.Event,
handler: 'handleEvent',
filter: {
module,
method,
},
} as SubstrateEventHandler);
}

if (filters[module][method].length > 0) {
const handlerList = filters[module][method];
Expand Down Expand Up @@ -399,7 +411,7 @@ const project: SubstrateProject = {
file: './dist/index.js',
handlers: [
{
kind: SubstrateHandlerKind.Event,
kind: SubstrateHandlerKind.Block,
handler: 'handleGenesis',
},
],
Expand Down
15 changes: 15 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ enum ModuleIdEnum {
exemption @deprecated
finalitytracker @deprecated
stocapped @deprecated

"unknown module value is populated for modules not yet implemented by Polymesh SubQuery"
unknown
}

"""
Expand Down Expand Up @@ -683,6 +686,9 @@ enum EventIdEnum {
VenueUpdated @deprecated
VoteEnactReferendum @deprecated
VoteRejectReferendum @deprecated

"Unknown event value is populated for events not yet implemented by Polymesh SubQuery"
Unknown
}

"""
Expand Down Expand Up @@ -1396,6 +1402,8 @@ enum CallIdEnum {
set_primary_key @deprecated
set_proposal_cool_off_period @deprecated
set_proposal_duration @deprecated

unknown
}

type Debug @entity {
Expand Down Expand Up @@ -1447,7 +1455,9 @@ type Extrinsic @entity {
signedbyAddress: Int! @deprecated(reason: "use `signed` instead.")
address: String
moduleId: ModuleIdEnum!
moduleIdText: String!
callId: CallIdEnum!
callIdText: String!
paramsTxt: String!
success: Int! @index(unique: false)
nonce: Int
Expand All @@ -1465,7 +1475,9 @@ type Event @entity {
extrinsicIdx: Int
specVersionId: Int!
moduleId: ModuleIdEnum!
moduleIdText: String!
eventId: EventIdEnum!
eventIdText: String!
attributesTxt: String!
eventArg_0: String
eventArg_1: String
Expand Down Expand Up @@ -2526,8 +2538,11 @@ type PolyxTransaction @entity {
amount: BigInt!
type: BalanceTypeEnum!
moduleId: ModuleIdEnum
moduleIdText: String
callId: CallIdEnum
callIdText: String
eventId: EventIdEnum
eventIdText: String
memo: String
extrinsic: Extrinsic
datetime: Date!
Expand Down
4 changes: 2 additions & 2 deletions scripts/run-migrations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { schemaMigrations } from '../db/schemaMigrations';
import { dbIsReady, getPostgresConnection } from '../db/utils';
import { dbIsReady, getPostgresDataSource } from '../db/utils';

const main = async () => {
const postgres = await getPostgresConnection();
const postgres = await getPostgresDataSource();

try {
await dbIsReady(postgres, 1);
Expand Down
4 changes: 2 additions & 2 deletions scripts/run-sql.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { readFileSync } from 'fs';
import { dbIsReady, getPostgresConnection } from '../db/utils';
import { dbIsReady, getPostgresDataSource } from '../db/utils';

const main = async (): Promise<void> => {
const postgres = await getPostgresConnection();
const postgres = await getPostgresDataSource();

await dbIsReady(postgres);

Expand Down
4 changes: 3 additions & 1 deletion src/mappings/entities/assets/mapAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ export const handleAssetTransfer = async (event: SubstrateEvent): Promise<void>
({ event }) => event.method === 'InstructionExecuted'
);
if (instructionExecutedEvent) {
instructionId = processInstructionId(instructionExecutedEvent.event.data[1]);
instructionId = processInstructionId(
instructionExecutedEvent.event.data[1] as unknown as Codec
);
}
}

Expand Down
Loading