@trufnetwork/sdk-js 0.3.8 → 0.4.1
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.
- package/dist/cjs/contracts-api/action.cjs +301 -77
- package/dist/cjs/contracts-api/action.cjs.map +3 -3
- package/dist/cjs/contracts-api/cache.integration.test.cjs +265 -0
- package/dist/cjs/contracts-api/cache.integration.test.cjs.map +7 -0
- package/dist/cjs/types/cache.cjs +34 -0
- package/dist/cjs/types/cache.cjs.map +7 -0
- package/dist/cjs/types/cache.test.cjs +205 -0
- package/dist/cjs/types/cache.test.cjs.map +7 -0
- package/dist/cjs/util/cacheMetadataParser.cjs +174 -0
- package/dist/cjs/util/cacheMetadataParser.cjs.map +7 -0
- package/dist/cjs/util/cacheMetadataParser.test.cjs +329 -0
- package/dist/cjs/util/cacheMetadataParser.test.cjs.map +7 -0
- package/dist/cjs/util/cacheValidation.cjs +88 -0
- package/dist/cjs/util/cacheValidation.cjs.map +7 -0
- package/dist/cjs/util/cacheValidation.test.cjs +108 -0
- package/dist/cjs/util/cacheValidation.test.cjs.map +7 -0
- package/dist/esm/contracts-api/action.mjs +302 -77
- package/dist/esm/contracts-api/action.mjs.map +3 -3
- package/dist/esm/contracts-api/cache.integration.test.mjs +263 -0
- package/dist/esm/contracts-api/cache.integration.test.mjs.map +7 -0
- package/dist/esm/types/cache.mjs +13 -0
- package/dist/esm/types/cache.mjs.map +7 -0
- package/dist/esm/types/cache.test.mjs +203 -0
- package/dist/esm/types/cache.test.mjs.map +7 -0
- package/dist/esm/util/cacheMetadataParser.mjs +153 -0
- package/dist/esm/util/cacheMetadataParser.mjs.map +7 -0
- package/dist/esm/util/cacheMetadataParser.test.mjs +327 -0
- package/dist/esm/util/cacheMetadataParser.test.mjs.map +7 -0
- package/dist/esm/util/cacheValidation.mjs +67 -0
- package/dist/esm/util/cacheValidation.mjs.map +7 -0
- package/dist/esm/util/cacheValidation.test.mjs +106 -0
- package/dist/esm/util/cacheValidation.test.mjs.map +7 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/contracts-api/action.d.ts +11 -1
- package/dist/types/contracts-api/action.d.ts.map +1 -1
- package/dist/types/contracts-api/cache.integration.test.d.ts +2 -0
- package/dist/types/contracts-api/cache.integration.test.d.ts.map +1 -0
- package/dist/types/types/cache.d.ts +129 -0
- package/dist/types/types/cache.d.ts.map +1 -0
- package/dist/types/types/cache.test.d.ts +2 -0
- package/dist/types/types/cache.test.d.ts.map +1 -0
- package/dist/types/util/cacheMetadataParser.d.ts +38 -0
- package/dist/types/util/cacheMetadataParser.d.ts.map +1 -0
- package/dist/types/util/cacheMetadataParser.test.d.ts +2 -0
- package/dist/types/util/cacheMetadataParser.test.d.ts.map +1 -0
- package/dist/types/util/cacheValidation.d.ts +27 -0
- package/dist/types/util/cacheValidation.d.ts.map +1 -0
- package/dist/types/util/cacheValidation.test.d.ts +2 -0
- package/dist/types/util/cacheValidation.test.d.ts.map +1 -0
- package/package.json +5 -3
- package/dist/cjs/client/client.test.cjs +0 -32
- package/dist/cjs/client/client.test.cjs.map +0 -7
- package/dist/esm/client/client.test.mjs +0 -30
- package/dist/esm/client/client.test.mjs.map +0 -7
- package/dist/types/client/client.test.d.ts +0 -2
- package/dist/types/client/client.test.d.ts.map +0 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache-related type definitions for the Truf Network SDK
|
|
3
|
+
* These types enable cache-aware operations with proper TypeScript support
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Metadata about cache operations
|
|
7
|
+
* Matches the Go SDK implementation structure
|
|
8
|
+
*/
|
|
9
|
+
export interface CacheMetadata {
|
|
10
|
+
/** Whether the data came from cache */
|
|
11
|
+
hit: boolean;
|
|
12
|
+
/** Whether cache was disabled for this query */
|
|
13
|
+
cacheDisabled?: boolean;
|
|
14
|
+
/** Block height when data was cached (optional) */
|
|
15
|
+
height?: number;
|
|
16
|
+
/** Stream ID used in the query */
|
|
17
|
+
streamId?: string;
|
|
18
|
+
/** Data provider address */
|
|
19
|
+
dataProvider?: string;
|
|
20
|
+
/** Start time of the query range */
|
|
21
|
+
from?: number;
|
|
22
|
+
/** End time of the query range */
|
|
23
|
+
to?: number;
|
|
24
|
+
/** Frozen time for historical queries */
|
|
25
|
+
frozenAt?: number;
|
|
26
|
+
/** Number of rows returned */
|
|
27
|
+
rowsServed?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Enhanced options for getRecord method with cache support
|
|
31
|
+
*/
|
|
32
|
+
export interface GetRecordOptions {
|
|
33
|
+
/** Start time for the query range */
|
|
34
|
+
from?: number;
|
|
35
|
+
/** End time for the query range */
|
|
36
|
+
to?: number;
|
|
37
|
+
/** Frozen time for historical queries */
|
|
38
|
+
frozenAt?: number;
|
|
39
|
+
/** Base time for index calculations */
|
|
40
|
+
baseTime?: string | number;
|
|
41
|
+
/** Procedure name prefix */
|
|
42
|
+
prefix?: string;
|
|
43
|
+
/** Enable cache usage for this query */
|
|
44
|
+
useCache?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Enhanced options for getIndex method with cache support
|
|
48
|
+
*/
|
|
49
|
+
export interface GetIndexOptions {
|
|
50
|
+
/** Start time for the query range */
|
|
51
|
+
from?: number;
|
|
52
|
+
/** End time for the query range */
|
|
53
|
+
to?: number;
|
|
54
|
+
/** Frozen time for historical queries */
|
|
55
|
+
frozenAt?: number;
|
|
56
|
+
/** Base time for index calculations */
|
|
57
|
+
baseTime?: string | number;
|
|
58
|
+
/** Procedure name prefix */
|
|
59
|
+
prefix?: string;
|
|
60
|
+
/** Enable cache usage for this query */
|
|
61
|
+
useCache?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Enhanced options for getIndexChange method with cache support
|
|
65
|
+
*/
|
|
66
|
+
export interface GetIndexChangeOptions {
|
|
67
|
+
/** Start time for the query range */
|
|
68
|
+
from?: number;
|
|
69
|
+
/** End time for the query range */
|
|
70
|
+
to?: number;
|
|
71
|
+
/** Frozen time for historical queries */
|
|
72
|
+
frozenAt?: number;
|
|
73
|
+
/** Base time for index calculations */
|
|
74
|
+
baseTime?: string | number;
|
|
75
|
+
/** Time interval for change calculations */
|
|
76
|
+
timeInterval: number;
|
|
77
|
+
/** Procedure name prefix */
|
|
78
|
+
prefix?: string;
|
|
79
|
+
/** Enable cache usage for this query */
|
|
80
|
+
useCache?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Enhanced options for getFirstRecord method with cache support
|
|
84
|
+
*/
|
|
85
|
+
export interface GetFirstRecordOptions {
|
|
86
|
+
/** Return records after this time */
|
|
87
|
+
after?: number;
|
|
88
|
+
/** Frozen time for historical queries */
|
|
89
|
+
frozenAt?: number;
|
|
90
|
+
/** Enable cache usage for this query */
|
|
91
|
+
useCache?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Response wrapper that includes cache metadata
|
|
95
|
+
* Provides structured access to both data and cache information
|
|
96
|
+
*/
|
|
97
|
+
export interface CacheAwareResponse<T> {
|
|
98
|
+
/** The actual response data */
|
|
99
|
+
data: T;
|
|
100
|
+
/** Cache metadata (if available) */
|
|
101
|
+
cache?: CacheMetadata;
|
|
102
|
+
/** Action logs for debugging (optional) */
|
|
103
|
+
logs?: string[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Aggregated cache metadata from multiple operations
|
|
107
|
+
*/
|
|
108
|
+
export interface CacheMetadataCollection {
|
|
109
|
+
/** Total number of queries performed */
|
|
110
|
+
totalQueries: number;
|
|
111
|
+
/** Number of cache hits */
|
|
112
|
+
cacheHits: number;
|
|
113
|
+
/** Number of cache misses */
|
|
114
|
+
cacheMisses: number;
|
|
115
|
+
/** Cache hit rate (0-1) */
|
|
116
|
+
cacheHitRate: number;
|
|
117
|
+
/** Total rows served across all queries */
|
|
118
|
+
totalRowsServed: number;
|
|
119
|
+
/** Individual metadata entries */
|
|
120
|
+
entries: CacheMetadata[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Error class for cache-related operations
|
|
124
|
+
*/
|
|
125
|
+
export declare class CacheError extends Error {
|
|
126
|
+
cause?: Error | undefined;
|
|
127
|
+
constructor(message: string, cause?: Error | undefined);
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/types/cache.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.test.d.ts","sourceRoot":"","sources":["../../../src/types/cache.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CacheMetadata, CacheMetadataCollection } from '../types/cache';
|
|
2
|
+
/**
|
|
3
|
+
* Parser for extracting cache metadata from action logs
|
|
4
|
+
* Handles the parsing of cache-related information from SQL action responses
|
|
5
|
+
*/
|
|
6
|
+
export declare class CacheMetadataParser {
|
|
7
|
+
/**
|
|
8
|
+
* Parses logs and removes prepended numeric prefixes (e.g., "1. ", "2. ")
|
|
9
|
+
* @param logsInput - The logs string or array to parse
|
|
10
|
+
* @returns Array of clean log lines
|
|
11
|
+
*/
|
|
12
|
+
static parseLogsForMetadata(logsInput: string | string[]): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Extracts cache metadata from action logs
|
|
15
|
+
* @param logs - The action logs returned from the backend (may be a single string or array)
|
|
16
|
+
* @returns Cache metadata if found, null otherwise
|
|
17
|
+
*/
|
|
18
|
+
static extractFromLogs(logs: string | string[]): CacheMetadata | null;
|
|
19
|
+
/**
|
|
20
|
+
* Validates cache metadata structure
|
|
21
|
+
* @param metadata - The cache metadata to validate
|
|
22
|
+
* @returns True if metadata is valid, false otherwise
|
|
23
|
+
*/
|
|
24
|
+
static isValidCacheMetadata(metadata: any): metadata is CacheMetadata;
|
|
25
|
+
/**
|
|
26
|
+
* Extracts cache metadata from Kwil response structure
|
|
27
|
+
* @param response - The full response from Kwil client
|
|
28
|
+
* @returns Cache metadata if found, null otherwise
|
|
29
|
+
*/
|
|
30
|
+
static extractFromResponse(response: any): CacheMetadata | null;
|
|
31
|
+
/**
|
|
32
|
+
* Aggregates multiple cache metadata entries into a collection
|
|
33
|
+
* @param metadataList - Array of cache metadata entries
|
|
34
|
+
* @returns Aggregated cache metadata collection
|
|
35
|
+
*/
|
|
36
|
+
static aggregate(metadataList: CacheMetadata[]): CacheMetadataCollection;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=cacheMetadataParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheMetadataParser.d.ts","sourceRoot":"","sources":["../../../src/util/cacheMetadataParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAExE;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE;IAsCnE;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,GAAG,IAAI;IAyCrE;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,IAAI,aAAa;IA8CrE;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,GAAG,GAAG,aAAa,GAAG,IAAI;IAc/D;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,aAAa,EAAE,GAAG,uBAAuB;CA2BzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheMetadataParser.test.d.ts","sourceRoot":"","sources":["../../../src/util/cacheMetadataParser.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GetRecordOptions, GetIndexOptions, GetIndexChangeOptions, GetFirstRecordOptions } from '../types/cache';
|
|
2
|
+
/**
|
|
3
|
+
* Validation utilities for cache-related parameters
|
|
4
|
+
*/
|
|
5
|
+
export declare class CacheValidation {
|
|
6
|
+
/**
|
|
7
|
+
* Validates GetRecordOptions parameters
|
|
8
|
+
*/
|
|
9
|
+
static validateGetRecordOptions(options: GetRecordOptions): void;
|
|
10
|
+
/**
|
|
11
|
+
* Validates GetIndexOptions parameters
|
|
12
|
+
*/
|
|
13
|
+
static validateGetIndexOptions(options: GetIndexOptions): void;
|
|
14
|
+
/**
|
|
15
|
+
* Validates GetIndexChangeOptions parameters
|
|
16
|
+
*/
|
|
17
|
+
static validateGetIndexChangeOptions(options: GetIndexChangeOptions): void;
|
|
18
|
+
/**
|
|
19
|
+
* Validates GetFirstRecordOptions parameters
|
|
20
|
+
*/
|
|
21
|
+
static validateGetFirstRecordOptions(options: GetFirstRecordOptions): void;
|
|
22
|
+
/**
|
|
23
|
+
* Validates time range parameters
|
|
24
|
+
*/
|
|
25
|
+
static validateTimeRange(from?: number, to?: number): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=cacheValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheValidation.d.ts","sourceRoot":"","sources":["../../../src/util/cacheValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEjH;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IA0BhE;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAK9D;;OAEG;IACH,MAAM,CAAC,6BAA6B,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAU1E;;OAEG;IACH,MAAM,CAAC,6BAA6B,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAc1E;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;CAK3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheValidation.test.d.ts","sourceRoot":"","sources":["../../../src/util/cacheValidation.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trufnetwork/sdk-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "TRUF.NETWORK SDK for JavaScript/TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -46,10 +46,12 @@
|
|
|
46
46
|
"prepublishOnly": "npm run build",
|
|
47
47
|
"tag:dev": "pnpm version 0.0.0-dev-$(date +%Y%m%d%H%M%S) --no-git-tag-version",
|
|
48
48
|
"publish:dev": "pnpm publish --tag dev --no-git-checks",
|
|
49
|
-
"test": "vitest"
|
|
49
|
+
"test": "vitest",
|
|
50
|
+
"test:unit": "vitest src/ --run",
|
|
51
|
+
"test:integration": "vitest tests/integration/ --run"
|
|
50
52
|
},
|
|
51
53
|
"dependencies": {
|
|
52
|
-
"@trufnetwork/kwil-js": "^0.9.
|
|
54
|
+
"@trufnetwork/kwil-js": "^0.9.6-rc.2",
|
|
53
55
|
"crypto-hash": "^3.1.0",
|
|
54
56
|
"ethers": "^6.13.5",
|
|
55
57
|
"lodash": "^4.17.21",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// src/client/client.test.ts
|
|
4
|
-
var import_vitest = require("vitest");
|
|
5
|
-
var import_ethers = require("ethers");
|
|
6
|
-
var import_nodeClient = require("./nodeClient.cjs");
|
|
7
|
-
import_vitest.describe.sequential("Client", { timeout: 3e4 }, () => {
|
|
8
|
-
import_vitest.it.skipIf(process.env.CI);
|
|
9
|
-
const wallet = new import_ethers.ethers.Wallet(
|
|
10
|
-
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
11
|
-
);
|
|
12
|
-
(0, import_vitest.it)("should create a client", async () => {
|
|
13
|
-
const chainId = await import_nodeClient.NodeTNClient.getDefaultChainId(
|
|
14
|
-
"http://localhost:8484"
|
|
15
|
-
);
|
|
16
|
-
if (!chainId) {
|
|
17
|
-
throw new Error("Chain id not found");
|
|
18
|
-
}
|
|
19
|
-
const client = new import_nodeClient.NodeTNClient({
|
|
20
|
-
endpoint: "http://localhost:8484",
|
|
21
|
-
signerInfo: {
|
|
22
|
-
address: wallet.address,
|
|
23
|
-
signer: wallet
|
|
24
|
-
},
|
|
25
|
-
chainId
|
|
26
|
-
});
|
|
27
|
-
const kwilClient = client.getKwilClient();
|
|
28
|
-
const chainInfo = await kwilClient.chainInfo();
|
|
29
|
-
(0, import_vitest.expect)(chainInfo.data?.chain_id).toBeDefined();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=client.test.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/client/client.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\nimport { ethers } from \"ethers\";\nimport { NodeTNClient } from \"./nodeClient\";\n\ndescribe.sequential(\"Client\", { timeout: 30000 }, () => {\n // Skip in CI, because it needs a local node\n it.skipIf(process.env.CI);\n\n const wallet = new ethers.Wallet(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n );\n it(\"should create a client\", async () => {\n const chainId = await NodeTNClient.getDefaultChainId(\n \"http://localhost:8484\",\n );\n if (!chainId) {\n throw new Error(\"Chain id not found\");\n }\n const client = new NodeTNClient({\n endpoint: \"http://localhost:8484\",\n signerInfo: {\n address: wallet.address,\n signer: wallet,\n },\n chainId,\n });\n const kwilClient = client.getKwilClient();\n const chainInfo = await kwilClient.chainInfo();\n expect(chainInfo.data?.chain_id).toBeDefined();\n });\n});\n"],
|
|
5
|
-
"mappings": ";;;AAAA,oBAAqC;AACrC,oBAAuB;AACvB,wBAA6B;AAE7B,uBAAS,WAAW,UAAU,EAAE,SAAS,IAAM,GAAG,MAAM;AAEtD,mBAAG,OAAO,QAAQ,IAAI,EAAE;AAExB,QAAM,SAAS,IAAI,qBAAO;AAAA,IACxB;AAAA,EACF;AACA,wBAAG,0BAA0B,YAAY;AACvC,UAAM,UAAU,MAAM,+BAAa;AAAA,MACjC;AAAA,IACF;AACA,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AACA,UAAM,SAAS,IAAI,+BAAa;AAAA,MAC9B,UAAU;AAAA,MACV,YAAY;AAAA,QACV,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa,OAAO,cAAc;AACxC,UAAM,YAAY,MAAM,WAAW,UAAU;AAC7C,8BAAO,UAAU,MAAM,QAAQ,EAAE,YAAY;AAAA,EAC/C,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// src/client/client.test.ts
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { ethers } from "ethers";
|
|
4
|
-
import { NodeTNClient } from "./nodeClient.mjs";
|
|
5
|
-
describe.sequential("Client", { timeout: 3e4 }, () => {
|
|
6
|
-
it.skipIf(process.env.CI);
|
|
7
|
-
const wallet = new ethers.Wallet(
|
|
8
|
-
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
9
|
-
);
|
|
10
|
-
it("should create a client", async () => {
|
|
11
|
-
const chainId = await NodeTNClient.getDefaultChainId(
|
|
12
|
-
"http://localhost:8484"
|
|
13
|
-
);
|
|
14
|
-
if (!chainId) {
|
|
15
|
-
throw new Error("Chain id not found");
|
|
16
|
-
}
|
|
17
|
-
const client = new NodeTNClient({
|
|
18
|
-
endpoint: "http://localhost:8484",
|
|
19
|
-
signerInfo: {
|
|
20
|
-
address: wallet.address,
|
|
21
|
-
signer: wallet
|
|
22
|
-
},
|
|
23
|
-
chainId
|
|
24
|
-
});
|
|
25
|
-
const kwilClient = client.getKwilClient();
|
|
26
|
-
const chainInfo = await kwilClient.chainInfo();
|
|
27
|
-
expect(chainInfo.data?.chain_id).toBeDefined();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=client.test.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/client/client.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\nimport { ethers } from \"ethers\";\nimport { NodeTNClient } from \"./nodeClient\";\n\ndescribe.sequential(\"Client\", { timeout: 30000 }, () => {\n // Skip in CI, because it needs a local node\n it.skipIf(process.env.CI);\n\n const wallet = new ethers.Wallet(\n \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n );\n it(\"should create a client\", async () => {\n const chainId = await NodeTNClient.getDefaultChainId(\n \"http://localhost:8484\",\n );\n if (!chainId) {\n throw new Error(\"Chain id not found\");\n }\n const client = new NodeTNClient({\n endpoint: \"http://localhost:8484\",\n signerInfo: {\n address: wallet.address,\n signer: wallet,\n },\n chainId,\n });\n const kwilClient = client.getKwilClient();\n const chainInfo = await kwilClient.chainInfo();\n expect(chainInfo.data?.chain_id).toBeDefined();\n });\n});\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAE7B,SAAS,WAAW,UAAU,EAAE,SAAS,IAAM,GAAG,MAAM;AAEtD,KAAG,OAAO,QAAQ,IAAI,EAAE;AAExB,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB;AAAA,EACF;AACA,KAAG,0BAA0B,YAAY;AACvC,UAAM,UAAU,MAAM,aAAa;AAAA,MACjC;AAAA,IACF;AACA,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AACA,UAAM,SAAS,IAAI,aAAa;AAAA,MAC9B,UAAU;AAAA,MACV,YAAY;AAAA,QACV,SAAS,OAAO;AAAA,QAChB,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa,OAAO,cAAc;AACxC,UAAM,YAAY,MAAM,WAAW,UAAU;AAC7C,WAAO,UAAU,MAAM,QAAQ,EAAE,YAAY;AAAA,EAC/C,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../../src/client/client.test.ts"],"names":[],"mappings":""}
|