@0xobelisk/sui-client 0.5.23 → 0.5.25
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/LICENSE +1 -1
- package/README.md +18 -18
- package/dist/{obelisk.d.ts → dubhe.d.ts} +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/metadata/index.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/package.json +4 -4
- package/src/{obelisk.ts → dubhe.ts} +8 -8
- package/src/index.ts +1 -1
- package/src/metadata/index.ts +3 -2
- package/src/types/index.ts +4 -4
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dubhe Client SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Dubhe is client agnostic: any client -- a browser, a game engine, or an ios/android app -- can implement the synchronization protocol and a client-side cache to replicate Store tables, along with the necessary infrastructure to send transactions to the World.
|
|
4
4
|
|
|
5
5
|
Currently we only support browsers, Node and the COCOS game engine.
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ We create a Project called Counter and declare sigleton schema called counter, w
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import {
|
|
19
|
+
import { DubheConfig } from '@0xobelisk/sui-common';
|
|
20
20
|
|
|
21
21
|
export const obeliskConfig = {
|
|
22
22
|
name: 'counter',
|
|
@@ -29,13 +29,13 @@ export const obeliskConfig = {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
sample_schema: 'u64',
|
|
32
|
-
} as
|
|
32
|
+
} as DubheConfig;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Through the CLI, we will generate the corresponding contract based on
|
|
35
|
+
Through the CLI, we will generate the corresponding contract based on dubhe.config.ts At this point we need to write the system logic.
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
obelisk schemagen
|
|
38
|
+
obelisk schemagen dubhe.config.ts
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
The next step is simply to write the system file method.
|
|
@@ -57,22 +57,22 @@ Finally we deploy the complete contract to devnet
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
|
-
obelisk publish --network devnet --configPath
|
|
60
|
+
obelisk publish --network devnet --configPath dubhe.config.ts
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
We'll get the `packageId` and `worldId` on the command line.
|
|
64
64
|
|
|
65
|
-
### Init
|
|
65
|
+
### Init Dubhe Client
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
|
-
import { getMetadata,
|
|
68
|
+
import { getMetadata, Dubhe, NetworkType } from "@0xobelisk/sui-client";
|
|
69
69
|
|
|
70
70
|
const network = "devnet" as NetworkType
|
|
71
71
|
const packageId = "0x804578b9eed47d461bba52c393cf148302819e2ba0a0f558356cc419b3e941ed"
|
|
72
72
|
|
|
73
73
|
const metadata = await getMetadata(network, packageId);
|
|
74
74
|
|
|
75
|
-
const obelisk = new
|
|
75
|
+
const obelisk = new Dubhe({
|
|
76
76
|
networkType: network,
|
|
77
77
|
packageId: packageId,
|
|
78
78
|
metadata: metadata,
|
|
@@ -85,11 +85,11 @@ const obelisk = new Obelisk({
|
|
|
85
85
|
If you need to call a method in the system, you can do so using the `obelisk.tx.moudleName.funcName()` form.
|
|
86
86
|
|
|
87
87
|
```typescript
|
|
88
|
-
import { getMetadata,
|
|
88
|
+
import { getMetadata, Dubhe, TransactionBlock } from "@0xobelisk/sui-client";
|
|
89
89
|
|
|
90
90
|
const metadata = await getMetadata(network, packageId);
|
|
91
91
|
|
|
92
|
-
const obelisk = new
|
|
92
|
+
const obelisk = new Dubhe({
|
|
93
93
|
networkType: network,
|
|
94
94
|
packageId: packageId,
|
|
95
95
|
metadata: metadata,
|
|
@@ -130,7 +130,7 @@ If your system method provides a method with no modification status and a return
|
|
|
130
130
|
|
|
131
131
|
```typescript
|
|
132
132
|
const metadata = await getMetadata(NETWORK, PACKAGE_ID);
|
|
133
|
-
const obelisk = new
|
|
133
|
+
const obelisk = new Dubhe({
|
|
134
134
|
networkType: NETWORK,
|
|
135
135
|
packageId: PACKAGE_ID,
|
|
136
136
|
metadata: metadata,
|
|
@@ -150,7 +150,7 @@ Queries the Object information of worldId.
|
|
|
150
150
|
|
|
151
151
|
```typescript
|
|
152
152
|
const metadata = await getMetadata(NETWORK, PACKAGE_ID);
|
|
153
|
-
const obelisk = new
|
|
153
|
+
const obelisk = new Dubhe({
|
|
154
154
|
networkType: NETWORK,
|
|
155
155
|
packageId: PACKAGE_ID,
|
|
156
156
|
metadata: metadata,
|
|
@@ -165,7 +165,7 @@ List all schema name in the world store.
|
|
|
165
165
|
|
|
166
166
|
```typescript
|
|
167
167
|
const metadata = await getMetadata(NETWORK, PACKAGE_ID);
|
|
168
|
-
const obelisk = new
|
|
168
|
+
const obelisk = new Dubhe({
|
|
169
169
|
networkType: NETWORK,
|
|
170
170
|
packageId: PACKAGE_ID,
|
|
171
171
|
metadata: metadata,
|
|
@@ -182,7 +182,7 @@ Get the entity's data based on schema name and entity id(option).
|
|
|
182
182
|
|
|
183
183
|
```typescript
|
|
184
184
|
const metadata = await getMetadata(NETWORK, PACKAGE_ID);
|
|
185
|
-
const obelisk = new
|
|
185
|
+
const obelisk = new Dubhe({
|
|
186
186
|
networkType: NETWORK,
|
|
187
187
|
packageId: PACKAGE_ID,
|
|
188
188
|
metadata: metadata,
|
|
@@ -215,7 +215,7 @@ Determine if the entity exists
|
|
|
215
215
|
|
|
216
216
|
```typescript
|
|
217
217
|
const metadata = await getMetadata(NETWORK, PACKAGE_ID);
|
|
218
|
-
const obelisk = new
|
|
218
|
+
const obelisk = new Dubhe({
|
|
219
219
|
networkType: NETWORK,
|
|
220
220
|
packageId: PACKAGE_ID,
|
|
221
221
|
metadata: metadata,
|
|
@@ -247,7 +247,7 @@ Query all the objects under the current worldId that are owned by a certain addr
|
|
|
247
247
|
|
|
248
248
|
```typescript
|
|
249
249
|
const metadata = await getMetadata(NETWORK, PACKAGE_ID);
|
|
250
|
-
const obelisk = new
|
|
250
|
+
const obelisk = new Dubhe({
|
|
251
251
|
networkType: NETWORK,
|
|
252
252
|
packageId: PACKAGE_ID,
|
|
253
253
|
metadata: metadata,
|
|
@@ -7,16 +7,16 @@ import { SuiInteractor } from './libs/suiInteractor';
|
|
|
7
7
|
import { MapObjectStruct } from './types';
|
|
8
8
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
9
9
|
import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
|
|
10
|
-
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx,
|
|
10
|
+
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg } from './types';
|
|
11
11
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
12
12
|
export declare function withMeta<T extends {
|
|
13
13
|
meta: SuiMoveMoudleFuncType;
|
|
14
14
|
}>(meta: SuiMoveMoudleFuncType, creator: Omit<T, 'meta'>): T;
|
|
15
15
|
/**
|
|
16
|
-
* @class
|
|
16
|
+
* @class Dubhe
|
|
17
17
|
* @description This class is used to aggregate the tools that used to interact with SUI network.
|
|
18
18
|
*/
|
|
19
|
-
export declare class
|
|
19
|
+
export declare class Dubhe {
|
|
20
20
|
#private;
|
|
21
21
|
accountManager: SuiAccountManager;
|
|
22
22
|
suiInteractor: SuiInteractor;
|
|
@@ -24,7 +24,7 @@ export declare class Obelisk {
|
|
|
24
24
|
packageId: string | undefined;
|
|
25
25
|
metadata: SuiMoveNormalizedModules | undefined;
|
|
26
26
|
/**
|
|
27
|
-
* Support the following ways to init the
|
|
27
|
+
* Support the following ways to init the DubheClient:
|
|
28
28
|
* 1. mnemonics
|
|
29
29
|
* 2. secretKey (base64 or hex)
|
|
30
30
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
@@ -35,7 +35,7 @@ export declare class Obelisk {
|
|
|
35
35
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
36
36
|
* @param packageId
|
|
37
37
|
*/
|
|
38
|
-
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, }?:
|
|
38
|
+
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, }?: DubheParams);
|
|
39
39
|
get query(): MapMoudleFuncQuery;
|
|
40
40
|
get tx(): MapMoudleFuncTx;
|
|
41
41
|
get object(): MapObjectStruct;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from '@mysten/sui/keypairs/ed25519';
|
|
|
6
6
|
export * from '@mysten/sui/keypairs/secp256k1';
|
|
7
7
|
export * from '@mysten/sui/keypairs/secp256r1';
|
|
8
8
|
export { bcs, BcsType } from '@mysten/bcs';
|
|
9
|
-
export {
|
|
9
|
+
export { Dubhe } from './dubhe';
|
|
10
10
|
export { SuiAccountManager } from './libs/suiAccountManager';
|
|
11
11
|
export { SuiTx } from './libs/suiTxBuilder';
|
|
12
12
|
export { MultiSigClient } from './libs/multiSig';
|
package/dist/index.js
CHANGED
|
@@ -45,8 +45,8 @@ var __privateAdd = (obj, member, value) => {
|
|
|
45
45
|
var src_exports = {};
|
|
46
46
|
__export(src_exports, {
|
|
47
47
|
BcsType: () => import_bcs3.BcsType,
|
|
48
|
+
Dubhe: () => Dubhe,
|
|
48
49
|
MultiSigClient: () => MultiSigClient,
|
|
49
|
-
Obelisk: () => Obelisk,
|
|
50
50
|
SuiAccountManager: () => SuiAccountManager,
|
|
51
51
|
SuiContractFactory: () => SuiContractFactory,
|
|
52
52
|
SuiTx: () => SuiTx,
|
|
@@ -63,7 +63,7 @@ __reExport(src_exports, require("@mysten/sui/keypairs/secp256k1"), module.export
|
|
|
63
63
|
__reExport(src_exports, require("@mysten/sui/keypairs/secp256r1"), module.exports);
|
|
64
64
|
var import_bcs3 = require("@mysten/bcs");
|
|
65
65
|
|
|
66
|
-
// src/
|
|
66
|
+
// src/dubhe.ts
|
|
67
67
|
var import_keccak256 = __toESM(require("keccak256"));
|
|
68
68
|
var import_client2 = require("@mysten/sui/client");
|
|
69
69
|
var import_transactions3 = require("@mysten/sui/transactions");
|
|
@@ -944,7 +944,7 @@ function numberToAddressHex(num) {
|
|
|
944
944
|
return paddedHex;
|
|
945
945
|
}
|
|
946
946
|
|
|
947
|
-
// src/
|
|
947
|
+
// src/dubhe.ts
|
|
948
948
|
var import_bcs2 = require("@mysten/bcs");
|
|
949
949
|
function isUndefined(value) {
|
|
950
950
|
return value === void 0;
|
|
@@ -971,9 +971,9 @@ function createTx(meta, fn) {
|
|
|
971
971
|
);
|
|
972
972
|
}
|
|
973
973
|
var _query, _tx, _object, _exec, _read, _bcs;
|
|
974
|
-
var
|
|
974
|
+
var Dubhe = class {
|
|
975
975
|
/**
|
|
976
|
-
* Support the following ways to init the
|
|
976
|
+
* Support the following ways to init the DubheClient:
|
|
977
977
|
* 1. mnemonics
|
|
978
978
|
* 2. secretKey (base64 or hex)
|
|
979
979
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
@@ -1667,8 +1667,8 @@ var MultiSigClient = class _MultiSigClient {
|
|
|
1667
1667
|
|
|
1668
1668
|
// src/metadata/index.ts
|
|
1669
1669
|
var import_client4 = require("@mysten/sui/client");
|
|
1670
|
-
async function loadMetadata(networkType, packageId) {
|
|
1671
|
-
|
|
1670
|
+
async function loadMetadata(networkType, packageId, fullnodeUrls) {
|
|
1671
|
+
fullnodeUrls = fullnodeUrls || [(0, import_client4.getFullnodeUrl)(networkType)];
|
|
1672
1672
|
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
1673
1673
|
if (packageId !== void 0) {
|
|
1674
1674
|
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(
|
|
@@ -1682,8 +1682,8 @@ async function loadMetadata(networkType, packageId) {
|
|
|
1682
1682
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1683
1683
|
0 && (module.exports = {
|
|
1684
1684
|
BcsType,
|
|
1685
|
+
Dubhe,
|
|
1685
1686
|
MultiSigClient,
|
|
1686
|
-
Obelisk,
|
|
1687
1687
|
SuiAccountManager,
|
|
1688
1688
|
SuiContractFactory,
|
|
1689
1689
|
SuiTx,
|