@dynamic-labs/solana 4.0.0-alpha.45 → 4.0.0-alpha.46

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 (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/CoinbaseSolana/CoinbaseSolana.cjs +1 -1
  6. package/src/CoinbaseSolana/CoinbaseSolana.js +1 -1
  7. package/src/Phantom/Phantom.cjs +1 -1
  8. package/src/Phantom/Phantom.js +1 -1
  9. package/src/SolProviderHelper/SolProviderHelper.cjs +17 -7
  10. package/src/SolProviderHelper/SolProviderHelper.js +17 -7
  11. package/src/SolanaWalletConnectors.cjs +1 -1
  12. package/src/SolanaWalletConnectors.js +1 -1
  13. package/src/Solflare/Solflare.cjs +1 -1
  14. package/src/Solflare/Solflare.js +1 -1
  15. package/src/index.cjs +2 -2
  16. package/src/index.js +2 -2
  17. package/src/injected/{BackpackSol.cjs → BackpackSol/BackpackSol.cjs} +2 -2
  18. package/src/injected/{BackpackSol.d.ts → BackpackSol/BackpackSol.d.ts} +1 -1
  19. package/src/injected/{BackpackSol.js → BackpackSol/BackpackSol.js} +2 -2
  20. package/src/injected/BackpackSol/index.d.ts +1 -0
  21. package/src/injected/{FallbackSolanaConnector.cjs → FallbackSolanaConnector/FallbackSolanaConnector.cjs} +1 -1
  22. package/src/injected/{FallbackSolanaConnector.d.ts → FallbackSolanaConnector/FallbackSolanaConnector.d.ts} +1 -1
  23. package/src/injected/{FallbackSolanaConnector.js → FallbackSolanaConnector/FallbackSolanaConnector.js} +1 -1
  24. package/src/injected/FallbackSolanaConnector/index.d.ts +1 -0
  25. package/src/injected/{InjectedWalletBase.cjs → InjectedWalletBase/InjectedWalletBase.cjs} +3 -3
  26. package/src/injected/{InjectedWalletBase.d.ts → InjectedWalletBase/InjectedWalletBase.d.ts} +1 -1
  27. package/src/injected/{InjectedWalletBase.js → InjectedWalletBase/InjectedWalletBase.js} +3 -3
  28. package/src/injected/InjectedWalletBase/index.d.ts +1 -0
  29. package/src/injected/{PhantomInjected.cjs → PhantomInjected/PhantomInjected.cjs} +2 -2
  30. package/src/injected/{PhantomInjected.d.ts → PhantomInjected/PhantomInjected.d.ts} +1 -1
  31. package/src/injected/{PhantomInjected.js → PhantomInjected/PhantomInjected.js} +2 -2
  32. package/src/injected/PhantomInjected/index.d.ts +1 -0
  33. package/src/injected/fetchInjectedWalletConnectors.cjs +39 -20
  34. package/src/injected/fetchInjectedWalletConnectors.js +39 -20
  35. package/src/{SolanaWalletStandardConnector/utils → injected/walletStandard}/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs +70 -19
  36. package/src/injected/walletStandard/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +4 -0
  37. package/src/{SolanaWalletStandardConnector/utils → injected/walletStandard}/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js +70 -19
  38. package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.cjs +29 -0
  39. package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.d.ts +3 -0
  40. package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.js +25 -0
  41. package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/index.d.ts +1 -0
  42. package/src/injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.cjs +10 -0
  43. package/src/injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.d.ts +1 -0
  44. package/src/injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.js +6 -0
  45. package/src/injected/walletStandard/getWalletStandardWallets/index.d.ts +1 -0
  46. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs +0 -100
  47. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.d.ts +0 -20
  48. package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.js +0 -96
  49. package/src/SolanaWalletStandardConnector/index.d.ts +0 -1
  50. package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +0 -3
  51. /package/src/{SolanaWalletStandardConnector/utils → injected/walletStandard}/createSolanaSignerFromWalletStandard/index.d.ts +0 -0
  52. /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs +0 -0
  53. /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.d.ts +0 -0
  54. /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js +0 -0
  55. /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/index.d.ts +0 -0
@@ -6,10 +6,37 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../../../_virtual/_tslib.cjs');
7
7
  var web3_js = require('@solana/web3.js');
8
8
  var fetchCluster = require('../../../phantomRedirect/fetchCluster/fetchCluster.cjs');
9
+ var logger = require('../../../utils/logger.cjs');
9
10
 
10
11
  const isVersionedTransaction = (transaction) => !('instructions' in transaction);
11
12
  const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
12
13
  const features = wallet.features;
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ const connect = (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
16
+ var _a;
17
+ const connectMethod = (_a = features['standard:connect']) === null || _a === void 0 ? void 0 : _a.connect;
18
+ if (!connectMethod) {
19
+ logger.logger.error('connect - Not implemented');
20
+ return;
21
+ }
22
+ const result = yield connectMethod({ silent: false });
23
+ if (!result.accounts[0]) {
24
+ return;
25
+ }
26
+ return {
27
+ address: result.accounts[0].address,
28
+ publicKey: result.accounts[0].publicKey,
29
+ };
30
+ });
31
+ const disconnect = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
32
+ var _b;
33
+ const disconnectMethod = (_b = features['standard:disconnect']) === null || _b === void 0 ? void 0 : _b.disconnect;
34
+ if (!disconnectMethod) {
35
+ logger.logger.debug('disconnect - Not implemented');
36
+ return;
37
+ }
38
+ yield disconnectMethod();
39
+ });
13
40
  const getCurrentAccount = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
