@msafe/sui3-sdk 0.0.13 → 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.ts 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 { SerializedSignature, PublicKey, 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;
@@ -135,87 +116,28 @@ interface SimulationResult {
135
116
  dryRunResult: DryRunTransactionBlockResponse;
136
117
  }
137
118
 
138
- interface IWallet {
139
- walletType: string;
140
- address(): Promise<string>;
141
- signPersonalMessage(input: {
142
- messageStr: string;
143
- }): Promise<SignatureWithBytes>;
144
- signTransactionBlock(input: {
145
- transactionBlock: TransactionBlock | Uint8Array;
146
- }): Promise<SignatureWithBytes>;
147
- signAndExecuteTransactionBlock(input: {
148
- transactionBlock: TransactionBlock;
149
- requestType?: ExecuteTransactionRequestType;
150
- options?: SuiTransactionBlockResponseOptions;
151
- }): Promise<SuiTransactionBlockResponse>;
152
- }
153
-
154
- interface PagedResult<T> {
155
- data: T[];
156
- meta: PagedMeta;
157
- }
158
- interface PagedMeta {
159
- page: number;
160
- limit: number;
161
- total: number;
162
- hasNext: boolean;
163
- }
164
-
165
- declare enum OpAddressBookType {
166
- Delete = "delete",
167
- Upsert = "upsert"
168
- }
169
- type UpdateAddressBookEntry = DeleteAddressBookEntry | UpsertAddressBookEntry;
170
- interface DeleteAddressBookEntry {
171
- opType: OpAddressBookType.Delete;
172
- address: string;
173
- }
174
- interface UpsertAddressBookEntry {
175
- opType: OpAddressBookType.Upsert;
176
- address: string;
177
- addressName: string;
178
- remark?: string;
179
- }
180
- type GetAddressBookResult = PagedResult<GetAddressBookResultEntry>;
181
- interface GetAddressBookResultEntry {
182
- address: string;
183
- addressName: string;
184
- remark?: string;
185
- updatedAt: Date;
186
- }
187
-
188
- type JWTToken = string;
189
- interface PaginationOption {
190
- page?: number;
191
- limit?: number;
192
- }
193
- interface PaginationResponse<T> {
194
- items: T[];
195
- meta: PaginationMeta;
196
- }
197
- interface PaginationMeta {
198
- totalItems: number;
199
- itemCount: number;
200
- itemsPerPage: number;
201
- totalPages: number;
202
- currentPage: number;
203
- }
204
-
205
119
  interface IBackend {
206
- authSign(input: AuthLoginRequest): Promise<JWTToken>;
120
+ authSign(input: IAuthLoginReq): Promise<JWTToken>;
207
121
  verifyToken(jwt?: JWTToken): Promise<boolean>;
208
122
  setJWTToken(token: JWTToken): void;
209
123
  getPublicKey(address: string): Promise<PublicKey | undefined>;
210
124
  getPublicKeyBatch(addresses: string[]): Promise<(PublicKey | undefined)[]>;
211
- getMSafeAccountInfo(msafeAddress: string): Promise<MSafeAccountInfo>;
212
- 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>;
213
135
  getPendingTransactions(msafeAddress: string): Promise<PendingTx[]>;
214
- getHistoryTransactions(msafeAddress: string, paginationOption?: PaginationOption): Promise<PagedResult<HistoryTransaction>>;
215
- 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>>;
216
138
  getCurrentSequenceNumber(msafeAddress: string): Promise<number>;
217
139
  getNextSequenceNumber(msafeAddress: string): Promise<number>;
218
- createMSafeAccount(input: CreateMSafeAccountInfoRequest): Promise<void>;
140
+ createMSafeAccount(input: ICreateMSafeReq): Promise<void>;
219
141
  proposeIntention(input: ProposeIntention): Promise<void>;
220
142
  proposePendingTransaction(input: {
221
143
  intention: TxIntention;
@@ -244,7 +166,7 @@ interface IBackend {
244
166
  userAddress: string;
245
167
  }): Promise<void>;
246
168
  processExecutedTransaction(digest: string): Promise<void>;
247
- getAddressBookEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
169
+ getAddressBookEntries(pagination?: IPageOptions): Promise<IGetAddressBookResult>;
248
170
  updateAddressBook(input: {
249
171
  updates: UpdateAddressBookEntry[];
250
172
  signature: SerializedSignature;
@@ -262,20 +184,19 @@ interface MSafeConfig {
262
184
  suiClient: {
263
185
  url: string;
264
186
  };
265
- backend: DBConfig;
266
- apiURL: string;
187
+ backend: {
188
+ url: string;
189
+ };
267
190
  syncingURL: string;
268
191
  }
269
192
  interface MSafeConfigOptions {
270
193
  suiClient?: {
271
194
  url?: string;
272
195
  };
273
- backend?: DBConfig;
196
+ backend?: {
197
+ url?: string;
198
+ };
274
199
  }
275
- type DBConfig = ModelConfig;
276
- declare const UNIT_DATABASE_CONFIG: DBConfig;
277
- declare const LOCAL_DATABASE_CONFIG: DBConfig;
278
- declare const DEV_DATABASE_CONFIG: DBConfig;
279
200
  declare const MSAFE_APPLICATION = "msafe";
280
201
  declare const TESTNET_RPC_URL = "https://sui-testnet.blockvision.org/v1/2Sgk89ivT64MnKdcGzjmyjY2ndD";
281
202
  declare const MAINNET_RPC_URL = "https://sui-mainnet.blockvision.org/v1/2Sgk7NPvqkd7mESYkxF01yX15l7";
@@ -285,7 +206,22 @@ declare const DEV_API_URL = "http://13.56.226.148";
285
206
  declare const DEV_SYNCING_URL = "http://52.53.228.20";
286
207
  declare const ENV_CONFIGS: Map<MSafeEnv, MSafeConfig>;
287
208
  declare function getMSafeConfig(env: MSafeEnv, options?: MSafeConfigOptions): MSafeConfig;
288
- 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
+ }
289
225
 
290
226
  declare class MSafeGlobals {
291
227
  readonly backend: IBackend;
@@ -318,40 +254,43 @@ declare class PublicKeyHelper {
318
254
  private getPublicKeyFromChain;
319
255
  }
320
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
+
321
268
  declare class CreateHelper {
322
269
  readonly globals: MSafeGlobals;
323
270
  readonly pkHelper: PublicKeyHelper;
324
271
  constructor(globals: MSafeGlobals, pkHelper: PublicKeyHelper);
325
272
  getPublicKeyBatch(addresses: string[]): Promise<(_mysten_sui_js_src_cryptography.PublicKey | undefined)[]>;
326
- calculateMSafeAddress(info: CreatePermissionInfo): Promise<string>;
327
- validateCreateInfo(createInfo: CreateMSafeAccountInfo): Promise<string>;
328
- submitMSafeCreation(creationInfo: CreateMSafeAccountInfo): Promise<string>;
273
+ calculateMSafeAddress(info: CreateMSafeInfo): Promise<string>;
274
+ validateCreateInfo(createInfo: CreateMSafeInfo): Promise<string>;
275
+ submitMSafeCreation(creationInfo: CreateMSafeInfo): Promise<string>;
329
276
  private reduceCreationInfoToRawConfig;
330
277
  private submitToBackend;
331
278
  }
332
279
 
333
- declare class MessageHelper {
334
- static createMSafeMessage(msafeAddress: string): string;
335
- static deCreateMSafeMessage(msg: string): string | undefined;
336
- static welcomeMessage(timestamp: string): string;
337
- static deWelcomeMessage(msg: string): string | undefined;
338
- static proposeIntentionMessage(data: ProposeIntentionData): string;
339
- static deProposeIntentionMessage(s: string): ProposeIntentionData;
340
- static updateAddressBookMessage(updates: UpdateAddressBookEntry[]): string;
341
- }
342
- interface ProposeIntentionData {
343
- msafeAddress: string;
344
- intention: TxIntention;
345
- sn: number;
346
- }
347
-
348
280
  declare class AddressBookSDK {
349
281
  readonly globals: MSafeGlobals;
350
282
  constructor(globals: MSafeGlobals);
351
- getEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
283
+ getEntries(pagination?: IPageOptions): Promise<_msafe_sui3_utils.IGetAddressBookResult>;
352
284
  update(updates: UpdateAddressBookEntry[]): Promise<void>;
353
285
  }
354
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
+
355
294
  interface OwnedCoin {
356
295
  type: string;
357
296
  balance: bigint;
@@ -367,16 +306,16 @@ interface BatchObjectOptions {
367
306
 
368
307
  declare class MSafeAccount {
369
308
  readonly globals: MSafeGlobals;
370
- readonly info: MSafeAccountInfo;
371
- multisigManager: MultisigAccountManager;
309
+ readonly info: IMSafeConfig;
310
+ multiSig: MultiSigAccount;
372
311
  private coinHelper;
373
- constructor(globals: MSafeGlobals, info: MSafeAccountInfo);
374
- static new(globals: MSafeGlobals, address: string): Promise<MSafeAccountInfo>;
312
+ constructor(globals: MSafeGlobals, info: IMSafeConfig);
313
+ static New(globals: MSafeGlobals, address: string): Promise<void>;
375
314
  ownedCoins(): Promise<OwnedCoin[]>;
376
315
  ownedObjects(options?: BatchObjectOptions): Promise<SuiObjectData[]>;
377
316
  pendingTransaction(): Promise<PendingTx | undefined>;
378
- historyTransaction(paginationOption?: PaginationOption): Promise<PagedResult<_msafe_sui3_utils.HistoryTransaction>>;
379
- futureIntentions(paginationOption?: PaginationOption): Promise<FutureIntention[]>;
317
+ historyTransaction(paginationOption?: IPageOptions): Promise<_msafe_sui3_utils.IPagedResult<_msafe_sui3_utils.HistoryTransaction>>;
318
+ futureIntentions(paginationOption?: IPageOptions): Promise<FutureIntention[]>;
380
319
  currentSequenceNumber(): Promise<number>;
381
320
  nextSequenceNumber(): Promise<number>;
382
321
  proposeIntention(input: {
@@ -411,9 +350,10 @@ declare class MSafeClient {
411
350
  jwtToken?: JWTToken;
412
351
  }): Promise<JWTToken>;
413
352
  private authSign;
414
- userInfo(): Promise<_msafe_sui3_utils.UserWithOwnedMSafe>;
415
- createAccount(info: CreateMSafeAccountInfo): Promise<string>;
416
- 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;
417
357
  getMSafeAccountFromAddress(msafeAddress: string): Promise<MSafeAccount>;
418
358
  get creationHelper(): CreateHelper;
419
359
  get publicKeyHelper(): PublicKeyHelper;
@@ -421,6 +361,7 @@ declare class MSafeClient {
421
361
  get backend(): IBackend;
422
362
  get wallet(): IWallet;
423
363
  get AddressBook(): AddressBookSDK;
364
+ get Invitation(): InvitationSDK;
424
365
  private walletAddress;
425
366
  }
426
367
 
@@ -433,11 +374,11 @@ declare class SignatureVerifier {
433
374
  message: Uint8Array;
434
375
  messageType: 'TransactionBlock' | 'Personal';
435
376
  signature: SerializedSignature;
436
- }): Promise<PublicKey>;
377
+ }): Promise<_mysten_sui_js_cryptography.PublicKey>;
437
378
  static getPublicKeyFromPersonalSignature(input: {
438
379
  messageStr: string;
439
380
  signature: SerializedSignature;
440
- }): Promise<PublicKey>;
381
+ }): Promise<_mysten_sui_js_cryptography.PublicKey>;
441
382
  static verifySignature(input: {
442
383
  message: Uint8Array;
443
384
  messageType: 'TransactionBlock' | 'Personal';
@@ -455,16 +396,6 @@ declare class SignatureVerifier {
455
396
  targetAddress: string;
456
397
  }): Promise<boolean>;
457
398
  }
458
- declare class PublicKeySerde {
459
- static ser(publicKey: PublicKey): {
460
- publicKey: string;
461
- scheme: "ED25519" | "Secp256k1" | "Secp256r1" | "MultiSig" | "ZkLogin";
462
- };
463
- static de(input: {
464
- publicKey: string | Uint8Array;
465
- scheme: SignatureScheme;
466
- }): PublicKey;
467
- }
468
399
 
469
400
  declare class Formatter {
470
401
  static normalizeSuiAddress(addr: string): string;
@@ -496,4 +427,4 @@ declare class Coin {
496
427
  static getBalance(data: SuiObjectData): bigint | undefined;
497
428
  }
498
429
 
499
- 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, type ProposeIntention, 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 };