@mr-zwets/bchn-api-wrapper 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/src/index.d.ts +4 -0
  2. package/dist/src/index.js +4 -0
  3. package/{src/interfaces/interfaces.ts → dist/src/interfaces/interfaces.d.ts} +51 -65
  4. package/dist/src/interfaces/interfaces.js +1 -0
  5. package/{src/interfaces/restInterfaces/interfaces.ts → dist/src/interfaces/restInterfaces/interfaces.d.ts} +145 -166
  6. package/dist/src/interfaces/restInterfaces/interfaces.js +1 -0
  7. package/dist/src/interfaces/rpcInterfaces/blockchain.d.ts +883 -0
  8. package/dist/src/interfaces/rpcInterfaces/blockchain.js +3 -0
  9. package/dist/src/interfaces/rpcInterfaces/control.d.ts +60 -0
  10. package/dist/src/interfaces/rpcInterfaces/control.js +3 -0
  11. package/dist/src/interfaces/rpcInterfaces/generating.d.ts +19 -0
  12. package/dist/src/interfaces/rpcInterfaces/generating.js +3 -0
  13. package/dist/src/interfaces/rpcInterfaces/index.d.ts +9 -0
  14. package/{src/interfaces/rpcInterfaces/index.ts → dist/src/interfaces/rpcInterfaces/index.js} +1 -3
  15. package/dist/src/interfaces/rpcInterfaces/mining.d.ts +140 -0
  16. package/dist/src/interfaces/rpcInterfaces/mining.js +3 -0
  17. package/dist/src/interfaces/rpcInterfaces/network.d.ts +197 -0
  18. package/dist/src/interfaces/rpcInterfaces/network.js +3 -0
  19. package/dist/src/interfaces/rpcInterfaces/rawtransactions.d.ts +304 -0
  20. package/dist/src/interfaces/rpcInterfaces/rawtransactions.js +3 -0
  21. package/dist/src/interfaces/rpcInterfaces/util.d.ts +49 -0
  22. package/dist/src/interfaces/rpcInterfaces/util.js +3 -0
  23. package/dist/src/interfaces/rpcInterfaces/wallet.d.ts +674 -0
  24. package/dist/src/interfaces/rpcInterfaces/wallet.js +3 -0
  25. package/dist/src/interfaces/rpcInterfaces/zmq.d.ts +9 -0
  26. package/dist/src/interfaces/rpcInterfaces/zmq.js +3 -0
  27. package/dist/src/restClient.d.ts +29 -0
  28. package/dist/src/restClient.js +113 -0
  29. package/dist/src/rpcClient.d.ts +19 -0
  30. package/dist/src/rpcClient.js +92 -0
  31. package/dist/src/utils/errors.d.ts +3 -0
  32. package/dist/src/utils/errors.js +6 -0
  33. package/dist/src/utils/utils.d.ts +11 -0
  34. package/dist/src/utils/utils.js +49 -0
  35. package/package.json +7 -3
  36. package/.claude/settings.local.json +0 -8
  37. package/.github/workflows/ci.yaml +0 -36
  38. package/CLAUDE.md +0 -70
  39. package/pnpm-lock.yaml +0 -1279
  40. package/src/index.ts +0 -4
  41. package/src/interfaces/rpcInterfaces/blockchain.ts +0 -933
  42. package/src/interfaces/rpcInterfaces/control.ts +0 -68
  43. package/src/interfaces/rpcInterfaces/generating.ts +0 -23
  44. package/src/interfaces/rpcInterfaces/mining.ts +0 -151
  45. package/src/interfaces/rpcInterfaces/network.ts +0 -213
  46. package/src/interfaces/rpcInterfaces/rawtransactions.ts +0 -332
  47. package/src/interfaces/rpcInterfaces/util.ts +0 -56
  48. package/src/interfaces/rpcInterfaces/wallet.ts +0 -728
  49. package/src/interfaces/rpcInterfaces/zmq.ts +0 -12
  50. package/src/restClient.ts +0 -134
  51. package/src/rpcClient.ts +0 -100
  52. package/src/utils/errors.ts +0 -6
  53. package/src/utils/utils.ts +0 -55
  54. package/test/restClient.test.ts +0 -34
  55. package/test/rpcClient.test.ts +0 -119
  56. package/test/setupTests.ts +0 -56
  57. package/test/tsconfig.json +0 -4
  58. package/tsconfig.json +0 -13
  59. package/vitest.config.ts +0 -9
