@dynamic-labs-wallet/node-svm 0.0.0-beta.316 → 0.0.0-pr354.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.
package/index.cjs.js CHANGED
@@ -16,75 +16,45 @@ function _extends() {
16
16
 
17
17
  const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating svm wallet account';
18
18
 
19
- // Base58 encoding/decoding (Bitcoin alphabet) without external dependencies
20
- // Implementation adapted from the reference algorithm; suitable for keys/signatures
21
- const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
22
- const ALPHABET_MAP = {};
23
- for(let i = 0; i < ALPHABET.length; i++)ALPHABET_MAP[ALPHABET[i]] = i;
24
- function encodeBase58(source) {
25
- const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);
26
- if (bytes.length === 0) return '';
27
- // Count leading zeros
28
- let zeros = 0;
29
- while(zeros < bytes.length && bytes[zeros] === 0)zeros++;
30
- // Allocate enough space in big-endian base58 representation.
31
- // log(256) / log(58), rounded up.
32
- const size = (bytes.length - zeros) * 138 / 100 + 1 >>> 0;
33
- const b58 = new Uint8Array(size);
34
- let length = 0;
35
- for(let i = zeros; i < bytes.length; i++){
36
- let carry = bytes[i];
37
- let j = 0;
38
- for(let k = size - 1; (carry !== 0 || j < length) && k >= 0; k--, j++){
39
- carry += 256 * b58[k] >>> 0;
40
- b58[k] = carry % 58 >>> 0;
41
- carry = carry / 58 >>> 0;
42
- }
43
- length = j;
44
- }
45
- // Skip leading zeros in base58 result
46
- let it = size - length;
47
- while(it < size && b58[it] === 0)it++;
48
- // Translate the result into a string.
49
- let str = '';
50
- for(let i = 0; i < zeros; i++)str += '1';
51
- for(; it < size; it++)str += ALPHABET[b58[it]];
52
- return str;
19
+ async function getBalance({ address, rpcUrl = node.SOLANA_RPC_URL }) {
20
+ const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
21
+ const balance = await connection.getBalance(new web3_js.PublicKey(address));
22
+ return balance;
53
23
  }
54
- function decodeBase58(str) {
55
- if (str.length === 0) return new Uint8Array();
56
- // Count leading zeros
57
- let zeros = 0;
58
- while(zeros < str.length && str[zeros] === '1')zeros++;
59
- // Allocate enough space in big-endian base256 representation.
60
- // log(58) / log(256), rounded up.
61
- const size = (str.length - zeros) * 733 / 1000 + 1 >>> 0;
62
- const b256 = new Uint8Array(size);
63
- let length = 0;
64
- for(let i = zeros; i < str.length; i++){
65
- const value = ALPHABET_MAP[str[i]];
66
- if (value === undefined) throw new Error('Invalid base58 character');
67
- let carry = value;
68
- let j = 0;
69
- for(let k = size - 1; (carry !== 0 || j < length) && k >= 0; k--, j++){
70
- carry += 58 * b256[k] >>> 0;
71
- b256[k] = (carry & 0xff) >>> 0;
72
- carry = carry >> 8 >>> 0;
73
- }
74
- length = j;
24
+ async function createSolanaTransaction({ senderSolanaAddress, amount, to, rpcUrl = 'https://api.devnet.solana.com' }) {
25
+ const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
26
+ const balance = await getBalance({
27
+ address: senderSolanaAddress,
28
+ rpcUrl
29
+ });
30
+ if (balance < amount * 1e9) {
31
+ throw new Error('Insufficient balance');
75
32
  }
76
- // Skip leading zeros in b256
77
- let it = size - length;
78
- while(it < size && b256[it] === 0)it++;
79
- const out = new Uint8Array(zeros + (size - it));
80
- out.fill(0, 0, zeros);
81
- let j = zeros;
82
- while(it < size)out[j++] = b256[it++];
83
- return out;
33
+ const fromPubkey = new web3_js.PublicKey(senderSolanaAddress);
34
+ const transaction = new web3_js.Transaction().add(web3_js.SystemProgram.transfer({
35
+ fromPubkey: fromPubkey,
36
+ toPubkey: new web3_js.PublicKey(to),
37
+ lamports: amount * 1e9
38
+ }));
39
+ const { blockhash } = await connection.getLatestBlockhash();
40
+ transaction.recentBlockhash = blockhash;
41
+ transaction.feePayer = fromPubkey;
42
+ const serializedTransaction = transaction.serializeMessage();
43
+ return {
44
+ transaction,
45
+ serializedTransaction
46
+ };
47
+ }
48
+ const addSignatureToTransaction = ({ transaction, signature, signerPublicKey })=>{
49
+ transaction.addSignature(signerPublicKey, Buffer.from(signature));
50
+ return transaction;
51
+ };
52
+ async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet.solana.com' }) {
53
+ const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
54
+ const txid = await connection.sendRawTransaction(Buffer.from(signedTransaction));
55
+ return txid;
84
56
  }
85
57
 
86
- // Helper: normalize bytes to hex without triggering Buffer.from(string, encoding) overload
87
- const toHex = (bytes)=>(Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes)).toString('hex');
88
58
  class DynamicSvmWalletClient extends node.DynamicWalletClient {
89
59
  /**
90
60
  * Creates a wallet account on the Solana chain
@@ -103,16 +73,11 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
103
73
  onError,
104
74
  onCeremonyComplete: (accountAddress, walletId)=>{
105
75
  // update wallet map
106
- const chainConfig = node.getMPCChainConfig(this.chainName);
107
76
  this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
108
77
  accountAddress,
109
78
  walletId,
110
79
  chainName: this.chainName,
111
80
  thresholdSignatureScheme,
112
- derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
113
- index,
114
- value
115
- ]))),
116
81
  externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
117
82
  });
118
83
  this.logger.debug('walletMap updated for wallet', {
@@ -152,12 +117,10 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
152
117
  }
153
118
  // Function to properly derive account address
154
119
  async deriveAccountAddress(rawPublicKey) {
155
- function ensure32(u8) {
156
- if (u8.length !== 32) throw new Error(`Invalid pubkey length: ${u8.length}`);
157
- return u8;
158
- }
159
- const pubKeyBytes = typeof rawPublicKey === 'string' ? new Uint8Array(Buffer.from(rawPublicKey, 'hex')) : rawPublicKey;
160
- const accountAddress = new web3_js.PublicKey(ensure32(pubKeyBytes)).toBase58();
120
+ const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
121
+ // Create PublicKey from bytes and convert to base58
122
+ const pubKey = new web3_js.PublicKey(pubKeyBytes);
123
+ const accountAddress = pubKey.toBase58();
161
124
  return {
162
125
  accountAddress
163
126
  };
@@ -169,24 +132,25 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
169
132
  * @param accountAddress Solana address (base58 encoded)
170
133
  * @param password The password for encrypted backup shares
171
134
  */ async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
172
- // Validate inputs early
135
+ await this.verifyPassword({
136
+ accountAddress,
137
+ password,
138
+ walletOperation: node.WalletOperation.SIGN_MESSAGE
139
+ });
173
140
  if (!accountAddress) {
174
141
  throw new Error('Account address is required');
175
142
  }
176
- if (Array.isArray(externalServerKeyShares) && externalServerKeyShares.length === 0) {
177
- throw new Error('External server key shares are required');
178
- }
179
143
  try {
180
- const messageBytes = typeof message === 'string' ? new TextEncoder().encode(message) : message;
181
- const messageHex = toHex(messageBytes);
182
144
  const signatureEd25519 = await this.sign({
183
- message: messageHex,
184
- accountAddress,
145
+ message,
146
+ accountAddress: accountAddress,
185
147
  chainName: this.chainName,
186
148
  password,
187
149
  externalServerKeyShares
188
150
  });
189
- return encodeBase58(signatureEd25519);
151
+ // Use PublicKey to encode signature
152
+ const base58Signature = new web3_js.PublicKey(signatureEd25519).toBase58();
153
+ return base58Signature;
190
154
  } catch (error) {
191
155
  this.logger.error('Error signing message:', error);
192
156
  throw error;
@@ -194,13 +158,6 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
194
158
  }
195
159
  //todo:should txn just be a string?
196
160
  async signTransaction({ senderAddress, transaction, password = undefined, externalServerKeyShares }) {
197
- // Validate inputs early
198
- if (!senderAddress) {
199
- throw new Error('Sender address is required');
200
- }
201
- if (Array.isArray(externalServerKeyShares) && externalServerKeyShares.length === 0) {
202
- throw new Error('External server key shares are required');
203
- }
204
161
  await this.verifyPassword({
205
162
  accountAddress: senderAddress,
206
163
  password,
@@ -208,14 +165,14 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
208
165
  });
209
166
  try {
210
167
  let messageToSign;
211
- if (typeof transaction === 'string') {
212
- messageToSign = transaction.startsWith('0x') ? transaction.slice(2) : transaction;
213
- } else if (transaction instanceof web3_js.VersionedTransaction) {
168
+ if (transaction instanceof web3_js.VersionedTransaction) {
169
+ // For versioned transactions, we need to sign the message directly
214
170
  const messageBytes = transaction.message.serialize();
215
- messageToSign = toHex(messageBytes);
171
+ messageToSign = Buffer.from(messageBytes).toString('hex');
216
172
  } else {
173
+ // For legacy transactions, serialize the message
217
174
  const messageBytes = transaction.serializeMessage();
218
- messageToSign = toHex(Buffer.isBuffer(messageBytes) ? messageBytes : messageBytes);
175
+ messageToSign = Buffer.from(messageBytes).toString('hex');
219
176
  }
220
177
  const signatureEd25519 = await this.sign({
221
178
  message: messageToSign,
@@ -227,7 +184,13 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
227
184
  if (!signatureEd25519) {
228
185
  throw new Error('Signature is undefined');
229
186
  }
230
- return encodeBase58(signatureEd25519);
187
+ const senderPublicKey = new web3_js.PublicKey(senderAddress);
188
+ const signedTransaction = addSignatureToTransaction({
189
+ transaction,
190
+ signature: signatureEd25519,
191
+ signerPublicKey: senderPublicKey
192
+ });
193
+ return signedTransaction;
231
194
  } catch (error) {
232
195
  this.logger.error('Error in signTransaction:', error);
233
196
  if (error instanceof Error) {
@@ -275,19 +238,18 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
275
238
  * @param privateKey The private key to convert
276
239
  * @returns The hex string
277
240
  */ decodePrivateKeyForSolana(privateKey) {
278
- const decoded = decodeBase58(privateKey); // 64 bytes
279
- if (decoded.length !== 64) throw new Error('Invalid Solana secret key length');
280
- return Buffer.from(decoded.slice(0, 32)).toString('hex');
241
+ const decoded = new web3_js.PublicKey(privateKey).toBuffer();
242
+ const slicedBytes = decoded.slice(0, 32);
243
+ return Buffer.from(slicedBytes).toString('hex');
281
244
  }
282
245
  getPublicKeyFromPrivateKey(privateKey) {
283
- const secret = decodeBase58(privateKey);
284
- const keypair = web3_js.Keypair.fromSecretKey(secret);
285
- return keypair.publicKey.toBase58();
246
+ const privateKeyBytes = new web3_js.PublicKey(privateKey).toBuffer();
247
+ const keypair = web3_js.Keypair.fromSecretKey(privateKeyBytes);
248
+ const publicKeyBase58 = keypair.publicKey.toBase58();
249
+ return publicKeyBase58;
286
250
  }
287
251
  encodePublicKey(publicKey) {
288
- // Ensure a plain Uint8Array is passed to PublicKey
289
- const bytes = publicKey instanceof Uint8Array ? publicKey : new Uint8Array(publicKey);
290
- return new web3_js.PublicKey(bytes).toBase58();
252
+ return new web3_js.PublicKey(publicKey).toBase58();
291
253
  }
292
254
  /**
293
255
  * Imports the private key for a given account address
@@ -312,16 +274,11 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
312
274
  onError,
313
275
  onCeremonyComplete: (accountAddress, walletId)=>{
314
276
  // update wallet map
315
- const chainConfig = node.getMPCChainConfig(this.chainName);
316
277
  this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
317
278
  accountAddress,
318
279
  walletId,
319
280
  chainName: this.chainName,
320
281
  thresholdSignatureScheme,
321
- derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
322
- index,
323
- value
324
- ]))),
325
282
  externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
326
283
  });
327
284
  ceremonyCeremonyCompleteResolver(undefined);
@@ -362,158 +319,8 @@ class DynamicSvmWalletClient extends node.DynamicWalletClient {
362
319
  }
363
320
  }
364
321
 
365
- async function getBalance({ address, rpcUrl = node.SOLANA_RPC_URL }) {
366
- const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
367
- const balance = await connection.getBalance(new web3_js.PublicKey(address));
368
- return balance;
369
- }
370
- async function createSolanaTransaction({ senderSolanaAddress, amount, to, rpcUrl = 'https://api.devnet.solana.com' }) {
371
- const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
372
- const balance = await getBalance({
373
- address: senderSolanaAddress,
374
- rpcUrl
375
- });
376
- if (balance < amount * 1e9) {
377
- throw new Error('Insufficient balance');
378
- }
379
- const fromPubkey = new web3_js.PublicKey(senderSolanaAddress);
380
- const transaction = new web3_js.Transaction().add(web3_js.SystemProgram.transfer({
381
- fromPubkey: fromPubkey,
382
- toPubkey: new web3_js.PublicKey(to),
383
- lamports: amount * 1e9
384
- }));
385
- const { blockhash } = await connection.getLatestBlockhash();
386
- transaction.recentBlockhash = blockhash;
387
- transaction.feePayer = fromPubkey;
388
- const serializedTransaction = transaction.serializeMessage();
389
- return {
390
- transaction,
391
- serializedTransaction
392
- };
393
- }
394
- const addSignatureToTransaction = ({ transaction, signature, signerPublicKey })=>{
395
- transaction.addSignature(signerPublicKey, Buffer.from(signature));
396
- return transaction;
397
- };
398
- function attachSignature({ transaction, signatureBase58, senderAddress }) {
399
- const sigBytes = decodeBase58(signatureBase58);
400
- const signerPubkey = new web3_js.PublicKey(senderAddress);
401
- return addSignatureToTransaction({
402
- transaction,
403
- signature: sigBytes,
404
- signerPublicKey: signerPubkey
405
- });
406
- }
407
- async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet.solana.com' }) {
408
- const connection = new web3_js.Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
409
- const txid = await connection.sendRawTransaction(Buffer.from(signedTransaction));
410
- return txid;
411
- }
412
-
413
- /**
414
- * Creates a delegated SVM wallet client for functional operations
415
- */ const createDelegatedSvmWalletClient = ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug = false })=>{
416
- const baseClient = node.createDelegatedWalletClient({
417
- environmentId,
418
- baseApiUrl,
419
- baseMPCRelayApiUrl,
420
- apiKey,
421
- debug
422
- });
423
- const svmClient = _extends({}, baseClient, {
424
- chainName: 'SVM'
425
- });
426
- return svmClient;
427
- };
428
- /**
429
- * Signs a message using delegated signing for SVM
430
- */ const delegatedSignMessage = async (client, { walletId, walletApiKey, keyShare, message, isFormatted = false })=>{
431
- try {
432
- // Use the delegated sign message function from node package
433
- const signatureEd25519 = await node.delegatedSignMessage(client, {
434
- walletId,
435
- walletApiKey,
436
- keyShare,
437
- message,
438
- chainName: client.chainName,
439
- isFormatted
440
- });
441
- // Use PublicKey to encode signature as base58 (SVM format)
442
- const base58Signature = new web3_js.PublicKey(signatureEd25519).toBase58();
443
- return base58Signature;
444
- } catch (error) {
445
- client.logger.error('Error in delegatedSignMessage', error);
446
- throw error;
447
- }
448
- };
449
- /**
450
- * Signs a transaction using delegated signing for SVM
451
- */ const delegatedSignTransaction = async (client, { walletId, walletApiKey, keyShare, transaction })=>{
452
- try {
453
- let messageToSign;
454
- if (transaction instanceof web3_js.VersionedTransaction) {
455
- // For versioned transactions, we need to sign the message directly
456
- const messageBytes = transaction.message.serialize();
457
- messageToSign = Buffer.from(Array.from(messageBytes)).toString('hex');
458
- } else {
459
- // For legacy transactions, serialize the message
460
- const messageBytes = transaction.serializeMessage();
461
- messageToSign = messageBytes.toString('hex');
462
- }
463
- // Use the delegated sign message function from node package
464
- const signatureEd25519 = await node.delegatedSignMessage(client, {
465
- walletId,
466
- walletApiKey,
467
- keyShare,
468
- message: messageToSign,
469
- chainName: client.chainName,
470
- isFormatted: false
471
- });
472
- if (!signatureEd25519) {
473
- throw new Error('Signature is undefined');
474
- }
475
- // Get the sender address from the transaction
476
- let senderAddress;
477
- if (transaction instanceof web3_js.VersionedTransaction) {
478
- // For versioned transactions, get the first signer
479
- const signers = transaction.message.staticAccountKeys;
480
- senderAddress = signers[0].toBase58();
481
- } else {
482
- var _transaction_feePayer;
483
- // For legacy transactions, use feePayer
484
- senderAddress = ((_transaction_feePayer = transaction.feePayer) == null ? void 0 : _transaction_feePayer.toBase58()) || '';
485
- }
486
- if (!senderAddress) {
487
- throw new Error('Could not determine sender address from transaction');
488
- }
489
- const senderPublicKey = new web3_js.PublicKey(senderAddress);
490
- const signedTransaction = addSignatureToTransaction({
491
- transaction,
492
- signature: signatureEd25519,
493
- signerPublicKey: senderPublicKey
494
- });
495
- return signedTransaction;
496
- } catch (error) {
497
- client.logger.error('Error in delegatedSignTransaction', error);
498
- throw error;
499
- }
500
- };
501
- /**
502
- * Revoke delegation - delegates to the node package
503
- */ const revokeDelegation = async (client, params)=>{
504
- return node.revokeDelegation(client, params);
505
- };
506
-
507
322
  exports.DynamicSvmWalletClient = DynamicSvmWalletClient;
508
- exports.ERROR_CREATE_WALLET_ACCOUNT = ERROR_CREATE_WALLET_ACCOUNT;
509
323
  exports.addSignatureToTransaction = addSignatureToTransaction;
510
- exports.attachSignature = attachSignature;
511
- exports.createDelegatedSvmWalletClient = createDelegatedSvmWalletClient;
512
324
  exports.createSolanaTransaction = createSolanaTransaction;
513
- exports.decodeBase58 = decodeBase58;
514
- exports.delegatedSignMessage = delegatedSignMessage;
515
- exports.delegatedSignTransaction = delegatedSignTransaction;
516
- exports.encodeBase58 = encodeBase58;
517
325
  exports.getBalance = getBalance;
518
- exports.revokeDelegation = revokeDelegation;
519
326
  exports.sendTransaction = sendTransaction;
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- import { DynamicWalletClient, getMPCChainConfig, getExternalServerKeyShareBackupInfo, WalletOperation, SOLANA_RPC_URL, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, revokeDelegation as revokeDelegation$1 } from '@dynamic-labs-wallet/node';
2
- import { PublicKey, VersionedTransaction, Keypair, Connection, Transaction, SystemProgram } from '@solana/web3.js';
1
+ import { SOLANA_RPC_URL, DynamicWalletClient, getExternalServerKeyShareBackupInfo, WalletOperation } from '@dynamic-labs-wallet/node';
2
+ import { Connection, PublicKey, Transaction, SystemProgram, VersionedTransaction, Keypair } from '@solana/web3.js';
3
3
 
4
4
  function _extends() {
5
5
  _extends = Object.assign || function assign(target) {
@@ -14,75 +14,45 @@ function _extends() {
14
14
 
15
15
  const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating svm wallet account';
16
16
 
17
- // Base58 encoding/decoding (Bitcoin alphabet) without external dependencies
18
- // Implementation adapted from the reference algorithm; suitable for keys/signatures
19
- const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
20
- const ALPHABET_MAP = {};
21
- for(let i = 0; i < ALPHABET.length; i++)ALPHABET_MAP[ALPHABET[i]] = i;
22
- function encodeBase58(source) {
23
- const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);
24
- if (bytes.length === 0) return '';
25
- // Count leading zeros
26
- let zeros = 0;
27
- while(zeros < bytes.length && bytes[zeros] === 0)zeros++;
28
- // Allocate enough space in big-endian base58 representation.
29
- // log(256) / log(58), rounded up.
30
- const size = (bytes.length - zeros) * 138 / 100 + 1 >>> 0;
31
- const b58 = new Uint8Array(size);
32
- let length = 0;
33
- for(let i = zeros; i < bytes.length; i++){
34
- let carry = bytes[i];
35
- let j = 0;
36
- for(let k = size - 1; (carry !== 0 || j < length) && k >= 0; k--, j++){
37
- carry += 256 * b58[k] >>> 0;
38
- b58[k] = carry % 58 >>> 0;
39
- carry = carry / 58 >>> 0;
40
- }
41
- length = j;
42
- }
43
- // Skip leading zeros in base58 result
44
- let it = size - length;
45
- while(it < size && b58[it] === 0)it++;
46
- // Translate the result into a string.
47
- let str = '';
48
- for(let i = 0; i < zeros; i++)str += '1';
49
- for(; it < size; it++)str += ALPHABET[b58[it]];
50
- return str;
17
+ async function getBalance({ address, rpcUrl = SOLANA_RPC_URL }) {
18
+ const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
19
+ const balance = await connection.getBalance(new PublicKey(address));
20
+ return balance;
51
21
  }
52
- function decodeBase58(str) {
53
- if (str.length === 0) return new Uint8Array();
54
- // Count leading zeros
55
- let zeros = 0;
56
- while(zeros < str.length && str[zeros] === '1')zeros++;
57
- // Allocate enough space in big-endian base256 representation.
58
- // log(58) / log(256), rounded up.
59
- const size = (str.length - zeros) * 733 / 1000 + 1 >>> 0;
60
- const b256 = new Uint8Array(size);
61
- let length = 0;
62
- for(let i = zeros; i < str.length; i++){
63
- const value = ALPHABET_MAP[str[i]];
64
- if (value === undefined) throw new Error('Invalid base58 character');
65
- let carry = value;
66
- let j = 0;
67
- for(let k = size - 1; (carry !== 0 || j < length) && k >= 0; k--, j++){
68
- carry += 58 * b256[k] >>> 0;
69
- b256[k] = (carry & 0xff) >>> 0;
70
- carry = carry >> 8 >>> 0;
71
- }
72
- length = j;
22
+ async function createSolanaTransaction({ senderSolanaAddress, amount, to, rpcUrl = 'https://api.devnet.solana.com' }) {
23
+ const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
24
+ const balance = await getBalance({
25
+ address: senderSolanaAddress,
26
+ rpcUrl
27
+ });
28
+ if (balance < amount * 1e9) {
29
+ throw new Error('Insufficient balance');
73
30
  }
74
- // Skip leading zeros in b256
75
- let it = size - length;
76
- while(it < size && b256[it] === 0)it++;
77
- const out = new Uint8Array(zeros + (size - it));
78
- out.fill(0, 0, zeros);
79
- let j = zeros;
80
- while(it < size)out[j++] = b256[it++];
81
- return out;
31
+ const fromPubkey = new PublicKey(senderSolanaAddress);
32
+ const transaction = new Transaction().add(SystemProgram.transfer({
33
+ fromPubkey: fromPubkey,
34
+ toPubkey: new PublicKey(to),
35
+ lamports: amount * 1e9
36
+ }));
37
+ const { blockhash } = await connection.getLatestBlockhash();
38
+ transaction.recentBlockhash = blockhash;
39
+ transaction.feePayer = fromPubkey;
40
+ const serializedTransaction = transaction.serializeMessage();
41
+ return {
42
+ transaction,
43
+ serializedTransaction
44
+ };
45
+ }
46
+ const addSignatureToTransaction = ({ transaction, signature, signerPublicKey })=>{
47
+ transaction.addSignature(signerPublicKey, Buffer.from(signature));
48
+ return transaction;
49
+ };
50
+ async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet.solana.com' }) {
51
+ const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
52
+ const txid = await connection.sendRawTransaction(Buffer.from(signedTransaction));
53
+ return txid;
82
54
  }
83
55
 
84
- // Helper: normalize bytes to hex without triggering Buffer.from(string, encoding) overload
85
- const toHex = (bytes)=>(Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes)).toString('hex');
86
56
  class DynamicSvmWalletClient extends DynamicWalletClient {
87
57
  /**
88
58
  * Creates a wallet account on the Solana chain
@@ -101,16 +71,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
101
71
  onError,
102
72
  onCeremonyComplete: (accountAddress, walletId)=>{
103
73
  // update wallet map
104
- const chainConfig = getMPCChainConfig(this.chainName);
105
74
  this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
106
75
  accountAddress,
107
76
  walletId,
108
77
  chainName: this.chainName,
109
78
  thresholdSignatureScheme,
110
- derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
111
- index,
112
- value
113
- ]))),
114
79
  externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
115
80
  });
116
81
  this.logger.debug('walletMap updated for wallet', {
@@ -150,12 +115,10 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
150
115
  }
151
116
  // Function to properly derive account address
152
117
  async deriveAccountAddress(rawPublicKey) {
153
- function ensure32(u8) {
154
- if (u8.length !== 32) throw new Error(`Invalid pubkey length: ${u8.length}`);
155
- return u8;
156
- }
157
- const pubKeyBytes = typeof rawPublicKey === 'string' ? new Uint8Array(Buffer.from(rawPublicKey, 'hex')) : rawPublicKey;
158
- const accountAddress = new PublicKey(ensure32(pubKeyBytes)).toBase58();
118
+ const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
119
+ // Create PublicKey from bytes and convert to base58
120
+ const pubKey = new PublicKey(pubKeyBytes);
121
+ const accountAddress = pubKey.toBase58();
159
122
  return {
160
123
  accountAddress
161
124
  };
@@ -167,24 +130,25 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
167
130
  * @param accountAddress Solana address (base58 encoded)
168
131
  * @param password The password for encrypted backup shares
169
132
  */ async signMessage({ message, accountAddress, password = undefined, externalServerKeyShares }) {
170
- // Validate inputs early
133
+ await this.verifyPassword({
134
+ accountAddress,
135
+ password,
136
+ walletOperation: WalletOperation.SIGN_MESSAGE
137
+ });
171
138
  if (!accountAddress) {
172
139
  throw new Error('Account address is required');
173
140
  }
174
- if (Array.isArray(externalServerKeyShares) && externalServerKeyShares.length === 0) {
175
- throw new Error('External server key shares are required');
176
- }
177
141
  try {
178
- const messageBytes = typeof message === 'string' ? new TextEncoder().encode(message) : message;
179
- const messageHex = toHex(messageBytes);
180
142
  const signatureEd25519 = await this.sign({
181
- message: messageHex,
182
- accountAddress,
143
+ message,
144
+ accountAddress: accountAddress,
183
145
  chainName: this.chainName,
184
146
  password,
185
147
  externalServerKeyShares
186
148
  });
187
- return encodeBase58(signatureEd25519);
149
+ // Use PublicKey to encode signature
150
+ const base58Signature = new PublicKey(signatureEd25519).toBase58();
151
+ return base58Signature;
188
152
  } catch (error) {
189
153
  this.logger.error('Error signing message:', error);
190
154
  throw error;
@@ -192,13 +156,6 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
192
156
  }
193
157
  //todo:should txn just be a string?
194
158
  async signTransaction({ senderAddress, transaction, password = undefined, externalServerKeyShares }) {
195
- // Validate inputs early
196
- if (!senderAddress) {
197
- throw new Error('Sender address is required');
198
- }
199
- if (Array.isArray(externalServerKeyShares) && externalServerKeyShares.length === 0) {
200
- throw new Error('External server key shares are required');
201
- }
202
159
  await this.verifyPassword({
203
160
  accountAddress: senderAddress,
204
161
  password,
@@ -206,14 +163,14 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
206
163
  });
207
164
  try {
208
165
  let messageToSign;
209
- if (typeof transaction === 'string') {
210
- messageToSign = transaction.startsWith('0x') ? transaction.slice(2) : transaction;
211
- } else if (transaction instanceof VersionedTransaction) {
166
+ if (transaction instanceof VersionedTransaction) {
167
+ // For versioned transactions, we need to sign the message directly
212
168
  const messageBytes = transaction.message.serialize();
213
- messageToSign = toHex(messageBytes);
169
+ messageToSign = Buffer.from(messageBytes).toString('hex');
214
170
  } else {
171
+ // For legacy transactions, serialize the message
215
172
  const messageBytes = transaction.serializeMessage();
216
- messageToSign = toHex(Buffer.isBuffer(messageBytes) ? messageBytes : messageBytes);
173
+ messageToSign = Buffer.from(messageBytes).toString('hex');
217
174
  }
218
175
  const signatureEd25519 = await this.sign({
219
176
  message: messageToSign,
@@ -225,7 +182,13 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
225
182
  if (!signatureEd25519) {
226
183
  throw new Error('Signature is undefined');
227
184
  }
228
- return encodeBase58(signatureEd25519);
185
+ const senderPublicKey = new PublicKey(senderAddress);
186
+ const signedTransaction = addSignatureToTransaction({
187
+ transaction,
188
+ signature: signatureEd25519,
189
+ signerPublicKey: senderPublicKey
190
+ });
191
+ return signedTransaction;
229
192
  } catch (error) {
230
193
  this.logger.error('Error in signTransaction:', error);
231
194
  if (error instanceof Error) {
@@ -273,19 +236,18 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
273
236
  * @param privateKey The private key to convert
274
237
  * @returns The hex string
275
238
  */ decodePrivateKeyForSolana(privateKey) {
276
- const decoded = decodeBase58(privateKey); // 64 bytes
277
- if (decoded.length !== 64) throw new Error('Invalid Solana secret key length');
278
- return Buffer.from(decoded.slice(0, 32)).toString('hex');
239
+ const decoded = new PublicKey(privateKey).toBuffer();
240
+ const slicedBytes = decoded.slice(0, 32);
241
+ return Buffer.from(slicedBytes).toString('hex');
279
242
  }
280
243
  getPublicKeyFromPrivateKey(privateKey) {
281
- const secret = decodeBase58(privateKey);
282
- const keypair = Keypair.fromSecretKey(secret);
283
- return keypair.publicKey.toBase58();
244
+ const privateKeyBytes = new PublicKey(privateKey).toBuffer();
245
+ const keypair = Keypair.fromSecretKey(privateKeyBytes);
246
+ const publicKeyBase58 = keypair.publicKey.toBase58();
247
+ return publicKeyBase58;
284
248
  }
285
249
  encodePublicKey(publicKey) {
286
- // Ensure a plain Uint8Array is passed to PublicKey
287
- const bytes = publicKey instanceof Uint8Array ? publicKey : new Uint8Array(publicKey);
288
- return new PublicKey(bytes).toBase58();
250
+ return new PublicKey(publicKey).toBase58();
289
251
  }
290
252
  /**
291
253
  * Imports the private key for a given account address
@@ -310,16 +272,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
310
272
  onError,
311
273
  onCeremonyComplete: (accountAddress, walletId)=>{
312
274
  // update wallet map
313
- const chainConfig = getMPCChainConfig(this.chainName);
314
275
  this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
315
276
  accountAddress,
316
277
  walletId,
317
278
  chainName: this.chainName,
318
279
  thresholdSignatureScheme,
319
- derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
320
- index,
321
- value
322
- ]))),
323
280
  externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
324
281
  });
325
282
  ceremonyCeremonyCompleteResolver(undefined);
@@ -360,146 +317,4 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
360
317
  }
361
318
  }
362
319
 
363
- async function getBalance({ address, rpcUrl = SOLANA_RPC_URL }) {
364
- const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
365
- const balance = await connection.getBalance(new PublicKey(address));
366
- return balance;
367
- }
368
- async function createSolanaTransaction({ senderSolanaAddress, amount, to, rpcUrl = 'https://api.devnet.solana.com' }) {
369
- const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
370
- const balance = await getBalance({
371
- address: senderSolanaAddress,
372
- rpcUrl
373
- });
374
- if (balance < amount * 1e9) {
375
- throw new Error('Insufficient balance');
376
- }
377
- const fromPubkey = new PublicKey(senderSolanaAddress);
378
- const transaction = new Transaction().add(SystemProgram.transfer({
379
- fromPubkey: fromPubkey,
380
- toPubkey: new PublicKey(to),
381
- lamports: amount * 1e9
382
- }));
383
- const { blockhash } = await connection.getLatestBlockhash();
384
- transaction.recentBlockhash = blockhash;
385
- transaction.feePayer = fromPubkey;
386
- const serializedTransaction = transaction.serializeMessage();
387
- return {
388
- transaction,
389
- serializedTransaction
390
- };
391
- }
392
- const addSignatureToTransaction = ({ transaction, signature, signerPublicKey })=>{
393
- transaction.addSignature(signerPublicKey, Buffer.from(signature));
394
- return transaction;
395
- };
396
- function attachSignature({ transaction, signatureBase58, senderAddress }) {
397
- const sigBytes = decodeBase58(signatureBase58);
398
- const signerPubkey = new PublicKey(senderAddress);
399
- return addSignatureToTransaction({
400
- transaction,
401
- signature: sigBytes,
402
- signerPublicKey: signerPubkey
403
- });
404
- }
405
- async function sendTransaction({ signedTransaction, rpcUrl = 'https://api.devnet.solana.com' }) {
406
- const connection = new Connection(rpcUrl != null ? rpcUrl : 'https://api.devnet.solana.com');
407
- const txid = await connection.sendRawTransaction(Buffer.from(signedTransaction));
408
- return txid;
409
- }
410
-
411
- /**
412
- * Creates a delegated SVM wallet client for functional operations
413
- */ const createDelegatedSvmWalletClient = ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug = false })=>{
414
- const baseClient = createDelegatedWalletClient({
415
- environmentId,
416
- baseApiUrl,
417
- baseMPCRelayApiUrl,
418
- apiKey,
419
- debug
420
- });
421
- const svmClient = _extends({}, baseClient, {
422
- chainName: 'SVM'
423
- });
424
- return svmClient;
425
- };
426
- /**
427
- * Signs a message using delegated signing for SVM
428
- */ const delegatedSignMessage = async (client, { walletId, walletApiKey, keyShare, message, isFormatted = false })=>{
429
- try {
430
- // Use the delegated sign message function from node package
431
- const signatureEd25519 = await delegatedSignMessage$1(client, {
432
- walletId,
433
- walletApiKey,
434
- keyShare,
435
- message,
436
- chainName: client.chainName,
437
- isFormatted
438
- });
439
- // Use PublicKey to encode signature as base58 (SVM format)
440
- const base58Signature = new PublicKey(signatureEd25519).toBase58();
441
- return base58Signature;
442
- } catch (error) {
443
- client.logger.error('Error in delegatedSignMessage', error);
444
- throw error;
445
- }
446
- };
447
- /**
448
- * Signs a transaction using delegated signing for SVM
449
- */ const delegatedSignTransaction = async (client, { walletId, walletApiKey, keyShare, transaction })=>{
450
- try {
451
- let messageToSign;
452
- if (transaction instanceof VersionedTransaction) {
453
- // For versioned transactions, we need to sign the message directly
454
- const messageBytes = transaction.message.serialize();
455
- messageToSign = Buffer.from(Array.from(messageBytes)).toString('hex');
456
- } else {
457
- // For legacy transactions, serialize the message
458
- const messageBytes = transaction.serializeMessage();
459
- messageToSign = messageBytes.toString('hex');
460
- }
461
- // Use the delegated sign message function from node package
462
- const signatureEd25519 = await delegatedSignMessage$1(client, {
463
- walletId,
464
- walletApiKey,
465
- keyShare,
466
- message: messageToSign,
467
- chainName: client.chainName,
468
- isFormatted: false
469
- });
470
- if (!signatureEd25519) {
471
- throw new Error('Signature is undefined');
472
- }
473
- // Get the sender address from the transaction
474
- let senderAddress;
475
- if (transaction instanceof VersionedTransaction) {
476
- // For versioned transactions, get the first signer
477
- const signers = transaction.message.staticAccountKeys;
478
- senderAddress = signers[0].toBase58();
479
- } else {
480
- var _transaction_feePayer;
481
- // For legacy transactions, use feePayer
482
- senderAddress = ((_transaction_feePayer = transaction.feePayer) == null ? void 0 : _transaction_feePayer.toBase58()) || '';
483
- }
484
- if (!senderAddress) {
485
- throw new Error('Could not determine sender address from transaction');
486
- }
487
- const senderPublicKey = new PublicKey(senderAddress);
488
- const signedTransaction = addSignatureToTransaction({
489
- transaction,
490
- signature: signatureEd25519,
491
- signerPublicKey: senderPublicKey
492
- });
493
- return signedTransaction;
494
- } catch (error) {
495
- client.logger.error('Error in delegatedSignTransaction', error);
496
- throw error;
497
- }
498
- };
499
- /**
500
- * Revoke delegation - delegates to the node package
501
- */ const revokeDelegation = async (client, params)=>{
502
- return revokeDelegation$1(client, params);
503
- };
504
-
505
- export { DynamicSvmWalletClient, ERROR_CREATE_WALLET_ACCOUNT, addSignatureToTransaction, attachSignature, createDelegatedSvmWalletClient, createSolanaTransaction, decodeBase58, delegatedSignMessage, delegatedSignTransaction, encodeBase58, getBalance, revokeDelegation, sendTransaction };
320
+ export { DynamicSvmWalletClient, addSignatureToTransaction, createSolanaTransaction, getBalance, sendTransaction };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/node-svm",
3
- "version": "0.0.0-beta.316",
3
+ "version": "0.0.0-pr354.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/node": "0.0.0-beta.316",
7
+ "@dynamic-labs-wallet/node": "0.0.0-pr354.0",
8
8
  "@solana/web3.js": "^1.98.2"
9
9
  },
10
10
  "publishConfig": {
@@ -36,17 +36,17 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
36
36
  * @param password The password for encrypted backup shares
37
37
  */
38
38
  signMessage({ message, accountAddress, password, externalServerKeyShares, }: {
39
- message: string | Uint8Array;
39
+ message: string;
40
40
  accountAddress: string;
41
41
  password?: string;
42
42
  externalServerKeyShares?: ServerKeyShare[];
43
43
  }): Promise<string>;
44
44
  signTransaction({ senderAddress, transaction, password, externalServerKeyShares, }: {
45
45
  senderAddress: string;
46
- transaction: VersionedTransaction | Transaction | string;
46
+ transaction: VersionedTransaction | Transaction;
47
47
  password?: string;
48
48
  externalServerKeyShares?: ServerKeyShare[];
49
- }): Promise<string>;
49
+ }): Promise<VersionedTransaction | Transaction>;
50
50
  /**
51
51
  * Exports the private key for a given account address
52
52
  *
@@ -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,EAI9B,MAAM,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,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;QAC9C,uBAAuB,EAAE,cAAc,EAAE,CAAC;KAC3C,CAAC;IA+DI,aAAa;CAOpB"}
@@ -1,5 +1,3 @@
1
1
  export * from './client.js';
2
2
  export * from './utils.js';
3
- export * from './base58.js';
4
- export * from './constants.js';
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -17,11 +17,6 @@ export declare const addSignatureToTransaction: ({ transaction, signature, signe
17
17
  signature: Uint8Array;
18
18
  signerPublicKey: PublicKey;
19
19
  }) => VersionedTransaction | Transaction;
20
- export declare function attachSignature({ transaction, signatureBase58, senderAddress, }: {
21
- transaction: Transaction | VersionedTransaction;
22
- signatureBase58: string;
23
- senderAddress: string;
24
- }): VersionedTransaction | Transaction;
25
20
  export declare function sendTransaction({ signedTransaction, rpcUrl, }: {
26
21
  signedTransaction: Uint8Array;
27
22
  rpcUrl?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,EAET,WAAW,EACX,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AAGzB,wBAAsB,UAAU,CAAC,EAC/B,OAAO,EACP,MAAuB,GACxB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAIA;AAED,wBAAsB,uBAAuB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X,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;GAwBA;AAED,eAAO,MAAM,yBAAyB,iDAInC;IACD,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAAC;IAChD,SAAS,EAAE,UAAU,CAAC;IACtB,eAAe,EAAE,SAAS,CAAC;CAC5B,KAAG,oBAAoB,GAAG,WAG1B,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,iBAAiB,EACjB,MAAwC,GACzC,EAAE;IACD,iBAAiB,EAAE,UAAU,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAMA"}
package/src/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './client/index.js';
2
- export * from './delegatedClient.js';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare function encodeBase58(source: Uint8Array): string;
2
- export declare function decodeBase58(str: string): Uint8Array;
3
- //# sourceMappingURL=base58.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/client/base58.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAmCvD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAmCpD"}
@@ -1,42 +0,0 @@
1
- import { VersionedTransaction } from '@solana/web3.js';
2
- import type { Transaction } from '@solana/web3.js';
3
- import type { ServerKeyShare, DelegatedWalletClient } from '@dynamic-labs-wallet/node';
4
- export type DelegatedSvmClientConfig = {
5
- environmentId: string;
6
- baseApiUrl?: string;
7
- baseMPCRelayApiUrl?: string;
8
- apiKey: string;
9
- debug?: boolean;
10
- };
11
- export type DelegatedSvmWalletClient = DelegatedWalletClient & {
12
- readonly chainName: 'SVM';
13
- };
14
- export type CreateDelegatedSvmClientProps = DelegatedSvmClientConfig;
15
- /**
16
- * Creates a delegated SVM wallet client for functional operations
17
- */
18
- export declare const createDelegatedSvmWalletClient: ({ environmentId, baseApiUrl, baseMPCRelayApiUrl, apiKey, debug, }: CreateDelegatedSvmClientProps) => DelegatedSvmWalletClient;
19
- /**
20
- * Signs a message using delegated signing for SVM
21
- */
22
- export declare const delegatedSignMessage: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, message, isFormatted, }: {
23
- walletId: string;
24
- walletApiKey: string;
25
- keyShare: ServerKeyShare;
26
- message: string;
27
- isFormatted?: boolean;
28
- }) => Promise<string>;
29
- /**
30
- * Signs a transaction using delegated signing for SVM
31
- */
32
- export declare const delegatedSignTransaction: (client: DelegatedSvmWalletClient, { walletId, walletApiKey, keyShare, transaction, }: {
33
- walletId: string;
34
- walletApiKey: string;
35
- keyShare: any;
36
- transaction: VersionedTransaction | Transaction;
37
- }) => Promise<VersionedTransaction | Transaction>;
38
- /**
39
- * Revoke delegation - delegates to the node package
40
- */
41
- export declare const revokeDelegation: (client: DelegatedSvmWalletClient, params: any) => Promise<void>;
42
- //# sourceMappingURL=delegatedClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegatedClient.d.ts","sourceRoot":"","sources":["../../packages/src/delegatedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAMnD,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAGnC,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAA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