@dynamic-labs/solana-core 0.0.0-exp20240827.1

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 (59) hide show
  1. package/CHANGELOG.md +3952 -0
  2. package/LICENSE +21 -0
  3. package/README.md +11 -0
  4. package/_virtual/_tslib.cjs +36 -0
  5. package/_virtual/_tslib.js +32 -0
  6. package/package.json +41 -0
  7. package/src/connector/SolWalletConnector.cjs +175 -0
  8. package/src/connector/SolWalletConnector.d.ts +37 -0
  9. package/src/connector/SolWalletConnector.js +171 -0
  10. package/src/connector/index.d.ts +1 -0
  11. package/src/constants.cjs +8 -0
  12. package/src/constants.d.ts +1 -0
  13. package/src/constants.js +4 -0
  14. package/src/index.cjs +36 -0
  15. package/src/index.d.ts +6 -0
  16. package/src/index.js +13 -0
  17. package/src/rpc/RpcProviderSolana/RpcProviderSolana.cjs +29 -0
  18. package/src/rpc/RpcProviderSolana/RpcProviderSolana.d.ts +18 -0
  19. package/src/rpc/RpcProviderSolana/RpcProviderSolana.js +27 -0
  20. package/src/rpc/RpcProviderSolana/index.d.ts +1 -0
  21. package/src/rpc/index.d.ts +3 -0
  22. package/src/rpc/solanaProvidersSelector/index.d.ts +1 -0
  23. package/src/rpc/solanaProvidersSelector/solanaProvidersSelector.cjs +24 -0
  24. package/src/rpc/solanaProvidersSelector/solanaProvidersSelector.d.ts +7 -0
  25. package/src/rpc/solanaProvidersSelector/solanaProvidersSelector.js +20 -0
  26. package/src/types.d.ts +67 -0
  27. package/src/utils/SolanaUiTransaction/SolanaUiTransaction.cjs +153 -0
  28. package/src/utils/SolanaUiTransaction/SolanaUiTransaction.d.ts +40 -0
  29. package/src/utils/SolanaUiTransaction/SolanaUiTransaction.js +148 -0
  30. package/src/utils/SolanaUiTransaction/index.d.ts +1 -0
  31. package/src/utils/decodeTransactionFromBase64/decodeTransactionFromBase64.cjs +16 -0
  32. package/src/utils/decodeTransactionFromBase64/decodeTransactionFromBase64.d.ts +3 -0
  33. package/src/utils/decodeTransactionFromBase64/decodeTransactionFromBase64.js +12 -0
  34. package/src/utils/decodeTransactionFromBase64/index.d.ts +1 -0
  35. package/src/utils/encodeTransactionToBase64/encodeTransactionToBase64.cjs +15 -0
  36. package/src/utils/encodeTransactionToBase64/encodeTransactionToBase64.d.ts +6 -0
  37. package/src/utils/encodeTransactionToBase64/encodeTransactionToBase64.js +11 -0
  38. package/src/utils/encodeTransactionToBase64/index.d.ts +1 -0
  39. package/src/utils/extractNonce/extractNonce.cjs +14 -0
  40. package/src/utils/extractNonce/extractNonce.d.ts +1 -0
  41. package/src/utils/extractNonce/extractNonce.js +10 -0
  42. package/src/utils/extractNonce/index.d.ts +1 -0
  43. package/src/utils/getGenesisHashLSKey/getGenesisHashLSKey.cjs +10 -0
  44. package/src/utils/getGenesisHashLSKey/getGenesisHashLSKey.d.ts +1 -0
  45. package/src/utils/getGenesisHashLSKey/getGenesisHashLSKey.js +6 -0
  46. package/src/utils/getGenesisHashLSKey/index.d.ts +1 -0
  47. package/src/utils/index.d.ts +5 -0
  48. package/src/utils/isVersionedTransaction/index.d.ts +1 -0
  49. package/src/utils/isVersionedTransaction/isVersionedTransaction.cjs +8 -0
  50. package/src/utils/isVersionedTransaction/isVersionedTransaction.d.ts +2 -0
  51. package/src/utils/isVersionedTransaction/isVersionedTransaction.js +4 -0
  52. package/src/wallet/SolanaWallet.cjs +52 -0
  53. package/src/wallet/SolanaWallet.d.ts +17 -0
  54. package/src/wallet/SolanaWallet.js +48 -0
  55. package/src/wallet/index.d.ts +2 -0
  56. package/src/wallet/isSolanaWallet/index.d.ts +1 -0
  57. package/src/wallet/isSolanaWallet/isSolanaWallet.cjs +8 -0
  58. package/src/wallet/isSolanaWallet/isSolanaWallet.d.ts +3 -0
  59. package/src/wallet/isSolanaWallet/isSolanaWallet.js +4 -0
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isVersionedTransaction = (transaction) => 'version' in transaction;
7
+
8
+ exports.isVersionedTransaction = isVersionedTransaction;
@@ -0,0 +1,2 @@
1
+ import { Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ export declare const isVersionedTransaction: (transaction: Transaction | VersionedTransaction) => transaction is VersionedTransaction;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isVersionedTransaction = (transaction) => 'version' in transaction;
3
+
4
+ export { isVersionedTransaction };
@@ -0,0 +1,52 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../_virtual/_tslib.cjs');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+ var utils = require('@dynamic-labs/utils');
9
+
10
+ class SolanaWallet extends walletConnectorCore.Wallet {
11
+ /**
12
+ * Retrieves the RPC connection
13
+ * @returns A promise that resolves to the RPC connection
14
+ */
15
+ getConnection() {
16
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
17
+ return this._connector.getWalletClient();
18
+ });
19
+ }
20
+ /**
21
+ * Retrieves the solana signer for the wallet.
22
+ * @returns A promise that resolves to the signer,
23
+ * or throws an error if the signer cannot be retrieved.
24
+ */
25
+ getSigner() {
26
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
27
+ const signer = yield this._connector.getSigner();
28
+ if (!signer) {
29
+ throw new Error('unable to retrieve Solana signer');
30
+ }
31
+ utils.wrapMethodWithCallback(signer, 'signTransaction', (originalSignTransaction, transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
32
+ yield this.sync();
33
+ return originalSignTransaction(transaction);
34
+ }));
35
+ utils.wrapMethodWithCallback(signer, 'signAllTransactions', (originalSignAllTransactions, transactions) => _tslib.__awaiter(this, void 0, void 0, function* () {
36
+ yield this.sync();
37
+ return originalSignAllTransactions(transactions);
38
+ }));
39
+ utils.wrapMethodWithCallback(signer, 'signAndSendTransaction', (originalSignAndSendTransaction, transaction, ...args) => _tslib.__awaiter(this, void 0, void 0, function* () {
40
+ yield this.sync();
41
+ return originalSignAndSendTransaction(transaction, ...args);
42
+ }));
43
+ utils.wrapMethodWithCallback(signer, 'signMessage', (originalSignMessage, message, ...args) => _tslib.__awaiter(this, void 0, void 0, function* () {
44
+ yield this.sync();
45
+ return originalSignMessage(message, ...args);
46
+ }));
47
+ return signer;
48
+ });
49
+ }
50
+ }
51
+
52
+ exports.SolanaWallet = SolanaWallet;
@@ -0,0 +1,17 @@
1
+ import { Connection } from '@solana/web3.js';
2
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
3
+ import { SolWalletConnector } from '../connector';
4
+ import { ISolana } from '../types';
5
+ export declare class SolanaWallet extends Wallet<SolWalletConnector> {
6
+ /**
7
+ * Retrieves the RPC connection
8
+ * @returns A promise that resolves to the RPC connection
9
+ */
10
+ getConnection(): Promise<Connection>;
11
+ /**
12
+ * Retrieves the solana signer for the wallet.
13
+ * @returns A promise that resolves to the signer,
14
+ * or throws an error if the signer cannot be retrieved.
15
+ */
16
+ getSigner(): Promise<ISolana>;
17
+ }
@@ -0,0 +1,48 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../_virtual/_tslib.js';
3
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
4
+ import { wrapMethodWithCallback } from '@dynamic-labs/utils';
5
+
6
+ class SolanaWallet extends Wallet {
7
+ /**
8
+ * Retrieves the RPC connection
9
+ * @returns A promise that resolves to the RPC connection
10
+ */
11
+ getConnection() {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ return this._connector.getWalletClient();
14
+ });
15
+ }
16
+ /**
17
+ * Retrieves the solana signer for the wallet.
18
+ * @returns A promise that resolves to the signer,
19
+ * or throws an error if the signer cannot be retrieved.
20
+ */
21
+ getSigner() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const signer = yield this._connector.getSigner();
24
+ if (!signer) {
25
+ throw new Error('unable to retrieve Solana signer');
26
+ }
27
+ wrapMethodWithCallback(signer, 'signTransaction', (originalSignTransaction, transaction) => __awaiter(this, void 0, void 0, function* () {
28
+ yield this.sync();
29
+ return originalSignTransaction(transaction);
30
+ }));
31
+ wrapMethodWithCallback(signer, 'signAllTransactions', (originalSignAllTransactions, transactions) => __awaiter(this, void 0, void 0, function* () {
32
+ yield this.sync();
33
+ return originalSignAllTransactions(transactions);
34
+ }));
35
+ wrapMethodWithCallback(signer, 'signAndSendTransaction', (originalSignAndSendTransaction, transaction, ...args) => __awaiter(this, void 0, void 0, function* () {
36
+ yield this.sync();
37
+ return originalSignAndSendTransaction(transaction, ...args);
38
+ }));
39
+ wrapMethodWithCallback(signer, 'signMessage', (originalSignMessage, message, ...args) => __awaiter(this, void 0, void 0, function* () {
40
+ yield this.sync();
41
+ return originalSignMessage(message, ...args);
42
+ }));
43
+ return signer;
44
+ });
45
+ }
46
+ }
47
+
48
+ export { SolanaWallet };
@@ -0,0 +1,2 @@
1
+ export * from './SolanaWallet';
2
+ export * from './isSolanaWallet';
@@ -0,0 +1 @@
1
+ export * from './isSolanaWallet';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isSolanaWallet = (wallet) => wallet.chain === 'SOL';
7
+
8
+ exports.isSolanaWallet = isSolanaWallet;
@@ -0,0 +1,3 @@
1
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { SolanaWallet } from '../SolanaWallet';
3
+ export declare const isSolanaWallet: (wallet: Wallet) => wallet is SolanaWallet;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isSolanaWallet = (wallet) => wallet.chain === 'SOL';
3
+
4
+ export { isSolanaWallet };