@0xobelisk/sui-client 1.1.6 → 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 +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -12
- package/dist/index.mjs.map +1 -1
- package/dist/libs/http/http.d.ts +2 -1
- package/dist/libs/suiIndexerClient/index.d.ts +6 -1
- package/dist/types/index.d.ts +9 -0
- package/package.json +9 -8
- package/src/dubhe.ts +3 -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 +8 -2
- 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;
|
|
@@ -107,5 +112,5 @@ export declare class SuiIndexerClient {
|
|
|
107
112
|
last_update_digest?: string;
|
|
108
113
|
value?: any;
|
|
109
114
|
}): Promise<StorageItemResponse<IndexerSchema> | undefined>;
|
|
110
|
-
subscribe(
|
|
115
|
+
subscribe(types: SubscribableType[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
111
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,
|
|
@@ -1274,10 +1275,10 @@ export class Dubhe {
|
|
|
1274
1275
|
}
|
|
1275
1276
|
|
|
1276
1277
|
async subscribe(
|
|
1277
|
-
|
|
1278
|
+
types: SubscribableType[],
|
|
1278
1279
|
handleData: (data: any) => void
|
|
1279
1280
|
): Promise<WebSocket> {
|
|
1280
|
-
return this.suiIndexerClient.subscribe(
|
|
1281
|
+
return this.suiIndexerClient.subscribe(types, handleData);
|
|
1281
1282
|
}
|
|
1282
1283
|
|
|
1283
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'];
|
|
@@ -305,9 +311,9 @@ export class SuiIndexerClient {
|
|
|
305
311
|
}
|
|
306
312
|
|
|
307
313
|
async subscribe(
|
|
308
|
-
|
|
314
|
+
types: SubscribableType[],
|
|
309
315
|
handleData: (data: any) => void
|
|
310
316
|
): Promise<WebSocket> {
|
|
311
|
-
return this.http.subscribe(
|
|
317
|
+
return this.http.subscribe(types, handleData);
|
|
312
318
|
}
|
|
313
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 };
|