@0xobelisk/sui-client 1.2.0-pre.118 → 1.2.0-pre.119
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 +6 -3
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -8
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiInteractor/defaultConfig.d.ts +4 -4
- package/dist/types/index.d.ts +10 -0
- package/package.json +1 -1
- package/src/dubhe.ts +35 -4
- package/src/libs/suiInteractor/defaultConfig.ts +4 -4
- package/src/types/index.ts +10 -0
package/dist/dubhe.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class Dubhe {
|
|
|
30
30
|
projectName: string | undefined;
|
|
31
31
|
frameworkPackageId: string | undefined;
|
|
32
32
|
dappStorageId: string | undefined;
|
|
33
|
+
dappHubId: string | undefined;
|
|
33
34
|
/**
|
|
34
35
|
* Support the following ways to init the DubheClient:
|
|
35
36
|
* 1. mnemonics
|
|
@@ -45,7 +46,7 @@ export declare class Dubhe {
|
|
|
45
46
|
* @param channelUrl, the base URL for Dubhe Channel API, optional
|
|
46
47
|
* @param frameworkPackageId, the published package ID of the dubhe framework, required for proxy operations
|
|
47
48
|
*/
|
|
48
|
-
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, channelUrl, frameworkPackageId, dappStorageId }?: DubheParams);
|
|
49
|
+
constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, dappKey: dappKeyParam, metadata, channelUrl, frameworkPackageId, dappStorageId, dappHubId }?: DubheParams);
|
|
49
50
|
get query(): MapMoudleFuncQuery;
|
|
50
51
|
get tx(): MapMoudleFuncTx;
|
|
51
52
|
get object(): MapObjectStruct;
|
|
@@ -274,10 +275,11 @@ export declare class Dubhe {
|
|
|
274
275
|
* @param durationMs Session duration in milliseconds ([60_000, 604_800_000])
|
|
275
276
|
* @param clockObjectId Object ID of the Sui Clock (default: 0x6)
|
|
276
277
|
*/
|
|
277
|
-
activateSession({ userStorageId, sessionWallet, durationMs, clockObjectId, derivePathParams, onSuccess, onError }: {
|
|
278
|
+
activateSession({ userStorageId, sessionWallet, durationMs, dappHubId: dappHubIdParam, clockObjectId, derivePathParams, onSuccess, onError }: {
|
|
278
279
|
userStorageId: string;
|
|
279
280
|
sessionWallet: string;
|
|
280
281
|
durationMs: number;
|
|
282
|
+
dappHubId?: string;
|
|
281
283
|
clockObjectId?: string;
|
|
282
284
|
derivePathParams?: DerivePathParams;
|
|
283
285
|
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
@@ -295,8 +297,9 @@ export declare class Dubhe {
|
|
|
295
297
|
*
|
|
296
298
|
* @param userStorageId Object ID of the UserStorage to deactivate the session on
|
|
297
299
|
*/
|
|
298
|
-
deactivateSession({ userStorageId, derivePathParams, onSuccess, onError }: {
|
|
300
|
+
deactivateSession({ userStorageId, dappHubId: dappHubIdParam, derivePathParams, onSuccess, onError }: {
|
|
299
301
|
userStorageId: string;
|
|
302
|
+
dappHubId?: string;
|
|
300
303
|
derivePathParams?: DerivePathParams;
|
|
301
304
|
onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
|
|
302
305
|
onError?: (error: Error) => void | Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -844,10 +844,10 @@ var SuiInteractor = class {
|
|
|
844
844
|
};
|
|
845
845
|
|
|
846
846
|
// src/libs/suiInteractor/defaultConfig.ts
|
|
847
|
-
var TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID = "
|
|
848
|
-
var TESTNET_DUBHE_HUB_OBJECT_ID = "
|
|
849
|
-
var MAINNET_DUBHE_FRAMEWORK_PACKAGE_ID = "
|
|
850
|
-
var MAINNET_DUBHE_HUB_OBJECT_ID = "
|
|
847
|
+
var TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID = "0x4177583b1da65b2d508cb10c8d4f463ecddff07faa9f15a8866d3f56c82521b0";
|
|
848
|
+
var TESTNET_DUBHE_HUB_OBJECT_ID = "0x42f50aa8ce4ee977f17474b0745b7ae9801eefc73606c173276837b91b54b30d";
|
|
849
|
+
var MAINNET_DUBHE_FRAMEWORK_PACKAGE_ID = "0x1a79c1611ab49723b388510813553ad912d96a4f1a9ed5fdbdb57e446c6fe946";
|
|
850
|
+
var MAINNET_DUBHE_HUB_OBJECT_ID = "0x49fb15ecac090f2b7e02c83465d240a3f64a52335b848f156277899d070f9829";
|
|
851
851
|
var getDefaultConfig = (networkType = "testnet") => {
|
|
852
852
|
switch (networkType) {
|
|
853
853
|
case "localnet":
|
|
@@ -1428,10 +1428,12 @@ var Dubhe = class {
|
|
|
1428
1428
|
networkType,
|
|
1429
1429
|
fullnodeUrls,
|
|
1430
1430
|
packageId,
|
|
1431
|
+
dappKey: dappKeyParam,
|
|
1431
1432
|
metadata,
|
|
1432
1433
|
channelUrl,
|
|
1433
1434
|
frameworkPackageId,
|
|
1434
|
-
dappStorageId
|
|
1435
|
+
dappStorageId,
|
|
1436
|
+
dappHubId
|
|
1435
1437
|
} = {}) {
|
|
1436
1438
|
// async getTransactions({
|
|
1437
1439
|
// first,
|
|
@@ -2140,10 +2142,11 @@ var Dubhe = class {
|
|
|
2140
2142
|
baseUrl: channelUrl || defaultParams.channelUrl
|
|
2141
2143
|
});
|
|
2142
2144
|
this.packageId = packageId ? normalizePackageId(packageId) : void 0;
|
|
2143
|
-
this.dappKey =
|
|
2145
|
+
this.dappKey = dappKeyParam;
|
|
2144
2146
|
const networkDefault = defaultParams.frameworkPackageId;
|
|
2145
2147
|
this.frameworkPackageId = frameworkPackageId ? normalizePackageId(frameworkPackageId) : networkDefault ? normalizePackageId(networkDefault) : void 0;
|
|
2146
2148
|
this.dappStorageId = dappStorageId;
|
|
2149
|
+
this.dappHubId = dappHubId;
|
|
2147
2150
|
if (metadata !== void 0) {
|
|
2148
2151
|
this.metadata = metadata;
|
|
2149
2152
|
const maxLoopNum = 5;
|
|
@@ -2499,10 +2502,12 @@ var Dubhe = class {
|
|
|
2499
2502
|
}
|
|
2500
2503
|
const packageIdChanged = config.packageId !== void 0 && config.packageId !== this.packageId;
|
|
2501
2504
|
const metadataChanged = config.metadata !== void 0 && config.metadata !== this.metadata;
|
|
2505
|
+
if (config.dappKey !== void 0) {
|
|
2506
|
+
this.dappKey = config.dappKey;
|
|
2507
|
+
}
|
|
2502
2508
|
if (packageIdChanged || metadataChanged) {
|
|
2503
2509
|
if (config.packageId !== void 0) {
|
|
2504
2510
|
this.packageId = normalizePackageId(config.packageId);
|
|
2505
|
-
this.dappKey = normalizeDappKey(config.packageId);
|
|
2506
2511
|
}
|
|
2507
2512
|
if (config.metadata !== void 0) {
|
|
2508
2513
|
this.metadata = config.metadata;
|
|
@@ -2972,6 +2977,7 @@ var Dubhe = class {
|
|
|
2972
2977
|
userStorageId,
|
|
2973
2978
|
sessionWallet,
|
|
2974
2979
|
durationMs,
|
|
2980
|
+
dappHubId: dappHubIdParam,
|
|
2975
2981
|
clockObjectId,
|
|
2976
2982
|
derivePathParams,
|
|
2977
2983
|
onSuccess,
|
|
@@ -2989,12 +2995,19 @@ var Dubhe = class {
|
|
|
2989
2995
|
'dappKey is required for activateSession. Set it in the Dubhe constructor ({ packageId: "0x..." }).'
|
|
2990
2996
|
);
|
|
2991
2997
|
}
|
|
2998
|
+
const hubId = dappHubIdParam ?? this.dappHubId;
|
|
2999
|
+
if (!hubId) {
|
|
3000
|
+
throw new Error(
|
|
3001
|
+
'dappHubId is required for activateSession. Pass it directly or set it in the Dubhe constructor ({ dappHubId: "0x..." }).'
|
|
3002
|
+
);
|
|
3003
|
+
}
|
|
2992
3004
|
const clockId = clockObjectId ?? SUI_CLOCK_OBJECT_ID;
|
|
2993
3005
|
const tx = new import_transactions3.Transaction();
|
|
2994
3006
|
tx.moveCall({
|
|
2995
3007
|
target: `${fwPkg}::dapp_system::activate_session`,
|
|
2996
3008
|
typeArguments: [typeArg],
|
|
2997
3009
|
arguments: [
|
|
3010
|
+
tx.object(hubId),
|
|
2998
3011
|
tx.object(userStorageId),
|
|
2999
3012
|
tx.pure.address(sessionWallet),
|
|
3000
3013
|
tx.pure.u64(durationMs),
|
|
@@ -3022,6 +3035,7 @@ var Dubhe = class {
|
|
|
3022
3035
|
*/
|
|
3023
3036
|
async deactivateSession({
|
|
3024
3037
|
userStorageId,
|
|
3038
|
+
dappHubId: dappHubIdParam,
|
|
3025
3039
|
derivePathParams,
|
|
3026
3040
|
onSuccess,
|
|
3027
3041
|
onError
|
|
@@ -3038,11 +3052,17 @@ var Dubhe = class {
|
|
|
3038
3052
|
'dappKey is required for deactivateSession. Set it in the Dubhe constructor ({ packageId: "0x..." }).'
|
|
3039
3053
|
);
|
|
3040
3054
|
}
|
|
3055
|
+
const hubId = dappHubIdParam ?? this.dappHubId;
|
|
3056
|
+
if (!hubId) {
|
|
3057
|
+
throw new Error(
|
|
3058
|
+
'dappHubId is required for deactivateSession. Pass it directly or set it in the Dubhe constructor ({ dappHubId: "0x..." }).'
|
|
3059
|
+
);
|
|
3060
|
+
}
|
|
3041
3061
|
const tx = new import_transactions3.Transaction();
|
|
3042
3062
|
tx.moveCall({
|
|
3043
3063
|
target: `${fwPkg}::dapp_system::deactivate_session`,
|
|
3044
3064
|
typeArguments: [typeArg],
|
|
3045
|
-
arguments: [tx.object(userStorageId)]
|
|
3065
|
+
arguments: [tx.object(hubId), tx.object(userStorageId)]
|
|
3046
3066
|
});
|
|
3047
3067
|
return this.signAndSendTxn({
|
|
3048
3068
|
tx,
|