@0xobelisk/sui-client 1.2.0-pre.12 → 1.2.0-pre.120
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 +7 -8
- package/dist/dubhe.d.ts +249 -77
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1370 -903
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1439 -988
- package/dist/index.mjs.map +1 -1
- package/dist/libs/dubheChannel/client.d.ts +66 -0
- package/dist/libs/dubheChannel/examples.d.ts +39 -0
- package/dist/libs/dubheChannel/index.d.ts +2 -0
- package/dist/libs/dubheChannel/types.d.ts +52 -0
- package/dist/libs/suiContractFactory/index.d.ts +1 -1
- package/dist/libs/suiInteractor/defaultConfig.d.ts +27 -0
- package/dist/libs/suiInteractor/index.d.ts +1 -1
- package/dist/libs/suiInteractor/suiInteractor.d.ts +8 -4
- package/dist/libs/suiTxBuilder/index.d.ts +4 -4
- package/dist/types/index.d.ts +17 -21
- package/dist/utils/const.d.ts +2 -0
- package/dist/utils/index.d.ts +25 -5
- package/package.json +28 -89
- package/src/dubhe.ts +1260 -625
- package/src/errors/index.ts +2 -4
- package/src/index.ts +10 -12
- package/src/libs/dubheChannel/README.md +385 -0
- package/src/libs/dubheChannel/client.ts +303 -0
- package/src/libs/dubheChannel/examples.ts +272 -0
- package/src/libs/dubheChannel/index.ts +11 -0
- package/src/libs/dubheChannel/types.ts +61 -0
- package/src/libs/multiSig/client.ts +2 -2
- package/src/libs/suiAccountManager/index.ts +4 -13
- package/src/libs/suiAccountManager/keypair.ts +3 -12
- package/src/libs/suiAccountManager/util.ts +1 -2
- package/src/libs/suiContractFactory/index.ts +27 -33
- package/src/libs/suiContractFactory/types.ts +1 -4
- package/src/libs/suiInteractor/defaultConfig.ts +52 -7
- package/src/libs/suiInteractor/index.ts +1 -1
- package/src/libs/suiInteractor/suiInteractor.ts +36 -54
- package/src/libs/suiInteractor/util.ts +1 -2
- package/src/libs/suiModel/suiOwnedObject.ts +3 -3
- package/src/libs/suiModel/suiSharedObject.ts +4 -8
- package/src/libs/suiTxBuilder/index.ts +23 -83
- package/src/libs/suiTxBuilder/util.ts +11 -33
- package/src/metadata/index.ts +1 -2
- package/src/types/index.ts +21 -39
- package/src/utils/const.ts +91 -0
- package/src/utils/index.ts +39 -5
- package/dist/libs/http/errors.d.ts +0 -28
- package/dist/libs/http/http.d.ts +0 -22
- package/dist/libs/http/index.d.ts +0 -4
- package/dist/libs/http/types.d.ts +0 -1
- package/dist/libs/http/ws-adapter.d.ts +0 -6
- package/dist/libs/suiIndexerClient/index.d.ts +0 -121
- package/dist/libs/suiIndexerClient/types.d.ts +0 -0
- package/dist/libs/suiIndexerClient/utils.d.ts +0 -2
- package/src/libs/http/errors.ts +0 -126
- package/src/libs/http/http.ts +0 -151
- package/src/libs/http/index.ts +0 -4
- package/src/libs/http/types.ts +0 -1
- package/src/libs/http/ws-adapter.ts +0 -36
- package/src/libs/suiIndexerClient/index.ts +0 -333
- package/src/libs/suiIndexerClient/types.ts +0 -0
- package/src/libs/suiIndexerClient/utils.ts +0 -49
package/README.md
CHANGED
|
@@ -25,10 +25,10 @@ export const dubheConfig = {
|
|
|
25
25
|
schemas: {
|
|
26
26
|
counter: {
|
|
27
27
|
structure: {
|
|
28
|
-
value: 'StorageValue<u32>'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
28
|
+
value: 'StorageValue<u32>'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
32
|
} as DubheConfig;
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -55,7 +55,7 @@ const dubhe = new Dubhe({
|
|
|
55
55
|
networkType: network,
|
|
56
56
|
packageId: packageId,
|
|
57
57
|
metadata: metadata,
|
|
58
|
-
secretKey: privkey
|
|
58
|
+
secretKey: privkey
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -68,7 +68,7 @@ const dubhe = new Dubhe({
|
|
|
68
68
|
networkType: network,
|
|
69
69
|
packageId: packageId,
|
|
70
70
|
metadata: metadata,
|
|
71
|
-
secretKey: privkey
|
|
71
|
+
secretKey: privkey
|
|
72
72
|
});
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -166,8 +166,7 @@ const numberKey = await dubhe.entity_key_from_u256(123);
|
|
|
166
166
|
To query objects owned by a specific address:
|
|
167
167
|
|
|
168
168
|
```typescript
|
|
169
|
-
const owner =
|
|
170
|
-
'0xfa99b5b0463fcfb7d0203c701a76da5eda21a96190eb1368ab36a437cc89195e';
|
|
169
|
+
const owner = '0xfa99b5b0463fcfb7d0203c701a76da5eda21a96190eb1368ab36a437cc89195e';
|
|
171
170
|
const ownedObjects = await dubhe.getOwnedObjects(owner);
|
|
172
171
|
```
|
|
173
172
|
|
package/dist/dubhe.d.ts
CHANGED
|
@@ -7,9 +7,8 @@ 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,
|
|
11
|
-
import {
|
|
12
|
-
import { Http } from './libs/http';
|
|
10
|
+
import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg, NetworkType } from './types';
|
|
11
|
+
import { DubheChannelClient } from './libs/dubheChannel';
|
|
13
12
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
14
13
|
export declare function withMeta<T extends {
|
|
15
14
|
meta: SuiMoveMoudleFuncType;
|
|
@@ -20,14 +19,18 @@ export declare function withMeta<T extends {
|
|
|
20
19
|
*/
|
|
21
20
|
export declare class Dubhe {
|
|
22
21
|
#private;
|
|
23
|
-
http: Http;
|
|
24
22
|
accountManager: SuiAccountManager;
|
|
25
23
|
suiInteractor: SuiInteractor;
|
|
26
|
-
suiIndexerClient: SuiIndexerClient;
|
|
27
24
|
contractFactory: SuiContractFactory;
|
|
25
|
+
dubheChannelClient: DubheChannelClient;
|
|
28
26
|
packageId: string | undefined;
|
|
27
|
+
/** Fully-qualified Move type string for this DApp's DappKey, e.g. `<64-hex>::dapp_key::DappKey`. */
|
|
28
|
+
dappKey: string | undefined;
|
|
29
29
|
metadata: SuiMoveNormalizedModules | undefined;
|
|
30
30
|
projectName: string | undefined;
|
|
31
|
+
frameworkPackageId: string | undefined;
|
|
32
|
+
dappStorageId: string | undefined;
|
|
33
|
+
dappHubId: string | undefined;
|
|
31
34
|
/**
|
|
32
35
|
* Support the following ways to init the DubheClient:
|
|
33
36
|
* 1. mnemonics
|
|
@@ -39,91 +42,28 @@ export declare class Dubhe {
|
|
|
39
42
|
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
|
|
40
43
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
41
44
|
* @param packageId
|
|
45
|
+
* @param metadata
|
|
46
|
+
* @param channelUrl, the base URL for Dubhe Channel API, optional
|
|
47
|
+
* @param frameworkPackageId, the published package ID of the dubhe framework, required for proxy operations
|
|
42
48
|
*/
|
|
43
|
-
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId,
|
|
49
|
+
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, dappKey: dappKeyParam, metadata, channelUrl, frameworkPackageId, dappStorageId, dappHubId }?: DubheParams);
|
|
44
50
|
get query(): MapMoudleFuncQuery;
|
|
45
51
|
get tx(): MapMoudleFuncTx;
|
|
46
52
|
get object(): MapObjectStruct;
|
|
47
53
|
view(dryResult: DevInspectResults): any[];
|
|
48
|
-
state({ tx, schema, params, customModuleName
|
|
54
|
+
state({ tx, schema, params, customModuleName }: {
|
|
49
55
|
tx: Transaction;
|
|
50
56
|
schema: string;
|
|
51
57
|
params: any[];
|
|
52
58
|
customModuleName?: string;
|
|
53
59
|
}): Promise<any[] | undefined>;
|
|
54
|
-
parseState({ schema, objectId, storageType, params, customModuleName
|
|
60
|
+
parseState({ schema, objectId, storageType, params, customModuleName }: {
|
|
55
61
|
schema: string;
|
|
56
62
|
objectId: string;
|
|
57
63
|
storageType: string;
|
|
58
64
|
params: any[];
|
|
59
65
|
customModuleName?: string;
|
|
60
66
|
}): Promise<any[] | undefined>;
|
|
61
|
-
getTransactions({ first, after, sender, digest, checkpoint, orderBy, }: {
|
|
62
|
-
first?: number;
|
|
63
|
-
after?: string;
|
|
64
|
-
sender?: string;
|
|
65
|
-
digest?: string;
|
|
66
|
-
checkpoint?: number;
|
|
67
|
-
orderBy?: string[];
|
|
68
|
-
}): Promise<ConnectionResponse<IndexerTransaction>>;
|
|
69
|
-
getTransaction(digest: string): Promise<IndexerTransaction | undefined>;
|
|
70
|
-
/**
|
|
71
|
-
* Wait for the transaction to be processed by the indexer and return all transaction-related data
|
|
72
|
-
* @param digest transaction digest
|
|
73
|
-
* @param options option parameters
|
|
74
|
-
* @returns result object containing transaction, events and schema data
|
|
75
|
-
*/
|
|
76
|
-
waitForIndexerTransaction(digest: string, options?: {
|
|
77
|
-
checkInterval?: number;
|
|
78
|
-
timeout?: number;
|
|
79
|
-
maxRetries?: number;
|
|
80
|
-
pageSize?: number;
|
|
81
|
-
}): Promise<IndexerTransactionResult>;
|
|
82
|
-
getEvents({ first, after, names, sender, digest, checkpoint, orderBy, }: {
|
|
83
|
-
first?: number;
|
|
84
|
-
after?: string;
|
|
85
|
-
names?: string[];
|
|
86
|
-
sender?: string;
|
|
87
|
-
digest?: string;
|
|
88
|
-
checkpoint?: string;
|
|
89
|
-
orderBy?: string[];
|
|
90
|
-
}): Promise<ConnectionResponse<IndexerEvent>>;
|
|
91
|
-
getSchemas({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, jsonOrderBy, }: {
|
|
92
|
-
name?: string;
|
|
93
|
-
key1?: any;
|
|
94
|
-
key2?: any;
|
|
95
|
-
is_removed?: boolean;
|
|
96
|
-
last_update_checkpoint?: string;
|
|
97
|
-
last_update_digest?: string;
|
|
98
|
-
value?: any;
|
|
99
|
-
first?: number;
|
|
100
|
-
after?: string;
|
|
101
|
-
orderBy?: string[];
|
|
102
|
-
jsonOrderBy?: JsonPathOrder[];
|
|
103
|
-
}): Promise<ConnectionResponse<IndexerSchema>>;
|
|
104
|
-
getStorage({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, first, after, orderBy, jsonOrderBy, }: {
|
|
105
|
-
name?: string;
|
|
106
|
-
key1?: any;
|
|
107
|
-
key2?: any;
|
|
108
|
-
is_removed?: boolean;
|
|
109
|
-
last_update_checkpoint?: string;
|
|
110
|
-
last_update_digest?: string;
|
|
111
|
-
value?: any;
|
|
112
|
-
first?: number;
|
|
113
|
-
after?: string;
|
|
114
|
-
orderBy?: string[];
|
|
115
|
-
jsonOrderBy?: JsonPathOrder[];
|
|
116
|
-
}): Promise<StorageResponse<IndexerSchema>>;
|
|
117
|
-
getStorageItem({ name, key1, key2, is_removed, last_update_checkpoint, last_update_digest, value, }: {
|
|
118
|
-
name: string;
|
|
119
|
-
key1?: any;
|
|
120
|
-
key2?: any;
|
|
121
|
-
is_removed?: boolean;
|
|
122
|
-
last_update_checkpoint?: string;
|
|
123
|
-
last_update_digest?: string;
|
|
124
|
-
value?: any;
|
|
125
|
-
}): Promise<StorageItemResponse<IndexerSchema> | undefined>;
|
|
126
|
-
subscribe(types: SubscribableType[], handleData: (data: any) => void): Promise<WebSocket>;
|
|
127
67
|
/**
|
|
128
68
|
* else:
|
|
129
69
|
* it will generate signer from the mnemonic with the given derivePathParams.
|
|
@@ -142,12 +82,36 @@ export declare class Dubhe {
|
|
|
142
82
|
getAddress(derivePathParams?: DerivePathParams): string;
|
|
143
83
|
currentAddress(): string;
|
|
144
84
|
getPackageId(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Return the fully-qualified Move type string for this DApp's `DappKey`.
|
|
87
|
+
*
|
|
88
|
+
* The format matches what `std::type_name::get<DappKey>()` returns on-chain:
|
|
89
|
+
* `<64-char-zero-padded-address>::dapp_key::DappKey`
|
|
90
|
+
*
|
|
91
|
+
* Use this whenever you need to pass a type argument or build a `target`
|
|
92
|
+
* string that references the DApp's DappKey type.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* tx.moveCall({
|
|
97
|
+
* target: `${frameworkPackageId}::dapp_system::settle_writes`,
|
|
98
|
+
* typeArguments: [contract.getDappKey()],
|
|
99
|
+
* arguments: [...],
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
getDappKey(): string | undefined;
|
|
145
104
|
getMetadata(): SuiMoveNormalizedModules | undefined;
|
|
146
|
-
getNetwork():
|
|
105
|
+
getNetwork(): NetworkType | undefined;
|
|
147
106
|
getNetworkConfig(): NetworkConfig;
|
|
148
107
|
getTxExplorerUrl(txHash: string): string;
|
|
149
108
|
getAccountExplorerUrl(address: string): string;
|
|
150
109
|
getExplorerUrl(): string;
|
|
110
|
+
/**
|
|
111
|
+
* Update configuration dynamically without recreating the entire instance
|
|
112
|
+
* @param config - Partial configuration to update (same type as constructor)
|
|
113
|
+
*/
|
|
114
|
+
updateConfig(config: Partial<DubheParams>): void;
|
|
151
115
|
/**
|
|
152
116
|
* Request some SUI from faucet
|
|
153
117
|
* @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
|
|
@@ -156,11 +120,10 @@ export declare class Dubhe {
|
|
|
156
120
|
getBalance(coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
|
|
157
121
|
balanceOf(accountAddress?: string, coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
|
|
158
122
|
client(): import("@mysten/sui/client").SuiClient;
|
|
159
|
-
indexerClient(): SuiIndexerClient;
|
|
160
123
|
getObject(objectId: string): Promise<SuiObjectData>;
|
|
161
124
|
getObjects(objectIds: string[]): Promise<SuiObjectData[]>;
|
|
162
125
|
signTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/dist/cjs/cryptography").SignatureWithBytes>;
|
|
163
|
-
signAndSendTxn({ tx, derivePathParams, onSuccess, onError
|
|
126
|
+
signAndSendTxn({ tx, derivePathParams, onSuccess, onError }: {
|
|
164
127
|
tx: Uint8Array | Transaction | SuiTx;
|
|
165
128
|
derivePathParams?: DerivePathParams;
|
|
166
129
|
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
@@ -168,6 +131,62 @@ export declare class Dubhe {
|
|
|
168
131
|
}): Promise<SuiTransactionBlockResponse>;
|
|
169
132
|
sendTx(transaction: Uint8Array | string, signature: string | string[]): Promise<SuiTransactionBlockResponse>;
|
|
170
133
|
waitForTransaction(digest: string): Promise<SuiTransactionBlockResponse>;
|
|
134
|
+
submitToChannel({ tx, nonce, chainType }: {
|
|
135
|
+
tx: Transaction;
|
|
136
|
+
nonce: number;
|
|
137
|
+
chainType?: string;
|
|
138
|
+
}): Promise<any>;
|
|
139
|
+
queryChannelTable({ packageId, account, table, key }: {
|
|
140
|
+
packageId?: string;
|
|
141
|
+
account?: string;
|
|
142
|
+
table: string;
|
|
143
|
+
key: any[];
|
|
144
|
+
}): Promise<any>;
|
|
145
|
+
/**
|
|
146
|
+
* Subscribe to channel table updates via Server-Sent Events
|
|
147
|
+
* @param params - Subscription parameters
|
|
148
|
+
* @param options - Event handlers for the subscription
|
|
149
|
+
* @returns Unsubscribe function
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // Subscribe to all tables and accounts (only dapp_key)
|
|
153
|
+
* const unsubscribe = await dubhe.subscribeChannelTable(
|
|
154
|
+
* {},
|
|
155
|
+
* { onMessage: (data) => console.log(data) }
|
|
156
|
+
* );
|
|
157
|
+
*
|
|
158
|
+
* // Subscribe to all tables for a specific account
|
|
159
|
+
* const unsubscribe = await dubhe.subscribeChannelTable(
|
|
160
|
+
* { account: '0xabc...' },
|
|
161
|
+
* { onMessage: (data) => console.log(data) }
|
|
162
|
+
* );
|
|
163
|
+
*
|
|
164
|
+
* // Subscribe to a specific table for a specific account
|
|
165
|
+
* const unsubscribe = await dubhe.subscribeChannelTable(
|
|
166
|
+
* { account: '0xabc...', table: 'position' },
|
|
167
|
+
* { onMessage: (data) => console.log(data) }
|
|
168
|
+
* );
|
|
169
|
+
*
|
|
170
|
+
* // Subscribe to a specific table, account, and key
|
|
171
|
+
* const unsubscribe = await dubhe.subscribeChannelTable(
|
|
172
|
+
* { account: '0xabc...', table: 'position', key: [] },
|
|
173
|
+
* { onMessage: (data) => console.log(data) }
|
|
174
|
+
* );
|
|
175
|
+
*/
|
|
176
|
+
subscribeChannelTable({ packageId: _packageId, account, table, key }?: {
|
|
177
|
+
packageId?: string;
|
|
178
|
+
account?: string;
|
|
179
|
+
table?: string;
|
|
180
|
+
key?: any[];
|
|
181
|
+
}, options?: {
|
|
182
|
+
onMessage?: (data: any) => void;
|
|
183
|
+
onError?: (error: Error) => void;
|
|
184
|
+
onOpen?: () => void;
|
|
185
|
+
onClose?: () => void;
|
|
186
|
+
}): Promise<() => void>;
|
|
187
|
+
latestNonce({ account }?: {
|
|
188
|
+
account?: string;
|
|
189
|
+
}): Promise<number>;
|
|
171
190
|
/**
|
|
172
191
|
* Transfer the given amount of SUI to the recipient
|
|
173
192
|
* @param recipient
|
|
@@ -227,4 +246,157 @@ export declare class Dubhe {
|
|
|
227
246
|
entity_key_from_address_with_seed(objectId: string, seed: string): Promise<string | undefined>;
|
|
228
247
|
entity_key_from_address_with_u256(objectId: string, x: number): Promise<string | undefined>;
|
|
229
248
|
entity_key_from_u256(x: number): Promise<string>;
|
|
249
|
+
/**
|
|
250
|
+
* Call the DApp's generated `user_storage_init::init_user_storage` entry function,
|
|
251
|
+
* which creates and shares a `UserStorage` object for the signer.
|
|
252
|
+
*
|
|
253
|
+
* Each DApp exposes this entry point under its own package ID.
|
|
254
|
+
* On Sui, the `UserStorage` object is shared immediately so all transactions
|
|
255
|
+
* can reference it without knowing the object ID in advance.
|
|
256
|
+
*
|
|
257
|
+
* @param dappHubId Object ID of the DappHub shared object
|
|
258
|
+
* @param dappStorageId Object ID of the DApp's DappStorage shared object
|
|
259
|
+
*/
|
|
260
|
+
initUserStorage({ dappHubId, dappStorageId: dappStorageIdParam, derivePathParams, onSuccess, onError }: {
|
|
261
|
+
dappHubId: string;
|
|
262
|
+
dappStorageId?: string;
|
|
263
|
+
derivePathParams?: DerivePathParams;
|
|
264
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
265
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
266
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
267
|
+
/**
|
|
268
|
+
* Activate a session key for the signer's `UserStorage`.
|
|
269
|
+
*
|
|
270
|
+
* The signer must be the `canonical_owner` of the `UserStorage` object.
|
|
271
|
+
* Calls `<frameworkPackageId>::dapp_system::activate_session<DappKey>`.
|
|
272
|
+
*
|
|
273
|
+
* @param userStorageId Object ID of the UserStorage to activate a session for
|
|
274
|
+
* @param sessionWallet Sui address of the session wallet
|
|
275
|
+
* @param durationMs Session duration in milliseconds ([60_000, 604_800_000])
|
|
276
|
+
* @param clockObjectId Object ID of the Sui Clock (default: 0x6)
|
|
277
|
+
*/
|
|
278
|
+
activateSession({ userStorageId, sessionWallet, durationMs, dappHubId: dappHubIdParam, clockObjectId, derivePathParams, onSuccess, onError }: {
|
|
279
|
+
userStorageId: string;
|
|
280
|
+
sessionWallet: string;
|
|
281
|
+
durationMs: number;
|
|
282
|
+
dappHubId?: string;
|
|
283
|
+
clockObjectId?: string;
|
|
284
|
+
derivePathParams?: DerivePathParams;
|
|
285
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
286
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
287
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
288
|
+
/**
|
|
289
|
+
* Deactivate the current session key on a `UserStorage`.
|
|
290
|
+
*
|
|
291
|
+
* Allowed callers:
|
|
292
|
+
* - The `canonical_owner` (revoke at any time).
|
|
293
|
+
* - The session key itself (voluntary sign-out).
|
|
294
|
+
* - Anyone, once the session has expired.
|
|
295
|
+
*
|
|
296
|
+
* Calls `<frameworkPackageId>::dapp_system::deactivate_session<DappKey>`.
|
|
297
|
+
*
|
|
298
|
+
* @param userStorageId Object ID of the UserStorage to deactivate the session on
|
|
299
|
+
*/
|
|
300
|
+
deactivateSession({ userStorageId, dappHubId: dappHubIdParam, derivePathParams, onSuccess, onError }: {
|
|
301
|
+
userStorageId: string;
|
|
302
|
+
dappHubId?: string;
|
|
303
|
+
derivePathParams?: DerivePathParams;
|
|
304
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
305
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
306
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
307
|
+
/**
|
|
308
|
+
* Look up the `UserStorage` object ID for the given address in this DApp.
|
|
309
|
+
*
|
|
310
|
+
* Scans the transaction history for `user_storage_init::init_user_storage`
|
|
311
|
+
* calls from the given address and extracts the created `UserStorage` object
|
|
312
|
+
* ID from the transaction's object changes.
|
|
313
|
+
*
|
|
314
|
+
* Returns the object ID on success, or `null` when:
|
|
315
|
+
* - `packageId` or `frameworkPackageId` is not set.
|
|
316
|
+
* - The user has not yet called `initUserStorage`.
|
|
317
|
+
*
|
|
318
|
+
* @param userAddress Sui address to look up (with or without 0x prefix).
|
|
319
|
+
*/
|
|
320
|
+
getUserStorageId(userAddress: string): Promise<string | null>;
|
|
321
|
+
/**
|
|
322
|
+
* Fetch and return the on-chain fields of a `UserStorage` shared object.
|
|
323
|
+
*
|
|
324
|
+
* The returned object mirrors Move's `UserStorage` struct plus two
|
|
325
|
+
* convenience fields computed from the raw counters:
|
|
326
|
+
* - `unsettled_count` = write_count − settled_count
|
|
327
|
+
* - `unsettled_bytes` = write_bytes − settled_bytes
|
|
328
|
+
*
|
|
329
|
+
* @param userStorageId Object ID of the UserStorage to inspect.
|
|
330
|
+
*/
|
|
331
|
+
getUserStorageFields(userStorageId: string): Promise<{
|
|
332
|
+
objectId: string;
|
|
333
|
+
dapp_key: string;
|
|
334
|
+
canonical_owner: string;
|
|
335
|
+
session_key: string;
|
|
336
|
+
session_expires_at: bigint;
|
|
337
|
+
write_count: bigint;
|
|
338
|
+
settled_count: bigint;
|
|
339
|
+
write_bytes: bigint;
|
|
340
|
+
settled_bytes: bigint;
|
|
341
|
+
unsettled_count: bigint;
|
|
342
|
+
unsettled_bytes: bigint;
|
|
343
|
+
}>;
|
|
344
|
+
/**
|
|
345
|
+
* Fetch and return the on-chain fields of a `DappStorage` shared object.
|
|
346
|
+
*
|
|
347
|
+
* Covers the full metadata + fee/credit subset of the Move struct.
|
|
348
|
+
*
|
|
349
|
+
* @param dappStorageId Object ID of the DappStorage to inspect.
|
|
350
|
+
*/
|
|
351
|
+
getDappStorageFields(dappStorageId: string): Promise<{
|
|
352
|
+
objectId: string;
|
|
353
|
+
dapp_key: string;
|
|
354
|
+
name: string;
|
|
355
|
+
description: string;
|
|
356
|
+
website_url: string;
|
|
357
|
+
admin: string;
|
|
358
|
+
version: number;
|
|
359
|
+
paused: boolean;
|
|
360
|
+
free_credit: bigint;
|
|
361
|
+
free_credit_expires_at: bigint;
|
|
362
|
+
credit_pool: bigint;
|
|
363
|
+
min_credit_to_unsuspend: bigint;
|
|
364
|
+
suspended: boolean;
|
|
365
|
+
total_settled: bigint;
|
|
366
|
+
base_fee_per_write: bigint;
|
|
367
|
+
bytes_fee_per_byte: bigint;
|
|
368
|
+
}>;
|
|
369
|
+
/**
|
|
370
|
+
* Settle accumulated write debt for a user.
|
|
371
|
+
*
|
|
372
|
+
* Calls `<frameworkPackageId>::dapp_system::settle_writes<DappKey>` with the
|
|
373
|
+
* given DappHub, DappStorage, and UserStorage objects.
|
|
374
|
+
*
|
|
375
|
+
* This is safe to prepend to any PTB — the framework function never aborts
|
|
376
|
+
* due to insufficient credit; it silently skips or partially settles.
|
|
377
|
+
*
|
|
378
|
+
* @param dappHubId Object ID of the DappHub shared object.
|
|
379
|
+
* @param dappStorageId Object ID of the DApp's DappStorage shared object.
|
|
380
|
+
* @param userStorageId Object ID of the user's UserStorage shared object.
|
|
381
|
+
*/
|
|
382
|
+
settleWrites({ dappHubId, dappStorageId: dappStorageIdParam, userStorageId, derivePathParams, onSuccess, onError }: {
|
|
383
|
+
dappHubId: string;
|
|
384
|
+
dappStorageId?: string;
|
|
385
|
+
userStorageId: string;
|
|
386
|
+
derivePathParams?: DerivePathParams;
|
|
387
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
388
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
389
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
390
|
+
/**
|
|
391
|
+
* Return the default network configuration for the given network type.
|
|
392
|
+
*
|
|
393
|
+
* Useful for reading `frameworkPackageId` without instantiating a full client:
|
|
394
|
+
*
|
|
395
|
+
* ```ts
|
|
396
|
+
* const { frameworkPackageId } = Dubhe.getDefaultConfig('testnet');
|
|
397
|
+
* // → '0x8817b...' (known constant for testnet/mainnet)
|
|
398
|
+
* // → undefined (for localnet/devnet — supply after local deployment)
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
static getDefaultConfig(networkType: NetworkType): NetworkConfig;
|
|
230
402
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from '@mysten/sui/client';
|
|
|
2
2
|
export * from '@mysten/sui/utils';
|
|
3
3
|
export * from '@mysten/sui/transactions';
|
|
4
4
|
export * from '@mysten/sui/bcs';
|
|
5
|
+
export * from '@mysten/sui/keypairs/passkey';
|
|
5
6
|
export * from '@mysten/sui/keypairs/ed25519';
|
|
6
7
|
export * from '@mysten/sui/keypairs/secp256k1';
|
|
7
8
|
export * from '@mysten/sui/keypairs/secp256r1';
|
|
@@ -11,7 +12,7 @@ export { SuiAccountManager } from './libs/suiAccountManager';
|
|
|
11
12
|
export { SuiTx } from './libs/suiTxBuilder';
|
|
12
13
|
export { MultiSigClient } from './libs/multiSig';
|
|
13
14
|
export { SuiContractFactory } from './libs/suiContractFactory';
|
|
14
|
-
export { SubscriptionKind } from './libs/suiIndexerClient';
|
|
15
15
|
export { loadMetadata } from './metadata';
|
|
16
16
|
export type * from './types';
|
|
17
|
-
export
|
|
17
|
+
export { getDefaultConfig, getDefaultURL, TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID, TESTNET_DUBHE_HUB_OBJECT_ID, MAINNET_DUBHE_FRAMEWORK_PACKAGE_ID, MAINNET_DUBHE_HUB_OBJECT_ID } from './libs/suiInteractor/defaultConfig';
|
|
18
|
+
export type { NetworkConfig } from './libs/suiInteractor/defaultConfig';
|