diff --git a/package-lock.json b/package-lock.json index dd8e3db..a7f8aa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "typeorm": "^0.3.20" }, "devDependencies": { + "@polkadot/api": "^12.3.1", "@subsquid/substrate-metadata-explorer": "^3.2.0", "@subsquid/substrate-typegen": "^8.1.0", "@subsquid/typeorm-codegen": "^2.0.0", @@ -366,6 +367,168 @@ "node": ">=14" } }, + "node_modules/@polkadot-api/json-rpc-provider": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/json-rpc-provider/-/json-rpc-provider-0.0.1.tgz", + "integrity": "sha512-/SMC/l7foRjpykLTUTacIH05H3mr9ip8b5xxfwXlVezXrNVLp3Cv0GX6uItkKd+ZjzVPf3PFrDF2B2/HLSNESA==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@polkadot-api/json-rpc-provider-proxy": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/json-rpc-provider-proxy/-/json-rpc-provider-proxy-0.0.1.tgz", + "integrity": "sha512-gmVDUP8LpCH0BXewbzqXF2sdHddq1H1q+XrAW2of+KZj4woQkIGBRGTJHeBEVHe30EB+UejR1N2dT4PO/RvDdg==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@polkadot-api/metadata-builders": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/metadata-builders/-/metadata-builders-0.0.1.tgz", + "integrity": "sha512-GCI78BHDzXAF/L2pZD6Aod/yl82adqQ7ftNmKg51ixRL02JpWUA+SpUKTJE5MY1p8kiJJIo09P2um24SiJHxNA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@polkadot-api/substrate-bindings": "0.0.1", + "@polkadot-api/utils": "0.0.1" + } + }, + "node_modules/@polkadot-api/observable-client": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@polkadot-api/observable-client/-/observable-client-0.1.0.tgz", + "integrity": "sha512-GBCGDRztKorTLna/unjl/9SWZcRmvV58o9jwU2Y038VuPXZcr01jcw/1O3x+yeAuwyGzbucI/mLTDa1QoEml3A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@polkadot-api/metadata-builders": "0.0.1", + "@polkadot-api/substrate-bindings": "0.0.1", + "@polkadot-api/substrate-client": "0.0.1", + "@polkadot-api/utils": "0.0.1" + }, + "peerDependencies": { + "rxjs": ">=7.8.0" + } + }, + "node_modules/@polkadot-api/substrate-bindings": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/substrate-bindings/-/substrate-bindings-0.0.1.tgz", + "integrity": "sha512-bAe7a5bOPnuFVmpv7y4BBMRpNTnMmE0jtTqRUw/+D8ZlEHNVEJQGr4wu3QQCl7k1GnSV1wfv3mzIbYjErEBocg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@noble/hashes": "^1.3.1", + "@polkadot-api/utils": "0.0.1", + "@scure/base": "^1.1.1", + "scale-ts": "^1.6.0" + } + }, + "node_modules/@polkadot-api/substrate-client": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/substrate-client/-/substrate-client-0.0.1.tgz", + "integrity": "sha512-9Bg9SGc3AwE+wXONQoW8GC00N3v6lCZLW74HQzqB6ROdcm5VAHM4CB/xRzWSUF9CXL78ugiwtHx3wBcpx4H4Wg==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@polkadot-api/utils": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@polkadot-api/utils/-/utils-0.0.1.tgz", + "integrity": "sha512-3j+pRmlF9SgiYDabSdZsBSsN5XHbpXOAce1lWj56IEEaFZVjsiCaxDOA7C9nCcgfVXuvnbxqqEGQvnY+QfBAUw==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@polkadot/api": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-12.3.1.tgz", + "integrity": "sha512-VCrtadJRJttya5NhZ8slkD/UQyOZv4qABjagQMaG1eTZpn5k1wskmDUGdHrZZpYO5jBPewnCgaN8+LPKO2qiOw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/api-augment": "12.3.1", + "@polkadot/api-base": "12.3.1", + "@polkadot/api-derive": "12.3.1", + "@polkadot/keyring": "^13.0.2", + "@polkadot/rpc-augment": "12.3.1", + "@polkadot/rpc-core": "12.3.1", + "@polkadot/rpc-provider": "12.3.1", + "@polkadot/types": "12.3.1", + "@polkadot/types-augment": "12.3.1", + "@polkadot/types-codec": "12.3.1", + "@polkadot/types-create": "12.3.1", + "@polkadot/types-known": "12.3.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "eventemitter3": "^5.0.1", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-augment": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-augment/-/api-augment-12.3.1.tgz", + "integrity": "sha512-KfofZVEUeTgLzcexdxKBT2vihazDheUoTLxbsa2ztmmw4UB/IjOL911y04pjg2obZQAI9B+oCyxJXyCfzauWEg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/api-base": "12.3.1", + "@polkadot/rpc-augment": "12.3.1", + "@polkadot/types": "12.3.1", + "@polkadot/types-augment": "12.3.1", + "@polkadot/types-codec": "12.3.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-base": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-base/-/api-base-12.3.1.tgz", + "integrity": "sha512-vNbxXNjn4APfXg+ui99gurX2Jzns+eezmWranxoGXT7q0mme1zAtWus5t4e+qe1qRjDNZZYPruF7YJA8dL5k8A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/rpc-core": "12.3.1", + "@polkadot/types": "12.3.1", + "@polkadot/util": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/api-derive": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-12.3.1.tgz", + "integrity": "sha512-2MbK1h4GcKEdSgDKKYI28iZESw0VOm0kekV6YGQflZNWe84jJOn2rohP8pACseUjQjwWDgbPPBvTlRZTk7zdAw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/api": "12.3.1", + "@polkadot/api-augment": "12.3.1", + "@polkadot/api-base": "12.3.1", + "@polkadot/rpc-core": "12.3.1", + "@polkadot/types": "12.3.1", + "@polkadot/types-codec": "12.3.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@polkadot/keyring": { "version": "13.0.2", "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-13.0.2.tgz", @@ -398,6 +561,68 @@ "node": ">=18" } }, + "node_modules/@polkadot/rpc-augment": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-augment/-/rpc-augment-12.3.1.tgz", + "integrity": "sha512-/tZLl5IuQ4vdGlUAbd8x3ShZ35XDSeyknKHCC+9kIrM/+KIyoCYBob2RXP9uqX8m516AWkXUrjsSO6DFPBpRGg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/rpc-core": "12.3.1", + "@polkadot/types": "12.3.1", + "@polkadot/types-codec": "12.3.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/rpc-core": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-12.3.1.tgz", + "integrity": "sha512-bNo26P20nRpLfANTK4sWEakxvqBJpKwAp/Gt7KlxoGgoTUbWFapyGKScFxp/pblycEziEbC+ZjkLMkaWaqi69g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/rpc-augment": "12.3.1", + "@polkadot/rpc-provider": "12.3.1", + "@polkadot/types": "12.3.1", + "@polkadot/util": "^13.0.2", + "rxjs": "^7.8.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/rpc-provider": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-12.3.1.tgz", + "integrity": "sha512-Tg1Oj/1ldivqwnnOWepcNHEHYgpOBffxlrZMEXH1XX6D3AZaUhAWbatizyisydpuMbknTQ9FGYSnb9rOc2QBJw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/keyring": "^13.0.2", + "@polkadot/types": "12.3.1", + "@polkadot/types-support": "12.3.1", + "@polkadot/util": "^13.0.2", + "@polkadot/util-crypto": "^13.0.2", + "@polkadot/x-fetch": "^13.0.2", + "@polkadot/x-global": "^13.0.2", + "@polkadot/x-ws": "^13.0.2", + "eventemitter3": "^5.0.1", + "mock-socket": "^9.3.1", + "nock": "^13.5.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@substrate/connect": "0.8.10" + } + }, "node_modules/@polkadot/types": { "version": "12.3.1", "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-12.3.1.tgz", @@ -460,6 +685,38 @@ "node": ">=18" } }, + "node_modules/@polkadot/types-known": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-12.3.1.tgz", + "integrity": "sha512-G8t0uiIW1iu3KwylHDPnqdHxg5qwBxzPZQJvsjnGx2qBUk2VqXditKWcNFLEwCTnJPL95t2AzEO711lS99WRbg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/networks": "^13.0.2", + "@polkadot/types": "12.3.1", + "@polkadot/types-codec": "12.3.1", + "@polkadot/types-create": "12.3.1", + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@polkadot/types-support": { + "version": "12.3.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-support/-/types-support-12.3.1.tgz", + "integrity": "sha512-TwL5M5HkZ4jQGKekD+qJFLba7UXWASfwlPy2OpKj0LOnnmq4tudXgN13UFdQ7HoOmisPhr+vYo9vteYeBZ0jTA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/util": "^13.0.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@polkadot/util": { "version": "13.0.2", "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-13.0.2.tgz", @@ -619,6 +876,21 @@ "node": ">=18" } }, + "node_modules/@polkadot/x-fetch": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-fetch/-/x-fetch-13.0.2.tgz", + "integrity": "sha512-B/gf9iriUr6za/Ui7zIFBfHz7UBZ68rJEIteWHx1UHRCZPcLqv+hgpev6xIGrkfFljI0/lI7IwtN2qy6HYzFBg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "node-fetch": "^3.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@polkadot/x-global": { "version": "13.0.2", "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-13.0.2.tgz", @@ -674,6 +946,21 @@ "node": ">=18" } }, + "node_modules/@polkadot/x-ws": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-ws/-/x-ws-13.0.2.tgz", + "integrity": "sha512-nC5e2eY5D5ZR5teQOB7ib+dWLbmNws86cTz3BjKCalSMBBIn6i3V9ElgABpierBmnSJe9D94EyrH1BxdVfDxUg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@polkadot/x-global": "13.0.2", + "tslib": "^2.6.2", + "ws": "^8.16.0" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -1286,6 +1573,57 @@ "resolved": "https://registry.npmjs.org/@substrate/calc/-/calc-0.2.8.tgz", "integrity": "sha512-1c3mxf35FBeOswduhy0Wil9s4exHahXFo974qa0Ci2AORX8JTxmwhBb10+3Ls9iWoTFwvgOaFr9v1HeRL5tCig==" }, + "node_modules/@substrate/connect": { + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/@substrate/connect/-/connect-0.8.10.tgz", + "integrity": "sha512-DIyQ13DDlXqVFnLV+S6/JDgiGowVRRrh18kahieJxhgvzcWicw5eLc6jpfQ0moVVLBYkO7rctB5Wreldwpva8w==", + "deprecated": "versions below 1.x are no longer maintained", + "dev": true, + "license": "GPL-3.0-only", + "optional": true, + "dependencies": { + "@substrate/connect-extension-protocol": "^2.0.0", + "@substrate/connect-known-chains": "^1.1.4", + "@substrate/light-client-extension-helpers": "^0.0.6", + "smoldot": "2.0.22" + } + }, + "node_modules/@substrate/connect-extension-protocol": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@substrate/connect-extension-protocol/-/connect-extension-protocol-2.0.0.tgz", + "integrity": "sha512-nKu8pDrE3LNCEgJjZe1iGXzaD6OSIDD4Xzz/yo4KO9mQ6LBvf49BVrt4qxBFGL6++NneLiWUZGoh+VSd4PyVIg==", + "dev": true, + "license": "GPL-3.0-only", + "optional": true + }, + "node_modules/@substrate/connect-known-chains": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@substrate/connect-known-chains/-/connect-known-chains-1.3.0.tgz", + "integrity": "sha512-BHcWdhOsnHtoWuS4LpFpH3MbLAhm1amq4hvl5ctI47KNZcZJcEPAF4zmeaTMuvj+UJ7LEFooy46Mn7zok47MwA==", + "dev": true, + "license": "GPL-3.0-only", + "optional": true + }, + "node_modules/@substrate/light-client-extension-helpers": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@substrate/light-client-extension-helpers/-/light-client-extension-helpers-0.0.6.tgz", + "integrity": "sha512-girltEuxQ1BvkJWmc8JJlk4ZxnlGXc/wkLcNguhY+UoDEMBK0LsdtfzQKIfrIehi4QdeSBlFEFBoI4RqPmsZzA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@polkadot-api/json-rpc-provider": "0.0.1", + "@polkadot-api/json-rpc-provider-proxy": "0.0.1", + "@polkadot-api/observable-client": "0.1.0", + "@polkadot-api/substrate-client": "0.0.1", + "@substrate/connect-extension-protocol": "^2.0.0", + "@substrate/connect-known-chains": "^1.1.4", + "rxjs": "^7.8.1" + }, + "peerDependencies": { + "smoldot": "2.x" + } + }, "node_modules/@substrate/ss58-registry": { "version": "1.49.0", "resolved": "https://registry.npmjs.org/@substrate/ss58-registry/-/ss58-registry-1.49.0.tgz", @@ -2521,6 +2859,13 @@ "es5-ext": "~0.10.14" } }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "dev": true, + "license": "MIT" + }, "node_modules/express": { "version": "4.19.2", "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", @@ -3254,6 +3599,13 @@ "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true, + "license": "ISC" + }, "node_modules/jsonc-parser": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", @@ -3395,6 +3747,16 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/mock-socket": { + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/mock-socket/-/mock-socket-9.3.1.tgz", + "integrity": "sha512-qxBgB7Qa2sEQgHFjj0dSigq7fX4k6Saisd5Nelwp2q8mlbAFh5dHV9JTTlF8viYJLSSWgMCZFUom8PJcMNBoJw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -3428,6 +3790,46 @@ "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" }, + "node_modules/nock": { + "version": "13.5.4", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", + "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, + "node_modules/nock/node_modules/debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nock/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true, + "license": "MIT" + }, "node_modules/node-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -3611,6 +4013,7 @@ "version": "8.11.5", "resolved": "https://registry.npmjs.org/pg/-/pg-8.11.5.tgz", "integrity": "sha512-jqgNHSKL5cbDjFlHyYsCXmQDrfIX/3RsNwYqpd4N0Kt8niLuNoRNH+aazv6cOd43gPh9Y4DjQCtb+X0MH0Hvnw==", + "license": "MIT", "dependencies": { "pg-connection-string": "^2.6.4", "pg-pool": "^3.6.2", @@ -3758,6 +4161,16 @@ "node": ">=10" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -3896,6 +4309,14 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/scale-ts": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/scale-ts/-/scale-ts-1.6.0.tgz", + "integrity": "sha512-Ja5VCjNZR8TGKhUumy9clVVxcDpM+YFjAnkMuwQy68Hixio3VRRvWdE3g8T/yC+HXA0ZDQl2TGyUmtmbcVl40Q==", + "dev": true, + "license": "MIT", + "optional": true + }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -4032,6 +4453,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/smoldot": { + "version": "2.0.22", + "resolved": "https://registry.npmjs.org/smoldot/-/smoldot-2.0.22.tgz", + "integrity": "sha512-B50vRgTY6v3baYH6uCgL15tfaag5tcS2o/P5q1OiXcKGv1axZDfz2dzzMuIkVpyMR2ug11F6EAtQlmYBQd292g==", + "dev": true, + "license": "GPL-3.0-or-later WITH Classpath-exception-2.0", + "optional": true, + "dependencies": { + "ws": "^8.8.1" + } + }, "node_modules/split2": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", diff --git a/package.json b/package.json index 5b93e16..7f27d0a 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "typeorm": "^0.3.20" }, "devDependencies": { + "@polkadot/api": "^12.3.1", "@subsquid/substrate-metadata-explorer": "^3.2.0", "@subsquid/substrate-typegen": "^8.1.0", "@subsquid/typeorm-codegen": "^2.0.0", diff --git a/scripts/fix-storage-node-mode.js b/scripts/fix-storage-node-mode.js new file mode 100644 index 0000000..a2f329e --- /dev/null +++ b/scripts/fix-storage-node-mode.js @@ -0,0 +1,65 @@ +const pg = require('pg'); +const { ApiPromise, WsProvider } = require('@polkadot/api'); + +const BLOCKCHAIN_RPC_ENDPOINT = process.env.RPC_CERE_HTTP ?? (console.log('RPC_CERE_HTTP not set.') || process.exit(1)); +const DB_HOST = process.env.DB_HOST ?? (console.log('DB_HOST not set.') || process.exit(1)); +const DB_PASS = process.env.DB_PASS ?? (console.log('DB_PASS not set.') || process.exit(1)); + +async function main() { + console.log(`Connecting to blockchain RPC endpoint at ${BLOCKCHAIN_RPC_ENDPOINT}.`); + + const wsProvider = new WsProvider(BLOCKCHAIN_RPC_ENDPOINT); + const api = await ApiPromise.create({ provider: wsProvider }); + + const chainStorageNodes = await api.query.ddcNodes.storageNodes.entries(); + console.log(`${chainStorageNodes.length} storage nodes found on chain.`); + + const chainStorageNodeModes = new Map(); + + chainStorageNodes.forEach(async ([id, node]) => { + id = id.toString().slice(-64) // remove module prefix + chainStorageNodeModes.set(id, node.toJSON().props.mode.toString()); + }); + + console.log(`Connecting to squid database at ${DB_HOST}.`); + + const db = new pg.Client({ + user: 'squid', + password: DB_PASS, + host: DB_HOST, + database: 'squid', + }); + await db.connect(); + + const res = await db.query('select * from ddc_node limit 1000'); + console.log(`${res.rows.length} storage nodes found in squid database.`); + + for (const row of res.rows) { + let { id, mode } = row; + id = id.slice(2); // remove 0x prefix + + if (!chainStorageNodeModes.has(id)) { + console.log(`Node ${id} not found on chain.`); + continue; + } + + const chainMode = chainStorageNodeModes.get(id); + if (mode !== chainMode) { + console.log(`Updating node ${id} mode from ${mode} to ${chainMode}.`); + await db.query('update ddc_node set mode=$1 where id=$2', [chainMode, '0x' + id]); + } else { + console.log(`Skipping node ${id}, mode is already set to ${chainMode}.`); + } + chainStorageNodeModes.delete(id); + } + + if (chainStorageNodeModes.size > 0) { + console.log(`Nodes not found in db: ${chainStorageNodeModes}.`); + } + + await db.end(); + console.log('Done.'); + process.exit(0); +} + +main()