14
41
  const address = yield walletConnector.getAddress();
15
42
  const account = wallet.accounts.find((account) => account.address === address);
@@ -19,8 +46,8 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
19
46
  return account;
20
47
  });
21
48
  const getChain = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
22
- var _a, _b;
23
- const rpc = (_b = (_a = walletConnector.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : walletConnector.solNetworks[0].rpcUrls[0];
49
+ var _c, _d;
50
+ const rpc = (_d = (_c = walletConnector.solNetworks[0].privateCustomerRpcUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : walletConnector.solNetworks[0].rpcUrls[0];
24
51
  const cluster = yield fetchCluster.fetchCluster(rpc);
25
52
  return `solana:${cluster}`;
26
53
  });
@@ -57,19 +84,39 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
57
84
  });
58
85
  return { signature: messages[0].signature };
59
86
  });
87
+ const on = (event, listener) => {
88
+ var _a;
89
+ const onMethod = (_a = features['standard:events']) === null || _a === void 0 ? void 0 : _a.on;
90
+ if (!onMethod) {
91
+ logger.logger.error('on - Not implemented');
92
+ return;
93
+ }
94
+ if (event !== 'accountChanged') {
95
+ logger.logger.debug(`on - Not implemented for event: ${event}`);
96
+ return;
97
+ }
98
+ const wrappedListener = (prop) => {
99
+ var _a;
100
+ const publicKey = (_a = prop.accounts) === null || _a === void 0 ? void 0 : _a[0].publicKey;
101
+ if (publicKey) {
102
+ listener(new TextDecoder().decode(publicKey));
103
+ }
104
+ };
105
+ // 'change' is the only event that is supported by the wallet standard
106
+ return onMethod('change', wrappedListener);
107
+ };
60
108
  return {
61
109
  addListener: () => {
62
- throw new Error('Not implemented');
110
+ throw new Error('addListener - Not implemented');
63
111
  },
64
- connect: () => {
65
- throw new Error('Not implemented');
66
- },
67
- disconnect: () => walletConnector.endSession(),
112
+ connect,
113
+ disconnect,
68
114
  emit: () => {
69
- throw new Error('Not implemented');
115
+ throw new Error('emit - Not implemented');
70
116
  },
71
117
  eventNames: () => {
72
- throw new Error('Not implemented');
118
+ logger.logger.error('eventNames - Not implemented');
119
+ return [];
73
120
  },
74
121
  isBackpack: false,
75
122
  isBraveWallet: false,
@@ -80,32 +127,36 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
80
127
  isPhantom: false,
81
128
  isSolflare: false,
82
129
  listenerCount: () => {
83
- throw new Error('Not implemented');
130
+ logger.logger.error('listenerCount - Not implemented');
131
+ return 0;
84
132
  },
85
133
  listeners: () => {
86
- throw new Error('Not implemented');
134
+ logger.logger.error('listeners - Not implemented');
135
+ return [];
87
136
  },
88
137
  off: () => {
89
- throw new Error('Not implemented');
90
- },
91
- on: () => {
92
- throw new Error('Not implemented');
138
+ throw new Error('off - Not implemented');
93
139
  },
140
+ on,
94
141
  once: () => {
95
- throw new Error('Not implemented');
142
+ throw new Error('once - Not implemented');
96
143
  },
97
144
  providers: [],
98
145
  get publicKey() {
146
+ var _a;
147
+ if (!((_a = wallet.accounts) === null || _a === void 0 ? void 0 : _a[0].publicKey)) {
148
+ return undefined;
149
+ }
99
150
  return new web3_js.PublicKey(wallet.accounts[0].publicKey);
100
151
  },
101
152
  removeAllListeners: () => {
102
- throw new Error('Not implemented');
153
+ throw new Error('removeAllListeners - Not implemented');
103
154
  },
104
155
  removeListener: () => {
105
- throw new Error('Not implemented');
156
+ throw new Error('removeListener - Not implemented');
106
157
  },
107
158
  send: () => {
108
- throw new Error('Not implemented');
159
+ throw new Error('send - Not implemented');
109
160
  },
110
161
  signAllTransactions,
111
162
  signAndSendTransaction,
@@ -0,0 +1,4 @@
1
+ import { Wallet } from '@wallet-standard/base';
2
+ import { ISolana } from '@dynamic-labs/solana-core';
3
+ import { InjectedWalletBase } from '../../InjectedWalletBase';
4
+ export declare const createSolanaSignerFromWalletStandard: (wallet: Wallet, walletConnector: InjectedWalletBase) => ISolana;
@@ -2,10 +2,37 @@
2
2
  import { __awaiter } from '../../../../_virtual/_tslib.js';
3
3
  import { PublicKey, VersionedTransaction, Transaction } from '@solana/web3.js';
4
4
  import { fetchCluster } from '../../../phantomRedirect/fetchCluster/fetchCluster.js';
5
+ import { logger } from '../../../utils/logger.js';
5
6
 
6
7
  const isVersionedTransaction = (transaction) => !('instructions' in transaction);
7
8
  const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
8
9
  const features = wallet.features;
10
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+ const connect = (args) => __awaiter(void 0, void 0, void 0, function* () {
12
+ var _a;
13
+ const connectMethod = (_a = features['standard:connect']) === null || _a === void 0 ? void 0 : _a.connect;
14
+ if (!connectMethod) {
15
+ logger.error('connect - Not implemented');
16
+ return;
17
+ }
18
+ const result = yield connectMethod({ silent: false });
19
+ if (!result.accounts[0]) {
20
+ return;
21
+ }
22
+ return {
23
+ address: result.accounts[0].address,
24
+ publicKey: result.accounts[0].publicKey,
25
+ };
26
+ });
27
+ const disconnect = () => __awaiter(void 0, void 0, void 0, function* () {
28
+ var _b;
29
+ const disconnectMethod = (_b = features['standard:disconnect']) === null || _b === void 0 ? void 0 : _b.disconnect;
30
+ if (!disconnectMethod) {
31
+ logger.debug('disconnect - Not implemented');
32
+ return;
33
+ }
34
+ yield disconnectMethod();
35
+ });
9
36
  const getCurrentAccount = () => __awaiter(void 0, void 0, void 0, function* () {
10
37
  const address = yield walletConnector.getAddress();
11
38
  const account = wallet.accounts.find((account) => account.address === address);
@@ -15,8 +42,8 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
15
42
  return account;
16
43
  });
17
44
  const getChain = () => __awaiter(void 0, void 0, void 0, function* () {
18
- var _a, _b;
19
- const rpc = (_b = (_a = walletConnector.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : walletConnector.solNetworks[0].rpcUrls[0];
45
+ var _c, _d;
46
+ const rpc = (_d = (_c = walletConnector.solNetworks[0].privateCustomerRpcUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : walletConnector.solNetworks[0].rpcUrls[0];
20
47
  const cluster = yield fetchCluster(rpc);
21
48
  return `solana:${cluster}`;
22
49
  });
@@ -53,19 +80,39 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
53
80
  });
54
81
  return { signature: messages[0].signature };
55
82
  });
83
+ const on = (event, listener) => {
84
+ var _a;
85
+ const onMethod = (_a = features['standard:events']) === null || _a === void 0 ? void 0 : _a.on;
86
+ if (!onMethod) {
87
+ logger.error('on - Not implemented');
88
+ return;
89
+ }
90
+ if (event !== 'accountChanged') {
91
+ logger.debug(`on - Not implemented for event: ${event}`);
92
+ return;
93
+ }
94
+ const wrappedListener = (prop) => {
95
+ var _a;
96
+ const publicKey = (_a = prop.accounts) === null || _a === void 0 ? void 0 : _a[0].publicKey;
97
+ if (publicKey) {
98
+ listener(new TextDecoder().decode(publicKey));
99
+ }
100
+ };
101
+ // 'change' is the only event that is supported by the wallet standard
102
+ return onMethod('change', wrappedListener);
103
+ };
56
104
  return {
57
105
  addListener: () => {
58
- throw new Error('Not implemented');
106
+ throw new Error('addListener - Not implemented');
59
107
  },
60
- connect: () => {
61
- throw new Error('Not implemented');
62
- },
63
- disconnect: () => walletConnector.endSession(),
108
+ connect,
109
+ disconnect,
64
110
  emit: () => {
65
- throw new Error('Not implemented');
111
+ throw new Error('emit - Not implemented');
66
112
  },
67
113
  eventNames: () => {
68
- throw new Error('Not implemented');
114
+ logger.error('eventNames - Not implemented');
115
+ return [];
69
116
  },
70
117
  isBackpack: false,
71
118
  isBraveWallet: false,
@@ -76,32 +123,36 @@ const createSolanaSignerFromWalletStandard = (wallet, walletConnector) => {
76
123
  isPhantom: false,
77
124
  isSolflare: false,
78
125
  listenerCount: () => {
79
- throw new Error('Not implemented');
126
+ logger.error('listenerCount - Not implemented');
127
+ return 0;
80
128
  },
81
129
  listeners: () => {
82
- throw new Error('Not implemented');
130
+ logger.error('listeners - Not implemented');
131
+ return [];
83
132
  },
84
133
  off: () => {
85
- throw new Error('Not implemented');
86
- },
87
- on: () => {
88
- throw new Error('Not implemented');
134
+ throw new Error('off - Not implemented');
89
135
  },
136
+ on,
90
137
  once: () => {
91
- throw new Error('Not implemented');
138
+ throw new Error('once - Not implemented');
92
139
  },
93
140
  providers: [],
94
141
  get publicKey() {
142
+ var _a;
143
+ if (!((_a = wallet.accounts) === null || _a === void 0 ? void 0 : _a[0].publicKey)) {
144
+ return undefined;
145
+ }
95
146
  return new PublicKey(wallet.accounts[0].publicKey);
96
147
  },
97
148
  removeAllListeners: () => {
98
- throw new Error('Not implemented');
149
+ throw new Error('removeAllListeners - Not implemented');
99
150
  },
100
151
  removeListener: () => {
101
- throw new Error('Not implemented');
152
+ throw new Error('removeListener - Not implemented');
102
153
  },
103
154
  send: () => {
104
- throw new Error('Not implemented');
155
+ throw new Error('send - Not implemented');
105
156
  },
106
157
  signAllTransactions,
107
158
  signAndSendTransaction,
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var utils = require('@dynamic-labs/utils');
7
+ var InjectedWalletBase = require('../../InjectedWalletBase/InjectedWalletBase.cjs');
8
+ var createSolanaSignerFromWalletStandard = require('../createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs');
9
+
10
+ const getConnectorConstructorForWalletStandardWallet = (wallet) => {
11
+ const sanitizedName = utils.sanitizeName(wallet.name);
12
+ return class extends InjectedWalletBase.InjectedWalletBase {
13
+ constructor(props) {
14
+ super(Object.assign(Object.assign({}, props), { metadata: {
15
+ groupKey: sanitizedName,
16
+ icon: wallet.icon,
17
+ id: sanitizedName,
18
+ name: wallet.name,
19
+ } }));
20
+ this.name = wallet.name;
21
+ this.overrideKey = `${sanitizedName}sol`;
22
+ }
23
+ findProvider() {
24
+ return createSolanaSignerFromWalletStandard.createSolanaSignerFromWalletStandard(wallet, this);
25
+ }
26
+ };
27
+ };
28
+
29
+ exports.getConnectorConstructorForWalletStandardWallet = getConnectorConstructorForWalletStandardWallet;
@@ -0,0 +1,3 @@
1
+ import { Wallet } from '@wallet-standard/base';
2
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
3
+ export declare const getConnectorConstructorForWalletStandardWallet: (wallet: Wallet) => WalletConnectorConstructor;
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+ import { sanitizeName } from '@dynamic-labs/utils';
3
+ import { InjectedWalletBase } from '../../InjectedWalletBase/InjectedWalletBase.js';
4
+ import { createSolanaSignerFromWalletStandard } from '../createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js';
5
+
6
+ const getConnectorConstructorForWalletStandardWallet = (wallet) => {
7
+ const sanitizedName = sanitizeName(wallet.name);
8
+ return class extends InjectedWalletBase {
9
+ constructor(props) {
10
+ super(Object.assign(Object.assign({}, props), { metadata: {
11
+ groupKey: sanitizedName,
12
+ icon: wallet.icon,
13
+ id: sanitizedName,
14
+ name: wallet.name,
15
+ } }));
16
+ this.name = wallet.name;
17
+ this.overrideKey = `${sanitizedName}sol`;
18
+ }
19
+ findProvider() {
20
+ return createSolanaSignerFromWalletStandard(wallet, this);
21
+ }
22
+ };
23
+ };
24
+
25
+ export { getConnectorConstructorForWalletStandardWallet };
@@ -0,0 +1 @@
1
+ export { getConnectorConstructorForWalletStandardWallet } from './getConnectorConstructorForWalletStandardWallet';
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var app = require('@wallet-standard/app');
7
+
8
+ const getWalletStandardWallets = () => app.getWallets().get();
9
+
10
+ exports.getWalletStandardWallets = getWalletStandardWallets;
@@ -0,0 +1 @@
1
+ export declare const getWalletStandardWallets: () => readonly import("@wallet-standard/base").Wallet[];
@@ -0,0 +1,6 @@
1
+ 'use client'
2
+ import { getWallets } from '@wallet-standard/app';
3
+
4
+ const getWalletStandardWallets = () => getWallets().get();
5
+
6
+ export { getWalletStandardWallets };
@@ -0,0 +1 @@
1
+ export { getWalletStandardWallets } from './getWalletStandardWallets';
@@ -1,100 +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 app = require('@wallet-standard/app');
8
- var solanaCore = require('@dynamic-labs/solana-core');
9
- var createSolanaSignerFromWalletStandard = require('./utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs');
10
-
11
- const encoder = new TextEncoder();
12
- class SolanaWalletStandardConnector extends solanaCore.SolanaWalletConnector {
13
- constructor(props) {
14
- super(props);
15
- this.connectedChain = 'SOL';
16
- this.supportedChains = ['SOL'];
17
- }
18
- get wallet() {
19
- const walletStandard = SolanaWalletStandardConnector.getWallet(this.walletBook, this.key);
20
- if (!walletStandard) {
21
- throw new Error('Wallet not found');
22
- }
23
- return walletStandard;
24
- }
25
- get walletFeatures() {
26
- return this.wallet.features;
27
- }
28
- connect() {
29
- return _tslib.__awaiter(this, void 0, void 0, function* () {
30
- yield this.walletFeatures['standard:connect'].connect();
31
- });
32
- }
33
- endSession() {
34
- return _tslib.__awaiter(this, void 0, void 0, function* () {
35
- yield this.walletFeatures['standard:disconnect'].disconnect();
36
- });
37
- }
38
- isInstalledOnBrowser() {
39
- return true;
40
- }
41
- getAddress() {
42
- return _tslib.__awaiter(this, void 0, void 0, function* () {
43
- yield this.connect();
44
- const [address] = yield this.getConnectedAccounts();
45
- return address;
46
- });
47
- }
48
- getConnectedAccounts() {
49
- return _tslib.__awaiter(this, void 0, void 0, function* () {
50
- const addresses = this.wallet.accounts.map((account) => account.address);
51
- return addresses;
52
- });
53
- }
54
- signMessage(messageToSign) {
55
- return _tslib.__awaiter(this, void 0, void 0, function* () {
56
- const signer = yield this.getSigner();
57
- if (!signer) {
58
- throw new Error('Signer not found');
59
- }
60
- const message = encoder.encode(messageToSign);
61
- const { signature } = yield signer.signMessage(message);
62
- if (!(signature instanceof Uint8Array)) {
63
- throw new Error('Signature not found');
64
- }
65
- return Buffer.from(signature).toString('base64');
66
- });
67
- }
68
- getSigner() {
69
- return _tslib.__awaiter(this, void 0, void 0, function* () {
70
- const { wallet } = this;
71
- return createSolanaSignerFromWalletStandard.createSolanaSignerFromWalletStandard(wallet, this);
72
- });
73
- }
74
- static getWallet(walletBook, walletKey) {
75
- var _a, _b;
76
- const wallets = app.getWallets().get();
77
- const injectedConfig = (_a = walletBook.wallets[walletKey].injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sol');
78
- if (!injectedConfig)
79
- return;
80
- const { features } = (_b = injectedConfig.walletStandard) !== null && _b !== void 0 ? _b : {};
81
- if (!features)
82
- return;
83
- const wallet = wallets.find((wallet) => {
84
- var _a;
85
- const isNameMatch = wallet.name === ((_a = injectedConfig.walletStandard) === null || _a === void 0 ? void 0 : _a.name);
86
- if (!isNameMatch)
87
- return false;
88
- const hasFeatures = features.reduce((hasAllFeatures, key) => {
89
- const walletFeatures = Object.keys(wallet.features);
90
- if (!hasAllFeatures)
91
- return false;
92
- return walletFeatures.includes(key);
93
- }, true);
94
- return hasFeatures;
95
- });
96
- return wallet;
97
- }
98
- }
99
-
100
- exports.SolanaWalletStandardConnector = SolanaWalletStandardConnector;
@@ -1,20 +0,0 @@
1
- import { Wallet } from '@wallet-standard/base';
2
- import { StandardConnectFeature, StandardDisconnectFeature } from '@wallet-standard/features';
3
- import { Chain } from '@dynamic-labs/wallet-connector-core';
4
- import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
- import { SolanaWalletConnector, SolanaWalletConnectorOpts, type ISolana } from '@dynamic-labs/solana-core';
6
- export declare abstract class SolanaWalletStandardConnector extends SolanaWalletConnector {
7
- connectedChain: Chain;
8
- supportedChains: Chain[];
9
- constructor(props: SolanaWalletConnectorOpts);
10
- get wallet(): Wallet;
11
- get walletFeatures(): StandardConnectFeature & StandardDisconnectFeature;
12
- connect(): Promise<void>;
13
- endSession(): Promise<void>;
14
- isInstalledOnBrowser(): boolean;
15
- getAddress(): Promise<string | undefined>;
16
- getConnectedAccounts(): Promise<string[]>;
17
- signMessage(messageToSign: string): Promise<string | undefined>;
18
- getSigner(): Promise<ISolana | undefined>;
19
- static getWallet(walletBook: WalletBookSchema, walletKey: string): Wallet | undefined;
20
- }
@@ -1,96 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { getWallets } from '@wallet-standard/app';
4
- import { SolanaWalletConnector } from '@dynamic-labs/solana-core';
5
- import { createSolanaSignerFromWalletStandard } from './utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js';
6
-
7
- const encoder = new TextEncoder();
8
- class SolanaWalletStandardConnector extends SolanaWalletConnector {
9
- constructor(props) {
10
- super(props);
11
- this.connectedChain = 'SOL';
12
- this.supportedChains = ['SOL'];
13
- }
14
- get wallet() {
15
- const walletStandard = SolanaWalletStandardConnector.getWallet(this.walletBook, this.key);
16
- if (!walletStandard) {
17
- throw new Error('Wallet not found');
18
- }
19
- return walletStandard;
20
- }
21
- get walletFeatures() {
22
- return this.wallet.features;
23
- }
24
- connect() {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- yield this.walletFeatures['standard:connect'].connect();
27
- });
28
- }
29
- endSession() {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- yield this.walletFeatures['standard:disconnect'].disconnect();
32
- });
33
- }
34
- isInstalledOnBrowser() {
35
- return true;
36
- }
37
- getAddress() {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- yield this.connect();
40
- const [address] = yield this.getConnectedAccounts();
41
- return address;
42
- });
43
- }
44
- getConnectedAccounts() {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const addresses = this.wallet.accounts.map((account) => account.address);
47
- return addresses;
48
- });
49
- }
50
- signMessage(messageToSign) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const signer = yield this.getSigner();
53
- if (!signer) {
54
- throw new Error('Signer not found');
55
- }
56
- const message = encoder.encode(messageToSign);
57
- const { signature } = yield signer.signMessage(message);
58
- if (!(signature instanceof Uint8Array)) {
59
- throw new Error('Signature not found');
60
- }
61
- return Buffer.from(signature).toString('base64');
62
- });
63
- }
64
- getSigner() {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const { wallet } = this;
67
- return createSolanaSignerFromWalletStandard(wallet, this);
68
- });
69
- }
70
- static getWallet(walletBook, walletKey) {
71
- var _a, _b;
72
- const wallets = getWallets().get();
73
- const injectedConfig = (_a = walletBook.wallets[walletKey].injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sol');
74
- if (!injectedConfig)
75
- return;
76
- const { features } = (_b = injectedConfig.walletStandard) !== null && _b !== void 0 ? _b : {};
77
- if (!features)
78
- return;
79
- const wallet = wallets.find((wallet) => {
80
- var _a;
81
- const isNameMatch = wallet.name === ((_a = injectedConfig.walletStandard) === null || _a === void 0 ? void 0 : _a.name);
82
- if (!isNameMatch)
83
- return false;
84
- const hasFeatures = features.reduce((hasAllFeatures, key) => {
85
- const walletFeatures = Object.keys(wallet.features);
86
- if (!hasAllFeatures)
87
- return false;
88
- return walletFeatures.includes(key);
89
- }, true);
90
- return hasFeatures;
91
- });
92
- return wallet;
93
- }
94
- }
95
-
96
- export { SolanaWalletStandardConnector };
@@ -1 +0,0 @@
1
- export { SolanaWalletStandardConnector } from './SolanaWalletStandardConnector';
@@ -1,3 +0,0 @@
1
- import { Wallet } from '@wallet-standard/base';
2
- import { ISolana, SolanaWalletConnector } from '@dynamic-labs/solana-core';
3
- export declare const createSolanaSignerFromWalletStandard: (wallet: Wallet, walletConnector: SolanaWalletConnector) => ISolana;