@dynamic-labs-wallet/svm 0.0.43 → 0.0.45

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
@@ -5,17 +5,9 @@ var bs58 = require('bs58');
5
5
  var web3_js = require('@solana/web3.js');
6
6
  require('@dynamic-labs-wallet/core');
7
7
 
8
- const addSignatureToTransaction = ({ transaction, signature })=>{
8
+ const addSignatureToTransaction = ({ transaction, signature, signerPublicKey })=>{
9
9
  try {
10
- if (transaction instanceof web3_js.Transaction) {
11
- transaction.addSignature(transaction.feePayer, Buffer.from(signature));
12
- } else {
13
- // For versioned transactions, we should add the signature to the fee payer
14
- // which is always the first account in the static account keys
15
- // TODO: see if this works for sponsored transactions
16
- const feePayer = transaction.message.staticAccountKeys[0];
17
- transaction.addSignature(feePayer, Buffer.from(signature));
18
- }
10
+ transaction.addSignature(signerPublicKey, Buffer.from(signature));
19
11
  return transaction;
20
12
  } catch (error) {
21
13
  console.error('Error in finalizing transaction:', error);
@@ -151,9 +143,11 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
151
143
  if (!signatureEd25519) {
152
144
  throw new Error('Signature is undefined');
153
145
  }
146
+ const senderPublicKey = new web3_js.PublicKey(senderAddress);
154
147
  const signedTransaction = addSignatureToTransaction({
155
148
  transaction,
156
- signature: signatureEd25519
149
+ signature: signatureEd25519,
150
+ signerPublicKey: senderPublicKey
157
151
  });
158
152
  return signedTransaction;
159
153
  } catch (error) {
@@ -226,14 +220,15 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
226
220
  * @param thresholdSignatureScheme The threshold signature scheme to use
227
221
  * @param password The password for encrypted backup shares
228
222
  * @returns The account address, raw public key, and client key shares
229
- */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined }) {
223
+ */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
230
224
  //get public key from private key
231
225
  const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
232
226
  const formattedPrivateKey = await this.decodePrivateKeyForSolana(privateKey);
233
227
  const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
234
228
  chainName,
235
229
  privateKey: formattedPrivateKey,
236
- thresholdSignatureScheme
230
+ thresholdSignatureScheme,
231
+ onError
237
232
  });
238
233
  if (!rawPublicKey || !clientKeyShares) {
239
234
  throw new Error('Error creating wallet account');
package/index.esm.js CHANGED
@@ -1,19 +1,11 @@
1
1
  import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation } from '@dynamic-labs-wallet/browser';
2
2
  import bs58 from 'bs58';
