@msafe/sui3-sdk 0.0.9 → 0.0.10
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 +68 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -53
- package/dist/index.d.ts +101 -53
- package/dist/index.js +66 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
- package/src/backend/BackendImpl.ts +22 -3
- package/src/backend/PseudoBackend.ts +18 -1
- package/src/backend/interface.ts +5 -1
- package/src/core/AddressBookSDK.ts +18 -0
- package/src/core/MSafeAccount.ts +2 -3
- package/src/core/MSafeClient.ts +6 -1
- package/src/core/MessageHelper.ts +28 -0
- package/src/core/index.ts +1 -0
- package/src/types/address-book.ts +32 -0
- package/src/{backend/types.ts → types/backend.ts} +1 -1
- package/src/types/index.ts +3 -0
- package/src/types/pagination.ts +15 -0
package/dist/index.d.cts
CHANGED
|
@@ -10,23 +10,6 @@ import { SignatureWithBytes } from '@mysten/sui.js/src/cryptography/keypair';
|
|
|
10
10
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
11
11
|
import * as _mysten_sui_js_dist_cjs_client from '@mysten/sui.js/dist/cjs/client';
|
|
12
12
|
|
|
13
|
-
type JWTToken = string;
|
|
14
|
-
interface PaginationOption {
|
|
15
|
-
page?: number;
|
|
16
|
-
pageSize: number;
|
|
17
|
-
}
|
|
18
|
-
interface PaginationResponse<T> {
|
|
19
|
-
items: T[];
|
|
20
|
-
meta: PaginationMeta;
|
|
21
|
-
}
|
|
22
|
-
interface PaginationMeta {
|
|
23
|
-
totalItems: number;
|
|
24
|
-
itemCount: number;
|
|
25
|
-
itemsPerPage: number;
|
|
26
|
-
totalPages: number;
|
|
27
|
-
currentPage: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
13
|
interface IntentionCoinTransfer {
|
|
31
14
|
txType: 'CoinTransfer';
|
|
32
15
|
recipient: string;
|
|
@@ -60,6 +43,25 @@ declare class IntentionHelper {
|
|
|
60
43
|
}): Promise<_mysten_sui_js_dist_cjs_builder.TransactionBlock>;
|
|
61
44
|
}
|
|
62
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
|
+
|
|
63
65
|
interface PendingTx {
|
|
64
66
|
digest: string;
|
|
65
67
|
payload: string;
|
|
@@ -112,6 +114,73 @@ interface FutureIntention {
|
|
|
112
114
|
createdAt: Date;
|
|
113
115
|
}
|
|
114
116
|
|
|
117
|
+
interface IWallet {
|
|
118
|
+
walletType: string;
|
|
119
|
+
address(): Promise<string>;
|
|
120
|
+
signPersonalMessage(input: {
|
|
121
|
+
messageStr: string;
|
|
122
|
+
}): Promise<SignatureWithBytes>;
|
|
123
|
+
signTransactionBlock(input: {
|
|
124
|
+
transactionBlock: TransactionBlock | Uint8Array;
|
|
125
|
+
}): Promise<SignatureWithBytes>;
|
|
126
|
+
signAndExecuteTransactionBlock(input: {
|
|
127
|
+
transactionBlock: TransactionBlock;
|
|
128
|
+
requestType?: ExecuteTransactionRequestType;
|
|
129
|
+
options?: SuiTransactionBlockResponseOptions;
|
|
130
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface PagedResult<T> {
|
|
134
|
+
data: T[];
|
|
135
|
+
meta: PagedMeta;
|
|
136
|
+
}
|
|
137
|
+
interface PagedMeta {
|
|
138
|
+
page: number;
|
|
139
|
+
limit: number;
|
|
140
|
+
total: number;
|
|
141
|
+
hasNext: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare enum OpAddressBookType {
|
|
145
|
+
Delete = "delete",
|
|
146
|
+
Upsert = "upsert"
|
|
147
|
+
}
|
|
148
|
+
type UpdateAddressBookEntry = DeleteAddressBookEntry | UpsertAddressBookEntry;
|
|
149
|
+
interface DeleteAddressBookEntry {
|
|
150
|
+
opType: OpAddressBookType.Delete;
|
|
151
|
+
address: string;
|
|
152
|
+
}
|
|
153
|
+
interface UpsertAddressBookEntry {
|
|
154
|
+
opType: OpAddressBookType.Upsert;
|
|
155
|
+
address: string;
|
|
156
|
+
addressName: string;
|
|
157
|
+
remark?: string;
|
|
158
|
+
}
|
|
159
|
+
type GetAddressBookResult = PagedResult<GetAddressBookResultEntry>;
|
|
160
|
+
interface GetAddressBookResultEntry {
|
|
161
|
+
address: string;
|
|
162
|
+
addressName: string;
|
|
163
|
+
remark?: string;
|
|
164
|
+
updatedAt: Date;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type JWTToken = string;
|
|
168
|
+
interface PaginationOption {
|
|
169
|
+
page?: number;
|
|
170
|
+
limit?: number;
|
|
171
|
+
}
|
|
172
|
+
interface PaginationResponse<T> {
|
|
173
|
+
items: T[];
|
|
174
|
+
meta: PaginationMeta;
|
|
175
|
+
}
|
|
176
|
+
interface PaginationMeta {
|
|
177
|
+
totalItems: number;
|
|
178
|
+
itemCount: number;
|
|
179
|
+
itemsPerPage: number;
|
|
180
|
+
totalPages: number;
|
|
181
|
+
currentPage: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
115
184
|
interface IBackend {
|
|
116
185
|
authSign(input: AuthLoginRequest): Promise<JWTToken>;
|
|
117
186
|
verifyToken(jwt?: JWTToken): Promise<boolean>;
|
|
@@ -160,6 +229,11 @@ interface IBackend {
|
|
|
160
229
|
userAddress: string;
|
|
161
230
|
}): Promise<void>;
|
|
162
231
|
processExecutedTransaction(digest: string): Promise<void>;
|
|
232
|
+
getAddressBookEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
|
|
233
|
+
updateAddressBook(input: {
|
|
234
|
+
updates: UpdateAddressBookEntry[];
|
|
235
|
+
signature: SerializedSignature;
|
|
236
|
+
}): Promise<void>;
|
|
163
237
|
}
|
|
164
238
|
|
|
165
239
|
declare enum MSafeEnv {
|
|
@@ -197,22 +271,6 @@ declare const ENV_CONFIGS: Map<MSafeEnv, MSafeConfig>;
|
|
|
197
271
|
declare function getMSafeConfig(env: MSafeEnv, options?: MSafeConfigOptions): MSafeConfig;
|
|
198
272
|
declare const AUTH_SIGN_MESSAGE = "Welcome to MSafe";
|
|
199
273
|
|
|
200
|
-
interface IWallet {
|
|
201
|
-
walletType: string;
|
|
202
|
-
address(): Promise<string>;
|
|
203
|
-
signPersonalMessage(input: {
|
|
204
|
-
messageStr: string;
|
|
205
|
-
}): Promise<SignatureWithBytes>;
|
|
206
|
-
signTransactionBlock(input: {
|
|
207
|
-
transactionBlock: TransactionBlock | Uint8Array;
|
|
208
|
-
}): Promise<SignatureWithBytes>;
|
|
209
|
-
signAndExecuteTransactionBlock(input: {
|
|
210
|
-
transactionBlock: TransactionBlock;
|
|
211
|
-
requestType?: ExecuteTransactionRequestType;
|
|
212
|
-
options?: SuiTransactionBlockResponseOptions;
|
|
213
|
-
}): Promise<SuiTransactionBlockResponse>;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
274
|
declare class MSafeGlobals {
|
|
217
275
|
readonly backend: IBackend;
|
|
218
276
|
readonly suiClient: SuiClient;
|
|
@@ -244,25 +302,6 @@ declare class PublicKeyHelper {
|
|
|
244
302
|
private getPublicKeyFromChain;
|
|
245
303
|
}
|
|
246
304
|
|
|
247
|
-
interface CreateMSafeAccountInfo {
|
|
248
|
-
ownerWithWeight: {
|
|
249
|
-
address: string;
|
|
250
|
-
weight: number;
|
|
251
|
-
}[];
|
|
252
|
-
threshold: number;
|
|
253
|
-
name: string;
|
|
254
|
-
description?: string;
|
|
255
|
-
creationNonce: number;
|
|
256
|
-
}
|
|
257
|
-
interface CreatePermissionInfo {
|
|
258
|
-
ownerWithWeight: {
|
|
259
|
-
address: string;
|
|
260
|
-
weight: number;
|
|
261
|
-
}[];
|
|
262
|
-
threshold: number;
|
|
263
|
-
creationNonce: number;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
305
|
declare class CreateHelper {
|
|
267
306
|
readonly globals: MSafeGlobals;
|
|
268
307
|
readonly pkHelper: PublicKeyHelper;
|
|
@@ -282,12 +321,20 @@ declare class MessageHelper {
|
|
|
282
321
|
static deWelcomeMessage(msg: string): string | undefined;
|
|
283
322
|
static proposeIntentionMessage(data: ProposeIntentionData): string;
|
|
284
323
|
static deProposeIntentionMessage(s: string): ProposeIntentionData;
|
|
324
|
+
static updateAddressBookMessage(updates: UpdateAddressBookEntry[]): string;
|
|
285
325
|
}
|
|
286
326
|
interface ProposeIntentionData {
|
|
287
327
|
intention: TxIntention;
|
|
288
328
|
sn: number;
|
|
289
329
|
}
|
|
290
330
|
|
|
331
|
+
declare class AddressBookSDK {
|
|
332
|
+
readonly globals: MSafeGlobals;
|
|
333
|
+
constructor(globals: MSafeGlobals);
|
|
334
|
+
getEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
|
|
335
|
+
update(updates: UpdateAddressBookEntry[]): Promise<void>;
|
|
336
|
+
}
|
|
337
|
+
|
|
291
338
|
declare class MSafeAccount {
|
|
292
339
|
readonly globals: MSafeGlobals;
|
|
293
340
|
readonly info: MSafeAccountInfo;
|
|
@@ -333,6 +380,7 @@ declare class MSafeClient {
|
|
|
333
380
|
get config(): MSafeConfig;
|
|
334
381
|
get backend(): IBackend;
|
|
335
382
|
get wallet(): IWallet;
|
|
383
|
+
get AddressBook(): AddressBookSDK;
|
|
336
384
|
private walletAddress;
|
|
337
385
|
}
|
|
338
386
|
|
|
@@ -408,4 +456,4 @@ declare class Coin {
|
|
|
408
456
|
static getBalance(data: SuiObjectData): bigint | undefined;
|
|
409
457
|
}
|
|
410
458
|
|
|
411
|
-
export { AUTH_SIGN_MESSAGE, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeAccountInfo, type CreatePermissionInfo, type DBConfig, DEV_API_URL, DEV_DATABASE_CONFIG, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, type IntentionCoinTransfer, IntentionHelper, type IntentionObjectTransfer, LOCAL_API_URL, LOCAL_DATABASE_CONFIG, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnv, MSafeGlobals, MessageHelper, type PendingTx, type PendingVote, PublicKeySerde, type ReceiveTransaction, SUI_COIN, SignatureVerifier, TESTNET_RPC_URL, type TxIntention, UNIT_DATABASE_CONFIG, Uint8ArrayToHex, getAllCoins, getMSafeConfig, getPublicKeyFromChain, stringToBuffer };
|
|
459
|
+
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, 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, TESTNET_RPC_URL, type TxIntention, UNIT_DATABASE_CONFIG, Uint8ArrayToHex, type UpdateAddressBookEntry, type UpsertAddressBookEntry, getAllCoins, getMSafeConfig, getPublicKeyFromChain, stringToBuffer };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,23 +10,6 @@ import { SignatureWithBytes } from '@mysten/sui.js/src/cryptography/keypair';
|
|
|
10
10
|
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
11
11
|
import * as _mysten_sui_js_dist_cjs_client from '@mysten/sui.js/dist/cjs/client';
|
|
12
12
|
|
|
13
|
-
type JWTToken = string;
|
|
14
|
-
interface PaginationOption {
|
|
15
|
-
page?: number;
|
|
16
|
-
pageSize: number;
|
|
17
|
-
}
|
|
18
|
-
interface PaginationResponse<T> {
|
|
19
|
-
items: T[];
|
|
20
|
-
meta: PaginationMeta;
|
|
21
|
-
}
|
|
22
|
-
interface PaginationMeta {
|
|
23
|
-
totalItems: number;
|
|
24
|
-
itemCount: number;
|
|
25
|
-
itemsPerPage: number;
|
|
26
|
-
totalPages: number;
|
|
27
|
-
currentPage: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
13
|
interface IntentionCoinTransfer {
|
|
31
14
|
txType: 'CoinTransfer';
|
|
32
15
|
recipient: string;
|
|
@@ -60,6 +43,25 @@ declare class IntentionHelper {
|
|
|
60
43
|
}): Promise<_mysten_sui_js_dist_cjs_builder.TransactionBlock>;
|
|
61
44
|
}
|
|
62
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
|
+
|
|
63
65
|
interface PendingTx {
|
|
64
66
|
digest: string;
|
|
65
67
|
payload: string;
|
|
@@ -112,6 +114,73 @@ interface FutureIntention {
|
|
|
112
114
|
createdAt: Date;
|
|
113
115
|
}
|
|
114
116
|
|
|
117
|
+
interface IWallet {
|
|
118
|
+
walletType: string;
|
|
119
|
+
address(): Promise<string>;
|
|
120
|
+
signPersonalMessage(input: {
|
|
121
|
+
messageStr: string;
|
|
122
|
+
}): Promise<SignatureWithBytes>;
|
|
123
|
+
signTransactionBlock(input: {
|
|
124
|
+
transactionBlock: TransactionBlock | Uint8Array;
|
|
125
|
+
}): Promise<SignatureWithBytes>;
|
|
126
|
+
signAndExecuteTransactionBlock(input: {
|
|
127
|
+
transactionBlock: TransactionBlock;
|
|
128
|
+
requestType?: ExecuteTransactionRequestType;
|
|
129
|
+
options?: SuiTransactionBlockResponseOptions;
|
|
130
|
+
}): Promise<SuiTransactionBlockResponse>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface PagedResult<T> {
|
|
134
|
+
data: T[];
|
|
135
|
+
meta: PagedMeta;
|
|
136
|
+
}
|
|
137
|
+
interface PagedMeta {
|
|
138
|
+
page: number;
|
|
139
|
+
limit: number;
|
|
140
|
+
total: number;
|
|
141
|
+
hasNext: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare enum OpAddressBookType {
|
|
145
|
+
Delete = "delete",
|
|
146
|
+
Upsert = "upsert"
|
|
147
|
+
}
|
|
148
|
+
type UpdateAddressBookEntry = DeleteAddressBookEntry | UpsertAddressBookEntry;
|
|
149
|
+
interface DeleteAddressBookEntry {
|
|
150
|
+
opType: OpAddressBookType.Delete;
|
|
151
|
+
address: string;
|
|
152
|
+
}
|
|
153
|
+
interface UpsertAddressBookEntry {
|
|
154
|
+
opType: OpAddressBookType.Upsert;
|
|
155
|
+
address: string;
|
|
156
|
+
addressName: string;
|
|
157
|
+
remark?: string;
|
|
158
|
+
}
|
|
159
|
+
type GetAddressBookResult = PagedResult<GetAddressBookResultEntry>;
|
|
160
|
+
interface GetAddressBookResultEntry {
|
|
161
|
+
address: string;
|
|
162
|
+
addressName: string;
|
|
163
|
+
remark?: string;
|
|
164
|
+
updatedAt: Date;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type JWTToken = string;
|
|
168
|
+
interface PaginationOption {
|
|
169
|
+
page?: number;
|
|
170
|
+
limit?: number;
|
|
171
|
+
}
|
|
172
|
+
interface PaginationResponse<T> {
|
|
173
|
+
items: T[];
|
|
174
|
+
meta: PaginationMeta;
|
|
175
|
+
}
|
|
176
|
+
interface PaginationMeta {
|
|
177
|
+
totalItems: number;
|
|
178
|
+
itemCount: number;
|
|
179
|
+
itemsPerPage: number;
|
|
180
|
+
totalPages: number;
|
|
181
|
+
currentPage: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
115
184
|
interface IBackend {
|
|
116
185
|
authSign(input: AuthLoginRequest): Promise<JWTToken>;
|
|
117
186
|
verifyToken(jwt?: JWTToken): Promise<boolean>;
|
|
@@ -160,6 +229,11 @@ interface IBackend {
|
|
|
160
229
|
userAddress: string;
|
|
161
230
|
}): Promise<void>;
|
|
162
231
|
processExecutedTransaction(digest: string): Promise<void>;
|
|
232
|
+
getAddressBookEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
|
|
233
|
+
updateAddressBook(input: {
|
|
234
|
+
updates: UpdateAddressBookEntry[];
|
|
235
|
+
signature: SerializedSignature;
|
|
236
|
+
}): Promise<void>;
|
|
163
237
|
}
|
|
164
238
|
|
|
165
239
|
declare enum MSafeEnv {
|
|
@@ -197,22 +271,6 @@ declare const ENV_CONFIGS: Map<MSafeEnv, MSafeConfig>;
|
|
|
197
271
|
declare function getMSafeConfig(env: MSafeEnv, options?: MSafeConfigOptions): MSafeConfig;
|
|
198
272
|
declare const AUTH_SIGN_MESSAGE = "Welcome to MSafe";
|
|
199
273
|
|
|
200
|
-
interface IWallet {
|
|
201
|
-
walletType: string;
|
|
202
|
-
address(): Promise<string>;
|
|
203
|
-
signPersonalMessage(input: {
|
|
204
|
-
messageStr: string;
|
|
205
|
-
}): Promise<SignatureWithBytes>;
|
|
206
|
-
signTransactionBlock(input: {
|
|
207
|
-
transactionBlock: TransactionBlock | Uint8Array;
|
|
208
|
-
}): Promise<SignatureWithBytes>;
|
|
209
|
-
signAndExecuteTransactionBlock(input: {
|
|
210
|
-
transactionBlock: TransactionBlock;
|
|
211
|
-
requestType?: ExecuteTransactionRequestType;
|
|
212
|
-
options?: SuiTransactionBlockResponseOptions;
|
|
213
|
-
}): Promise<SuiTransactionBlockResponse>;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
274
|
declare class MSafeGlobals {
|
|
217
275
|
readonly backend: IBackend;
|
|
218
276
|
readonly suiClient: SuiClient;
|
|
@@ -244,25 +302,6 @@ declare class PublicKeyHelper {
|
|
|
244
302
|
private getPublicKeyFromChain;
|
|
245
303
|
}
|
|
246
304
|
|
|
247
|
-
interface CreateMSafeAccountInfo {
|
|
248
|
-
ownerWithWeight: {
|
|
249
|
-
address: string;
|
|
250
|
-
weight: number;
|
|
251
|
-
}[];
|
|
252
|
-
threshold: number;
|
|
253
|
-
name: string;
|
|
254
|
-
description?: string;
|
|
255
|
-
creationNonce: number;
|
|
256
|
-
}
|
|
257
|
-
interface CreatePermissionInfo {
|
|
258
|
-
ownerWithWeight: {
|
|
259
|
-
address: string;
|
|
260
|
-
weight: number;
|
|
261
|
-
}[];
|
|
262
|
-
threshold: number;
|
|
263
|
-
creationNonce: number;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
305
|
declare class CreateHelper {
|
|
267
306
|
readonly globals: MSafeGlobals;
|
|
268
307
|
readonly pkHelper: PublicKeyHelper;
|
|
@@ -282,12 +321,20 @@ declare class MessageHelper {
|
|
|
282
321
|
static deWelcomeMessage(msg: string): string | undefined;
|
|
283
322
|
static proposeIntentionMessage(data: ProposeIntentionData): string;
|
|
284
323
|
static deProposeIntentionMessage(s: string): ProposeIntentionData;
|
|
324
|
+
static updateAddressBookMessage(updates: UpdateAddressBookEntry[]): string;
|
|
285
325
|
}
|
|
286
326
|
interface ProposeIntentionData {
|
|
287
327
|
intention: TxIntention;
|
|
288
328
|
sn: number;
|
|
289
329
|
}
|
|
290
330
|
|
|
331
|
+
declare class AddressBookSDK {
|
|
332
|
+
readonly globals: MSafeGlobals;
|
|
333
|
+
constructor(globals: MSafeGlobals);
|
|
334
|
+
getEntries(pagination?: PaginationOption): Promise<GetAddressBookResult>;
|
|
335
|
+
update(updates: UpdateAddressBookEntry[]): Promise<void>;
|
|
336
|
+
}
|
|
337
|
+
|
|
291
338
|
declare class MSafeAccount {
|
|
292
339
|
readonly globals: MSafeGlobals;
|
|
293
340
|
readonly info: MSafeAccountInfo;
|
|
@@ -333,6 +380,7 @@ declare class MSafeClient {
|
|
|
333
380
|
get config(): MSafeConfig;
|
|
334
381
|
get backend(): IBackend;
|
|
335
382
|
get wallet(): IWallet;
|
|
383
|
+
get AddressBook(): AddressBookSDK;
|
|
336
384
|
private walletAddress;
|
|
337
385
|
}
|
|
338
386
|
|
|
@@ -408,4 +456,4 @@ declare class Coin {
|
|
|
408
456
|
static getBalance(data: SuiObjectData): bigint | undefined;
|
|
409
457
|
}
|
|
410
458
|
|
|
411
|
-
export { AUTH_SIGN_MESSAGE, COIN_TYPE_ARG_REGEX, Coin, CoinHelper, CreateHelper, type CreateMSafeAccountInfo, type CreatePermissionInfo, type DBConfig, DEV_API_URL, DEV_DATABASE_CONFIG, DEV_SYNCING_URL, ENV_CONFIGS, Formatter, type FutureIntention, HexToUint8Array, type HistorySendTx, type HistoryVote, type IWallet, type IntentionCoinTransfer, IntentionHelper, type IntentionObjectTransfer, LOCAL_API_URL, LOCAL_DATABASE_CONFIG, LOCAL_SYNCING_URL, MAINNET_RPC_URL, MSafeAccount, MSafeClient, type MSafeConfig, type MSafeConfigOptions, MSafeEnv, MSafeGlobals, MessageHelper, type PendingTx, type PendingVote, PublicKeySerde, type ReceiveTransaction, SUI_COIN, SignatureVerifier, TESTNET_RPC_URL, type TxIntention, UNIT_DATABASE_CONFIG, Uint8ArrayToHex, getAllCoins, getMSafeConfig, getPublicKeyFromChain, stringToBuffer };
|
|
459
|
+
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, 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, TESTNET_RPC_URL, type TxIntention, UNIT_DATABASE_CONFIG, Uint8ArrayToHex, type UpdateAddressBookEntry, type UpsertAddressBookEntry, getAllCoins, getMSafeConfig, getPublicKeyFromChain, stringToBuffer };
|
package/dist/index.js
CHANGED
|
@@ -224,6 +224,10 @@ var CreateHelper = class {
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
+
// src/core/MessageHelper.ts
|
|
228
|
+
import { normalizeSuiAddress as normalizeSuiAddress2 } from "@mysten/sui.js/utils";
|
|
229
|
+
import { MD5 } from "crypto-js";
|
|
230
|
+
|
|
227
231
|
// src/transactions/coin-transfer.ts
|
|
228
232
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
229
233
|
|
|
@@ -495,6 +499,38 @@ var MessageHelper = class {
|
|
|
495
499
|
intention: IntentionHelper.de(intentionData)
|
|
496
500
|
};
|
|
497
501
|
}
|
|
502
|
+
static updateAddressBookMessage(updates) {
|
|
503
|
+
const normalized = updates.map((update) => ({
|
|
504
|
+
...update,
|
|
505
|
+
address: normalizeSuiAddress2(update.address)
|
|
506
|
+
}));
|
|
507
|
+
function sortObjectKeys(obj) {
|
|
508
|
+
return Object.keys(obj).sort().reduce((result, key) => ({ ...result, [key]: obj[key] }), {});
|
|
509
|
+
}
|
|
510
|
+
const sortedUpdates = normalized.map((update) => sortObjectKeys(update));
|
|
511
|
+
const raw = JSON.stringify(sortedUpdates, null, 2);
|
|
512
|
+
const encoded = stringToBuffer(raw);
|
|
513
|
+
if (encoded.length <= 1024) {
|
|
514
|
+
return raw;
|
|
515
|
+
}
|
|
516
|
+
const md5 = MD5(raw);
|
|
517
|
+
return `Bulk address book update: ${md5}`;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
// src/core/AddressBookSDK.ts
|
|
522
|
+
var AddressBookSDK = class {
|
|
523
|
+
constructor(globals) {
|
|
524
|
+
this.globals = globals;
|
|
525
|
+
}
|
|
526
|
+
async getEntries(pagination) {
|
|
527
|
+
return this.globals.backend.getAddressBookEntries(pagination);
|
|
528
|
+
}
|
|
529
|
+
async update(updates) {
|
|
530
|
+
const messageStr = MessageHelper.updateAddressBookMessage(updates);
|
|
531
|
+
const sig = await this.globals.wallet.signPersonalMessage({ messageStr });
|
|
532
|
+
return this.globals.backend.updateAddressBook({ updates, signature: sig.signature });
|
|
533
|
+
}
|
|
498
534
|
};
|
|
499
535
|
|
|
500
536
|
// src/core/MSafeAccount.ts
|
|
@@ -916,7 +952,7 @@ var BackendImpl = class {
|
|
|
916
952
|
{
|
|
917
953
|
params: {
|
|
918
954
|
page: paginationOption?.page,
|
|
919
|
-
limit: paginationOption?.
|
|
955
|
+
limit: paginationOption?.limit
|
|
920
956
|
},
|
|
921
957
|
headers: this.headers()
|
|
922
958
|
}
|
|
@@ -932,7 +968,7 @@ var BackendImpl = class {
|
|
|
932
968
|
{
|
|
933
969
|
params: {
|
|
934
970
|
page: paginationOption?.page,
|
|
935
|
-
limit: paginationOption?.
|
|
971
|
+
limit: paginationOption?.limit
|
|
936
972
|
},
|
|
937
973
|
headers: this.headers()
|
|
938
974
|
}
|
|
@@ -1050,6 +1086,22 @@ var BackendImpl = class {
|
|
|
1050
1086
|
throw new Error(`invalid skipNextFailedIntention return: ${res}`);
|
|
1051
1087
|
}
|
|
1052
1088
|
}
|
|
1089
|
+
async getAddressBookEntries(pagination) {
|
|
1090
|
+
const res = await axios.get(`${this.apiURL}/address-book`, {
|
|
1091
|
+
headers: this.headers(),
|
|
1092
|
+
params: pagination
|
|
1093
|
+
});
|
|
1094
|
+
if (res.status !== 200) {
|
|
1095
|
+
throw new Error(`Invalid address-book return: ${res}`);
|
|
1096
|
+
}
|
|
1097
|
+
return res.data;
|
|
1098
|
+
}
|
|
1099
|
+
async updateAddressBook(input) {
|
|
1100
|
+
const res = await axios.post(`${this.apiURL}/address-book`, input, { headers: this.headers() });
|
|
1101
|
+
if (res.status !== 200 && res.status !== 201) {
|
|
1102
|
+
throw new Error(`invalid updateAddressBook return: ${res}`);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1053
1105
|
async processExecutedTransaction(digest) {
|
|
1054
1106
|
}
|
|
1055
1107
|
headers(token) {
|
|
@@ -1165,12 +1217,23 @@ var MSafeClient = class _MSafeClient {
|
|
|
1165
1217
|
get wallet() {
|
|
1166
1218
|
return this.globals.wallet;
|
|
1167
1219
|
}
|
|
1220
|
+
get AddressBook() {
|
|
1221
|
+
return new AddressBookSDK(this.globals);
|
|
1222
|
+
}
|
|
1168
1223
|
async walletAddress() {
|
|
1169
1224
|
return this.wallet.address();
|
|
1170
1225
|
}
|
|
1171
1226
|
};
|
|
1227
|
+
|
|
1228
|
+
// src/types/address-book.ts
|
|
1229
|
+
var OpAddressBookType = /* @__PURE__ */ ((OpAddressBookType2) => {
|
|
1230
|
+
OpAddressBookType2["Delete"] = "delete";
|
|
1231
|
+
OpAddressBookType2["Upsert"] = "upsert";
|
|
1232
|
+
return OpAddressBookType2;
|
|
1233
|
+
})(OpAddressBookType || {});
|
|
1172
1234
|
export {
|
|
1173
1235
|
AUTH_SIGN_MESSAGE,
|
|
1236
|
+
AddressBookSDK,
|
|
1174
1237
|
COIN_TYPE_ARG_REGEX,
|
|
1175
1238
|
Coin,
|
|
1176
1239
|
CoinHelper,
|
|
@@ -1191,6 +1254,7 @@ export {
|
|
|
1191
1254
|
MSafeEnv,
|
|
1192
1255
|
MSafeGlobals,
|
|
1193
1256
|
MessageHelper,
|
|
1257
|
+
OpAddressBookType,
|
|
1194
1258
|
PublicKeySerde,
|
|
1195
1259
|
SUI_COIN,
|
|
1196
1260
|
SignatureVerifier,
|