@dynamic-labs-wallet/node-svm 0.0.354 → 1.0.0-beta
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 +89 -107
- package/index.esm.js +90 -108
- package/package.json +2 -2
- package/src/client/client.d.ts +30 -24
- package/src/client/client.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -3,17 +3,6 @@
|
|
|
3
3
|
var node = require('@dynamic-labs-wallet/node');
|
|
4
4
|
var web3_js = require('@solana/web3.js');
|
|
5
5
|
|
|
6
|
-
function _extends() {
|
|
7
|
-
_extends = Object.assign || function assign(target) {
|
|
8
|
-
for(var i = 1; i < arguments.length; i++){
|
|
9
|
-
var source = arguments[i];
|
|
10
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
11
|
-
}
|
|
12
|
-
return target;
|
|
13
|
-
};
|
|
14
|
-
return _extends.apply(this, arguments);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
6
|
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating svm wallet account';
|
|
18
7
|
const ERROR_SIGN_RAW_MESSAGE = 'Error signing raw message';
|
|
19
8
|
|
|
@@ -92,9 +81,10 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
92
81
|
* Creates a wallet account on the Solana chain
|
|
93
82
|
*
|
|
94
83
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
95
|
-
* @returns The
|
|
96
|
-
*/ async createWalletAccount({ thresholdSignatureScheme, password
|
|
84
|
+
* @returns The walletMetadata, raw public key, and client key shares
|
|
85
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic = false }) {
|
|
97
86
|
try {
|
|
87
|
+
let resolvedWalletId;
|
|
98
88
|
let ceremonyCeremonyCompleteResolver;
|
|
99
89
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
100
90
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -102,28 +92,11 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
102
92
|
const { rawPublicKey, externalServerKeyShares } = await this.keyGen({
|
|
103
93
|
chainName: this.chainName,
|
|
104
94
|
thresholdSignatureScheme,
|
|
95
|
+
password,
|
|
96
|
+
backUpToDynamic,
|
|
105
97
|
onError,
|
|
106
|
-
onCeremonyComplete: (
|
|
107
|
-
|
|
108
|
-
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
109
|
-
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
110
|
-
accountAddress,
|
|
111
|
-
walletId,
|
|
112
|
-
chainName: this.chainName,
|
|
113
|
-
thresholdSignatureScheme,
|
|
114
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
115
|
-
index,
|
|
116
|
-
value
|
|
117
|
-
]))),
|
|
118
|
-
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
119
|
-
});
|
|
120
|
-
this.logger.debug('walletMap updated for wallet', {
|
|
121
|
-
context: {
|
|
122
|
-
accountAddress,
|
|
123
|
-
walletId,
|
|
124
|
-
walletMap: this.walletMap
|
|
125
|
-
}
|
|
126
|
-
});
|
|
98
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
99
|
+
resolvedWalletId = walletId;
|
|
127
100
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
128
101
|
}
|
|
129
102
|
});
|
|
@@ -132,21 +105,34 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
132
105
|
if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array || typeof rawPublicKey === 'string')) {
|
|
133
106
|
throw new Error('Raw public key is not a Uint8Array or string' + typeof rawPublicKey);
|
|
134
107
|
}
|
|
135
|
-
if (!externalServerKeyShares) {
|
|
108
|
+
if (!externalServerKeyShares || !resolvedWalletId) {
|
|
136
109
|
throw new Error('Error creating wallet account');
|
|
137
110
|
}
|
|
138
111
|
const { accountAddress } = await this.deriveAccountAddress(rawPublicKey);
|
|
139
|
-
const
|
|
112
|
+
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
113
|
+
const walletMetadata = {
|
|
114
|
+
walletId: resolvedWalletId,
|
|
115
|
+
accountAddress,
|
|
116
|
+
chainName: this.chainName,
|
|
117
|
+
thresholdSignatureScheme,
|
|
118
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
119
|
+
index,
|
|
120
|
+
value
|
|
121
|
+
])))
|
|
122
|
+
};
|
|
123
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
140
124
|
accountAddress,
|
|
141
125
|
externalServerKeyShares,
|
|
142
126
|
password,
|
|
143
|
-
|
|
127
|
+
backUpToDynamic,
|
|
128
|
+
walletMetadata
|
|
144
129
|
});
|
|
130
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
145
131
|
return {
|
|
146
|
-
|
|
132
|
+
walletMetadata,
|
|
147
133
|
rawPublicKey,
|
|
148
134
|
externalServerKeyShares,
|
|
149
|
-
externalKeySharesWithBackupStatus
|
|
135
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
150
136
|
};
|
|
151
137
|
} catch (error) {
|
|
152
138
|
logError$1({
|
|
@@ -173,22 +159,14 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
173
159
|
* This function takes a message and returns it after being signed with MPC
|
|
174
160
|
*
|
|
175
161
|
* @param message The message to sign (Uint8Array)
|
|
176
|
-
* @param
|
|
162
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
177
163
|
* @param password The password for encrypted backup shares
|
|
178
|
-
*/ async signMessage({ message,
|
|
179
|
-
|
|
164
|
+
*/ async signMessage({ message, walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
165
|
+
const { accountAddress } = walletMetadata;
|
|
180
166
|
if (!accountAddress) {
|
|
181
167
|
throw new Error('Account address is required');
|
|
182
168
|
}
|
|
183
169
|
try {
|
|
184
|
-
// Attempt to recover key shares from backup if not provided
|
|
185
|
-
await this.ensureKeySharesRecovered({
|
|
186
|
-
accountAddress,
|
|
187
|
-
password,
|
|
188
|
-
walletOperation: node.WalletOperation.SIGN_MESSAGE,
|
|
189
|
-
externalServerKeyShares,
|
|
190
|
-
errorMessage: 'External server key shares are required to sign a message. No backup shares available for recovery.'
|
|
191
|
-
});
|
|
192
170
|
const messageBytes = typeof message === 'string' ? new TextEncoder().encode(message) : message;
|
|
193
171
|
const messageHex = toHex(messageBytes);
|
|
194
172
|
const signatureEd25519 = await this.sign({
|
|
@@ -196,7 +174,8 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
196
174
|
accountAddress,
|
|
197
175
|
chainName: this.chainName,
|
|
198
176
|
password,
|
|
199
|
-
externalServerKeyShares
|
|
177
|
+
externalServerKeyShares,
|
|
178
|
+
walletMetadata
|
|
200
179
|
});
|
|
201
180
|
return encodeBase58(signatureEd25519);
|
|
202
181
|
} catch (error) {
|
|
@@ -215,21 +194,14 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
215
194
|
* The message must be a hex string representing already-hashed data.
|
|
216
195
|
*
|
|
217
196
|
* @param message The pre-formatted hex message to sign
|
|
218
|
-
* @param
|
|
197
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
219
198
|
* @param password The password for encrypted backup shares
|
|
220
|
-
*/ async signRawMessage({ message,
|
|
199
|
+
*/ async signRawMessage({ message, walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
200
|
+
const { accountAddress } = walletMetadata;
|
|
221
201
|
if (!accountAddress) {
|
|
222
202
|
throw new Error('Account address is required');
|
|
223
203
|
}
|
|
224
204
|
try {
|
|
225
|
-
// Attempt to recover key shares from backup if not provided
|
|
226
|
-
await this.ensureKeySharesRecovered({
|
|
227
|
-
accountAddress,
|
|
228
|
-
password,
|
|
229
|
-
walletOperation: node.WalletOperation.SIGN_MESSAGE,
|
|
230
|
-
externalServerKeyShares,
|
|
231
|
-
errorMessage: 'External server key shares are required to sign a raw message. No backup shares available for recovery.'
|
|
232
|
-
});
|
|
233
205
|
const messageHex = node.stripHexPrefix(message);
|
|
234
206
|
const signatureEd25519 = await this.sign({
|
|
235
207
|
message: messageHex,
|
|
@@ -237,7 +209,8 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
237
209
|
chainName: this.chainName,
|
|
238
210
|
password,
|
|
239
211
|
externalServerKeyShares,
|
|
240
|
-
isFormatted: true
|
|
212
|
+
isFormatted: true,
|
|
213
|
+
walletMetadata
|
|
241
214
|
});
|
|
242
215
|
return encodeBase58(signatureEd25519);
|
|
243
216
|
} catch (error) {
|
|
@@ -248,14 +221,16 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
248
221
|
accountAddress
|
|
249
222
|
}
|
|
250
223
|
});
|
|
251
|
-
throw new Error(ERROR_SIGN_RAW_MESSAGE
|
|
224
|
+
throw new Error(ERROR_SIGN_RAW_MESSAGE, {
|
|
225
|
+
cause: error
|
|
226
|
+
});
|
|
252
227
|
}
|
|
253
228
|
}
|
|
254
229
|
//todo:should txn just be a string?
|
|
255
|
-
async signTransaction({
|
|
256
|
-
|
|
257
|
-
if (!
|
|
258
|
-
throw new Error('
|
|
230
|
+
async signTransaction({ walletMetadata, transaction, password = undefined, externalServerKeyShares, sponsor = false }) {
|
|
231
|
+
const { accountAddress } = walletMetadata;
|
|
232
|
+
if (!accountAddress) {
|
|
233
|
+
throw new Error('Account address is required');
|
|
259
234
|
}
|
|
260
235
|
if (sponsor) {
|
|
261
236
|
if (typeof transaction === 'string') {
|
|
@@ -265,19 +240,7 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
265
240
|
transaction
|
|
266
241
|
});
|
|
267
242
|
}
|
|
268
|
-
await this.verifyPassword({
|
|
269
|
-
accountAddress: senderAddress,
|
|
270
|
-
password
|
|
271
|
-
});
|
|
272
243
|
try {
|
|
273
|
-
// Attempt to recover key shares from backup if not provided
|
|
274
|
-
await this.ensureKeySharesRecovered({
|
|
275
|
-
accountAddress: senderAddress,
|
|
276
|
-
password,
|
|
277
|
-
walletOperation: node.WalletOperation.SIGN_TRANSACTION,
|
|
278
|
-
externalServerKeyShares,
|
|
279
|
-
errorMessage: 'External server key shares are required to sign transaction. No backup shares available for recovery.'
|
|
280
|
-
});
|
|
281
244
|
let messageToSign;
|
|
282
245
|
if (typeof transaction === 'string') {
|
|
283
246
|
messageToSign = transaction.startsWith('0x') ? transaction.slice(2) : transaction;
|
|
@@ -290,10 +253,12 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
290
253
|
}
|
|
291
254
|
const signatureEd25519 = await this.sign({
|
|
292
255
|
message: messageToSign,
|
|
293
|
-
accountAddress
|
|
256
|
+
accountAddress,
|
|
294
257
|
chainName: this.chainName,
|
|
295
258
|
password,
|
|
296
|
-
externalServerKeyShares
|
|
259
|
+
externalServerKeyShares,
|
|
260
|
+
walletMetadata,
|
|
261
|
+
walletOperation: node.WalletOperation.SIGN_TRANSACTION
|
|
297
262
|
});
|
|
298
263
|
if (!signatureEd25519) {
|
|
299
264
|
throw new Error('Signature is undefined');
|
|
@@ -304,24 +269,26 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
304
269
|
message: 'Error in signTransaction:',
|
|
305
270
|
error: error,
|
|
306
271
|
context: {
|
|
307
|
-
|
|
272
|
+
accountAddress
|
|
308
273
|
}
|
|
309
274
|
});
|
|
310
275
|
throw error;
|
|
311
276
|
}
|
|
312
277
|
}
|
|
313
278
|
/**
|
|
314
|
-
* Exports the private key for a given
|
|
279
|
+
* Exports the private key for a given wallet
|
|
315
280
|
*
|
|
316
|
-
* @param
|
|
281
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
317
282
|
* @param password The password for encrypted backup shares
|
|
318
283
|
* @returns The private key
|
|
319
|
-
*/ async exportPrivateKey({
|
|
284
|
+
*/ async exportPrivateKey({ walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
285
|
+
const { accountAddress } = walletMetadata;
|
|
320
286
|
const { derivedPrivateKey } = await this.exportKey({
|
|
321
287
|
accountAddress,
|
|
322
288
|
chainName: this.chainName,
|
|
323
289
|
password,
|
|
324
|
-
externalServerKeyShares
|
|
290
|
+
externalServerKeyShares,
|
|
291
|
+
walletMetadata
|
|
325
292
|
});
|
|
326
293
|
if (!derivedPrivateKey) {
|
|
327
294
|
throw new Error('Derived private key is undefined');
|
|
@@ -378,8 +345,9 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
378
345
|
* @param chainName The chain name to import the private key for
|
|
379
346
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
380
347
|
* @param password The password for encrypted backup shares
|
|
381
|
-
* @returns The
|
|
382
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password
|
|
348
|
+
* @returns The walletMetadata, raw public key, and client key shares
|
|
349
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, backUpToDynamic = false }) {
|
|
350
|
+
let resolvedWalletId;
|
|
383
351
|
let ceremonyCeremonyCompleteResolver;
|
|
384
352
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
385
353
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -391,44 +359,47 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
|
|
|
391
359
|
chainName,
|
|
392
360
|
privateKey: formattedPrivateKey,
|
|
393
361
|
thresholdSignatureScheme,
|
|
362
|
+
password,
|
|
363
|
+
backUpToDynamic,
|
|
394
364
|
onError,
|
|
395
|
-
onCeremonyComplete: (
|
|
396
|
-
|
|
397
|
-
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
398
|
-
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
399
|
-
accountAddress,
|
|
400
|
-
walletId,
|
|
401
|
-
chainName: this.chainName,
|
|
402
|
-
thresholdSignatureScheme,
|
|
403
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
404
|
-
index,
|
|
405
|
-
value
|
|
406
|
-
]))),
|
|
407
|
-
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
408
|
-
});
|
|
365
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
366
|
+
resolvedWalletId = walletId;
|
|
409
367
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
410
368
|
}
|
|
411
369
|
});
|
|
412
370
|
// Wait for the ceremony to complete before proceeding
|
|
413
371
|
await ceremonyCompletePromise;
|
|
414
|
-
if (!rawPublicKey || !externalServerKeyShares) {
|
|
372
|
+
if (!rawPublicKey || !externalServerKeyShares || !resolvedWalletId) {
|
|
415
373
|
throw new Error('Error creating wallet account');
|
|
416
374
|
}
|
|
417
375
|
const { accountAddress } = await this.deriveAccountAddress(rawPublicKey);
|
|
418
376
|
if (accountAddress !== publicKey) {
|
|
419
377
|
throw new Error(`Public key mismatch: derived address ${accountAddress} !== public key ${publicKey}`);
|
|
420
378
|
}
|
|
421
|
-
const
|
|
379
|
+
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
380
|
+
const walletMetadata = {
|
|
381
|
+
walletId: resolvedWalletId,
|
|
382
|
+
accountAddress,
|
|
383
|
+
chainName: this.chainName,
|
|
384
|
+
thresholdSignatureScheme,
|
|
385
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
386
|
+
index,
|
|
387
|
+
value
|
|
388
|
+
])))
|
|
389
|
+
};
|
|
390
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
422
391
|
accountAddress,
|
|
423
392
|
externalServerKeyShares,
|
|
424
393
|
password,
|
|
425
|
-
|
|
394
|
+
backUpToDynamic,
|
|
395
|
+
walletMetadata
|
|
426
396
|
});
|
|
397
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
427
398
|
return {
|
|
428
|
-
|
|
399
|
+
walletMetadata,
|
|
429
400
|
rawPublicKey: rawPublicKey,
|
|
430
401
|
externalServerKeyShares,
|
|
431
|
-
externalKeySharesWithBackupStatus
|
|
402
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
432
403
|
};
|
|
433
404
|
}
|
|
434
405
|
/**
|
|
@@ -527,6 +498,17 @@ async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet
|
|
|
527
498
|
return txid;
|
|
528
499
|
}
|
|
529
500
|
|
|
501
|
+
function _extends() {
|
|
502
|
+
_extends = Object.assign || function assign(target) {
|
|
503
|
+
for(var i = 1; i < arguments.length; i++){
|
|
504
|
+
var source = arguments[i];
|
|
505
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
506
|
+
}
|
|
507
|
+
return target;
|
|
508
|
+
};
|
|
509
|
+
return _extends.apply(this, arguments);
|
|
510
|
+
}
|
|
511
|
+
|
|
530
512
|
const logError = node.createLogError('node-svm');
|
|
531
513
|
/**
|
|
532
514
|
* Creates a delegated SVM wallet client for functional operations
|
package/index.esm.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import { createLogError, DynamicWalletClient, getMPCChainConfig,
|
|
1
|
+
import { createLogError, DynamicWalletClient, getMPCChainConfig, stripHexPrefix, WalletOperation, SOLANA_RPC_URL, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, revokeDelegation as revokeDelegation$1 } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import { PublicKey, VersionedTransaction, Keypair, Transaction, Connection, SystemProgram } from '@solana/web3.js';
|
|
3
3
|
|
|
4
|
-
function _extends() {
|
|
5
|
-
_extends = Object.assign || function assign(target) {
|
|
6
|
-
for(var i = 1; i < arguments.length; i++){
|
|
7
|
-
var source = arguments[i];
|
|
8
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
9
|
-
}
|
|
10
|
-
return target;
|
|
11
|
-
};
|
|
12
|
-
return _extends.apply(this, arguments);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
4
|
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating svm wallet account';
|
|
16
5
|
const ERROR_SIGN_RAW_MESSAGE = 'Error signing raw message';
|
|
17
6
|
|
|
@@ -90,9 +79,10 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
90
79
|
* Creates a wallet account on the Solana chain
|
|
91
80
|
*
|
|
92
81
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
93
|
-
* @returns The
|
|
94
|
-
*/ async createWalletAccount({ thresholdSignatureScheme, password
|
|
82
|
+
* @returns The walletMetadata, raw public key, and client key shares
|
|
83
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic = false }) {
|
|
95
84
|
try {
|
|
85
|
+
let resolvedWalletId;
|
|
96
86
|
let ceremonyCeremonyCompleteResolver;
|
|
97
87
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
98
88
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -100,28 +90,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
100
90
|
const { rawPublicKey, externalServerKeyShares } = await this.keyGen({
|
|
101
91
|
chainName: this.chainName,
|
|
102
92
|
thresholdSignatureScheme,
|
|
93
|
+
password,
|
|
94
|
+
backUpToDynamic,
|
|
103
95
|
onError,
|
|
104
|
-
onCeremonyComplete: (
|
|
105
|
-
|
|
106
|
-
const chainConfig = getMPCChainConfig(this.chainName);
|
|
107
|
-
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
108
|
-
accountAddress,
|
|
109
|
-
walletId,
|
|
110
|
-
chainName: this.chainName,
|
|
111
|
-
thresholdSignatureScheme,
|
|
112
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
113
|
-
index,
|
|
114
|
-
value
|
|
115
|
-
]))),
|
|
116
|
-
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
117
|
-
});
|
|
118
|
-
this.logger.debug('walletMap updated for wallet', {
|
|
119
|
-
context: {
|
|
120
|
-
accountAddress,
|
|
121
|
-
walletId,
|
|
122
|
-
walletMap: this.walletMap
|
|
123
|
-
}
|
|
124
|
-
});
|
|
96
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
97
|
+
resolvedWalletId = walletId;
|
|
125
98
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
126
99
|
}
|
|
127
100
|
});
|
|
@@ -130,21 +103,34 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
130
103
|
if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array || typeof rawPublicKey === 'string')) {
|
|
131
104
|
throw new Error('Raw public key is not a Uint8Array or string' + typeof rawPublicKey);
|
|
132
105
|
}
|
|
133
|
-
if (!externalServerKeyShares) {
|
|
106
|
+
if (!externalServerKeyShares || !resolvedWalletId) {
|
|
134
107
|
throw new Error('Error creating wallet account');
|
|
135
108
|
}
|
|
136
109
|
const { accountAddress } = await this.deriveAccountAddress(rawPublicKey);
|
|
137
|
-
const
|
|
110
|
+
const chainConfig = getMPCChainConfig(this.chainName);
|
|
111
|
+
const walletMetadata = {
|
|
112
|
+
walletId: resolvedWalletId,
|
|
113
|
+
accountAddress,
|
|
114
|
+
chainName: this.chainName,
|
|
115
|
+
thresholdSignatureScheme,
|
|
116
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
117
|
+
index,
|
|
118
|
+
value
|
|
119
|
+
])))
|
|
120
|
+
};
|
|
121
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
138
122
|
accountAddress,
|
|
139
123
|
externalServerKeyShares,
|
|
140
124
|
password,
|
|
141
|
-
|
|
125
|
+
backUpToDynamic,
|
|
126
|
+
walletMetadata
|
|
142
127
|
});
|
|
128
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
143
129
|
return {
|
|
144
|
-
|
|
130
|
+
walletMetadata,
|
|
145
131
|
rawPublicKey,
|
|
146
132
|
externalServerKeyShares,
|
|
147
|
-
externalKeySharesWithBackupStatus
|
|
133
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
148
134
|
};
|
|
149
135
|
} catch (error) {
|
|
150
136
|
logError$1({
|
|
@@ -171,22 +157,14 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
171
157
|
* This function takes a message and returns it after being signed with MPC
|
|
172
158
|
*
|
|
173
159
|
* @param message The message to sign (Uint8Array)
|
|
174
|
-
* @param
|
|
160
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
175
161
|
* @param password The password for encrypted backup shares
|
|
176
|
-
*/ async signMessage({ message,
|
|
177
|
-
|
|
162
|
+
*/ async signMessage({ message, walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
163
|
+
const { accountAddress } = walletMetadata;
|
|
178
164
|
if (!accountAddress) {
|
|
179
165
|
throw new Error('Account address is required');
|
|
180
166
|
}
|
|
181
167
|
try {
|
|
182
|
-
// Attempt to recover key shares from backup if not provided
|
|
183
|
-
await this.ensureKeySharesRecovered({
|
|
184
|
-
accountAddress,
|
|
185
|
-
password,
|
|
186
|
-
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
187
|
-
externalServerKeyShares,
|
|
188
|
-
errorMessage: 'External server key shares are required to sign a message. No backup shares available for recovery.'
|
|
189
|
-
});
|
|
190
168
|
const messageBytes = typeof message === 'string' ? new TextEncoder().encode(message) : message;
|
|
191
169
|
const messageHex = toHex(messageBytes);
|
|
192
170
|
const signatureEd25519 = await this.sign({
|
|
@@ -194,7 +172,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
194
172
|
accountAddress,
|
|
195
173
|
chainName: this.chainName,
|
|
196
174
|
password,
|
|
197
|
-
externalServerKeyShares
|
|
175
|
+
externalServerKeyShares,
|
|
176
|
+
walletMetadata
|
|
198
177
|
});
|
|
199
178
|
return encodeBase58(signatureEd25519);
|
|
200
179
|
} catch (error) {
|
|
@@ -213,21 +192,14 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
213
192
|
* The message must be a hex string representing already-hashed data.
|
|
214
193
|
*
|
|
215
194
|
* @param message The pre-formatted hex message to sign
|
|
216
|
-
* @param
|
|
195
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
217
196
|
* @param password The password for encrypted backup shares
|
|
218
|
-
*/ async signRawMessage({ message,
|
|
197
|
+
*/ async signRawMessage({ message, walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
198
|
+
const { accountAddress } = walletMetadata;
|
|
219
199
|
if (!accountAddress) {
|
|
220
200
|
throw new Error('Account address is required');
|
|
221
201
|
}
|
|
222
202
|
try {
|
|
223
|
-
// Attempt to recover key shares from backup if not provided
|
|
224
|
-
await this.ensureKeySharesRecovered({
|
|
225
|
-
accountAddress,
|
|
226
|
-
password,
|
|
227
|
-
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
228
|
-
externalServerKeyShares,
|
|
229
|
-
errorMessage: 'External server key shares are required to sign a raw message. No backup shares available for recovery.'
|
|
230
|
-
});
|
|
231
203
|
const messageHex = stripHexPrefix(message);
|
|
232
204
|
const signatureEd25519 = await this.sign({
|
|
233
205
|
message: messageHex,
|
|
@@ -235,7 +207,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
235
207
|
chainName: this.chainName,
|
|
236
208
|
password,
|
|
237
209
|
externalServerKeyShares,
|
|
238
|
-
isFormatted: true
|
|
210
|
+
isFormatted: true,
|
|
211
|
+
walletMetadata
|
|
239
212
|
});
|
|
240
213
|
return encodeBase58(signatureEd25519);
|
|
241
214
|
} catch (error) {
|
|
@@ -246,14 +219,16 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
246
219
|
accountAddress
|
|
247
220
|
}
|
|
248
221
|
});
|
|
249
|
-
throw new Error(ERROR_SIGN_RAW_MESSAGE
|
|
222
|
+
throw new Error(ERROR_SIGN_RAW_MESSAGE, {
|
|
223
|
+
cause: error
|
|
224
|
+
});
|
|
250
225
|
}
|
|
251
226
|
}
|
|
252
227
|
//todo:should txn just be a string?
|
|
253
|
-
async signTransaction({
|
|
254
|
-
|
|
255
|
-
if (!
|
|
256
|
-
throw new Error('
|
|
228
|
+
async signTransaction({ walletMetadata, transaction, password = undefined, externalServerKeyShares, sponsor = false }) {
|
|
229
|
+
const { accountAddress } = walletMetadata;
|
|
230
|
+
if (!accountAddress) {
|
|
231
|
+
throw new Error('Account address is required');
|
|
257
232
|
}
|
|
258
233
|
if (sponsor) {
|
|
259
234
|
if (typeof transaction === 'string') {
|
|
@@ -263,19 +238,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
263
238
|
transaction
|
|
264
239
|
});
|
|
265
240
|
}
|
|
266
|
-
await this.verifyPassword({
|
|
267
|
-
accountAddress: senderAddress,
|
|
268
|
-
password
|
|
269
|
-
});
|
|
270
241
|
try {
|
|
271
|
-
// Attempt to recover key shares from backup if not provided
|
|
272
|
-
await this.ensureKeySharesRecovered({
|
|
273
|
-
accountAddress: senderAddress,
|
|
274
|
-
password,
|
|
275
|
-
walletOperation: WalletOperation.SIGN_TRANSACTION,
|
|
276
|
-
externalServerKeyShares,
|
|
277
|
-
errorMessage: 'External server key shares are required to sign transaction. No backup shares available for recovery.'
|
|
278
|
-
});
|
|
279
242
|
let messageToSign;
|
|
280
243
|
if (typeof transaction === 'string') {
|
|
281
244
|
messageToSign = transaction.startsWith('0x') ? transaction.slice(2) : transaction;
|
|
@@ -288,10 +251,12 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
288
251
|
}
|
|
289
252
|
const signatureEd25519 = await this.sign({
|
|
290
253
|
message: messageToSign,
|
|
291
|
-
accountAddress
|
|
254
|
+
accountAddress,
|
|
292
255
|
chainName: this.chainName,
|
|
293
256
|
password,
|
|
294
|
-
externalServerKeyShares
|
|
257
|
+
externalServerKeyShares,
|
|
258
|
+
walletMetadata,
|
|
259
|
+
walletOperation: WalletOperation.SIGN_TRANSACTION
|
|
295
260
|
});
|
|
296
261
|
if (!signatureEd25519) {
|
|
297
262
|
throw new Error('Signature is undefined');
|
|
@@ -302,24 +267,26 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
302
267
|
message: 'Error in signTransaction:',
|
|
303
268
|
error: error,
|
|
304
269
|
context: {
|
|
305
|
-
|
|
270
|
+
accountAddress
|
|
306
271
|
}
|
|
307
272
|
});
|
|
308
273
|
throw error;
|
|
309
274
|
}
|
|
310
275
|
}
|
|
311
276
|
/**
|
|
312
|
-
* Exports the private key for a given
|
|
277
|
+
* Exports the private key for a given wallet
|
|
313
278
|
*
|
|
314
|
-
* @param
|
|
279
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
315
280
|
* @param password The password for encrypted backup shares
|
|
316
281
|
* @returns The private key
|
|
317
|
-
*/ async exportPrivateKey({
|
|
282
|
+
*/ async exportPrivateKey({ walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
283
|
+
const { accountAddress } = walletMetadata;
|
|
318
284
|
const { derivedPrivateKey } = await this.exportKey({
|
|
319
285
|
accountAddress,
|
|
320
286
|
chainName: this.chainName,
|
|
321
287
|
password,
|
|
322
|
-
externalServerKeyShares
|
|
288
|
+
externalServerKeyShares,
|
|
289
|
+
walletMetadata
|
|
323
290
|
});
|
|
324
291
|
if (!derivedPrivateKey) {
|
|
325
292
|
throw new Error('Derived private key is undefined');
|
|
@@ -376,8 +343,9 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
376
343
|
* @param chainName The chain name to import the private key for
|
|
377
344
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
378
345
|
* @param password The password for encrypted backup shares
|
|
379
|
-
* @returns The
|
|
380
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password
|
|
346
|
+
* @returns The walletMetadata, raw public key, and client key shares
|
|
347
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, backUpToDynamic = false }) {
|
|
348
|
+
let resolvedWalletId;
|
|
381
349
|
let ceremonyCeremonyCompleteResolver;
|
|
382
350
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
383
351
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -389,44 +357,47 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
389
357
|
chainName,
|
|
390
358
|
privateKey: formattedPrivateKey,
|
|
391
359
|
thresholdSignatureScheme,
|
|
360
|
+
password,
|
|
361
|
+
backUpToDynamic,
|
|
392
362
|
onError,
|
|
393
|
-
onCeremonyComplete: (
|
|
394
|
-
|
|
395
|
-
const chainConfig = getMPCChainConfig(this.chainName);
|
|
396
|
-
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
397
|
-
accountAddress,
|
|
398
|
-
walletId,
|
|
399
|
-
chainName: this.chainName,
|
|
400
|
-
thresholdSignatureScheme,
|
|
401
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
402
|
-
index,
|
|
403
|
-
value
|
|
404
|
-
]))),
|
|
405
|
-
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
406
|
-
});
|
|
363
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
364
|
+
resolvedWalletId = walletId;
|
|
407
365
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
408
366
|
}
|
|
409
367
|
});
|
|
410
368
|
// Wait for the ceremony to complete before proceeding
|
|
411
369
|
await ceremonyCompletePromise;
|
|
412
|
-
if (!rawPublicKey || !externalServerKeyShares) {
|
|
370
|
+
if (!rawPublicKey || !externalServerKeyShares || !resolvedWalletId) {
|
|
413
371
|
throw new Error('Error creating wallet account');
|
|
414
372
|
}
|
|
415
373
|
const { accountAddress } = await this.deriveAccountAddress(rawPublicKey);
|
|
416
374
|
if (accountAddress !== publicKey) {
|
|
417
375
|
throw new Error(`Public key mismatch: derived address ${accountAddress} !== public key ${publicKey}`);
|
|
418
376
|
}
|
|
419
|
-
const
|
|
377
|
+
const chainConfig = getMPCChainConfig(this.chainName);
|
|
378
|
+
const walletMetadata = {
|
|
379
|
+
walletId: resolvedWalletId,
|
|
380
|
+
accountAddress,
|
|
381
|
+
chainName: this.chainName,
|
|
382
|
+
thresholdSignatureScheme,
|
|
383
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
384
|
+
index,
|
|
385
|
+
value
|
|
386
|
+
])))
|
|
387
|
+
};
|
|
388
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
420
389
|
accountAddress,
|
|
421
390
|
externalServerKeyShares,
|
|
422
391
|
password,
|
|
423
|
-
|
|
392
|
+
backUpToDynamic,
|
|
393
|
+
walletMetadata
|
|
424
394
|
});
|
|
395
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
425
396
|
return {
|
|
426
|
-
|
|
397
|
+
walletMetadata,
|
|
427
398
|
rawPublicKey: rawPublicKey,
|
|
428
399
|
externalServerKeyShares,
|
|
429
|
-
externalKeySharesWithBackupStatus
|
|
400
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
430
401
|
};
|
|
431
402
|
}
|
|
432
403
|
/**
|
|
@@ -525,6 +496,17 @@ async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet
|
|
|
525
496
|
return txid;
|
|
526
497
|
}
|
|
527
498
|
|
|
499
|
+
function _extends() {
|
|
500
|
+
_extends = Object.assign || function assign(target) {
|
|
501
|
+
for(var i = 1; i < arguments.length; i++){
|
|
502
|
+
var source = arguments[i];
|
|
503
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
504
|
+
}
|
|
505
|
+
return target;
|
|
506
|
+
};
|
|
507
|
+
return _extends.apply(this, arguments);
|
|
508
|
+
}
|
|
509
|
+
|
|
528
510
|
const logError = createLogError('node-svm');
|
|
529
511
|
/**
|
|
530
512
|
* Creates a delegated SVM wallet client for functional operations
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-svm",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-beta",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "0.0
|
|
7
|
+
"@dynamic-labs-wallet/node": "1.0.0-beta",
|
|
8
8
|
"@solana/web3.js": "^1.98.2"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ServerKeyShare, DynamicWalletClient, type Ed25519KeygenResult, type ThresholdSignatureScheme, type TraceContext, type DynamicWalletClientProps } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import { type ServerKeyShare, DynamicWalletClient, type Ed25519KeygenResult, type ThresholdSignatureScheme, type TraceContext, type DynamicWalletClientProps, type WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
4
4
|
readonly chainName = "SVM";
|
|
@@ -8,17 +8,16 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
8
8
|
* Creates a wallet account on the Solana chain
|
|
9
9
|
*
|
|
10
10
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
11
|
-
* @returns The
|
|
11
|
+
* @returns The walletMetadata, raw public key, and client key shares
|
|
12
12
|
*/
|
|
13
|
-
createWalletAccount({ thresholdSignatureScheme, password, onError,
|
|
13
|
+
createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic, }: {
|
|
14
14
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
15
15
|
password?: string;
|
|
16
16
|
onError?: (error: Error) => void;
|
|
17
|
-
|
|
17
|
+
backUpToDynamic?: boolean;
|
|
18
18
|
}): Promise<{
|
|
19
|
-
|
|
19
|
+
walletMetadata: WalletMetadata;
|
|
20
20
|
rawPublicKey: Uint8Array | string;
|
|
21
|
-
/** @deprecated Use externalKeySharesWithBackupStatus instead */
|
|
22
21
|
externalServerKeyShares: ServerKeyShare[];
|
|
23
22
|
externalKeySharesWithBackupStatus: Array<{
|
|
24
23
|
share: ServerKeyShare;
|
|
@@ -32,12 +31,12 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
32
31
|
* This function takes a message and returns it after being signed with MPC
|
|
33
32
|
*
|
|
34
33
|
* @param message The message to sign (Uint8Array)
|
|
35
|
-
* @param
|
|
34
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
36
35
|
* @param password The password for encrypted backup shares
|
|
37
36
|
*/
|
|
38
|
-
signMessage({ message,
|
|
37
|
+
signMessage({ message, walletMetadata, password, externalServerKeyShares, }: {
|
|
39
38
|
message: string | Uint8Array;
|
|
40
|
-
|
|
39
|
+
walletMetadata: WalletMetadata;
|
|
41
40
|
password?: string;
|
|
42
41
|
externalServerKeyShares?: ServerKeyShare[];
|
|
43
42
|
}): Promise<string>;
|
|
@@ -46,17 +45,17 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
46
45
|
* The message must be a hex string representing already-hashed data.
|
|
47
46
|
*
|
|
48
47
|
* @param message The pre-formatted hex message to sign
|
|
49
|
-
* @param
|
|
48
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
50
49
|
* @param password The password for encrypted backup shares
|
|
51
50
|
*/
|
|
52
|
-
signRawMessage({ message,
|
|
51
|
+
signRawMessage({ message, walletMetadata, password, externalServerKeyShares, }: {
|
|
53
52
|
message: string;
|
|
54
|
-
|
|
53
|
+
walletMetadata: WalletMetadata;
|
|
55
54
|
password?: string;
|
|
56
55
|
externalServerKeyShares?: ServerKeyShare[];
|
|
57
56
|
}): Promise<string>;
|
|
58
|
-
signTransaction({
|
|
59
|
-
|
|
57
|
+
signTransaction({ walletMetadata, transaction, password, externalServerKeyShares, sponsor, }: {
|
|
58
|
+
walletMetadata: WalletMetadata;
|
|
60
59
|
transaction: VersionedTransaction | Transaction | string;
|
|
61
60
|
password?: string;
|
|
62
61
|
externalServerKeyShares?: ServerKeyShare[];
|
|
@@ -64,14 +63,14 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
64
63
|
sponsor?: boolean;
|
|
65
64
|
}): Promise<string>;
|
|
66
65
|
/**
|
|
67
|
-
* Exports the private key for a given
|
|
66
|
+
* Exports the private key for a given wallet
|
|
68
67
|
*
|
|
69
|
-
* @param
|
|
68
|
+
* @param walletMetadata Wallet metadata (the full object returned by createWalletAccount/importPrivateKey, with backupInfo merged from any subsequent updatePassword/refresh/reshare)
|
|
70
69
|
* @param password The password for encrypted backup shares
|
|
71
70
|
* @returns The private key
|
|
72
71
|
*/
|
|
73
|
-
exportPrivateKey({
|
|
74
|
-
|
|
72
|
+
exportPrivateKey({ walletMetadata, password, externalServerKeyShares, }: {
|
|
73
|
+
walletMetadata: WalletMetadata;
|
|
75
74
|
password?: string;
|
|
76
75
|
externalServerKeyShares?: ServerKeyShare[];
|
|
77
76
|
}): Promise<string>;
|
|
@@ -103,19 +102,18 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
103
102
|
* @param chainName The chain name to import the private key for
|
|
104
103
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
105
104
|
* @param password The password for encrypted backup shares
|
|
106
|
-
* @returns The
|
|
105
|
+
* @returns The walletMetadata, raw public key, and client key shares
|
|
107
106
|
*/
|
|
108
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError,
|
|
107
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, backUpToDynamic, }: {
|
|
109
108
|
privateKey: string;
|
|
110
109
|
chainName: string;
|
|
111
110
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
112
111
|
password?: string;
|
|
113
112
|
onError?: (error: Error) => void;
|
|
114
|
-
|
|
113
|
+
backUpToDynamic?: boolean;
|
|
115
114
|
}): Promise<{
|
|
116
|
-
|
|
115
|
+
walletMetadata: WalletMetadata;
|
|
117
116
|
rawPublicKey: Uint8Array | string | undefined;
|
|
118
|
-
/** @deprecated Use externalKeySharesWithBackupStatus instead */
|
|
119
117
|
externalServerKeyShares: ServerKeyShare[];
|
|
120
118
|
externalKeySharesWithBackupStatus: Array<{
|
|
121
119
|
share: ServerKeyShare;
|
|
@@ -140,6 +138,14 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
140
138
|
transaction: VersionedTransaction | Transaction;
|
|
141
139
|
traceContext?: TraceContext;
|
|
142
140
|
}): Promise<VersionedTransaction | Transaction>;
|
|
143
|
-
getSvmWallets(): Promise<
|
|
141
|
+
getSvmWallets(): Promise<{
|
|
142
|
+
walletId: string;
|
|
143
|
+
chainName: string;
|
|
144
|
+
accountAddress: string;
|
|
145
|
+
externalServerKeySharesBackupInfo: import("@dynamic-labs-wallet/core").KeyShareBackupInfo;
|
|
146
|
+
externalServerKeyShares: never[];
|
|
147
|
+
derivationPath: string | undefined;
|
|
148
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
149
|
+
}[]>;
|
|
144
150
|
}
|
|
145
151
|
//# 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,KAAK,cAAc,EACnB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"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"}
|