@dynamic-labs/solana 2.0.0-alpha.15 → 2.0.0-alpha.17

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,25 @@
1
1
 
2
+ ## [2.0.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.16...v2.0.0-alpha.17) (2024-03-15)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * rename prop canConnectViaEmail to requiresNonDynamicEmailOtp (#4991)
8
+
9
+ ### Features
10
+
11
+ * allow creating embedded wallet with phone number without email ([#4953](https://github.com/dynamic-labs/DynamicAuth/issues/4953)) ([39d31cb](https://github.com/dynamic-labs/DynamicAuth/commit/39d31cbc969fff7acf53c0b6c5e5093ff846f3ea))
12
+
13
+
14
+ * rename prop canConnectViaEmail to requiresNonDynamicEmailOtp ([#4991](https://github.com/dynamic-labs/DynamicAuth/issues/4991)) ([e83a365](https://github.com/dynamic-labs/DynamicAuth/commit/e83a3658d4f5cf0630fc8f15be66f2d3db84ab98))
15
+
16
+ ## [2.0.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.15...v2.0.0-alpha.16) (2024-03-15)
17
+
18
+
19
+ ### Features
20
+
21
+ * add bundlerProvider prop to allow AA customers to select a provider ([#4975](https://github.com/dynamic-labs/DynamicAuth/issues/4975)) ([1870cef](https://github.com/dynamic-labs/DynamicAuth/commit/1870cef4f50944a86226d10f09ef7bf6595f3c95))
22
+
2
23
  ## [2.0.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.14...v2.0.0-alpha.15) (2024-03-15)
3
24
 
4
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "2.0.0-alpha.15",
3
+ "version": "2.0.0-alpha.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -30,13 +30,13 @@
30
30
  "@dynamic-labs/sdk-api": "0.0.389",
31
31
  "bs58": "5.0.0",
32
32
  "tweetnacl": "1.0.3",
33
- "@dynamic-labs/rpc-provider-solana": "2.0.0-alpha.15",
34
- "@dynamic-labs/rpc-providers": "2.0.0-alpha.15",
35
- "@dynamic-labs/turnkey": "2.0.0-alpha.15",
36
- "@dynamic-labs/types": "2.0.0-alpha.15",
37
- "@dynamic-labs/utils": "2.0.0-alpha.15",
38
- "@dynamic-labs/wallet-book": "2.0.0-alpha.15",
39
- "@dynamic-labs/wallet-connector-core": "2.0.0-alpha.15",
33
+ "@dynamic-labs/rpc-provider-solana": "2.0.0-alpha.17",
34
+ "@dynamic-labs/rpc-providers": "2.0.0-alpha.17",
35
+ "@dynamic-labs/turnkey": "2.0.0-alpha.17",
36
+ "@dynamic-labs/types": "2.0.0-alpha.17",
37
+ "@dynamic-labs/utils": "2.0.0-alpha.17",
38
+ "@dynamic-labs/wallet-book": "2.0.0-alpha.17",
39
+ "@dynamic-labs/wallet-connector-core": "2.0.0-alpha.17",
40
40
  "eventemitter3": "5.0.1"
41
41
  },
42
42
  "peerDependencies": {}
@@ -6,7 +6,6 @@ var _tslib = require('../_virtual/_tslib.cjs');
6
6
  var utils = require('@dynamic-labs/utils');
7
7
  var walletBook = require('@dynamic-labs/wallet-book');
8
8
  require('@dynamic-labs/turnkey');
9
- require('@dynamic-labs/sdk-api');
10
9
  require('./solWalletConnector.cjs');
11
10
  require('tweetnacl');
12
11
  require('bs58');
@@ -2,7 +2,6 @@ import { __awaiter } from '../_virtual/_tslib.js';
2
2
  import { bufferToBase64 } from '@dynamic-labs/utils';
3
3
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
4
  import '@dynamic-labs/turnkey';
5
- import '@dynamic-labs/sdk-api';
6
5
  import './solWalletConnector.js';
7
6
  import 'tweetnacl';
8
7
  import 'bs58';
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../_virtual/_tslib.cjs');
6
+ var utils = require('@dynamic-labs/utils');
7
+ var walletBook = require('@dynamic-labs/wallet-book');
8
+ var InjectedWalletBase = require('./injected/InjectedWalletBase.cjs');
9
+
10
+ class Solflare extends InjectedWalletBase.InjectedWalletBase {
11
+ constructor(opts) {
12
+ super(opts);
13
+ this.name = 'Solflare';
14
+ this.overrideKey = 'solflare';
15
+ this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
16
+ }
17
+ getAddress() {
18
+ var _a, _b, _c, _d, _e;
19
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
20
+ /**
21
+ * It should redirect to in-app browser if on mobile and if not in the in-app browser,
22
+ * this checks if it is not in the in-app browser by checking if the provider is not available.
23
+ */
24
+ if (utils.isMobile() && !this.isInstalledOnBrowser()) {
25
+ utils.handleMobileWalletRedirect({
26
+ nativeLink: ((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.native) || 'solflare://ul/v1/browse',
27
+ universalLink: ((_d = (_c = this.wallet) === null || _c === void 0 ? void 0 : _c.mobile) === null || _d === void 0 ? void 0 : _d.universal) || 'https://solflare.com/ul/v1/browse',
28
+ });
29
+ return;
30
+ }
31
+ return (_e = this.getSolProviderHelper()) === null || _e === void 0 ? void 0 : _e.getAddress();
32
+ });
33
+ }
34
+ signMessage(messageToSign) {
35
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
36
+ const walletAddress = yield this.getAddress();
37
+ if (!walletAddress) {
38
+ return undefined;
39
+ }
40
+ const provider = yield this.getSigner();
41
+ if (!provider) {
42
+ return undefined;
43
+ }
44
+ const encodedMessage = new TextEncoder().encode(messageToSign);
45
+ const isSignedMessage = (value) => value.signature !== undefined;
46
+ yield provider.connect();
47
+ /**
48
+ * TODO: Remove the sleep once problem is fixed on Solflare's extension.
49
+ * Tracked in DYN-442
50
+ */
51
+ yield new Promise((resolve) => {
52
+ setTimeout(resolve, 100);
53
+ });
54
+ const rawMessage = yield provider.signMessage(encodedMessage, 'utf8');
55
+ return isSignedMessage(rawMessage)
56
+ ? utils.bufferToBase64(rawMessage.signature)
57
+ : undefined;
58
+ });
59
+ }
60
+ }
61
+
62
+ exports.Solflare = Solflare;
@@ -0,0 +1,58 @@
1
+ import { __awaiter } from '../_virtual/_tslib.js';
2
+ import { isMobile, handleMobileWalletRedirect, bufferToBase64 } from '@dynamic-labs/utils';
3
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
+ import { InjectedWalletBase } from './injected/InjectedWalletBase.js';
5
+
6
+ class Solflare extends InjectedWalletBase {
7
+ constructor(opts) {
8
+ super(opts);
9
+ this.name = 'Solflare';
10
+ this.overrideKey = 'solflare';
11
+ this.wallet = findWalletBookWallet(this.walletBook, this.key);
12
+ }
13
+ getAddress() {
14
+ var _a, _b, _c, _d, _e;
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ /**
17
+ * It should redirect to in-app browser if on mobile and if not in the in-app browser,
18
+ * this checks if it is not in the in-app browser by checking if the provider is not available.
19
+ */
20
+ if (isMobile() && !this.isInstalledOnBrowser()) {
21
+ handleMobileWalletRedirect({
22
+ nativeLink: ((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.native) || 'solflare://ul/v1/browse',
23
+ universalLink: ((_d = (_c = this.wallet) === null || _c === void 0 ? void 0 : _c.mobile) === null || _d === void 0 ? void 0 : _d.universal) || 'https://solflare.com/ul/v1/browse',
24
+ });
25
+ return;
26
+ }
27
+ return (_e = this.getSolProviderHelper()) === null || _e === void 0 ? void 0 : _e.getAddress();
28
+ });
29
+ }
30
+ signMessage(messageToSign) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const walletAddress = yield this.getAddress();
33
+ if (!walletAddress) {
34
+ return undefined;
35
+ }
36
+ const provider = yield this.getSigner();
37
+ if (!provider) {
38
+ return undefined;
39
+ }
40
+ const encodedMessage = new TextEncoder().encode(messageToSign);
41
+ const isSignedMessage = (value) => value.signature !== undefined;
42
+ yield provider.connect();
43
+ /**
44
+ * TODO: Remove the sleep once problem is fixed on Solflare's extension.
45
+ * Tracked in DYN-442
46
+ */
47
+ yield new Promise((resolve) => {
48
+ setTimeout(resolve, 100);
49
+ });
50
+ const rawMessage = yield provider.signMessage(encodedMessage, 'utf8');
51
+ return isSignedMessage(rawMessage)
52
+ ? bufferToBase64(rawMessage.signature)
53
+ : undefined;
54
+ });
55
+ }
56
+ }
57
+
58
+ export { Solflare };
package/src/index.cjs CHANGED
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var turnkey = require('@dynamic-labs/turnkey');
6
- var sdkApi = require('@dynamic-labs/sdk-api');
7
6
  var Phantom = require('./Phantom.cjs');