3
- import { Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
3
+ import { VersionedTransaction, PublicKey, Keypair } from '@solana/web3.js';
4
4
  import '@dynamic-labs-wallet/core';
5
5
 
6
- const addSignatureToTransaction = ({ transaction, signature })=>{
6
+ const addSignatureToTransaction = ({ transaction, signature, signerPublicKey })=>{
7
7
  try {
8
- if (transaction instanceof Transaction) {
9
- transaction.addSignature(transaction.feePayer, Buffer.from(signature));
10
- } else {
11
- // For versioned transactions, we should add the signature to the fee payer
12
- // which is always the first account in the static account keys
13
- // TODO: see if this works for sponsored transactions
14
- const feePayer = transaction.message.staticAccountKeys[0];
15
- transaction.addSignature(feePayer, Buffer.from(signature));
16
- }
8
+ transaction.addSignature(signerPublicKey, Buffer.from(signature));
17
9
  return transaction;
18
10
  } catch (error) {
19
11
  console.error('Error in finalizing transaction:', error);
@@ -149,9 +141,11 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
149
141
  if (!signatureEd25519) {
150
142
  throw new Error('Signature is undefined');
151
143
  }
144
+ const senderPublicKey = new PublicKey(senderAddress);
152
145
  const signedTransaction = addSignatureToTransaction({
153
146
  transaction,
154
- signature: signatureEd25519
147
+ signature: signatureEd25519,
148
+ signerPublicKey: senderPublicKey
155
149
  });
156
150
  return signedTransaction;
157
151
  } catch (error) {
@@ -224,14 +218,15 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
224
218
  * @param thresholdSignatureScheme The threshold signature scheme to use
225
219
  * @param password The password for encrypted backup shares
226
220
  * @returns The account address, raw public key, and client key shares
227
- */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined }) {
221
+ */ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
228
222
  //get public key from private key
229
223
  const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
230
224
  const formattedPrivateKey = await this.decodePrivateKeyForSolana(privateKey);
231
225
  const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
232
226
  chainName,
233
227
  privateKey: formattedPrivateKey,
234
- thresholdSignatureScheme
228
+ thresholdSignatureScheme,
229
+ onError
235
230
  });
236
231
  if (!rawPublicKey || !clientKeyShares) {
237
232
  throw new Error('Error creating wallet account');
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/svm",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@dynamic-labs-wallet/browser": "0.0.43",
7
- "@dynamic-labs-wallet/core": "0.0.43",
6
+ "@dynamic-labs-wallet/browser": "0.0.45",
7
+ "@dynamic-labs-wallet/core": "0.0.45",
8
8
  "@solana/web3.js": "^1.98.0",
9
9
  "bs58": "^6.0.0"
10
10
  },
package/src/svm/svm.d.ts CHANGED
@@ -86,11 +86,12 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
86
86
  * @param password The password for encrypted backup shares
87
87
  * @returns The account address, raw public key, and client key shares
88
88
  */
89
- importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, }: {
89
+ importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, }: {
90
90
  privateKey: string;
91
91
  chainName: string;
92
92
  thresholdSignatureScheme: ThresholdSignatureScheme;
93
93
  password?: string;
94
+ onError?: (error: Error) => void;
94
95
  }): Promise<{
95
96
  accountAddress: string;
96
97
  rawPublicKey: Uint8Array | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"svm.d.ts","sourceRoot":"","sources":["../../src/svm/svm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAW,WAAW,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;gBAEZ,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,GACnB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B;IASD;;;;;OAKG;IACG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,GACrB,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,UAAU,CAAC;QACzB,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IAoDI,oBAAoB,CAAC,YAAY,EAAE,UAAU;;;IAOnD;;;;;;OAMG;IACG,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;IA6CK,eAAe,CAAC,EACpB,aAAa,EACb,WAAW,EACX,QAAoB,GACrB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,oBAAoB,GAAG,WAAW,CAAC;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AAC;QACjC,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;;;IASD;;;;;OAKG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM;IAM5C,0BAA0B,CAAC,UAAU,EAAE,MAAM;IAQ7C,eAAe,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM;IAI9C;;;;;;;;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,UAAU,GAAG,SAAS,CAAC;QACrC,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IAqDI,aAAa;CAOpB"}
@@ -1,4 +1,4 @@
1
- import { Transaction, VersionedTransaction } from '@solana/web3.js';
1
+ import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
2
2
  export declare function getBalance({ address, rpcUrl, }: {
3
3
  address: string;
4
4
  rpcUrl?: string;
@@ -12,9 +12,10 @@ export declare function createSolanaTransaction({ senderSolanaAddress, amount, t
12
12
  transaction: Transaction;
13
13
  serializedTransaction: Buffer;
14
14
  }>;
15
- export declare const addSignatureToTransaction: ({ transaction, signature, }: {
15
+ export declare const addSignatureToTransaction: ({ transaction, signature, signerPublicKey, }: {
16
16
  transaction: Transaction | VersionedTransaction;
17
17
  signature: Uint8Array;
18
+ signerPublicKey: PublicKey;
18
19
  }) => VersionedTransaction | Transaction;
19
20
  export declare function sendTransaction({ signedTransaction, rpcUrl, }: {
20
21
  signedTransaction: Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/svm/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,WAAW,EACX,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,wBAAsB,UAAU,CAAC,EAC/B,OAAO,EACP,MAAuB,GACxB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAWA;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,mBAAmB,EACnB,MAAM,EACN,EAAE,EACF,MAAwC,GACzC,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;GA+BA;AAED,eAAO,MAAM,yBAAyB,gCAGnC;IACD,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAAC;IAChD,SAAS,EAAE,UAAU,CAAC;CACvB,KAAG,oBAAoB,GAAG,WAmB1B,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,iBAAiB,EACjB,MAAwC,GACzC,EAAE;IACD,iBAAiB,EAAE,UAAU,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAaA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/svm/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,EAET,WAAW,EACX,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,wBAAsB,UAAU,CAAC,EAC/B,OAAO,EACP,MAAuB,GACxB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,mBAWA;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,mBAAmB,EACnB,MAAM,EACN,EAAE,EACF,MAAwC,GACzC,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,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