@0xobelisk/sui-client 1.1.5 → 1.1.7
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/README.md +20 -15
- package/dist/dubhe.d.ts +9 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -16
- package/dist/index.mjs.map +1 -1
- package/dist/libs/http/http.d.ts +2 -1
- package/dist/libs/suiIndexerClient/index.d.ts +12 -1
- package/dist/types/index.d.ts +9 -0
- package/package.json +9 -8
- package/src/dubhe.ts +18 -2
- package/src/index.ts +1 -0
- package/src/libs/http/errors.ts +5 -1
- package/src/libs/http/http.ts +3 -5
- package/src/libs/suiIndexerClient/index.ts +21 -7
- package/src/metadata/index.ts +2 -3
- package/src/types/index.ts +5 -0
package/dist/libs/http/http.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WebSocketInstance } from './ws-adapter';
|
|
2
|
+
import { SubscribableType } from '../../types';
|
|
2
3
|
export type FetchOptions = RequestInit & {
|
|
3
4
|
next?: {
|
|
4
5
|
revalidate?: boolean | number;
|
|
@@ -17,5 +18,5 @@ export declare class Http {
|
|
|
17
18
|
query: string;
|
|
18
19
|
variables?: any;
|
|
19
20
|
}): Promise<T>;
|
|
20
|
-
subscribe(
|
|
21
|
+
subscribe(types: SubscribableType[], handleData: (data: any) => void): Promise<WebSocketInstance>;
|
|
21
22
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Http } from '../http';
|
|
2
|
+
import { SubscribableType } from '../../types';
|
|
2
3
|
export interface OrderDirection {
|
|
3
4
|
ASC: 'ASC';
|
|
4
5
|
DESC: 'DESC';
|
|
5
6
|
}
|
|
7
|
+
export declare enum SubscriptionKind {
|
|
8
|
+
Event = "event",
|
|
9
|
+
Schema = "schema"
|
|
10
|
+
}
|
|
6
11
|
export interface PageInfo {
|
|
7
12
|
hasNextPage: boolean;
|
|
8
13
|
endCursor?: string;
|
|
@@ -11,6 +16,7 @@ export interface IndexerTransaction {
|
|
|
11
16
|
id: number;
|
|
12
17
|
checkpoint: number;
|
|
13
18
|
digest: string;
|
|
19
|
+
sender: string;
|
|
14
20
|
created_at: string;
|
|
15
21
|
}
|
|
16
22
|
export interface IndexerSchema {
|
|
@@ -30,6 +36,7 @@ export interface IndexerEvent {
|
|
|
30
36
|
checkpoint: string;
|
|
31
37
|
digest: string;
|
|
32
38
|
name: string;
|
|
39
|
+
sender: string;
|
|
33
40
|
value: any;
|
|
34
41
|
created_at: string;
|
|
35
42
|
}
|
|
@@ -58,6 +65,8 @@ export declare class SuiIndexerClient {
|
|
|
58
65
|
getTransactions(params?: {
|
|
59
66
|
first?: number;
|
|
60
67
|
after?: string;
|
|
68
|
+
sender?: string;
|
|
69
|
+
digest?: string;
|
|
61
70
|
checkpoint?: number;
|
|
62
71
|
orderBy?: string[];
|
|
63
72
|
}): Promise<ConnectionResponse<IndexerTransaction>>;
|
|
@@ -77,6 +86,8 @@ export declare class SuiIndexerClient {
|
|
|
77
86
|
first?: number;
|
|
78
87
|
after?: string;
|
|
79
88
|
name?: string;
|
|
89
|
+
sender?: string;
|
|
90
|
+
digest?: string;
|
|
80
91
|
checkpoint?: string;
|
|
81
92
|
orderBy?: string[];
|
|
82
93
|
}): Promise<ConnectionResponse<IndexerEvent>>;
|
|
@@ -101,5 +112,5 @@ export declare class SuiIndexerClient {
|
|
|
101
112
|
last_update_digest?: string;
|
|
102
113
|
value?: any;
|
|
103
114
|
}): Promise<StorageItemResponse<IndexerSchema> | undefined>;
|
|
104
|
-
subscribe(
|
|
115
|
+
subscribe(types: SubscribableType[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
105
116
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { SuiMoveNormalizedModules, DevInspectResults, SuiTransactionBlockRe
|
|
|
6
6
|
import { SuiTx } from '../libs/suiTxBuilder';
|
|
7
7
|
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
8
8
|
import { FetchOptions } from '../libs/http';
|
|
9
|
+
import { SubscriptionKind } from '../libs/suiIndexerClient';
|
|
9
10
|
export declare const ObjectContentFields: import("superstruct").Struct<Record<string, any>, null>;
|
|
10
11
|
export type ObjectContentFields = Infer<typeof ObjectContentFields>;
|
|
11
12
|
export type DubheObjectData = {
|
|
@@ -206,4 +207,12 @@ export type ObjectContent = {
|
|
|
206
207
|
dataType: string;
|
|
207
208
|
};
|
|
208
209
|
export type SuiDubheReturnType<T extends boolean> = T extends true ? SuiTransactionBlockResponse : SuiTx;
|
|
210
|
+
export type SubscribableType = {
|
|
211
|
+
kind: SubscriptionKind.Event;
|
|
212
|
+
name?: string;
|
|
213
|
+
sender?: string;
|
|
214
|
+
} | {
|
|
215
|
+
kind: SubscriptionKind.Schema;
|
|
216
|
+
name?: string;
|
|
217
|
+
};
|
|
209
218
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/sui-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Tookit for interacting with move eps framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -70,19 +70,19 @@
|
|
|
70
70
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
71
71
|
"@typescript-eslint/parser": "^6.8.0",
|
|
72
72
|
"dotenv": "^16.3.1",
|
|
73
|
-
"eslint": "^8.52.0",
|
|
74
|
-
"eslint-config-prettier": "^8.8.0",
|
|
75
73
|
"eslint-plugin-prettier": "^5.0.1",
|
|
76
74
|
"graphql-ws": "^6.0.2",
|
|
77
75
|
"jest": "^29.7.0",
|
|
78
76
|
"lint-staged": "^15.0.2",
|
|
79
|
-
"prettier": "^2.8.8",
|
|
80
77
|
"ts-node": "^10.9.1",
|
|
81
78
|
"tsconfig-paths": "^4.2.0",
|
|
82
79
|
"tsup": "^7.1.0",
|
|
83
80
|
"typedoc": "^0.25.2",
|
|
84
81
|
"typescript": "^5.2.2",
|
|
85
|
-
"@types/ws": "^8.5.14"
|
|
82
|
+
"@types/ws": "^8.5.14",
|
|
83
|
+
"eslint": "^8.56.0",
|
|
84
|
+
"eslint-config-prettier": "^9.1.0",
|
|
85
|
+
"prettier": "3.3.3"
|
|
86
86
|
},
|
|
87
87
|
"lint-staged": {
|
|
88
88
|
"**/*.ts": [
|
|
@@ -154,8 +154,9 @@
|
|
|
154
154
|
"lint:fix": "eslint . --ignore-pattern dist --ext .ts --fix",
|
|
155
155
|
"commit": "commit",
|
|
156
156
|
"doc": "typedoc --out docs src/index.ts",
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
157
|
+
"format": "prettier --write .",
|
|
158
|
+
"format:check": "prettier --check .",
|
|
159
|
+
"type-check": "tsc --noEmit",
|
|
160
|
+
"validate": "pnpm format:check && pnpm type-check"
|
|
160
161
|
}
|
|
161
162
|
}
|
package/src/dubhe.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
SuiTxArg,
|
|
29
29
|
SuiObjectArg,
|
|
30
30
|
SuiVecTxArg,
|
|
31
|
+
SubscribableType,
|
|
31
32
|
} from './types';
|
|
32
33
|
import {
|
|
33
34
|
convertHttpToWebSocket,
|
|
@@ -1120,15 +1121,24 @@ export class Dubhe {
|
|
|
1120
1121
|
async getTransactions({
|
|
1121
1122
|
first,
|
|
1122
1123
|
after,
|
|
1124
|
+
sender,
|
|
1125
|
+
digest,
|
|
1126
|
+
checkpoint,
|
|
1123
1127
|
orderBy,
|
|
1124
1128
|
}: {
|
|
1125
1129
|
first?: number;
|
|
1126
1130
|
after?: string;
|
|
1131
|
+
sender?: string;
|
|
1132
|
+
digest?: string;
|
|
1133
|
+
checkpoint?: number;
|
|
1127
1134
|
orderBy?: string[];
|
|
1128
1135
|
}): Promise<ConnectionResponse<IndexerTransaction>> {
|
|
1129
1136
|
return await this.suiIndexerClient.getTransactions({
|
|
1130
1137
|
first,
|
|
1131
1138
|
after,
|
|
1139
|
+
sender,
|
|
1140
|
+
digest,
|
|
1141
|
+
checkpoint,
|
|
1132
1142
|
orderBy,
|
|
1133
1143
|
});
|
|
1134
1144
|
}
|
|
@@ -1137,12 +1147,16 @@ export class Dubhe {
|
|
|
1137
1147
|
first,
|
|
1138
1148
|
after,
|
|
1139
1149
|
name,
|
|
1150
|
+
sender,
|
|
1151
|
+
digest,
|
|
1140
1152
|
checkpoint,
|
|
1141
1153
|
orderBy,
|
|
1142
1154
|
}: {
|
|
1143
1155
|
first?: number;
|
|
1144
1156
|
after?: string;
|
|
1145
1157
|
name?: string;
|
|
1158
|
+
sender?: string;
|
|
1159
|
+
digest?: string;
|
|
1146
1160
|
checkpoint?: string;
|
|
1147
1161
|
orderBy?: string[];
|
|
1148
1162
|
}): Promise<ConnectionResponse<IndexerEvent>> {
|
|
@@ -1150,6 +1164,8 @@ export class Dubhe {
|
|
|
1150
1164
|
first,
|
|
1151
1165
|
after,
|
|
1152
1166
|
name,
|
|
1167
|
+
sender,
|
|
1168
|
+
digest,
|
|
1153
1169
|
checkpoint,
|
|
1154
1170
|
orderBy,
|
|
1155
1171
|
});
|
|
@@ -1259,10 +1275,10 @@ export class Dubhe {
|
|
|
1259
1275
|
}
|
|
1260
1276
|
|
|
1261
1277
|
async subscribe(
|
|
1262
|
-
|
|
1278
|
+
types: SubscribableType[],
|
|
1263
1279
|
handleData: (data: any) => void
|
|
1264
1280
|
): Promise<WebSocket> {
|
|
1265
|
-
return this.suiIndexerClient.subscribe(
|
|
1281
|
+
return this.suiIndexerClient.subscribe(types, handleData);
|
|
1266
1282
|
}
|
|
1267
1283
|
|
|
1268
1284
|
#processKeyParameter(tx: Transaction, keyType: string, value: any) {
|
package/src/index.ts
CHANGED
|
@@ -11,5 +11,6 @@ export { SuiAccountManager } from './libs/suiAccountManager';
|
|
|
11
11
|
export { SuiTx } from './libs/suiTxBuilder';
|
|
12
12
|
export { MultiSigClient } from './libs/multiSig';
|
|
13
13
|
export { SuiContractFactory } from './libs/suiContractFactory';
|
|
14
|
+
export { SubscriptionKind } from './libs/suiIndexerClient';
|
|
14
15
|
export { loadMetadata } from './metadata';
|
|
15
16
|
export type * from './types';
|
package/src/libs/http/errors.ts
CHANGED
package/src/libs/http/http.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseError, HttpError, GraphQLError, ParseError } from './errors';
|
|
2
2
|
import { createWebSocketClient, WebSocketInstance } from './ws-adapter';
|
|
3
|
+
import { SubscribableType } from '../../types';
|
|
3
4
|
|
|
4
5
|
export type FetchOptions = RequestInit & {
|
|
5
6
|
next?: {
|
|
@@ -122,17 +123,14 @@ export class Http {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
async subscribe(
|
|
125
|
-
|
|
126
|
+
types: SubscribableType[],
|
|
126
127
|
handleData: (data: any) => void
|
|
127
128
|
): Promise<WebSocketInstance> {
|
|
128
129
|
const ws = createWebSocketClient(this.wsEndpoint);
|
|
129
130
|
|
|
130
131
|
ws.onopen = () => {
|
|
131
132
|
console.log('Connected to the WebSocket server');
|
|
132
|
-
const subscribeMessage = JSON.stringify(
|
|
133
|
-
type: 'subscribe',
|
|
134
|
-
names: names,
|
|
135
|
-
});
|
|
133
|
+
const subscribeMessage = JSON.stringify(types);
|
|
136
134
|
ws.send(subscribeMessage);
|
|
137
135
|
};
|
|
138
136
|
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Http } from '../http';
|
|
2
2
|
import { parseValue } from './utils';
|
|
3
|
+
import { SubscribableType } from '../../types';
|
|
3
4
|
|
|
4
5
|
export interface OrderDirection {
|
|
5
6
|
ASC: 'ASC';
|
|
6
7
|
DESC: 'DESC';
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
export enum SubscriptionKind {
|
|
11
|
+
Event = 'event',
|
|
12
|
+
Schema = 'schema',
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
// export interface OrderBy {
|
|
10
16
|
// field: string;
|
|
11
17
|
// direction: OrderDirection['ASC'] | OrderDirection['DESC'];
|
|
@@ -20,6 +26,7 @@ export interface IndexerTransaction {
|
|
|
20
26
|
id: number;
|
|
21
27
|
checkpoint: number;
|
|
22
28
|
digest: string;
|
|
29
|
+
sender: string;
|
|
23
30
|
created_at: string;
|
|
24
31
|
}
|
|
25
32
|
|
|
@@ -41,6 +48,7 @@ export interface IndexerEvent {
|
|
|
41
48
|
checkpoint: string;
|
|
42
49
|
digest: string;
|
|
43
50
|
name: string;
|
|
51
|
+
sender: string;
|
|
44
52
|
value: any;
|
|
45
53
|
created_at: string;
|
|
46
54
|
}
|
|
@@ -80,18 +88,21 @@ export class SuiIndexerClient {
|
|
|
80
88
|
async getTransactions(params?: {
|
|
81
89
|
first?: number;
|
|
82
90
|
after?: string;
|
|
91
|
+
sender?: string;
|
|
92
|
+
digest?: string;
|
|
83
93
|
checkpoint?: number;
|
|
84
94
|
orderBy?: string[];
|
|
85
|
-
}) {
|
|
95
|
+
}): Promise<ConnectionResponse<IndexerTransaction>> {
|
|
86
96
|
const query = `
|
|
87
|
-
query GetTransactions($first: Int, $after: String, $checkpoint: Int, $orderBy: [TransactionOrderField!]) {
|
|
88
|
-
transactions(first: $first, after: $after, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
97
|
+
query GetTransactions($first: Int, $after: String, $sender: String, $digest: String, $checkpoint: Int, $orderBy: [TransactionOrderField!]) {
|
|
98
|
+
transactions(first: $first, after: $after, sender: $sender, digest: $digest, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
89
99
|
edges {
|
|
90
100
|
cursor
|
|
91
101
|
node {
|
|
92
102
|
id
|
|
93
103
|
checkpoint
|
|
94
104
|
digest
|
|
105
|
+
sender
|
|
95
106
|
created_at
|
|
96
107
|
}
|
|
97
108
|
}
|
|
@@ -181,12 +192,14 @@ export class SuiIndexerClient {
|
|
|
181
192
|
first?: number;
|
|
182
193
|
after?: string;
|
|
183
194
|
name?: string;
|
|
195
|
+
sender?: string;
|
|
196
|
+
digest?: string;
|
|
184
197
|
checkpoint?: string;
|
|
185
198
|
orderBy?: string[];
|
|
186
199
|
}): Promise<ConnectionResponse<IndexerEvent>> {
|
|
187
200
|
const query = `
|
|
188
|
-
query GetEvents($first: Int, $after: String, $name: String, $checkpoint: String, $orderBy: [EventOrderField!]) {
|
|
189
|
-
events(first: $first, after: $after, name: $name, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
201
|
+
query GetEvents($first: Int, $after: String, $name: String, $sender: String, $digest: String, $checkpoint: String, $orderBy: [EventOrderField!]) {
|
|
202
|
+
events(first: $first, after: $after, name: $name, sender: $sender, digest: $digest, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
190
203
|
edges {
|
|
191
204
|
cursor
|
|
192
205
|
node {
|
|
@@ -194,6 +207,7 @@ export class SuiIndexerClient {
|
|
|
194
207
|
checkpoint
|
|
195
208
|
digest
|
|
196
209
|
name
|
|
210
|
+
sender
|
|
197
211
|
value
|
|
198
212
|
created_at
|
|
199
213
|
}
|
|
@@ -297,9 +311,9 @@ export class SuiIndexerClient {
|
|
|
297
311
|
}
|
|
298
312
|
|
|
299
313
|
async subscribe(
|
|
300
|
-
|
|
314
|
+
types: SubscribableType[],
|
|
301
315
|
handleData: (data: any) => void
|
|
302
316
|
): Promise<WebSocket> {
|
|
303
|
-
return this.http.subscribe(
|
|
317
|
+
return this.http.subscribe(types, handleData);
|
|
304
318
|
}
|
|
305
319
|
}
|
package/src/metadata/index.ts
CHANGED
|
@@ -13,9 +13,8 @@ export async function loadMetadata(
|
|
|
13
13
|
fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType)];
|
|
14
14
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
15
15
|
if (packageId !== undefined) {
|
|
16
|
-
const jsonData =
|
|
17
|
-
packageId
|
|
18
|
-
);
|
|
16
|
+
const jsonData =
|
|
17
|
+
await suiInteractor.getNormalizedMoveModulesByPackage(packageId);
|
|
19
18
|
|
|
20
19
|
return jsonData as SuiMoveNormalizedModules;
|
|
21
20
|
} else {
|
package/src/types/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { SuiTx } from '../libs/suiTxBuilder';
|
|
|
24
24
|
|
|
25
25
|
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
26
26
|
import { FetchOptions } from '../libs/http';
|
|
27
|
+
import { SubscriptionKind } from '../libs/suiIndexerClient';
|
|
27
28
|
|
|
28
29
|
export const ObjectContentFields = record(string(), any());
|
|
29
30
|
export type ObjectContentFields = Infer<typeof ObjectContentFields>;
|
|
@@ -306,3 +307,7 @@ export type ObjectContent = {
|
|
|
306
307
|
export type SuiDubheReturnType<T extends boolean> = T extends true
|
|
307
308
|
? SuiTransactionBlockResponse
|
|
308
309
|
: SuiTx;
|
|
310
|
+
|
|
311
|
+
export type SubscribableType =
|
|
312
|
+
| { kind: SubscriptionKind.Event; name?: string; sender?: string }
|
|
313
|
+
| { kind: SubscriptionKind.Schema; name?: string };
|