@dynamic-labs-wallet/svm 0.0.68 → 0.0.70

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
@@ -44,8 +44,8 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
44
44
  });
45
45
  }
46
46
  });
47
- if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array)) {
48
- throw new Error('Raw public key is not a Uint8Array');
47
+ if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array || typeof rawPublicKey === 'string')) {
48
+ throw new Error('Raw public key is not a Uint8Array or string' + typeof rawPublicKey);
49
49
  }
50
50
  if (!clientKeyShares) {
51
51
  throw new Error('Error creating wallet account');
@@ -75,9 +75,9 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
75
75
  throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
76
76
  }
77
77
  }
78
- // Function to properly derive account address
79
78
  async deriveAccountAddress(rawPublicKey) {
80
- const accountAddress = bs58.encode(rawPublicKey);
79
+ const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
80
+ const accountAddress = bs58.encode(pubKeyBytes);
81
81
  return {
82
82
  accountAddress
83
83
  };
@@ -159,6 +159,7 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
159
159
  * @param password The password for encrypted backup shares
160
160
  * @returns The private key
161
161
  */ async exportPrivateKey({ accountAddress, displayContainer, password = undefined }) {
162
+ var _derivedPrivateKey_match;
162
163
  await this.verifyPassword({
163
164
  accountAddress,
164
165
  password,
@@ -172,12 +173,13 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
172
173
  if (!derivedPrivateKey) {
173
174
  throw new Error('Derived private key is undefined');
174
175
  }
175
- const encodedPrivateKey = bs58.encode(Buffer.from(derivedPrivateKey));
176
+ // Convert hex string to Uint8Array
177
+ const privateKeyBytes = new Uint8Array(((_derivedPrivateKey_match = derivedPrivateKey.match(/.{1,2}/g)) == null ? void 0 : _derivedPrivateKey_match.map((byte)=>parseInt(byte, 16))) || []);
176
178
  // Display the private key in the container via iframe
177
179
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
178
180
  container: displayContainer
179
181
  });
180
- iframeDisplay.displayPrivateKey(encodedPrivateKey);
182
+ iframeDisplay.displayPrivateKey(JSON.stringify(Array.from(privateKeyBytes)));
181
183
  }
182
184
  /**
183
185
  * Exports the private key for a given account address
package/index.esm.js CHANGED
@@ -42,8 +42,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
42
42
  });
43
43
  }
44
44
  });
45
- if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array)) {
46
- throw new Error('Raw public key is not a Uint8Array');
45
+ if (!rawPublicKey || !(rawPublicKey instanceof Uint8Array || typeof rawPublicKey === 'string')) {
46
+ throw new Error('Raw public key is not a Uint8Array or string' + typeof rawPublicKey);
47
47
  }
48
48
  if (!clientKeyShares) {
49
49
  throw new Error('Error creating wallet account');
@@ -73,9 +73,9 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
73
73
  throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
74
74
  }
75
75
  }
76
- // Function to properly derive account address
77
76
  async deriveAccountAddress(rawPublicKey) {
78
- const accountAddress = bs58.encode(rawPublicKey);
77
+ const pubKeyBytes = typeof rawPublicKey === 'string' ? Buffer.from(rawPublicKey, 'hex') : rawPublicKey;
78
+ const accountAddress = bs58.encode(pubKeyBytes);
79
79
  return {
80
80
  accountAddress
81
81
  };
@@ -157,6 +157,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
157
157
  * @param password The password for encrypted backup shares
158
158
  * @returns The private key
159
159
  */ async exportPrivateKey({ accountAddress, displayContainer, password = undefined }) {
160
+ var _derivedPrivateKey_match;
160
161
  await this.verifyPassword({
161
162
  accountAddress,
162
163
  password,
@@ -170,12 +171,13 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
170
171
  if (!derivedPrivateKey) {
171
172
  throw new Error('Derived private key is undefined');
172
173
  }
173
- const encodedPrivateKey = bs58.encode(Buffer.from(derivedPrivateKey));
174
+ // Convert hex string to Uint8Array
175
+ const privateKeyBytes = new Uint8Array(((_derivedPrivateKey_match = derivedPrivateKey.match(/.{1,2}/g)) == null ? void 0 : _derivedPrivateKey_match.map((byte)=>parseInt(byte, 16))) || []);
174
176
  // Display the private key in the container via iframe
175
177
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
176
178
  container: displayContainer
177
179
  });
178
- iframeDisplay.displayPrivateKey(encodedPrivateKey);
180
+ iframeDisplay.displayPrivateKey(JSON.stringify(Array.from(privateKeyBytes)));
179
181
  }
180
182
  /**
181
183
  * Exports the private key for a given account address
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/svm",
3
- "version": "0.0.68",
3
+ "version": "0.0.70",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@dynamic-labs-wallet/browser": "0.0.68",
6
+ "@dynamic-labs-wallet/browser": "0.0.70",
7
7
  "@solana/web3.js": "^1.98.2",
8
8
  "bs58": "^6.0.0"
9
9
  },
package/src/svm/svm.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
23
23
  rawPublicKey: Uint8Array;
24
24
  clientKeyShares: ClientKeyShare[];
25
25
  }>;
26
- deriveAccountAddress(rawPublicKey: Uint8Array): Promise<{
26
+ deriveAccountAddress(rawPublicKey: string | Uint8Array): Promise<{
27
27
  accountAddress: string;
28
28
  }>;
29
29
  /**
@@ -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,EAEL,WAAW,EACX,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AA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