@0xobelisk/sui-client 1.0.9 → 1.1.0
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/index.js +36 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -14
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiIndexerClient/index.d.ts +2 -2
- package/dist/libs/suiIndexerClient/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/libs/suiIndexerClient/index.ts +2 -2
- package/src/libs/suiIndexerClient/utils.ts +39 -13
|
@@ -18,7 +18,7 @@ export interface IndexerSchema {
|
|
|
18
18
|
name: string;
|
|
19
19
|
key1?: string;
|
|
20
20
|
key2?: string;
|
|
21
|
-
value:
|
|
21
|
+
value: any;
|
|
22
22
|
last_update_checkpoint: string;
|
|
23
23
|
last_update_digest: string;
|
|
24
24
|
is_removed: boolean;
|
|
@@ -30,7 +30,7 @@ export interface IndexerEvent {
|
|
|
30
30
|
checkpoint: string;
|
|
31
31
|
digest: string;
|
|
32
32
|
name: string;
|
|
33
|
-
value:
|
|
33
|
+
value: any;
|
|
34
34
|
created_at: string;
|
|
35
35
|
}
|
|
36
36
|
export interface ConnectionResponse<T> {
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ export interface IndexerSchema {
|
|
|
28
28
|
name: string;
|
|
29
29
|
key1?: string;
|
|
30
30
|
key2?: string;
|
|
31
|
-
value:
|
|
31
|
+
value: any;
|
|
32
32
|
last_update_checkpoint: string;
|
|
33
33
|
last_update_digest: string;
|
|
34
34
|
is_removed: boolean;
|
|
@@ -41,7 +41,7 @@ export interface IndexerEvent {
|
|
|
41
41
|
checkpoint: string;
|
|
42
42
|
digest: string;
|
|
43
43
|
name: string;
|
|
44
|
-
value:
|
|
44
|
+
value: any;
|
|
45
45
|
created_at: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -1,23 +1,49 @@
|
|
|
1
|
-
export const
|
|
2
|
-
if (typeof
|
|
3
|
-
return
|
|
1
|
+
export const parseData = (data: unknown): unknown => {
|
|
2
|
+
if (typeof data !== 'object' || data === null) {
|
|
3
|
+
return data;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
if (Array.isArray(data)) {
|
|
7
|
+
return data.map((item) => parseData(item));
|
|
8
|
+
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const parsedData: Record<string, unknown> = {};
|
|
11
|
+
for (const key in data as object) {
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
13
|
+
const value = (data as Record<string, unknown>)[key];
|
|
13
14
|
|
|
14
|
-
if ('
|
|
15
|
-
|
|
15
|
+
if (typeof value === 'object' && value !== null) {
|
|
16
|
+
if ('variant' in value) {
|
|
17
|
+
parsedData[key] = value.variant;
|
|
18
|
+
} else if ('fields' in value) {
|
|
19
|
+
parsedData[key] = parseData(value.fields);
|
|
20
|
+
} else {
|
|
21
|
+
parsedData[key] = parseData(value);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
parsedData[key] = value;
|
|
16
25
|
}
|
|
17
26
|
}
|
|
27
|
+
}
|
|
28
|
+
return parsedData;
|
|
29
|
+
};
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
export const parseValue = (value: unknown): unknown => {
|
|
32
|
+
if (typeof value !== 'object' || value === null) {
|
|
21
33
|
return value;
|
|
22
34
|
}
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.map((item) => parseValue(item));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if ('variant' in value) {
|
|
41
|
+
return value.variant;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ('fields' in value) {
|
|
45
|
+
return parseData(value.fields);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return parseData(value);
|
|
23
49
|
};
|