@dynamic-labs/solana 1.0.2 → 1.0.3

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,19 @@
1
1
 
2
+ ### [1.0.3](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.2...v1.0.3) (2023-12-28)
3
+
4
+
5
+ ### Features
6
+
7
+ * add default footer to wallet list when tos and pp not enabled ([#4229](https://github.com/dynamic-labs/DynamicAuth/issues/4229)) ([a6d90a7](https://github.com/dynamic-labs/DynamicAuth/commit/a6d90a7276cafeaffcb21c5362837d020fc10215)), closes [#4224](https://github.com/dynamic-labs/DynamicAuth/issues/4224)
8
+ * add starknet support for sopelia ([#4268](https://github.com/dynamic-labs/DynamicAuth/issues/4268)) ([53d4ce4](https://github.com/dynamic-labs/DynamicAuth/commit/53d4ce400070adfb32021b01b9c748b9a7d90577))
9
+ * delay setting user to after pregenerated wallet flow ([#4244](https://github.com/dynamic-labs/DynamicAuth/issues/4244)) ([503d34d](https://github.com/dynamic-labs/DynamicAuth/commit/503d34d9d6f5edd55b009f1f63c049ac6dfb1fb7))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * coinbase solana signMessage ([#4261](https://github.com/dynamic-labs/DynamicAuth/issues/4261)) ([7e0e69c](https://github.com/dynamic-labs/DynamicAuth/commit/7e0e69c0ad9f9c9778ff9255909dd2314e16fa06))
15
+ * solflare connect ([#4215](https://github.com/dynamic-labs/DynamicAuth/issues/4215)) ([#4219](https://github.com/dynamic-labs/DynamicAuth/issues/4219)) ([df39306](https://github.com/dynamic-labs/DynamicAuth/commit/df393069b9a9859052b2d55db8dfc3399d85f2a9))
16
+
2
17
  ### [1.0.2](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.1...v1.0.2) (2023-12-18)
3
18
 
4
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@solana/web3.js": "1.70.1",
30
- "@dynamic-labs/rpc-providers": "1.0.2",
31
- "@dynamic-labs/types": "1.0.2",
32
- "@dynamic-labs/utils": "1.0.2",
33
- "@dynamic-labs/wallet-book": "1.0.2",
34
- "@dynamic-labs/wallet-connector-core": "1.0.2",
30
+ "@dynamic-labs/rpc-providers": "1.0.3",
31
+ "@dynamic-labs/types": "1.0.3",
32
+ "@dynamic-labs/utils": "1.0.3",
33
+ "@dynamic-labs/wallet-book": "1.0.3",
34
+ "@dynamic-labs/wallet-connector-core": "1.0.3",
35
35
  "eventemitter3": "5.0.1"
36
36
  },
37
37
  "peerDependencies": {}
@@ -3,8 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../_virtual/_tslib.cjs');
6
+ var utils = require('@dynamic-labs/utils');
6
7
  var solWalletConnector = require('./solWalletConnector.cjs');
7
8
  var solProviderHelper = require('./solProviderHelper.cjs');
9
+ require('@solana/web3.js');
10
+ require('@dynamic-labs/wallet-connector-core');
11
+ require('./injected/PhantomLedger.cjs');
12
+ var isSignedMessage = require('./utils/isSignedMessage.cjs');
8
13
 
9
14
  class CoinbaseSolana extends solWalletConnector.SolWalletConnector {
10
15
  constructor() {
@@ -40,7 +45,20 @@ class CoinbaseSolana extends solWalletConnector.SolWalletConnector {
40
45
  }
41
46
  signMessage(messageToSign) {
42
47
  return _tslib.__awaiter(this, void 0, void 0, function* () {
43
- return solProviderHelper.SolProviderHelper.signMessageWithName(messageToSign, this.name);
48
+ const walletAddress = yield this.fetchPublicAddress();
49
+ if (!walletAddress) {
50
+ return undefined;
51
+ }
52
+ const provider = yield this.getSigner();
53
+ if (!provider) {
54
+ return undefined;
55
+ }
56
+ const encodedMessage = new TextEncoder().encode(messageToSign);
57
+ const signedMessage = yield provider.signMessage(encodedMessage, walletAddress);
58
+ if (!signedMessage) {
59
+ return undefined;
60
+ }
61
+ return utils.bufferToBase64(isSignedMessage.isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
44
62
  });
45
63
  }
46
64
  getConnectedAccounts() {
@@ -1,11 +1,11 @@
1
1
  import { SolWalletConnector } from './solWalletConnector';
2
- import { ISolana } from './types';
2
+ import { ICoinbaseSolanaSigner } from './types';
3
3
  export declare class CoinbaseSolana extends SolWalletConnector {
4
4
  name: string;
5
5
  setupEventListeners(): void;
6
6
  teardownEventListeners(): void;
7
7
  connect(): Promise<void>;
8
- getSigner(): Promise<ISolana | undefined>;
8
+ getSigner(): Promise<ICoinbaseSolanaSigner | undefined>;
9
9
  isInstalledOnBrowser(): boolean;
10
10
  fetchPublicAddress(): Promise<string | undefined>;
11
11
  signMessage(messageToSign: string): Promise<string | undefined>;
@@ -1,6 +1,11 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
+ import { bufferToBase64 } from '@dynamic-labs/utils';
2
3
  import { SolWalletConnector } from './solWalletConnector.js';
3
4
  import { SolProviderHelper } from './solProviderHelper.js';
5
+ import '@solana/web3.js';
6
+ import '@dynamic-labs/wallet-connector-core';
7
+ import './injected/PhantomLedger.js';
8
+ import { isSignedMessage } from './utils/isSignedMessage.js';
4
9
 
5
10
  class CoinbaseSolana extends SolWalletConnector {
6
11
  constructor() {
@@ -36,7 +41,20 @@ class CoinbaseSolana extends SolWalletConnector {
36
41
  }
37
42
  signMessage(messageToSign) {
38
43
  return __awaiter(this, void 0, void 0, function* () {
39
- return SolProviderHelper.signMessageWithName(messageToSign, this.name);
44
+ const walletAddress = yield this.fetchPublicAddress();
45
+ if (!walletAddress) {
46
+ return undefined;
47
+ }
48
+ const provider = yield this.getSigner();
49
+ if (!provider) {
50
+ return undefined;
51
+ }
52
+ const encodedMessage = new TextEncoder().encode(messageToSign);
53
+ const signedMessage = yield provider.signMessage(encodedMessage, walletAddress);
54
+ if (!signedMessage) {
55
+ return undefined;
56
+ }
57
+ return bufferToBase64(isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
40
58
  });
41
59
  }
42
60
  getConnectedAccounts() {
package/src/Solflare.cjs CHANGED
@@ -17,7 +17,11 @@ class Solflare extends solWalletConnector.SolWalletConnector {
17
17
  }
18
18
  fetchPublicAddress() {
19
19
  return _tslib.__awaiter(this, void 0, void 0, function* () {
20
- if (utils.isMobile()) {
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()) {
21
25
  const url = encodeURIComponent(window.location.toString());
22
26
  const ref = encodeURIComponent(window.location.origin);
23
27
  if (utils.isSamsungBrowser()) {
package/src/Solflare.js CHANGED
@@ -13,7 +13,11 @@ class Solflare extends SolWalletConnector {
13
13
  }
14
14
  fetchPublicAddress() {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
- if (isMobile()) {
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()) {
17
21
  const url = encodeURIComponent(window.location.toString());
18
22
  const ref = encodeURIComponent(window.location.origin);
19
23
  if (isSamsungBrowser()) {
package/src/index.d.ts CHANGED
@@ -4,4 +4,4 @@ export * from './Solflare';
4
4
  export declare const SolanaWalletConnectors: (props: any) => typeof import("./injected/BraveSol").BraveSol[];
5
5
  export { isSignedMessage } from './utils/isSignedMessage';
6
6
  export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
7
- export type { ISolana, IBackpackSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
7
+ export type { ISolana, IBackpackSolanaSigner, ICoinbaseSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
package/src/types.d.ts CHANGED
@@ -9,7 +9,7 @@ declare global {
9
9
  Slope?: {
10
10
  new (): ISolana;
11
11
  };
12
- coinbaseSolana?: ISolana;
12
+ coinbaseSolana?: ICoinbaseSolanaSigner;
13
13
  glowSolana?: ISolana;
14
14
  phantom?: IWindowPhantom;
15
15
  solana?: ISolana;
@@ -59,7 +59,10 @@ export type IBackpackSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
59
59
  signMessage: (message: Uint8Array, encoding?: string) => Promise<void | Uint8Array>;
60
60
  send: (transaction: Transaction, signers?: Signer[], options?: SendOptions, connection?: Connection, publicKey?: PublicKey) => Promise<TransactionSignature>;
61
61
  };
62
- export type ISolana = ISolanaSigner | IBackpackSolanaSigner;
62
+ export type ICoinbaseSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
63
+ signMessage: (message: Uint8Array, publicKey?: string) => Promise<void | Uint8Array>;
64
+ };
65
+ export type ISolana = ISolanaSigner | IBackpackSolanaSigner | ICoinbaseSolanaSigner;
63
66
  export type ProviderFlag = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare' | 'isExodus' | 'isBackpack' | 'isMagicEden';
64
67
  export type EthProviderCondition = ProviderCondition<ProviderFlag>;
65
68
  export {};