@dynamic-labs-wallet/sui 0.0.75 → 0.0.76-preview
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/index.cjs.js +126 -2
- package/index.esm.js +127 -3
- package/package.json +4 -3
- package/src/client/client.d.ts +49 -2
- package/src/client/client.d.ts.map +1 -1
- package/src/client/constants.d.ts +2 -0
- package/src/client/constants.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var browser = require('@dynamic-labs-wallet/browser');
|
|
4
4
|
var ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
5
5
|
var cryptography = require('@mysten/sui/cryptography');
|
|
6
|
+
var converter = require('bech32-converting');
|
|
6
7
|
var verify = require('@mysten/sui/verify');
|
|
7
8
|
var bcs = require('@mysten/sui/bcs');
|
|
8
9
|
var blake2b = require('@noble/hashes/blake2b');
|
|
@@ -20,6 +21,8 @@ function _extends() {
|
|
|
20
21
|
|
|
21
22
|
const ERROR_KEYGEN_FAILED = 'Error with keygen';
|
|
22
23
|
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating sui wallet account';
|
|
24
|
+
const ERROR_IMPORT_PRIVATE_KEY = 'Error importing private key';
|
|
25
|
+
const ERROR_EXPORT_PRIVATE_KEY = 'Error exporting private key';
|
|
23
26
|
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
24
27
|
const ERROR_VERIFY_TRANSACTION_SIGNATURE = 'Error verifying transaction signature';
|
|
25
28
|
|
|
@@ -67,7 +70,6 @@ class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
|
67
70
|
});
|
|
68
71
|
// Update client key shares in wallet map
|
|
69
72
|
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
70
|
-
// TODO: remove this once iframe handling for secret shares is implemented
|
|
71
73
|
await this.setClientKeySharesToLocalStorage({
|
|
72
74
|
accountAddress,
|
|
73
75
|
clientKeyShares,
|
|
@@ -81,7 +83,7 @@ class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
|
81
83
|
});
|
|
82
84
|
return {
|
|
83
85
|
accountAddress,
|
|
84
|
-
rawPublicKey,
|
|
86
|
+
rawPublicKey: rawPublicKey,
|
|
85
87
|
publicKeyHex
|
|
86
88
|
};
|
|
87
89
|
} catch (error) {
|
|
@@ -208,6 +210,128 @@ class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
|
208
210
|
publicKeyHex: rawPublicKey
|
|
209
211
|
};
|
|
210
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Converts a Sui private key from Bech32 format to a 64-character hex string.
|
|
215
|
+
* The output is compatible with RFC8032 Ed25519 private key format.
|
|
216
|
+
*
|
|
217
|
+
* @param suiPrivateKey - The Sui private key in Bech32 format starting with "suiprivkey1"
|
|
218
|
+
* @returns A 64-character hex string representing the Ed25519 private key
|
|
219
|
+
* @throws Error if the input is not a valid Sui private key format
|
|
220
|
+
*/ convertSuiPrivateKeyToHex(suiPrivateKey) {
|
|
221
|
+
if (!suiPrivateKey.startsWith('suiprivkey1')) {
|
|
222
|
+
throw new Error('Invalid input: Sui private key must start with "suiprivkey1"');
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const suiConverter = converter('suiprivkey');
|
|
226
|
+
const hexKey = suiConverter.toHex(suiPrivateKey);
|
|
227
|
+
let cleanHex = hexKey.startsWith('0x00') ? hexKey.slice(4) : hexKey.startsWith('0x') ? hexKey.slice(2) : hexKey;
|
|
228
|
+
if (cleanHex.length > 64) {
|
|
229
|
+
cleanHex = cleanHex.slice(cleanHex.length - 64);
|
|
230
|
+
}
|
|
231
|
+
if (cleanHex.length !== 64) {
|
|
232
|
+
throw new Error(`Invalid output: Expected 64 characters, got ${cleanHex.length}`);
|
|
233
|
+
}
|
|
234
|
+
return cleanHex.toLowerCase();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
if (error instanceof Error) {
|
|
237
|
+
throw new Error(`Failed to convert Sui private key: ${error.message}`);
|
|
238
|
+
}
|
|
239
|
+
throw new Error('Failed to convert Sui private key: Unknown error');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Gets the public key for a given private key
|
|
244
|
+
*
|
|
245
|
+
* @param privateKey The private key to get the public key for
|
|
246
|
+
* @returns The public key for the given private key
|
|
247
|
+
*/ getPublicKeyFromPrivateKey(privateKey) {
|
|
248
|
+
const keypair = ed25519.Ed25519Keypair.fromSecretKey(privateKey);
|
|
249
|
+
const publicKey = keypair.getPublicKey();
|
|
250
|
+
const publicKeyBase58 = publicKey.toSuiAddress();
|
|
251
|
+
return publicKeyBase58;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Imports the private key for a given account address
|
|
255
|
+
*
|
|
256
|
+
* @param privateKey The private key to import
|
|
257
|
+
* @param chainName The chain name to import the private key for
|
|
258
|
+
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
259
|
+
* @param password The password for encrypted backup shares
|
|
260
|
+
* @returns The account address, raw public key, and client key shares
|
|
261
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
262
|
+
try {
|
|
263
|
+
const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
|
|
264
|
+
const formattedPrivateKey = await this.convertSuiPrivateKeyToHex(privateKey);
|
|
265
|
+
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
266
|
+
chainName,
|
|
267
|
+
privateKey: formattedPrivateKey,
|
|
268
|
+
thresholdSignatureScheme,
|
|
269
|
+
onError,
|
|
270
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
271
|
+
// update wallet map
|
|
272
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
273
|
+
accountAddress,
|
|
274
|
+
walletId,
|
|
275
|
+
chainName: this.chainName,
|
|
276
|
+
thresholdSignatureScheme,
|
|
277
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
if (!rawPublicKey || !clientKeyShares) {
|
|
282
|
+
throw new Error(ERROR_IMPORT_PRIVATE_KEY);
|
|
283
|
+
}
|
|
284
|
+
const { accountAddress } = await this.deriveAccountAddress({
|
|
285
|
+
rawPublicKey: rawPublicKey
|
|
286
|
+
});
|
|
287
|
+
if (accountAddress !== publicKey) {
|
|
288
|
+
throw new Error(`Public key mismatch: derived address ${accountAddress} !== public key ${publicKey}`);
|
|
289
|
+
}
|
|
290
|
+
// Update client key shares in wallet map
|
|
291
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
292
|
+
await this.setClientKeySharesToLocalStorage({
|
|
293
|
+
accountAddress,
|
|
294
|
+
clientKeyShares,
|
|
295
|
+
overwriteOrMerge: 'overwrite'
|
|
296
|
+
});
|
|
297
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
298
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
299
|
+
accountAddress,
|
|
300
|
+
clientKeyShares,
|
|
301
|
+
password
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
accountAddress,
|
|
305
|
+
rawPublicKey: rawPublicKey,
|
|
306
|
+
clientKeyShares
|
|
307
|
+
};
|
|
308
|
+
} catch (error) {
|
|
309
|
+
this.logger.error(ERROR_IMPORT_PRIVATE_KEY, error);
|
|
310
|
+
throw new Error(ERROR_IMPORT_PRIVATE_KEY);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Exports the private key for a given account address
|
|
315
|
+
*
|
|
316
|
+
* @param accountAddress The account address to export the private key for
|
|
317
|
+
* @param password The password for encrypted backup shares
|
|
318
|
+
* @returns The private key
|
|
319
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
320
|
+
try {
|
|
321
|
+
const { derivedPrivateKey } = await this.exportKey({
|
|
322
|
+
accountAddress,
|
|
323
|
+
chainName: this.chainName,
|
|
324
|
+
password
|
|
325
|
+
});
|
|
326
|
+
if (!derivedPrivateKey) {
|
|
327
|
+
throw new Error('Derived private key is undefined');
|
|
328
|
+
}
|
|
329
|
+
return derivedPrivateKey;
|
|
330
|
+
} catch (error) {
|
|
331
|
+
this.logger.error(ERROR_EXPORT_PRIVATE_KEY, error);
|
|
332
|
+
throw new Error(ERROR_EXPORT_PRIVATE_KEY);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
211
335
|
async getSuiWallets() {
|
|
212
336
|
const wallets = await this.getWallets();
|
|
213
337
|
const suiWallets = wallets.filter((wallet)=>wallet.chainName === 'sui');
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DynamicWalletClient, getClientKeyShareBackupInfo, getMPCChainConfig } from '@dynamic-labs-wallet/browser';
|
|
2
|
-
import { Ed25519PublicKey } from '@mysten/sui/keypairs/ed25519';
|
|
2
|
+
import { Ed25519PublicKey, Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
3
3
|
import { messageWithIntent, toSerializedSignature } from '@mysten/sui/cryptography';
|
|
4
|
+
import converter from 'bech32-converting';
|
|
4
5
|
import { verifyPersonalMessageSignature, verifyTransactionSignature } from '@mysten/sui/verify';
|
|
5
6
|
import { bcs } from '@mysten/sui/bcs';
|
|
6
7
|
import { blake2b } from '@noble/hashes/blake2b';
|
|
@@ -18,6 +19,8 @@ function _extends() {
|
|
|
18
19
|
|
|
19
20
|
const ERROR_KEYGEN_FAILED = 'Error with keygen';
|
|
20
21
|
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating sui wallet account';
|
|
22
|
+
const ERROR_IMPORT_PRIVATE_KEY = 'Error importing private key';
|
|
23
|
+
const ERROR_EXPORT_PRIVATE_KEY = 'Error exporting private key';
|
|
21
24
|
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
22
25
|
const ERROR_VERIFY_TRANSACTION_SIGNATURE = 'Error verifying transaction signature';
|
|
23
26
|
|
|
@@ -65,7 +68,6 @@ class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
65
68
|
});
|
|
66
69
|
// Update client key shares in wallet map
|
|
67
70
|
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
68
|
-
// TODO: remove this once iframe handling for secret shares is implemented
|
|
69
71
|
await this.setClientKeySharesToLocalStorage({
|
|
70
72
|
accountAddress,
|
|
71
73
|
clientKeyShares,
|
|
@@ -79,7 +81,7 @@ class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
79
81
|
});
|
|
80
82
|
return {
|
|
81
83
|
accountAddress,
|
|
82
|
-
rawPublicKey,
|
|
84
|
+
rawPublicKey: rawPublicKey,
|
|
83
85
|
publicKeyHex
|
|
84
86
|
};
|
|
85
87
|
} catch (error) {
|
|
@@ -206,6 +208,128 @@ class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
206
208
|
publicKeyHex: rawPublicKey
|
|
207
209
|
};
|
|
208
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Converts a Sui private key from Bech32 format to a 64-character hex string.
|
|
213
|
+
* The output is compatible with RFC8032 Ed25519 private key format.
|
|
214
|
+
*
|
|
215
|
+
* @param suiPrivateKey - The Sui private key in Bech32 format starting with "suiprivkey1"
|
|
216
|
+
* @returns A 64-character hex string representing the Ed25519 private key
|
|
217
|
+
* @throws Error if the input is not a valid Sui private key format
|
|
218
|
+
*/ convertSuiPrivateKeyToHex(suiPrivateKey) {
|
|
219
|
+
if (!suiPrivateKey.startsWith('suiprivkey1')) {
|
|
220
|
+
throw new Error('Invalid input: Sui private key must start with "suiprivkey1"');
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const suiConverter = converter('suiprivkey');
|
|
224
|
+
const hexKey = suiConverter.toHex(suiPrivateKey);
|
|
225
|
+
let cleanHex = hexKey.startsWith('0x00') ? hexKey.slice(4) : hexKey.startsWith('0x') ? hexKey.slice(2) : hexKey;
|
|
226
|
+
if (cleanHex.length > 64) {
|
|
227
|
+
cleanHex = cleanHex.slice(cleanHex.length - 64);
|
|
228
|
+
}
|
|
229
|
+
if (cleanHex.length !== 64) {
|
|
230
|
+
throw new Error(`Invalid output: Expected 64 characters, got ${cleanHex.length}`);
|
|
231
|
+
}
|
|
232
|
+
return cleanHex.toLowerCase();
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (error instanceof Error) {
|
|
235
|
+
throw new Error(`Failed to convert Sui private key: ${error.message}`);
|
|
236
|
+
}
|
|
237
|
+
throw new Error('Failed to convert Sui private key: Unknown error');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Gets the public key for a given private key
|
|
242
|
+
*
|
|
243
|
+
* @param privateKey The private key to get the public key for
|
|
244
|
+
* @returns The public key for the given private key
|
|
245
|
+
*/ getPublicKeyFromPrivateKey(privateKey) {
|
|
246
|
+
const keypair = Ed25519Keypair.fromSecretKey(privateKey);
|
|
247
|
+
const publicKey = keypair.getPublicKey();
|
|
248
|
+
const publicKeyBase58 = publicKey.toSuiAddress();
|
|
249
|
+
return publicKeyBase58;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Imports the private key for a given account address
|
|
253
|
+
*
|
|
254
|
+
* @param privateKey The private key to import
|
|
255
|
+
* @param chainName The chain name to import the private key for
|
|
256
|
+
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
257
|
+
* @param password The password for encrypted backup shares
|
|
258
|
+
* @returns The account address, raw public key, and client key shares
|
|
259
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
|
|
260
|
+
try {
|
|
261
|
+
const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
|
|
262
|
+
const formattedPrivateKey = await this.convertSuiPrivateKeyToHex(privateKey);
|
|
263
|
+
const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
|
|
264
|
+
chainName,
|
|
265
|
+
privateKey: formattedPrivateKey,
|
|
266
|
+
thresholdSignatureScheme,
|
|
267
|
+
onError,
|
|
268
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
269
|
+
// update wallet map
|
|
270
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
271
|
+
accountAddress,
|
|
272
|
+
walletId,
|
|
273
|
+
chainName: this.chainName,
|
|
274
|
+
thresholdSignatureScheme,
|
|
275
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
if (!rawPublicKey || !clientKeyShares) {
|
|
280
|
+
throw new Error(ERROR_IMPORT_PRIVATE_KEY);
|
|
281
|
+
}
|
|
282
|
+
const { accountAddress } = await this.deriveAccountAddress({
|
|
283
|
+
rawPublicKey: rawPublicKey
|
|
284
|
+
});
|
|
285
|
+
if (accountAddress !== publicKey) {
|
|
286
|
+
throw new Error(`Public key mismatch: derived address ${accountAddress} !== public key ${publicKey}`);
|
|
287
|
+
}
|
|
288
|
+
// Update client key shares in wallet map
|
|
289
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
290
|
+
await this.setClientKeySharesToLocalStorage({
|
|
291
|
+
accountAddress,
|
|
292
|
+
clientKeyShares,
|
|
293
|
+
overwriteOrMerge: 'overwrite'
|
|
294
|
+
});
|
|
295
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
296
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
297
|
+
accountAddress,
|
|
298
|
+
clientKeyShares,
|
|
299
|
+
password
|
|
300
|
+
});
|
|
301
|
+
return {
|
|
302
|
+
accountAddress,
|
|
303
|
+
rawPublicKey: rawPublicKey,
|
|
304
|
+
clientKeyShares
|
|
305
|
+
};
|
|
306
|
+
} catch (error) {
|
|
307
|
+
this.logger.error(ERROR_IMPORT_PRIVATE_KEY, error);
|
|
308
|
+
throw new Error(ERROR_IMPORT_PRIVATE_KEY);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Exports the private key for a given account address
|
|
313
|
+
*
|
|
314
|
+
* @param accountAddress The account address to export the private key for
|
|
315
|
+
* @param password The password for encrypted backup shares
|
|
316
|
+
* @returns The private key
|
|
317
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
318
|
+
try {
|
|
319
|
+
const { derivedPrivateKey } = await this.exportKey({
|
|
320
|
+
accountAddress,
|
|
321
|
+
chainName: this.chainName,
|
|
322
|
+
password
|
|
323
|
+
});
|
|
324
|
+
if (!derivedPrivateKey) {
|
|
325
|
+
throw new Error('Derived private key is undefined');
|
|
326
|
+
}
|
|
327
|
+
return derivedPrivateKey;
|
|
328
|
+
} catch (error) {
|
|
329
|
+
this.logger.error(ERROR_EXPORT_PRIVATE_KEY, error);
|
|
330
|
+
throw new Error(ERROR_EXPORT_PRIVATE_KEY);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
209
333
|
async getSuiWallets() {
|
|
210
334
|
const wallets = await this.getWallets();
|
|
211
335
|
const suiWallets = wallets.filter((wallet)=>wallet.chainName === 'sui');
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/sui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.76-preview",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
6
|
+
"@dynamic-labs-wallet/browser": "0.0.76-preview",
|
|
7
7
|
"@mysten/sui": "1.26.0",
|
|
8
|
-
"@noble/hashes": "1.7.1"
|
|
8
|
+
"@noble/hashes": "1.7.1",
|
|
9
|
+
"bech32-converting": "^1.0.9"
|
|
9
10
|
},
|
|
10
11
|
"publishConfig": {
|
|
11
12
|
"access": "public"
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientKeyShare, DynamicWalletClient,
|
|
1
|
+
import { ClientKeyShare, DynamicWalletClient, ThresholdSignatureScheme, DynamicWalletClientProps } from '@dynamic-labs-wallet/browser';
|
|
2
2
|
export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
3
3
|
readonly chainName = "SUI";
|
|
4
4
|
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, }: DynamicWalletClientProps);
|
|
@@ -9,7 +9,7 @@ export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
9
9
|
}): Promise<{
|
|
10
10
|
accountAddress: string;
|
|
11
11
|
publicKeyHex: string;
|
|
12
|
-
rawPublicKey:
|
|
12
|
+
rawPublicKey: string | undefined;
|
|
13
13
|
}>;
|
|
14
14
|
getRawPublicKeyFromClientKeyShares({ chainName, clientKeyShare, }: {
|
|
15
15
|
chainName: string;
|
|
@@ -37,6 +37,53 @@ export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
|
37
37
|
accountAddress: string;
|
|
38
38
|
publicKeyHex: string;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Converts a Sui private key from Bech32 format to a 64-character hex string.
|
|
42
|
+
* The output is compatible with RFC8032 Ed25519 private key format.
|
|
43
|
+
*
|
|
44
|
+
* @param suiPrivateKey - The Sui private key in Bech32 format starting with "suiprivkey1"
|
|
45
|
+
* @returns A 64-character hex string representing the Ed25519 private key
|
|
46
|
+
* @throws Error if the input is not a valid Sui private key format
|
|
47
|
+
*/
|
|
48
|
+
convertSuiPrivateKeyToHex(suiPrivateKey: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the public key for a given private key
|
|
51
|
+
*
|
|
52
|
+
* @param privateKey The private key to get the public key for
|
|
53
|
+
* @returns The public key for the given private key
|
|
54
|
+
*/
|
|
55
|
+
getPublicKeyFromPrivateKey(privateKey: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Imports the private key for a given account address
|
|
58
|
+
*
|
|
59
|
+
* @param privateKey The private key to import
|
|
60
|
+
* @param chainName The chain name to import the private key for
|
|
61
|
+
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
62
|
+
* @param password The password for encrypted backup shares
|
|
63
|
+
* @returns The account address, raw public key, and client key shares
|
|
64
|
+
*/
|
|
65
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, }: {
|
|
66
|
+
privateKey: string;
|
|
67
|
+
chainName: string;
|
|
68
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
69
|
+
password?: string;
|
|
70
|
+
onError?: (error: Error) => void;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
accountAddress: string;
|
|
73
|
+
rawPublicKey: string | undefined;
|
|
74
|
+
clientKeyShares: ClientKeyShare[];
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Exports the private key for a given account address
|
|
78
|
+
*
|
|
79
|
+
* @param accountAddress The account address to export the private key for
|
|
80
|
+
* @param password The password for encrypted backup shares
|
|
81
|
+
* @returns The private key
|
|
82
|
+
*/
|
|
83
|
+
exportPrivateKey({ accountAddress, password, }: {
|
|
84
|
+
accountAddress: string;
|
|
85
|
+
password?: string;
|
|
86
|
+
}): Promise<string>;
|
|
40
87
|
getSuiWallets(): Promise<any>;
|
|
41
88
|
}
|
|
42
89
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EAGzB,MAAM,8BAA8B,CAAC;AAkBtC,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,KAAK,GACN,EAAE,wBAAwB;IAWrB,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,GACR,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;KAClC,CAAC;IAsDI,kCAAkC,CAAC,EACvC,SAAS,EACT,cAAc,GACf,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,cAAc,CAAC;KAChC;IAYD;;OAEG;YACW,eAAe;YAoCf,sBAAsB;YA6BtB,0BAA0B;IA6BlC,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCb,eAAe,CAAC,EACpB,WAAW,EACX,aAAa,EACb,QAAoB,GACrB,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCnB,oBAAoB,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE;;;;IAW/D;;;;;;;OAOG;IACH,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAgCxD;;;;;OAKG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM;IAO7C;;;;;;;;OAQG;IACG,gBAAgB,CAAC,EACrB,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,QAAoB,EACpB,OAAO,GACR,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IA+DF;;;;;;OAMG;IACG,gBAAgB,CAAC,EACrB,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAiBK,aAAa;CAOpB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
|
|
2
2
|
export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating sui wallet account";
|
|
3
|
+
export declare const ERROR_IMPORT_PRIVATE_KEY = "Error importing private key";
|
|
4
|
+
export declare const ERROR_EXPORT_PRIVATE_KEY = "Error exporting private key";
|
|
3
5
|
export declare const ERROR_SIGN_MESSAGE = "Error signing message";
|
|
4
6
|
export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
|
|
5
7
|
export declare const ERROR_VERIFY_MESSAGE_SIGNATURE = "Error verifying message signature";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,8BAA8B,sCACN,CAAC;AAEtC,eAAO,MAAM,kCAAkC,0CACN,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,8BAA8B,sCACN,CAAC;AAEtC,eAAO,MAAM,kCAAkC,0CACN,CAAC"}
|