@dynamic-labs/solana 3.0.0-alpha.24 → 3.0.0-alpha.26

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,15 @@
1
1
 
2
+ ## [3.0.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.25...v3.0.0-alpha.26) (2024-07-24)
3
+
4
+ ## [3.0.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.24...v3.0.0-alpha.25) (2024-07-24)
5
+
6
+
7
+ ### Features
8
+
9
+ * add ability to specify mobileExperience on a wallet by wallet ([#6195](https://github.com/dynamic-labs/DynamicAuth/issues/6195)) ([947fd0a](https://github.com/dynamic-labs/DynamicAuth/commit/947fd0ab864d1995a1ef35a51c77a585649fd43f))
10
+ * global wallet new package ([#6385](https://github.com/dynamic-labs/DynamicAuth/issues/6385)) ([230a0f3](https://github.com/dynamic-labs/DynamicAuth/commit/230a0f380c2bc8c69619daed0c7f3280da8b8bb9))
11
+ * solana send balance modal for injected ([#6405](https://github.com/dynamic-labs/DynamicAuth/issues/6405)) ([b8aa84b](https://github.com/dynamic-labs/DynamicAuth/commit/b8aa84b58eb71791405bf68b6c46c40bebb170f8))
12
+
2
13
  ## [3.0.0-alpha.24](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.23...v3.0.0-alpha.24) (2024-07-20)
3
14
 
4
15
  ## [3.0.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.22...v3.0.0-alpha.23) (2024-07-19)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "3.0.0-alpha.24",
3
+ "version": "3.0.0-alpha.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -27,20 +27,21 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@solana/web3.js": "1.92.1",
30
- "@dynamic-labs/sdk-api-core": "0.0.489",
30
+ "@dynamic-labs/sdk-api-core": "0.0.497",
31
31
  "@wallet-standard/app": "1.0.1",
32
32
  "@wallet-standard/base": "1.0.1",
33
33
  "@wallet-standard/features": "1.0.3",
34
34
  "@wallet-standard/experimental-features": "0.1.1",
35
35
  "bs58": "5.0.0",
36
36
  "tweetnacl": "1.0.3",
37
- "@dynamic-labs/embedded-wallet-solana": "3.0.0-alpha.24",
38
- "@dynamic-labs/rpc-provider-solana": "3.0.0-alpha.24",
39
- "@dynamic-labs/rpc-providers": "3.0.0-alpha.24",
40
- "@dynamic-labs/types": "3.0.0-alpha.24",
41
- "@dynamic-labs/utils": "3.0.0-alpha.24",
42
- "@dynamic-labs/wallet-book": "3.0.0-alpha.24",
43
- "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.24",
37
+ "@dynamic-labs/embedded-wallet-solana": "3.0.0-alpha.26",
38
+ "@dynamic-labs/rpc-provider-solana": "3.0.0-alpha.26",
39
+ "@dynamic-labs/rpc-providers": "3.0.0-alpha.26",
40
+ "@dynamic-labs/solana-utils": "3.0.0-alpha.26",
41
+ "@dynamic-labs/types": "3.0.0-alpha.26",
42
+ "@dynamic-labs/utils": "3.0.0-alpha.26",
43
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.26",
44
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.26",
44
45
  "eventemitter3": "5.0.1"
45
46
  },
46
47
  "peerDependencies": {}
package/src/Phantom.cjs CHANGED
@@ -32,7 +32,7 @@ class Phantom extends solWalletConnector.SolWalletConnector {
32
32
  if (!utils.isMobile() || phantomInjected.isInstalledOnBrowser()) {
33
33
  return phantomInjected;
34
34
  }
35
- if (this.constructorProps.mobileExperience === 'redirect') {
35
+ if (this.mobileExperience === 'redirect') {
36
36
  return new PhantomRedirect.PhantomRedirect(this.constructorProps);
37
37
  }
38
38
  else {
package/src/Phantom.js CHANGED
@@ -28,7 +28,7 @@ class Phantom extends SolWalletConnector {
28
28
  if (!isMobile() || phantomInjected.isInstalledOnBrowser()) {
29
29
  return phantomInjected;
30
30
  }
31
- if (this.constructorProps.mobileExperience === 'redirect') {
31
+ if (this.mobileExperience === 'redirect') {
32
32
  return new PhantomRedirect(this.constructorProps);
33
33
  }
34
34
  else {
@@ -4,8 +4,10 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
+ var web3_js = require('@solana/web3.js');
7
8
  var walletBook = require('@dynamic-labs/wallet-book');
8
9
  var utils = require('@dynamic-labs/utils');
10
+ var solanaUtils = require('@dynamic-labs/solana-utils');
9
11
  var solProviderHelper = require('../solProviderHelper.cjs');
10
12
  var solWalletConnector = require('../solWalletConnector.cjs');
11
13
  var SignMessageNotSupportedError = require('../errors/SignMessageNotSupportedError.cjs');
@@ -44,6 +46,34 @@ class InjectedWalletBase extends solWalletConnector.SolWalletConnector {
44
46
  return (_a = this.getSolProviderHelper()) === null || _a === void 0 ? void 0 : _a.connect();
45
47
  });
46
48
  }
49
+ createUiTransaction(from) {
50
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
51
+ return new solanaUtils.SolanaUiTransaction({
52
+ connection: this.getWalletClient(),
53
+ from,
54
+ onSubmit: (transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
55
+ var _a;
56
+ const signer = yield this.getSigner();
57
+ if (!signer)
58
+ throw new Error('Signer not found');
59
+ const blockhash = yield this.getWalletClient().getLatestBlockhash();
60
+ if ('version' in transaction) {
61
+ transaction.message.recentBlockhash =
62
+ blockhash.blockhash;
63
+ }
64
+ else {
65
+ const userAddress = yield this.getAddress();
66
+ if (!userAddress)
67
+ throw new Error('User address not found');
68
+ transaction.recentBlockhash = blockhash.blockhash;
69
+ transaction.feePayer =
70
+ (_a = transaction.feePayer) !== null && _a !== void 0 ? _a : new web3_js.PublicKey(userAddress);
71
+ }
72
+ return (yield signer.signAndSendTransaction(transaction)).signature;
73
+ }),
74
+ });
75
+ });
76
+ }
47
77
  isInstalledOnBrowser() {
48
78
  var _a;
49
79
  return Boolean((_a = this.getSolProviderHelper()) === null || _a === void 0 ? void 0 : _a.isInstalledHelper());
@@ -54,7 +84,8 @@ class InjectedWalletBase extends solWalletConnector.SolWalletConnector {
54
84
  if (!this.isInstalledOnBrowser()) {
55
85
  if (utils.isMobile() &&
56
86
  ((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) &&
57
- this.wallet.mobile.inAppBrowser) {
87
+ this.wallet.mobile.inAppBrowser &&
88
+ this.mobileExperience === 'in-app-browser') {
58
89
  const inAppBrowserCompiledTemplate = utils.template(this.wallet.mobile.inAppBrowser);
59
90
  const deepLink = inAppBrowserCompiledTemplate({
60
91
  encodedDappURI: encodeURIComponent(window.location.toString()),
@@ -1,8 +1,10 @@
1
1
  import { WalletSchema } from '@dynamic-labs/wallet-book';
2
+ import { IUITransaction } from '@dynamic-labs/types';
3
+ import { ISendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
4
  import { ISolana } from '../types';
3
5
  import { SolProviderHelper } from '../solProviderHelper';
4
6
  import { SolWalletConnector } from '../solWalletConnector';
5
- export declare abstract class InjectedWalletBase extends SolWalletConnector {
7
+ export declare abstract class InjectedWalletBase extends SolWalletConnector implements ISendBalanceWalletConnector {
6
8
  solProviderHelper: SolProviderHelper | undefined;
7
9
  wallet: WalletSchema | undefined;
8
10
  getSolProviderHelper(): SolProviderHelper | undefined;
@@ -11,6 +13,7 @@ export declare abstract class InjectedWalletBase extends SolWalletConnector {
11
13
  teardownEventListeners(): void;
12
14
  connect(): Promise<void>;
13
15
  getSigner<T = ISolana>(): Promise<T | undefined>;
16
+ createUiTransaction(from: string): Promise<IUITransaction>;
14
17
  isInstalledOnBrowser(): boolean;
15
18
  getAddress(): Promise<string | undefined>;
16
19
  signMessage(messageToSign: string): Promise<string | undefined>;
@@ -1,7 +1,9 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
+ import { PublicKey } from '@solana/web3.js';
3
4
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
5
  import { isMobile, template } from '@dynamic-labs/utils';
6
+ import { SolanaUiTransaction } from '@dynamic-labs/solana-utils';
5
7
  import { SolProviderHelper } from '../solProviderHelper.js';
6
8
  import { SolWalletConnector } from '../solWalletConnector.js';
7
9
  import { SignMessageNotSupportedError } from '../errors/SignMessageNotSupportedError.js';
@@ -40,6 +42,34 @@ class InjectedWalletBase extends SolWalletConnector {
40
42
  return (_a = this.getSolProviderHelper()) === null || _a === void 0 ? void 0 : _a.connect();
41
43
  });
42
44
  }
45
+ createUiTransaction(from) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ return new SolanaUiTransaction({
48
+ connection: this.getWalletClient(),
49
+ from,
50
+ onSubmit: (transaction) => __awaiter(this, void 0, void 0, function* () {
51
+ var _a;
52
+ const signer = yield this.getSigner();
53
+ if (!signer)
54
+ throw new Error('Signer not found');
55
+ const blockhash = yield this.getWalletClient().getLatestBlockhash();
56
+ if ('version' in transaction) {
57
+ transaction.message.recentBlockhash =
58
+ blockhash.blockhash;
59
+ }
60
+ else {
61
+ const userAddress = yield this.getAddress();
62
+ if (!userAddress)
63
+ throw new Error('User address not found');
64
+ transaction.recentBlockhash = blockhash.blockhash;
65
+ transaction.feePayer =
66
+ (_a = transaction.feePayer) !== null && _a !== void 0 ? _a : new PublicKey(userAddress);
67
+ }
68
+ return (yield signer.signAndSendTransaction(transaction)).signature;
69
+ }),
70
+ });
71
+ });
72
+ }
43
73
  isInstalledOnBrowser() {
44
74
  var _a;
45
75
  return Boolean((_a = this.getSolProviderHelper()) === null || _a === void 0 ? void 0 : _a.isInstalledHelper());
@@ -50,7 +80,8 @@ class InjectedWalletBase extends SolWalletConnector {
50
80
  if (!this.isInstalledOnBrowser()) {
51
81
  if (isMobile() &&
52
82
  ((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) &&
53
- this.wallet.mobile.inAppBrowser) {
83
+ this.wallet.mobile.inAppBrowser &&
84
+ this.mobileExperience === 'in-app-browser') {
54
85
  const inAppBrowserCompiledTemplate = template(this.wallet.mobile.inAppBrowser);
55
86
  const deepLink = inAppBrowserCompiledTemplate({
56
87
  encodedDappURI: encodeURIComponent(window.location.toString()),