package/src/restClient.ts DELETED
@@ -1,134 +0,0 @@
1
- import type { RestClientConfig, formatOptions, ResponseType } from "./interfaces/interfaces.js";
2
- import type {
3
- BlockInfoNoTxDetails,
4
- BlockInfoTxDetails,
5
- BlockInfoWithPatterns,
6
- ChainInfo,
7
- HeaderInfo,
8
- MempoolContent,
9
- MempoolInfo,
10
- TxDetails,
11
- TxDetailsWithPatterns,
12
- UtxosInfo
13
- } from "./interfaces/restInterfaces/interfaces.js";
14
- import { validateUrl } from "./utils/utils.js";
15
-
16
- /** REST client for read-only BCHN blockchain access via the REST interface. */
17
- export class BchnRestClient {
18
- private baseUrl: string;
19
- private timeoutMs: number;
20
- private logger: Console;
21
-
22
- constructor(config: RestClientConfig) {
23
- this.baseUrl = validateUrl(config.url);
24
- this.timeoutMs = config.timeoutMs ?? 5000;
25
- this.logger = config.logger ?? console;
26
- }
27
-
28
- private async fetchFromNode<T, TFormat extends formatOptions>(
29
- endpoint: string,
30
- format: TFormat
31
- ): Promise<ResponseType<TFormat, T>> {
32
- try {
33
- const response = await fetch(`${this.baseUrl}/rest/${endpoint}`, {
34
- signal: AbortSignal.timeout(this.timeoutMs),
35
- });
36
-
37
- if (!response.ok) {
38
- throw new Error(`Error fetching data from ${endpoint}: ${response.statusText}`);
39
- }
40
-
41
- if (format === 'json') {
42
- return await response.json() as ResponseType<TFormat, T>;
43
- } else {
44
- return await response.text() as ResponseType<TFormat, T>; // For 'bin' and 'hex', return raw text
45
- }
46
- } catch(error) {
47
- let errorMessage: string | undefined
48
-
49
- // Check if the error is due to timeout or other fetch-related issues
50
- if (typeof error === 'string') {
51
- errorMessage = error;
52
- this.logger.error(error);
53
- } else if (error instanceof DOMException && error.name === 'TimeoutError') {
54
- // If error is an instance DOMException TimeoutError
55
- errorMessage = 'Request timed out';
56
- this.logger.error(`Request to ${endpoint} timed out after ${this.timeoutMs} ms`);
57
- } else {
58
- this.logger.error(`Unknown error occurred during request to ${endpoint}`);
59
- throw new Error(`Unknown error: ${error}`);
60
- }
61
-
62
- // Always rethrow the error after logging
63
- throw new Error(errorMessage);
64
- }
65
- }
66
-
67
- /** Returns transaction details by txid. */
68
- async getTransaction<TFormat extends formatOptions = 'json'>(
69
- txid: string, format:TFormat = 'json' as TFormat
70
- ) {
71
- return this.fetchFromNode<TxDetails, TFormat>(`tx/${txid}.${format}`, format);
72
- }
73
-
74
- // getBlock overload signatures
75
- // This is needed so the getBlock return type can depend on the 'includeTxDetails' boolean flag
76
-
77
- /** Returns block data. Use includeTxDetails=true for full transaction objects. */
78
- async getBlock<TFormat extends formatOptions = 'json'>(
79
- blockhash: string, includeTxDetails: true, format?:TFormat
80
- ): Promise<TFormat extends 'json' ? BlockInfoTxDetails : string>;
81
-
82
- async getBlock<TFormat extends formatOptions = 'json'>(
83
- blockhash: string, includeTxDetails: false, format?:TFormat
84
- ): Promise<TFormat extends 'json' ? BlockInfoNoTxDetails : string>;
85
-
86
- // getBlock Implementation
87
- async getBlock<TFormat extends formatOptions = 'json'>(
88
- blockhash: string, includeTxDetails: boolean, format:TFormat = 'json' as TFormat
89
- ): Promise<any> {
90
- const path = includeTxDetails ? 'block' : 'block/notxdetails';
91
- return this.fetchFromNode(`${path}/${blockhash}.${format}`, format);
92
- }
93
-
94
- /** Returns block headers starting from a specific block hash. */
95
- async getBlockHeaders<TFormat extends formatOptions = 'json'>(
96
- count: number, blockhash: string, format:TFormat = 'json' as TFormat
97
- ) {
98
- return this.fetchFromNode<HeaderInfo, TFormat>(`headers/${count}/${blockhash}.${format}`, format);
99
- }
100
-
101
- /** Returns current chain state (network, sync progress, best block). */
102
- async getChainInfo() {
103
- return this.fetchFromNode<ChainInfo, 'json'>('chaininfo.json', 'json');
104
- }
105
-
106
- /** Queries UTXO set for specific outpoints. Outpoints format: "txid-vout". */
107
- async getUTXOs<TFormat extends formatOptions = 'json'>(
108
- checkmempool: boolean, outpoints: string[], format:TFormat = 'json' as TFormat
109
- ) {
110
- const path = (checkmempool ? 'checkmempool/' : '') + outpoints.join('/');
111
- const endpoint = `getutxos/${path}.${format}`;
112
- return this.fetchFromNode<UtxosInfo, TFormat>(endpoint, format);
113
- }
114
-
115
- /** Returns mempool statistics (size, bytes, fee rates). */
116
- async getMempoolInfo() {
117
- return this.fetchFromNode<MempoolInfo, 'json'>('mempool/info.json', 'json');
118
- }
119
-
120
- /** Returns all transactions currently in the mempool. */
121
- async getMempoolContents() {
122
- return this.fetchFromNode<MempoolContent, 'json'>('mempool/contents.json', 'json');
123
- }
124
-
125
- /** Returns block with bytecode pattern data (v29.0.0+). */
126
- async getBlockWithPatterns(blockhash: string) {
127
- return this.fetchFromNode<BlockInfoWithPatterns, 'json'>(`block/withpatterns/${blockhash}.json`, 'json');
128
- }
129
-
130
- /** Returns transaction with bytecode pattern data (v29.0.0+). */
131
- async getTransactionWithPatterns(txid: string) {
132
- return this.fetchFromNode<TxDetailsWithPatterns, 'json'>(`tx/withpatterns/${txid}.json`, 'json');
133
- }
134
- }
package/src/rpcClient.ts DELETED
@@ -1,100 +0,0 @@
1
- import type { RpcClientConfig, RpcRequest } from "./interfaces/interfaces.js";
2
- import { getRandomId, validateAndConstructUrl } from "./utils/utils.js";
3
- import { RetryLimitExceededError } from "./utils/errors.js";
4
-
5
- /** RPC client for full BCHN node interaction via JSON-RPC. */
6
- export class BchnRpcClient {
7
- private url: string
8
- private rpcUser: string
9
- private rpcPassword: string
10
-
11
- private maxRetries: number // number of retries before throwing an exception
12
- private retryDelayMs: number // delay between each retry
13
- private logger: typeof console // logger
14
- private timeoutMs: number // max timeout for each retry
15
-
16
- constructor(config: RpcClientConfig){
17
- this.url = validateAndConstructUrl(config)
18
- if(!config.rpcUser) throw new Error('Need to provide rpcUser in config')
19
- if(!config.rpcPassword) throw new Error('Need to provide rpcPassword in config')
20
- this.rpcUser = config.rpcUser;
21
- this.rpcPassword= config.rpcPassword;
22
-
23
- // optional config
24
- this.maxRetries = config.maxRetries ?? 0;
25
- this.retryDelayMs= config.retryDelayMs ?? 100;
26
- this.logger = config.logger ?? console;
27
- this.timeoutMs = config.timeoutMs ?? 5000;
28
- }
29
-
30
- /**
31
- * Sends a typed RPC request to the BCHN node.
32
- * @example
33
- * const result = await client.request<GetBlockCount>("getblockcount");
34
- * const block = await client.request<GetBlockVerbosity1>("getblock", hash, 1);
35
- */
36
- async request<T extends RpcRequest>(
37
- endpoint: T['method'],
38
- ...params: T['params']
39
- ): Promise<T['response']> {
40
- const auth = Buffer.from(`${this.rpcUser}:${this.rpcPassword}`).toString('base64');
41
-
42
- // Retry logic
43
- for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
44
- try {
45
- // Send the request with a timeout and retries
46
- const response = await fetch(this.url, {
47
- method: 'POST',
48
- headers: {
49
- 'Content-Type': 'application/json',
50
- 'Authorization': `Basic ${auth}`
51
- },
52
- body: JSON.stringify({ jsonrpc: '2.0', method: endpoint, params, id: getRandomId() }),
53
- signal: AbortSignal.timeout(this.timeoutMs),
54
- });
55
-
56
- const result = await response.json();
57
-
58
- // Handle response errors
59
- if (!response.ok || result.error) {
60
- throw new Error(`Error: ${result.error?.message || response.statusText}`);
61
- }
62
-
63
- return result.result as T['response']; // Return the result if successful
64
-
65
- } catch (error) {
66
- let errorMessage: string | undefined
67
-
68
- // Check if the error is due to timeout or other fetch-related issues
69
- if(typeof error == 'string'){
70
- errorMessage = error
71
- this.logger.error(error)
72
- }
73
- else if (error instanceof DOMException && error.name === 'TimeoutError') {
74
- // If error is an instance DOMException TimeoutError
75
- errorMessage = error.message
76
- this.logger.error(`Request timed out after ${this.timeoutMs} ms`);
77
- }
78
- else if (error instanceof Error) {
79
- // If error is an instance of Error, you can safely access its properties
80
- errorMessage = error.message
81
- this.logger.error(`Request failed with error: ${error.message}`);
82
-
83
- }
84
-
85
- // Retry if allowed
86
- if (attempt < this.maxRetries) {
87
- this.logger.warn(`Retrying request... (${attempt + 1}/${this.maxRetries})`);
88
- await new Promise(res => setTimeout(res, this.retryDelayMs)); // Wait before retrying
89
- } else {
90
- // If no retries are left, throw the final error
91
- throw new RetryLimitExceededError(`Request failed after ${this.maxRetries + 1} attempts: ${errorMessage}`);
92
- }
93
- }
94
- }
95
-
96
- // This line ensures TypeScript is satisfied that a value will always be returned, but
97
- // it should never be reached if the retries fail, as the last attempt should throw an error.
98
- throw new Error('Request failed unexpectedly');
99
- }
100
- }
@@ -1,6 +0,0 @@
1
- export class RetryLimitExceededError extends Error {
2
- constructor(message: string) {
3
- super(message);
4
- this.name = 'RetryLimitExceededError';
5
- }
6
- }
@@ -1,55 +0,0 @@
1
- import type {
2
- RpcClientConfig,
3
- RpcClientUrlConfig,
4
- RpcClientHostConfig,
5
- } from "../interfaces/interfaces.js";
6
-
7
- export function getRandomId(): number {
8
- return Math.floor(Math.random() * 100000);
9
- }
10
-
11
- // A utility function to validate and construct the URL from the RpcClientConfig object
12
- export function validateAndConstructUrl(config: RpcClientConfig): string {
13
- let url: string
14
- if (isUrlConfig(config)) {
15
- url = validateUrl(config.url)
16
- } else if (isHostConfig(config)) {
17
- const { protocol, host, port } = config;
18
- if (protocol !== 'http' && protocol !== 'https') {
19
- throw new Error("Protocol should be 'http' or 'https'");
20
- }
21
- url = validateUrl(`${protocol}://${host}:${port}`)
22
- } else {
23
- throw new Error('Invalid configuration: Either provide the url or protocol/host/port');
24
- }
25
- return url
26
- }
27
-
28
- // A utility function to validate a URL
29
- export function validateUrl(url: string) {
30
- if(!url) throw new Error('URL is required');
31
- try {
32
- new URL(url);
33
- } catch (err) {
34
- throw new Error('Invalid URL format');
35
- }
36
- return url
37
- }
38
-
39
- // Type guard to check if the config is RpcClientUrlConfig
40
- function isUrlConfig(config: RpcClientConfig): config is RpcClientUrlConfig {
41
- return 'url' in config;
42
- }
43
-
44
- // Type guard to check if the config is RpcClientHostConfig
45
- function isHostConfig(config: RpcClientConfig): config is RpcClientHostConfig {
46
- return 'protocol' in config && 'hostname' in config && 'port' in config;
47
- }
48
-
49
- export enum BchnNetworkPort {
50
- Mainnet = 8332,
51
- Testnet = 18332,
52
- Testnet4 = 28332,
53
- Scalenet = 38332,
54
- Regtest = 18443
55
- }
@@ -1,34 +0,0 @@
1
- import { BchnRestClient } from '../src/index.js';
2
-
3
- const localhostUrl = 'http://localhost:8332';
4
-
5
- describe('BchnRestClient URL validation tests', () => {
6
- it('should create an instance with a valid URL', () => {
7
- const client = new BchnRestClient({url: localhostUrl});
8
- expect(client).toBeInstanceOf(BchnRestClient);
9
- });
10
-
11
- it('should throw an error for an invalid URL', () => {
12
- expect(() => new BchnRestClient({url: 'invalid-url'})).toThrow('Invalid URL');
13
- });
14
-
15
- it('should throw an error if the URL is missing', () => {
16
- expect(() => new BchnRestClient({url: ''})).toThrow('URL is required');
17
- });
18
- });
19
-
20
- describe('BchnRestClient Timeout Handling', () => {
21
- const config = {
22
- url: localhostUrl,
23
- timeoutMs: 1000, // 1 second timeout
24
- };
25
- const restClient = new BchnRestClient(config);
26
-
27
- it('should throw a timeout error if the request exceeds the timeout limit', async () => {
28
- await expect(restClient.getChainInfo()).rejects.toThrow('Request timed out');
29
- });
30
-
31
- it('should not return a timeout error if the request completes in time', async () => {
32
- await expect(restClient.getMempoolInfo()).resolves.toEqual({});
33
- });
34
- });
@@ -1,119 +0,0 @@
1
- import { BchnRpcClient, type GetBestBlockHash, type GetBlockCount, type GetBlockHash, type RpcClientConfig } from '../src/index.js';
2
-
3
- const localhostUrl = 'http://localhost:8332';
4
- const testRpcUser = 'rpcUser';
5
- const testRpcPassword = 'rpcPassword';
6
-
7
- describe('BchnRpcClient should have the correct constructor arguments', () => {
8
- it('should create an instance with a valid URL', () => {
9
- const config = {
10
- url: localhostUrl,
11
- rpcUser: testRpcUser,
12
- rpcPassword: testRpcPassword
13
- }
14
- const client = new BchnRpcClient(config);
15
- expect(client).toBeInstanceOf(BchnRpcClient);
16
- });
17
-
18
- it('should throw an error for an invalid URL', () => {
19
- const config = {
20
- url: 'invalid-url',
21
- rpcUser: testRpcUser,
22
- rpcPassword: testRpcPassword
23
- }
24
- expect(() => new BchnRpcClient(config)).toThrow('Invalid URL');
25
- });
26
-
27
- it('should throw an error if the URL is empty', () => {
28
- const config = {
29
- url: '',
30
- rpcUser: testRpcUser,
31
- rpcPassword: testRpcPassword
32
- }
33
- expect(() => new BchnRpcClient(config)).toThrow('URL is required');
34
- });
35
-
36
- it('should throw an error if the URL is missing', () => {
37
- const config = {
38
- rpcUser: testRpcUser,
39
- rpcPassword: testRpcPassword
40
- } as RpcClientConfig
41
- expect(() => new BchnRpcClient(config)).toThrow('Invalid configuration: Either provide the url or protocol/host/port');
42
- });
43
-
44
- it('should throw an error if rpcUser is missing', () => {
45
- const config = {
46
- url: localhostUrl,
47
- rpcPassword: testRpcPassword
48
- } as RpcClientConfig
49
- expect(() => new BchnRpcClient(config)).toThrow('Need to provide rpcUser in config');
50
- });
51
-
52
- it('should throw an error if rpcPassword is missing', () => {
53
- const config = {
54
- url: localhostUrl,
55
- rpcUser: testRpcUser
56
- } as RpcClientConfig
57
- expect(() => new BchnRpcClient(config)).toThrow('Need to provide rpcPassword in config');
58
- });
59
- });
60
-
61
- describe('BchnRpcClient Timeout and Retry Handling', () => {
62
- it('should throw a timeout error if the request exceeds the timeout limit', async () => {
63
- const config = {
64
- url: localhostUrl,
65
- rpcUser: testRpcUser,
66
- rpcPassword: testRpcPassword,
67
- timeoutMs: 1000,
68
- }
69
- const rpcClient = new BchnRpcClient(config);
70
-
71
- await expect(rpcClient.request("getbestblockhash")).rejects.toThrow('Request failed after 1 attempts: The operation was aborted due to timeout');
72
- });
73
-
74
- it('should not return a timeout error if the request completes in time', async () => {
75
- const config = {
76
- url: localhostUrl,
77
- rpcUser: testRpcUser,
78
- rpcPassword: testRpcPassword,
79
- timeoutMs: 1000,
80
- }
81
- const rpcClient = new BchnRpcClient(config);
82
-
83
- await expect(rpcClient.request<GetBlockCount>("getblockcount")).resolves.toEqual({});
84
- });
85
-
86
- it('should return an RetryLimitExceededError if all retries fail', async () => {
87
- const config = {
88
- url: localhostUrl,
89
- rpcUser: testRpcUser,
90
- rpcPassword: testRpcPassword,
91
- maxRetries: 3,
92
- timeoutMs: 1000,
93
- }
94
- const rpcClient = new BchnRpcClient(config);
95
- await expect(rpcClient.request<GetBestBlockHash>("getbestblockhash")).rejects.toThrow("Request failed after 4 attempts: The operation was aborted due to timeout");
96
- });
97
- });
98
-
99
- describe('BchnRpcClient Handling of Parameters', () => {
100
- it('should error with incorrect number of params', async () => {
101
- const config = {
102
- url: localhostUrl,
103
- rpcUser: testRpcUser,
104
- rpcPassword: testRpcPassword,
105
- }
106
- const rpcClient = new BchnRpcClient(config);
107
- await expect(rpcClient.request("getblockhash")).rejects.toThrow("Request failed after 1 attempts: Error: Invalid Request");
108
- })
109
-
110
- it('should not error with correct number of params', async () => {
111
- const config = {
112
- url: localhostUrl,
113
- rpcUser: testRpcUser,
114
- rpcPassword: testRpcPassword,
115
- }
116
- const rpcClient = new BchnRpcClient(config);
117
- await expect(rpcClient.request<GetBlockHash>("getblockhash", 5)).resolves.toEqual({});
118
- })
119
- })
@@ -1,56 +0,0 @@
1
- import { http, delay, HttpResponse } from 'msw';
2
- import { setupServer, SetupServerApi } from 'msw/node';
3
-
4
- type jsonResult = { method: string; params?: unknown[] } | null | undefined
5
-
6
- const localhostUrl = 'http://localhost:8332';
7
-
8
- const server: SetupServerApi = setupServer(
9
- // Mock endpoint with a delay to simulate timeout
10
- http.get(`${localhostUrl}/rest/chaininfo.json`, async() => {
11
- // Introduce a delay longer than the timeout setting to simulate a timeout scenario
12
- await delay(3000)
13
- return HttpResponse.json({})
14
- }),
15
-
16
- http.get(`${localhostUrl}/rest/mempool/info.json`, async() => {
17
- // Mock normally working REST endpoint
18
- await delay(500)
19
- return HttpResponse.json({})
20
- }),
21
-
22
- http.post(`${localhostUrl}`, async ({ request }) => {
23
- const json = await request.json() as jsonResult;
24
-
25
- if (json === null || json === undefined) {
26
- throw new Error('Invalid JSON response');
27
- }
28
-
29
- // Introduce a delay longer than the timeout setting to simulate a timeout scenario
30
- if (json.method === 'getbestblockhash') {
31
- await delay(3000)
32
- return HttpResponse.json({"jsonrpc": "2.0", "result": {}, "id": 4})
33
- }
34
-
35
- if (json.method === 'getblockcount') {
36
- // Mock normally working RPC command
37
- await delay(500)
38
- return HttpResponse.json({"jsonrpc": "2.0", "result": {}, "id": 5})
39
- }
40
-
41
- if (json.method === 'getblockhash') {
42
- // Mock normally working RPC command
43
- await delay(500)
44
- if (json.params?.[0]) {
45
- return HttpResponse.json({"jsonrpc": "2.0", "result": {}, "id": 6})
46
- } else {
47
- return HttpResponse.json({"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}, "id": 7})
48
- }
49
- }
50
- })
51
- );
52
-
53
- // Start the server before tests and reset handlers after each test
54
- beforeAll(() => server.listen());
55
- afterEach(() => server.resetHandlers());
56
- afterAll(() => server.close());
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "include": ["**/*"],
4
- }
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "NodeNext",
4
- "verbatimModuleSyntax": true,
5
- "moduleResolution": "NodeNext",
6
- "target": "ES6",
7
- "strict": true,
8
- "outDir": "./dist",
9
- "declaration": true,
10
- "types": ["vitest/globals", "node"],
11
- },
12
- "include": ["src"]
13
- }
package/vitest.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'node',
7
- setupFiles: ['./test/setupTests.ts']
8
- },
9
- })