diff --git a/acala/src/index.ts b/acala/src/index.ts index 97e9f40..174c9e9 100644 --- a/acala/src/index.ts +++ b/acala/src/index.ts @@ -1,7 +1,7 @@ //Exports all handler functions import {atob} from 'abab'; if (!global.atob) { - global.atob = atob; + global.atob = atob as any; } export * from "./mappings/mappingHandlers"; import "@polkadot/api-augment"; diff --git a/acala/src/mappings/mappingHandlers.ts b/acala/src/mappings/mappingHandlers.ts index 344c25f..4cc6232 100644 --- a/acala/src/mappings/mappingHandlers.ts +++ b/acala/src/mappings/mappingHandlers.ts @@ -1,11 +1,12 @@ import { EventRecord } from "@polkadot/types/interfaces"; -import { SubstrateExtrinsic, SubstrateBlock, SubstrateEvent } from "@subql/types"; +import {SubstrateExtrinsic, SubstrateBlock, SubstrateEvent, SubstrateEventFilter} 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'; +import assert from "assert"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -37,7 +38,7 @@ export async function handleBlock(block: SubstrateBlock): Promise { const evmLogs: EvmLog[][] = [] for (const evt of wrappedEvents.filter(evt => { - const baseFilter = acalaProcessor.handlerProcessors['substrate/AcalaEvmEvent'].baseFilter[0]; + const baseFilter = (acalaProcessor as any).handlerProcessors['substrate/AcalaEvmEvent'].baseFilter[0] as any as SubstrateEventFilter; return evt.event.section === baseFilter.module && evt.event.method === baseFilter.method; })) { const logResult = await handleEvmLog(block.block.header.number.toString(), evt); @@ -52,7 +53,7 @@ export async function handleBlock(block: SubstrateBlock): Promise { const evmTransactions: EvmTransaction[][] = []; for (const ex of wrappedExtrinsics.filter(ex => { - const baseFilter = acalaProcessor.handlerProcessors['substrate/AcalaEvmCall'].baseFilter[0]; + const baseFilter = (acalaProcessor as any).handlerProcessors['substrate/AcalaEvmCall'].baseFilter[0]; return ex.extrinsic.method.section === baseFilter.module && ex.extrinsic.method.method === baseFilter.method && ex.success; })) { const transactionResult = await handleEvmTransaction(ex.idx, ex); @@ -156,15 +157,18 @@ async function handleEvmTransaction(idx: number, tx: SubstrateExtrinsic): Promis 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, - })); + return calls.map((call, i) => { + assert(call.blockNumber, 'No blockNumber in call') + return 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 { diff --git a/acala/tsconfig.json b/acala/tsconfig.json index f2f01c2..8df919c 100644 --- a/acala/tsconfig.json +++ b/acala/tsconfig.json @@ -10,9 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/aleph-zero/tsconfig.json b/aleph-zero/tsconfig.json index 4146dec..8df919c 100644 --- a/aleph-zero/tsconfig.json +++ b/aleph-zero/tsconfig.json @@ -10,10 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], } \ No newline at end of file diff --git a/altair/src/mappings/mappingHandlers.ts b/altair/src/mappings/mappingHandlers.ts index 29f5e8a..7f00b73 100644 --- a/altair/src/mappings/mappingHandlers.ts +++ b/altair/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -46,22 +48,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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, + txHash: extrinsic.extrinsic.hash.toString(), + }); } function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { @@ -78,4 +82,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/altair/tsconfig.json b/altair/tsconfig.json index 9b95212..8df919c 100644 --- a/altair/tsconfig.json +++ b/altair/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/astar/tsconfig.json b/astar/tsconfig.json index 450689b..8df919c 100644 --- a/astar/tsconfig.json +++ b/astar/tsconfig.json @@ -14,6 +14,7 @@ }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/automata/src/mappings/mappingHandlers.ts b/automata/src/mappings/mappingHandlers.ts index c48169f..f645b34 100644 --- a/automata/src/mappings/mappingHandlers.ts +++ b/automata/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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, + txHash: extrinsic.extrinsic.hash.toString() + }); } function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { @@ -79,4 +83,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/automata/tsconfig.json b/automata/tsconfig.json index 9b95212..8df919c 100644 --- a/automata/tsconfig.json +++ b/automata/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/basilisk/src/mappings/mappingHandlers.ts b/basilisk/src/mappings/mappingHandlers.ts index c48169f..72c984b 100644 --- a/basilisk/src/mappings/mappingHandlers.ts +++ b/basilisk/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { @@ -79,4 +83,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/basilisk/tsconfig.json b/basilisk/tsconfig.json index 9b95212..8df919c 100644 --- a/basilisk/tsconfig.json +++ b/basilisk/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/bifrost-parachain/src/mappings/mappingHandlers.ts b/bifrost-parachain/src/mappings/mappingHandlers.ts index bcb2ed2..5b0834c 100644 --- a/bifrost-parachain/src/mappings/mappingHandlers.ts +++ b/bifrost-parachain/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -82,4 +82,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/bifrost-parachain/tsconfig.json b/bifrost-parachain/tsconfig.json index 9b95212..8df919c 100644 --- a/bifrost-parachain/tsconfig.json +++ b/bifrost-parachain/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/bitcountry-pioneer/src/mappings/mappingHandlers.ts b/bitcountry-pioneer/src/mappings/mappingHandlers.ts index c48169f..72c984b 100644 --- a/bitcountry-pioneer/src/mappings/mappingHandlers.ts +++ b/bitcountry-pioneer/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { @@ -79,4 +83,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/bitcountry-pioneer/tsconfig.json b/bitcountry-pioneer/tsconfig.json index 9b95212..8df919c 100644 --- a/bitcountry-pioneer/tsconfig.json +++ b/bitcountry-pioneer/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/calamari/src/mappings/mappingHandlers.ts b/calamari/src/mappings/mappingHandlers.ts index 04442b7..432b705 100644 --- a/calamari/src/mappings/mappingHandlers.ts +++ b/calamari/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { diff --git a/calamari/tsconfig.json b/calamari/tsconfig.json index 9b95212..8df919c 100644 --- a/calamari/tsconfig.json +++ b/calamari/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/clover/src/mappings/mappingHandlers.ts b/clover/src/mappings/mappingHandlers.ts index c48169f..216ac41 100644 --- a/clover/src/mappings/mappingHandlers.ts +++ b/clover/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { diff --git a/clover/tsconfig.json b/clover/tsconfig.json index 9b95212..8df919c 100644 --- a/clover/tsconfig.json +++ b/clover/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/contextfree/src/mappings/mappingHandlers.ts b/contextfree/src/mappings/mappingHandlers.ts index c48169f..ae2c178 100644 --- a/contextfree/src/mappings/mappingHandlers.ts +++ b/contextfree/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -33,7 +35,6 @@ export async function handleBlock(block: SubstrateBlock): Promise { ); // Save all data - // All save order should always follow this structure for (const event of events) { await event.save() } @@ -47,22 +48,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { @@ -79,4 +82,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/contextfree/tsconfig.json b/contextfree/tsconfig.json index 9b95212..8df919c 100644 --- a/contextfree/tsconfig.json +++ b/contextfree/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/karura/scripts/publish-manifest.sh b/karura/scripts/publish-manifest.sh deleted file mode 100644 index 26cd1e3..0000000 --- a/karura/scripts/publish-manifest.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -for file in ./project*.yaml; do - echo "Publishing $file..." - npx subql publish -f "$file" -done \ No newline at end of file diff --git a/khala/tsconfig.json b/khala/tsconfig.json index 2394621..8df919c 100644 --- a/khala/tsconfig.json +++ b/khala/tsconfig.json @@ -10,10 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/kilt-spiritnet/tsconfig.json b/kilt-spiritnet/tsconfig.json index 4146dec..8df919c 100644 --- a/kilt-spiritnet/tsconfig.json +++ b/kilt-spiritnet/tsconfig.json @@ -10,10 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], } \ No newline at end of file diff --git a/kusama/tsconfig.json b/kusama/tsconfig.json index 9b95212..8df919c 100644 --- a/kusama/tsconfig.json +++ b/kusama/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/moonbeam-evm/src/index.ts b/moonbeam-evm/src/index.ts index 7d1d562..9dd6f6f 100644 --- a/moonbeam-evm/src/index.ts +++ b/moonbeam-evm/src/index.ts @@ -2,7 +2,7 @@ import {atob} from 'abab'; if (!global.atob) { - global.atob = atob; + global.atob = atob as any; } export * from './mappings/mappingHandlers' import "@polkadot/api-augment" diff --git a/moonbeam-evm/src/mappings/mappingHandlers.ts b/moonbeam-evm/src/mappings/mappingHandlers.ts index 707304d..12bfaae 100644 --- a/moonbeam-evm/src/mappings/mappingHandlers.ts +++ b/moonbeam-evm/src/mappings/mappingHandlers.ts @@ -3,8 +3,9 @@ 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"; +import assert from "assert"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { if (!specVersion) { specVersion = await SpecVersion.get(block.specVersion.toString()); @@ -29,7 +30,7 @@ export async function handleBlock(block: SubstrateBlock): Promise { input: ext as SubstrateExtrinsic<[TransactionV2 | EthTransaction]>, ds: {} as any, filter: undefined, - api: undefined + api: undefined as any }); evmCalls.push(result as [FrontierEvmCall]); } @@ -46,8 +47,8 @@ export async function handleBlock(block: SubstrateBlock): Promise { await log.save() } for (const evmCall of evmCalls.map((call,idx)=>handleEvmTransaction(`${block.block.header.number.toString()}-${idx}`,call)) - .filter(tx=>tx)) { - await evmCall.save() + .filter(tx=> tx)) { + await (evmCall as EvmTransaction).save() } } @@ -58,7 +59,7 @@ export function handleEvent(blockNumber: string, eventIdx: number, event: EventR module: event.event.section, event: event.event.method, }); - const ret: [Event, EvmLogModel] = [newEvent, undefined]; + const ret: [Event, EvmLogModel] = [newEvent, undefined as any]; if (event.event.section === 'evm' && event.event.method === 'Log') { ret[1] = handleEvmEvent(blockNumber, eventIdx, event); } @@ -100,11 +101,12 @@ function handleEvmEvent(blockNumber: string, eventIdx: number, event: EventRecor }); } -export function handleEvmTransaction(idx: string, transaction: [FrontierEvmCall]): EvmTransaction { +export function handleEvmTransaction(idx: string, transaction: [FrontierEvmCall]): EvmTransaction | undefined{ const [tx] = transaction if (!tx.hash) { return; } + assert(tx.blockNumber, 'Missing blockNumber') const func = isZero(tx.data) ? undefined : inputToFunctionSighash(tx.data).toLowerCase(); return EvmTransaction.create({ id: idx, diff --git a/moonbeam-evm/src/tests/moonbeam.test.ts b/moonbeam-evm/src/tests/moonbeam.test.ts index bc9f80d..729fd26 100644 --- a/moonbeam-evm/src/tests/moonbeam.test.ts +++ b/moonbeam-evm/src/tests/moonbeam.test.ts @@ -17,7 +17,7 @@ subqlTest( EvmTransaction.create({ id: `${blockNumber}-${5}`, from: '0x16f615a38528764eea9c6388a8c4e1fc8305cbb3', - to: null, + to: undefined, blockHeight: BigInt(blockNumber), func:'0x600d805', success: true, diff --git a/moonbeam-evm/tsconfig.json b/moonbeam-evm/tsconfig.json index 9b95212..8df919c 100644 --- a/moonbeam-evm/tsconfig.json +++ b/moonbeam-evm/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/neumann/src/mappings/mappingHandlers.ts b/neumann/src/mappings/mappingHandlers.ts index c48169f..72c984b 100644 --- a/neumann/src/mappings/mappingHandlers.ts +++ b/neumann/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { @@ -79,4 +83,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/neumann/tsconfig.json b/neumann/tsconfig.json index 9b95212..8df919c 100644 --- a/neumann/tsconfig.json +++ b/neumann/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/nodle-parachain/tsconfig.json b/nodle-parachain/tsconfig.json index 450689b..8df919c 100644 --- a/nodle-parachain/tsconfig.json +++ b/nodle-parachain/tsconfig.json @@ -14,6 +14,7 @@ }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/parallel-heiko/src/mappings/mappingHandlers.ts b/parallel-heiko/src/mappings/mappingHandlers.ts index c48169f..a651408 100644 --- a/parallel-heiko/src/mappings/mappingHandlers.ts +++ b/parallel-heiko/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt() + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module : event.event.section, + event : event.event.method + }); } 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; + 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[] { diff --git a/parallel-heiko/tsconfig.json b/parallel-heiko/tsconfig.json index 9b95212..8df919c 100644 --- a/parallel-heiko/tsconfig.json +++ b/parallel-heiko/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/parallel/src/mappings/mappingHandlers.ts b/parallel/src/mappings/mappingHandlers.ts index e0077fe..a651408 100644 --- a/parallel/src/mappings/mappingHandlers.ts +++ b/parallel/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { diff --git a/parallel/tsconfig.json b/parallel/tsconfig.json index 9b95212..8df919c 100644 --- a/parallel/tsconfig.json +++ b/parallel/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/polkadex/tsconfig.json b/polkadex/tsconfig.json index 4146dec..8df919c 100644 --- a/polkadex/tsconfig.json +++ b/polkadex/tsconfig.json @@ -10,10 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], } \ No newline at end of file diff --git a/polkadot/src/mappings/mappingHandlers.ts b/polkadot/src/mappings/mappingHandlers.ts index e6dcb40..a651408 100644 --- a/polkadot/src/mappings/mappingHandlers.ts +++ b/polkadot/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,7 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // Check for updates to Spec Version if (!specVersion || specVersion.id !== block.specVersion.toString()) { - specVersion = new SpecVersion(block.specVersion.toString(),block.block.header.number.toBigInt()); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt() + }); await specVersion.save(); } @@ -46,21 +49,24 @@ function handleEvent( eventIdx: number, event: EventRecord ): Event { - const newEvent = new Event(`${blockNumber}-${eventIdx}`,event.event.section,event.event.method,BigInt(blockNumber)); - return newEvent; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module : event.event.section, + event : event.event.method + }); } 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; + 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[] { diff --git a/polkadot/tsconfig.json b/polkadot/tsconfig.json index 9b95212..8df919c 100644 --- a/polkadot/tsconfig.json +++ b/polkadot/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/quartz/src/mappings/mappingHandlers.ts b/quartz/src/mappings/mappingHandlers.ts index c48169f..ae2c178 100644 --- a/quartz/src/mappings/mappingHandlers.ts +++ b/quartz/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -33,7 +35,6 @@ export async function handleBlock(block: SubstrateBlock): Promise { ); // Save all data - // All save order should always follow this structure for (const event of events) { await event.save() } @@ -47,22 +48,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { @@ -79,4 +82,4 @@ function wrapExtrinsics(wrappedBlock: SubstrateBlock): SubstrateExtrinsic[] { events.findIndex((evt) => evt.event.method === "ExtrinsicSuccess") > -1, }; }); -} +} \ No newline at end of file diff --git a/quartz/tsconfig.json b/quartz/tsconfig.json index 9b95212..8df919c 100644 --- a/quartz/tsconfig.json +++ b/quartz/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/statemine/src/mappings/mappingHandlers.ts b/statemine/src/mappings/mappingHandlers.ts index c48169f..216ac41 100644 --- a/statemine/src/mappings/mappingHandlers.ts +++ b/statemine/src/mappings/mappingHandlers.ts @@ -2,7 +2,7 @@ import { EventRecord } from "@polkadot/types/interfaces"; import { SubstrateExtrinsic, SubstrateBlock } from "@subql/types"; import { SpecVersion, Event, Extrinsic } from "../types"; -let specVersion: SpecVersion; +let specVersion: SpecVersion | undefined; export async function handleBlock(block: SubstrateBlock): Promise { // Initialise Spec Version if (!specVersion) { @@ -11,8 +11,10 @@ export async function handleBlock(block: SubstrateBlock): Promise { // 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(); + specVersion = SpecVersion.create({ + id: block.specVersion.toString(), + blockHeight: block.block.header.number.toBigInt(), + }); await specVersion.save(); } @@ -47,22 +49,24 @@ function handleEvent( 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; + return Event.create({ + id: `${blockNumber}-${eventIdx}`, + blockHeight: BigInt(blockNumber), + module: event.event.section, + event: event.event.method, + }); } 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; + 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[] { diff --git a/statemine/tsconfig.json b/statemine/tsconfig.json index 9b95212..8df919c 100644 --- a/statemine/tsconfig.json +++ b/statemine/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/statemint/tsconfig.json b/statemint/tsconfig.json index 9b95212..8df919c 100644 --- a/statemint/tsconfig.json +++ b/statemint/tsconfig.json @@ -9,10 +9,12 @@ "module": "commonjs", "outDir": "dist", "rootDir": "src", - "target": "es2017" + "target": "es2017", + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/turing/tsconfig.json b/turing/tsconfig.json index 4146dec..8df919c 100644 --- a/turing/tsconfig.json +++ b/turing/tsconfig.json @@ -10,10 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], } \ No newline at end of file diff --git a/westend/tsconfig.json b/westend/tsconfig.json index 2394621..8df919c 100644 --- a/westend/tsconfig.json +++ b/westend/tsconfig.json @@ -10,10 +10,11 @@ "outDir": "dist", "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] -} + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], +} \ No newline at end of file diff --git a/zeitgeist/tsconfig.json b/zeitgeist/tsconfig.json index 2502cf2..8df919c 100644 --- a/zeitgeist/tsconfig.json +++ b/zeitgeist/tsconfig.json @@ -8,12 +8,13 @@ "resolveJsonModule": true, "module": "commonjs", "outDir": "dist", - "rootDir": ".", + "rootDir": "src", "target": "es2017", - "strict": true + "strict": true, }, "include": [ "src/**/*", - "node_modules/@subql/types/dist/global.d.ts" - ] + "node_modules/@subql/types-core/dist/global.d.ts", + "node_modules/@subql/types/dist/global.d.ts", + ], } \ No newline at end of file