@asichain/asi-wallet-sdk 0.1.0

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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +330 -0
  3. package/dist/config/index.d.ts +15 -0
  4. package/dist/domains/Asset/index.d.ts +12 -0
  5. package/dist/domains/BlockchainGateway/index.d.ts +48 -0
  6. package/dist/domains/BrowserStorage/index.d.ts +21 -0
  7. package/dist/domains/Client/index.d.ts +16 -0
  8. package/dist/domains/Deploy/factory/index.d.ts +4 -0
  9. package/dist/domains/Deploy/index.d.ts +8 -0
  10. package/dist/domains/EncryptedRecord/index.d.ts +10 -0
  11. package/dist/domains/Error/DeploymentErrorHandler.d.ts +8 -0
  12. package/dist/domains/Error/index.d.ts +2 -0
  13. package/dist/domains/Error/meta.d.ts +21 -0
  14. package/dist/domains/HttpClient/index.d.ts +13 -0
  15. package/dist/domains/Signer/index.d.ts +12 -0
  16. package/dist/domains/Vault/index.d.ts +41 -0
  17. package/dist/domains/Wallet/index.d.ts +58 -0
  18. package/dist/domains/index.d.ts +15 -0
  19. package/dist/index.cjs.js +1 -0
  20. package/dist/index.d.ts +504 -0
  21. package/dist/index.esm.js +1 -0
  22. package/dist/services/AssetsService/index.d.ts +6 -0
  23. package/dist/services/BinaryWriter/index.d.ts +8 -0
  24. package/dist/services/Crypto/index.d.ts +29 -0
  25. package/dist/services/Fee/index.d.ts +5 -0
  26. package/dist/services/KeyDerivation/index.d.ts +15 -0
  27. package/dist/services/KeysManager/index.d.ts +14 -0
  28. package/dist/services/Mnemonic/index.d.ts +11 -0
  29. package/dist/services/Resubmit/DeployResubmitter.d.ts +22 -0
  30. package/dist/services/Resubmit/NodeManager.d.ts +22 -0
  31. package/dist/services/Resubmit/index.d.ts +3 -0
  32. package/dist/services/Resubmit/types.d.ts +32 -0
  33. package/dist/services/Signer/index.d.ts +5 -0
  34. package/dist/services/Transfer/index.d.ts +11 -0
  35. package/dist/services/Wallets/index.d.ts +16 -0
  36. package/dist/services/index.d.ts +19 -0
  37. package/dist/utils/codec/index.d.ts +6 -0
  38. package/dist/utils/constants/index.d.ts +24 -0
  39. package/dist/utils/functions/index.d.ts +5 -0
  40. package/dist/utils/index.d.ts +5 -0
  41. package/dist/utils/polyfills/index.d.ts +1 -0
  42. package/dist/utils/validators/index.d.ts +21 -0
  43. package/package.json +53 -0