8
7
  var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
9
8
  var isSignedMessage = require('./utils/isSignedMessage.cjs');
@@ -13,7 +12,7 @@ var isBackpackSolanaSigner = require('./utils/isBackpackSolanaSigner.cjs');
13
12
  const SolanaWalletConnectors = (props) => [
14
13
  ...fetchInjectedWalletConnectors.injectedWalletOverrides,
15
14
  ...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(props),
16
- ...turnkey.TurnkeyWalletConnectors(props, sdkApi.ChainEnum.Sol),
15
+ ...turnkey.TurnkeySolanaWalletConnectors(props),
17
16
  Phantom.Phantom,
18
17
  ];
19
18
 
package/src/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { TurnkeyWalletConnectors } from '@dynamic-labs/turnkey';
2
- import { ChainEnum } from '@dynamic-labs/sdk-api';
1
+ import { TurnkeySolanaWalletConnectors } from '@dynamic-labs/turnkey';
3
2
  import { Phantom } from './Phantom.js';
4
3
  import { injectedWalletOverrides, fetchInjectedWalletConnectors } from './injected/fetchInjectedWalletConnectors.js';
5
4
  export { isSignedMessage } from './utils/isSignedMessage.js';
@@ -9,7 +8,7 @@ export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner.js';
9
8
  const SolanaWalletConnectors = (props) => [
10
9
  ...injectedWalletOverrides,
11
10
  ...fetchInjectedWalletConnectors(props),
12
- ...TurnkeyWalletConnectors(props, ChainEnum.Sol),
11
+ ...TurnkeySolanaWalletConnectors(props),
13
12
  Phantom,
14
13
  ];
