diff --git a/.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch b/.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch new file mode 100644 index 00000000..72919cc3 --- /dev/null +++ b/.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch @@ -0,0 +1,55 @@ +diff --git a/http/index.js b/http/index.js +index 63d7d0439956851f8794e10defbbd944fdae2766..13a08f7451bcb5838b19a64d47182a1dd8a7a813 100644 +--- a/http/index.js ++++ b/http/index.js +@@ -1,4 +1,4 @@ +-import { logger, noop } from '@polkadot/util'; ++import { logger, noop, stringify } from '@polkadot/util'; + import { fetch } from '@polkadot/x-fetch'; + import { RpcCoder } from '../coder/index.js'; + import defaults from '../defaults.js'; +@@ -99,13 +99,14 @@ export class HttpProvider { + async send(method, params, isCacheable) { + this.__internal__stats.total.requests++; + const [, body] = this.__internal__coder.encodeJson(method, params); ++ const cacheKey = isCacheable ? `${method}::${stringify(params)}` : ''; + let resultPromise = isCacheable +- ? this.__internal__callCache.get(body) ++ ? this.__internal__callCache.get(cacheKey) + : null; + if (!resultPromise) { + resultPromise = this.__internal__send(body); + if (isCacheable) { +- this.__internal__callCache.set(body, resultPromise); ++ this.__internal__callCache.set(cacheKey, resultPromise); + } + } + else { +diff --git a/ws/index.js b/ws/index.js +index 879299b5d960a9bce6572a0e585ede29935db2a7..9ea7f184dd0c65dfe37585dd811120838ca580b9 100644 +--- a/ws/index.js ++++ b/ws/index.js +@@ -1,5 +1,5 @@ + import { EventEmitter } from 'eventemitter3'; +-import { isChildClass, isNull, isUndefined, logger, noop, objectSpread } from '@polkadot/util'; ++import { isChildClass, isNull, isUndefined, logger, noop, objectSpread, stringify } from '@polkadot/util'; + import { xglobal } from '@polkadot/x-global'; + import { WebSocket } from '@polkadot/x-ws'; + import { RpcCoder } from '../coder/index.js'; +@@ -395,13 +395,14 @@ export class WsProvider { + this.__internal__endpointStats.requests++; + this.__internal__stats.total.requests++; + const [id, body] = this.__internal__coder.encodeJson(method, params); ++ const cacheKey = isCacheable ? `${method}::${stringify(params)}` : ''; + let resultPromise = isCacheable +- ? this.__internal__callCache.get(body) ++ ? this.__internal__callCache.get(cacheKey) + : null; + if (!resultPromise) { + resultPromise = this.__internal__send(id, body, method, params, subscription); + if (isCacheable) { +- this.__internal__callCache.set(body, resultPromise); ++ this.__internal__callCache.set(cacheKey, resultPromise); + } + } + else { diff --git a/.yarn/patches/typeorm-npm-0.3.17-f8c2578e7f.patch b/.yarn/patches/typeorm-npm-0.3.17-f8c2578e7f.patch deleted file mode 100644 index 02663b99..00000000 --- a/.yarn/patches/typeorm-npm-0.3.17-f8c2578e7f.patch +++ /dev/null @@ -1,167 +0,0 @@ -diff --git a/browser/data-source/DataSource.js b/browser/data-source/DataSource.js -index ac597a62857e6f05d1a7496ae9c49cdf6403c599..8a0530d03f0d51bca4c36bdb7e1a629683d4ab2f 100644 ---- a/browser/data-source/DataSource.js -+++ b/browser/data-source/DataSource.js -@@ -13,6 +13,9 @@ import { ObjectUtils } from "../util/ObjectUtils"; - import { RelationIdLoader } from "../query-builder/RelationIdLoader"; - import { DriverUtils } from "../driver/DriverUtils"; - import { InstanceChecker } from "../util/InstanceChecker"; -+import { registerQueryBuilders } from "../query-builder"; -+ -+registerQueryBuilders() - /** - * DataSource is a pre-defined connection configuration to a specific database. - * You can have multiple data sources connected (with multiple connections in it), -diff --git a/browser/query-builder/QueryBuilder.js b/browser/query-builder/QueryBuilder.js -index 3fdc1a9b88b663c100562c073a2371b64c248b4a..f45f2db8c65f7aaf05ffb9e7c7e7d3da73a5e253 100644 ---- a/browser/query-builder/QueryBuilder.js -+++ b/browser/query-builder/QueryBuilder.js -@@ -23,6 +23,7 @@ import { escapeRegExp } from "../util/escapeRegExp"; - * Allows to build complex sql queries in a fashion way and execute those queries. - */ - export class QueryBuilder { -+ static queryBuilderRegistry = {} - /** - * QueryBuilder can be initialized from given Connection and QueryRunner objects or from given other QueryBuilder. - */ -@@ -71,10 +72,9 @@ export class QueryBuilder { - ]; - } - // loading it dynamically because of circular issue -- const SelectQueryBuilderCls = require("./SelectQueryBuilder").SelectQueryBuilder; - if (InstanceChecker.isSelectQueryBuilder(this)) - return this; -- return new SelectQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["SelectQueryBuilder"](this); - } - /** - * Creates INSERT query. -@@ -82,10 +82,9 @@ export class QueryBuilder { - insert() { - this.expressionMap.queryType = "insert"; - // loading it dynamically because of circular issue -- const InsertQueryBuilderCls = require("./InsertQueryBuilder").InsertQueryBuilder; - if (InstanceChecker.isInsertQueryBuilder(this)) - return this; -- return new InsertQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["InsertQueryBuilder"](this); - } - /** - * Creates UPDATE query and applies given update values. -@@ -105,10 +104,9 @@ export class QueryBuilder { - this.expressionMap.queryType = "update"; - this.expressionMap.valuesSet = updateSet; - // loading it dynamically because of circular issue -- const UpdateQueryBuilderCls = require("./UpdateQueryBuilder").UpdateQueryBuilder; - if (InstanceChecker.isUpdateQueryBuilder(this)) - return this; -- return new UpdateQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["UpdateQueryBuilder"](this); - } - /** - * Creates DELETE query. -@@ -116,26 +114,23 @@ export class QueryBuilder { - delete() { - this.expressionMap.queryType = "delete"; - // loading it dynamically because of circular issue -- const DeleteQueryBuilderCls = require("./DeleteQueryBuilder").DeleteQueryBuilder; - if (InstanceChecker.isDeleteQueryBuilder(this)) - return this; -- return new DeleteQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["DeleteQueryBuilder"](this); - } - softDelete() { - this.expressionMap.queryType = "soft-delete"; - // loading it dynamically because of circular issue -- const SoftDeleteQueryBuilderCls = require("./SoftDeleteQueryBuilder").SoftDeleteQueryBuilder; - if (InstanceChecker.isSoftDeleteQueryBuilder(this)) - return this; -- return new SoftDeleteQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["SoftDeleteQueryBuilder"](this); - } - restore() { - this.expressionMap.queryType = "restore"; - // loading it dynamically because of circular issue -- const SoftDeleteQueryBuilderCls = require("./SoftDeleteQueryBuilder").SoftDeleteQueryBuilder; - if (InstanceChecker.isSoftDeleteQueryBuilder(this)) - return this; -- return new SoftDeleteQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["SoftDeleteQueryBuilder"](this); - } - /** - * Sets entity's relation with which this query builder gonna work. -@@ -152,10 +147,9 @@ export class QueryBuilder { - this.expressionMap.setMainAlias(mainAlias); - } - // loading it dynamically because of circular issue -- const RelationQueryBuilderCls = require("./RelationQueryBuilder").RelationQueryBuilder; - if (InstanceChecker.isRelationQueryBuilder(this)) - return this; -- return new RelationQueryBuilderCls(this); -+ return QueryBuilder.queryBuilderRegistry["RelationQueryBuilder"](this); - } - /** - * Checks if given relation or relations exist in the entity. -@@ -1120,6 +1114,9 @@ export class QueryBuilder { - hasCommonTableExpressions() { - return this.expressionMap.commonTableExpressions.length > 0; - } -+ static registerQueryBuilderClass(name, factory) { -+ QueryBuilder.queryBuilderRegistry[name] = factory -+ } - } - - //# sourceMappingURL=QueryBuilder.js.map -diff --git a/browser/query-builder/index.js b/browser/query-builder/index.js -new file mode 100644 -index 0000000000000000000000000000000000000000..794b3a665ac2b64a8ec42e64bca6b27b34d5cd5f ---- /dev/null -+++ b/browser/query-builder/index.js -@@ -0,0 +1,34 @@ -+import { DeleteQueryBuilder } from "./DeleteQueryBuilder" -+import { InsertQueryBuilder } from "./InsertQueryBuilder" -+import { QueryBuilder } from "./QueryBuilder" -+import { RelationQueryBuilder } from "./RelationQueryBuilder" -+import { SelectQueryBuilder } from "./SelectQueryBuilder" -+import { SoftDeleteQueryBuilder } from "./SoftDeleteQueryBuilder" -+import { UpdateQueryBuilder } from "./UpdateQueryBuilder" -+ -+export function registerQueryBuilders() { -+ QueryBuilder.registerQueryBuilderClass( -+ "DeleteQueryBuilder", -+ (qb) => new DeleteQueryBuilder(qb), -+ ) -+ QueryBuilder.registerQueryBuilderClass( -+ "InsertQueryBuilder", -+ (qb) => new InsertQueryBuilder(qb), -+ ) -+ QueryBuilder.registerQueryBuilderClass( -+ "RelationQueryBuilder", -+ (qb) => new RelationQueryBuilder(qb), -+ ) -+ QueryBuilder.registerQueryBuilderClass( -+ "SelectQueryBuilder", -+ (qb) => new SelectQueryBuilder(qb), -+ ) -+ QueryBuilder.registerQueryBuilderClass( -+ "SoftDeleteQueryBuilder", -+ (qb) => new SoftDeleteQueryBuilder(qb), -+ ) -+ QueryBuilder.registerQueryBuilderClass( -+ "UpdateQueryBuilder", -+ (qb) => new UpdateQueryBuilder(qb), -+ ) -+} -\ No newline at end of file -diff --git a/data-source/DataSource.js b/data-source/DataSource.js -index 1aedd237abde0c8f75d8852b5c49c43b82a216c2..5bb28b8f2d04eca0e39c0d4512eece22e4fcedd7 100644 ---- a/data-source/DataSource.js -+++ b/data-source/DataSource.js -@@ -16,6 +16,7 @@ const ObjectUtils_1 = require("../util/ObjectUtils"); - const RelationIdLoader_1 = require("../query-builder/RelationIdLoader"); - const DriverUtils_1 = require("../driver/DriverUtils"); - const InstanceChecker_1 = require("../util/InstanceChecker"); -+ - /** - * DataSource is a pre-defined connection configuration to a specific database. - * You can have multiple data sources connected (with multiple connections in it), diff --git a/package.json b/package.json index 5901bb48..e055faab 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,6 @@ "wasm-pack": "^0.12.1" }, "resolutions": { - "typeorm@^0.3.17": "patch:typeorm@npm%3A0.3.17#./.yarn/patches/typeorm-npm-0.3.17-f8c2578e7f.patch" + "@polkadot/rpc-provider@10.10.1": "patch:@polkadot/rpc-provider@npm%3A10.10.1#./.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch" } } diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 17760b78..0ba09f03 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -105,15 +105,16 @@ export class Api { return this.#provider.send( 'chain_getBlockHash', Number.isInteger(blockNumber) ? [blockNumber] : [], + !!blockNumber, ) } async getHeader(hash?: string) { - return this.#provider.send
('chain_getHeader', hash ? [hash] : []) + return this.#provider.send
('chain_getHeader', hash ? [hash] : [], !!hash) } async getBlock(hash?: string) { - return this.#provider.send('chain_getBlock', hash ? [hash] : []) + return this.#provider.send('chain_getBlock', hash ? [hash] : [], !!hash) } async getStorage(key: string, hash?: string) { @@ -122,12 +123,12 @@ export class Api { // child storage key, use childstate_getStorage const params = [child, storageKey] if (hash) params.push(hash as HexString) - return this.#provider.send('childstate_getStorage', params) + return this.#provider.send('childstate_getStorage', params, !!hash) } else { // main storage key, use state_getStorage const params = [key] if (hash) params.push(hash) - return this.#provider.send('state_getStorage', params) + return this.#provider.send('state_getStorage', params, !!hash) } } @@ -139,13 +140,13 @@ export class Api { const params = [child, storageKey, pageSize, stripChildPrefix(startKey as HexString)] if (hash) params.push(hash as HexString) return this.#provider - .send('childstate_getKeysPaged', params) + .send('childstate_getKeysPaged', params, !!hash) .then((keys) => keys.map((key) => prefixedChildKey(child, key))) } else { // main storage key, use state_getKeysPaged const params = [prefix, pageSize, startKey] if (hash) params.push(hash) - return this.#provider.send('state_getKeysPaged', params) + return this.#provider.send('state_getKeysPaged', params, !!hash) } } } diff --git a/yarn.lock b/yarn.lock index 4b5709fc..11d2a4ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1715,6 +1715,30 @@ __metadata: languageName: node linkType: hard +"@polkadot/rpc-provider@patch:@polkadot/rpc-provider@npm%3A10.10.1#./.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch::locator=chopsticks-monorepo%40workspace%3A.": + version: 10.10.1 + resolution: "@polkadot/rpc-provider@patch:@polkadot/rpc-provider@npm%3A10.10.1#./.yarn/patches/@polkadot-rpc-provider-npm-10.10.1-c60ba50fe2.patch::version=10.10.1&hash=0d586a&locator=chopsticks-monorepo%40workspace%3A." + dependencies: + "@polkadot/keyring": ^12.5.1 + "@polkadot/types": 10.10.1 + "@polkadot/types-support": 10.10.1 + "@polkadot/util": ^12.5.1 + "@polkadot/util-crypto": ^12.5.1 + "@polkadot/x-fetch": ^12.5.1 + "@polkadot/x-global": ^12.5.1 + "@polkadot/x-ws": ^12.5.1 + "@substrate/connect": 0.7.33 + eventemitter3: ^5.0.1 + mock-socket: ^9.3.1 + nock: ^13.3.4 + tslib: ^2.6.2 + dependenciesMeta: + "@substrate/connect": + optional: true + checksum: bc3325560561f9689b3e68d7394c6936c720e7d9662e8b09d5ca5cc5031f6d5bdbe1b2bac165fca9d16ec984e0b2b96517c437601e1512fdbd62cb92bf8493a0 + languageName: node + linkType: hard + "@polkadot/types-augment@npm:10.10.1": version: 10.10.1 resolution: "@polkadot/types-augment@npm:10.10.1" @@ -8103,7 +8127,7 @@ __metadata: languageName: node linkType: hard -"typeorm@npm:0.3.17": +"typeorm@npm:^0.3.17": version: 0.3.17 resolution: "typeorm@npm:0.3.17" dependencies: @@ -8183,86 +8207,6 @@ __metadata: languageName: node linkType: hard -"typeorm@patch:typeorm@npm%3A0.3.17#./.yarn/patches/typeorm-npm-0.3.17-f8c2578e7f.patch::locator=chopsticks-monorepo%40workspace%3A.": - version: 0.3.17 - resolution: "typeorm@patch:typeorm@npm%3A0.3.17#./.yarn/patches/typeorm-npm-0.3.17-f8c2578e7f.patch::version=0.3.17&hash=9ea05a&locator=chopsticks-monorepo%40workspace%3A." - dependencies: - "@sqltools/formatter": ^1.2.5 - app-root-path: ^3.1.0 - buffer: ^6.0.3 - chalk: ^4.1.2 - cli-highlight: ^2.1.11 - date-fns: ^2.29.3 - debug: ^4.3.4 - dotenv: ^16.0.3 - glob: ^8.1.0 - mkdirp: ^2.1.3 - reflect-metadata: ^0.1.13 - sha.js: ^2.4.11 - tslib: ^2.5.0 - uuid: ^9.0.0 - yargs: ^17.6.2 - peerDependencies: - "@google-cloud/spanner": ^5.18.0 - "@sap/hana-client": ^2.12.25 - better-sqlite3: ^7.1.2 || ^8.0.0 - hdb-pool: ^0.1.6 - ioredis: ^5.0.4 - mongodb: ^5.2.0 - mssql: ^9.1.1 - mysql2: ^2.2.5 || ^3.0.1 - oracledb: ^5.1.0 - pg: ^8.5.1 - pg-native: ^3.0.0 - pg-query-stream: ^4.0.0 - redis: ^3.1.1 || ^4.0.0 - sql.js: ^1.4.0 - sqlite3: ^5.0.3 - ts-node: ^10.7.0 - typeorm-aurora-data-api-driver: ^2.0.0 - peerDependenciesMeta: - "@google-cloud/spanner": - optional: true - "@sap/hana-client": - optional: true - better-sqlite3: - optional: true - hdb-pool: - optional: true - ioredis: - optional: true - mongodb: - optional: true - mssql: - optional: true - mysql2: - optional: true - oracledb: - optional: true - pg: - optional: true - pg-native: - optional: true - pg-query-stream: - optional: true - redis: - optional: true - sql.js: - optional: true - sqlite3: - optional: true - ts-node: - optional: true - typeorm-aurora-data-api-driver: - optional: true - bin: - typeorm: cli.js - typeorm-ts-node-commonjs: cli-ts-node-commonjs.js - typeorm-ts-node-esm: cli-ts-node-esm.js - checksum: c22085840e466d1b203abbca1cde582fd250dcdb51cac0d20ff4dd27abf2f9eb8efa1ce6cc8a7a204764ccc495a3f65e368cff36726ec92fb273116b7c31437c - languageName: node - linkType: hard - "typescript@npm:^5.1.6": version: 5.1.6 resolution: "typescript@npm:5.1.6"