@@ -0,0 +1,504 @@
1
+ import { BIP32Interface } from 'bip32';
2
+ import { AxiosRequestConfig, AxiosInstance } from 'axios';
3
+
4
+ declare class FeeService {
5
+ static generateRandomGasFee: () => string;
6
+ static getGasFeeAsNumber: () => number;
7
+ static formatGasFee: (fee?: string) => string;
8
+ }
9
+
10
+ declare const enum KeyUsage {
11
+ ENCRYPT = "encrypt",
12
+ DECRYPT = "decrypt",
13
+ DERIVATION = "deriveKey"
14
+ }
15
+ interface CryptoConfig {
16
+ readonly VERSION: number;
17
+ readonly IV_LENGTH: number;
18
+ readonly SALT_LENGTH: number;
19
+ readonly KEY_SIZE_BITS: number;
20
+ readonly KEY_IMPORT_FORMAT: "raw" | "pkcs8" | "spki";
21
+ readonly KEY_DERIVATION_ITERATIONS: number;
22
+ readonly KEY_DERIVATION_FUNCTION: string;
23
+ readonly KEY_IMPORT_USAGE: KeyUsage[];
24
+ readonly HASH_FUNCTION: string;
25
+ readonly ALGORITHM: string;
26
+ }
27
+ interface EncryptedData {
28
+ data: string;
29
+ salt: string;
30
+ iv: string;
31
+ version: number;
32
+ }
33
+ declare class CryptoService {
34
+ static encryptWithPassword(data: string, password: string): Promise<EncryptedData>;
35
+ static decryptWithPassword(payload: EncryptedData, passphrase: string): Promise<string>;
36
+ static deriveKey(password: string, salt: Uint8Array): Promise<CryptoKey>;
37
+ }
38
+
39
+ type AssetId = string;
40
+ type Assets = Map<AssetId, Asset>;
41
+
42
+ declare class Asset {
43
+ private id;
44
+ private name;
45
+ private decimals;
46
+ constructor(id: string, name: string, decimals?: number);
47
+ getId(): string;
48
+ getName(): string;
49
+ getDecimals(): number;
50
+ }
51
+
52
+ type AddressBrand = {
53
+ readonly __brand: unique symbol;
54
+ };
55
+ type Address = `1111${string & AddressBrand}`;
56
+ interface StoredWalletMeta {
57
+ name: string;
58
+ address: Address;
59
+ encryptedPrivateKey: string;
60
+ masterNodeId: string | null;
61
+ index: string | null;
62
+ }
63
+ type StringifiedWalletMeta = string;
64
+ type WalletMemory = Map<string, string>;
65
+ declare enum WalletMemoryKeys {
66
+ PRIVATE_KEY = "private_key",
67
+ CRYPTO_SALT = "crypto_salt",
68
+ CRYPTO_IV = "crypto_iv",
69
+ CRYPTO_VERSION = "crypto version"
70
+ }
71
+ interface SigningCapability {
72
+ signDigest(digest: Uint8Array): Promise<Uint8Array>;
73
+ getPublicKey(): Uint8Array;
74
+ }
75
+ declare class Wallet {
76
+ private static unsafeRawKeyExportEnabled;
77
+ private name;
78
+ private address;
79
+ private privateKey;
80
+ private isLocked;
81
+ private assets;
82
+ private masterNodeId;
83
+ private index;
84
+ private constructor();
85
+ static fromPrivateKey(name: string, privateKey: Uint8Array, password: string, masterNodeId?: string | null, index?: number | null): Promise<Wallet>;
86
+ static fromEncryptedData(name: string, address: Address, encryptedPrivateKey: EncryptedData, masterNodeId: string | null, index: number | null): Wallet;
87
+ /**
88
+ * @deprecated Raw key export is disabled by default. Prefer `withSigningCapability()`.
89
+ * Enable only for legacy migration by calling `Wallet.enableUnsafeRawKeyExportForLegacyInterop()`.
90
+ */
91
+ decrypt(password: string): Promise<Uint8Array>;
92
+ static enableUnsafeRawKeyExportForLegacyInterop(): void;
93
+ static disableUnsafeRawKeyExport(): void;
94
+ static isUnsafeRawKeyExportEnabled(): boolean;
95
+ private decryptPrivateKey;
96
+ withSigningCapability<T>(password: string, callback: (signingCapability: SigningCapability) => Promise<T> | T): Promise<T>;
97
+ getEncryptedPrivateKey(): EncryptedData;
98
+ registerAsset(asset: Asset): void;
99
+ getAddress(): Address;
100
+ getName(): string;
101
+ getIndex(): number | null;
102
+ getAssets(): Assets;
103
+ isWalletLocked(): boolean;
104
+ toString(): StringifiedWalletMeta;
105
+ private static encryptPrivateKey;
106
+ }
107
+
108
+ interface CreateWalletOptions {
109
+ name?: string;
110
+ }
111
+ interface WalletMeta {
112
+ address: string;
113
+ privateKey: Uint8Array;
114
+ publicKey?: Uint8Array;
115
+ mnemonic?: string;
116
+ }
117
+ declare class WalletsService {
118
+ static createWallet(privateKey?: Uint8Array, options?: CreateWalletOptions): WalletMeta;
119
+ static createWalletFromMnemonic(mnemonic?: string, index?: number): Promise<WalletMeta>;
120
+ static deriveAddressFromPrivateKey(privateKey: Uint8Array): Address;
121
+ static deriveAddressFromPublicKey(publicKey: Uint8Array): Address;
122
+ }
123
+
124
+ declare enum MnemonicStrength {
125
+ TWELVE_WORDS = 128,
126
+ TWENTY_FOUR_WORDS = 256
127
+ }
128
+ declare class MnemonicService {
129
+ static generateMnemonic(strength?: MnemonicStrength): string;
130
+ static generateMnemonicArray(strength?: MnemonicStrength): string[];
131
+ static isMnemonicValid(mnemonic: string): boolean;
132
+ static mnemonicToWordArray(mnemonic: string): string[];
133
+ static wordArrayToMnemonic(words: string[]): string;
134
+ }
135
+
136
+ interface Bip44PathOptions {
137
+ coinType: number;
138
+ account?: number;
139
+ change?: number;
140
+ index?: number;
141
+ }
142
+ declare class KeyDerivationService {
143
+ static buildBip44Path({ coinType, account, change, index, }: Bip44PathOptions): string;
144
+ static derivePrivateKey(masterNode: BIP32Interface, path: string): Uint8Array;
145
+ static mnemonicToSeed(mnemonicWords: string[] | string, passphrase?: string): Promise<Uint8Array>;
146
+ static seedToMasterNode(seed: any): BIP32Interface;
147
+ static deriveKeyFromMnemonic(mnemonicWords: string[], options?: Bip44PathOptions): Promise<Uint8Array>;
148
+ static deriveNextKeyFromMnemonic(mnemonicWords: string[], currentIndex: number, options?: Omit<Bip44PathOptions, "index">): Promise<Uint8Array>;
149
+ }
150
+
151
+ interface KeyPair {
152
+ privateKey: Uint8Array;
153
+ publicKey: Uint8Array;
154
+ }
155
+ declare class KeysManager {
156
+ static generateRandomKey(length?: number): Uint8Array;
157
+ static generateKeyPair(keyLength?: number): KeyPair;
158
+ static getKeyPairFromPrivateKey(privateKey: Uint8Array): KeyPair;
159
+ static getPublicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
160
+ static convertKeyToHex(key: Uint8Array): string;
161
+ static deriveKeyFromMnemonic(mnemonicWords: string[], options?: Bip44PathOptions): Promise<Uint8Array>;
162
+ static generateMpcKeyPair(): any;
163
+ }
164
+
165
+ declare enum RecoverableDeployErrors {
166
+ READ_ONLY_NODE = "READ_ONLY_NODE",
167
+ CASPER_INSTANCE_UNAVAILABLE = "CASPER_INSTANCE_UNAVAILABLE",
168
+ INVALID_DEPLOY_ID = "INVALID_DEPLOY_ID",
169
+ INVALID_BLOCK_NUMBER = "INVALID_BLOCK_NUMBER"
170
+ }
171
+ declare enum FatalDeployErrors {
172
+ INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
173
+ WRONG_NETWORK = "WRONG_NETWORK",
174
+ PARSING_ERROR = "PARSING_ERROR",
175
+ LOW_PHLO_PRICE = "LOW_PHLO_PRICE",
176
+ SIGNATURE_ERROR = "SIGNATURE_ERROR",
177
+ STORAGE_RETRIEVAL_ERROR = "STORAGE_RETRIEVAL_ERROR",
178
+ UNKNOWN_ERROR = "UNKNOWN_ERROR",
179
+ DEPLOY_SUBMIT_TIMEOUT = "DEPLOY_SUBMIT_TIMEOUT",
180
+ BLOCK_INCLUSION_TIMEOUT = "BLOCK_INCLUSION_TIMEOUT",
181
+ FINALIZATION_TIMEOUT = "FINALIZATION_TIMEOUT"
182
+ }
183
+ type DeploymentErrorType = RecoverableDeployErrors | FatalDeployErrors;
184
+ declare const deploymentErrorMessages: Record<DeploymentErrorType, string>;
185
+ declare function getDeploymentErrorMessage(errorType: DeploymentErrorType): string;
186
+
187
+ declare class DeploymentErrorHandler {
188
+ parseDeploymentError(errorMessage: string): DeploymentErrorType;
189
+ isDeploymentErrorRecoverable(errorType: DeploymentErrorType): boolean;
190
+ isDeploymentErrorFatal(errorType: DeploymentErrorType): boolean;
191
+ isPollingErrorRecoverable(errorMessage: string): boolean;
192
+ getErrorMessageByErrorType(errorType: DeploymentErrorType): string;
193
+ }
194
+
195
+ interface SigningRequest {
196
+ wallet: Wallet;
197
+ data: any;
198
+ }
199
+ interface SignedResult {
200
+ data: any;
201
+ deployer: string;
202
+ signature: string;
203
+ sigAlgorithm: string;
204
+ }
205
+ type PasswordProvider = () => Promise<string>;
206
+
207
+ declare enum DeployStatus {
208
+ DEPLOYING = "Deploying",
209
+ INCLUDED_IN_BLOCK = "IncludedInBlock",
210
+ FINALIZED = "Finalized",
211
+ CHECK_ERROR = "CheckingError"
212
+ }
213
+ type DeployStatusResult = {
214
+ status: Exclude<DeployStatus, DeployStatus.CHECK_ERROR>;
215
+ } | {
216
+ status: DeployStatus.CHECK_ERROR;
217
+ errorMessage: string;
218
+ };
219
+ type GatewayClientConfig = {
220
+ baseUrl: string;
221
+ axiosConfig?: AxiosRequestConfig;
222
+ };
223
+ interface BlockchainGatewayConfig {
224
+ validator: GatewayClientConfig;
225
+ indexer: GatewayClientConfig;
226
+ }
227
+ declare class BlockchainGateway {
228
+ private static instance;
229
+ private validatorClient;
230
+ private indexerClient;
231
+ private constructor();
232
+ private static createHttpClient;
233
+ changeValidator(config: GatewayClientConfig): this;
234
+ changeIndexer(config: GatewayClientConfig): this;
235
+ static init(config: BlockchainGatewayConfig): BlockchainGateway;
236
+ static isInitialized(): boolean;
237
+ static getInstance(): BlockchainGateway;
238
+ getValidatorClientUrl(): string;
239
+ submitDeploy(deployData: SignedResult): Promise<string | undefined>;
240
+ submitExploratoryDeploy(rholangCode: string): Promise<any>;
241
+ exploreDeployData(rholangCode: string): Promise<any>;
242
+ getDeploy(deployHash: string): Promise<any>;
243
+ isDeployFinalized(deploy: any): Promise<boolean>;
244
+ getDeployStatus(deployHash: string): Promise<DeployStatusResult>;
245
+ getBlock(blockHash: string): Promise<any>;
246
+ getLatestBlockNumber(): Promise<number>;
247
+ isValidatorActive(): Promise<boolean>;
248
+ private getGatewayErrorMessage;
249
+ private validateBlocksResponse;
250
+ private getLatestBlock;
251
+ }
252
+
253
+ interface NodeProvider {
254
+ connectDefaultNode(): Promise<void>;
255
+ connectActiveRandomNode(): Promise<void>;
256
+ deactivateCurrentNode(): void;
257
+ isInitialized(): boolean;
258
+ getRetriesLeft(): number;
259
+ }
260
+ interface ResubmitConfig {
261
+ phloPrice: number;
262
+ useRandomNode: boolean;
263
+ deployValiditySeconds: number;
264
+ nodeSelectionAttempts: number;
265
+ deployRetries: number;
266
+ deployIntervalSeconds: number;
267
+ pollingIntervalSeconds: number;
268
+ }
269
+ interface ErrorDetail {
270
+ blockchainError?: {
271
+ type: DeploymentErrorType;
272
+ message: string;
273
+ };
274
+ exceededTimeout?: FatalDeployErrors.DEPLOY_SUBMIT_TIMEOUT | FatalDeployErrors.BLOCK_INCLUSION_TIMEOUT;
275
+ }
276
+ interface ResubmitResult {
277
+ success: boolean;
278
+ deployId?: string;
279
+ deployStatus?: DeployStatus;
280
+ error?: ErrorDetail;
281
+ }
282
+
283
+ declare class DeployResubmitter {
284
+ private readonly config;
285
+ private readonly nodeManager;
286
+ private readonly errorHandler;
287
+ private startSubmissionTime;
288
+ constructor(config: ResubmitConfig, availableNodesUrls: string[]);
289
+ private isDeployExpired;
290
+ private sleep;
291
+ private retryDeployToOneNode;
292
+ private retryDeployToRandomNodes;
293
+ private pollDeployStatus;
294
+ /**
295
+
296
+ * Main resubmit function
297
+ * Executes the complete resubmit algorithm for deploy
298
+ * NOT FOR "READ-ONLY" DEPLOYS (exploratory deploys)
299
+ */
300
+ resubmit(rholangCode: string, wallet: Wallet, passwordProvider: PasswordProvider, phloLimit?: number): Promise<ResubmitResult>;
301
+ }
302
+
303
+ declare class NodeManager implements NodeProvider {
304
+ private static instance;
305
+ private retriesLeft;
306
+ private readonly availableNodesUrls;
307
+ private readonly useRandomNode;
308
+ private readonly inactiveNodesUrls;
309
+ private currentNodeUrl;
310
+ private constructor();
311
+ static initialize(availableNodesUrls: string[], nodeSelectionAttempts?: number, useRandomNode?: boolean): NodeManager;
312
+ connectDefaultNode(): Promise<void>;
313
+ private connectNode;
314
+ static getInstance(): NodeManager;
315
+ isInitialized(): boolean;
316
+ private markNodeInactive;
317
+ deactivateCurrentNode(): void;
318
+ private deactivateNode;
319
+ private getAvailableNodesUrls;
320
+ getRetriesLeft(): number;
321
+ private getRandomAvailableNodeUrl;
322
+ connectActiveRandomNode(): Promise<void>;
323
+ }
324
+
325
+ declare class SignerService {
326
+ static sign(request: SigningRequest, passwordProvider: PasswordProvider): Promise<SignedResult>;
327
+ private static readonly deployDataProtobufSerialize;
328
+ }
329
+
330
+ declare class AssetsService {
331
+ transfer(fromAddress: Address, toAddress: Address, amount: bigint, wallet: Wallet, passwordProvider: PasswordProvider, phloLimit?: number): Promise<string | undefined>;
332
+ getASIBalance(address: Address): Promise<bigint>;
333
+ }
334
+
335
+ declare class BinaryWriterService {
336
+ private buffer;
337
+ writeString(fieldNumber: number, value: string): void;
338
+ writeInt64(fieldNumber: number, value: number): void;
339
+ private writeInteger;
340
+ private writeInteger64;
341
+ getResultBuffer(): Uint8Array;
342
+ }
343
+
344
+ declare class EncryptedRecord {
345
+ private encryptedSeedData;
346
+ static createAndEncrypt(data: string, password: string): Promise<EncryptedRecord>;
347
+ static createFromEncryptedData(encryptedData: EncryptedData): EncryptedRecord;
348
+ static createFromStringifiedEncryptedData(data: string): EncryptedRecord;
349
+ private constructor();
350
+ decrypt(password: string): Promise<string>;
351
+ toString(): string;
352
+ }
353
+
354
+ type Wallets = Map<Address, Wallet>;
355
+ type Seeds = Map<string, EncryptedRecord>;
356
+ type VaultRawData = string;
357
+ type StoredWalletsMetaRecords = Record<Address, StringifiedWalletMeta>;
358
+ type StoredSeedsMetaRecords = Record<string, string>;
359
+ declare const DEFAULT_STORAGE_KEY = "0";
360
+ declare class Vault {
361
+ private static vaultPrefix;
362
+ private isLocked;
363
+ private wallets;
364
+ private seeds;
365
+ private encryptedVaultData;
366
+ constructor(VaultData?: VaultRawData);
367
+ static getSavedVaultKeys(): string[];
368
+ static getVaultDataFromStorage(vaultKey: string): VaultRawData | null;
369
+ isVaultLocked(): boolean;
370
+ save(vaultKey?: string): void;
371
+ lock(password: string): Promise<void>;
372
+ unlock(password: string): Promise<void>;
373
+ isEmpty(): boolean;
374
+ getWallets(): Wallet[];
375
+ getWalletsCount(): number;
376
+ getWalletAddresses(): Address[];
377
+ addWallet(wallet: Wallet): void;
378
+ removeWallet(address: Address): void;
379
+ getWallet(address: Address): Wallet | undefined;
380
+ hasWallet(address: Address): boolean;
381
+ hasSeed(seedId: string): boolean;
382
+ private metaToWallets;
383
+ private metaToSeeds;
384
+ getSeeds(): EncryptedRecord[];
385
+ getSeed(id: string): EncryptedRecord | undefined;
386
+ addSeed(id: string, seed: EncryptedRecord): void;
387
+ removeSeed(id: string): void;
388
+ getSeedsIds(): string[];
389
+ toString(): string;
390
+ private ensureUnlocked;
391
+ private static ensureBrowserEnvironment;
392
+ }
393
+
394
+ interface HttpClient {
395
+ get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
396
+ post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
397
+ getBaseUrl(): string | undefined;
398
+ }
399
+ declare class AxiosHttpClient implements HttpClient {
400
+ private readonly client;
401
+ constructor(client: AxiosInstance);
402
+ get<T>(url: string): Promise<T>;
403
+ post<T>(url: string, data?: any): Promise<T>;
404
+ getBaseUrl(): string | undefined;
405
+ }
406
+
407
+ interface Storage {
408
+ write: (id: string, data: string) => void;
409
+ read: (id: string) => string | null;
410
+ delete: (id: string) => void;
411
+ has: (id: string) => boolean;
412
+ isEmpty: () => boolean;
413
+ clear: () => void;
414
+ }
415
+ declare class BrowserStorage implements Storage {
416
+ private prefix;
417
+ constructor(prefix?: string);
418
+ write(id: string, data: string): void;
419
+ read(id: string): string | null;
420
+ delete(id: string): void;
421
+ has(id: string): boolean;
422
+ isEmpty(): boolean;
423
+ clear(): void;
424
+ private getIds;
425
+ private createKey;
426
+ }
427
+
428
+ interface WalletClientConfig {
429
+ mode: string;
430
+ }
431
+ declare enum WalletClientModes {
432
+ LOCAL = "local",
433
+ MPC = "mpc"
434
+ }
435
+ declare const DEFAULT_CLIENT_CONFIG: WalletClientConfig;
436
+ declare const DEFAULT_AXIOS_TIMEOUT_MS: number;
437
+ declare const MAX_WALLETS_PER_ACCOUNT: number;
438
+ declare const DEFAULT_DECIMALS_AMOUNT: number;
439
+ declare const DEFAULT_PHLO_LIMIT: number;
440
+ declare const DEFAULT_RESUBMIT_CONFIG: ResubmitConfig;
441
+
442
+ declare const encodeBase58: (hex: string) => string;
443
+ declare const decodeBase58: (value: string) => Uint8Array;
444
+ declare const decodeBase16: (hex: string) => Uint8Array;
445
+ declare const encodeBase16: (bytes: Uint8Array) => string;
446
+ declare const arrayBufferToBase64: (buffer: ArrayBuffer) => string;
447
+ declare const base64ToArrayBuffer: (base64: string) => ArrayBuffer;
448
+
449
+ declare const PRIVATE_KEY_LENGTH = 32;
450
+ declare const ASI_CHAIN_PREFIX: {
451
+ coinId: string;
452
+ version: string;
453
+ };
454
+ declare const ASI_COIN_TYPE = 60;
455
+ declare const ASI_DECIMALS = 8;
456
+ declare const GasFee: {
457
+ BASE_FEE: number;
458
+ VARIATION_RANGE: number;
459
+ LABEL: string;
460
+ TRANSFER: string;
461
+ DEPLOY: string;
462
+ };
463
+ declare const POWER_BASE: number;
464
+ declare const ASI_BASE_UNIT: bigint;
465
+ declare const FAULT_TOLERANCE_THRESHOLD: number;
466
+ declare const INVALID_BLOCK_NUMBER = -1;
467
+ declare const DEFAULT_BIP_44_PATH_OPTIONS: {
468
+ coinType: number;
469
+ account: number;
470
+ change: number;
471
+ index: number;
472
+ };
473
+
474
+ declare const toAtomicAmount: (amount: number | string) => bigint;
475
+ declare const fromAtomicAmountToString: (atomicAmount: bigint) => string;
476
+ declare const fromAtomicAmountToNumber: (atomicAmount: bigint) => number;
477
+ declare const fromAtomicAmount: (atomicAmount: bigint) => string;
478
+ declare const genRandomHex: (size: number) => string;
479
+
480
+ declare const setupBufferPolyfill: () => void;
481
+
482
+ declare const validateAccountName: (name: string, maxLength?: number) => {
483
+ isValid: boolean;
484
+ error?: string;
485
+ };
486
+ declare enum AddressValidationErrorCode {
487
+ INVALID_PREFIX = "INVALID_PREFIX",
488
+ INVALID_LENGTH = "INVALID_LENGTH",
489
+ INVALID_ALPHABET = "INVALID_ALPHABET",
490
+ INVALID_BASE58 = "INVALID_BASE58",
491
+ INVALID_HEX_LENGTH = "INVALID_HEX_LENGTH",
492
+ INVALID_CHAIN_PREFIX = "INVALID_CHAIN_PREFIX",
493
+ INVALID_CHECKSUM = "INVALID_CHECKSUM",
494
+ NON_CANONICAL = "NON_CANONICAL"
495
+ }
496
+ interface AddressValidationResult {
497
+ isValid: boolean;
498
+ errorCode?: AddressValidationErrorCode;
499
+ }
500
+ declare const validateAddress: (address: string) => AddressValidationResult;
501
+ declare const isAddress: (address: string) => address is Address;
502
+
503
+ export { ASI_BASE_UNIT, ASI_CHAIN_PREFIX, ASI_COIN_TYPE, ASI_DECIMALS, AddressValidationErrorCode, Asset, AssetsService, AxiosHttpClient, BinaryWriterService as BinaryWriter, BlockchainGateway, CryptoService, DEFAULT_AXIOS_TIMEOUT_MS, DEFAULT_BIP_44_PATH_OPTIONS, DEFAULT_CLIENT_CONFIG, DEFAULT_DECIMALS_AMOUNT, DEFAULT_PHLO_LIMIT, DEFAULT_RESUBMIT_CONFIG, DEFAULT_STORAGE_KEY, DeployResubmitter, DeployStatus, DeploymentErrorHandler, EncryptedRecord, FAULT_TOLERANCE_THRESHOLD, FatalDeployErrors, FeeService, GasFee, INVALID_BLOCK_NUMBER, KeyDerivationService, KeysManager, MAX_WALLETS_PER_ACCOUNT, MnemonicService, MnemonicStrength, POWER_BASE, PRIVATE_KEY_LENGTH, RecoverableDeployErrors, NodeManager as ResubmitNodeManager, BrowserStorage as SecureStorage, SignerService, Vault, Wallet, WalletClientModes, WalletMemoryKeys, WalletsService, arrayBufferToBase64, base64ToArrayBuffer, decodeBase16, decodeBase58, deploymentErrorMessages, encodeBase16, encodeBase58, fromAtomicAmount, fromAtomicAmountToNumber, fromAtomicAmountToString, genRandomHex, getDeploymentErrorMessage, isAddress, setupBufferPolyfill, toAtomicAmount, validateAccountName, validateAddress };
504
+ export type { Address, AddressValidationResult, AssetId, Assets, Bip44PathOptions, BlockchainGatewayConfig, CreateWalletOptions, CryptoConfig, DeployStatusResult, DeploymentErrorType, EncryptedData, HttpClient, KeyPair, PasswordProvider, ResubmitConfig, ResubmitResult, Seeds, SignedResult, SigningCapability, SigningRequest, StoredSeedsMetaRecords, StoredWalletMeta, StoredWalletsMetaRecords, StringifiedWalletMeta, VaultRawData, WalletClientConfig, WalletMemory, WalletMeta, Wallets };
@@ -0,0 +1 @@
1
+ import e from"bs58";import*as t from"bip39";import{mnemonicToSeed as r}from"bip39";import{Buffer as n}from"buffer";import*as a from"tiny-secp256k1";import{BIP32Factory as s}from"bip32";import{getPublicKey as i,utils as o,sign as c}from"@noble/secp256k1";import l from"blakejs";import d from"js-sha3";import u from"axios";const h=32,y={coinId:"000000",version:"00"},p=60,g=8,m={BASE_FEE:.0025,VARIATION_RANGE:.1,LABEL:"ASI",TRANSFER:"0.0025",DEPLOY:"0.0025"},f=10,w=BigInt(10)**BigInt(8),E=.99,I=-1,N={coinType:60,account:0,change:0,index:0};var A;class v{}A=v,v.generateRandomGasFee=()=>{const e=2*(Math.random()-.5)*m.VARIATION_RANGE;return(m.BASE_FEE*(1+e)).toFixed(4)},v.getGasFeeAsNumber=()=>m.BASE_FEE,v.formatGasFee=e=>`${e||A.generateRandomGasFee()} ${m.LABEL}`;const R=t=>{const r=S(t);return e.encode(r)},b=t=>e.decode(t),S=e=>{const t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substr(r,2),16);return t},D=e=>Array.from(e,e=>e.toString(16).padStart(2,"0")).join(""),L=e=>{const t=new Uint8Array(e);let r="";for(let e=0;e<t.byteLength;e++)r+=String.fromCharCode(t[e]);return btoa(r)},_=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer},O=2,C=12,T=16,P=256,k="AES-GCM",U="SHA-256",K="raw",V="PBKDF2",B=1e5;class M{static async encryptWithPassword(e,t){const r=crypto.getRandomValues(new Uint8Array(T)),n=crypto.getRandomValues(new Uint8Array(C)),a=await this.deriveKey(t,r),s=await crypto.subtle.encrypt({name:k,iv:n},a,(new TextEncoder).encode(e));return{data:L(s),salt:L(r.buffer),iv:L(n.buffer),version:O}}static async decryptWithPassword(e,t){if(e.version!==O)throw new Error(`Unsupported version ${e.version}`);const r=new Uint8Array(_(e.salt)),n=new Uint8Array(_(e.iv)),a=await this.deriveKey(t,r),s=await crypto.subtle.decrypt({name:k,iv:n},a,_(e.data));return(new TextDecoder).decode(s)}static async deriveKey(e,t){const r=await crypto.subtle.importKey(K,(new TextEncoder).encode(e),V,!1,["deriveKey"]);return crypto.subtle.deriveKey({name:V,salt:new Uint8Array(t),iterations:B,hash:U},r,{name:k,length:P},!1,["encrypt","decrypt"])}}const x=()=>{"undefined"==typeof window||window.Buffer||(window.Buffer=n)};var W;x(),function(e){e[e.TWELVE_WORDS=128]="TWELVE_WORDS",e[e.TWENTY_FOUR_WORDS=256]="TWENTY_FOUR_WORDS"}(W||(W={}));class F{static generateMnemonic(e=W.TWELVE_WORDS){return t.generateMnemonic(e)}static generateMnemonicArray(e=W.TWELVE_WORDS){return this.mnemonicToWordArray(this.generateMnemonic(e))}static isMnemonicValid(e){return t.validateMnemonic(e)}static mnemonicToWordArray(e){return e.trim().split(" ")}static wordArrayToMnemonic(e){return e.join(" ")}}x();class ${static buildBip44Path({coinType:e=60,account:t=0,change:r=0,index:n=0}){return`m/44'/${e}'/${t}'/${r}/${n}`}static derivePrivateKey(e,t){const r=e.derivePath(t);if(!r.privateKey)throw new Error("No private key at derived node");return new Uint8Array(r.privateKey)}static async mnemonicToSeed(e,t=""){return"string"==typeof e?await r(e,t):await r(F.wordArrayToMnemonic(e),t)}static seedToMasterNode(e){return s(a).fromSeed(e)}static async deriveKeyFromMnemonic(e,t=N){const r=this.buildBip44Path(t),n=await $.mnemonicToSeed(e),a=$.seedToMasterNode(n);return $.derivePrivateKey(a,r)}static async deriveNextKeyFromMnemonic(e,t,r=N){const n=t+1;return await this.deriveKeyFromMnemonic(e,{...r,index:n})}}const{randomBytes:G,bytesToHex:H}=o;class z{static generateRandomKey(e=32){if(!e||e<0||!Number.isInteger(e))throw new Error("PrivateKeyLength must be a positive integer");return G(e)}static generateKeyPair(e=32){if(!e||e<0||!Number.isInteger(e))throw new Error("PrivateKeyLength must be a positive integer");const t=G(e);return{privateKey:t,publicKey:i(t)}}static getKeyPairFromPrivateKey(e){return{privateKey:e,publicKey:i(e)}}static getPublicKeyFromPrivateKey(e){return i(e)}static convertKeyToHex(e){return H(e)}static async deriveKeyFromMnemonic(e,t){return await $.deriveKeyFromMnemonic(e,t)}static generateMpcKeyPair(){throw new Error("MPC key generation is not implemented yet.")}}const{blake2bHex:Y}=l,{keccak256:j}=d;class J{static createWallet(e,t){let r;r=e?z.getKeyPairFromPrivateKey(e):z.generateKeyPair();return{address:this.deriveAddressFromPublicKey(r.publicKey),publicKey:r.publicKey,privateKey:r.privateKey}}static async createWalletFromMnemonic(e,t){const r=e?F.mnemonicToWordArray(e):F.generateMnemonicArray(),n=F.wordArrayToMnemonic(r);if(!n||!F.isMnemonicValid(n))throw new Error("WalletsService.createWalletFromMnemonic: Recovery mnemonic is missing or invalid");const a=await $.mnemonicToSeed(r),s=$.seedToMasterNode(a),i=$.buildBip44Path({coinType:60,account:0,change:0,index:t||0}),o=$.derivePrivateKey(s,i);return{...this.createWallet(o),mnemonic:n}}static deriveAddressFromPrivateKey(e){const t=z.getKeyPairFromPrivateKey(e);return this.deriveAddressFromPublicKey(t.publicKey)}static deriveAddressFromPublicKey(e){const t=j(e.slice(1)),r=S(t.slice(-40)),n=j(r),a=`${y.coinId}${y.version}${n}`,s=S(a),i=Y(s,void 0,32).slice(0,8);return R(`${a}${i}`)}}function X(e,t,r,n,a,s){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var o,c=n.kind,l="getter"===c?"get":"setter"===c?"set":"value",d=!t&&e?n.static?e:e.prototype:null,u=t||(d?Object.getOwnPropertyDescriptor(d,n.name):{}),h=!1,y=r.length-1;y>=0;y--){var p={};for(var g in n)p[g]="access"===g?{}:n[g];for(var g in n.access)p.access[g]=n.access[g];p.addInitializer=function(e){if(h)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(e||null))};var m=(0,r[y])("accessor"===c?{get:u.get,set:u.set}:u[l],p);if("accessor"===c){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(o=i(m.get))&&(u.get=o),(o=i(m.set))&&(u.set=o),(o=i(m.init))&&a.unshift(o)}else(o=i(m))&&("field"===c?a.unshift(o):u[l]=o)}d&&Object.defineProperty(d,n.name,u),h=!0}var Z,q;"function"==typeof SuppressedError&&SuppressedError,function(e){e.READ_ONLY_NODE="READ_ONLY_NODE",e.CASPER_INSTANCE_UNAVAILABLE="CASPER_INSTANCE_UNAVAILABLE",e.INVALID_DEPLOY_ID="INVALID_DEPLOY_ID",e.INVALID_BLOCK_NUMBER="INVALID_BLOCK_NUMBER"}(Z||(Z={})),function(e){e.INSUFFICIENT_BALANCE="INSUFFICIENT_BALANCE",e.WRONG_NETWORK="WRONG_NETWORK",e.PARSING_ERROR="PARSING_ERROR",e.LOW_PHLO_PRICE="LOW_PHLO_PRICE",e.SIGNATURE_ERROR="SIGNATURE_ERROR",e.STORAGE_RETRIEVAL_ERROR="STORAGE_RETRIEVAL_ERROR",e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.DEPLOY_SUBMIT_TIMEOUT="DEPLOY_SUBMIT_TIMEOUT",e.BLOCK_INCLUSION_TIMEOUT="BLOCK_INCLUSION_TIMEOUT",e.FINALIZATION_TIMEOUT="FINALIZATION_TIMEOUT"}(q||(q={}));const Q={[Z.READ_ONLY_NODE]:"Node is read-only. Trying another node...",[Z.CASPER_INSTANCE_UNAVAILABLE]:"Casper instance not available. Trying another node...",[Z.INVALID_DEPLOY_ID]:"Invalid deploy ID. Please try again.",[Z.INVALID_BLOCK_NUMBER]:"Invalid block number. Please try again.",[q.INSUFFICIENT_BALANCE]:"Insufficient balance. Please top up your account.",[q.WRONG_NETWORK]:"Wrong network. Please contact technical support.",[q.PARSING_ERROR]:"Parsing error. Please contact technical support.",[q.LOW_PHLO_PRICE]:"Phlo price too low. Please rebuild the transaction with a higher phlo price.",[q.SIGNATURE_ERROR]:"Signature verification failed. Please try again.",[q.STORAGE_RETRIEVAL_ERROR]:"Storage retrieval error. Please try again later.",[q.UNKNOWN_ERROR]:"An unknown error occurred. Please try again.",[q.DEPLOY_SUBMIT_TIMEOUT]:"Deploy submission timed out. Please try again.",[q.BLOCK_INCLUSION_TIMEOUT]:"Deploy was not included in a block within the expected time.",[q.FINALIZATION_TIMEOUT]:"Block finalization polling timed out."};function ee(e){return Q[e]??"An unknown error occurred. Please try again."}function te(e,t){return function(...t){return"string"==typeof t[0]&&(t[0]=t[0].toLowerCase()),e.apply(this,t)}}let re=(()=>{var e;let t,r,n=[];return e=class{parseDeploymentError(e){return e.includes("read only")?Z.READ_ONLY_NODE:e.includes("casper instance")?Z.CASPER_INSTANCE_UNAVAILABLE:e.includes("invalid deploy ID")?Z.INVALID_DEPLOY_ID:e.includes("invalid block number")?Z.INVALID_BLOCK_NUMBER:e.includes("insufficient balance")?q.INSUFFICIENT_BALANCE:e.includes("wrong network")?q.WRONG_NETWORK:e.includes("parsing error")?q.PARSING_ERROR:e.includes("low")&&e.includes("phlo")?q.LOW_PHLO_PRICE:e.includes("signature")||e.includes("sign")||e.includes("invalid signature")?q.SIGNATURE_ERROR:e.includes("storage")||e.includes("retrieval")?q.STORAGE_RETRIEVAL_ERROR:q.UNKNOWN_ERROR}isDeploymentErrorRecoverable(e){return Object.values(Z).includes(e)}isDeploymentErrorFatal(e){return Object.values(q).includes(e)}isPollingErrorRecoverable(e){return e.includes("casper instance")||e.includes("storage")||e.includes("parsing")}getErrorMessageByErrorType(e){return Q[e]??Q[q.UNKNOWN_ERROR]}constructor(){!function(e,t,r){for(var n=arguments.length>2,a=0;a<t.length;a++)r=n?t[a].call(e,r):t[a].call(e)}(this,n)}},(()=>{const a="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;t=[te],r=[te],X(e,null,t,{kind:"method",name:"parseDeploymentError",static:!1,private:!1,access:{has:e=>"parseDeploymentError"in e,get:e=>e.parseDeploymentError},metadata:a},null,n),X(e,null,r,{kind:"method",name:"isPollingErrorRecoverable",static:!1,private:!1,access:{has:e=>"isPollingErrorRecoverable"in e,get:e=>e.isPollingErrorRecoverable},metadata:a},null,n),a&&Object.defineProperty(e,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:a})})(),e})();class ne{constructor(e){this.client=e}async get(e){return(await this.client.get(e)).data}async post(e,t){return(await this.client.post(e,t)).data}getBaseUrl(){return this.client.defaults.baseURL}}var ae,se;!function(e){e.DEPLOYING="Deploying",e.INCLUDED_IN_BLOCK="IncludedInBlock",e.FINALIZED="Finalized",e.CHECK_ERROR="CheckingError"}(ae||(ae={}));class ie{constructor(e,t){this.validatorClient=e,this.indexerClient=t}static createHttpClient(e){const t=u.create({baseURL:e.baseUrl,...e.axiosConfig});return new ne(t)}changeValidator(e){return this.validatorClient=ie.createHttpClient(e),this}changeIndexer(e){return this.indexerClient=ie.createHttpClient(e),this}static init(e){return ie.instance=new ie(this.createHttpClient(e.validator),this.createHttpClient(e.indexer)),ie.instance}static isInitialized(){return void 0!==ie?.instance}static getInstance(){if(!ie.isInitialized())throw new Error("BlockchainGateway is not initialized. Call BlockchainGateway.init() first.");return ie.instance}getValidatorClientUrl(){return this.validatorClient.getBaseUrl()??""}async submitDeploy(e){try{const t=await this.validatorClient.post("/api/deploy",e,{headers:{"Content-Type":"application/json"}});if(console.log("BlockchainGateway.submitDeploy: Deploy result:",t),"string"==typeof t){const e=/DeployId is:\s*([a-fA-F0-9]+)/.exec(t);return e?e[1]:t}return t.signature||t.deployId||t}catch(e){const t="BlockchainGateway.submitDeploy: "+this.getGatewayErrorMessage(e);throw new Error(t)}}async submitExploratoryDeploy(e){try{return await this.indexerClient.post("/api/explore-deploy",e)}catch(e){const t="BlockchainGateway.submitExploratoryDeploy: "+this.getGatewayErrorMessage(e);throw new Error(t)}}async exploreDeployData(e){try{return(await this.submitExploratoryDeploy(e)).expr}catch(e){const t="BlockchainGateway.exploreDeployData: "+this.getGatewayErrorMessage(e);throw console.error(t),new Error(t)}}async getDeploy(e){return await this.indexerClient.get(`/api/deploy/${e}`)}async isDeployFinalized(e){return e.faultTolerance>=.99}async getDeployStatus(e){try{let t;if(t=await this.getDeploy(e),!t?.blockHash)return{status:ae.DEPLOYING};return{status:await this.isDeployFinalized(t)?ae.FINALIZED:ae.INCLUDED_IN_BLOCK}}catch(e){const t="BlockchainGateway.getDeployStatus: "+this.getGatewayErrorMessage(e);return{status:ae.CHECK_ERROR,errorMessage:t}}}async getBlock(e){const t=await this.indexerClient.get(`/api/block/${e}`);return t?.blockInfo}async getLatestBlockNumber(){try{const e=await this.getLatestBlock();return e?.blockNumber??-1}catch(e){const t="BlockchainGateway.getLatestBlockNumber: "+this.getGatewayErrorMessage(e);return console.error(t),-1}}async isValidatorActive(){try{return await this.validatorClient.get("/status"),!0}catch(e){return console.error("BlockchainGateway.isValidatorActive: Node health check failed:",e),!1}}getGatewayErrorMessage(e){if(u.isAxiosError(e)){const t=e.response?.status??e.code,r=e.response?.statusText??"";return`Axios error while requesting "${e.config?.url??""}": [${t}] ${r} - ${e.message}`}return e instanceof Error?e.message:String(e)}validateBlocksResponse(e){if(!e?.length){throw new Error("BlockchainGateway.validateBlocksResponse: No blocks returned from /api/blocks endpoint")}}async getLatestBlock(){const e=await this.indexerClient.get("/api/blocks/1");return this.validateBlocksResponse(e),e[0]}}!function(e){e.LOCAL="local",e.MPC="mpc"}(se||(se={}));const oe={mode:se.LOCAL},ce=3e4,le=20,de=8,ue=5e5,he={phloPrice:1,useRandomNode:!0,deployValiditySeconds:80,nodeSelectionAttempts:3,deployRetries:3,deployIntervalSeconds:5,pollingIntervalSeconds:3};class ye{constructor(e,t,r){if(this.inactiveNodesUrls=new Set,this.currentNodeUrl="",!e?.length)throw new Error("At least one node URL must be provided");this.availableNodesUrls=e,this.useRandomNode=r,this.retriesLeft=t}static initialize(e,t=he.nodeSelectionAttempts,r=he.useRandomNode){const n=r?Math.max(1,t):0,a=new ye(e,n,r);return ye.instance=a,a}async connectDefaultNode(){if(this.useRandomNode)throw new Error("NodeManager.connectDefaultNode: Random node selection is enabled, cannot connect to default node");await this.connectNode(this.availableNodesUrls[0])}async connectNode(e){ie.getInstance().getValidatorClientUrl()!==e&&ie.getInstance().changeValidator({baseUrl:e});if(!await ie.getInstance().isValidatorActive()){this.deactivateNode(e);const t=`NodeManager.connectNode: Node ${e} is not active`;throw console.error(t),new Error(t)}this.currentNodeUrl=e}static getInstance(){if(!ye.instance)throw new Error("NodeManager is not initialized. Call NodeManager.initialize() first.");return ye.instance}isInitialized(){return!!this.currentNodeUrl}markNodeInactive(e){this.inactiveNodesUrls.add(e)}deactivateCurrentNode(){this.isInitialized()&&this.deactivateNode(this.currentNodeUrl)}deactivateNode(e){this.retriesLeft--,this.markNodeInactive(e),this.currentNodeUrl===e&&(this.currentNodeUrl="")}getAvailableNodesUrls(){return this.availableNodesUrls.filter(e=>!this.inactiveNodesUrls.has(e))}getRetriesLeft(){return this.retriesLeft}getRandomAvailableNodeUrl(){const e=this.getAvailableNodesUrls();if(!e?.length)throw console.error("NodeManager.getRandomAvailableNodeUrl: No available node URLs to select"),new Error("NodeManager: no available node URLs");return e[Math.floor(Math.random()*e.length)]}async connectActiveRandomNode(){if(!this.useRandomNode)throw new Error("NodeManager.connectActiveRandomNode: Random node selection is disabled, connect to default node");for(;this.retriesLeft>0;){const e=this.getRandomAvailableNodeUrl();if(console.log(`NodeManager.connectActiveRandomNode: Attempting to connect to node ${e}. Retries left: ${this.retriesLeft}`),e){try{await this.connectNode(e)}catch(e){continue}return}}throw new Error("NodeManager.connectActiveRandomNode: No active node URL found after all attempts")}}const pe=127;class ge{constructor(){this.buffer=[]}writeString(e,t){if(!t)return;const r=e<<3|2;this.writeInteger(r);const n=(new TextEncoder).encode(t);this.writeInteger(n.length),this.buffer.push(...Array.from(n))}writeInt64(e,t){if(!t)return;const r=e<<3;this.writeInteger(r),this.writeInteger64(t)}writeInteger(e){for(;e>pe;)this.buffer.push(e&pe|128),e>>>=7;this.buffer.push(e)}writeInteger64(e){for(;e>pe;)this.buffer.push(e&pe|128),e=Math.floor(e/128);this.buffer.push(e)}getResultBuffer(){return new Uint8Array(this.buffer)}}const{blake2bHex:me}=l;class fe{static async sign(e,t){const{wallet:r,data:n}=e;try{const e=await t();return await r.withSigningCapability(e,async e=>{const t=this.deployDataProtobufSerialize(n),r=me(t,void 0,32),a=Uint8Array.from(Buffer.from(r,"hex")),s=await e.signDigest(a),i=e.getPublicKey();return{data:{term:n.term,timestamp:n.timestamp,phloPrice:n.phloPrice,phloLimit:n.phloLimit,validAfterBlockNumber:n.validAfterBlockNumber,shardId:n.shardId},deployer:D(i),signature:D(s),sigAlgorithm:"secp256k1"}})}catch(e){const t=`SignerService.sign: ${e.message}`;throw new Error(t)}}}fe.deployDataProtobufSerialize=e=>{const{term:t,timestamp:r,phloPrice:n,phloLimit:a,validAfterBlockNumber:s,shardId:i=""}=e,o=new ge;return o.writeString(2,t),o.writeInt64(3,r),o.writeInt64(7,n),o.writeInt64(8,a),o.writeInt64(10,s),o.writeString(11,i),o.getResultBuffer()};const we=/[,\s]+/g,Ee=/^\d+(?:\.\d+)?$/,Ie=/(\.\d*?[1-9])0+$/,Ne=/\.0+$/,Ae=e=>{const t=w.toString().length-1;if("number"==typeof e){if(!Number.isFinite(e))throw new Error("Invalid number");e=String(e)}let r=String(e).trim();if(!r.length)throw new Error("Cannot process empty amount");let n=!1;if(r.startsWith("-")&&(n=!0,r=r.slice(1)),r=r.replace(we,""),!Ee.test(r))throw new Error("Invalid amount format");const[a,s=""]=r.split("."),i=a||"0";let o=s;o.length>t&&(console.warn(`Fraction ${o} has more than allowed decimals; truncating`),o=o.slice(0,t)),o=o.padEnd(t,"0");const c=BigInt(i)*w+BigInt(o||"0");return n?-c:c},ve=e=>{const t=e/w,r=e%w,n=w.toString().length-1,a=r.toString().padStart(n,"0");return`${t.toString()}.${a}`.replace(Ie,"$1").replace(Ne,"")},Re=e=>{const t=e/w,r=e%w;return t>BigInt(Number.MAX_SAFE_INTEGER)?(console.warn("Integer part exceeds Number.MAX_SAFE_INTEGER; returning imprecise Number"),Number(ve(e))):Number(t)+Number(r)/Number(w)},be=ve,Se=e=>[...Array(e)].map(()=>Math.floor(16*Math.random()).toString(16)).join(""),{blake2bHex:De}=l,Le=/[<>:"/\\|?*]/,_e=(e,t=30)=>e&&0!==e.trim().length?e.length>t?{isValid:!1,error:`Account name must be ${t} characters or less`}:Le.test(e)?{isValid:!1,error:"Account name contains invalid characters"}:{isValid:!0}:{isValid:!1,error:"Account name is required"},Oe=/^[a-zA-Z0-9]+$/,Ce=/^[1-9A-HJ-NP-Za-km-z]+$/,Te=`${y.coinId}${y.version}`;var Pe;!function(e){e.INVALID_PREFIX="INVALID_PREFIX",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_ALPHABET="INVALID_ALPHABET",e.INVALID_BASE58="INVALID_BASE58",e.INVALID_HEX_LENGTH="INVALID_HEX_LENGTH",e.INVALID_CHAIN_PREFIX="INVALID_CHAIN_PREFIX",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.NON_CANONICAL="NON_CANONICAL"}(Pe||(Pe={}));const ke=e=>({isValid:!1,errorCode:e}),Ue=e=>{if(!e.startsWith("1111"))return ke(Pe.INVALID_PREFIX);if(e.length<50||e.length>54)return ke(Pe.INVALID_LENGTH);if(!Oe.test(e))return ke(Pe.INVALID_ALPHABET);if(!Ce.test(e))return ke(Pe.INVALID_BASE58);const t=D(b(e));if(80!==t.length)return ke(Pe.INVALID_HEX_LENGTH);if(R(t)!==e)return ke(Pe.NON_CANONICAL);const r=t.slice(0,72),n=t.slice(72);if(!r.startsWith(Te))return ke(Pe.INVALID_CHAIN_PREFIX);const a=De(S(r),void 0,32).slice(0,8);return 8!==n.length||n!==a?ke(Pe.INVALID_CHECKSUM):{isValid:!0}},Ke=e=>Ue(e).isValid;class Ve{constructor(e,t){if(this.startSubmissionTime=0,this.config=e,this.nodeManager=ye.initialize(t,e.nodeSelectionAttempts,e.useRandomNode),this.errorHandler=new re,!ie.isInitialized())throw new Error("BlockchainGateway is not initialized")}isDeployExpired(){return Date.now()-this.startSubmissionTime>=1e3*this.config.deployValiditySeconds}sleep(e){return new Promise(t=>setTimeout(t,1e3*e))}async retryDeployToOneNode(e,t,r,n){let a=this.config.deployRetries,s={success:!1};for(;a>0&&!this.isDeployExpired();){try{const a=ie.getInstance(),i=await a.getLatestBlockNumber();if(-1===i)throw new Error("DeployResubmitter.retryDeployToOneNode: Invalid block number");const o={term:e,phloLimit:n||ue,phloPrice:1,validAfterBlockNumber:i-1,timestamp:Date.now(),shardId:"root"},c=await fe.sign({wallet:t,data:o},r),l=await a.submitDeploy(c);if("string"!=typeof l){throw new Error("Invalid deploy ID received: "+l)}return s={success:!0,deployId:l},s}catch(e){const t="DeployResubmitter.retryDeployToOneNode:"+e.message,r=this.errorHandler.parseDeploymentError(t);if(console.error(t),s.error={blockchainError:{type:r,message:t}},this.errorHandler.isDeploymentErrorFatal(r))break;a--}await this.sleep(this.config.deployIntervalSeconds)}return this.isDeployExpired()&&(s.error=s?.error||{},s.error.exceededTimeout=q.DEPLOY_SUBMIT_TIMEOUT),{success:!1,error:s.error}}async retryDeployToRandomNodes(e,t,r,n){let a={success:!1};for(;!this.isDeployExpired()&&this.nodeManager.getRetriesLeft()>0&&(await this.nodeManager.connectActiveRandomNode(),a=await this.retryDeployToOneNode(e,t,r,n),!a.success)&&(this.nodeManager.deactivateCurrentNode(),a.error?.blockchainError?.type)&&!this.errorHandler.isDeploymentErrorFatal(a.error?.blockchainError?.type););return a}async pollDeployStatus(e){let t;for(;!this.isDeployExpired();){const r=await ie.getInstance().getDeployStatus(e),n=r.status;if(n===ae.CHECK_ERROR){const e=`DeployResubmitter.pollDeployStatus: ${"errorMessage"in r?r.errorMessage:"Unknown error"}`,n=this.errorHandler.parseDeploymentError(e);console.error(e);const a={type:n,message:e};if(this.errorHandler.isDeploymentErrorFatal(n)&&!e.includes("Bad Request"))return{success:!1,deployStatus:ae.CHECK_ERROR,error:{blockchainError:a}};t=a}if(console.log("DeployResubmitter.pollDeployStatus: current deploy status:",n),n==ae.INCLUDED_IN_BLOCK||n==ae.FINALIZED)return{success:!0,deployStatus:r.status};await this.sleep(this.config.pollingIntervalSeconds)}return{success:!1,deployStatus:t?ae.CHECK_ERROR:ae.DEPLOYING,error:{...t,exceededTimeout:q.BLOCK_INCLUSION_TIMEOUT}}}async resubmit(e,t,r,n){let a;if(console.log("DeployResubmitter: starting deploy submission with resubmission logic"),this.startSubmissionTime=Date.now(),this.config.useRandomNode?a=await this.retryDeployToRandomNodes(e,t,r,n):(await this.nodeManager.connectDefaultNode(),a=await this.retryDeployToOneNode(e,t,r,n)),!a.success||!a?.deployId)return a;console.log(`DeployResubmitter: deploy submitted successfully with ID: ${a.deployId}. Starting to poll for status...`);const s=await this.pollDeployStatus(a.deployId);return console.log(`DeployResubmitter: finished polling deploy status. Final status: ${s.deployStatus}, success: ${s.success}`),s}}const Be=e=>e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");class Me{async transfer(e,t,r,n,a,s=5e5){try{const i=Ue(e);if(!i.isValid)throw new Error(`AssetsService.transfer: Invalid 'fromAddress': ${i.errorCode??"UNKNOWN"}`);const o=Ue(t);if(!o.isValid)throw new Error(`AssetsService.transfer: Invalid 'toAddress': ${o.errorCode??"UNKNOWN"}`);if(r<=0n)throw new Error("AssetsService.transfer: Transfer amount must be greater than zero");const c=ie.getInstance(),l=((e,t,r)=>{if(r<=0n)throw new Error("Transfer amount must be greater than zero");const n=Be(e),a=Be(t),s=r.toString();return`\n new \n deployerId(\`rho:rchain:deployerId\`),\n stdout(\`rho:io:stdout\`),\n rl(\`rho:registry:lookup\`),\n ASIVaultCh,\n vaultCh,\n toVaultCh,\n asiVaultkeyCh,\n resultCh\n in {\n rl!(\`rho:rchain:asiVault\`, *ASIVaultCh) |\n for (@(_, ASIVault) <- ASIVaultCh) {\n @ASIVault!("findOrCreate", "${n}", *vaultCh) |\n @ASIVault!("findOrCreate", "${a}", *toVaultCh) |\n @ASIVault!("deployerAuthKey", *deployerId, *asiVaultkeyCh) |\n for (@(true, vault) <- vaultCh; key <- asiVaultkeyCh; @(true, toVault) <- toVaultCh) {\n @vault!("transfer", "${a}", ${s}, *key, *resultCh) |\n for (@result <- resultCh) {\n match result {\n (true, Nil) => {\n stdout!(("Transfer successful:", ${s}, "ASI"))\n }\n (false, reason) => {\n stdout!(("Transfer failed:", reason))\n }\n }\n }\n } |\n for (@(false, errorMsg) <- vaultCh) {\n stdout!(("Sender vault error:", errorMsg))\n } |\n for (@(false, errorMsg) <- toVaultCh) {\n stdout!(("Destination vault error:", errorMsg))\n }\n }\n }\n `})(e,t,r),d=await c.getLatestBlockNumber();if(-1===d)throw new Error("AssetsService.transfer: Invalid block number");const u={term:l,phloLimit:s,phloPrice:1,validAfterBlockNumber:d-1,timestamp:Date.now(),shardId:"root"},h=await fe.sign({wallet:n,data:u},a);return await c.submitDeploy(h)}catch(e){const t="AssetsService.transfer: "+e.message;throw new Error(t)}}async getASIBalance(e){const t=Ue(e);if(!t.isValid)throw new Error(`AssetsService.getASIBalance: Invalid address: ${t.errorCode??"UNKNOWN"}`);const r=ie.getInstance(),n=(e=>`\n new return, rl(\`rho:registry:lookup\`), ASIVaultCh, vaultCh in {\n rl!(\`rho:rchain:asiVault\`, *ASIVaultCh) |\n for (@(_, ASIVault) <- ASIVaultCh) {\n @ASIVault!("findOrCreate", "${Be(e)}", *vaultCh) |\n for (@maybeVault <- vaultCh) {\n match maybeVault {\n (true, vault) => @vault!("balance", *return)\n (false, err) => return!(err)\n }\n }\n }\n }\n`)(e);try{const e=await r.exploreDeployData(n);if(e&&e.length>0){const t=e[0];if(t?.ExprInt?.data)return BigInt(t.ExprInt.data);if(t?.ExprString?.data)throw new Error("Balance check error:")}return BigInt(0)}catch(e){return BigInt(0)}}}class xe{constructor(e,t,r=8){this.id=e,this.name=t,this.decimals=r}getId(){return this.id}getName(){return this.name}getDecimals(){return this.decimals}}class We{static async createAndEncrypt(e,t){const r=await M.encryptWithPassword(e,t);return new We(r)}static createFromEncryptedData(e){return new We(e)}static createFromStringifiedEncryptedData(e){return new We(JSON.parse(e))}constructor(e){this.encryptedSeedData=e}async decrypt(e){return await M.decryptWithPassword(this.encryptedSeedData,e)}toString(){return JSON.stringify(this.encryptedSeedData)}}var Fe;!function(e){e.PRIVATE_KEY="private_key",e.CRYPTO_SALT="crypto_salt",e.CRYPTO_IV="crypto_iv",e.CRYPTO_VERSION="crypto version"}(Fe||(Fe={}));class $e{constructor(e,t,r,n,a){this.name=e,this.index=a,this.masterNodeId=n,this.address=t,this.privateKey=r,this.assets=new Map,this.isLocked=!0}static async fromPrivateKey(e,t,r,n=null,a=null){const s=J.deriveAddressFromPrivateKey(t),i=await this.encryptPrivateKey(t,r);return new $e(e,s,i,n,a)}static fromEncryptedData(e,t,r,n,a){const s=Ue(t);if(!s.isValid)throw new Error(`Invalid address format: ${s.errorCode??"UNKNOWN"}`);return new $e(e,t,r,n,a)}async decrypt(e){if(!$e.unsafeRawKeyExportEnabled)throw new Error("Wallet.decrypt is disabled by default for security. Use withSigningCapability() instead.");return await this.decryptPrivateKey(e)}static enableUnsafeRawKeyExportForLegacyInterop(){$e.unsafeRawKeyExportEnabled=!0}static disableUnsafeRawKeyExport(){$e.unsafeRawKeyExportEnabled=!1}static isUnsafeRawKeyExportEnabled(){return $e.unsafeRawKeyExportEnabled}async decryptPrivateKey(e){try{const t=await M.decryptWithPassword(this.privateKey,e),r=JSON.parse(t);if(r&&"object"==typeof r&&!Array.isArray(r)){const e=Object.keys(r).sort((e,t)=>Number(e)-Number(t)).map(e=>{const t=r[e],n="string"==typeof t?Number(t):t;return"number"!=typeof n||isNaN(n)?0:n});return new Uint8Array(e)}return new Uint8Array(r)}catch(e){throw new Error("Unlock Failed: "+e?.message)}}async withSigningCapability(e,t){const r=await this.decryptPrivateKey(e);let n=!1;const a={signDigest:async e=>{if(n)throw new Error("Signing capability has expired");return await c(e,r)},getPublicKey:()=>{if(n)throw new Error("Signing capability has expired");return z.getPublicKeyFromPrivateKey(r)}};try{return await t(a)}finally{n=!0,r.fill(0)}}getEncryptedPrivateKey(){return this.privateKey}registerAsset(e){this.assets.set(e.getId(),e)}getAddress(){return this.address}getName(){return this.name}getIndex(){return this.index}getAssets(){return this.assets}isWalletLocked(){return this.isLocked}toString(){const e={name:this.name,address:this.address,encryptedPrivateKey:JSON.stringify(this.privateKey),masterNodeId:this.masterNodeId??"",index:this.index?.toString()??""};return JSON.stringify(e)}static async encryptPrivateKey(e,t){return await M.encryptWithPassword(JSON.stringify(e),t)}}$e.unsafeRawKeyExportEnabled=!1;const Ge="0";class He{constructor(e){if("undefined"==typeof window)throw new Error("getVault can only be called in a browser environment");if(this.isLocked=!1,this.wallets=new Map,this.seeds=new Map,this.encryptedVaultData=null,!e)return;const t=JSON.parse(e);this.encryptedVaultData=t,this.isLocked=!0}static getSavedVaultKeys(){this.ensureBrowserEnvironment();const e=[];for(let t=0;t<localStorage.length;t++){const r=localStorage.key(t);r&&r.startsWith(this.vaultPrefix)&&e.push(r)}return e}static getVaultDataFromStorage(e){return this.ensureBrowserEnvironment(),localStorage.getItem(e)}isVaultLocked(){return this.isLocked}save(e="0"){if(He.ensureBrowserEnvironment(),!this.isLocked)throw new Error("Cannot save an unlocked vault");const t=`${He.vaultPrefix}_${e}`;localStorage.setItem(t,JSON.stringify(this.encryptedVaultData))}async lock(e){this.ensureUnlocked();const t=this.toString();this.encryptedVaultData=await M.encryptWithPassword(t,e),this.wallets=new Map,this.seeds=new Map,this.isLocked=!0}async unlock(e){if(!this.isLocked)return;if(!this.encryptedVaultData)throw new Error("Vault was unlocked on undefined encryptedVaultData");const t=await M.decryptWithPassword(this.encryptedVaultData,e),{wallets:r,seeds:n}=JSON.parse(t);this.metaToWallets(r),this.metaToSeeds(n),this.isLocked=!1}isEmpty(){return this.ensureUnlocked(),0===this.wallets.size}getWallets(){return Array.from(this.wallets.values())}getWalletsCount(){return this.ensureUnlocked(),this.wallets.size}getWalletAddresses(){return this.ensureUnlocked(),Array.from(this.wallets.keys())}addWallet(e){this.ensureUnlocked(),this.wallets.set(e.getAddress(),e)}removeWallet(e){this.ensureUnlocked(),this.wallets.delete(e)}getWallet(e){return this.ensureUnlocked(),this.wallets.get(e)}hasWallet(e){return this.ensureUnlocked(),this.wallets.has(e)}hasSeed(e){return this.ensureUnlocked(),this.seeds.has(e)}metaToWallets(e){const t=new Map;Object.keys(e).forEach(r=>{const n=JSON.parse(e[r]),a=$e.fromEncryptedData(n.name,n.address,JSON.parse(n.encryptedPrivateKey),n.masterNodeId,n.index?+n.index:null);t.set(r,a)}),this.wallets=t}metaToSeeds(e){const t=new Map;Object.keys(e).forEach(r=>{const n=We.createFromStringifiedEncryptedData(e[r]);t.set(r,n)}),this.seeds=t}getSeeds(){return this.ensureUnlocked(),Array.from(this.seeds.values())}getSeed(e){return this.ensureUnlocked(),this.seeds.get(e)}addSeed(e,t){this.ensureUnlocked(),this.seeds.set(e,t)}removeSeed(e){this.ensureUnlocked(),this.seeds.delete(e)}getSeedsIds(){return this.ensureUnlocked(),Array.from(this.seeds.keys())}toString(){const e={},t={};this.ensureUnlocked();const r=this.getWalletAddresses(),n=this.getSeedsIds();return r.forEach(e=>{const r=this.getWallet(e);r&&(t[e]=r.toString())}),n.forEach(t=>{const r=this.getSeed(t);r&&(e[t]=r.toString())}),JSON.stringify({wallets:t,seeds:e})}ensureUnlocked(){if(this.isLocked)throw new Error("Attempted to access locked vault")}static ensureBrowserEnvironment(){if("undefined"==typeof window)throw new Error("getVault can only be called in a browser environment")}}He.vaultPrefix="ASI_WALLETS_VAULT";class ze{constructor(e="storage_prefix"){if("undefined"==typeof localStorage)throw new Error("localStorage is not supported in this environment.");this.prefix=e}write(e,t){localStorage.setItem(this.createKey(e),t)}read(e){return localStorage.getItem(this.createKey(e))}delete(e){localStorage.removeItem(this.createKey(e))}has(e){return!!localStorage.getItem(this.createKey(e))}isEmpty(){return!this.getIds().length}clear(){this.getIds().forEach(e=>localStorage.removeItem(e))}getIds(){const e=[];for(let t=0;t<localStorage.length;t++){const r=localStorage.key(t);if(!r)break;r.startsWith(`${this.prefix}`)&&e.push(r)}return e}createKey(e){return`${this.prefix}_${e}`}}export{w as ASI_BASE_UNIT,y as ASI_CHAIN_PREFIX,p as ASI_COIN_TYPE,g as ASI_DECIMALS,Pe as AddressValidationErrorCode,xe as Asset,Me as AssetsService,ne as AxiosHttpClient,ge as BinaryWriter,ie as BlockchainGateway,M as CryptoService,ce as DEFAULT_AXIOS_TIMEOUT_MS,N as DEFAULT_BIP_44_PATH_OPTIONS,oe as DEFAULT_CLIENT_CONFIG,de as DEFAULT_DECIMALS_AMOUNT,ue as DEFAULT_PHLO_LIMIT,he as DEFAULT_RESUBMIT_CONFIG,Ge as DEFAULT_STORAGE_KEY,Ve as DeployResubmitter,ae as DeployStatus,re as DeploymentErrorHandler,We as EncryptedRecord,E as FAULT_TOLERANCE_THRESHOLD,q as FatalDeployErrors,v as FeeService,m as GasFee,I as INVALID_BLOCK_NUMBER,$ as KeyDerivationService,z as KeysManager,le as MAX_WALLETS_PER_ACCOUNT,F as MnemonicService,W as MnemonicStrength,f as POWER_BASE,h as PRIVATE_KEY_LENGTH,Z as RecoverableDeployErrors,ye as ResubmitNodeManager,ze as SecureStorage,fe as SignerService,He as Vault,$e as Wallet,se as WalletClientModes,Fe as WalletMemoryKeys,J as WalletsService,L as arrayBufferToBase64,_ as base64ToArrayBuffer,S as decodeBase16,b as decodeBase58,Q as deploymentErrorMessages,D as encodeBase16,R as encodeBase58,be as fromAtomicAmount,Re as fromAtomicAmountToNumber,ve as fromAtomicAmountToString,Se as genRandomHex,ee as getDeploymentErrorMessage,Ke as isAddress,x as setupBufferPolyfill,Ae as toAtomicAmount,_e as validateAccountName,Ue as validateAddress};
@@ -0,0 +1,6 @@
1
+ import Wallet, { Address } from "@domains/Wallet";
2
+ import { PasswordProvider } from "@domains/Signer";
3
+ export default class AssetsService {
4
+ transfer(fromAddress: Address, toAddress: Address, amount: bigint, wallet: Wallet, passwordProvider: PasswordProvider, phloLimit?: number): Promise<string | undefined>;
5
+ getASIBalance(address: Address): Promise<bigint>;
6
+ }
@@ -0,0 +1,8 @@
1
+ export default class BinaryWriterService {
2
+ private buffer;
3
+ writeString(fieldNumber: number, value: string): void;
4
+ writeInt64(fieldNumber: number, value: number): void;
5
+ private writeInteger;
6
+ private writeInteger64;
7
+ getResultBuffer(): Uint8Array;
8
+ }
@@ -0,0 +1,29 @@
1
+ declare const enum KeyUsage {
2
+ ENCRYPT = "encrypt",
3
+ DECRYPT = "decrypt",
4
+ DERIVATION = "deriveKey"
5
+ }
6
+ export interface CryptoConfig {
7
+ readonly VERSION: number;
8
+ readonly IV_LENGTH: number;
9
+ readonly SALT_LENGTH: number;
10
+ readonly KEY_SIZE_BITS: number;
11
+ readonly KEY_IMPORT_FORMAT: "raw" | "pkcs8" | "spki";
12
+ readonly KEY_DERIVATION_ITERATIONS: number;
13
+ readonly KEY_DERIVATION_FUNCTION: string;
14
+ readonly KEY_IMPORT_USAGE: KeyUsage[];
15
+ readonly HASH_FUNCTION: string;
16
+ readonly ALGORITHM: string;
17
+ }
18
+ export interface EncryptedData {
19
+ data: string;
20
+ salt: string;
21
+ iv: string;
22
+ version: number;
23
+ }
24
+ export default class CryptoService {
25
+ static encryptWithPassword(data: string, password: string): Promise<EncryptedData>;
26
+ static decryptWithPassword(payload: EncryptedData, passphrase: string): Promise<string>;
27
+ static deriveKey(password: string, salt: Uint8Array): Promise<CryptoKey>;
28
+ }
29
+ export {};
@@ -0,0 +1,5 @@
1
+ export default class FeeService {
2
+ static generateRandomGasFee: () => string;
3
+ static getGasFeeAsNumber: () => number;
4
+ static formatGasFee: (fee?: string) => string;
5
+ }
@@ -0,0 +1,15 @@
1
+ import { type BIP32Interface } from "bip32";
2
+ export interface Bip44PathOptions {
3
+ coinType: number;
4
+ account?: number;
5
+ change?: number;
6
+ index?: number;
7
+ }
8
+ export default class KeyDerivationService {
9
+ static buildBip44Path({ coinType, account, change, index, }: Bip44PathOptions): string;
10
+ static derivePrivateKey(masterNode: BIP32Interface, path: string): Uint8Array;
11
+ static mnemonicToSeed(mnemonicWords: string[] | string, passphrase?: string): Promise<Uint8Array>;
12
+ static seedToMasterNode(seed: any): BIP32Interface;
13
+ static deriveKeyFromMnemonic(mnemonicWords: string[], options?: Bip44PathOptions): Promise<Uint8Array>;
14
+ static deriveNextKeyFromMnemonic(mnemonicWords: string[], currentIndex: number, options?: Omit<Bip44PathOptions, "index">): Promise<Uint8Array>;
15
+ }
@@ -0,0 +1,14 @@
1
+ import { Bip44PathOptions } from "@services/KeyDerivation";
2
+ export interface KeyPair {
3
+ privateKey: Uint8Array;
4
+ publicKey: Uint8Array;
5
+ }
6
+ export default class KeysManager {
7
+ static generateRandomKey(length?: number): Uint8Array;
8
+ static generateKeyPair(keyLength?: number): KeyPair;
9
+ static getKeyPairFromPrivateKey(privateKey: Uint8Array): KeyPair;
10
+ static getPublicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
11
+ static convertKeyToHex(key: Uint8Array): string;
12
+ static deriveKeyFromMnemonic(mnemonicWords: string[], options?: Bip44PathOptions): Promise<Uint8Array>;
13
+ static generateMpcKeyPair(): any;
14
+ }