@msafe/sui3-sdk 0.0.12 → 0.0.14

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/index.d.cts CHANGED
@@ -3,10 +3,10 @@ import { PublicKey as PublicKey$1 } from '@mysten/sui.js/src/cryptography';
3
3
  import * as _mysten_sui_js_client from '@mysten/sui.js/client';
4
4
  import { SuiClient, GasCostSummary, DryRunTransactionBlockResponse, ExecuteTransactionRequestType, SuiTransactionBlockResponseOptions, SuiTransactionBlockResponse, CoinMetadata, SuiObjectDataOptions, SuiObjectResponse, SuiObjectData, CoinStruct } from '@mysten/sui.js/client';
5
5
  import * as _msafe_sui3_utils from '@msafe/sui3-utils';
6
- import { AuthLoginRequest, MSafeAccountInfo, UserWithOwnedMSafe, HistoryTransaction, CreateMSafeAccountInfoRequest, MultisigAccountManager } from '@msafe/sui3-utils';
7
- import { PublicKey, SerializedSignature, SignatureScheme } from '@mysten/sui.js/cryptography';
6
+ import { IAuthLoginReq, JWTToken, IMSafeInfoResp, IUserInfoResp, UserMSafeStatus, IPageOptions, IPagedResult, HistoryTransaction, ICreateMSafeReq, IGetAddressBookResult, UpdateAddressBookEntry, IMSafeConfig, MultiSigAccount } from '@msafe/sui3-utils';
7
+ import * as _mysten_sui_js_cryptography from '@mysten/sui.js/cryptography';
8
+ import { SerializedSignature, PublicKey } from '@mysten/sui.js/cryptography';
8
9
  import * as _mysten_sui_js_dist_cjs_builder from '@mysten/sui.js/dist/cjs/builder';
9
- import { ModelConfig } from '@msafe/sui3-model/common';
10
10
  import { SignatureWithBytes } from '@mysten/sui.js/src/cryptography/keypair';
11
11
  import { TransactionBlock } from '@mysten/sui.js/transactions';
12
12
 
@@ -43,25 +43,6 @@ declare class IntentionHelper {
43
43
  }): Promise<_mysten_sui_js_dist_cjs_builder.TransactionBlock>;
44
44
  }
45
45
 
