@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/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;
|
|
@@ -105,7 +105,7 @@ export declare class Dubhe {
|
|
|
105
105
|
last_update_digest?: string;
|
|
106
106
|
value?: any;
|
|
107
107
|
}): Promise<StorageItemResponse<IndexerSchema> | undefined>;
|
|
108
|
-
subscribe(
|
|
108
|
+
subscribe(types: SubscribableType[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
109
109
|
/**
|
|
110
110
|
* else:
|
|
111
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;
|
|
@@ -1288,8 +1294,8 @@ var SuiIndexerClient = class {
|
|
|
1288
1294
|
value: result
|
|
1289
1295
|
};
|
|
1290
1296
|
}
|
|
1291
|
-
async subscribe(
|
|
1292
|
-
return this.http.subscribe(
|
|
1297
|
+
async subscribe(types, handleData) {
|
|
1298
|
+
return this.http.subscribe(types, handleData);
|
|
1293
1299
|
}
|
|
1294
1300
|
};
|
|
1295
1301
|
|
|
@@ -1427,14 +1433,11 @@ var Http = class {
|
|
|
1427
1433
|
);
|
|
1428
1434
|
}
|
|
1429
1435
|
}
|
|
1430
|
-
async subscribe(
|
|
1436
|
+
async subscribe(types, handleData) {
|
|
1431
1437
|
const ws = createWebSocketClient(this.wsEndpoint);
|
|
1432
1438
|
ws.onopen = () => {
|
|
1433
1439
|
console.log("Connected to the WebSocket server");
|
|
1434
|
-
const subscribeMessage = JSON.stringify(
|
|
1435
|
-
type: "subscribe",
|
|
1436
|
-
names
|
|
1437
|
-
});
|
|
1440
|
+
const subscribeMessage = JSON.stringify(types);
|
|
1438
1441
|
ws.send(subscribeMessage);
|
|
1439
1442
|
};
|
|
1440
1443
|
ws.onmessage = (event) => {
|
|
@@ -2385,8 +2388,8 @@ var Dubhe = class {
|
|
|
2385
2388
|
});
|
|
2386
2389
|
return response;
|
|
2387
2390
|
}
|
|
2388
|
-
async subscribe(
|
|
2389
|
-
return this.suiIndexerClient.subscribe(
|
|
2391
|
+
async subscribe(types, handleData) {
|
|
2392
|
+
return this.suiIndexerClient.subscribe(types, handleData);
|
|
2390
2393
|
}
|
|
2391
2394
|
/**
|
|
2392
2395
|
* else:
|
|
@@ -2785,9 +2788,7 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
|
2785
2788
|
fullnodeUrls = fullnodeUrls || [(0, import_client3.getFullnodeUrl)(networkType)];
|
|
2786
2789
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
2787
2790
|
if (packageId !== void 0) {
|
|
2788
|
-
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(
|
|
2789
|
-
packageId
|
|
2790
|
-
);
|
|
2791
|
+
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(packageId);
|
|
2791
2792
|
return jsonData;
|
|
2792
2793
|
} else {
|
|
2793
2794
|
console.error("please set your package id.");
|
|
@@ -2798,6 +2799,7 @@ async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
|
2798
2799
|
BcsType,
|
|
2799
2800
|
Dubhe,
|
|
2800
2801
|
MultiSigClient,
|
|
2802
|
+
SubscriptionKind,
|
|
2801
2803
|
SuiAccountManager,
|
|
2802
2804
|
SuiContractFactory,
|
|
2803
2805
|
SuiTx,
|