15
14
 
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var CoinbaseSolana = require('../CoinbaseSolana.cjs');
6
6
  var Slope = require('../Slope.cjs');
7
+ var Solflare = require('../Solflare.cjs');
7
8
  var InjectedWalletBase = require('./InjectedWalletBase.cjs');
8
9
  var BackpackSol = require('./BackpackSol.cjs');
9
10
 
@@ -11,6 +12,7 @@ const injectedWalletOverrides = [
11
12
  CoinbaseSolana.CoinbaseSolana,
12
13
  Slope.Slope,
13
14
  BackpackSol.BackpackSol,
15
+ Solflare.Solflare,
14
16
  ];
15
17
  const filteredInjectedWalletKeysOverrides = [
16
18
  'coinbasesolana',
@@ -18,6 +20,7 @@ const filteredInjectedWalletKeysOverrides = [
18
20
  'phantom',
19
21
  'phantomledger',
20
22
  'backpacksol',
23
+ 'solflare',
21
24
  ];
22
25
  const fetchInjectedWalletConnectors = ({ walletBook, }) => {
23
26
  var _a;
@@ -1,5 +1,6 @@
1
1
  import { CoinbaseSolana } from '../CoinbaseSolana.js';
2
2
  import { Slope } from '../Slope.js';
3
+ import { Solflare } from '../Solflare.js';
3
4
  import { InjectedWalletBase } from './InjectedWalletBase.js';
4
5
  import { BackpackSol } from './BackpackSol.js';
5
6
 
@@ -7,6 +8,7 @@ const injectedWalletOverrides = [
7
8
  CoinbaseSolana,
8
9
  Slope,
9
10
  BackpackSol,
11
+ Solflare,
10
12
  ];
11
13
  const filteredInjectedWalletKeysOverrides = [
12
14
  'coinbasesolana',
@@ -14,6 +16,7 @@ const filteredInjectedWalletKeysOverrides = [
14
16
  'phantom',
15
17
  'phantomledger',
16
18
  'backpacksol',
19
+ 'solflare',
17
20
  ];
18
21
  const fetchInjectedWalletConnectors = ({ walletBook, }) => {
19
22
  var _a;