@dynamic-labs/solana 3.0.0-alpha.52 → 3.0.0-alpha.53

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/package.json +9 -10
  3. package/src/CoinbaseSolana.cjs +1 -1
  4. package/src/CoinbaseSolana.d.ts +1 -1
  5. package/src/CoinbaseSolana.js +1 -1
  6. package/src/Phantom.cjs +2 -2
  7. package/src/Phantom.d.ts +1 -2
  8. package/src/Phantom.js +1 -1
  9. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs +2 -2
  10. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.d.ts +1 -2
  11. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.js +1 -1
  12. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs +1 -1
  13. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +1 -2
  14. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js +1 -1
  15. package/src/Solflare.d.ts +1 -1
  16. package/src/index.cjs +5 -0
  17. package/src/index.d.ts +1 -1
  18. package/src/index.js +1 -0
  19. package/src/injected/BackpackSol.d.ts +1 -1
  20. package/src/injected/FallbackSolanaConnector.d.ts +1 -1
  21. package/src/injected/InjectedWalletBase.cjs +2 -2
  22. package/src/injected/InjectedWalletBase.d.ts +1 -2
  23. package/src/injected/InjectedWalletBase.js +2 -2
  24. package/src/injected/PhantomInjected.d.ts +1 -1
  25. package/src/injected/UnknownInjected.d.ts +1 -1
  26. package/src/phantomRedirect/PhantomRedirect.cjs +3 -3
  27. package/src/phantomRedirect/PhantomRedirect.d.ts +1 -2
  28. package/src/phantomRedirect/PhantomRedirect.js +2 -2
  29. package/src/solProviderHelper.d.ts +2 -2
  30. package/src/utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.d.ts +1 -1
  31. package/src/utils/isBackpackSolanaSigner.d.ts +1 -1
  32. package/src/utils/isSignedMessage.d.ts +1 -1
  33. package/src/contants.cjs +0 -8
  34. package/src/contants.d.ts +0 -1
  35. package/src/contants.js +0 -4
  36. package/src/solWalletConnector.cjs +0 -172
  37. package/src/solWalletConnector.d.ts +0 -35
  38. package/src/solWalletConnector.js +0 -168
  39. package/src/types.d.ts +0 -68
  40. package/src/utils/extractNonce.cjs +0 -14
  41. package/src/utils/extractNonce.d.ts +0 -1
  42. package/src/utils/extractNonce.js +0 -10
  43. package/src/utils/getGenesisHashLSKey.cjs +0 -10
  44. package/src/utils/getGenesisHashLSKey.d.ts +0 -1
  45. package/src/utils/getGenesisHashLSKey.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,4 +1,43 @@
1
1
 
