@0xobelisk/sui-client 1.2.0-pre.11 → 1.2.0-pre.110

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.
Files changed (60) hide show
  1. package/README.md +7 -8
  2. package/dist/dubhe.d.ts +70 -76
  3. package/dist/index.d.ts +1 -2
  4. package/dist/index.js +988 -901
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1063 -986
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/libs/dubheChannel/client.d.ts +66 -0
  9. package/dist/libs/dubheChannel/examples.d.ts +39 -0
  10. package/dist/libs/dubheChannel/index.d.ts +2 -0
  11. package/dist/libs/dubheChannel/types.d.ts +52 -0
  12. package/dist/libs/suiContractFactory/index.d.ts +1 -1
  13. package/dist/libs/suiInteractor/defaultConfig.d.ts +1 -0
  14. package/dist/libs/suiInteractor/suiInteractor.d.ts +8 -4
  15. package/dist/libs/suiTxBuilder/index.d.ts +4 -4
  16. package/dist/types/index.d.ts +3 -21
  17. package/dist/utils/const.d.ts +2 -0
  18. package/dist/utils/index.d.ts +7 -5
  19. package/package.json +28 -89
  20. package/src/dubhe.ts +796 -623
  21. package/src/errors/index.ts +2 -4
  22. package/src/index.ts +1 -12
  23. package/src/libs/dubheChannel/README.md +385 -0
  24. package/src/libs/dubheChannel/client.ts +303 -0
  25. package/src/libs/dubheChannel/examples.ts +272 -0
  26. package/src/libs/dubheChannel/index.ts +11 -0
  27. package/src/libs/dubheChannel/types.ts +61 -0
  28. package/src/libs/multiSig/client.ts +2 -2
  29. package/src/libs/suiAccountManager/index.ts +4 -13
  30. package/src/libs/suiAccountManager/keypair.ts +3 -12
  31. package/src/libs/suiAccountManager/util.ts +1 -2
  32. package/src/libs/suiContractFactory/index.ts +27 -33
  33. package/src/libs/suiContractFactory/types.ts +1 -4
  34. package/src/libs/suiInteractor/defaultConfig.ts +9 -7
  35. package/src/libs/suiInteractor/suiInteractor.ts +36 -54
  36. package/src/libs/suiInteractor/util.ts +1 -2
  37. package/src/libs/suiModel/suiOwnedObject.ts +3 -3
  38. package/src/libs/suiModel/suiSharedObject.ts +4 -8
  39. package/src/libs/suiTxBuilder/index.ts +23 -83
  40. package/src/libs/suiTxBuilder/util.ts +11 -33
  41. package/src/metadata/index.ts +1 -2
  42. package/src/types/index.ts +7 -39
  43. package/src/utils/const.ts +91 -0
  44. package/src/utils/index.ts +16 -5
  45. package/dist/libs/http/errors.d.ts +0 -28
  46. package/dist/libs/http/http.d.ts +0 -22
  47. package/dist/libs/http/index.d.ts +0 -4
  48. package/dist/libs/http/types.d.ts +0 -1
  49. package/dist/libs/http/ws-adapter.d.ts +0 -6
  50. package/dist/libs/suiIndexerClient/index.d.ts +0 -121
  51. package/dist/libs/suiIndexerClient/types.d.ts +0 -0
  52. package/dist/libs/suiIndexerClient/utils.d.ts +0 -2
  53. package/src/libs/http/errors.ts +0 -126
  54. package/src/libs/http/http.ts +0 -151
  55. package/src/libs/http/index.ts +0 -4
  56. package/src/libs/http/types.ts +0 -1
  57. package/src/libs/http/ws-adapter.ts +0 -36
  58. package/src/libs/suiIndexerClient/index.ts +0 -333
  59. package/src/libs/suiIndexerClient/types.ts +0 -0
  60. 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, SubscribableType, IndexerTransactionResult } from './types';
11
- import { ConnectionResponse, IndexerTransaction, IndexerEvent, IndexerSchema, SuiIndexerClient, StorageResponse, StorageItemResponse, JsonPathOrder } from './libs/suiIndexerClient';
12
- import { Http } from './libs/http';
10
+ import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, DubheParams, SuiTxArg, SuiObjectArg, SuiVecTxArg } 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,11 +19,10 @@ 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;
29
27
  metadata: SuiMoveNormalizedModules | undefined;
30
28
  projectName: string | undefined;
@@ -39,91 +37,27 @@ export declare class Dubhe {
39
37
  * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
40
38
  * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
41
39
  * @param packageId
40
+ * @param metadata
41
+ * @param channelUrl, the base URL for Dubhe Channel API, optional
42
42
  */
43
- constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, customFetch, defaultOptions, indexerUrl, indexerWsUrl, }?: DubheParams);
43
+ constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, channelUrl }?: DubheParams);
44
44
  get query(): MapMoudleFuncQuery;
45
45
  get tx(): MapMoudleFuncTx;
46
46
  get object(): MapObjectStruct;
47
47
  view(dryResult: DevInspectResults): any[];
