@0xobelisk/sui-client 1.2.0-pre.113 → 1.2.0-pre.117
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/dist/dubhe.d.ts +179 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +382 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +376 -22
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiInteractor/defaultConfig.d.ts +26 -0
- package/dist/libs/suiInteractor/index.d.ts +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/utils/index.d.ts +19 -1
- package/package.json +1 -1
- package/src/dubhe.ts +454 -23
- package/src/index.ts +9 -0
- package/src/libs/suiInteractor/defaultConfig.ts +47 -4
- package/src/libs/suiInteractor/index.ts +1 -1
- package/src/types/index.ts +4 -0
- package/src/utils/index.ts +24 -1
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, NetworkType } from './types';
|
|
11
11
|
import { DubheChannelClient } from './libs/dubheChannel';
|
|
12
12
|
export declare function isUndefined(value?: unknown): value is undefined;
|
|
13
13
|
export declare function withMeta<T extends {
|
|
@@ -24,8 +24,12 @@ export declare class Dubhe {
|
|
|
24
24
|
contractFactory: SuiContractFactory;
|
|
25
25
|
dubheChannelClient: DubheChannelClient;
|
|
26
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;
|
|
27
29
|
metadata: SuiMoveNormalizedModules | undefined;
|
|
28
30
|
projectName: string | undefined;
|
|
31
|
+
frameworkPackageId: string | undefined;
|
|
32
|
+
dappStorageId: string | undefined;
|
|
29
33
|
/**
|
|
30
34
|
* Support the following ways to init the DubheClient:
|
|
31
35
|
* 1. mnemonics
|
|
@@ -39,8 +43,9 @@ export declare class Dubhe {
|
|
|
39
43
|
* @param packageId
|
|
40
44
|
* @param metadata
|
|
41
45
|
* @param channelUrl, the base URL for Dubhe Channel API, optional
|
|
46
|
+
* @param frameworkPackageId, the published package ID of the dubhe framework, required for proxy operations
|
|
42
47
|
*/
|
|
43
|
-
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, channelUrl }?: DubheParams);
|
|
48
|
+
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, channelUrl, frameworkPackageId, dappStorageId }?: DubheParams);
|
|
44
49
|
get query(): MapMoudleFuncQuery;
|
|
45
50
|
get tx(): MapMoudleFuncTx;
|
|
46
51
|
get object(): MapObjectStruct;
|
|
@@ -76,8 +81,27 @@ export declare class Dubhe {
|
|
|
76
81
|
getAddress(derivePathParams?: DerivePathParams): string;
|
|
77
82
|
currentAddress(): string;
|
|
78
83
|
getPackageId(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Return the fully-qualified Move type string for this DApp's `DappKey`.
|
|
86
|
+
*
|
|
87
|
+
* The format matches what `std::type_name::get<DappKey>()` returns on-chain:
|
|
88
|
+
* `<64-char-zero-padded-address>::dapp_key::DappKey`
|
|
89
|
+
*
|
|
90
|
+
* Use this whenever you need to pass a type argument or build a `target`
|
|
91
|
+
* string that references the DApp's DappKey type.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* tx.moveCall({
|
|
96
|
+
* target: `${frameworkPackageId}::dapp_system::settle_writes`,
|
|
97
|
+
* typeArguments: [contract.getDappKey()],
|
|
98
|
+
* arguments: [...],
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
getDappKey(): string | undefined;
|
|
79
103
|
getMetadata(): SuiMoveNormalizedModules | undefined;
|
|
80
|
-
getNetwork():
|
|
104
|
+
getNetwork(): NetworkType | undefined;
|
|
81
105
|
getNetworkConfig(): NetworkConfig;
|
|
82
106
|
getTxExplorerUrl(txHash: string): string;
|
|
83
107
|
getAccountExplorerUrl(address: string): string;
|
|
@@ -148,7 +172,7 @@ export declare class Dubhe {
|
|
|
148
172
|
* { onMessage: (data) => console.log(data) }
|
|
149
173
|
* );
|
|
150
174
|
*/
|
|
151
|
-
subscribeChannelTable({ packageId, account, table, key }?: {
|
|
175
|
+
subscribeChannelTable({ packageId: _packageId, account, table, key }?: {
|
|
152
176
|
packageId?: string;
|
|
153
177
|
account?: string;
|
|
154
178
|
table?: string;
|
|
@@ -221,4 +245,155 @@ export declare class Dubhe {
|
|
|
221
245
|
entity_key_from_address_with_seed(objectId: string, seed: string): Promise<string | undefined>;
|
|
222
246
|
entity_key_from_address_with_u256(objectId: string, x: number): Promise<string | undefined>;
|
|
223
247
|
entity_key_from_u256(x: number): Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* Call the DApp's generated `user_storage_init::init_user_storage` entry function,
|
|
250
|
+
* which creates and shares a `UserStorage` object for the signer.
|
|
251
|
+
*
|
|
252
|
+
* Each DApp exposes this entry point under its own package ID.
|
|
253
|
+
* On Sui, the `UserStorage` object is shared immediately so all transactions
|
|
254
|
+
* can reference it without knowing the object ID in advance.
|
|
255
|
+
*
|
|
256
|
+
* @param dappHubId Object ID of the DappHub shared object
|
|
257
|
+
* @param dappStorageId Object ID of the DApp's DappStorage shared object
|
|
258
|
+
*/
|
|
259
|
+
initUserStorage({ dappHubId, dappStorageId: dappStorageIdParam, derivePathParams, onSuccess, onError }: {
|
|
260
|
+
dappHubId: string;
|
|
261
|
+
dappStorageId?: string;
|
|
262
|
+
derivePathParams?: DerivePathParams;
|
|
263
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
264
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
265
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
266
|
+
/**
|
|
267
|
+
* Activate a session key for the signer's `UserStorage`.
|
|
268
|
+
*
|
|
269
|
+
* The signer must be the `canonical_owner` of the `UserStorage` object.
|
|
270
|
+
* Calls `<frameworkPackageId>::dapp_system::activate_session<DappKey>`.
|
|
271
|
+
*
|
|
272
|
+
* @param userStorageId Object ID of the UserStorage to activate a session for
|
|
273
|
+
* @param sessionWallet Sui address of the session wallet
|
|
274
|
+
* @param durationMs Session duration in milliseconds ([60_000, 604_800_000])
|
|
275
|
+
* @param clockObjectId Object ID of the Sui Clock (default: 0x6)
|
|
276
|
+
*/
|
|
277
|
+
activateSession({ userStorageId, sessionWallet, durationMs, clockObjectId, derivePathParams, onSuccess, onError }: {
|
|
278
|
+
userStorageId: string;
|
|
279
|
+
sessionWallet: string;
|
|
280
|
+
durationMs: number;
|
|
281
|
+
clockObjectId?: string;
|
|
282
|
+
derivePathParams?: DerivePathParams;
|
|
283
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
284
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
285
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
286
|
+
/**
|
|
287
|
+
* Deactivate the current session key on a `UserStorage`.
|
|
288
|
+
*
|
|
289
|
+
* Allowed callers:
|
|
290
|
+
* - The `canonical_owner` (revoke at any time).
|
|
291
|
+
* - The session key itself (voluntary sign-out).
|
|
292
|
+
* - Anyone, once the session has expired.
|
|
293
|
+
*
|
|
294
|
+
* Calls `<frameworkPackageId>::dapp_system::deactivate_session<DappKey>`.
|
|
295
|
+
*
|
|
296
|
+
* @param userStorageId Object ID of the UserStorage to deactivate the session on
|
|
297
|
+
*/
|
|
298
|
+
deactivateSession({ userStorageId, derivePathParams, onSuccess, onError }: {
|
|
299
|
+
userStorageId: string;
|
|
300
|
+
derivePathParams?: DerivePathParams;
|
|
301
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
302
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
303
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
304
|
+
/**
|
|
305
|
+
* Look up the `UserStorage` object ID for the given address in this DApp.
|
|
306
|
+
*
|
|
307
|
+
* Scans the transaction history for `user_storage_init::init_user_storage`
|
|
308
|
+
* calls from the given address and extracts the created `UserStorage` object
|
|
309
|
+
* ID from the transaction's object changes.
|
|
310
|
+
*
|
|
311
|
+
* Returns the object ID on success, or `null` when:
|
|
312
|
+
* - `packageId` or `frameworkPackageId` is not set.
|
|
313
|
+
* - The user has not yet called `initUserStorage`.
|
|
314
|
+
*
|
|
315
|
+
* @param userAddress Sui address to look up (with or without 0x prefix).
|
|
316
|
+
*/
|
|
317
|
+
getUserStorageId(userAddress: string): Promise<string | null>;
|
|
318
|
+
/**
|
|
319
|
+
* Fetch and return the on-chain fields of a `UserStorage` shared object.
|
|
320
|
+
*
|
|
321
|
+
* The returned object mirrors Move's `UserStorage` struct plus two
|
|
322
|
+
* convenience fields computed from the raw counters:
|
|
323
|
+
* - `unsettled_count` = write_count − settled_count
|
|
324
|
+
* - `unsettled_bytes` = write_bytes − settled_bytes
|
|
325
|
+
*
|
|
326
|
+
* @param userStorageId Object ID of the UserStorage to inspect.
|
|
327
|
+
*/
|
|
328
|
+
getUserStorageFields(userStorageId: string): Promise<{
|
|
329
|
+
objectId: string;
|
|
330
|
+
dapp_key: string;
|
|
331
|
+
canonical_owner: string;
|
|
332
|
+
session_key: string;
|
|
333
|
+
session_expires_at: bigint;
|
|
334
|
+
write_count: bigint;
|
|
335
|
+
settled_count: bigint;
|
|
336
|
+
write_bytes: bigint;
|
|
337
|
+
settled_bytes: bigint;
|
|
338
|
+
unsettled_count: bigint;
|
|
339
|
+
unsettled_bytes: bigint;
|
|
340
|
+
}>;
|
|
341
|
+
/**
|
|
342
|
+
* Fetch and return the on-chain fields of a `DappStorage` shared object.
|
|
343
|
+
*
|
|
344
|
+
* Covers the full metadata + fee/credit subset of the Move struct.
|
|
345
|
+
*
|
|
346
|
+
* @param dappStorageId Object ID of the DappStorage to inspect.
|
|
347
|
+
*/
|
|
348
|
+
getDappStorageFields(dappStorageId: string): Promise<{
|
|
349
|
+
objectId: string;
|
|
350
|
+
dapp_key: string;
|
|
351
|
+
name: string;
|
|
352
|
+
description: string;
|
|
353
|
+
website_url: string;
|
|
354
|
+
admin: string;
|
|
355
|
+
version: number;
|
|
356
|
+
paused: boolean;
|
|
357
|
+
free_credit: bigint;
|
|
358
|
+
free_credit_expires_at: bigint;
|
|
359
|
+
credit_pool: bigint;
|
|
360
|
+
min_credit_to_unsuspend: bigint;
|
|
361
|
+
suspended: boolean;
|
|
362
|
+
total_settled: bigint;
|
|
363
|
+
base_fee_per_write: bigint;
|
|
364
|
+
bytes_fee_per_byte: bigint;
|
|
365
|
+
}>;
|
|
366
|
+
/**
|
|
367
|
+
* Settle accumulated write debt for a user.
|
|
368
|
+
*
|
|
369
|
+
* Calls `<frameworkPackageId>::dapp_system::settle_writes<DappKey>` with the
|
|
370
|
+
* given DappHub, DappStorage, and UserStorage objects.
|
|
371
|
+
*
|
|
372
|
+
* This is safe to prepend to any PTB — the framework function never aborts
|
|
373
|
+
* due to insufficient credit; it silently skips or partially settles.
|
|
374
|
+
*
|
|
375
|
+
* @param dappHubId Object ID of the DappHub shared object.
|
|
376
|
+
* @param dappStorageId Object ID of the DApp's DappStorage shared object.
|
|
377
|
+
* @param userStorageId Object ID of the user's UserStorage shared object.
|
|
378
|
+
*/
|
|
379
|
+
settleWrites({ dappHubId, dappStorageId: dappStorageIdParam, userStorageId, derivePathParams, onSuccess, onError }: {
|
|
380
|
+
dappHubId: string;
|
|
381
|
+
dappStorageId?: string;
|
|
382
|
+
userStorageId: string;
|
|
383
|
+
derivePathParams?: DerivePathParams;
|
|
384
|
+
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
385
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
386
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
387
|
+
/**
|
|
388
|
+
* Return the default network configuration for the given network type.
|
|
389
|
+
*
|
|
390
|
+
* Useful for reading `frameworkPackageId` without instantiating a full client:
|
|
391
|
+
*
|
|
392
|
+
* ```ts
|
|
393
|
+
* const { frameworkPackageId } = Dubhe.getDefaultConfig('testnet');
|
|
394
|
+
* // → '0x8817b...' (known constant for testnet/mainnet)
|
|
395
|
+
* // → undefined (for localnet/devnet — supply after local deployment)
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
static getDefaultConfig(networkType: NetworkType): NetworkConfig;
|
|
224
399
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,3 +14,5 @@ export { MultiSigClient } from './libs/multiSig';
|
|
|
14
14
|
export { SuiContractFactory } from './libs/suiContractFactory';
|
|
15
15
|
export { loadMetadata } from './metadata';
|
|
16
16
|
export type * from './types';
|
|
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';
|