2
+ ## [3.0.0-alpha.53](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.52...v3.0.0-alpha.53) (2024-08-29)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * simplify solana wallet signer types (#6748)
8
+ * deprecate getEoaConnector (#6571)
9
+ * limit methods and props returned by wallet.connector (#6540)
10
+ * move generic solana code to solana-core package (#6701)
11
+ * revamp ether v6 interface (#6548)
12
+ * add ethereum wallet specific methods and intercept to sync when needed (#6662)
13
+ * add solana wallet specific methods and intercept to sync when needed (#6608)
14
+ * don't force primary wallet to be connected (#6128)
15
+
16
+ ### Features
17
+
18
+ * add bitcoin wallet specific methods and intercept to sync when needed ([#6663](https://github.com/dynamic-labs/DynamicAuth/issues/6663)) ([ed699b1](https://github.com/dynamic-labs/DynamicAuth/commit/ed699b1f8c264755779ec4840d105f89ade5500e))
19
+ * add ethereum wallet specific methods and intercept to sync when needed ([#6662](https://github.com/dynamic-labs/DynamicAuth/issues/6662)) ([372360e](https://github.com/dynamic-labs/DynamicAuth/commit/372360ed7ca395f88811fc62c94b2b494eb59971))
20
+ * add solana wallet specific methods and intercept to sync when needed ([#6608](https://github.com/dynamic-labs/DynamicAuth/issues/6608)) ([565f610](https://github.com/dynamic-labs/DynamicAuth/commit/565f6100340296c267e9706fd263e9bd3f7d3732))
21
+ * add useSmartWallets hook to manage aa wallets ([#6564](https://github.com/dynamic-labs/DynamicAuth/issues/6564)) ([a243d36](https://github.com/dynamic-labs/DynamicAuth/commit/a243d361ce7c368d0f1afda55f9c1fabefd75ba8))
22
+ * don't force primary wallet to be connected ([#6128](https://github.com/dynamic-labs/DynamicAuth/issues/6128)) ([018a6f6](https://github.com/dynamic-labs/DynamicAuth/commit/018a6f66f8725914ab97ea3e2e1c80626266e503))
23
+ * new prop to enable prompt for linking when account change is detected ([#6713](https://github.com/dynamic-labs/DynamicAuth/issues/6713)) ([b5a6321](https://github.com/dynamic-labs/DynamicAuth/commit/b5a63212ae33fae24401f141d5ca2356b446dcff))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * always sync wagmi client with primary wallet ([#6577](https://github.com/dynamic-labs/DynamicAuth/issues/6577)) ([be22fde](https://github.com/dynamic-labs/DynamicAuth/commit/be22fdea3bb61db79b06ba56cb32da6cd8141b66))
29
+ * cosmos wallet intercepts ([#6720](https://github.com/dynamic-labs/DynamicAuth/issues/6720)) ([cfc9df4](https://github.com/dynamic-labs/DynamicAuth/commit/cfc9df48a8032f7348fec14f77b9e378d2e26a22))
30
+ * magiceden wallet events not working correctly on page refresh ([#6735](https://github.com/dynamic-labs/DynamicAuth/issues/6735)) ([6ed5964](https://github.com/dynamic-labs/DynamicAuth/commit/6ed5964134a2cafd392c19f18eb71e6ca2ce238d))
31
+ * use proxy to intercept solana signer methods ([#6743](https://github.com/dynamic-labs/DynamicAuth/issues/6743)) ([ecbe5ea](https://github.com/dynamic-labs/DynamicAuth/commit/ecbe5ea772592d2c693d8222d85b7642acd151a8))
32
+ * wallet.chain references ([525c1ca](https://github.com/dynamic-labs/DynamicAuth/commit/525c1ca9a8fe6402c06eabe6aebc30e310411d9b))
33
+
34
+
35
+ * deprecate getEoaConnector ([#6571](https://github.com/dynamic-labs/DynamicAuth/issues/6571)) ([0226ee5](https://github.com/dynamic-labs/DynamicAuth/commit/0226ee5a13f2418607076ee6f2ec0a579b06dd5d))
36
+ * limit methods and props returned by wallet.connector ([#6540](https://github.com/dynamic-labs/DynamicAuth/issues/6540)) ([9c86e35](https://github.com/dynamic-labs/DynamicAuth/commit/9c86e35c72cd40313bfd19254dd6171ee8f62213))
37
+ * move generic solana code to solana-core package ([#6701](https://github.com/dynamic-labs/DynamicAuth/issues/6701)) ([30815f5](https://github.com/dynamic-labs/DynamicAuth/commit/30815f5d46feeefb2413c1b7d30b43d5370ee032))
38
+ * revamp ether v6 interface ([#6548](https://github.com/dynamic-labs/DynamicAuth/issues/6548)) ([f3b2fb8](https://github.com/dynamic-labs/DynamicAuth/commit/f3b2fb8da7de21f9c58e67fa7f5580166195092a))
39
+ * simplify solana wallet signer types ([#6748](https://github.com/dynamic-labs/DynamicAuth/issues/6748)) ([01d1a42](https://github.com/dynamic-labs/DynamicAuth/commit/01d1a42bc916ab329580b741ba60d706bf6c5491))
40
+
2
41
  ## [3.0.0-alpha.52](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.51...v3.0.0-alpha.52) (2024-08-28)
3
42
 
4
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/solana",
3
- "version": "3.0.0-alpha.52",
3
+ "version": "3.0.0-alpha.53",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -27,21 +27,20 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@solana/web3.js": "1.92.1",
30
- "@dynamic-labs/sdk-api-core": "0.0.519",
31
30
  "@wallet-standard/app": "1.0.1",
32
31
  "@wallet-standard/base": "1.0.1",
33
32
  "@wallet-standard/features": "1.0.3",
34
33
  "@wallet-standard/experimental-features": "0.1.1",
35
34
  "bs58": "5.0.0",
36
35
  "tweetnacl": "1.0.3",
37
- "@dynamic-labs/embedded-wallet-solana": "3.0.0-alpha.52",
38
- "@dynamic-labs/rpc-providers": "3.0.0-alpha.52",
39
- "@dynamic-labs/solana-core": "3.0.0-alpha.52",
40
- "@dynamic-labs/types": "3.0.0-alpha.52",
41
- "@dynamic-labs/utils": "3.0.0-alpha.52",
42
- "@dynamic-labs/wallet-book": "3.0.0-alpha.52",
43
- "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.52",
44
- "eventemitter3": "5.0.1"
36
+ "@dynamic-labs/embedded-wallet-solana": "3.0.0-alpha.53",
37
+ "@dynamic-labs/rpc-providers": "3.0.0-alpha.53",
38
+ "@dynamic-labs/sdk-api-core": "0.0.519",
39
+ "@dynamic-labs/solana-core": "3.0.0-alpha.53",
40
+ "@dynamic-labs/types": "3.0.0-alpha.53",
41
+ "@dynamic-labs/utils": "3.0.0-alpha.53",
42
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.53",
43
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.53"
45
44
  },
46
45
  "peerDependencies": {}
47
46
  }
@@ -7,7 +7,7 @@ var _tslib = require('../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
8
  var walletBook = require('@dynamic-labs/wallet-book');
9
9
  require('@dynamic-labs/embedded-wallet-solana');
10
- require('./solWalletConnector.cjs');
10
+ require('@dynamic-labs/solana-core');
11
11
  require('tweetnacl');
12
12
  require('bs58');
13
13
  require('@solana/web3.js');
@@ -1,4 +1,4 @@
1
- import { SolWalletConnectorOpts } from './solWalletConnector';
1
+ import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
2
  import { InjectedWalletBase } from './injected/InjectedWalletBase';
3
3
  export declare class CoinbaseSolana extends InjectedWalletBase {
4
4
  name: string;
@@ -3,7 +3,7 @@ import { __awaiter } from '../_virtual/_tslib.js';
3
3
  import { bufferToBase64 } from '@dynamic-labs/utils';
4
4
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
5
  import '@dynamic-labs/embedded-wallet-solana';
6
- import './solWalletConnector.js';
6
+ import '@dynamic-labs/solana-core';
7
7
  import 'tweetnacl';
8
8
  import 'bs58';
9
9
  import '@solana/web3.js';
package/src/Phantom.cjs CHANGED
@@ -6,11 +6,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../_virtual/_tslib.cjs');
7
7
  var walletBook = require('@dynamic-labs/wallet-book');
8
8
  var utils = require('@dynamic-labs/utils');
9
- var solWalletConnector = require('./solWalletConnector.cjs');
9
+ var solanaCore = require('@dynamic-labs/solana-core');
10
10
  var PhantomRedirect = require('./phantomRedirect/PhantomRedirect.cjs');
11
11
  var PhantomInjected = require('./injected/PhantomInjected.cjs');
12
12
 
13
- class Phantom extends solWalletConnector.SolWalletConnector {
13
+ class Phantom extends solanaCore.SolWalletConnector {
14
14
  constructor(opts) {
15
15
  super(opts);
16
16
  this.name = 'Phantom';
package/src/Phantom.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { WalletSchema } from '@dynamic-labs/wallet-book';
2
2
  import { WalletConnectorCore } from '@dynamic-labs/wallet-connector-core';
3
- import { ISolana } from '..';
4
- import { SolWalletConnector, SolWalletConnectorOpts } from './solWalletConnector';
3
+ import { SolWalletConnector, SolWalletConnectorOpts, type ISolana } from '@dynamic-labs/solana-core';
5
4
  export declare class Phantom extends SolWalletConnector {
6
5
  name: string;
7
6
  overrideKey: string;
package/src/Phantom.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { __awaiter } from '../_virtual/_tslib.js';
3
3
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
4
  import { isMobile } from '@dynamic-labs/utils';
5
- import { SolWalletConnector } from './solWalletConnector.js';
5
+ import { SolWalletConnector } from '@dynamic-labs/solana-core';
6
6
  import { PhantomRedirect } from './phantomRedirect/PhantomRedirect.js';
7
7
  import { PhantomInjected } from './injected/PhantomInjected.js';
8
8
 
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var app = require('@wallet-standard/app');
8
- var solWalletConnector = require('../solWalletConnector.cjs');
8
+ var solanaCore = require('@dynamic-labs/solana-core');
9
9
  var createSolanaSignerFromWalletStandard = require('./utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs');
10
10
 
11
11
  const encoder = new TextEncoder();
12
- class SolanaWalletStandardConnector extends solWalletConnector.SolWalletConnector {
12
+ class SolanaWalletStandardConnector extends solanaCore.SolWalletConnector {
13
13
  constructor(props) {
14
14
  super(props);
15
15
  this.connectedChain = 'SOL';
@@ -2,8 +2,7 @@ import { Wallet } from '@wallet-standard/base';
2
2
  import { StandardConnectFeature, StandardDisconnectFeature } from '@wallet-standard/features';
3
3
  import { Chain } from '@dynamic-labs/wallet-connector-core';
4
4
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
- import { SolWalletConnector, SolWalletConnectorOpts } from './../solWalletConnector';
6
- import { ISolana } from './../types';
5
+ import { SolWalletConnector, SolWalletConnectorOpts, type ISolana } from '@dynamic-labs/solana-core';
7
6
  export declare abstract class SolanaWalletStandardConnector extends SolWalletConnector {
8
7
  connectedChain: Chain;
9
8
  supportedChains: Chain[];
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { getWallets } from '@wallet-standard/app';
4
- import { SolWalletConnector } from '../solWalletConnector.js';
4
+ import { SolWalletConnector } from '@dynamic-labs/solana-core';
5
5
  import { createSolanaSignerFromWalletStandard } from './utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js';
6
6
 
7
7
  const encoder = new TextEncoder();
@@ -55,7 +55,7 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
55
55
  account,
56
56
  message,
57
57
  });
58
- return messages[0].signature;
58
+ return { signature: messages[0].signature };
59
59
  });
60
60
  return {
61
61
  addListener: () => {
@@ -1,4 +1,3 @@
1
1
  import { Wallet } from '@wallet-standard/base';
2
- import { ISolana } from '../../../types';
3
- import { SolWalletConnector } from '../../../solWalletConnector';
2
+ import { SolWalletConnector, ISolana } from '@dynamic-labs/solana-core';
4
3
  export declare const createSolanaSignerFromWalletStandard: (wallet: Wallet, walletConnector: SolWalletConnector) => ISolana;
@@ -51,7 +51,7 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
51
51
  account,
52
52
  message,
53
53
  });
54
- return messages[0].signature;
54
+ return { signature: messages[0].signature };
55
55
  });
56
56
  return {
57
57
  addListener: () => {
package/src/Solflare.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
1
2
  import { InjectedWalletBase } from './injected/InjectedWalletBase';
2
- import { SolWalletConnectorOpts } from './solWalletConnector';
3
3
  export declare class Solflare extends InjectedWalletBase {
4
4
  name: string;
5
5
  overrideKey: string;
package/src/index.cjs CHANGED
@@ -10,6 +10,7 @@ var UnknownInjected = require('./injected/UnknownInjected.cjs');
10
10
  var FallbackSolanaConnector = require('./injected/FallbackSolanaConnector.cjs');
11
11
  var isSignedMessage = require('./utils/isSignedMessage.cjs');
12
12
  var isBackpackSolanaSigner = require('./utils/isBackpackSolanaSigner.cjs');
13
+ var solanaCore = require('@dynamic-labs/solana-core');
13
14
 
14
15
  /* eslint-disable @typescript-eslint/no-unused-vars */
15
16
  const SolanaWalletConnectors = (props) => [
@@ -23,4 +24,8 @@ const SolanaWalletConnectors = (props) => [
23
24
 
24
25
  exports.isSignedMessage = isSignedMessage.isSignedMessage;
25
26
  exports.isBackpackSolanaSigner = isBackpackSolanaSigner.isBackpackSolanaSigner;
27
+ Object.defineProperty(exports, 'isSolanaWallet', {
28
+ enumerable: true,
29
+ get: function () { return solanaCore.isSolanaWallet; }
30
+ });
26
31
  exports.SolanaWalletConnectors = SolanaWalletConnectors;
package/src/index.d.ts CHANGED
@@ -2,5 +2,5 @@ import { Phantom } from './Phantom';
2
2
  export declare const SolanaWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof Phantom)[];
3
3
  export { isSignedMessage } from './utils/isSignedMessage';
4
4
  export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
5
- export type { ISolana, IBackpackSolanaSigner, ICoinbaseSolanaSigner, SignedMessage, ISolanaSigner, } from './types';
6
5
  export type { IEmbeddedWalletSolanaSigner } from '@dynamic-labs/embedded-wallet-solana';
6
+ export { isSolanaWallet } from '@dynamic-labs/solana-core';
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ import { UnknownInjected } from './injected/UnknownInjected.js';
6
6
  import { FallbackSolanaConnector } from './injected/FallbackSolanaConnector.js';
7
7
  export { isSignedMessage } from './utils/isSignedMessage.js';
8
8
  export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner.js';
9
+ export { isSolanaWallet } from '@dynamic-labs/solana-core';
9
10
 
10
11
  /* eslint-disable @typescript-eslint/no-unused-vars */
11
12
  const SolanaWalletConnectors = (props) => [
@@ -1,4 +1,4 @@
1
- import { SolWalletConnectorOpts } from '../solWalletConnector';
1
+ import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
2
  import { InjectedWalletBase } from './InjectedWalletBase';
3
3
  export declare class BackpackSol extends InjectedWalletBase {
4
4
  name: string;
@@ -1,4 +1,4 @@
1
- import { SolWalletConnectorOpts } from '../solWalletConnector';
1
+ import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
2
  import { InjectedWalletBase } from './InjectedWalletBase';
3
3
  export declare class FallbackSolanaConnector extends InjectedWalletBase {
4
4
  name: string;
@@ -9,10 +9,9 @@ var walletBook = require('@dynamic-labs/wallet-book');
9
9
  var utils = require('@dynamic-labs/utils');
10
10
  var solanaCore = require('@dynamic-labs/solana-core');
11
11
  var solProviderHelper = require('../solProviderHelper.cjs');
12
- var solWalletConnector = require('../solWalletConnector.cjs');
13
12
  var SignMessageNotSupportedError = require('../errors/SignMessageNotSupportedError.cjs');
14
13
 
15
- class InjectedWalletBase extends solWalletConnector.SolWalletConnector {
14
+ class InjectedWalletBase extends solanaCore.SolWalletConnector {
16
15
  getSolProviderHelper() {
17
16
  if (!this.wallet) {
18
17
  this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
@@ -48,6 +47,7 @@ class InjectedWalletBase extends solWalletConnector.SolWalletConnector {
48
47
  }
49
48
  createUiTransaction(from) {
50
49
  return _tslib.__awaiter(this, void 0, void 0, function* () {
50
+ yield this.validateActiveWallet(from);
51
51
  const transaction = new solanaCore.SolanaUiTransaction({
52
52
  connection: this.getWalletClient(),
53
53
  from,
@@ -1,9 +1,8 @@
1
1
  import { WalletSchema } from '@dynamic-labs/wallet-book';
2
+ import { SolWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
2
3
  import { IUITransaction } from '@dynamic-labs/types';
3
4
  import { ISendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
4
- import { ISolana } from '../types';
5
5
  import { SolProviderHelper } from '../solProviderHelper';
6
- import { SolWalletConnector } from '../solWalletConnector';
7
6
  export declare abstract class InjectedWalletBase extends SolWalletConnector implements ISendBalanceWalletConnector {
8
7
  solProviderHelper: SolProviderHelper | undefined;
9
8
  wallet: WalletSchema | undefined;
@@ -3,9 +3,8 @@ import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { PublicKey } from '@solana/web3.js';
4
4
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
5
  import { isMobile, template } from '@dynamic-labs/utils';
6
- import { SolanaUiTransaction } from '@dynamic-labs/solana-core';
6
+ import { SolWalletConnector, SolanaUiTransaction } from '@dynamic-labs/solana-core';
7
7
  import { SolProviderHelper } from '../solProviderHelper.js';
8
- import { SolWalletConnector } from '../solWalletConnector.js';
9
8
  import { SignMessageNotSupportedError } from '../errors/SignMessageNotSupportedError.js';
10
9
 
11
10
  class InjectedWalletBase extends SolWalletConnector {
@@ -44,6 +43,7 @@ class InjectedWalletBase extends SolWalletConnector {
44
43
  }
45
44
  createUiTransaction(from) {
46
45
  return __awaiter(this, void 0, void 0, function* () {
46
+ yield this.validateActiveWallet(from);
47
47
  const transaction = new SolanaUiTransaction({
48
48
  connection: this.getWalletClient(),
49
49
  from,
@@ -1,4 +1,4 @@
1
- import { SolWalletConnectorOpts } from '../solWalletConnector';
1
+ import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
2
  import { InjectedWalletBase } from './InjectedWalletBase';
3
3
  export declare class PhantomInjected extends InjectedWalletBase {
4
4
  name: string;
@@ -1,4 +1,4 @@
1
- import { SolWalletConnectorOpts } from '../solWalletConnector';
1
+ import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
2
2
  import { InjectedWalletBase } from './InjectedWalletBase';
3
3
  export declare class UnknownInjected extends InjectedWalletBase {
4
4
  name: string;
@@ -7,7 +7,7 @@ var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var nacl = require('tweetnacl');
8
8
  var bs58 = require('bs58');
9
9
  var web3_js = require('@solana/web3.js');
10
- var solWalletConnector = require('../solWalletConnector.cjs');
10
+ var solanaCore = require('@dynamic-labs/solana-core');
11
11
  var utils = require('./utils.cjs');
12
12
  var storage = require('./storage.cjs');
13
13
 
@@ -16,7 +16,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
16
16
  var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
17
17
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
18
18
 
19
- class PhantomRedirect extends solWalletConnector.SolWalletConnector {
19
+ class PhantomRedirect extends solanaCore.SolWalletConnector {
20
20
  constructor(props) {
21
21
  super(Object.assign({}, props));
22
22
  this.name = 'Phantom';
@@ -248,7 +248,7 @@ class PhantomRedirect extends solWalletConnector.SolWalletConnector {
248
248
  const url = utils.buildUrl('signMessage', params);
249
249
  window.location.href = url;
250
250
  // actual signature will be retrived upon redirect back to dapp
251
- return Buffer.from('');
251
+ return { signature: Buffer.from('') };
252
252
  }),
253
253
  signTransaction: (transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
254
254
  const serializedTransaction = bs58__default["default"].encode(transaction.serialize({
@@ -1,7 +1,6 @@
1
1
  import { Transaction } from '@solana/web3.js';
2
2
  import { IPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
3
- import { SolWalletConnector } from '../solWalletConnector';
4
- import { ISolana } from '..';
3
+ import { SolWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
5
4
  import { Method } from './types';
6
5
  export declare class PhantomRedirect extends SolWalletConnector implements IPhantomRedirectConnector {
7
6
  name: string;
@@ -3,7 +3,7 @@ import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import nacl from 'tweetnacl';
4
4
  import bs58 from 'bs58';
5
5
  import { PublicKey, Transaction } from '@solana/web3.js';
6
- import { SolWalletConnector } from '../solWalletConnector.js';
6
+ import { SolWalletConnector } from '@dynamic-labs/solana-core';
7
7
  import { fetchCluster, buildUrl, decryptPayload, encryptPayload } from './utils.js';
8
8
  import { storage, clearStorage } from './storage.js';
9
9
 
@@ -239,7 +239,7 @@ class PhantomRedirect extends SolWalletConnector {
239
239
  const url = buildUrl('signMessage', params);
240
240
  window.location.href = url;
241
241
  // actual signature will be retrived upon redirect back to dapp
242
- return Buffer.from('');
242
+ return { signature: Buffer.from('') };
243
243
  }),
244
244
  signTransaction: (transaction) => __awaiter(this, void 0, void 0, function* () {
245
245
  const serializedTransaction = bs58.encode(transaction.serialize({
@@ -1,6 +1,6 @@
1
1
  import { WalletSchema } from '@dynamic-labs/wallet-book';
2
2
  import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
- import { ISolana, ExtensionLocator as ExtensionLocator } from './types';
3
+ import { ISolana, ExtensionLocator as ExtensionLocator } from '@dynamic-labs/solana-core';
4
4
  export declare class SolProviderHelper {
5
5
  private wallet;
6
6
  constructor(wallet: WalletSchema);
@@ -22,7 +22,7 @@ export declare class SolProviderHelper {
22
22
  windowLocations?: string[] | undefined;
23
23
  } | undefined;
24
24
  getInstalledProvider(): ISolana | undefined;
25
- installedProviders(): (import("./types").ISolanaSigner | import("./types").IBackpackSolanaSigner | import("./types").ICoinbaseSolanaSigner)[];
25
+ installedProviders(): import("@dynamic-labs/solana-core").ISolanaSigner[];
26
26
  installedProviderLookup(extensionLocators: Array<ProviderCondition<ExtensionLocator>>): ISolana | undefined;
27
27
  findProvider(): ISolana | undefined;
28
28
  isInstalledHelper(): boolean;
@@ -1,3 +1,3 @@
1
1
  import { WalletSchema } from '@dynamic-labs/wallet-book';
2
- import { ISolana } from '../../types';
2
+ import { ISolana } from '@dynamic-labs/solana-core';
3
3
  export declare const findWalletProviderFromWalletStandard: (injectConfig: NonNullable<WalletSchema['injectedConfig']>[number]) => ISolana | undefined;
@@ -1,2 +1,2 @@
1
- import { IBackpackSolanaSigner, ISolana } from '../types';
1
+ import { IBackpackSolanaSigner, ISolana } from '@dynamic-labs/solana-core';
2
2
  export declare const isBackpackSolanaSigner: (signer: ISolana) => signer is IBackpackSolanaSigner;
@@ -1,2 +1,2 @@
1
- import { SignedMessage } from '../types';
1
+ import { SignedMessage } from '@dynamic-labs/solana-core';
2
2
  export declare const isSignedMessage: (message: SignedMessage | Uint8Array) => message is SignedMessage;
package/src/contants.cjs DELETED
@@ -1,8 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- const SOLANA_GENESIS_HASH = 'genesis-hash';
7
-
8
- exports.SOLANA_GENESIS_HASH = SOLANA_GENESIS_HASH;
package/src/contants.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const SOLANA_GENESIS_HASH = "genesis-hash";
package/src/contants.js DELETED
@@ -1,4 +0,0 @@
1
- 'use client'
2
- const SOLANA_GENESIS_HASH = 'genesis-hash';
3
-
4
- export { SOLANA_GENESIS_HASH };
@@ -1,172 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../_virtual/_tslib.cjs');
7
- var web3_js = require('@solana/web3.js');
8
- var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
- var utils = require('@dynamic-labs/utils');
10
- var walletBook = require('@dynamic-labs/wallet-book');
11
- var extractNonce = require('./utils/extractNonce.cjs');
12
- var getGenesisHashLSKey = require('./utils/getGenesisHashLSKey.cjs');
13
-
14
- const MEMO_PROGRAM_ID = new web3_js.PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
15
- class SolWalletConnector extends walletConnectorCore.WalletConnectorBase {
16
- constructor(opts) {
17
- var _a;
18
- super(opts);
19
- this.isHardwareWalletEnabled = false;
20
- this.verifiedCredentials = [];
21
- this.supportedChains = ['SOL'];
22
- this.connectedChain = 'SOL';
23
- this.solNetworks = opts.solNetworks;
24
- this.chainRpcProviders = opts.chainRpcProviders;
25
- (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerSolanaProviders();
26
- }
27
- getNetwork() {
28
- return _tslib.__awaiter(this, void 0, void 0, function* () {
29
- const provider = this.getWalletClient();
30
- let genesisHash = localStorage.getItem(getGenesisHashLSKey.getGenesisHashLSKey(provider.rpcEndpoint));
31
- if (!genesisHash) {
32
- genesisHash = yield provider.getGenesisHash();
33
- localStorage.setItem(getGenesisHashLSKey.getGenesisHashLSKey(provider.rpcEndpoint), genesisHash);
34
- }
35
- genesisHash = genesisHash.substring(0, 32);
36
- // see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
37
- let network;
38
- if (genesisHash === '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp') {
39
- network = 'mainnet';
40
- }
41
- else if (genesisHash === 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1') {
42
- network = 'devnet';
43
- }
44
- else {
45
- network = 'testnet';
46
- }
47
- return network;
48
- });
49
- }
50
- endSession() {
51
- return _tslib.__awaiter(this, void 0, void 0, function* () {
52
- localStorage.removeItem(getGenesisHashLSKey.getGenesisHashLSKey(this.getWalletClient().rpcEndpoint));
53
- });
54
- }
55
- getWalletClient() {
56
- var _a;
57
- const [network] = this.solNetworks;
58
- if (!network) {
59
- throw new utils.DynamicError('No enabled networks');
60
- }
61
- const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
62
- return new web3_js.Connection(rpcUrl, 'confirmed');
63
- }
64
- getPublicClient() {
65
- return _tslib.__awaiter(this, void 0, void 0, function* () {
66
- var _a;
67
- if (this.solNetworks.length === 0)
68
- return;
69
- const configurations = {
70
- cosmos: [],
71
- evm: undefined,
72
- solana: this.solNetworks,
73
- starknet: undefined,
74
- };
75
- if (!this.chainRpcProviders)
76
- return undefined;
77
- const providers = this.chainRpcProviders.getProviders(configurations);
78
- return (_a = this.chainRpcProviders.getSolanaProviderByChainId(providers, '101')) === null || _a === void 0 ? void 0 : _a.provider;
79
- });
80
- }
81
- getBalance(address) {
82
- return _tslib.__awaiter(this, void 0, void 0, function* () {
83
- const publicKey = new web3_js.PublicKey(address);
84
- const balance = this.lamportsToSol(yield this.getWalletClient().getBalance(publicKey));
85
- return balance.toString();
86
- });
87
- }
88
- // Solana uses lamports as the smallest unit of currency. This converts lamports to SOL.
89
- lamportsToSol(lamports) {
90
- return lamports / 1000000000;
91
- }
92
- canConnectWithHardwareWallet() {
93
- const wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
94
- if (!wallet || !wallet.hardwareWallets)
95
- return false;
96
- return wallet.hardwareWallets.includes('ledger');
97
- }
98
- signMessage(messageToSign) {
99
- const _super = Object.create(null, {
100
- signMessage: { get: () => super.signMessage }
101
- });
102
- return _tslib.__awaiter(this, void 0, void 0, function* () {
103
- if (this.isHardwareWalletEnabled) {
104
- throw new utils.NotSupportedError(`Message signing is currently not supported on ${this.name} hardware wallet.
105
- You can use signMessageViaTransaction instead to achieve similar functionality
106
- by signing a transaction with a memo instruction.
107
- You can read more about it here https://github.com/solana-labs/solana/issues/21366`);
108
- }
109
- return _super.signMessage.call(this, messageToSign);
110
- });
111
- }
112
- proveOwnership(messageToSign) {
113
- const _super = Object.create(null, {
114
- proveOwnership: { get: () => super.proveOwnership }
115
- });
116
- return _tslib.__awaiter(this, void 0, void 0, function* () {
117
- if (this.isHardwareWalletEnabled) {
118
- const nonce = extractNonce.extractNonce(messageToSign);
119
- if (!nonce) {
120
- throw new utils.DynamicError('Nonce missing');
121
- }
122
- return this.signMessageViaTransaction(nonce);
123
- }
124
- return _super.proveOwnership.call(this, messageToSign);
125
- });
126
- }
127
- signMessageViaTransaction(messageToSign) {
128
- return _tslib.__awaiter(this, void 0, void 0, function* () {
129
- const address = yield this.getAddress();
130
- if (!address) {
131
- throw new utils.DynamicError('Address missing');
132
- }
133
- const transaction = this.buildAuthTx(messageToSign);
134
- transaction.feePayer = new web3_js.PublicKey(address);
135
- transaction.recentBlockhash = (yield this.getWalletClient().getLatestBlockhash()).blockhash;
136
- const signer = yield this.getSigner();
137
- if (!signer) {
138
- throw new utils.DynamicError('Signer not found');
139
- }
140
- const signedTransaction = yield signer.signTransaction(transaction);
141
- const serializedSignedTransaction = signedTransaction.serialize();
142
- /**
143
- * Serializing the transaction and adding the type 'Buffer' is required
144
- * when connecting with backpack + Ledger, because the returned object is not correctly
145
- * serialized
146
- */
147
- return JSON.stringify({
148
- signedTransaction: {
149
- data: Array.from(serializedSignedTransaction),
150
- type: 'Buffer',
151
- },
152
- });
153
- });
154
- }
155
- buildAuthTx(message) {
156
- const transaction = new web3_js.Transaction();
157
- transaction.add(new web3_js.TransactionInstruction({
158
- data: Buffer.from(message, 'utf8'),
159
- keys: [],
160
- programId: MEMO_PROGRAM_ID,
161
- }));
162
- return transaction;
163
- }
164
- setVerifiedCredentials(verifiedCredentials) {
165
- this.verifiedCredentials = verifiedCredentials;
166
- }
167
- isLedgerAddress(address) {
168
- return utils.isLedgerAddressViaVerifiedCredentials(address, this.verifiedCredentials);
169
- }
170
- }
171
-
172
- exports.SolWalletConnector = SolWalletConnector;
@@ -1,35 +0,0 @@
1
- import { Connection } from '@solana/web3.js';
2
- import { IChainRpcProviders } from '@dynamic-labs/solana-core';
3
- import { Chain, IHardwareWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
4
- import { GenericNetwork } from '@dynamic-labs/types';
5
- import { WalletBookSchema } from '@dynamic-labs/wallet-book';
6
- import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
7
- import { ISolana } from './types';
8
- export type SolWalletConnectorOpts = {
9
- chainRpcProviders: IChainRpcProviders;
10
- solNetworks: GenericNetwork[];
11
- walletBook: WalletBookSchema;
12
- };
13
- export declare abstract class SolWalletConnector extends WalletConnectorBase implements IHardwareWalletConnector {
14
- isHardwareWalletEnabled: boolean;
15
- verifiedCredentials: JwtVerifiedCredential[];
16
- solNetworks: GenericNetwork[];
17
- supportedChains: Chain[];
18
- connectedChain: Chain;
19
- constructor(opts: SolWalletConnectorOpts);
20
- getNetwork(): Promise<string>;
21
- endSession(): Promise<void>;
22
- getWalletClient(): Connection;
23
- getPublicClient(): Promise<Connection | undefined>;
24
- abstract getSigner(): Promise<ISolana | undefined>;
25
- abstract connect(): Promise<void>;
26
- getBalance(address: string): Promise<string | undefined>;
27
- lamportsToSol(lamports: number): number;
28
- canConnectWithHardwareWallet(): boolean;
29
- signMessage(messageToSign: string): Promise<string | undefined>;
30
- proveOwnership(messageToSign: string): Promise<string | undefined>;
31
- signMessageViaTransaction(messageToSign: string): Promise<string>;
32
- private buildAuthTx;
33
- setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
34
- isLedgerAddress(address: string): boolean;
35
- }
@@ -1,168 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../_virtual/_tslib.js';
3
- import { PublicKey, Connection, Transaction, TransactionInstruction } from '@solana/web3.js';
4
- import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
5
- import { DynamicError, NotSupportedError, isLedgerAddressViaVerifiedCredentials } from '@dynamic-labs/utils';
6
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
7
- import { extractNonce } from './utils/extractNonce.js';
8
- import { getGenesisHashLSKey } from './utils/getGenesisHashLSKey.js';
9
-
10
- const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
11
- class SolWalletConnector extends WalletConnectorBase {
12
- constructor(opts) {
13
- var _a;
14
- super(opts);
15
- this.isHardwareWalletEnabled = false;
16
- this.verifiedCredentials = [];
17
- this.supportedChains = ['SOL'];
18
- this.connectedChain = 'SOL';
19
- this.solNetworks = opts.solNetworks;
20
- this.chainRpcProviders = opts.chainRpcProviders;
21
- (_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerSolanaProviders();
22
- }
23
- getNetwork() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const provider = this.getWalletClient();
26
- let genesisHash = localStorage.getItem(getGenesisHashLSKey(provider.rpcEndpoint));
27
- if (!genesisHash) {
28
- genesisHash = yield provider.getGenesisHash();
29
- localStorage.setItem(getGenesisHashLSKey(provider.rpcEndpoint), genesisHash);
30
- }
31
- genesisHash = genesisHash.substring(0, 32);
32
- // see: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
33
- let network;
34
- if (genesisHash === '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp') {
35
- network = 'mainnet';
36
- }
37
- else if (genesisHash === 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1') {
38
- network = 'devnet';
39
- }
40
- else {
41
- network = 'testnet';
42
- }
43
- return network;
44
- });
45
- }
46
- endSession() {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- localStorage.removeItem(getGenesisHashLSKey(this.getWalletClient().rpcEndpoint));
49
- });
50
- }
51
- getWalletClient() {
52
- var _a;
53
- const [network] = this.solNetworks;
54
- if (!network) {
55
- throw new DynamicError('No enabled networks');
56
- }
57
- const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
58
- return new Connection(rpcUrl, 'confirmed');
59
- }
60
- getPublicClient() {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- var _a;
63
- if (this.solNetworks.length === 0)
64
- return;
65
- const configurations = {
66
- cosmos: [],
67
- evm: undefined,
68
- solana: this.solNetworks,
69
- starknet: undefined,
70
- };
71
- if (!this.chainRpcProviders)
72
- return undefined;
73
- const providers = this.chainRpcProviders.getProviders(configurations);
74
- return (_a = this.chainRpcProviders.getSolanaProviderByChainId(providers, '101')) === null || _a === void 0 ? void 0 : _a.provider;
75
- });
76
- }
77
- getBalance(address) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const publicKey = new PublicKey(address);
80
- const balance = this.lamportsToSol(yield this.getWalletClient().getBalance(publicKey));
81
- return balance.toString();
82
- });
83
- }
84
- // Solana uses lamports as the smallest unit of currency. This converts lamports to SOL.
85
- lamportsToSol(lamports) {
86
- return lamports / 1000000000;
87
- }
88
- canConnectWithHardwareWallet() {
89
- const wallet = findWalletBookWallet(this.walletBook, this.key);
90
- if (!wallet || !wallet.hardwareWallets)
91
- return false;
92
- return wallet.hardwareWallets.includes('ledger');
93
- }
94
- signMessage(messageToSign) {
95
- const _super = Object.create(null, {
96
- signMessage: { get: () => super.signMessage }
97
- });
98
- return __awaiter(this, void 0, void 0, function* () {
99
- if (this.isHardwareWalletEnabled) {
100
- throw new NotSupportedError(`Message signing is currently not supported on ${this.name} hardware wallet.
101
- You can use signMessageViaTransaction instead to achieve similar functionality
102
- by signing a transaction with a memo instruction.
103
- You can read more about it here https://github.com/solana-labs/solana/issues/21366`);
104
- }
105
- return _super.signMessage.call(this, messageToSign);
106
- });
107
- }
108
- proveOwnership(messageToSign) {
109
- const _super = Object.create(null, {
110
- proveOwnership: { get: () => super.proveOwnership }
111
- });
112
- return __awaiter(this, void 0, void 0, function* () {
113
- if (this.isHardwareWalletEnabled) {
114
- const nonce = extractNonce(messageToSign);
115
- if (!nonce) {
116
- throw new DynamicError('Nonce missing');
117
- }
118
- return this.signMessageViaTransaction(nonce);
119
- }
120
- return _super.proveOwnership.call(this, messageToSign);
121
- });
122
- }
123
- signMessageViaTransaction(messageToSign) {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- const address = yield this.getAddress();
126
- if (!address) {
127
- throw new DynamicError('Address missing');
128
- }
129
- const transaction = this.buildAuthTx(messageToSign);
130
- transaction.feePayer = new PublicKey(address);
131
- transaction.recentBlockhash = (yield this.getWalletClient().getLatestBlockhash()).blockhash;
132
- const signer = yield this.getSigner();
133
- if (!signer) {
134
- throw new DynamicError('Signer not found');
135
- }
136
- const signedTransaction = yield signer.signTransaction(transaction);
137
- const serializedSignedTransaction = signedTransaction.serialize();
138
- /**
139
- * Serializing the transaction and adding the type 'Buffer' is required
140
- * when connecting with backpack + Ledger, because the returned object is not correctly
141
- * serialized
142
- */
143
- return JSON.stringify({
144
- signedTransaction: {
145
- data: Array.from(serializedSignedTransaction),
146
- type: 'Buffer',
147
- },
148
- });
149
- });
150
- }
151
- buildAuthTx(message) {
152
- const transaction = new Transaction();
153
- transaction.add(new TransactionInstruction({
154
- data: Buffer.from(message, 'utf8'),
155
- keys: [],
156
- programId: MEMO_PROGRAM_ID,
157
- }));
158
- return transaction;
159
- }
160
- setVerifiedCredentials(verifiedCredentials) {
161
- this.verifiedCredentials = verifiedCredentials;
162
- }
163
- isLedgerAddress(address) {
164
- return isLedgerAddressViaVerifiedCredentials(address, this.verifiedCredentials);
165
- }
166
- }
167
-
168
- export { SolWalletConnector };
package/src/types.d.ts DELETED
@@ -1,68 +0,0 @@
1
- import { Connection, SendOptions, Signer, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
2
- import EventEmitter from 'eventemitter3';
3
- import { ProviderCondition } from '@dynamic-labs/wallet-connector-core';
4
- declare global {
5
- interface IWindowPhantom {
6
- solana: ISolana;
7
- }
8
- interface Window {
9
- coinbaseSolana?: ICoinbaseSolanaSigner;
10
- glowSolana?: ISolana;
11
- phantom?: IWindowPhantom;
12
- solana?: ISolana;
13
- solflare?: ISolana;
14
- backpack?: IBackpackSolanaSigner;
15
- magicEden?: {
16
- solana: ISolana;
17
- };
18
- }
19
- }
20
- type PublicKey = {
21
- toString: () => string;
22
- };
23
- export type ConnectionResult = {
24
- address?: string;
25
- publicKey?: PublicKey;
26
- } | undefined;
27
- interface ISolanaEvents {
28
- connect(...args: unknown[]): unknown;
29
- disconnect(...args: unknown[]): unknown;
30
- accountChanged(publicKey: string): unknown;
31
- activeWalletDidChange(publicKey: string): unknown;
32
- }
33
- export type SignedMessage = {
34
- signature: Uint8Array;
35
- };
36
- export type ISolanaSigner = {
37
- [key in ExtensionLocator]: boolean;
38
- } & EventEmitter<ISolanaEvents> & {
39
- publicKey?: {
40
- toBytes(): Uint8Array;
41
- };
42
- isConnected: boolean;
43
- providers: ISolanaSigner[];
44
- signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
45
- signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
46
- signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
47
- signature: TransactionSignature;
48
- }>;
49
- signMessage(message: Uint8Array, encoding?: string): Promise<SignedMessage>;
50
- connect: (args?: {
51
- onlyIfTrusted: boolean;
52
- }) => Promise<ConnectionResult>;
53
- disconnect(): Promise<void>;
54
- };
55
- type BackpackSolanaSignerResponse = {
56
- signature: Uint8Array;
57
- };
58
- export type IBackpackSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
59
- signMessage: (message: Uint8Array, encoding?: string) => Promise<void | BackpackSolanaSignerResponse | Uint8Array>;
60
- send: (transaction: Transaction, signers?: Signer[], options?: SendOptions, connection?: Connection, publicKey?: PublicKey) => Promise<TransactionSignature>;
61
- };
62
- export type ICoinbaseSolanaSigner = Omit<ISolanaSigner, 'signMessage'> & {
63
- signMessage: (message: Uint8Array, publicKey?: string) => Promise<void | Uint8Array>;
64
- };
65
- export type ISolana = ISolanaSigner | IBackpackSolanaSigner | ICoinbaseSolanaSigner;
66
- export type ExtensionLocator = 'isBraveWallet' | 'isGlow' | 'isPhantom' | 'isSolflare' | 'isExodus' | 'isBackpack' | 'isMagicEden';
67
- export type EthProviderCondition = ProviderCondition<ExtensionLocator>;
68
- export {};
@@ -1,14 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- const extractNonce = (messageToSign) => {
7
- const regex = messageToSign.match(/Nonce: (.*)/);
8
- if (regex && regex.length === 2) {
9
- return regex[1];
10
- }
11
- return undefined;
12
- };
13
-
14
- exports.extractNonce = extractNonce;
@@ -1 +0,0 @@
1
- export declare const extractNonce: (messageToSign: string) => string | undefined;
@@ -1,10 +0,0 @@
1
- 'use client'
2
- const extractNonce = (messageToSign) => {
3
- const regex = messageToSign.match(/Nonce: (.*)/);
4
- if (regex && regex.length === 2) {
5
- return regex[1];
6
- }
7
- return undefined;
8
- };
9
-
10
- export { extractNonce };
@@ -1,10 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var contants = require('../contants.cjs');
7
-
8
- const getGenesisHashLSKey = (rpcEndpoint) => `${rpcEndpoint}_${contants.SOLANA_GENESIS_HASH}`;
9
-
10
- exports.getGenesisHashLSKey = getGenesisHashLSKey;
@@ -1 +0,0 @@
1
- export declare const getGenesisHashLSKey: (rpcEndpoint: string) => string;
@@ -1,6 +0,0 @@
1
- 'use client'
2
- import { SOLANA_GENESIS_HASH } from '../contants.js';
3
-
4
- const getGenesisHashLSKey = (rpcEndpoint) => `${rpcEndpoint}_${SOLANA_GENESIS_HASH}`;
5
-
6
- export { getGenesisHashLSKey };