@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.cjs +256 -374
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -145
- package/dist/index.d.ts +76 -145
- package/dist/index.js +260 -369
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/backend/BackendImpl.ts +106 -111
- package/src/backend/interface.ts +24 -14
- package/src/core/AddressBookSDK.ts +4 -5
- package/src/core/CreateHelper.ts +18 -32
- package/src/core/InvitationSDK.ts +15 -0
- package/src/core/MSafeAccount.ts +30 -17
- package/src/core/MSafeClient.ts +15 -8
- package/src/core/PublicKeyHelper.ts +3 -0
- package/src/core/index.ts +0 -1
- package/src/globals/MSafeGlobals.ts +1 -1
- package/src/globals/const.ts +17 -45
- package/src/types/create.ts +11 -0
- package/src/types/index.ts +1 -4
- package/src/types/msafe.ts +2 -2
- package/src/utils/crypto.ts +1 -32
- package/src/utils/sui.ts +2 -2
- package/src/backend/CoreDatabase.ts +0 -55
- package/src/backend/PseudoBackend.ts +0 -936
- package/src/core/MessageHelper.ts +0 -95
- package/src/types/address-book.ts +0 -32
- package/src/types/backend.ts +0 -19
- package/src/types/creation.ts +0 -19
- package/src/types/pagination.ts +0 -15
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 {
|
|
7
|
-
import
|
|
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:
|
|
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<
|
|
212
|
-
getUserInfo(
|
|
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?:
|
|
215
|
-
getFutureIntentions(msafeAddress: string, paginationOption?:
|
|
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:
|
|
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?:
|
|
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:
|
|
266
|
-
|
|
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?:
|
|
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
|
-
|
|
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:
|
|
327
|
-
validateCreateInfo(createInfo:
|
|
328
|
-
submitMSafeCreation(creationInfo:
|
|
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?:
|
|
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:
|
|
371
|
-
|
|
309
|
+
readonly info: IMSafeConfig;
|
|
310
|
+
multiSig: MultiSigAccount;
|
|
372
311
|
private coinHelper;
|
|
373
|
-
constructor(globals: MSafeGlobals, info:
|
|
374
|
-
static
|
|
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?:
|
|
379
|
-
futureIntentions(paginationOption?:
|
|
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.
|
|
415
|
-
|
|
416
|
-
|
|
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 {
|
|
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 };
|