diff --git a/.changeset/red-rings-approve.md b/.changeset/red-rings-approve.md new file mode 100644 index 000000000..23c231c2a --- /dev/null +++ b/.changeset/red-rings-approve.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/rpc": minor +--- + +Replace the HTTP client `axios` with the native supported `fetch` to avoid the modifying the default adapter of axios diff --git a/packages/rpc/__tests__/ckb-rpc.test.js b/packages/rpc/__tests__/ckb-rpc.test.js index 4561b55dc..2263ad920 100644 --- a/packages/rpc/__tests__/ckb-rpc.test.js +++ b/packages/rpc/__tests__/ckb-rpc.test.js @@ -1,8 +1,18 @@ /* eslint-disable max-len */ +/** mock template start **/ +jest.mock("cross-fetch"); +const axiosMock = require("cross-fetch").default; + +beforeAll(() => { + const originalResolve = axiosMock.mockResolvedValue; + axiosMock.mockResolvedValue = (value) => + originalResolve({ + json: () => Promise.resolve(value.data), + }); +}); -jest.mock("axios"); +/** mock template end **/ -const axiosMock = require("axios"); const { CKBRPC, ResultFormatter } = require("../lib"); describe("Test with mock", () => { @@ -94,7 +104,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getBlockByNumber(BLOCK_NUMBER); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_block_by_number", @@ -175,7 +185,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.txPoolInfo(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "tx_pool_info", @@ -202,7 +212,7 @@ describe("Test with mock", () => { }); const res = await rpc.clearTxPool(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "clear_tx_pool", @@ -245,7 +255,7 @@ describe("Test with mock", () => { }); const res = await rpc.getRawTxPool(true); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_raw_tx_pool", @@ -292,7 +302,7 @@ describe("Test with mock", () => { }); const res = await rpc.getRawTxPool(false); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_raw_tx_pool", @@ -321,7 +331,7 @@ describe("Test with mock", () => { }); const res = await rpc.getRawTxPool(null); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_raw_tx_pool", @@ -350,7 +360,7 @@ describe("Test with mock", () => { }); const res = await rpc.getRawTxPool(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_raw_tx_pool", @@ -379,7 +389,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getCurrentEpoch(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_current_epoch", @@ -407,7 +417,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getEpochByNumber(BLOCK_NUMBER); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_epoch_by_number", @@ -438,7 +448,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getCellbaseOutputCapacityDetails(BLOCK_HASH); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_cellbase_output_capacity_details", @@ -469,7 +479,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.calculateDaoMaximumWithdraw(...PARAMS); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "calculate_dao_maximum_withdraw", @@ -510,7 +520,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getBlockEconomicState(BLOCK_HASH); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_block_economic_state", @@ -564,7 +574,7 @@ describe("Test with mock", () => { TRANSACTION_HASHES, BLOCK_HASH ); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_transaction_proof", @@ -609,7 +619,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getTransactionProof(TRANSACTION_HASHES); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_transaction_proof", @@ -652,7 +662,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.verifyTransactionProof(TRANSACTION_PROOF); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "verify_transaction_proof", @@ -716,7 +726,7 @@ describe("Test with mock", () => { }); const res = await rpc.getConsensus(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_consensus", @@ -778,7 +788,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getBlockchainInfo(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_blockchain_info", @@ -822,7 +832,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.localNodeInfo(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "local_node_info", @@ -859,7 +869,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getPeers(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_peers", @@ -877,7 +887,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getTipBlockNumber(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_tip_block_number", @@ -896,7 +906,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getBlockHash("0x0"); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_block_hash", @@ -974,7 +984,7 @@ describe("Test with mock", () => { }); const res = await rpc.getBlock(BLOCK_HASH); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_block", @@ -1064,7 +1074,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getTipHeader(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_tip_header", @@ -1139,7 +1149,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getTransaction(TX_HASH); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_transaction", @@ -1218,7 +1228,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getLiveCell(OUT_POINT, true); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_live_cell", @@ -1261,7 +1271,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getBannedAddresses(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_banned_addresses", @@ -1279,7 +1289,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.clearBannedAddresses(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "clear_banned_addresses", @@ -1298,7 +1308,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.setBan(...PARAMS); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "set_ban", @@ -1325,7 +1335,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.syncState(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "sync_state", @@ -1352,7 +1362,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.setNetworkActive(false); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "set_network_active", @@ -1372,7 +1382,7 @@ describe("Test with mock", () => { const PEER_ID = "peer id"; const ADDRESS = "address"; const res = await rpc.addNode(PEER_ID, ADDRESS); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "add_node", @@ -1391,7 +1401,7 @@ describe("Test with mock", () => { }); const PEER_ID = "peer id"; const res = await rpc.removeNode(PEER_ID); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "remove_node", @@ -1409,7 +1419,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.pingPeers(); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "ping_peers", @@ -1446,7 +1456,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getHeader(BLOCK_HASH); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_header", @@ -1499,7 +1509,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.getHeaderByNumber(BLOCK_NUMBER); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "get_header_by_number", @@ -1573,7 +1583,7 @@ describe("Test with mock", () => { }, }); const res = await rpc.sendTransaction(tx, "passthrough"); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", method: "send_transaction", @@ -2035,7 +2045,7 @@ describe("Test with mock", () => { "\n", JSON.stringify({ id, jsonrpc: "2.0", ...expectedParams }) ); - expect(axiosMock.mock.calls[0][0].data).toEqual({ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ id, jsonrpc: "2.0", ...expectedParams, @@ -2192,7 +2202,7 @@ describe("Test with mock", () => { ], }); const res = await batch.exec(); - expect(axiosMock.mock.calls[0][0].data).toEqual([ + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual([ { id, jsonrpc: "2.0", diff --git a/packages/rpc/__tests__/initAxiosWebworkerAdapter.test.js b/packages/rpc/__tests__/initAxiosWebworkerAdapter.test.js deleted file mode 100644 index b5ad1d8d8..000000000 --- a/packages/rpc/__tests__/initAxiosWebworkerAdapter.test.js +++ /dev/null @@ -1,25 +0,0 @@ -const { - initAxiosWebworkerAdapter, -} = require("../lib/initAxiosWebworkerAdapter"); - -jest.mock("@vespaiach/axios-fetch-adapter", () => ({ - __esModule: true, - default: jest.fn(), -})); -const axios = require("axios"); - -const defaultAdapter = axios.defaults.adapter; -const fetchAdapter = require("@vespaiach/axios-fetch-adapter").default; - -describe("initAxiosWebworkerAdapter", () => { - it("Should the adapter is default adapter when it's not on service worker", () => { - initAxiosWebworkerAdapter(); - expect(axios.defaults.adapter).toBe(defaultAdapter); - }); - - it("Should the adapter become fetch adapter when it's on service worker", () => { - globalThis.ServiceWorkerGlobalScope = Object; - initAxiosWebworkerAdapter(); - expect(axios.defaults.adapter).toBe(fetchAdapter); - }); -}); diff --git a/packages/rpc/__tests__/method.test.js b/packages/rpc/__tests__/method.test.js index 39f1a12b2..06ef9c05c 100644 --- a/packages/rpc/__tests__/method.test.js +++ b/packages/rpc/__tests__/method.test.js @@ -1,7 +1,20 @@ -jest.mock('axios') -const axiosMock = require('axios') const {Method} = require('../lib/method') +jest.mock("cross-fetch"); +const axiosMock = require("cross-fetch").default; + +beforeAll(() => { + const originalResolve = axiosMock.mockResolvedValue; + axiosMock.mockResolvedValue = (value) => + originalResolve({ + json: () => Promise.resolve(value.data), + }); +}); + +afterAll(() => { + jest.restoreAllMocks(); +}); + describe('Test Method', () => { const ranNum = 1 const id = Math.round(ranNum * 10000) diff --git a/packages/rpc/__tests__/mock.test.js b/packages/rpc/__tests__/mock.test.js new file mode 100644 index 000000000..67332d558 --- /dev/null +++ b/packages/rpc/__tests__/mock.test.js @@ -0,0 +1,44 @@ +/** mock template start **/ +jest.mock("cross-fetch"); +const axiosMock = require("cross-fetch").default; + +const { RPC } = require("../"); + +beforeAll(() => { + const originalResolve = axiosMock.mockResolvedValue; + axiosMock.mockResolvedValue = (value) => + originalResolve({ + json: () => Promise.resolve(value), + }); +}); + +/** mock template end **/ + +describe("mock cross-fetch", () => { + afterEach(() => { + jest.clearAllMocks(); + }); + + it("json() should work as expected", async () => { + axiosMock.mockResolvedValue({ key: "value" }); + + const res = await axiosMock("test-url", {}); + await expect(res.json()).resolves.toEqual({ key: "value" }); + }); + + it("rpc should work as expected", async () => { + const rpc = new RPC("mock-url"); + + jest.spyOn(globalThis.Math, "random").mockReturnValue(0.1); + axiosMock.mockResolvedValue({ id: 1000, result: "0x1" }); + + const blockNumber = await rpc.getTipBlockNumber(); + expect(JSON.parse(axiosMock.mock.calls[0][1].body)).toEqual({ + jsonrpc: "2.0", + id: 1000, + method: "get_tip_block_number", + params: [], + }); + expect(blockNumber).toBe("0x1"); + }); +}); diff --git a/packages/rpc/__tests__/nock-test/rpc.test.js b/packages/rpc/__tests__/nock-test/rpc.test.js index 3757f97aa..6abccb503 100644 --- a/packages/rpc/__tests__/nock-test/rpc.test.js +++ b/packages/rpc/__tests__/nock-test/rpc.test.js @@ -20,7 +20,7 @@ describe("rpc", () => { try { await rpc.getBlockHash("0x01"); } catch (err) { - expect(err.message).toEqual("timeout of 100ms exceeded"); + expect(err.message).toMatch(/aborted/); } }); it("should call rpc successful", async () => { diff --git a/packages/rpc/package.json b/packages/rpc/package.json index 149019221..ca39cf69f 100644 --- a/packages/rpc/package.json +++ b/packages/rpc/package.json @@ -38,9 +38,8 @@ "dependencies": { "@ckb-lumos/base": "0.21.0-next.1", "@ckb-lumos/bi": "0.21.0-next.1", - "@vespaiach/axios-fetch-adapter": "^0.3.1", - "axios": "0.27.2", - "tslib": "2.3.1" + "abort-controller": "^3.0.0", + "cross-fetch": "^3.1.5" }, "devDependencies": { "@types/jest": "^29.4.0", diff --git a/packages/rpc/src/index.ts b/packages/rpc/src/index.ts index 2e8125ec6..cad961650 100644 --- a/packages/rpc/src/index.ts +++ b/packages/rpc/src/index.ts @@ -1,23 +1,20 @@ -// import axios from 'axios' import { Base } from "./Base"; import { Method } from "./method"; import { CKBComponents } from "./types/api"; - import { formatter as paramsFormatter } from "./paramsFormatter"; import * as resultFormatter from "./resultFormatter"; - import { IdNotMatchedInBatchException, MethodInBatchNotFoundException, PayloadInBatchException, } from "./exceptions"; -import axios from "axios"; import { RPCConfig } from "./types/common"; -import { initAxiosWebworkerAdapter } from "./initAxiosWebworkerAdapter"; +import fetch from "cross-fetch"; +import { AbortController as CrossAbortController } from "abort-controller"; export const ParamsFormatter = paramsFormatter; export const ResultFormatter = resultFormatter; -initAxiosWebworkerAdapter(); + export class CKBRPC extends Base { #config: RPCConfig; #node: CKBComponents.Node = { @@ -136,17 +133,24 @@ export class CKBRPC extends Base { } }); - const batchRes = await axios({ + const controller = new CrossAbortController() as AbortController; + const signal = controller.signal; + + const timeout = setTimeout( + () => controller.abort(), + ctx.#config.timeout + ); + + const batchRes = await fetch(ctx.#node.url, { method: "POST", headers: { "content-type": "application/json" }, - data: payload, - url: ctx.#node.url, - httpAgent: ctx.#node.httpAgent, - httpsAgent: ctx.#node.httpsAgent, - timeout: ctx.#config.timeout, - }); + body: JSON.stringify(payload), + signal: signal, + }).then((res) => res.json()); + + clearTimeout(timeout); - return batchRes.data.map((res: any, i: number) => { + return batchRes.map((res: any, i: number) => { if (res.id !== payload[i].id) { return new IdNotMatchedInBatchException(i, payload[i].id, res.id); } diff --git a/packages/rpc/src/initAxiosWebworkerAdapter.ts b/packages/rpc/src/initAxiosWebworkerAdapter.ts deleted file mode 100644 index af5cd5345..000000000 --- a/packages/rpc/src/initAxiosWebworkerAdapter.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -/* eslint-disable @typescript-eslint/no-var-requires */ -import axios from "axios"; - -// this is a hack for passing unit tests -/** @internal */ -export function initAxiosWebworkerAdapter(): void { - /* istanbul ignore next */ - if ( - // @ts-ignore - "ServiceWorkerGlobalScope" in globalThis && - // @ts-ignore - globalThis instanceof globalThis?.ServiceWorkerGlobalScope - ) { - /* istanbul ignore next */ const fetchAdapter = require("@vespaiach/axios-fetch-adapter"); - /* istanbul ignore next */ axios.defaults.adapter = fetchAdapter.default; - } -} diff --git a/packages/rpc/src/method.ts b/packages/rpc/src/method.ts index 8e3d06d55..a46edd9f3 100644 --- a/packages/rpc/src/method.ts +++ b/packages/rpc/src/method.ts @@ -1,10 +1,9 @@ -import axios from "axios"; import { IdNotMatchException, ResponseException } from "./exceptions"; -import { initAxiosWebworkerAdapter } from "./initAxiosWebworkerAdapter"; import { CKBComponents } from "./types/api"; import { RPCConfig } from "./types/common"; +import fetch from "cross-fetch"; +import { AbortController as CrossAbortController } from "abort-controller"; -initAxiosWebworkerAdapter(); export class Method { #name: string; #config: RPCConfig; @@ -40,29 +39,36 @@ export class Method { } /* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types */ - public call = (...params: (string | number | object)[]) => { + public call = async (...params: (string | number | object)[]) => { const payload = this.getPayload(...params); - return axios({ + const controller = new CrossAbortController() as AbortController; + const signal = controller.signal; + + const timeout = setTimeout(() => controller.abort(), this.#config.timeout); + + const res = await fetch(this.#node.url, { method: "POST", headers: { "content-type": "application/json", }, - data: payload, - url: this.#node.url, - httpAgent: this.#node.httpAgent, - httpsAgent: this.#node.httpsAgent, - timeout: this.#config.timeout, - }).then((res) => { - if (res.data.id !== payload.id) { - throw new IdNotMatchException(payload.id, res.data.id); - } - if (res.data.error) { - throw new ResponseException(JSON.stringify(res.data.error)); - } - return ( - this.#options.resultFormatters?.(res.data.result) ?? res.data.result - ); - }); + body: JSON.stringify(payload), + signal, + }) + .then((res) => res.json()) + .then((res) => { + if (res.id !== payload.id) { + throw new IdNotMatchException(payload.id, res.id); + } + if (res.error) { + throw new ResponseException(JSON.stringify(res.error)); + } + return ( + this.#options.resultFormatters?.(res.result) ?? res.result + ); + }); + + clearTimeout(timeout); + return res; }; public getPayload = (...params: (string | number | object)[]) => { diff --git a/packages/rpc/tsconfig.json b/packages/rpc/tsconfig.json index 9606477aa..6e7bf5123 100644 --- a/packages/rpc/tsconfig.json +++ b/packages/rpc/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "lib", - "lib": ["WebWorker"] + "lib": ["DOM"] }, "include": ["src"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ccbdeca8d..084462dc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -610,15 +610,12 @@ importers: '@ckb-lumos/bi': specifier: 0.21.0-next.1 version: link:../bi - '@vespaiach/axios-fetch-adapter': - specifier: ^0.3.1 - version: 0.3.1(axios@0.27.2) - axios: - specifier: 0.27.2 - version: 0.27.2 - tslib: - specifier: 2.3.1 - version: 2.3.1 + abort-controller: + specifier: ^3.0.0 + version: 3.0.0 + cross-fetch: + specifier: ^3.1.5 + version: 3.1.5 devDependencies: '@types/jest': specifier: ^29.4.0 @@ -4636,7 +4633,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 chalk: 4.1.2 jest-message-util: 28.1.3 jest-util: 28.1.3 @@ -4657,14 +4654,14 @@ packages: '@jest/test-result': 28.1.3 '@jest/transform': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.8.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 28.1.3 - jest-config: 28.1.3(@types/node@20.1.0)(ts-node@10.9.1) + jest-config: 28.1.3(@types/node@20.9.0)(ts-node@10.9.1) jest-haste-map: 28.1.3 jest-message-util: 28.1.3 jest-regex-util: 28.0.2 @@ -4692,7 +4689,7 @@ packages: dependencies: '@jest/fake-timers': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 jest-mock: 28.1.3 dev: true @@ -4726,7 +4723,7 @@ packages: dependencies: '@jest/types': 28.1.3 '@sinonjs/fake-timers': 9.1.2 - '@types/node': 20.1.0 + '@types/node': 20.9.0 jest-message-util: 28.1.3 jest-mock: 28.1.3 jest-util: 28.1.3 @@ -4758,7 +4755,7 @@ packages: '@jest/transform': 28.1.3 '@jest/types': 28.1.3 '@jridgewell/trace-mapping': 0.3.18 - '@types/node': 20.1.0 + '@types/node': 20.9.0 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -4853,7 +4850,7 @@ packages: '@jest/schemas': 28.1.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 20.1.0 + '@types/node': 20.9.0 '@types/yargs': 17.0.24 chalk: 4.1.2 dev: true @@ -4865,7 +4862,7 @@ packages: '@jest/schemas': 29.4.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 20.1.0 + '@types/node': 20.9.0 '@types/yargs': 17.0.24 chalk: 4.1.2 @@ -5628,7 +5625,7 @@ packages: /@types/graceful-fs@4.1.6: resolution: {integrity: sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==} dependencies: - '@types/node': 20.1.0 + '@types/node': 20.9.0 dev: true /@types/hast@2.3.4: @@ -5762,6 +5759,11 @@ packages: /@types/node@20.1.0: resolution: {integrity: sha512-O+z53uwx64xY7D6roOi4+jApDGFg0qn6WHcxe5QeqjMaTezBO/mxdfFXIVAVVyNWKx84OmPB3L8kbVYOTeN34A==} + /@types/node@20.9.0: + resolution: {integrity: sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==} + dependencies: + undici-types: 5.26.5 + /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true @@ -6093,14 +6095,6 @@ packages: eslint-visitor-keys: 3.4.1 dev: true - /@vespaiach/axios-fetch-adapter@0.3.1(axios@0.27.2): - resolution: {integrity: sha512-+1F52VWXmQHSRFSv4/H0wtnxfvjRMPK5531e880MIjypPdUSX6QZuoDgEVeCE1vjhzDdxCVX7rOqkub7StEUwQ==} - peerDependencies: - axios: '>=0.26.0' - dependencies: - axios: 0.27.2 - dev: false - /@webassemblyjs/ast@1.11.1: resolution: {integrity: sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==} dependencies: @@ -6343,6 +6337,13 @@ packages: through: 2.3.8 dev: true + /abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + dependencies: + event-target-shim: 5.0.1 + dev: false + /accepts@1.3.8: resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} engines: {node: '>= 0.6'} @@ -6663,6 +6664,7 @@ packages: /asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: true /at-least-node@1.0.0: resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} @@ -6769,15 +6771,6 @@ packages: - debug dev: false - /axios@0.27.2: - resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} - dependencies: - follow-redirects: 1.15.2 - form-data: 4.0.0 - transitivePeerDependencies: - - debug - dev: false - /babel-jest@28.1.3(@babel/core@7.16.7): resolution: {integrity: sha512-epUaPOEWMk3cWX0M/sPvCHHCe9fMFAa/9hXEgKP8nFfNl/jlGkE9ucq9NqkZGXLDduCJYS0UvSlPUwC0S+rH6Q==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} @@ -7699,6 +7692,7 @@ packages: engines: {node: '>= 0.8'} dependencies: delayed-stream: 1.0.0 + dev: true /comma-separated-tokens@1.0.8: resolution: {integrity: sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==} @@ -8465,6 +8459,7 @@ packages: /delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} + dev: true /depd@1.1.2: resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} @@ -9131,6 +9126,11 @@ packages: require-like: 0.1.2 dev: false + /event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + dev: false + /eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: false @@ -9670,15 +9670,6 @@ packages: mime-types: 2.1.35 dev: true - /form-data@4.0.0: - resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} - engines: {node: '>= 6'} - dependencies: - asynckit: 0.4.0 - combined-stream: 1.0.8 - mime-types: 2.1.35 - dev: false - /forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -11001,7 +10992,7 @@ packages: '@jest/expect': 28.1.3 '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -11088,6 +11079,46 @@ packages: - supports-color dev: true + /jest-config@28.1.3(@types/node@20.9.0)(ts-node@10.9.1): + resolution: {integrity: sha512-MG3INjByJ0J4AsNBm7T3hsuxKQqFIiRo/AUqb1q9LRKI5UU6Aar9JHbr9Ivn1TVwfUD9KirRoM/T6u8XlcQPHQ==} + engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} + peerDependencies: + '@types/node': '*' + ts-node: '>=9.0.0' + peerDependenciesMeta: + '@types/node': + optional: true + ts-node: + optional: true + dependencies: + '@babel/core': 7.16.7 + '@jest/test-sequencer': 28.1.3 + '@jest/types': 28.1.3 + '@types/node': 20.9.0 + babel-jest: 28.1.3(@babel/core@7.16.7) + chalk: 4.1.2 + ci-info: 3.8.0 + deepmerge: 4.3.1 + glob: 7.2.3 + graceful-fs: 4.2.11 + jest-circus: 28.1.3 + jest-environment-node: 28.1.3 + jest-get-type: 28.0.2 + jest-regex-util: 28.0.2 + jest-resolve: 28.1.3 + jest-runner: 28.1.3 + jest-util: 28.1.3 + jest-validate: 28.1.3 + micromatch: 4.0.5 + parse-json: 5.2.0 + pretty-format: 28.1.3 + slash: 3.0.0 + strip-json-comments: 3.1.1 + ts-node: 10.9.1(@types/node@20.1.0)(typescript@5.0.4) + transitivePeerDependencies: + - supports-color + dev: true + /jest-diff@28.1.3: resolution: {integrity: sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} @@ -11133,7 +11164,7 @@ packages: '@jest/environment': 28.1.3 '@jest/fake-timers': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 jest-mock: 28.1.3 jest-util: 28.1.3 dev: true @@ -11154,7 +11185,7 @@ packages: dependencies: '@jest/types': 28.1.3 '@types/graceful-fs': 4.1.6 - '@types/node': 20.1.0 + '@types/node': 20.9.0 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -11230,7 +11261,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 dev: true /jest-pnp-resolver@1.2.3(jest-resolve@28.1.3): @@ -11284,7 +11315,7 @@ packages: '@jest/test-result': 28.1.3 '@jest/transform': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 chalk: 4.1.2 emittery: 0.10.2 graceful-fs: 4.2.11 @@ -11370,7 +11401,7 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -11382,7 +11413,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.5.0 - '@types/node': 20.1.0 + '@types/node': 20.9.0 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -11406,7 +11437,7 @@ packages: dependencies: '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 20.1.0 + '@types/node': 20.9.0 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.10.2 @@ -11426,7 +11457,7 @@ packages: resolution: {integrity: sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g==} engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0} dependencies: - '@types/node': 20.1.0 + '@types/node': 20.9.0 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -15542,6 +15573,9 @@ packages: through: 2.3.8 dev: false + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + /unherit@1.1.3: resolution: {integrity: sha512-Ft16BJcnapDKp0+J/rqFC3Rrk6Y/Ng4nzsC028k2jdDII/rdZ7Wd3pPT/6+vIIxRagwRc9K0IUX0Ra4fKvw+WQ==} dependencies: