@meshconnect/web-link-sdk 3.2.15 → 3.2.16

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 (101) hide show
  1. package/Link.d.ts +2 -0
  2. package/Link.js +530 -0
  3. package/index.d.ts +3 -0
  4. package/index.js +3 -0
  5. package/package.json +8 -20
  6. package/utils/connectors/evm/chainConfigs.d.ts +2 -0
  7. package/utils/connectors/evm/chainConfigs.js +115 -0
  8. package/utils/connectors/evm/chainSwitching.d.ts +15 -0
  9. package/utils/connectors/evm/chainSwitching.js +242 -0
  10. package/utils/connectors/evm/index.d.ts +8 -0
  11. package/utils/connectors/evm/index.js +8 -0
  12. package/utils/connectors/evm/provider.d.ts +6 -0
  13. package/utils/connectors/evm/provider.js +13 -0
  14. package/utils/connectors/evm/signing.d.ts +1 -0
  15. package/utils/connectors/evm/signing.js +78 -0
  16. package/utils/connectors/evm/transactions.d.ts +28 -0
  17. package/utils/connectors/evm/transactions.js +381 -0
  18. package/utils/connectors/evm/types.d.ts +57 -0
  19. package/utils/connectors/evm/types.js +1 -0
  20. package/utils/connectors/evm/walletConnection.d.ts +20 -0
  21. package/utils/connectors/evm/walletConnection.js +160 -0
  22. package/utils/connectors/evm/walletDiscovery.d.ts +10 -0
  23. package/utils/connectors/evm/walletDiscovery.js +55 -0
  24. package/utils/connectors/solana/connection.d.ts +4 -0
  25. package/utils/connectors/solana/connection.js +108 -0
  26. package/utils/connectors/solana/index.d.ts +5 -0
  27. package/utils/connectors/solana/index.js +5 -0
  28. package/utils/connectors/solana/providerDiscovery.d.ts +3 -0
  29. package/utils/connectors/solana/providerDiscovery.js +127 -0
  30. package/utils/connectors/solana/signing.d.ts +1 -0
  31. package/utils/connectors/solana/signing.js +59 -0
  32. package/utils/connectors/solana/transaction.d.ts +17 -0
  33. package/utils/connectors/solana/transaction.js +362 -0
  34. package/utils/connectors/solana/types.d.ts +71 -0
  35. package/utils/connectors/solana/types.js +8 -0
  36. package/utils/event-types.d.ts +233 -0
  37. package/{src/utils/event-types.test.ts → utils/event-types.js} +5 -15
  38. package/utils/popup.d.ts +3 -0
  39. package/utils/popup.js +36 -0
  40. package/utils/sdk-specs.d.ts +5 -0
  41. package/utils/sdk-specs.js +6 -0
  42. package/utils/style.d.ts +3 -0
  43. package/utils/style.js +13 -0
  44. package/utils/types.d.ts +234 -0
  45. package/utils/types.js +1 -0
  46. package/utils/version.d.ts +1 -0
  47. package/utils/version.js +1 -0
  48. package/utils/wallet/EVMWalletStrategy.d.ts +31 -0
  49. package/utils/wallet/EVMWalletStrategy.js +265 -0
  50. package/utils/wallet/SolanaWalletStrategy.d.ts +33 -0
  51. package/utils/wallet/SolanaWalletStrategy.js +300 -0
  52. package/utils/wallet/WalletStrategy.d.ts +61 -0
  53. package/utils/wallet/WalletStrategy.js +25 -0
  54. package/utils/wallet/WalletStrategyFactory.d.ts +15 -0
  55. package/utils/wallet/WalletStrategyFactory.js +31 -0
  56. package/utils/wallet/index.d.ts +4 -0
  57. package/utils/wallet/index.js +4 -0
  58. package/utils/wallet-browser-event-types.d.ts +116 -0
  59. package/utils/wallet-browser-event-types.js +17 -0
  60. package/jest.setup.ts +0 -4
  61. package/src/Link.test.ts +0 -434
  62. package/src/Link.ts +0 -491
  63. package/src/index.ts +0 -3
  64. package/src/utils/__snapshots__/popup.test.ts.snap +0 -89
  65. package/src/utils/connectors/evm/chainConfigs.ts +0 -120
  66. package/src/utils/connectors/evm/chainSwitching.ts +0 -165
  67. package/src/utils/connectors/evm/index.ts +0 -8
  68. package/src/utils/connectors/evm/provider.ts +0 -22
  69. package/src/utils/connectors/evm/signing.ts +0 -39
  70. package/src/utils/connectors/evm/transactions.ts +0 -356
  71. package/src/utils/connectors/evm/types.ts +0 -63
  72. package/src/utils/connectors/evm/walletConnection.ts +0 -140
  73. package/src/utils/connectors/evm/walletDiscovery.ts +0 -67
  74. package/src/utils/connectors/solana/connection.ts +0 -69
  75. package/src/utils/connectors/solana/index.ts +0 -5
  76. package/src/utils/connectors/solana/providerDiscovery.ts +0 -153
  77. package/src/utils/connectors/solana/signing.ts +0 -18
  78. package/src/utils/connectors/solana/transaction.ts +0 -382
  79. package/src/utils/connectors/solana/types.ts +0 -66
  80. package/src/utils/event-types.ts +0 -350
  81. package/src/utils/popup.test.ts +0 -50
  82. package/src/utils/popup.ts +0 -123
  83. package/src/utils/sdk-specs.test.ts +0 -18
  84. package/src/utils/sdk-specs.ts +0 -7
  85. package/src/utils/style.test.ts +0 -33
  86. package/src/utils/style.ts +0 -15
  87. package/src/utils/types.ts +0 -270
  88. package/src/utils/version.ts +0 -1
  89. package/src/utils/wallet/EVMWalletStrategy.ts +0 -176
  90. package/src/utils/wallet/SolanaWalletStrategy.ts +0 -207
  91. package/src/utils/wallet/WalletStrategy.ts +0 -99
  92. package/src/utils/wallet/WalletStrategyFactory.ts +0 -46
  93. package/src/utils/wallet/__tests__/EVMWalletStrategy.test.ts +0 -233
  94. package/src/utils/wallet/__tests__/SolanaWalletStrategy.test.ts +0 -253
  95. package/src/utils/wallet/__tests__/WalletStrategy.test.ts +0 -77
  96. package/src/utils/wallet/__tests__/WalletStrategyFactory.test.ts +0 -65
  97. package/src/utils/wallet/index.ts +0 -4
  98. package/src/utils/wallet-browser-event-types.ts +0 -190
  99. package/tools/copy.js +0 -26
  100. package/tools/update-version.js +0 -10
  101. package/tsconfig.json +0 -14
@@ -1,7 +1,4 @@
1
- import { isLinkEventTypeKey } from './event-types'
2
-
3
- describe('Event types tests', () => {
4
- test.each([
1
+ var LINK_EVENT_TYPE_KEYS = [
5
2
  'integrationConnected',
6
3
  'integrationConnectionError',
7
4
  'integrationMfaRequired',
@@ -41,14 +38,7 @@ describe('Event types tests', () => {
41
38
  'fundingOptionsUpdated',
42
39
  'fundingOptionsViewed',
43
40
  'gasIncreaseWarning'
44
- ])(
45
- 'isLinkEventTypeKey should return true if parameter is "%s"',
46
- eventType => {
47
- expect(isLinkEventTypeKey(eventType)).toBe(true)
48
- }
49
- )
50
-
51
- test('isLinkEventTypeKey should return false if parameter is not event', () => {
52
- expect(isLinkEventTypeKey('test')).toBe(false)
53
- })
54
- })
41
+ ];
42
+ export function isLinkEventTypeKey(key) {
43
+ return LINK_EVENT_TYPE_KEYS.includes(key);
44
+ }
@@ -0,0 +1,3 @@
1
+ export declare const iframeId = "mesh-link-popup__iframe";
2
+ export declare function removePopup(): void;
3
+ export declare function addPopup(iframeLink: string): void;
package/utils/popup.js ADDED
@@ -0,0 +1,36 @@
1
+ import { getLinkStyle, getNumber } from './style';
2
+ var popupId = 'mesh-link-popup';
3
+ var backdropId = 'mesh-link-popup__backdrop';
4
+ var popupContentId = 'mesh-link-popup__popup-content';
5
+ var stylesId = 'mesh-link-popup__styles';
6
+ export var iframeId = 'mesh-link-popup__iframe';
7
+ var getStylesContent = function (style) { return "\n body {\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n overflow: hidden;\n }\n\n #".concat(popupId, " {\n all: unset;\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n }\n\n #").concat(backdropId, " {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10000;\n background: black;\n opacity: ").concat(getNumber(0.6, style === null || style === void 0 ? void 0 : style.io), ";\n }\n\n #").concat(popupContentId, " {\n position: absolute;\n height: 80%;\n max-height: 710px;\n min-height: 685px;\n margin: auto;\n z-index: 10001;\n width: 30%;\n max-width: 430px;\n min-width: 380px;\n display: flex;\n flex-direction: column;\n border-radius: ").concat(getNumber(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n flex-grow: 1;\n }\n\n #").concat(popupContentId, " iframe {\n border: none;\n width: 100%;\n flex-grow: 1;\n border-radius: ").concat(getNumber(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n }\n\n @media only screen and (max-width: 768px) {\n #").concat(popupContentId, " {\n height: 100vh;\n width: 100vw;\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n min-height: 100%;\n border-radius: 0px;\n }\n\n #").concat(popupContentId, " iframe {\n border-radius: 0px;\n }\n }\n\n @media only screen and (max-height: 710px) {\n #").concat(popupContentId, " {\n max-height: 100%;\n min-height: 100%;\n }\n }\n"); };
8
+ export function removePopup() {
9
+ var _a, _b;
10
+ var existingPopup = window.document.getElementById(popupId);
11
+ (_a = existingPopup === null || existingPopup === void 0 ? void 0 : existingPopup.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(existingPopup);
12
+ var existingStyles = window.document.getElementById(stylesId);
13
+ (_b = existingStyles === null || existingStyles === void 0 ? void 0 : existingStyles.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(existingStyles);
14
+ }
15
+ export function addPopup(iframeLink) {
16
+ removePopup();
17
+ var styleElement = document.createElement('style');
18
+ styleElement.id = stylesId;
19
+ var style = getLinkStyle(iframeLink);
20
+ styleElement.textContent = getStylesContent(style);
21
+ window.document.head.appendChild(styleElement);
22
+ var popupRootElement = document.createElement('div');
23
+ popupRootElement.id = popupId;
24
+ var popupBackdropElement = document.createElement('div');
25
+ popupBackdropElement.id = backdropId;
26
+ popupRootElement.appendChild(popupBackdropElement);
27
+ var popupContentElement = document.createElement('div');
28
+ popupContentElement.id = popupContentId;
29
+ var iframeElement = document.createElement('iframe');
30
+ iframeElement.id = iframeId;
31
+ iframeElement.src = iframeLink;
32
+ iframeElement.allow = 'clipboard-read *; clipboard-write *';
33
+ popupContentElement.appendChild(iframeElement);
34
+ popupRootElement.appendChild(popupContentElement);
35
+ window.document.body.appendChild(popupRootElement);
36
+ }
@@ -0,0 +1,5 @@
1
+ export declare const sdkSpecs: {
2
+ platform: string;
3
+ version: string;
4
+ origin: string;
5
+ };
@@ -0,0 +1,6 @@
1
+ import { sdkVersion } from './version';
2
+ export var sdkSpecs = {
3
+ platform: 'web',
4
+ version: sdkVersion,
5
+ origin: window.location.origin
6
+ };
@@ -0,0 +1,3 @@
1
+ import { LinkStyle } from './types';
2
+ export declare function getLinkStyle(url: string): LinkStyle | undefined;
3
+ export declare function getNumber(def: number, value?: number): number;
package/utils/style.js ADDED
@@ -0,0 +1,13 @@
1
+ export function getLinkStyle(url) {
2
+ try {
3
+ var params = new URLSearchParams(new URL(url).search);
4
+ var style = params.get('link_style');
5
+ return style && JSON.parse(window.atob(style));
6
+ }
7
+ catch (e) {
8
+ return undefined;
9
+ }
10
+ }
11
+ export function getNumber(def, value) {
12
+ return value !== undefined ? value : def;
13
+ }
@@ -0,0 +1,234 @@
1
+ import type { BrokerType } from '@meshconnect/node-api';
2
+ import { SessionSummary, LinkEventType } from './event-types';
3
+ export type EventType = 'brokerageAccountAccessToken' | 'delayedAuthentication' | 'loaded' | 'transferFinished';
4
+ export interface Link {
5
+ /**
6
+ * A function that takes linkToken parameter from `/api/v1/linktoken` endpoint as an input, and opens the Link UI popup
7
+ * @param linkToken - Base64 encoded link token from the `/api/v1/linktoken` endpoint
8
+ * @param customIframeId - Optional custom ID for the existing iframe element. If not provided, a new iframe element will be created
9
+ */
10
+ openLink: (linkToken: string, customIframeId?: string) => void;
11
+ /**
12
+ * A function to close Link UI popup
13
+ */
14
+ closeLink: () => void;
15
+ }
16
+ export interface AccountToken {
17
+ account: Account;
18
+ accessToken: string;
19
+ refreshToken?: string;
20
+ tokenId?: string;
21
+ }
22
+ export interface Account {
23
+ accountId: string;
24
+ accountName: string;
25
+ fund?: number;
26
+ cash?: number;
27
+ isReconnected?: boolean;
28
+ }
29
+ /**
30
+ * Integration brand information
31
+ */
32
+ export interface BrandInfo {
33
+ /**
34
+ * Integration logo in base 64 format
35
+ */
36
+ brokerLogo: string;
37
+ /**
38
+ * Integration logo URL (obsolete, use `logoLightUrl` instead)
39
+ */
40
+ brokerLogoUrl?: string;
41
+ /**
42
+ * Integration logo URL for light theme
43
+ */
44
+ logoLightUrl?: string;
45
+ /**
46
+ * Integration logo URL for dark theme
47
+ */
48
+ logoDarkUrl?: string;
49
+ /**
50
+ * Integration icon URL for light theme
51
+ */
52
+ iconLightUrl?: string;
53
+ /**
54
+ * Integration icon URL for dark theme
55
+ */
56
+ iconDarkUrl?: string;
57
+ }
58
+ export interface LinkPayload {
59
+ accessToken?: AccessTokenPayload;
60
+ delayedAuth?: DelayedAuthPayload;
61
+ }
62
+ export interface AccessTokenPayload {
63
+ accountTokens: AccountToken[];
64
+ brokerBrandInfo: BrandInfo;
65
+ expiresInSeconds?: number;
66
+ refreshTokenExpiresInSeconds?: number;
67
+ brokerType: BrokerType;
68
+ brokerName: string;
69
+ }
70
+ export interface DelayedAuthPayload {
71
+ refreshTokenExpiresInSeconds?: number;
72
+ brokerType: BrokerType;
73
+ refreshToken: string;
74
+ brokerName: string;
75
+ brokerBrandInfo: BrandInfo;
76
+ }
77
+ export interface TransferFinishedPayload {
78
+ status: 'success';
79
+ txId: string;
80
+ fromAddress: string;
81
+ toAddress: string;
82
+ symbol: string;
83
+ amount: number;
84
+ networkId: string;
85
+ amountInFiat?: number;
86
+ totalAmountInFiat?: number;
87
+ networkName?: string;
88
+ txHash?: string;
89
+ transferId?: string;
90
+ refundAddress?: string;
91
+ }
92
+ export interface IntegrationAccessToken {
93
+ accountId: string;
94
+ accountName: string;
95
+ accessToken: string;
96
+ brokerType: BrokerType;
97
+ brokerName: string;
98
+ }
99
+ export interface WalletBrowserPayload {
100
+ networkType?: string;
101
+ integrationName: string;
102
+ targetChainId?: string;
103
+ walletName?: string;
104
+ }
105
+ export interface SignRequestPayload {
106
+ address: string;
107
+ message: string;
108
+ walletName?: string;
109
+ }
110
+ export interface ChainSwitchPayload {
111
+ chainId: number;
112
+ networkType?: string;
113
+ walletName?: string;
114
+ }
115
+ export interface TransferPayload {
116
+ toAddress: string;
117
+ amount: number;
118
+ decimalPlaces: number;
119
+ chainId: number;
120
+ account: string;
121
+ network: string;
122
+ blockhash?: string;
123
+ walletName?: string;
124
+ gasLimit?: number | null;
125
+ maxFeePerGas?: number | null;
126
+ maxPriorityFeePerGas?: number | null;
127
+ }
128
+ export interface SmartContractPayload {
129
+ address: string;
130
+ abi: string;
131
+ functionName: string;
132
+ args: unknown[];
133
+ account: string;
134
+ value?: string;
135
+ walletName?: string;
136
+ tokenProgram?: string;
137
+ blockhash?: string;
138
+ createATA?: boolean;
139
+ gasLimit?: number | null;
140
+ maxFeePerGas?: number | null;
141
+ maxPriorityFeePerGas?: number | null;
142
+ }
143
+ export interface TransactionBatchPayload {
144
+ version: string;
145
+ from: string;
146
+ chainId: string;
147
+ atomicRequired: boolean;
148
+ calls: {
149
+ to: string;
150
+ value: string;
151
+ data?: string;
152
+ }[];
153
+ }
154
+ export interface WalletCapabilitiesPayload {
155
+ from: string;
156
+ chainId: string;
157
+ }
158
+ export interface DisconnectPayload {
159
+ networkType?: string;
160
+ walletName?: string;
161
+ }
162
+ export interface AddressLookupTableStateDto {
163
+ deactivationSlot: bigint;
164
+ lastExtendedSlot: number;
165
+ lastExtendedStartIndex: number;
166
+ key: string;
167
+ authority?: string;
168
+ addresses: string[];
169
+ }
170
+ export interface SolanaTransferWithInstructionsPayload {
171
+ transactionInstructions: {
172
+ states: AddressLookupTableStateDto[];
173
+ instructions: TransactionInstructionDto[];
174
+ account: string;
175
+ blockhash: string;
176
+ walletName?: string;
177
+ network?: string;
178
+ };
179
+ transferConfig: SmartContractPayload;
180
+ }
181
+ export interface SolanaAccountMeta {
182
+ shouldFillPubkey: boolean;
183
+ pubKey: string | null;
184
+ isWritable: boolean;
185
+ isSigner: boolean;
186
+ }
187
+ export interface TransactionInstructionDto {
188
+ programId: string;
189
+ accounts: SolanaAccountMeta[];
190
+ data: string;
191
+ }
192
+ export interface LinkOptions {
193
+ /**
194
+ * Client ID that can be obtained at https://dashboard.meshconnect.com/company/keys
195
+ */
196
+ clientId?: string;
197
+ /**
198
+ * A callback function that is called when an integration is successfully connected.
199
+ * It receives a payload of type `LinkPayload`.
200
+ */
201
+ onIntegrationConnected: (payload: LinkPayload) => void;
202
+ /**
203
+ * (Optional) A callback function that is called when the Front iframe is closed.
204
+ */
205
+ onExit?: (error?: string, summary?: SessionSummary) => void;
206
+ /**
207
+ * (Optional) A callback function that is called when a transfer is finished.
208
+ * It receives a payload of type `TransferFinishedPayload`.
209
+ */
210
+ onTransferFinished?: (payload: TransferFinishedPayload) => void;
211
+ /**
212
+ * (Optional) A callback function that is called when various events occur within the Front iframe.
213
+ * It receives an object with type `LinkEventTypeKeys` indicating the event, and an optional 'payload' containing additional data.
214
+ */
215
+ onEvent?: (event: LinkEventType) => void;
216
+ /**
217
+ * (Optional) An array of integration access tokens.
218
+ * These access tokens are used to initialize crypto transfers flow at 'Select asset step'
219
+ */
220
+ accessTokens?: IntegrationAccessToken[];
221
+ /**
222
+ * (Optional) An array of integration access tokens.
223
+ * Can be used to initialize the crypto transfers flow as an alternative to the target addresses.
224
+ */
225
+ transferDestinationTokens?: IntegrationAccessToken[];
226
+ /**
227
+ * Link UI language. Supported: 'en', 'ru'. Can be set as 'en-US', 'ru-RU', etc.
228
+ */
229
+ language?: string;
230
+ }
231
+ export interface LinkStyle {
232
+ ir: number;
233
+ io: number;
234
+ }
package/utils/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const sdkVersion = "3.2.16";
@@ -0,0 +1 @@
1
+ export var sdkVersion = '3.2.16';
@@ -0,0 +1,31 @@
1
+ import { BaseWalletStrategy } from './WalletStrategy';
2
+ import { WalletBrowserPayload, SignRequestPayload, ChainSwitchPayload, TransferPayload, SmartContractPayload, DisconnectPayload, TransactionBatchPayload, WalletCapabilitiesPayload } from '../types';
3
+ export declare class EVMWalletStrategy extends BaseWalletStrategy {
4
+ sendTransactionWithInstructions(): Promise<string>;
5
+ connect(payload: WalletBrowserPayload): Promise<{
6
+ accounts: string[];
7
+ chainId: number;
8
+ isConnected: boolean;
9
+ }>;
10
+ disconnect(payload: DisconnectPayload): Promise<void>;
11
+ signMessage(payload: SignRequestPayload): Promise<string>;
12
+ switchChain(payload: ChainSwitchPayload): Promise<{
13
+ chainId: number;
14
+ accounts: string[];
15
+ }>;
16
+ sendNativeTransfer(payload: TransferPayload): Promise<string>;
17
+ sendSmartContractInteraction(payload: SmartContractPayload): Promise<string>;
18
+ sendNativeSmartContractInteraction(payload: SmartContractPayload): Promise<string>;
19
+ sendTransactionBatch(payload: TransactionBatchPayload): Promise<string>;
20
+ getWalletCapabilities(payload: WalletCapabilitiesPayload): Promise<{
21
+ atomic: {
22
+ status: string;
23
+ };
24
+ }>;
25
+ getProviders(): {
26
+ icon: string | undefined;
27
+ id: string;
28
+ name: string;
29
+ type: string;
30
+ }[];
31
+ }
@@ -0,0 +1,265 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import { BaseWalletStrategy } from './WalletStrategy';
53
+ import { connectToEVMWallet, disconnectFromEVMWallet, signEVMMessage, sendEVMTransaction, sendEVMTokenTransaction, sendNativeSmartContractTransaction, switchEVMChain, findAvailableProviders, sendEVMTransactionBatch, getWalletCapabilities } from '../connectors/evm';
54
+ var EVMWalletStrategy = /** @class */ (function (_super) {
55
+ __extends(EVMWalletStrategy, _super);
56
+ function EVMWalletStrategy() {
57
+ return _super !== null && _super.apply(this, arguments) || this;
58
+ }
59
+ EVMWalletStrategy.prototype.sendTransactionWithInstructions = function () {
60
+ throw new Error('Method not implemented.');
61
+ };
62
+ EVMWalletStrategy.prototype.connect = function (payload) {
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var result, error_1;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ _a.trys.push([0, 2, , 3]);
69
+ return [4 /*yield*/, connectToEVMWallet(payload.integrationName, payload.targetChainId ? parseInt(payload.targetChainId, 10) : undefined)];
70
+ case 1:
71
+ result = _a.sent();
72
+ if (result instanceof Error) {
73
+ throw result;
74
+ }
75
+ return [2 /*return*/, {
76
+ accounts: result.accounts,
77
+ chainId: result.chainId,
78
+ isConnected: result.isConnected
79
+ }];
80
+ case 2:
81
+ error_1 = _a.sent();
82
+ throw this.handleError(error_1, 'connect to EVM wallet');
83
+ case 3: return [2 /*return*/];
84
+ }
85
+ });
86
+ });
87
+ };
88
+ EVMWalletStrategy.prototype.disconnect = function (payload) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ var result, error_2;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0:
94
+ _a.trys.push([0, 2, , 3]);
95
+ return [4 /*yield*/, disconnectFromEVMWallet(payload.walletName || 'Unknown Wallet')];
96
+ case 1:
97
+ result = _a.sent();
98
+ if (result instanceof Error) {
99
+ throw result;
100
+ }
101
+ return [3 /*break*/, 3];
102
+ case 2:
103
+ error_2 = _a.sent();
104
+ throw this.handleError(error_2, 'disconnect from EVM wallet');
105
+ case 3: return [2 /*return*/];
106
+ }
107
+ });
108
+ });
109
+ };
110
+ EVMWalletStrategy.prototype.signMessage = function (payload) {
111
+ return __awaiter(this, void 0, void 0, function () {
112
+ var result, error_3;
113
+ return __generator(this, function (_a) {
114
+ switch (_a.label) {
115
+ case 0:
116
+ _a.trys.push([0, 2, , 3]);
117
+ return [4 /*yield*/, signEVMMessage(payload.walletName || 'Unknown Wallet', payload.address, payload.message)];
118
+ case 1:
119
+ result = _a.sent();
120
+ if (result instanceof Error) {
121
+ throw result;
122
+ }
123
+ return [2 /*return*/, result];
124
+ case 2:
125
+ error_3 = _a.sent();
126
+ throw this.handleError(error_3, 'sign EVM message');
127
+ case 3: return [2 /*return*/];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ EVMWalletStrategy.prototype.switchChain = function (payload) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ var result, error_4;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0:
138
+ _a.trys.push([0, 2, , 3]);
139
+ return [4 /*yield*/, switchEVMChain(payload.chainId)];
140
+ case 1:
141
+ result = _a.sent();
142
+ if (result instanceof Error) {
143
+ throw result;
144
+ }
145
+ return [2 /*return*/, result];
146
+ case 2:
147
+ error_4 = _a.sent();
148
+ throw this.handleError(error_4, 'switch EVM chain');
149
+ case 3: return [2 /*return*/];
150
+ }
151
+ });
152
+ });
153
+ };
154
+ EVMWalletStrategy.prototype.sendNativeTransfer = function (payload) {
155
+ return __awaiter(this, void 0, void 0, function () {
156
+ var result, error_5;
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0:
160
+ _a.trys.push([0, 2, , 3]);
161
+ return [4 /*yield*/, sendEVMTransaction(payload.toAddress, BigInt(payload.amount * Math.pow(10, payload.decimalPlaces)), payload.account, payload.gasLimit, payload.maxFeePerGas, payload.maxPriorityFeePerGas)];
162
+ case 1:
163
+ result = _a.sent();
164
+ if (result instanceof Error) {
165
+ throw result;
166
+ }
167
+ return [2 /*return*/, result];
168
+ case 2:
169
+ error_5 = _a.sent();
170
+ throw this.handleError(error_5, 'send EVM native transfer');
171
+ case 3: return [2 /*return*/];
172
+ }
173
+ });
174
+ });
175
+ };
176
+ EVMWalletStrategy.prototype.sendSmartContractInteraction = function (payload) {
177
+ return __awaiter(this, void 0, void 0, function () {
178
+ var result, error_6;
179
+ return __generator(this, function (_a) {
180
+ switch (_a.label) {
181
+ case 0:
182
+ _a.trys.push([0, 2, , 3]);
183
+ return [4 /*yield*/, sendEVMTokenTransaction(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args, payload.account)];
184
+ case 1:
185
+ result = _a.sent();
186
+ if (result instanceof Error) {
187
+ throw result;
188
+ }
189
+ return [2 /*return*/, result];
190
+ case 2:
191
+ error_6 = _a.sent();
192
+ throw this.handleError(error_6, 'send EVM smart contract interaction');
193
+ case 3: return [2 /*return*/];
194
+ }
195
+ });
196
+ });
197
+ };
198
+ EVMWalletStrategy.prototype.sendNativeSmartContractInteraction = function (payload) {
199
+ return __awaiter(this, void 0, void 0, function () {
200
+ var result, error_7;
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0:
204
+ _a.trys.push([0, 2, , 3]);
205
+ return [4 /*yield*/, sendNativeSmartContractTransaction(payload.address, JSON.parse(payload.abi), payload.functionName, payload.args, payload.account, payload.value)];
206
+ case 1:
207
+ result = _a.sent();
208
+ if (result instanceof Error) {
209
+ throw result;
210
+ }
211
+ return [2 /*return*/, result];
212
+ case 2:
213
+ error_7 = _a.sent();
214
+ throw this.handleError(error_7, 'send EVM smart contract interaction');
215
+ case 3: return [2 /*return*/];
216
+ }
217
+ });
218
+ });
219
+ };
220
+ EVMWalletStrategy.prototype.sendTransactionBatch = function (payload) {
221
+ return __awaiter(this, void 0, void 0, function () {
222
+ var result, error_8;
223
+ return __generator(this, function (_a) {
224
+ switch (_a.label) {
225
+ case 0:
226
+ _a.trys.push([0, 2, , 3]);
227
+ return [4 /*yield*/, sendEVMTransactionBatch(payload)];
228
+ case 1:
229
+ result = _a.sent();
230
+ if (result instanceof Error) {
231
+ throw result;
232
+ }
233
+ return [2 /*return*/, result];
234
+ case 2:
235
+ error_8 = _a.sent();
236
+ throw this.handleError(error_8, 'send EVM smart contract interaction');
237
+ case 3: return [2 /*return*/];
238
+ }
239
+ });
240
+ });
241
+ };
242
+ EVMWalletStrategy.prototype.getWalletCapabilities = function (payload) {
243
+ return __awaiter(this, void 0, void 0, function () {
244
+ var result;
245
+ return __generator(this, function (_a) {
246
+ switch (_a.label) {
247
+ case 0: return [4 /*yield*/, getWalletCapabilities(payload.from, payload.chainId)];
248
+ case 1:
249
+ result = _a.sent();
250
+ return [2 /*return*/, result];
251
+ }
252
+ });
253
+ });
254
+ };
255
+ EVMWalletStrategy.prototype.getProviders = function () {
256
+ return findAvailableProviders().map(function (provider) { return ({
257
+ icon: provider.icon,
258
+ id: provider.id,
259
+ name: provider.name,
260
+ type: 'evm'
261
+ }); });
262
+ };
263
+ return EVMWalletStrategy;
264
+ }(BaseWalletStrategy));
265
+ export { EVMWalletStrategy };
@@ -0,0 +1,33 @@
1
+ import { BaseWalletStrategy } from './WalletStrategy';
2
+ import { WalletBrowserPayload, SignRequestPayload, ChainSwitchPayload, TransferPayload, SmartContractPayload, DisconnectPayload, SolanaTransferWithInstructionsPayload } from '../types';
3
+ export declare class SolanaWalletStrategy extends BaseWalletStrategy {
4
+ connect(payload: WalletBrowserPayload): Promise<{
5
+ accounts: string[];
6
+ chainId: string;
7
+ isConnected: boolean;
8
+ }>;
9
+ disconnect(payload: DisconnectPayload): Promise<void>;
10
+ signMessage(payload: SignRequestPayload): Promise<string>;
11
+ /**
12
+ * Handles chain switching for Solana networks
13
+ * Supports both mainnet (101) and devnet (103)
14
+ */
15
+ switchChain(payload: ChainSwitchPayload): Promise<{
16
+ chainId: string;
17
+ accounts: string[];
18
+ }>;
19
+ sendNativeTransfer(payload: TransferPayload): Promise<string>;
20
+ sendSmartContractInteraction(payload: SmartContractPayload): Promise<string>;
21
+ sendTransactionWithInstructions(payload: SolanaTransferWithInstructionsPayload): Promise<string>;
22
+ sendNativeSmartContractInteraction(): Promise<string>;
23
+ sendTransactionBatch(): Promise<string>;
24
+ getWalletCapabilities(): Promise<{
25
+ atomic: {
26
+ status: string;
27
+ };
28
+ }>;
29
+ getProviders(): {
30
+ id: string;
31
+ type: string;
32
+ }[];
33
+ }