48
- state({ tx, schema, params, customModuleName, }: {
48
+ state({ tx, schema, params, customModuleName }: {
49
49
  tx: Transaction;
50
50
  schema: string;
51
51
  params: any[];
52
52
  customModuleName?: string;
53
53
  }): Promise<any[] | undefined>;
54
- parseState({ schema, objectId, storageType, params, customModuleName, }: {
54
+ parseState({ schema, objectId, storageType, params, customModuleName }: {
55
55
  schema: string;
56
56
  objectId: string;
57
57
  storageType: string;
58
58
  params: any[];
59
59
  customModuleName?: string;
60
60
  }): 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
61
  /**
128
62
  * else:
129
63
  * it will generate signer from the mnemonic with the given derivePathParams.
@@ -148,6 +82,11 @@ export declare class Dubhe {
148
82
  getTxExplorerUrl(txHash: string): string;
149
83
  getAccountExplorerUrl(address: string): string;
150
84
  getExplorerUrl(): string;
85
+ /**
86
+ * Update configuration dynamically without recreating the entire instance
87
+ * @param config - Partial configuration to update (same type as constructor)
88
+ */
89
+ updateConfig(config: Partial<DubheParams>): void;
151
90
  /**
152
91
  * Request some SUI from faucet
153
92
  * @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
@@ -156,11 +95,10 @@ export declare class Dubhe {
156
95
  getBalance(coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
157
96
  balanceOf(accountAddress?: string, coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/client").CoinBalance>;
158
97
  client(): import("@mysten/sui/client").SuiClient;
159
- indexerClient(): SuiIndexerClient;
160
98
  getObject(objectId: string): Promise<SuiObjectData>;
161
99
  getObjects(objectIds: string[]): Promise<SuiObjectData[]>;
162
100
  signTxn(tx: Uint8Array | Transaction | SuiTx, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui/dist/cjs/cryptography").SignatureWithBytes>;
163
- signAndSendTxn({ tx, derivePathParams, onSuccess, onError, }: {
101
+ signAndSendTxn({ tx, derivePathParams, onSuccess, onError }: {
164
102
  tx: Uint8Array | Transaction | SuiTx;
165
103
  derivePathParams?: DerivePathParams;
166
104
  onSuccess?: (result: SuiTransactionBlockResponse) => void | Promise<void>;
@@ -168,6 +106,62 @@ export declare class Dubhe {
168
106
  }): Promise<SuiTransactionBlockResponse>;
169
107
  sendTx(transaction: Uint8Array | string, signature: string | string[]): Promise<SuiTransactionBlockResponse>;
170
108
  waitForTransaction(digest: string): Promise<SuiTransactionBlockResponse>;
109
+ submitToChannel({ tx, nonce, chainType }: {
110
+ tx: Transaction;
111
+ nonce: number;
112
+ chainType?: string;
113
+ }): Promise<any>;
114
+ queryChannelTable({ packageId, account, table, key }: {
115
+ packageId?: string;
116
+ account?: string;
117
+ table: string;
118
+ key: any[];
119
+ }): Promise<any>;
120
+ /**
121
+ * Subscribe to channel table updates via Server-Sent Events
122
+ * @param params - Subscription parameters
123
+ * @param options - Event handlers for the subscription
124
+ * @returns Unsubscribe function
125
+ *
126
+ * @example
127
+ * // Subscribe to all tables and accounts (only dapp_key)
128
+ * const unsubscribe = await dubhe.subscribeChannelTable(
129
+ * {},
130
+ * { onMessage: (data) => console.log(data) }
131
+ * );
132
+ *
133
+ * // Subscribe to all tables for a specific account
134
+ * const unsubscribe = await dubhe.subscribeChannelTable(
135
+ * { account: '0xabc...' },
136
+ * { onMessage: (data) => console.log(data) }
137
+ * );
138
+ *
139
+ * // Subscribe to a specific table for a specific account
140
+ * const unsubscribe = await dubhe.subscribeChannelTable(
141
+ * { account: '0xabc...', table: 'position' },
142
+ * { onMessage: (data) => console.log(data) }
143
+ * );
144
+ *
145
+ * // Subscribe to a specific table, account, and key
146
+ * const unsubscribe = await dubhe.subscribeChannelTable(
147
+ * { account: '0xabc...', table: 'position', key: [] },
148
+ * { onMessage: (data) => console.log(data) }
149
+ * );
150
+ */
151
+ subscribeChannelTable({ packageId, account, table, key }?: {
152
+ packageId?: string;
153
+ account?: string;
154
+ table?: string;
155
+ key?: any[];
156
+ }, options?: {
157
+ onMessage?: (data: any) => void;
158
+ onError?: (error: Error) => void;
159
+ onOpen?: () => void;
160
+ onClose?: () => void;
161
+ }): Promise<() => void>;
162
+ latestNonce({ account }?: {
163
+ account?: string;
164
+ }): Promise<number>;
171
165
  /**
172
166
  * Transfer the given amount of SUI to the recipient
173
167
  * @param recipient
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,5 @@ 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 type { IndexerEvent, IndexerSchema, IndexerTransaction, ConnectionResponse, StorageResponse, StorageItemResponse, PageInfo, JsonPathOrder, JsonValueType, } from './libs/suiIndexerClient';