46
- interface CreateMSafeAccountInfo {
47
- ownerWithWeight: {
48
- address: string;
49
- weight: number;
50
- }[];
51
- threshold: number;
52
- name: string;
53
- description?: string;
54
- creationNonce: number;
55
- }
56
- interface CreatePermissionInfo {
57
- ownerWithWeight: {
58
- address: string;
59
- weight: number;
60
- }[];
61
- threshold: number;
62
- creationNonce: number;
63
- }
64
-
65
46
  interface PendingTx {
66
47
  digest: string;
67
48
  payload: string;
@@ -117,6 +98,16 @@ interface FutureIntention {
117
98
  statusRemark?: string;
118
99
  createdAt: Date;
119
100
  }
101
+ interface ProposeIntention {
102
+ application: string;
103
+ txType: string;
104
+ txSubType: string;
105
+ intention: TxIntention;
106
+ sequenceNumber: number;
107
+ userAddress: string;
108
+ msafeAddress: string;
109
+ signature: SerializedSignature;
110
+ }
120
111
  interface SimulationResult {
121
112
  success: boolean;
122
113
  errorMsg?: string;
@@ -125,97 +116,29 @@ interface SimulationResult {
125
116
  dryRunResult: DryRunTransactionBlockResponse;
126
117
  }
127
118
 
128
- interface IWallet {
129
- walletType: string;
130
- address(): Promise<string>;
131
- signPersonalMessage(input: {
132
- messageStr: string;
133
- }): Promise<SignatureWithBytes>;
134
- signTransactionBlock(input: {
135
- transactionBlock: TransactionBlock | Uint8Array;
136
- }): Promise<SignatureWithBytes>;
137
- signAndExecuteTransactionBlock(input: {
138
- transactionBlock: TransactionBlock;
139
- requestType?: ExecuteTransactionRequestType;
140
- options?: SuiTransactionBlockResponseOptions;
141
- }): Promise<SuiTransactionBlockResponse>;
142
- }
143
-
144
- interface PagedResult<T> {
145
- data: T[];
146
- meta: PagedMeta;
147
- }
148
- interface PagedMeta {
149
- page: number;
150
- limit: number;
151
- total: number;
152
- hasNext: boolean;
153
- }
154
-
155
- declare enum OpAddressBookType {
156
- Delete = "delete",
157
- Upsert = "upsert"
158
- }
159
- type UpdateAddressBookEntry = DeleteAddressBookEntry | UpsertAddressBookEntry;
160
- interface DeleteAddressBookEntry {
161
- opType: OpAddressBookType.Delete;
162
- address: string;
163
- }
164
- interface UpsertAddressBookEntry {
165
- opType: OpAddressBookType.Upsert;
166
- address: string;
167
- addressName: string;
168
- remark?: string;
169
- }
170
- type GetAddressBookResult = PagedResult<GetAddressBookResultEntry>;
171
- interface GetAddressBookResultEntry {
172
- address: string;
173
- addressName: string;
174
- remark?: string;
175
- updatedAt: Date;
176
- }
177
-
178
- type JWTToken = string;
179
- interface PaginationOption {
180
- page?: number;
181
- limit?: number;
182
- }
183
- interface PaginationResponse<T> {
184
- items: T[];
185
- meta: PaginationMeta;
186
- }
187
- interface PaginationMeta {
188
- totalItems: number;
189
- itemCount: number;
190
- itemsPerPage: number;
191
- totalPages: number;
192
- currentPage: number;
193
- }
194
-
195
119
  interface IBackend {
196
- authSign(input: AuthLoginRequest): Promise<JWTToken>;
120
+ authSign(input: IAuthLoginReq): Promise<JWTToken>;
197
121
  verifyToken(jwt?: JWTToken): Promise<boolean>;
198
122
  setJWTToken(token: JWTToken): void;
199
123
  getPublicKey(address: string): Promise<PublicKey | undefined>;
200
124
  getPublicKeyBatch(addresses: string[]): Promise<(PublicKey | undefined)[]>;
201
- getMSafeAccountInfo(msafeAddress: string): Promise<MSafeAccountInfo>;
202
- getUserInfo(userAddress: string): Promise<UserWithOwnedMSafe>;
125
+ getMSafeAccountInfo(msafeAddress: string): Promise<IMSafeInfoResp>;
126
+ getUserInfo(): Promise<IUserInfoResp>;
127
+ getOwnedMSafeByStatus(input: {
128
+ status?: UserMSafeStatus;
129
+ pagination?: IPageOptions;
130
+ }): Promise<IPagedResult<IMSafeInfoResp>>;
131
+ updateMSafeStatus(input: {
132
+ msafeAddress: string;
133
+ status: UserMSafeStatus;
134
+ }): Promise<void>;
203
135
  getPendingTransactions(msafeAddress: string): Promise<PendingTx[]>;
204
- getHistoryTransactions(msafeAddress: string, paginationOption?: PaginationOption): Promise<PagedResult<HistoryTransaction>>;
205
- getFutureIntentions(msafeAddress: string, paginationOption?: PaginationOption): Promise<PagedResult<FutureIntention>>;
136
+ getHistoryTransactions(msafeAddress: string, paginationOption?: IPageOptions): Promise<IPagedResult<HistoryTransaction>>;
137
+ getFutureIntentions(msafeAddress: string, paginationOption?: IPageOptions): Promise<IPagedResult<FutureIntention>>;
206
138
  getCurrentSequenceNumber(msafeAddress: string): Promise<number>;
207
139
  getNextSequenceNumber(msafeAddress: string): Promise<number>;
208
- createMSafeAccount(input: CreateMSafeAccountInfoRequest): Promise<void>;
209
- proposeIntention(input: {
210
- intention: TxIntention;
211
- sequenceNumber: number;
212
- userAddress: string;
213
- msafeAddress: string;
214
- signature: SerializedSignature;
215
- application: string;
216
- txType: string;
217
- txSubType: string;
218
- }): Promise<void>;
140
+ createMSafeAccount(input: ICreateMSafeReq): Promise<void>;
141
+ proposeIntention(input: ProposeIntention): Promise<void>;
219
142
  proposePendingTransaction(input: {
220
143
  intention: TxIntention;
221
144
  userAddress: string;
@@ -243,7 +166,7 @@ interface IBackend {
243
166
  userAddress: string;
244
167
  }): Promise<void>;
245
168
  processExecutedTransaction(digest: string): Promise<void>;
246
- getAddressBookEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
169
+ getAddressBookEntries(pagination?: IPageOptions): Promise<IGetAddressBookResult>;
247
170
  updateAddressBook(input: {
248
171
  updates: UpdateAddressBookEntry[];
249
172
  signature: SerializedSignature;
@@ -261,20 +184,19 @@ interface MSafeConfig {
261
184
  suiClient: {
262
185
  url: string;
263
186
  };
264
- backend: DBConfig;
265
- apiURL: string;
187
+ backend: {
188
+ url: string;
189
+ };
266
190
  syncingURL: string;
267
191
  }
268
192
  interface MSafeConfigOptions {
269
193
  suiClient?: {
270
194
  url?: string;
271
195
  };
272
- backend?: DBConfig;
196
+ backend?: {
197
+ url?: string;
198
+ };
273
199
  }
274
- type DBConfig = ModelConfig;
275
- declare const UNIT_DATABASE_CONFIG: DBConfig;
276
- declare const LOCAL_DATABASE_CONFIG: DBConfig;
277
- declare const DEV_DATABASE_CONFIG: DBConfig;
278
200
  declare const MSAFE_APPLICATION = "msafe";
279
201
  declare const TESTNET_RPC_URL = "https://sui-testnet.blockvision.org/v1/2Sgk89ivT64MnKdcGzjmyjY2ndD";
280
202
  declare const MAINNET_RPC_URL = "https://sui-mainnet.blockvision.org/v1/2Sgk7NPvqkd7mESYkxF01yX15l7";
@@ -284,7 +206,22 @@ declare const DEV_API_URL = "http://13.56.226.148";
284
206
  declare const DEV_SYNCING_URL = "http://52.53.228.20";
285
207
  declare const ENV_CONFIGS: Map<MSafeEnv, MSafeConfig>;
286
208
  declare function getMSafeConfig(env: MSafeEnv, options?: MSafeConfigOptions): MSafeConfig;
287
- declare const AUTH_SIGN_MESSAGE = "Welcome to MSafe";
209
+
210
+ interface IWallet {
211
+ walletType: string;
212
+ address(): Promise<string>;
213
+ signPersonalMessage(input: {
214
+ messageStr: string;
215
+ }): Promise<SignatureWithBytes>;
216
+ signTransactionBlock(input: {
217
+ transactionBlock: TransactionBlock | Uint8Array;
218
+ }): Promise<SignatureWithBytes>;
219
+ signAndExecuteTransactionBlock(input: {
220
+ transactionBlock: TransactionBlock;
221
+ requestType?: ExecuteTransactionRequestType;
222
+ options?: SuiTransactionBlockResponseOptions;
223
+ }): Promise<SuiTransactionBlockResponse>;
224
+ }
288
225
 
289
226
  declare class MSafeGlobals {
290
227
  readonly backend: IBackend;
@@ -317,40 +254,43 @@ declare class PublicKeyHelper {
317
254
  private getPublicKeyFromChain;
318
255
  }
319
256
 
257
+ interface CreateMSafeInfo {
258
+ name: string;
259
+ description?: string;
260
+ owners: {
261
+ address: string;
262
+ weight: number;
263
+ }[];
264
+ creationNonce: number;
265
+ threshold: number;
266
+ }
267
+
320
268
  declare class CreateHelper {
321
269
  readonly globals: MSafeGlobals;
322
270
  readonly pkHelper: PublicKeyHelper;
323
271
  constructor(globals: MSafeGlobals, pkHelper: PublicKeyHelper);
324
272
  getPublicKeyBatch(addresses: string[]): Promise<(_mysten_sui_js_src_cryptography.PublicKey | undefined)[]>;
325
- calculateMSafeAddress(info: CreatePermissionInfo): Promise<string>;
326
- validateCreateInfo(createInfo: CreateMSafeAccountInfo): Promise<string>;
327
- submitMSafeCreation(creationInfo: CreateMSafeAccountInfo): Promise<string>;
273
+ calculateMSafeAddress(info: CreateMSafeInfo): Promise<string>;
274
+ validateCreateInfo(createInfo: CreateMSafeInfo): Promise<string>;
275
+ submitMSafeCreation(creationInfo: CreateMSafeInfo): Promise<string>;
328
276
  private reduceCreationInfoToRawConfig;
329
277
  private submitToBackend;
330
278
  }
331
279
 
332
- declare class MessageHelper {
333
- static createMSafeMessage(msafeAddress: string): string;
334
- static deCreateMSafeMessage(msg: string): string | undefined;
335
- static welcomeMessage(timestamp: string): string;
336
- static deWelcomeMessage(msg: string): string | undefined;
337
- static proposeIntentionMessage(data: ProposeIntentionData): string;
338
- static deProposeIntentionMessage(s: string): ProposeIntentionData;
339
- static updateAddressBookMessage(updates: UpdateAddressBookEntry[]): string;
340
- }
341
- interface ProposeIntentionData {
342
- msafeAddress: string;
343
- intention: TxIntention;
344
- sn: number;
345
- }
346
-
347
280
  declare class AddressBookSDK {
348
281
  readonly globals: MSafeGlobals;
349
282
  constructor(globals: MSafeGlobals);
350
- getEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
283
+ getEntries(pagination?: IPageOptions): Promise<_msafe_sui3_utils.IGetAddressBookResult>;
351
284
  update(updates: UpdateAddressBookEntry[]): Promise<void>;
352
285
  }
353
286
 
287
+ declare class InvitationSDK {
288
+ readonly globals: MSafeGlobals;
289
+ constructor(globals: MSafeGlobals);
290
+ getMSafeByStatus(status: UserMSafeStatus, pagination?: IPageOptions): Promise<_msafe_sui3_utils.IPagedResult<_msafe_sui3_utils.IMSafeInfoResp>>;
291
+ updateMSafeStatus(msafeAddress: string, status: UserMSafeStatus): Promise<void>;
292
+ }
293
+
354
294
  interface OwnedCoin {
355
295
  type: string;
356
296
  balance: bigint;
@@ -366,19 +306,25 @@ interface BatchObjectOptions {
366
306
 
367
307
  declare class MSafeAccount {
368
308
  readonly globals: MSafeGlobals;
369
- readonly info: MSafeAccountInfo;
370
- multisigManager: MultisigAccountManager;
309
+ readonly info: IMSafeConfig;
310
+ multiSig: MultiSigAccount;
371
311
  private coinHelper;
372
- constructor(globals: MSafeGlobals, info: MSafeAccountInfo);
373
- static new(globals: MSafeGlobals, address: string): Promise<MSafeAccountInfo>;
312
+ constructor(globals: MSafeGlobals, info: IMSafeConfig);
313
+ static New(globals: MSafeGlobals, address: string): Promise<void>;
374
314
  ownedCoins(): Promise<OwnedCoin[]>;
375
315
  ownedObjects(options?: BatchObjectOptions): Promise<SuiObjectData[]>;
376
316
  pendingTransaction(): Promise<PendingTx | undefined>;
377
- historyTransaction(paginationOption?: PaginationOption): Promise<PagedResult<_msafe_sui3_utils.HistoryTransaction>>;
378
- futureIntentions(paginationOption?: PaginationOption): Promise<FutureIntention[]>;
317
+ historyTransaction(paginationOption?: IPageOptions): Promise<_msafe_sui3_utils.IPagedResult<_msafe_sui3_utils.HistoryTransaction>>;
318
+ futureIntentions(paginationOption?: IPageOptions): Promise<FutureIntention[]>;
379
319
  currentSequenceNumber(): Promise<number>;
380
320
  nextSequenceNumber(): Promise<number>;
381
- proposeIntention(intention: TxIntention, sequenceNumber: number): Promise<void>;
321
+ proposeIntention(input: {
322
+ application: string;
323
+ txType: string;
324
+ txSubType: string;
325
+ intention: TxIntention;
326
+ sequenceNumber: number;
327
+ }): Promise<void>;
382
328
  voteForTransaction(digest: string, payload: string): Promise<void>;
383
329
  proposePendingTransaction(intention: TxIntention): Promise<void>;
384
330
  rejectCurrentTx(pending?: PendingTx): Promise<void>;
@@ -404,9 +350,10 @@ declare class MSafeClient {
404
350
  jwtToken?: JWTToken;
405
351
  }): Promise<JWTToken>;
406
352
  private authSign;
407
- userInfo(): Promise<_msafe_sui3_utils.UserWithOwnedMSafe>;
408
- createAccount(info: CreateMSafeAccountInfo): Promise<string>;
409
- getMSafeAccount(info: MSafeAccountInfo): MSafeAccount;
353
+ userInfo(): Promise<_msafe_sui3_utils.IUserInfoResp>;
354
+ ownedMSafe(pagination?: IPageOptions): Promise<_msafe_sui3_utils.IPagedResult<_msafe_sui3_utils.IMSafeInfoResp>>;
355
+ createAccount(info: CreateMSafeInfo): Promise<string>;
356
+ getMSafeAccount(info: IMSafeConfig): MSafeAccount;
410
357
  getMSafeAccountFromAddress(msafeAddress: string): Promise<MSafeAccount>;
411
358
  get creationHelper(): CreateHelper;
412
359
  get publicKeyHelper(): PublicKeyHelper;
@@ -414,6 +361,7 @@ declare class MSafeClient {
414
361
  get backend(): IBackend;
415
362
  get wallet(): IWallet;
416
363
  get AddressBook(): AddressBookSDK;
364
+ get Invitation(): InvitationSDK;
417
365
  private walletAddress;
418
366
  }
419
367
 
@@ -426,11 +374,11 @@ declare class SignatureVerifier {
426
374
  message: Uint8Array;
427
375
  messageType: 'TransactionBlock' | 'Personal';
428
376
  signature: SerializedSignature;
429
- }): Promise<PublicKey>;
377
+ }): Promise<_mysten_sui_js_cryptography.PublicKey>;
430
378
  static getPublicKeyFromPersonalSignature(input: {
431
379
  messageStr: string;
432
380
  signature: SerializedSignature;
433
- }): Promise<PublicKey>;
381
+ }): Promise<_mysten_sui_js_cryptography.PublicKey>;
434
382
  static verifySignature(input: {
435
383
  message: Uint8Array;
436
384
  messageType: 'TransactionBlock' | 'Personal';
@@ -448,16 +396,6 @@ declare class SignatureVerifier {
448
396
  targetAddress: string;
449
397
  }): Promise<boolean>;
450
398
  }
451
- declare class PublicKeySerde {
452
- static ser(publicKey: PublicKey): {
453
- publicKey: string;
454
- scheme: "ED25519" | "Secp256k1" | "Secp256r1" | "MultiSig" | "ZkLogin";
455
- };
456
- static de(input: {
457
- publicKey: string | Uint8Array;
458
- scheme: SignatureScheme;
459
- }): PublicKey;
460
- }
461
399
 
462
400
  declare class Formatter {
463
401
  static normalizeSuiAddress(addr: string): string;
@@ -489,4 +427,4 @@ declare class Coin {
489
427
  static getBalance(data: SuiObjectData): bigint | undefined;
490
428
  }
491
429
 
492
- export { AUTH_SIGN_MESSAGE, AddressBookSDK, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeAccountInfo, type CreatePermissionInfo, type DBConfig, DEV_API_URL, DEV_DATABASE_CONFIG, DEV_SYNCING_URL, type DeleteAddressBookEntry, ENV_CONFIGS, Formatter, type FutureIntention, type GetAddressBookResult, type GetAddressBookResultEntry, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, type IntentionCoinTransfer, IntentionHelper, type IntentionObjectTransfer, type JWTToken, LOCAL_API_URL, LOCAL_DATABASE_CONFIG, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSAFE_APPLICATION, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnv, MSafeGlobals, MessageHelper, OpAddressBookType, type PagedMeta, type PagedResult, type PaginationMeta, type PaginationOption, type PaginationResponse, type PendingTx, type PendingVote, PublicKeySerde, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulationResult, TESTNET_RPC_URL, type TxIntention, UNIT_DATABASE_CONFIG, Uint8ArrayToHex, type UpdateAddressBookEntry, type UpsertAddressBookEntry, getAllCoins, getMSafeConfig, getPublicKeyFromChain, stringToBuffer };
430
+ export { AddressBookSDK, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeInfo, DEV_API_URL, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, type IntentionCoinTransfer, IntentionHelper, type IntentionObjectTransfer, LOCAL_API_URL, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSAFE_APPLICATION, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnv, MSafeGlobals, type PendingTx, type PendingVote, type ProposeIntention, type ReceiveTransaction, SUI_COIN, SignatureVerifier, type SimulationResult, TESTNET_RPC_URL, type TxIntention, Uint8ArrayToHex, getAllCoins, getMSafeConfig, getPublicKeyFromChain, stringToBuffer };