@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/README.md
CHANGED
|
@@ -45,17 +45,17 @@ There are two ways to initialize the Dubhe client:
|
|
|
45
45
|
1. Using dynamic metadata loading:
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
|
-
import { loadMetadata, Dubhe, NetworkType } from
|
|
48
|
+
import { loadMetadata, Dubhe, NetworkType } from '@0xobelisk/sui-client';
|
|
49
49
|
|
|
50
|
-
const network =
|
|
51
|
-
const packageId =
|
|
50
|
+
const network = 'devnet' as NetworkType;
|
|
51
|
+
const packageId = 'YOUR_PACKAGE_ID';
|
|
52
52
|
|
|
53
53
|
const metadata = await loadMetadata(network, packageId);
|
|
54
54
|
const dubhe = new Dubhe({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
networkType: network,
|
|
56
|
+
packageId: packageId,
|
|
57
|
+
metadata: metadata,
|
|
58
|
+
secretKey: privkey,
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -65,10 +65,10 @@ const dubhe = new Dubhe({
|
|
|
65
65
|
import metadata from './metadata.json';
|
|
66
66
|
|
|
67
67
|
const dubhe = new Dubhe({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
networkType: network,
|
|
69
|
+
packageId: packageId,
|
|
70
|
+
metadata: metadata,
|
|
71
|
+
secretKey: privkey,
|
|
72
72
|
});
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -77,11 +77,13 @@ const dubhe = new Dubhe({
|
|
|
77
77
|
To call contract methods:
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
|
-
import { Transaction } from
|
|
80
|
+
import { Transaction } from '@0xobelisk/sui-client';
|
|
81
81
|
|
|
82
82
|
// Create transaction
|
|
83
83
|
const tx = new Transaction();
|
|
84
|
-
const params = [
|
|
84
|
+
const params = [
|
|
85
|
+
/* your parameters */
|
|
86
|
+
];
|
|
85
87
|
|
|
86
88
|
// Execute transaction
|
|
87
89
|
const response = await dubhe.tx.counter_system.inc(tx, params);
|
|
@@ -97,7 +99,9 @@ To query contract state:
|
|
|
97
99
|
|
|
98
100
|
```typescript
|
|
99
101
|
const tx = new Transaction();
|
|
100
|
-
const params = [
|
|
102
|
+
const params = [
|
|
103
|
+
/* your parameters */
|
|
104
|
+
];
|
|
101
105
|
const result = await dubhe.query.counter_system.get(tx, params);
|
|
102
106
|
|
|
103
107
|
// For BCS encoded results
|
|
@@ -162,7 +166,8 @@ const numberKey = await dubhe.entity_key_from_u256(123);
|
|
|
162
166
|
To query objects owned by a specific address:
|
|
163
167
|
|
|
164
168
|
```typescript
|
|
165
|
-
const owner =
|
|
169
|
+
const owner =
|
|
170
|
+
'0xfa99b5b0463fcfb7d0203c701a76da5eda21a96190eb1368ab36a437cc89195e';
|
|
166
171
|
const ownedObjects = await dubhe.getOwnedObjects(owner);
|
|
167
172
|
```
|
|
168
173
|
|
package/dist/dubhe.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { MapObjectStruct } from './types';
|
|
|
7
7
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
8
8
|
import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
|
|
9
9
|
import { NetworkConfig } from './libs/suiInteractor';
|
|
10
|
-
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg } from './types';
|
|
10
|
+
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg, SubscribableType } from './types';
|
|
11
11
|
import { ConnectionResponse, IndexerTransaction, IndexerEvent, IndexerSchema, SuiIndexerClient, StorageResponse, StorageItemResponse } from './libs/suiIndexerClient';
|
|
12
12
|
import { Http } from './libs/http';
|
|
13
13
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
@@ -55,15 +55,20 @@ export declare class Dubhe {
|
|
|
55
55
|
storageType: string;
|
|
56
56
|
params: any[];
|
|
57
57
|
}): Promise<any[] | undefined>;
|
|
58
|
-
getTransactions({ first, after, orderBy, }: {
|
|
58
|
+
getTransactions({ first, after, sender, digest, checkpoint, orderBy, }: {
|
|
59
59
|
first?: number;
|
|
60
60
|
after?: string;
|
|
61
|
+
sender?: string;
|
|
62
|
+
digest?: string;
|
|
63
|
+
checkpoint?: number;
|
|
61
64
|
orderBy?: string[];
|
|
62
65
|
}): Promise<ConnectionResponse<IndexerTransaction>>;
|
|
63
|
-
getEvents({ first, after, name, checkpoint, orderBy, }: {
|
|
66
|
+
getEvents({ first, after, name, sender, digest, checkpoint, orderBy, }: {
|
|
64
67
|
first?: number;
|
|
65
68
|
after?: string;
|
|
66
69
|
name?: string;
|
|
70
|
+
sender?: string;
|
|
71
|
+
digest?: string;
|
|
67
72
|
checkpoint?: string;
|
|
68
73
|
orderBy?: string[];
|
|
69
74
|
}): Promise<ConnectionResponse<IndexerEvent>>;
|
|
@@ -100,7 +105,7 @@ export declare class Dubhe {
|
|
|
100
105
|
last_update_digest?: string;
|
|
101
106
|
value?: any;
|
|
102
107
|
}): Promise<StorageItemResponse<IndexerSchema> | undefined>;
|
|
103
|
-
subscribe(
|
|
108
|
+
subscribe(types: SubscribableType[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
104
109
|
/**
|
|
105
110
|
* else:
|
|
106
111
|
* it will generate signer from the mnemonic with the given derivePathParams.
|
package/dist/index.d.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/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
BcsType: () => import_bcs4.BcsType,
|
|
52
52
|
Dubhe: () => Dubhe,
|
|
53
53
|
MultiSigClient: () => MultiSigClient,
|
|
54
|
+
SubscriptionKind: () => SubscriptionKind,
|
|
54
55
|
SuiAccountManager: () => SuiAccountManager,
|
|
55
56
|
SuiContractFactory: () => SuiContractFactory,
|
|
56
57
|
SuiTx: () => SuiTx,
|
|
@@ -1115,6 +1116,11 @@ var parseValue = (value) => {
|
|
|
1115
1116
|
};
|
|
1116
1117
|
|
|
1117
1118
|
// src/libs/suiIndexerClient/index.ts
|
|
1119
|
+
var SubscriptionKind = /* @__PURE__ */ ((SubscriptionKind2) => {
|
|
1120
|
+
SubscriptionKind2["Event"] = "event";
|
|
1121
|
+
SubscriptionKind2["Schema"] = "schema";
|
|
1122
|
+
return SubscriptionKind2;
|
|
1123
|
+
})(SubscriptionKind || {});
|
|
1118
1124
|
var SuiIndexerClient = class {
|
|
1119
1125
|
constructor(http) {
|
|
1120
1126
|
this.http = http;
|
|
@@ -1124,14 +1130,15 @@ var SuiIndexerClient = class {
|
|
|
1124
1130
|
}
|
|
1125
1131
|
async getTransactions(params) {
|
|
1126
1132
|
const query = `
|
|
1127
|
-
query GetTransactions($first: Int, $after: String, $checkpoint: Int, $orderBy: [TransactionOrderField!]) {
|
|
1128
|
-
transactions(first: $first, after: $after, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
1133
|
+
query GetTransactions($first: Int, $after: String, $sender: String, $digest: String, $checkpoint: Int, $orderBy: [TransactionOrderField!]) {
|
|
1134
|
+
transactions(first: $first, after: $after, sender: $sender, digest: $digest, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
1129
1135
|
edges {
|
|
1130
1136
|
cursor
|
|
1131
1137
|
node {
|
|
1132
1138
|
id
|
|
1133
1139
|
checkpoint
|
|
1134
1140
|
digest
|
|
1141
|
+
sender
|
|
1135
1142
|
created_at
|
|
1136
1143
|
}
|
|
1137
1144
|
}
|
|
@@ -1200,8 +1207,8 @@ var SuiIndexerClient = class {
|
|
|
1200
1207
|
}
|
|
1201
1208
|
async getEvents(params) {
|
|
1202
1209
|
const query = `
|
|
1203
|
-
query GetEvents($first: Int, $after: String, $name: String, $checkpoint: String, $orderBy: [EventOrderField!]) {
|
|
1204
|
-
events(first: $first, after: $after, name: $name, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
1210
|
+
query GetEvents($first: Int, $after: String, $name: String, $sender: String, $digest: String, $checkpoint: String, $orderBy: [EventOrderField!]) {
|
|
1211
|
+
events(first: $first, after: $after, name: $name, sender: $sender, digest: $digest, checkpoint: $checkpoint, orderBy: $orderBy) {
|
|
1205
1212
|
edges {
|
|
1206
1213
|
cursor
|
|
1207
1214
|
node {
|
|
@@ -1209,6 +1216,7 @@ var SuiIndexerClient = class {
|
|
|
1209
1216
|
checkpoint
|
|
1210
1217
|
digest
|
|
1211
1218
|
name
|
|
1219
|
+
sender
|
|
1212
1220
|
value
|
|
1213
1221
|
created_at
|
|
1214
1222
|
}
|
|
@@ -1286,8 +1294,8 @@ var SuiIndexerClient = class {
|
|
|
1286
1294
|
value: result
|
|
1287
1295
|
};
|
|
1288
1296
|
}
|
|
1289
|
-
async subscribe(
|
|
1290
|
-
return this.http.subscribe(
|
|
1297
|
+
async subscribe(types, handleData) {
|
|
1298
|
+
return this.http.subscribe(types, handleData);
|
|
1291
1299
|
}
|
|
1292
1300
|
};
|
|
1293
1301
|
|
|
@@ -1425,14 +1433,11 @@ var Http = class {
|
|
|
1425
1433
|
);
|
|
1426
1434
|
}
|
|
1427
1435
|
}
|
|
1428
|
-
async subscribe(
|
|
1436
|
+
async subscribe(types, handleData) {
|
|
1429
1437
|
const ws = createWebSocketClient(this.wsEndpoint);
|
|
1430
1438
|
ws.onopen = () => {
|
|
1431
1439
|
console.log("Connected to the WebSocket server");
|
|
1432
|
-
const subscribeMessage = JSON.stringify(
|
|
1433
|
-
type: "subscribe",
|
|
1434
|
-
names
|
|
1435
|
-
});
|
|
1440
|
+
const subscribeMessage = JSON.stringify(types);
|
|
1436
1441
|
ws.send(subscribeMessage);
|
|
1437
1442
|
};
|
|
1438
1443
|
ws.onmessage = (event) => {
|
|
@@ -2280,11 +2285,17 @@ var Dubhe = class {
|
|
|
2280
2285
|
async getTransactions({
|
|
2281
2286
|
first,
|
|
2282
2287
|
after,
|
|
2288
|
+
sender,
|
|
2289
|
+
digest,
|
|
2290
|
+
checkpoint,
|
|
2283
2291
|
orderBy
|
|
2284
2292
|
}) {
|
|
2285
2293
|
return await this.suiIndexerClient.getTransactions({
|
|
2286
2294
|
first,
|
|
2287
2295
|
after,
|
|
2296
|
+
sender,
|
|
2297
|
+
digest,
|
|
2298
|
+
checkpoint,
|
|
2288
2299
|
orderBy
|
|
2289
2300
|
});
|
|
2290
2301
|
}
|
|
@@ -2292,6 +2303,8 @@ var Dubhe = class {
|
|
|
2292
2303
|
first,
|
|
2293
2304
|
after,
|
|
2294
2305
|
name,
|
|
2306
|
+
sender,
|
|
2307
|
+
digest,
|
|
2295
2308
|
checkpoint,
|
|
2296
2309
|
orderBy
|
|
2297
2310
|
}) {
|
|
@@ -2299,6 +2312,8 @@ var Dubhe = class {
|
|
|
2299
2312
|
first,
|
|
2300
2313
|
after,
|
|
2301
2314
|
name,
|
|
2315
|
+
sender,
|
|
2316
|
+
digest,
|
|
2302
2317
|
checkpoint,
|
|
2303
2318
|
orderBy
|
|
2304
2319
|
});
|
|
@@ -2373,8 +2388,8 @@ var Dubhe = class {
|
|
|
2373
2388
|
});
|
|
2374
2389
|
return response;
|
|
2375
2390
|
}
|
|
2376
|
-
async subscribe(
|
|
2377
|
-
return this.suiIndexerClient.subscribe(
|
|
2391
|
+
async subscribe(types, handleData) {
|
|
2392
|
+
return this.suiIndexerClient.subscribe(types, handleData);
|
|
2378
2393
|
}
|
|
2379
2394
|
/**
|
|
2380
2395
|
* else:
|
|
@@ -2773,9 +2788,7 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
|
2773
2788
|
fullnodeUrls = fullnodeUrls || [(0, import_client3.getFullnodeUrl)(networkType)];
|
|
2774
2789
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
2775
2790
|
if (packageId !== void 0) {
|
|
2776
|
-
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(
|
|
2777
|
-
packageId
|
|
2778
|
-
);
|
|
2791
|
+
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(packageId);
|
|
2779
2792
|
return jsonData;
|
|
2780
2793
|
} else {
|
|
2781
2794
|
console.error("please set your package id.");
|
|
@@ -2786,6 +2799,7 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
|
2786
2799
|
BcsType,
|
|
2787
2800
|
Dubhe,
|
|
2788
2801
|
MultiSigClient,
|
|
2802
|
+
SubscriptionKind,
|
|
2789
2803
|
SuiAccountManager,
|
|
2790
2804
|
SuiContractFactory,
|
|
2791
2805
|
SuiTx,
|