diff --git a/.depcheckrc.json b/.depcheckrc.json index 4f61f0d..92185ff 100644 --- a/.depcheckrc.json +++ b/.depcheckrc.json @@ -3,6 +3,9 @@ "@lavamoat/allow-scripts", "@lavamoat/preinstall-always-fail", "@metamask/auto-changelog", - "prettier-plugin-packagejson" + "@types/*", + "prettier-plugin-packagejson", + "ts-node", + "typedoc" ] } diff --git a/.eslintrc.js b/.eslintrc.js index 1fe06f0..5f1e827 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,6 +4,18 @@ module.exports = { extends: ['@metamask/eslint-config'], overrides: [ + { + files: ['*.ts'], + extends: ['@metamask/eslint-config-typescript'], + }, + + { + files: ['*.d.ts'], + parserOptions: { + sourceType: 'script', + }, + }, + { files: ['*.js'], parserOptions: { @@ -13,5 +25,11 @@ module.exports = { }, ], - ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js'], + ignorePatterns: [ + '!.eslintrc.js', + '!.prettierrc.js', + 'dist/', + 'docs/', + '.yarn/', + ], }; diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 77f270c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -declare module 'eth-query' { - // What it says on the tin. We omit `null`, as that value is used for a - // successful response to indicate a lack of an error. - type EverythingButNull = - | string - | number - | boolean - // eslint-disable-next-line @typescript-eslint/ban-types - | object - | symbol - | undefined; - - type ProviderSendAsyncResponse = { - error?: { message: string }; - result?: Result; - }; - - type ProviderSendAsyncCallback = ( - error: unknown, - response: ProviderSendAsyncResponse, - ) => void; - - type Provider = { - sendAsync( - payload: SendAsyncPayload, - callback: ProviderSendAsyncCallback, - ): void; - }; - - type SendAsyncPayload = { - id: number; - jsonrpc: '2.0'; - method: string; - params: Params; - }; - - type SendAsyncCallback = ( - ...args: - | [error: EverythingButNull, result: undefined] - | [error: null, result: Result] - ) => void; - - export default class EthQuery { - constructor(provider: Provider); - - sendAsync( - opts: Partial>, - callback: SendAsyncCallback, - ): void; - - [method: string]: (...args: any[]) => void; - } -} diff --git a/index.js b/index.js deleted file mode 100644 index cf8ec93..0000000 --- a/index.js +++ /dev/null @@ -1,199 +0,0 @@ -const createRandomId = require('json-rpc-random-id')(); -const extend = require('xtend'); - -module.exports = EthQuery; - -/** - * Wrapping an Ethereum provider object, EthQuery provides some conveniences - * around making requests to an RPC endpoint: - * - * - Each of the RPC methods in the Ethereum spec may be requested not only - * via `sendAsync`, but also via its own instance method, whose API is suited - * for the RPC method. - * - When requesting an RPC method, `id` and `jsonrpc` do not need to be - * specified and are filled in with reasonable defaults. - * - The mechanics of `sendAsync` (or any of the RPC-method-specific instance - * methods) are simplified such that its callback will be called with an error - * argument not only if the callback on the provider's `sendAsync` method was - * called with an argument, but also if the `response` object has an `error` - * property. - * - * @param {any} provider - The provider object. - */ -function EthQuery(provider) { - const self = this; - self.currentProvider = provider; -} - -// -// base queries -// - -// default block -EthQuery.prototype.getBalance = generateFnWithDefaultBlockFor( - 2, - 'eth_getBalance', -); -EthQuery.prototype.getCode = generateFnWithDefaultBlockFor(2, 'eth_getCode'); -EthQuery.prototype.getTransactionCount = generateFnWithDefaultBlockFor( - 2, - 'eth_getTransactionCount', -); -EthQuery.prototype.getStorageAt = generateFnWithDefaultBlockFor( - 3, - 'eth_getStorageAt', -); -EthQuery.prototype.call = generateFnWithDefaultBlockFor(2, 'eth_call'); -// standard -EthQuery.prototype.protocolVersion = generateFnFor('eth_protocolVersion'); -EthQuery.prototype.syncing = generateFnFor('eth_syncing'); -EthQuery.prototype.coinbase = generateFnFor('eth_coinbase'); -EthQuery.prototype.mining = generateFnFor('eth_mining'); -EthQuery.prototype.hashrate = generateFnFor('eth_hashrate'); -EthQuery.prototype.gasPrice = generateFnFor('eth_gasPrice'); -EthQuery.prototype.accounts = generateFnFor('eth_accounts'); -EthQuery.prototype.blockNumber = generateFnFor('eth_blockNumber'); -EthQuery.prototype.getBlockTransactionCountByHash = generateFnFor( - 'eth_getBlockTransactionCountByHash', -); -EthQuery.prototype.getBlockTransactionCountByNumber = generateFnFor( - 'eth_getBlockTransactionCountByNumber', -); -EthQuery.prototype.getUncleCountByBlockHash = generateFnFor( - 'eth_getUncleCountByBlockHash', -); -EthQuery.prototype.getUncleCountByBlockNumber = generateFnFor( - 'eth_getUncleCountByBlockNumber', -); -EthQuery.prototype.sign = generateFnFor('eth_sign'); -EthQuery.prototype.sendTransaction = generateFnFor('eth_sendTransaction'); -EthQuery.prototype.sendRawTransaction = generateFnFor('eth_sendRawTransaction'); -EthQuery.prototype.estimateGas = generateFnFor('eth_estimateGas'); -EthQuery.prototype.getBlockByHash = generateFnFor('eth_getBlockByHash'); -EthQuery.prototype.getBlockByNumber = generateFnFor('eth_getBlockByNumber'); -EthQuery.prototype.getTransactionByHash = generateFnFor( - 'eth_getTransactionByHash', -); -EthQuery.prototype.getTransactionByBlockHashAndIndex = generateFnFor( - 'eth_getTransactionByBlockHashAndIndex', -); -EthQuery.prototype.getTransactionByBlockNumberAndIndex = generateFnFor( - 'eth_getTransactionByBlockNumberAndIndex', -); -EthQuery.prototype.getTransactionReceipt = generateFnFor( - 'eth_getTransactionReceipt', -); -EthQuery.prototype.getUncleByBlockHashAndIndex = generateFnFor( - 'eth_getUncleByBlockHashAndIndex', -); -EthQuery.prototype.getUncleByBlockNumberAndIndex = generateFnFor( - 'eth_getUncleByBlockNumberAndIndex', -); -EthQuery.prototype.getCompilers = generateFnFor('eth_getCompilers'); -EthQuery.prototype.compileLLL = generateFnFor('eth_compileLLL'); -EthQuery.prototype.compileSolidity = generateFnFor('eth_compileSolidity'); -EthQuery.prototype.compileSerpent = generateFnFor('eth_compileSerpent'); -EthQuery.prototype.newFilter = generateFnFor('eth_newFilter'); -EthQuery.prototype.newBlockFilter = generateFnFor('eth_newBlockFilter'); -EthQuery.prototype.newPendingTransactionFilter = generateFnFor( - 'eth_newPendingTransactionFilter', -); -EthQuery.prototype.uninstallFilter = generateFnFor('eth_uninstallFilter'); -EthQuery.prototype.getFilterChanges = generateFnFor('eth_getFilterChanges'); -EthQuery.prototype.getFilterLogs = generateFnFor('eth_getFilterLogs'); -EthQuery.prototype.getLogs = generateFnFor('eth_getLogs'); -EthQuery.prototype.getWork = generateFnFor('eth_getWork'); -EthQuery.prototype.submitWork = generateFnFor('eth_submitWork'); -EthQuery.prototype.submitHashrate = generateFnFor('eth_submitHashrate'); - -// network level - -EthQuery.prototype.sendAsync = function (opts, callback) { - const self = this; - self.currentProvider.sendAsync( - createPayload(opts), - function (error, response) { - let improvedError = error; - if (!error && response.error) { - improvedError = new Error( - `EthQuery - RPC Error - ${response.error.message}`, - ); - } - if (improvedError) { - return callback(improvedError); - } - return callback(null, response.result); - }, - ); -}; - -// util - -/** - * Generates an instance method designed to call an RPC method that takes no - * parameters. This instance method uses `sendAsync` internally to make the - * request to the network. - * - * @param {any} methodName - The RPC method. - * @returns {any} The method. - */ -function generateFnFor(methodName) { - return function (...args) { - const self = this; - const callback = args.pop(); - self.sendAsync( - { - method: methodName, - params: args, - }, - callback, - ); - }; -} - -/** - * Generates an instance method designed to call an RPC methods that takes one - * or more parameters. This instance method uses `sendAsync` internally to make - * the request to the network. - * - * @param {any} argCount - The number of parameters that the RPC method is - * expected to take. - * @param {any} methodName - The RPC method. - * @returns {any} The method. - */ -function generateFnWithDefaultBlockFor(argCount, methodName) { - return function (...args) { - const self = this; - const callback = args.pop(); - // set optional default block param - if (args.length < argCount) { - args.push('latest'); - } - self.sendAsync( - { - method: methodName, - params: args, - }, - callback, - ); - }; -} - -/** - * Builds a complete request payload object from a partial version. - * - * @param {any} data - The partial request object. - * @returns {any} The complete request object. - */ -function createPayload(data) { - return extend( - { - // defaults - id: createRandomId(), - jsonrpc: '2.0', - params: [], - // user-specified - }, - data, - ); -} diff --git a/package.json b/package.json index 17a6777..e6a5326 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,15 @@ }, "license": "ISC", "author": "", - "main": "index.js", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "files": [ + "dist/" + ], "scripts": { + "build": "tsc --project tsconfig.build.json", + "build:clean": "rimraf dist && yarn build", + "build:docs": "typedoc", "lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:dependencies --check && yarn lint:changelog", "lint:changelog": "auto-changelog validate", "lint:dependencies": "depcheck", @@ -23,8 +30,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "json-rpc-random-id": "^1.0.0", - "xtend": "^4.0.1" + "json-rpc-random-id": "^1.0.0" }, "devDependencies": { "@lavamoat/allow-scripts": "^2.3.1", @@ -32,6 +38,10 @@ "@metamask/auto-changelog": "^3.1.0", "@metamask/eslint-config": "^11.0.1", "@metamask/eslint-config-nodejs": "^11.0.1", + "@metamask/eslint-config-typescript": "^11.0.0", + "@types/node": "^16", + "@typescript-eslint/eslint-plugin": "^5.43.0", + "@typescript-eslint/parser": "^5.43.0", "depcheck": "^1.4.3", "eslint": "^8.27.0", "eslint-config-prettier": "^8.5.0", @@ -40,7 +50,11 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", "prettier": "^2.7.1", - "prettier-plugin-packagejson": "^2.3.0" + "prettier-plugin-packagejson": "^2.3.0", + "rimraf": "^3.0.2", + "ts-node": "^10.7.0", + "typedoc": "^0.23.15", + "typescript": "~4.8.4" }, "engines": { "node": ">=16.0.0" diff --git a/src/eth-query.ts b/src/eth-query.ts new file mode 100644 index 0000000..1ea0d86 --- /dev/null +++ b/src/eth-query.ts @@ -0,0 +1,656 @@ +import createRandomIdFactory from 'json-rpc-random-id'; + +const createRandomId = createRandomIdFactory(); + +/** + * Makes a subset of an object type optional. + */ +type PickPartial = { [Key in Keys]?: Type[Key] }; + +/** + * What it says on the tin. We omit `null` as that value is used for a + * successful response to indicate a lack of an error. + */ +type EverythingButNull = + | string + | number + | boolean + // We mean to use `object` here. + // eslint-disable-next-line @typescript-eslint/ban-types + | object + | symbol + | undefined; + +/** + * A singular (non-collection) value within a request parameter list. + */ +type SimpleParam = string | number | boolean | null; + +/** + * The base type for the params that a request takes. + */ +type BaseParams = (SimpleParam | Record)[]; + +/** + * The type of the `payload` for `sendAsync`. + */ +type SendAsyncPayload = { + id: number; + jsonrpc: '2.0'; + method: string; + params: Params; +}; + +/** + * The type of the `callback` for `sendAsync`. + */ +type SendAsyncCallback = ( + ...args: + | [error: EverythingButNull, result: undefined] + | [error: null, result: Result] +) => void; + +/** + * The type of the `response` for the provider object. + */ +type ProviderSendAsyncResponse = { + error?: { message: string }; + result?: Result; +}; + +/** + * The type of the `callback` for the provider object's `sendAsync` method. + */ +type ProviderSendAsyncCallback = ( + error: unknown, + response: ProviderSendAsyncResponse, +) => void; + +/** + * An Ethereum provider object. Although it may contain other methods, all we + * care about in this library is `sendAsync`. + */ +export type Provider = { + sendAsync( + payload: SendAsyncPayload, + callback: ProviderSendAsyncCallback, + ): void; +}; + +/** + * Generates an instance method designed to call an RPC method. This instance + * method uses `sendAsync` internally to make the request to the network. + * + * @param methodName - The RPC method. + * @returns The generated method. + */ +function generateFnFor(methodName: string) { + return function ( + this: EthQuery, + ...args: [...Params, SendAsyncCallback] + ) { + const callback = args.pop(); + // Typecast: The remaining arguments must be the params. + const params = args.slice(0, -1) as Params; + if (callback === undefined) { + throw new Error('Could not find callback'); + } + if (typeof callback !== 'function') { + throw new Error('Callback is not a function'); + } + // We are inside EthQuery at this point. + // eslint-disable-next-line no-invalid-this + this.sendAsync( + { + method: methodName, + params, + }, + callback, + ); + }; +} + +/** + * Generates an instance method designed to call an RPC method that takes a + * block parameter, but where the API is simplified such that this parameter can + * be omitted, in which case it is filled in with "latest". Once this occurs, + * the generated instance method uses `sendAsync` internally to make the request + * to the network. + * + * @param argCount - The number of parameters that the RPC method is + * expected to take. + * @param methodName - The RPC method. + * @returns The generated method. + */ +function generateFnWithDefaultBlockFor( + argCount: number, + methodName: string, +) { + return function ( + this: EthQuery, + ...args: [...Params, SendAsyncCallback] + ) { + const callback = args.pop(); + // Typecast: The remaining arguments must be the params. + const params = args.slice(0, -1) as Params; + if (callback === undefined) { + throw new Error('Could not find callback'); + } + if (typeof callback !== 'function') { + throw new Error('Callback is not a function'); + } + // set optional default block param + if (params.length < argCount) { + params.push('latest'); + } + // We are inside EthQuery at this point. + // eslint-disable-next-line no-invalid-this + this.sendAsync( + { + method: methodName, + params, + }, + callback, + ); + }; +} + +/** + * Builds a complete request payload object from a partial version. + * + * @param data - The partial request object. + * @returns The complete request object. + */ +function createPayload( + data: PickPartial, 'id' | 'jsonrpc' | 'params'> & + Pick, 'method'>, +): SendAsyncPayload { + return Object.assign( + {}, + { + // defaults + id: createRandomId(), + jsonrpc: '2.0', + params: [], + }, + // user-specified + data, + ); +} + +/** + * Wrapping an Ethereum provider object, EthQuery provides some conveniences + * around making requests to an RPC endpoint: + * + * - Each of the RPC methods in the Ethereum spec may be requested not only + * via `sendAsync`, but also via its own instance method, whose API is suited + * for the RPC method. + * - When requesting an RPC method, `id` and `jsonrpc` do not need to be + * specified and are filled in with reasonable defaults. + * - The mechanics of `sendAsync` (or any of the RPC-method-specific instance + * methods) are simplified such that its callback will be called with an error + * argument not only if the callback on the provider's `sendAsync` method was + * called with an argument, but also if the `response` object has an `error` + * property. + */ +export class EthQuery { + /** + * The Ethereum provider that the EthQuery is wrapping. + */ + currentProvider: Provider; + + /** + * Constructs an EthQuery. + * + * @param provider - The Ethereum provider. + */ + constructor(provider: Provider) { + this.currentProvider = provider; + } + + /** + * Makes an `eth_getBalance` request, filling in the block param with "latest" + * if not given. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getBalance = generateFnWithDefaultBlockFor(2, 'eth_getBalance'); + + /** + * Makes an `eth_getCode` request, filling in the block param with "latest" + * if not given. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getCode = generateFnWithDefaultBlockFor(2, 'eth_getCode'); + + /** + * Makes an `eth_getTransactionCount` request, filling in the block param with + * "latest" if not given. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getTransactionCount = generateFnWithDefaultBlockFor( + 2, + 'eth_getTransactionCount', + ); + + /** + * Makes an `eth_getStorageAt` request, filling in the block param with + * "latest" if not given. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getStorageAt = generateFnWithDefaultBlockFor(3, 'eth_getStorageAt'); + + /** + * Makes an `eth_call` request, filling in the block param with "latest" if + * not given. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + call = generateFnWithDefaultBlockFor(2, 'eth_call'); + + /** + * Makes an `eth_protocolVersion` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + protocolVersion = generateFnFor('eth_protocolVersion'); + + /** + * Makes an `eth_syncing` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + syncing = generateFnFor('eth_syncing'); + + /** + * Makes an `eth_coinbase` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + coinbase = generateFnFor('eth_coinbase'); + + /** + * Makes an `eth_mining` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + mining = generateFnFor('eth_mining'); + + /** + * Makes an `eth_hashrate` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + hashrate = generateFnFor('eth_hashrate'); + + /** + * Makes an `eth_gasPrice` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + gasPrice = generateFnFor('eth_gasPrice'); + + /** + * Makes an `eth_accounts` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + accounts = generateFnFor('eth_accounts'); + + /** + * Makes an `eth_blockNumber` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + blockNumber = generateFnFor('eth_blockNumber'); + + /** + * Makes an `eth_getBlockTransactionCountByHash` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getBlockTransactionCountByHash = generateFnFor( + 'eth_getBlockTransactionCountByHash', + ); + + /** + * Makes an `eth_getBlockTransactionCountByNumber` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getBlockTransactionCountByNumber = generateFnFor( + 'eth_getBlockTransactionCountByNumber', + ); + + /** + * Makes an `eth_getUncleCountByBlockHash` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getUncleCountByBlockHash = generateFnFor('eth_getUncleCountByBlockHash'); + + /** + * Makes an `eth_getUncleCountByBlockNumber` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getUncleCountByBlockNumber = generateFnFor('eth_getUncleCountByBlockNumber'); + + /** + * Makes an `eth_sign` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + sign = generateFnFor('eth_sign'); + + /** + * Makes an `eth_sendTransaction` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + sendTransaction = generateFnFor('eth_sendTransaction'); + + /** + * Makes an `eth_sendRawTransaction` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + sendRawTransaction = generateFnFor('eth_sendRawTransaction'); + + /** + * Makes an `eth_estimateGas` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + estimateGas = generateFnFor('eth_estimateGas'); + + /** + * Makes an `eth_getBlockByHash` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getBlockByHash = generateFnFor('eth_getBlockByHash'); + + /** + * Makes an `eth_getBlockByNumber` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getBlockByNumber = generateFnFor('eth_getBlockByNumber'); + + /** + * Makes an `eth_getTransactionByHash` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getTransactionByHash = generateFnFor('eth_getTransactionByHash'); + + /** + * Makes an `eth_getTransactionByBlockHashAndIndex` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getTransactionByBlockHashAndIndex = generateFnFor( + 'eth_getTransactionByBlockHashAndIndex', + ); + + /** + * Makes an `eth_getTransactionByBlockNumberAndIndex` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getTransactionByBlockNumberAndIndex = generateFnFor( + 'eth_getTransactionByBlockNumberAndIndex', + ); + + /** + * Makes an `eth_getTransactionReceipt` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getTransactionReceipt = generateFnFor('eth_getTransactionReceipt'); + + /** + * Makes an `eth_getUncleByBlockHashAndIndex` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getUncleByBlockHashAndIndex = generateFnFor( + 'eth_getUncleByBlockHashAndIndex', + ); + + /** + * Makes an `eth_getUncleByBlockNumberAndIndex` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getUncleByBlockNumberAndIndex = generateFnFor( + 'eth_getUncleByBlockNumberAndIndex', + ); + + /** + * Makes an `eth_getCompilers` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getCompilers = generateFnFor('eth_getCompilers'); + + /** + * Makes an `eth_compileLLL` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + compileLLL = generateFnFor('eth_compileLLL'); + + /** + * Makes an `eth_compileSolidity` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + compileSolidity = generateFnFor('eth_compileSolidity'); + + /** + * Makes an `eth_compileSerpent` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + compileSerpent = generateFnFor('eth_compileSerpent'); + + /** + * Makes an `eth_newFilter` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + newFilter = generateFnFor('eth_newFilter'); + + /** + * Makes an `eth_newBlockFilter` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + newBlockFilter = generateFnFor('eth_newBlockFilter'); + + /** + * Makes an `eth_newPendingTransactionFilter` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + newPendingTransactionFilter = generateFnFor( + 'eth_newPendingTransactionFilter', + ); + + /** + * Makes an `eth_uninstallFilter` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + uninstallFilter = generateFnFor('eth_uninstallFilter'); + + /** + * Makes an `eth_getFilterChanges` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getFilterChanges = generateFnFor('eth_getFilterChanges'); + + /** + * Makes an `eth_getFilterLogs` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getFilterLogs = generateFnFor('eth_getFilterLogs'); + + /** + * Makes an `eth_getLogs` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getLogs = generateFnFor('eth_getLogs'); + + /** + * Makes an `eth_getWork` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + getWork = generateFnFor('eth_getWork'); + + /** + * Makes an `eth_submitWork` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + submitWork = generateFnFor('eth_submitWork'); + + /** + * Makes an `eth_submitHashrate` request. + * + * @param args - The params for the request followed by a callback, which will + * be called with an error value or a result value depending on the outcome of + * the request. + */ + submitHashrate = generateFnFor('eth_submitHashrate'); + + /** + * Makes a request for a particular RPC method. + * + * @param opts - The JSON-RPC payload. Must include `method`, but may include + * `id`, `jsonrpc`, or `params`; reasonable defaults will be used for any + * omitted properties. + * @param callback - A function which will be called with an error value or a + * result value depending on the outcome of the request. + */ + sendAsync( + opts: Partial> & + Pick, 'method'>, + callback: SendAsyncCallback, + ) { + const payload = createPayload(opts); + this.currentProvider.sendAsync( + payload, + (error, response) => { + let improvedError = error; + if (!error && response.error) { + improvedError = new Error( + `EthQuery - RPC Error - ${response.error.message}`, + ); + } + if (improvedError) { + return callback(improvedError, undefined); + } + if (response.result) { + return callback(null, response.result); + } + throw new Error( + 'The callback to sendAsync received no error or response', + ); + }, + ); + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..65429ee --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export * from './eth-query'; diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..d14bab8 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "noEmit": false, + "outDir": "dist", + "rootDir": "src", + "sourceMap": true + }, + "exclude": ["./dist", "./node_modules", "./src/**/*.test.ts"] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..097cac2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "exactOptionalPropertyTypes": true, + "forceConsistentCasingInFileNames": true, + "lib": ["ES2020"], + "module": "CommonJS", + "moduleResolution": "node", + "noEmit": true, + "noErrorTruncation": true, + "noUncheckedIndexedAccess": true, + "strict": true, + "target": "es2020" + }, + "exclude": ["./dist", "./node_modules"] +} diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..b527b62 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,6 @@ +{ + "entryPoints": ["./src/index.ts"], + "excludePrivate": true, + "hideGenerator": true, + "out": "docs" +} diff --git a/types/json-rpc-random-id.d.ts b/types/json-rpc-random-id.d.ts new file mode 100644 index 0000000..e28c42d --- /dev/null +++ b/types/json-rpc-random-id.d.ts @@ -0,0 +1,8 @@ +declare module 'json-rpc-random-id' { + // This is the name of the function. + // eslint-disable-next-line @typescript-eslint/naming-convention + export default function IdIterator(opts?: { + max?: number; + start?: number; + }): () => number; +} diff --git a/yarn.lock b/yarn.lock index 02b16b9..092fc3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -151,6 +151,15 @@ __metadata: languageName: node linkType: hard +"@cspotcode/source-map-support@npm:^0.8.0": + version: 0.8.1 + resolution: "@cspotcode/source-map-support@npm:0.8.1" + dependencies: + "@jridgewell/trace-mapping": 0.3.9 + checksum: 5718f267085ed8edb3e7ef210137241775e607ee18b77d95aa5bd7514f47f5019aa2d82d96b3bf342ef7aa890a346fa1044532ff7cc3009e7d24fce3ce6200fa + languageName: node + linkType: hard + "@es-joy/jsdoccomment@npm:~0.36.1": version: 0.36.1 resolution: "@es-joy/jsdoccomment@npm:0.36.1" @@ -261,6 +270,13 @@ __metadata: languageName: node linkType: hard +"@jridgewell/resolve-uri@npm:^3.0.3": + version: 3.1.1 + resolution: "@jridgewell/resolve-uri@npm:3.1.1" + checksum: f5b441fe7900eab4f9155b3b93f9800a916257f4e8563afbcd3b5a5337b55e52bd8ae6735453b1b745457d9f6cdb16d74cd6220bbdd98cf153239e13f6cbb653 + languageName: node + linkType: hard + "@jridgewell/set-array@npm:^1.0.1": version: 1.1.2 resolution: "@jridgewell/set-array@npm:1.1.2" @@ -282,6 +298,16 @@ __metadata: languageName: node linkType: hard +"@jridgewell/trace-mapping@npm:0.3.9": + version: 0.3.9 + resolution: "@jridgewell/trace-mapping@npm:0.3.9" + dependencies: + "@jridgewell/resolve-uri": ^3.0.3 + "@jridgewell/sourcemap-codec": ^1.4.10 + checksum: d89597752fd88d3f3480845691a05a44bd21faac18e2185b6f436c3b0fd0c5a859fbbd9aaa92050c4052caf325ad3e10e2e1d1b64327517471b7d51babc0ddef + languageName: node + linkType: hard + "@jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.9": version: 0.3.18 resolution: "@jridgewell/trace-mapping@npm:0.3.18" @@ -350,6 +376,19 @@ __metadata: languageName: node linkType: hard +"@metamask/eslint-config-typescript@npm:^11.0.0": + version: 11.1.0 + resolution: "@metamask/eslint-config-typescript@npm:11.1.0" + peerDependencies: + "@metamask/eslint-config": ^11.0.0 + "@typescript-eslint/eslint-plugin": ^5.42.1 + "@typescript-eslint/parser": ^5.42.1 + eslint: ^8.27.0 + typescript: ~4.8.4 + checksum: 86f20303730fce7a2d6944d133e3d4cf745816bdc202fd17ebd341e4937777c662e80b3c1496a8da7d5e06e39518dec3206c4a4e872d9491f423e792bcdf56db + languageName: node + linkType: hard + "@metamask/eslint-config@npm:^11.0.1": version: 11.1.0 resolution: "@metamask/eslint-config@npm:11.1.0" @@ -457,6 +496,41 @@ __metadata: languageName: node linkType: hard +"@tsconfig/node10@npm:^1.0.7": + version: 1.0.9 + resolution: "@tsconfig/node10@npm:1.0.9" + checksum: a33ae4dc2a621c0678ac8ac4bceb8e512ae75dac65417a2ad9b022d9b5411e863c4c198b6ba9ef659e14b9fb609bbec680841a2e84c1172df7a5ffcf076539df + languageName: node + linkType: hard + +"@tsconfig/node12@npm:^1.0.7": + version: 1.0.11 + resolution: "@tsconfig/node12@npm:1.0.11" + checksum: 5ce29a41b13e7897a58b8e2df11269c5395999e588b9a467386f99d1d26f6c77d1af2719e407621412520ea30517d718d5192a32403b8dfcc163bf33e40a338a + languageName: node + linkType: hard + +"@tsconfig/node14@npm:^1.0.0": + version: 1.0.3 + resolution: "@tsconfig/node14@npm:1.0.3" + checksum: 19275fe80c4c8d0ad0abed6a96dbf00642e88b220b090418609c4376e1cef81bf16237bf170ad1b341452feddb8115d8dd2e5acdfdea1b27422071163dc9ba9d + languageName: node + linkType: hard + +"@tsconfig/node16@npm:^1.0.2": + version: 1.0.4 + resolution: "@tsconfig/node16@npm:1.0.4" + checksum: 202319785901f942a6e1e476b872d421baec20cf09f4b266a1854060efbf78cde16a4d256e8bc949d31e6cd9a90f1e8ef8fb06af96a65e98338a2b6b0de0a0ff + languageName: node + linkType: hard + +"@types/json-schema@npm:^7.0.9": + version: 7.0.12 + resolution: "@types/json-schema@npm:7.0.12" + checksum: 00239e97234eeb5ceefb0c1875d98ade6e922bfec39dd365ec6bd360b5c2f825e612ac4f6e5f1d13601b8b30f378f15e6faa805a3a732f4a1bbe61915163d293 + languageName: node + linkType: hard + "@types/json5@npm:^0.0.29": version: 0.0.29 resolution: "@types/json5@npm:0.0.29" @@ -471,6 +545,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^16": + version: 16.18.38 + resolution: "@types/node@npm:16.18.38" + checksum: a3baa141e49ce94486f083eea1240cf38479a73ba663e1bf3f52f85b466125821b6e3ea85ded38fde3901530aca4601291395a50eefcea533a4f3b45171bda28 + languageName: node + linkType: hard + "@types/parse-json@npm:^4.0.0": version: 4.0.0 resolution: "@types/parse-json@npm:4.0.0" @@ -478,6 +559,134 @@ __metadata: languageName: node linkType: hard +"@types/semver@npm:^7.3.12": + version: 7.5.0 + resolution: "@types/semver@npm:7.5.0" + checksum: 0a64b9b9c7424d9a467658b18dd70d1d781c2d6f033096a6e05762d20ebbad23c1b69b0083b0484722aabf35640b78ccc3de26368bcae1129c87e9df028a22e2 + languageName: node + linkType: hard + +"@typescript-eslint/eslint-plugin@npm:^5.43.0": + version: 5.62.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.62.0" + dependencies: + "@eslint-community/regexpp": ^4.4.0 + "@typescript-eslint/scope-manager": 5.62.0 + "@typescript-eslint/type-utils": 5.62.0 + "@typescript-eslint/utils": 5.62.0 + debug: ^4.3.4 + graphemer: ^1.4.0 + ignore: ^5.2.0 + natural-compare-lite: ^1.4.0 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependencies: + "@typescript-eslint/parser": ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: fc104b389c768f9fa7d45a48c86d5c1ad522c1d0512943e782a56b1e3096b2cbcc1eea3fcc590647bf0658eef61aac35120a9c6daf979bf629ad2956deb516a1 + languageName: node + linkType: hard + +"@typescript-eslint/parser@npm:^5.43.0": + version: 5.62.0 + resolution: "@typescript-eslint/parser@npm:5.62.0" + dependencies: + "@typescript-eslint/scope-manager": 5.62.0 + "@typescript-eslint/types": 5.62.0 + "@typescript-eslint/typescript-estree": 5.62.0 + debug: ^4.3.4 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: d168f4c7f21a7a63f47002e2d319bcbb6173597af5c60c1cf2de046b46c76b4930a093619e69faf2d30214c29ab27b54dcf1efc7046a6a6bd6f37f59a990e752 + languageName: node + linkType: hard + +"@typescript-eslint/scope-manager@npm:5.62.0": + version: 5.62.0 + resolution: "@typescript-eslint/scope-manager@npm:5.62.0" + dependencies: + "@typescript-eslint/types": 5.62.0 + "@typescript-eslint/visitor-keys": 5.62.0 + checksum: 6062d6b797fe1ce4d275bb0d17204c827494af59b5eaf09d8a78cdd39dadddb31074dded4297aaf5d0f839016d601032857698b0e4516c86a41207de606e9573 + languageName: node + linkType: hard + +"@typescript-eslint/type-utils@npm:5.62.0": + version: 5.62.0 + resolution: "@typescript-eslint/type-utils@npm:5.62.0" + dependencies: + "@typescript-eslint/typescript-estree": 5.62.0 + "@typescript-eslint/utils": 5.62.0 + debug: ^4.3.4 + tsutils: ^3.21.0 + peerDependencies: + eslint: "*" + peerDependenciesMeta: + typescript: + optional: true + checksum: fc41eece5f315dfda14320be0da78d3a971d650ea41300be7196934b9715f3fe1120a80207551eb71d39568275dbbcf359bde540d1ca1439d8be15e9885d2739 + languageName: node + linkType: hard + +"@typescript-eslint/types@npm:5.62.0": + version: 5.62.0 + resolution: "@typescript-eslint/types@npm:5.62.0" + checksum: 48c87117383d1864766486f24de34086155532b070f6264e09d0e6139449270f8a9559cfef3c56d16e3bcfb52d83d42105d61b36743626399c7c2b5e0ac3b670 + languageName: node + linkType: hard + +"@typescript-eslint/typescript-estree@npm:5.62.0": + version: 5.62.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.62.0" + dependencies: + "@typescript-eslint/types": 5.62.0 + "@typescript-eslint/visitor-keys": 5.62.0 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 3624520abb5807ed8f57b1197e61c7b1ed770c56dfcaca66372d584ff50175225798bccb701f7ef129d62c5989070e1ee3a0aa2d84e56d9524dcf011a2bb1a52 + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:5.62.0": + version: 5.62.0 + resolution: "@typescript-eslint/utils@npm:5.62.0" + dependencies: + "@eslint-community/eslint-utils": ^4.2.0 + "@types/json-schema": ^7.0.9 + "@types/semver": ^7.3.12 + "@typescript-eslint/scope-manager": 5.62.0 + "@typescript-eslint/types": 5.62.0 + "@typescript-eslint/typescript-estree": 5.62.0 + eslint-scope: ^5.1.1 + semver: ^7.3.7 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: ee9398c8c5db6d1da09463ca7bf36ed134361e20131ea354b2da16a5fdb6df9ba70c62a388d19f6eebb421af1786dbbd79ba95ddd6ab287324fc171c3e28d931 + languageName: node + linkType: hard + +"@typescript-eslint/visitor-keys@npm:5.62.0": + version: 5.62.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.62.0" + dependencies: + "@typescript-eslint/types": 5.62.0 + eslint-visitor-keys: ^3.3.0 + checksum: 976b05d103fe8335bef5c93ad3f76d781e3ce50329c0243ee0f00c0fcfb186c81df50e64bfdd34970148113f8ade90887f53e3c4938183afba830b4ba8e30a35 + languageName: node + linkType: hard + "@vue/compiler-core@npm:3.3.4": version: 3.3.4 resolution: "@vue/compiler-core@npm:3.3.4" @@ -564,7 +773,14 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.9.0": +"acorn-walk@npm:^8.1.1": + version: 8.2.0 + resolution: "acorn-walk@npm:8.2.0" + checksum: 1715e76c01dd7b2d4ca472f9c58968516a4899378a63ad5b6c2d668bba8da21a71976c14ec5f5b75f887b6317c4ae0b897ab141c831d741dc76024d8745f1ad1 + languageName: node + linkType: hard + +"acorn@npm:^8.4.1, acorn@npm:^8.9.0": version: 8.10.0 resolution: "acorn@npm:8.10.0" bin: @@ -629,6 +845,13 @@ __metadata: languageName: node linkType: hard +"ansi-sequence-parser@npm:^1.1.0": + version: 1.1.0 + resolution: "ansi-sequence-parser@npm:1.1.0" + checksum: 75f4d3a4c555655a698aec05b5763cbddcd16ccccdbfd178fb0aa471ab74fdf98e031b875ef26e64be6a95cf970c89238744b26de6e34af97f316d5186b1df53 + languageName: node + linkType: hard + "ansi-styles@npm:^3.2.1": version: 3.2.1 resolution: "ansi-styles@npm:3.2.1" @@ -681,6 +904,13 @@ __metadata: languageName: node linkType: hard +"arg@npm:^4.1.0": + version: 4.1.3 + resolution: "arg@npm:4.1.3" + checksum: 544af8dd3f60546d3e4aff084d451b96961d2267d668670199692f8d054f0415d86fc5497d0e641e91546f0aa920e7c29e5250e99fc89f5552a34b5d93b77f43 + languageName: node + linkType: hard + "argparse@npm:^1.0.7": version: 1.0.10 resolution: "argparse@npm:1.0.10" @@ -1053,6 +1283,13 @@ __metadata: languageName: node linkType: hard +"create-require@npm:^1.1.0": + version: 1.1.1 + resolution: "create-require@npm:1.1.1" + checksum: a9a1503d4390d8b59ad86f4607de7870b39cad43d929813599a23714831e81c520bddf61bcdd1f8e30f05fd3a2b71ae8538e946eb2786dc65c2bbc520f692eff + languageName: node + linkType: hard + "cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -1199,6 +1436,13 @@ __metadata: languageName: node linkType: hard +"diff@npm:^4.0.1": + version: 4.0.2 + resolution: "diff@npm:4.0.2" + checksum: f2c09b0ce4e6b301c221addd83bf3f454c0bc00caa3dd837cf6c127d6edf7223aa2bbe3b688feea110b7f262adbfc845b757c44c8a9f8c0c5b15d8fa9ce9d20d + languageName: node + linkType: hard + "diff@npm:^5.0.0": version: 5.1.0 resolution: "diff@npm:5.1.0" @@ -1499,6 +1743,16 @@ __metadata: languageName: node linkType: hard +"eslint-scope@npm:^5.1.1": + version: 5.1.1 + resolution: "eslint-scope@npm:5.1.1" + dependencies: + esrecurse: ^4.3.0 + estraverse: ^4.1.1 + checksum: 47e4b6a3f0cc29c7feedee6c67b225a2da7e155802c6ea13bbef4ac6b9e10c66cd2dcb987867ef176292bf4e64eccc680a49e35e9e9c669f4a02bac17e86abdb + languageName: node + linkType: hard + "eslint-scope@npm:^7.2.0": version: 7.2.0 resolution: "eslint-scope@npm:7.2.0" @@ -1620,6 +1874,13 @@ __metadata: languageName: node linkType: hard +"estraverse@npm:^4.1.1": + version: 4.3.0 + resolution: "estraverse@npm:4.3.0" + checksum: a6299491f9940bb246124a8d44b7b7a413a8336f5436f9837aaa9330209bd9ee8af7e91a654a3545aee9c54b3308e78ee360cef1d777d37cfef77d2fa33b5827 + languageName: node + linkType: hard + "estraverse@npm:^5.1.0, estraverse@npm:^5.2.0": version: 5.3.0 resolution: "estraverse@npm:5.3.0" @@ -1650,6 +1911,10 @@ __metadata: "@metamask/auto-changelog": ^3.1.0 "@metamask/eslint-config": ^11.0.1 "@metamask/eslint-config-nodejs": ^11.0.1 + "@metamask/eslint-config-typescript": ^11.0.0 + "@types/node": ^16 + "@typescript-eslint/eslint-plugin": ^5.43.0 + "@typescript-eslint/parser": ^5.43.0 depcheck: ^1.4.3 eslint: ^8.27.0 eslint-config-prettier: ^8.5.0 @@ -1660,7 +1925,10 @@ __metadata: json-rpc-random-id: ^1.0.0 prettier: ^2.7.1 prettier-plugin-packagejson: ^2.3.0 - xtend: ^4.0.1 + rimraf: ^3.0.2 + ts-node: ^10.7.0 + typedoc: ^0.23.15 + typescript: ~4.8.4 languageName: unknown linkType: soft @@ -1719,7 +1987,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.3.0": +"fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": version: 3.3.0 resolution: "fast-glob@npm:3.3.0" dependencies: @@ -2027,6 +2295,20 @@ __metadata: languageName: node linkType: hard +"globby@npm:^11.1.0": + version: 11.1.0 + resolution: "globby@npm:11.1.0" + dependencies: + array-union: ^2.1.0 + dir-glob: ^3.0.1 + fast-glob: ^3.2.9 + ignore: ^5.2.0 + merge2: ^1.4.1 + slash: ^3.0.0 + checksum: b4be8885e0cfa018fc783792942d53926c35c50b3aefd3fdcfb9d22c627639dc26bd2327a40a0b74b074100ce95bb7187bfeae2f236856aa3de183af7a02aea6 + languageName: node + linkType: hard + "globby@npm:^13.1.2": version: 13.2.2 resolution: "globby@npm:13.2.2" @@ -2644,6 +2926,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:^3.2.0": + version: 3.2.0 + resolution: "jsonc-parser@npm:3.2.0" + checksum: 946dd9a5f326b745aa326d48a7257e3f4a4b62c5e98ec8e49fa2bdd8d96cef7e6febf1399f5c7016114fd1f68a1c62c6138826d5d90bc650448e3cf0951c53c7 + languageName: node + linkType: hard + "levn@npm:^0.4.1": version: 0.4.1 resolution: "levn@npm:0.4.1" @@ -2718,6 +3007,13 @@ __metadata: languageName: node linkType: hard +"lunr@npm:^2.3.9": + version: 2.3.9 + resolution: "lunr@npm:2.3.9" + checksum: 176719e24fcce7d3cf1baccce9dd5633cd8bdc1f41ebe6a180112e5ee99d80373fe2454f5d4624d437e5a8319698ca6837b9950566e15d2cae5f2a543a3db4b8 + languageName: node + linkType: hard + "magic-string@npm:^0.30.0": version: 0.30.1 resolution: "magic-string@npm:0.30.1" @@ -2727,6 +3023,13 @@ __metadata: languageName: node linkType: hard +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + "make-fetch-happen@npm:^11.0.3": version: 11.1.1 resolution: "make-fetch-happen@npm:11.1.1" @@ -2750,6 +3053,15 @@ __metadata: languageName: node linkType: hard +"marked@npm:^4.2.12": + version: 4.3.0 + resolution: "marked@npm:4.3.0" + bin: + marked: bin/marked.js + checksum: 0db6817893952c3ec710eb9ceafb8468bf5ae38cb0f92b7b083baa13d70b19774674be04db5b817681fa7c5c6a088f61300815e4dd75a59696f4716ad69f6260 + languageName: node + linkType: hard + "merge-stream@npm:^2.0.0": version: 2.0.0 resolution: "merge-stream@npm:2.0.0" @@ -2797,6 +3109,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^7.1.3": + version: 7.4.6 + resolution: "minimatch@npm:7.4.6" + dependencies: + brace-expansion: ^2.0.1 + checksum: 1a6c8d22618df9d2a88aabeef1de5622eb7b558e9f8010be791cb6b0fa6e102d39b11c28d75b855a1e377b12edc7db8ff12a99c20353441caa6a05e78deb5da9 + languageName: node + linkType: hard + "minimatch@npm:^9.0.1": version: 9.0.3 resolution: "minimatch@npm:9.0.3" @@ -2942,6 +3263,13 @@ __metadata: languageName: node linkType: hard +"natural-compare-lite@npm:^1.4.0": + version: 1.4.0 + resolution: "natural-compare-lite@npm:1.4.0" + checksum: 5222ac3986a2b78dd6069ac62cbb52a7bf8ffc90d972ab76dfe7b01892485d229530ed20d0c62e79a6b363a663b273db3bde195a1358ce9e5f779d4453887225 + languageName: node + linkType: hard + "natural-compare@npm:^1.4.0": version: 1.4.0 resolution: "natural-compare@npm:1.4.0" @@ -3539,7 +3867,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.8": +"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8": version: 7.5.4 resolution: "semver@npm:7.5.4" dependencies: @@ -3573,6 +3901,18 @@ __metadata: languageName: node linkType: hard +"shiki@npm:^0.14.1": + version: 0.14.3 + resolution: "shiki@npm:0.14.3" + dependencies: + ansi-sequence-parser: ^1.1.0 + jsonc-parser: ^3.2.0 + vscode-oniguruma: ^1.7.0 + vscode-textmate: ^8.0.0 + checksum: a4dd98e3b2a5dd8be207448f111ffb9ad2ed6c530f215714d8b61cbf91ec3edbabb09109b8ec58a26678aacd24e8161d5a9bc0c1fa1b4f64b27ceb180cbd0c89 + languageName: node + linkType: hard + "side-channel@npm:^1.0.4": version: 1.0.4 resolution: "side-channel@npm:1.0.4" @@ -3598,6 +3938,13 @@ __metadata: languageName: node linkType: hard +"slash@npm:^3.0.0": + version: 3.0.0 + resolution: "slash@npm:3.0.0" + checksum: 94a93fff615f25a999ad4b83c9d5e257a7280c90a32a7cb8b4a87996e4babf322e469c42b7f649fd5796edd8687652f3fb452a86dc97a816f01113183393f11c + languageName: node + linkType: hard + "slash@npm:^4.0.0": version: 4.0.0 resolution: "slash@npm:4.0.0" @@ -3893,6 +4240,44 @@ __metadata: languageName: node linkType: hard +"ts-node@npm:^10.7.0": + version: 10.9.1 + resolution: "ts-node@npm:10.9.1" + dependencies: + "@cspotcode/source-map-support": ^0.8.0 + "@tsconfig/node10": ^1.0.7 + "@tsconfig/node12": ^1.0.7 + "@tsconfig/node14": ^1.0.0 + "@tsconfig/node16": ^1.0.2 + acorn: ^8.4.1 + acorn-walk: ^8.1.1 + arg: ^4.1.0 + create-require: ^1.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + v8-compile-cache-lib: ^3.0.1 + yn: 3.1.1 + peerDependencies: + "@swc/core": ">=1.2.50" + "@swc/wasm": ">=1.2.50" + "@types/node": "*" + typescript: ">=2.7" + peerDependenciesMeta: + "@swc/core": + optional: true + "@swc/wasm": + optional: true + bin: + ts-node: dist/bin.js + ts-node-cwd: dist/bin-cwd.js + ts-node-esm: dist/bin-esm.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: 090adff1302ab20bd3486e6b4799e90f97726ed39e02b39e566f8ab674fd5bd5f727f43615debbfc580d33c6d9d1c6b1b3ce7d8e3cca3e20530a145ffa232c35 + languageName: node + linkType: hard + "tsconfig-paths@npm:^3.14.1": version: 3.14.2 resolution: "tsconfig-paths@npm:3.14.2" @@ -3905,6 +4290,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:^1.8.1": + version: 1.14.1 + resolution: "tslib@npm:1.14.1" + checksum: dbe628ef87f66691d5d2959b3e41b9ca0045c3ee3c7c7b906cc1e328b39f199bb1ad9e671c39025bd56122ac57dfbf7385a94843b1cc07c60a4db74795829acd + languageName: node + linkType: hard + "tslib@npm:^2.5.0, tslib@npm:^2.6.0": version: 2.6.0 resolution: "tslib@npm:2.6.0" @@ -3912,6 +4304,17 @@ __metadata: languageName: node linkType: hard +"tsutils@npm:^3.21.0": + version: 3.21.0 + resolution: "tsutils@npm:3.21.0" + dependencies: + tslib: ^1.8.1 + peerDependencies: + typescript: ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + checksum: 1843f4c1b2e0f975e08c4c21caa4af4f7f65a12ac1b81b3b8489366826259323feb3fc7a243123453d2d1a02314205a7634e048d4a8009921da19f99755cdc48 + languageName: node + linkType: hard + "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0" @@ -3939,6 +4342,42 @@ __metadata: languageName: node linkType: hard +"typedoc@npm:^0.23.15": + version: 0.23.28 + resolution: "typedoc@npm:0.23.28" + dependencies: + lunr: ^2.3.9 + marked: ^4.2.12 + minimatch: ^7.1.3 + shiki: ^0.14.1 + peerDependencies: + typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x + bin: + typedoc: bin/typedoc + checksum: 40eb4e207aac1b734e09400cf03f543642cc7b11000895198dd5a0d3166315759ccf4ac30a2915153597c5c186101c72bac2f1fc12b428184a9274d3a0e44c5e + languageName: node + linkType: hard + +"typescript@npm:~4.8.4": + version: 4.8.4 + resolution: "typescript@npm:4.8.4" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 3e4f061658e0c8f36c820802fa809e0fd812b85687a9a2f5430bc3d0368e37d1c9605c3ce9b39df9a05af2ece67b1d844f9f6ea8ff42819f13bcb80f85629af0 + languageName: node + linkType: hard + +"typescript@patch:typescript@~4.8.4#~builtin": + version: 4.8.4 + resolution: "typescript@patch:typescript@npm%3A4.8.4#~builtin::version=4.8.4&hash=7ad353" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 563a0ef47abae6df27a9a3ab38f75fc681f633ccf1a3502b1108e252e187787893de689220f4544aaf95a371a4eb3141e4a337deb9895de5ac3c1ca76430e5f0 + languageName: node + linkType: hard + "unbox-primitive@npm:^1.0.2": version: 1.0.2 resolution: "unbox-primitive@npm:1.0.2" @@ -3992,6 +4431,27 @@ __metadata: languageName: node linkType: hard +"v8-compile-cache-lib@npm:^3.0.1": + version: 3.0.1 + resolution: "v8-compile-cache-lib@npm:3.0.1" + checksum: 78089ad549e21bcdbfca10c08850022b22024cdcc2da9b168bcf5a73a6ed7bf01a9cebb9eac28e03cd23a684d81e0502797e88f3ccd27a32aeab1cfc44c39da0 + languageName: node + linkType: hard + +"vscode-oniguruma@npm:^1.7.0": + version: 1.7.0 + resolution: "vscode-oniguruma@npm:1.7.0" + checksum: 53519d91d90593e6fb080260892e87d447e9b200c4964d766772b5053f5699066539d92100f77f1302c91e8fc5d9c772fbe40fe4c90f3d411a96d5a9b1e63f42 + languageName: node + linkType: hard + +"vscode-textmate@npm:^8.0.0": + version: 8.0.0 + resolution: "vscode-textmate@npm:8.0.0" + checksum: 127780dfea89559d70b8326df6ec344cfd701312dd7f3f591a718693812b7852c30b6715e3cfc8b3200a4e2515b4c96f0843c0eacc0a3020969b5de262c2a4bb + languageName: node + linkType: hard + "which-boxed-primitive@npm:^1.0.2": version: 1.0.2 resolution: "which-boxed-primitive@npm:1.0.2" @@ -4089,13 +4549,6 @@ __metadata: languageName: node linkType: hard -"xtend@npm:^4.0.1": - version: 4.0.2 - resolution: "xtend@npm:4.0.2" - checksum: ac5dfa738b21f6e7f0dd6e65e1b3155036d68104e67e5d5d1bde74892e327d7e5636a076f625599dc394330a731861e87343ff184b0047fef1360a7ec0a5a36a - languageName: node - linkType: hard - "y18n@npm:^5.0.5": version: 5.0.8 resolution: "y18n@npm:5.0.8" @@ -4161,6 +4614,13 @@ __metadata: languageName: node linkType: hard +"yn@npm:3.1.1": + version: 3.1.1 + resolution: "yn@npm:3.1.1" + checksum: 2c487b0e149e746ef48cda9f8bad10fc83693cd69d7f9dcd8be4214e985de33a29c9e24f3c0d6bcf2288427040a8947406ab27f7af67ee9456e6b84854f02dd6 + languageName: node + linkType: hard + "yocto-queue@npm:^0.1.0": version: 0.1.0 resolution: "yocto-queue@npm:0.1.0"