@0xobelisk/sui-client 1.2.0-pre.99 → 2.0.0

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/src/index.ts CHANGED
@@ -14,3 +14,12 @@ 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 {
18
+ getDefaultConfig,
19
+ getDefaultURL,
20
+ TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID,
21
+ TESTNET_DUBHE_HUB_OBJECT_ID,
22
+ MAINNET_DUBHE_FRAMEWORK_PACKAGE_ID,
23
+ MAINNET_DUBHE_HUB_OBJECT_ID
24
+ } from './libs/suiInteractor/defaultConfig';
25
+ export type { NetworkConfig } from './libs/suiInteractor/defaultConfig';
@@ -1,5 +1,25 @@
1
1
  import { NetworkType } from 'src/types';
2
2
 
3
+ /**
4
+ * Testnet deployment of the Dubhe framework.
5
+ * Update these constants whenever the framework is redeployed to testnet.
6
+ */
7
+ export const TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID =
8
+ '0xae33be6675639d6f1a5c468ae6bbc457ae4e22e57cd7526741d6143ce219d995';
9
+
10
+ export const TESTNET_DUBHE_HUB_OBJECT_ID =
11
+ '0x80391929a8772aba091156fd1f099bf79240d2cf4471a14026b4aa68e3a240cc';
12
+
13
+ /**
14
+ * Mainnet deployment of the Dubhe framework.
15
+ * Update these constants whenever the framework is redeployed to mainnet.
16
+ */
17
+ export const MAINNET_DUBHE_FRAMEWORK_PACKAGE_ID =
18
+ '0x5bc40de124588b1e3514ca50f5e7109869351c4d9544e5f0cb9d30dd47bf8de7';
19
+
20
+ export const MAINNET_DUBHE_HUB_OBJECT_ID =
21
+ '0x96e92d9baccfd0a2927b4f209756e1edbc18904bff34e486e4bb4a151320e1e5';
22
+
3
23
  export interface NetworkConfig {
4
24
  fullNode: string;
5
25
  graphql?: string;
@@ -9,21 +29,36 @@ export interface NetworkConfig {
9
29
  explorer: string;
10
30
  indexerUrl: string;
11
31
  channelUrl: string;
32
+ /**
33
+ * Published package ID of the Dubhe framework for this network.
34
+ * Defined for testnet and mainnet (known constants).
35
+ * Undefined for localnet/devnet — supply after deploying dubhe locally.
36
+ */
37
+ frameworkPackageId?: string;
38
+ /**
39
+ * Shared DappHub object ID for this network.
40
+ * Defined for testnet and mainnet (known constants).
41
+ * Undefined for localnet/devnet — read from the deployment JSON after publishing.
42
+ */
43
+ dappHubId?: string;
12
44
  }
13
45
 
14
- export const getDefaultURL = (networkType: NetworkType = 'testnet'): NetworkConfig => {
46
+ export const getDefaultConfig = (networkType: NetworkType = 'testnet'): NetworkConfig => {
15
47
  switch (networkType) {
16
- case 'localnet':
48
+ case 'localnet': {
49
+ const localRpc = encodeURIComponent('http://127.0.0.1:9000');
17
50
  return {
18
51
  fullNode: 'http://127.0.0.1:9000',
19
52
  graphql: 'http://127.0.0.1:9125',
20
53
  network: 'localnet',
21
- txExplorer: 'https://explorer.polymedia.app/txblock/:txHash?network=local',
22
- accountExplorer: 'https://explorer.polymedia.app/address/:address?network=local',
23
- explorer: 'https://explorer.polymedia.app?network=local',
54
+ txExplorer: `https://custom.suiscan.xyz/custom/tx/:txHash?network=${localRpc}`,
55
+ accountExplorer: `https://custom.suiscan.xyz/custom/account/:address?network=${localRpc}`,
56
+ explorer: `https://custom.suiscan.xyz/custom?network=${localRpc}`,
24
57
  indexerUrl: 'http://127.0.0.1:3001',
25
58
  channelUrl: 'http://127.0.0.1:8080'
59
+ // frameworkPackageId: undefined — set after deploying dubhe locally
26
60
  };
61
+ }
27
62
  case 'devnet':
28
63
  return {
29
64
  fullNode: 'https://fullnode.devnet.sui.io:443',
@@ -33,6 +68,7 @@ export const getDefaultURL = (networkType: NetworkType = 'testnet'): NetworkConf
33
68
  explorer: 'https://suiscan.xyz/devnet',
34
69
  indexerUrl: 'http://127.0.0.1:3001',
35
70
  channelUrl: 'http://127.0.0.1:8080'
71
+ // frameworkPackageId: undefined — no persistent deployment on devnet
36
72
  };
37
73
  case 'testnet':
38
74
  return {
@@ -43,7 +79,9 @@ export const getDefaultURL = (networkType: NetworkType = 'testnet'): NetworkConf
43
79
  accountExplorer: 'https://suiscan.xyz/testnet/address/:address',
44
80
  explorer: 'https://suiscan.xyz/testnet',
45
81
  indexerUrl: 'http://127.0.0.1:3001',
46
- channelUrl: 'http://127.0.0.1:8080'
82
+ channelUrl: 'http://127.0.0.1:8080',
83
+ frameworkPackageId: TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID,
84
+ dappHubId: TESTNET_DUBHE_HUB_OBJECT_ID
47
85
  };
48
86
  case 'mainnet':
49
87
  return {
@@ -54,7 +92,9 @@ export const getDefaultURL = (networkType: NetworkType = 'testnet'): NetworkConf
54
92
  accountExplorer: 'https://suiscan.xyz/mainnet/address/:address',
55
93
  explorer: 'https://suiscan.xyz/mainnet',
56
94
  indexerUrl: 'http://127.0.0.1:3001',
57
- channelUrl: 'http://127.0.0.1:8080'
95
+ channelUrl: 'http://127.0.0.1:8080',
96
+ frameworkPackageId: MAINNET_DUBHE_FRAMEWORK_PACKAGE_ID || undefined,
97
+ dappHubId: MAINNET_DUBHE_HUB_OBJECT_ID || undefined
58
98
  };
59
99
  default:
60
100
  return {
@@ -65,7 +105,12 @@ export const getDefaultURL = (networkType: NetworkType = 'testnet'): NetworkConf
65
105
  accountExplorer: 'https://suiscan.xyz/testnet/address/:address',
66
106
  explorer: 'https://suiscan.xyz/testnet',
67
107
  indexerUrl: 'http://127.0.0.1:3001',
68
- channelUrl: 'http://127.0.0.1:8080'
108
+ channelUrl: 'http://127.0.0.1:8080',
109
+ frameworkPackageId: TESTNET_DUBHE_FRAMEWORK_PACKAGE_ID,
110
+ dappHubId: TESTNET_DUBHE_HUB_OBJECT_ID
69
111
  };
70
112
  }
71
113
  };
114
+
115
+ /** @deprecated Use `getDefaultConfig` instead. */
116
+ export const getDefaultURL = getDefaultConfig;
@@ -1,3 +1,3 @@
1
1
  export { SuiInteractor } from './suiInteractor';
2
- export { getDefaultURL } from './defaultConfig';
2
+ export { getDefaultConfig, getDefaultURL } from './defaultConfig';
3
3
  export type { NetworkConfig } from './defaultConfig';
@@ -47,8 +47,22 @@ export type DubheParams = {
47
47
  faucetUrl?: string;
48
48
  networkType?: NetworkType;
49
49
  packageId?: string;
50
+ /**
51
+ * The canonical dapp_key type string, e.g. `"0105c1...::dapp_key::DappKey"`.
52
+ * Stable across all upgrades — derived from the original (genesis) package ID.
53
+ * When provided this value is used directly; otherwise it is computed from packageId
54
+ * (only safe before the first upgrade).
55
+ * Obtain from the generated `DappKey` export in deployment.ts.
56
+ */
57
+ dappKey?: string;
50
58
  metadata?: SuiMoveNormalizedModules;
51
59
  channelUrl?: string;
60
+ /** Published package ID of the dubhe framework. Required for session and user-storage operations. */
61
+ frameworkPackageId?: string;
62
+ /** Object ID of the DappStorage shared object. Stored for convenience; also passed to individual methods. */
63
+ dappStorageId?: string;
64
+ /** Object ID of the DappHub shared object. Required for activate/deactivate session and other DappHub-gated calls. */
65
+ dappHubId?: string;
52
66
  };
53
67
 
54
68
  export type SchemaFieldType = {
@@ -40,11 +40,34 @@ function convertHttpToWebSocket(url: string): string {
40
40
  return url;
41
41
  }
42
42
 
43
+ /**
44
+ * Build the fully-qualified Move type string for a DApp's `DappKey`.
45
+ *
46
+ * The format matches what `std::type_name::get<DappKey>()` returns on-chain:
47
+ * `<64-char-zero-padded-address>::dapp_key::DappKey`
48
+ *
49
+ * @param packageId - The DApp's published package ID (with or without 0x prefix).
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * tx.moveCall({
54
+ * target: `${frameworkPackageId}::dapp_system::settle_writes`,
55
+ * typeArguments: [normalizeDappKey(packageId)],
56
+ * arguments: [...],
57
+ * });
58
+ * ```
59
+ */
60
+ function normalizeDappKey(packageId: string): string {
61
+ const raw = packageId.replace(/^0x/, '');
62
+ return `${raw.padStart(64, '0')}::dapp_key::DappKey`;
63
+ }
64
+
43
65
  export {
44
66
  BasicBcsTypes,
45
67
  capitalizeFirstLetter,
46
68
  normalizeHexAddress,
47
69
  numberToAddressHex,
48
70
  normalizePackageId,
49
- convertHttpToWebSocket
71
+ convertHttpToWebSocket,
72
+ normalizeDappKey
50
73
  };