@dynamic-labs/embedded-wallet-solana 3.0.0-alpha.56 → 3.0.0-alpha.57

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/CHANGELOG.md CHANGED
@@ -1,4 +1,22 @@
1
1
 
2
+ ## [3.0.0-alpha.57](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.56...v3.0.0-alpha.57) (2024-09-05)
3
+
4
+
5
+ ### Features
6
+
7
+ * add support for headless mfa ([#6802](https://github.com/dynamic-labs/DynamicAuth/issues/6802)) ([1eea60e](https://github.com/dynamic-labs/DynamicAuth/commit/1eea60e4f6acf60a9efa8ae64626d0c72e18a12d))
8
+ * telegram auto login ([#6803](https://github.com/dynamic-labs/DynamicAuth/issues/6803)) ([1123ae4](https://github.com/dynamic-labs/DynamicAuth/commit/1123ae4acfdfc54be8dbfa03cc41cbbd00b4bea4))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * circular dependency in solana-core and wallet-book ([#6794](https://github.com/dynamic-labs/DynamicAuth/issues/6794)) ([c0d9254](https://github.com/dynamic-labs/DynamicAuth/commit/c0d9254f21c4a847bcf271886997ba61fe077696))
14
+ * fix overriding cosmos wallet methods ([#6799](https://github.com/dynamic-labs/DynamicAuth/issues/6799)) ([ebce93b](https://github.com/dynamic-labs/DynamicAuth/commit/ebce93bab49bb54d320c77a558d0df48eb1ce19a))
15
+ * fix overriding solana wallet methods ([#6798](https://github.com/dynamic-labs/DynamicAuth/issues/6798)) ([6ab57b5](https://github.com/dynamic-labs/DynamicAuth/commit/6ab57b534b04a3824898bbb9df3fc23397e661f3))
16
+ * memoize return of useSwitchWallet ([#6804](https://github.com/dynamic-labs/DynamicAuth/issues/6804)) ([7e96eb2](https://github.com/dynamic-labs/DynamicAuth/commit/7e96eb28ca3809edd89855c4ecb1344f3e9d53bd))
17
+ * phantom wallets error when trying to sync wallet ([#6782](https://github.com/dynamic-labs/DynamicAuth/issues/6782)) ([481e474](https://github.com/dynamic-labs/DynamicAuth/commit/481e4746adf1ebac5584e3c83d1603e5b2e48f8a))
18
+ * remove miss use of hook inside function ([#6795](https://github.com/dynamic-labs/DynamicAuth/issues/6795)) ([35902cf](https://github.com/dynamic-labs/DynamicAuth/commit/35902cfc876e93928cf5baff0313d8b0352c1129))
19
+
2
20
  ## [3.0.0-alpha.56](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.55...v3.0.0-alpha.56) (2024-09-03)
3
21
 
4
22
 
package/package.cjs CHANGED
@@ -3,12 +3,12 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "3.0.0-alpha.56";
6
+ var version = "3.0.0-alpha.57";
7
7
  var dependencies = {
8
- "@dynamic-labs/sdk-api-core": "0.0.525",
9
- "@dynamic-labs/utils": "3.0.0-alpha.56",
10
- "@dynamic-labs/logger": "3.0.0-alpha.56",
11
- "@dynamic-labs/types": "3.0.0-alpha.56",
8
+ "@dynamic-labs/sdk-api-core": "0.0.526",
9
+ "@dynamic-labs/utils": "3.0.0-alpha.57",
10
+ "@dynamic-labs/logger": "3.0.0-alpha.57",
11
+ "@dynamic-labs/types": "3.0.0-alpha.57",
12
12
  eventemitter3: "5.0.1",
13
13
  "@solana/spl-token": "0.4.6",
14
14
  "@solana/web3.js": "1.92.1",
package/package.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use client'
2
- var version = "3.0.0-alpha.56";
2
+ var version = "3.0.0-alpha.57";
3
3
  var dependencies = {
4
- "@dynamic-labs/sdk-api-core": "0.0.525",
5
- "@dynamic-labs/utils": "3.0.0-alpha.56",
6
- "@dynamic-labs/logger": "3.0.0-alpha.56",
7
- "@dynamic-labs/types": "3.0.0-alpha.56",
4
+ "@dynamic-labs/sdk-api-core": "0.0.526",
5
+ "@dynamic-labs/utils": "3.0.0-alpha.57",
6
+ "@dynamic-labs/logger": "3.0.0-alpha.57",
7
+ "@dynamic-labs/types": "3.0.0-alpha.57",
8
8
  eventemitter3: "5.0.1",
9
9
  "@solana/spl-token": "0.4.6",
10
10
  "@solana/web3.js": "1.92.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/embedded-wallet-solana",
3
- "version": "3.0.0-alpha.56",
3
+ "version": "3.0.0-alpha.57",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -26,10 +26,10 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/sdk-api-core": "0.0.525",
30
- "@dynamic-labs/utils": "3.0.0-alpha.56",
31
- "@dynamic-labs/logger": "3.0.0-alpha.56",
32
- "@dynamic-labs/types": "3.0.0-alpha.56",
29
+ "@dynamic-labs/sdk-api-core": "0.0.526",
30
+ "@dynamic-labs/utils": "3.0.0-alpha.57",
31
+ "@dynamic-labs/logger": "3.0.0-alpha.57",
32
+ "@dynamic-labs/types": "3.0.0-alpha.57",
33
33
  "eventemitter3": "5.0.1",
34
34
  "@solana/spl-token": "0.4.6",
35
35
  "@solana/web3.js": "1.92.1",
@@ -37,12 +37,12 @@
37
37
  "@turnkey/iframe-stamper": "2.0.0",
38
38
  "@turnkey/solana": "0.3.9",
39
39
  "@turnkey/webauthn-stamper": "0.5.0",
40
- "@dynamic-labs/embedded-wallet": "3.0.0-alpha.56",
41
- "@dynamic-labs/rpc-providers": "3.0.0-alpha.56",
42
- "@dynamic-labs/solana-core": "3.0.0-alpha.56",
43
- "@dynamic-labs/wallet-book": "3.0.0-alpha.56",
44
- "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.56",
45
- "@dynamic-labs/webauthn": "3.0.0-alpha.56",
40
+ "@dynamic-labs/embedded-wallet": "3.0.0-alpha.57",
41
+ "@dynamic-labs/rpc-providers": "3.0.0-alpha.57",
42
+ "@dynamic-labs/solana-core": "3.0.0-alpha.57",
43
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.57",
44
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.57",
45
+ "@dynamic-labs/webauthn": "3.0.0-alpha.57",
46
46
  "react-dom": "18.2.0",
47
47
  "viem": "2.9.25"
48
48
  },
@@ -9,6 +9,7 @@ var webauthnStamper = require('@turnkey/webauthn-stamper');
9
9
  var http = require('@turnkey/http');
10
10
  var solana = require('@turnkey/solana');
11
11
  var iframeStamper = require('@turnkey/iframe-stamper');
12
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
12
13
  var utils = require('@dynamic-labs/utils');
13
14
  var solanaCore = require('@dynamic-labs/solana-core');
14
15
  var embeddedWallet = require('@dynamic-labs/embedded-wallet');
@@ -44,6 +45,7 @@ class TurnkeySolanaWalletConnector extends embeddedWallet.TurnkeyWalletConnector
44
45
  throw new Error('Failed to get environment id');
45
46
  };
46
47
  this.stampCreateWalletAccountRequest = (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ request, }) {
48
+ yield this.createOrRestoreSession();
47
49
  const turnkeyClient = this.getTurnkeyClient();
48
50
  return turnkeyClient.stampCreateWalletAccounts(request);
49
51
  });
@@ -117,15 +119,32 @@ class TurnkeySolanaWalletConnector extends embeddedWallet.TurnkeyWalletConnector
117
119
  return false;
118
120
  }
119
121
  setVerifiedCredentials(verifiedCredentials) {
120
- const turnkeyVerifiedCredential = embeddedWallet.findTurnkeyVerifiedCredential(verifiedCredentials, solanaCore.ProviderChain.SOLANA);
121
- const didTurnkeyVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredential) !==
122
- JSON.stringify(turnkeyVerifiedCredential);
122
+ const turnkeyVerifiedCredentials = embeddedWallet.findTurnkeyVerifiedCredentials(verifiedCredentials, solanaCore.ProviderChain.SOLANA);
123
+ const [turnkeyVerifiedCredential] = turnkeyVerifiedCredentials;
124
+ const didTurnkeyVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredentials) !==
125
+ JSON.stringify(turnkeyVerifiedCredentials);
123
126
  if (!didTurnkeyVerifiedCredentialsChanged) {
124
127
  return;
125
128
  }
126
129
  this.verifiedCredential = turnkeyVerifiedCredential;
130
+ this.verifiedCredentials = turnkeyVerifiedCredentials;
127
131
  this.refreshTurnkeyAccount();
128
132
  }
133
+ validateActiveWallet(expectedAddress) {
134
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
135
+ var _a, _b;
136
+ const activeAddress = ((_a = this.verifiedCredential) === null || _a === void 0 ? void 0 : _a.address) || '';
137
+ const isWalletActive = walletConnectorCore.isSameAddress(activeAddress, expectedAddress, this.connectedChain);
138
+ if (!isWalletActive) {
139
+ const targetActiveAccount = (_b = this.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((vc) => (vc === null || vc === void 0 ? void 0 : vc.address) === expectedAddress);
140
+ if (!targetActiveAccount) {
141
+ throw new utils.DynamicError('Account not found');
142
+ }
143
+ this.verifiedCredential = targetActiveAccount;
144
+ this.refreshTurnkeyAccount();
145
+ }
146
+ });
147
+ }
129
148
  getAccount() {
130
149
  return this.turnkeyAddress;
131
150
  }
@@ -35,6 +35,7 @@ export declare class TurnkeySolanaWalletConnector extends TurnkeyWalletConnector
35
35
  getPublicClient(): Promise<Connection | undefined>;
36
36
  supportsNetworkSwitching(): boolean;
37
37
  setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
38
+ validateActiveWallet(expectedAddress: string): Promise<void>;
38
39
  getAccount(): string | undefined;
39
40
  endSession(): Promise<void>;
40
41
  private refreshTurnkeyAccount;
@@ -5,9 +5,10 @@ import { WebauthnStamper } from '@turnkey/webauthn-stamper';
5
5
  import { TurnkeyClient } from '@turnkey/http';
6
6
  import { TurnkeySigner } from '@turnkey/solana';
7
7
  import { IframeStamper } from '@turnkey/iframe-stamper';
8
+ import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
8
9
  import { DynamicError, getTLD, PlatformService, bufferToBase64 } from '@dynamic-labs/utils';
9
10
  import { SolanaWallet, ProviderChain, getGenesisHashLSKey, SolanaUiTransaction } from '@dynamic-labs/solana-core';
10
- import { TurnkeyWalletConnectorBase, findTurnkeyVerifiedCredential, PasskeyService, TURNKEY_API_BASE_URL, TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS, logger } from '@dynamic-labs/embedded-wallet';
11
+ import { TurnkeyWalletConnectorBase, findTurnkeyVerifiedCredentials, PasskeyService, TURNKEY_API_BASE_URL, TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS, logger } from '@dynamic-labs/embedded-wallet';
11
12
  import { createSolanaConnection } from '../utils/createSolanaConnection/createSolanaConnection.js';
12
13
  import { decodeTransaction, getTotalSolanaSpend, summarizeTransactionDecodedData } from '../utils/transactionDecoder/transactionDecoder.js';
13
14
  import { optimizeSolanaTransaction } from '../utils/api/api.js';
@@ -40,6 +41,7 @@ class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase {
40
41
  throw new Error('Failed to get environment id');
41
42
  };
42
43
  this.stampCreateWalletAccountRequest = (_b) => __awaiter(this, [_b], void 0, function* ({ request, }) {
44
+ yield this.createOrRestoreSession();
43
45
  const turnkeyClient = this.getTurnkeyClient();
44
46
  return turnkeyClient.stampCreateWalletAccounts(request);
45
47
  });
@@ -113,15 +115,32 @@ class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase {
113
115
  return false;
114
116
  }
115
117
  setVerifiedCredentials(verifiedCredentials) {
116
- const turnkeyVerifiedCredential = findTurnkeyVerifiedCredential(verifiedCredentials, ProviderChain.SOLANA);
117
- const didTurnkeyVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredential) !==
118
- JSON.stringify(turnkeyVerifiedCredential);
118
+ const turnkeyVerifiedCredentials = findTurnkeyVerifiedCredentials(verifiedCredentials, ProviderChain.SOLANA);
119
+ const [turnkeyVerifiedCredential] = turnkeyVerifiedCredentials;
120
+ const didTurnkeyVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredentials) !==
121
+ JSON.stringify(turnkeyVerifiedCredentials);
119
122
  if (!didTurnkeyVerifiedCredentialsChanged) {
120
123
  return;
121
124
  }
122
125
  this.verifiedCredential = turnkeyVerifiedCredential;
126
+ this.verifiedCredentials = turnkeyVerifiedCredentials;
123
127
  this.refreshTurnkeyAccount();
124
128
  }
129
+ validateActiveWallet(expectedAddress) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ var _a, _b;
132
+ const activeAddress = ((_a = this.verifiedCredential) === null || _a === void 0 ? void 0 : _a.address) || '';
133
+ const isWalletActive = isSameAddress(activeAddress, expectedAddress, this.connectedChain);
134
+ if (!isWalletActive) {
135
+ const targetActiveAccount = (_b = this.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((vc) => (vc === null || vc === void 0 ? void 0 : vc.address) === expectedAddress);
136
+ if (!targetActiveAccount) {
137
+ throw new DynamicError('Account not found');
138
+ }
139
+ this.verifiedCredential = targetActiveAccount;
140
+ this.refreshTurnkeyAccount();
141
+ }
142
+ });
143
+ }
125
144
  getAccount() {
126
145
  return this.turnkeyAddress;
127
146
  }