@swapper-finance/deposit-sdk 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025 Swapper Finance
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
package/README.md ADDED
@@ -0,0 +1,404 @@
1
+ # @swapper-finance/deposit-sdk
2
+
3
+ Easy iframe embedding for the Swapper deposit widget with full TypeScript support.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @swapper-finance/deposit-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### Option 1: Embed in Container
14
+
15
+ ```typescript
16
+ import { SwapperIframe } from '@swapper-finance/deposit-sdk';
17
+
18
+ // Create and mount the iframe
19
+ const swapper = new SwapperIframe({
20
+ container: '#swapper-container', // or pass an HTMLElement
21
+ integratorId: 'your-integrator-id',
22
+ dstChainId: '8453',
23
+ dstTokenAddr: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
24
+ depositWalletAddress: '0x2A018F2506acaEEE2C10632514Fc5DCa9eE2c28A',
25
+ });
26
+ ```
27
+
28
+ ### Option 2: Open in Modal Popup
29
+
30
+ ```typescript
31
+ import { openSwapperModal } from '@swapper-finance/deposit-sdk';
32
+
33
+ // Open in a centered modal with backdrop
34
+ const modal = openSwapperModal({
35
+ integratorId: 'your-integrator-id',
36
+ dstChainId: '8453',
37
+ dstTokenAddr: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
38
+ depositWalletAddress: '0x2A018F2506acaEEE2C10632514Fc5DCa9eE2c28A',
39
+ });
40
+
41
+ // Close programmatically if needed
42
+ // modal.close();
43
+ ```
44
+
45
+ ## Configuration Options
46
+
47
+ ### Required Parameters
48
+
49
+ - `integratorId` - Your integrator identifier
50
+ - `dstChainId` - Destination chain ID
51
+ - `dstTokenAddr` - Destination token address
52
+ - `depositWalletAddress` - Wallet address for deposits
53
+
54
+ ### Optional Parameters
55
+
56
+ #### Styling
57
+
58
+ The SDK supports a three-tier styling system:
59
+
60
+ ```typescript
61
+ const swapper = new SwapperIframe({
62
+ // ... required params
63
+ styles: {
64
+ // Level 1: Theme mode (light or dark)
65
+ themeMode: 'dark',
66
+
67
+ // Level 2: Brand colors
68
+ brandTheme: {
69
+ primaryColor: '#FF6B35',
70
+ secondaryColor: '#004E89',
71
+ },
72
+
73
+ // Level 3: Component-specific overrides (highest priority)
74
+ componentStyles: {
75
+ backgroundColor: '#1A1A1A',
76
+ textColor: '#E8E8E8',
77
+ borderRadius: '12px',
78
+ width: '100%',
79
+ primaryButtonBackground: '#FF6B35',
80
+ primaryButtonText: '#FFFFFF',
81
+ // ... more style options
82
+ },
83
+ },
84
+ });
85
+ ```
86
+
87
+ #### Custom Contract Calls
88
+
89
+ ```typescript
90
+ import { ContractCallType } from '@swapper-finance/deposit-sdk';
91
+
92
+ const swapper = new SwapperIframe({
93
+ // ... required params
94
+ customContractCalls: [
95
+ {
96
+ callType: ContractCallType.CALL,
97
+ target: '0x...',
98
+ value: '0',
99
+ callData: '0x...',
100
+ payload: '0x...'
101
+ },
102
+ ],
103
+ });
104
+ ```
105
+
106
+ ## API Reference
107
+
108
+ ### Constructor
109
+
110
+ ```typescript
111
+ new SwapperIframe(options: SwapperIframeOptions)
112
+ ```
113
+
114
+ ### Methods
115
+
116
+ #### `mount(container: HTMLElement | string): void`
117
+
118
+ Mounts the iframe to a container element.
119
+
120
+ ```typescript
121
+ swapper.mount('#my-container');
122
+ // or
123
+ swapper.mount(document.getElementById('my-container'));
124
+ ```
125
+
126
+ #### `updateConfig(config: Partial<SwapperConfig>): void`
127
+
128
+ Updates the configuration dynamically via postMessage.
129
+
130
+ ```typescript
131
+ swapper.updateConfig({
132
+ depositWalletAddress: '0xNewAddress...',
133
+ dstChainId: '1',
134
+ });
135
+ ```
136
+
137
+ #### `updateStyles(styles: SwapperStyles): void`
138
+
139
+ Updates only the styles.
140
+
141
+ ```typescript
142
+ swapper.updateStyles({
143
+ themeMode: 'light',
144
+ brandTheme: {
145
+ primaryColor: '#836FFF',
146
+ },
147
+ });
148
+ ```
149
+
150
+ #### `updateCustomContractCalls(calls: ContractCall[]): void`
151
+
152
+ Updates custom contract calls.
153
+
154
+ ```typescript
155
+ swapper.updateCustomContractCalls([
156
+ {
157
+ callType: ContractCallType.CALL,
158
+ target: '0x...',
159
+ value: '0',
160
+ callData: '0x...',
161
+ payload: '0x...',
162
+ },
163
+ ]);
164
+ ```
165
+
166
+ #### `getConfig(): SwapperConfig`
167
+
168
+ Returns the current configuration.
169
+
170
+ ```typescript
171
+ const config = swapper.getConfig();
172
+ console.log(config.depositWalletAddress);
173
+ ```
174
+
175
+ #### `destroy(): void`
176
+
177
+ Removes the iframe and cleans up event listeners.
178
+
179
+ ```typescript
180
+ swapper.destroy();
181
+ ```
182
+
183
+ ## Modal API Reference
184
+
185
+ ### Opening a Modal
186
+
187
+ #### Quick Function: `openSwapperModal(options)`
188
+
189
+ ```typescript
190
+ import { openSwapperModal } from '@swapper-finance/deposit-sdk';
191
+
192
+ const modal = openSwapperModal({
193
+ // Required configuration
194
+ integratorId: 'your-id',
195
+ dstChainId: '8453',
196
+ dstTokenAddr: '0x...',
197
+ depositWalletAddress: '0x...',
198
+
199
+ // Optional: Widget styling
200
+ styles: {
201
+ themeMode: 'light',
202
+ },
203
+
204
+ // Optional: Modal styling
205
+ modalStyle: {
206
+ overlayColor: 'rgba(0, 0, 0, 0.8)',
207
+ borderRadius: '16px'
208
+ },
209
+
210
+ // Optional: Callback when closed
211
+ onClose: () => {
212
+ console.log('Modal was closed');
213
+ },
214
+ });
215
+
216
+ // Close programmatically
217
+ modal.close();
218
+ ```
219
+
220
+ ### Modal Options
221
+
222
+ #### `modalStyle` Configuration
223
+
224
+ ```typescript
225
+ interface ModalStyle {
226
+ /**
227
+ * Modal width (default: '480px')
228
+ */
229
+ width?: string;
230
+
231
+ /**
232
+ * Modal height (default: '560px')
233
+ */
234
+ height?: string;
235
+
236
+ /**
237
+ * Background overlay color (default: 'rgba(0, 0, 0, 0.7)')
238
+ */
239
+ overlayColor?: string;
240
+
241
+ /**
242
+ * Modal border radius (default: '16px')
243
+ */
244
+ borderRadius?: string;
245
+
246
+ /**
247
+ * Z-index for modal (default: 10000)
248
+ */
249
+ zIndex?: number;
250
+
251
+ /**
252
+ * Show close button (default: false)
253
+ * Set to true to show a close button
254
+ */
255
+ showCloseButton?: boolean;
256
+ }
257
+ ```
258
+
259
+ ### Modal Class Methods
260
+
261
+ #### `SwapperModal` Class
262
+
263
+ For more control, use the `SwapperModal` class directly:
264
+
265
+ ```typescript
266
+ import { SwapperModal } from '@swapper-finance/deposit-sdk';
267
+
268
+ // Create modal instance
269
+ const modal = new SwapperModal({
270
+ integratorId: 'your-id',
271
+ dstChainId: '8453',
272
+ dstTokenAddr: '0x...',
273
+ depositWalletAddress: '0x...',
274
+ modalStyle: {
275
+ showCloseButton: true, // Optional: show close button
276
+ },
277
+ onClose: () => {
278
+ console.log('Modal closed');
279
+ },
280
+ });
281
+
282
+ // Open modal
283
+ modal.open();
284
+
285
+ // Close modal
286
+ modal.close();
287
+
288
+ // Check if open
289
+ if (modal.isModalOpen()) {
290
+ console.log('Modal is open');
291
+ }
292
+
293
+ // Get iframe instance
294
+ const iframe = modal.getIframe();
295
+
296
+ // Destroy completely
297
+ modal.destroy();
298
+ ```
299
+
300
+ ## Available Style Properties
301
+
302
+ ### ComponentStyles
303
+
304
+ ```typescript
305
+ interface ComponentStyles {
306
+ // Layout
307
+ backgroundColor?: string;
308
+ borderRadius?: string;
309
+ width?: string;
310
+
311
+ // Typography
312
+ textColor?: string;
313
+
314
+ // Buttons
315
+ primaryButtonBackground?: string;
316
+ primaryButtonText?: string;
317
+ secondaryButtonBackground?: string;
318
+ secondaryButtonText?: string;
319
+ disabledButtonBackground?: string;
320
+ disabledButtonText?: string;
321
+
322
+ // Status colors
323
+ successColor?: string;
324
+ warningColor?: string;
325
+ errorColor?: string;
326
+
327
+ // Brand colors
328
+ primaryColor?: string;
329
+ secondaryColor?: string;
330
+
331
+ // Additional UI elements
332
+ inputBackground?: string;
333
+ inputBorder?: string;
334
+ cardBackground?: string;
335
+ borderColor?: string;
336
+ }
337
+ ```
338
+
339
+ ## Examples
340
+
341
+ ### Modal Popup Usage
342
+
343
+ ```html
344
+ <!DOCTYPE html>
345
+ <html>
346
+ <head>
347
+ <title>Swapper Modal</title>
348
+ </head>
349
+ <body>
350
+ <button id="open-modal">Open Swapper</button>
351
+
352
+ <script type="module">
353
+ import { openSwapperModal } from '@swapper-finance/deposit-sdk';
354
+
355
+ document.getElementById('open-modal').onclick = () => {
356
+ openSwapperModal({
357
+ integratorId: 'your-integrator-id',
358
+ dstChainId: '8453',
359
+ dstTokenAddr: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
360
+ depositWalletAddress: '0x2A018F2506acaEEE2C10632514Fc5DCa9eE2c28A',
361
+ modalStyle: {
362
+ width: '600px',
363
+ height: '800px',
364
+ },
365
+ onClose: () => {
366
+ console.log('Modal closed');
367
+ },
368
+ });
369
+ };
370
+ </script>
371
+ </body>
372
+ </html>
373
+ ```
374
+
375
+ ### React Example (Embedded)
376
+
377
+ ```tsx
378
+ import { useEffect, useRef } from 'react';
379
+ import { SwapperIframe } from '@swapper-finance/deposit-sdk';
380
+
381
+ function SwapperWidget() {
382
+ const containerRef = useRef<HTMLDivElement>(null);
383
+ const swapperRef = useRef<SwapperIframe | null>(null);
384
+
385
+ useEffect(() => {
386
+ if (containerRef.current && !swapperRef.current) {
387
+ swapperRef.current = new SwapperIframe({
388
+ container: containerRef.current,
389
+ integratorId: 'your-integrator-id',
390
+ dstChainId: '8453',
391
+ dstTokenAddr: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
392
+ depositWalletAddress: '0x2A018F2506acaEEE2C10632514Fc5DCa9eE2c28A',
393
+ });
394
+ }
395
+
396
+ return () => {
397
+ swapperRef.current?.destroy();
398
+ swapperRef.current = null;
399
+ };
400
+ }, []);
401
+
402
+ return <div ref={containerRef} />;
403
+ }
404
+ ```
@@ -0,0 +1,23 @@
1
+ import { SwapperConfig, SwapperIframeOptions, SwapperEventHandler, SwapperStyles, ContractCall } from "./types";
2
+ export declare class SwapperIframe {
3
+ private iframe;
4
+ private config;
5
+ private iframeUrl;
6
+ private eventHandlers;
7
+ private messageListener?;
8
+ constructor(options: SwapperIframeOptions);
9
+ private validateConfig;
10
+ private createIframe;
11
+ private setupMessageListener;
12
+ mount(container: HTMLElement | string): void;
13
+ updateConfig(config: Partial<SwapperConfig>): void;
14
+ updateStyles(styles: SwapperStyles): void;
15
+ updateCustomContractCalls(customContractCalls: ContractCall[]): void;
16
+ private sendMessage;
17
+ on(eventType: string, handler: SwapperEventHandler): void;
18
+ off(eventType: string, handler: SwapperEventHandler): void;
19
+ getIframe(): HTMLIFrameElement;
20
+ getConfig(): SwapperConfig;
21
+ destroy(): void;
22
+ }
23
+ //# sourceMappingURL=SwapperIframe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwapperIframe.d.ts","sourceRoot":"","sources":["../src/SwapperIframe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EAEnB,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAC;AAUjB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,eAAe,CAAC,CAAgC;gBAM5C,OAAO,EAAE,oBAAoB;IA2BzC,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,YAAY;IA+CpB,OAAO,CAAC,oBAAoB;IAoCrB,KAAK,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;IAqB5C,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IAelD,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAQzC,yBAAyB,CAAC,mBAAmB,EAAE,YAAY,EAAE,GAAG,IAAI;IAO3E,OAAO,CAAC,WAAW;IAUZ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAYzD,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAa1D,SAAS,IAAI,iBAAiB;IAO9B,SAAS,IAAI,aAAa;IAO1B,OAAO,IAAI,IAAI;CAcvB"}
@@ -0,0 +1 @@
1
+ const DEFAULT_IFRAME_URL="https://staging-swapper-deposit-sdk.web.app/";export class SwapperIframe{constructor(t){this.eventHandlers=new Map,this.validateConfig(t),this.config={integratorId:t.integratorId,dstChainId:t.dstChainId,dstTokenAddr:t.dstTokenAddr,depositWalletAddress:t.depositWalletAddress,styles:t.styles,customContractCalls:t.customContractCalls},this.iframeUrl=t.iframeUrl||DEFAULT_IFRAME_URL,this.iframe=this.createIframe(t),this.setupMessageListener(),t.container&&this.mount(t.container)}validateConfig(t){const e=["integratorId","dstChainId","dstTokenAddr","depositWalletAddress"];for(const s of e)if(!t[s])throw new Error(`Missing required parameter: ${s}`)}createIframe(t){const e=document.createElement("iframe"),s=new URL(this.iframeUrl);return s.searchParams.set("integratorId",this.config.integratorId),s.searchParams.set("dstChainId",this.config.dstChainId),s.searchParams.set("dstTokenAddr",this.config.dstTokenAddr),s.searchParams.set("depositWalletAddress",this.config.depositWalletAddress),this.config.styles&&s.searchParams.set("styles",JSON.stringify(this.config.styles)),this.config.customContractCalls&&s.searchParams.set("customContractCalls",JSON.stringify(this.config.customContractCalls)),e.src=s.toString(),e.style.border="none",e.style.width=t.iframeAttributes?.width||"100%",e.style.height=t.iframeAttributes?.height||"600px",e.title=t.iframeAttributes?.title||"Swapper Deposit Widget",t.iframeAttributes&&Object.entries(t.iframeAttributes).forEach(([t,s])=>{s&&"width"!==t&&"height"!==t&&"title"!==t&&e.setAttribute(t,s)}),e}setupMessageListener(){this.messageListener=t=>{const e=new URL(this.iframeUrl).origin;if(t.origin===e&&t.data&&"object"==typeof t.data){const e={type:t.data.type,data:t.data.data},s=this.eventHandlers.get(e.type);s&&s.forEach(t=>t(e));const i=this.eventHandlers.get("*");i&&i.forEach(t=>t(e))}},window.addEventListener("message",this.messageListener)}mount(t){const e="string"==typeof t?document.querySelector(t):t;if(!e)throw new Error(`Container not found: ${"string"==typeof t?t:"provided element"}`);e.appendChild(this.iframe)}updateConfig(t){this.config={...this.config,...t},this.sendMessage({type:"SWAPPER_CONFIG",config:t})}updateStyles(t){this.updateConfig({styles:t})}updateCustomContractCalls(t){this.updateConfig({customContractCalls:t})}sendMessage(t){const e=new URL(this.iframeUrl).origin;this.iframe.contentWindow?.postMessage(t,e)}on(t,e){this.eventHandlers.has(t)||this.eventHandlers.set(t,new Set),this.eventHandlers.get(t).add(e)}off(t,e){const s=this.eventHandlers.get(t);s&&(s.delete(e),0===s.size&&this.eventHandlers.delete(t))}getIframe(){return this.iframe}getConfig(){return{...this.config}}destroy(){this.messageListener&&window.removeEventListener("message",this.messageListener),this.eventHandlers.clear(),this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe)}}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwapperIframe.js","sourceRoot":"","sources":["../src/SwapperIframe.ts"],"names":[],"mappings":"AAYA,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAK1E,MAAM,OAAO,aAAa;IAWxB,YAAY,OAA6B;QAPjC,kBAAa,GAA0C,IAAI,GAAG,EAAE,CAAC;QAQvE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE7B,IAAI,CAAC,MAAM,GAAG;YACZ,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAClD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;SACjD,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAGzC,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAG5B,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAKO,cAAc,CAAC,MAAqB;QAC1C,MAAM,QAAQ,GAAG;YACf,cAAc;YACd,YAAY;YACZ,cAAc;YACd,sBAAsB;SACvB,CAAC;QAEF,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,KAA4B,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;YAC1D,C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,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ import { SwapperIframe } from "./SwapperIframe";
2
+ import { SwapperConfig } from "./types";
3
+ export interface SwapperModalOptions extends Omit<SwapperConfig, "container"> {
4
+ iframeUrl?: string;
5
+ iframeAttributes?: {
6
+ width?: string;
7
+ height?: string;
8
+ title?: string;
9
+ allow?: string;
10
+ sandbox?: string;
11
+ [key: string]: string | undefined;
12
+ };
13
+ modalStyle?: {
14
+ overlayColor?: string;
15
+ width?: string;
16
+ height?: string;
17
+ borderRadius?: string;
18
+ zIndex?: number;
19
+ showCloseButton?: boolean;
20
+ };
21
+ onClose?: () => void;
22
+ }
23
+ export declare class SwapperModal {
24
+ private iframe;
25
+ private overlay;
26
+ private modalContainer;
27
+ private iframeContainer;
28
+ private options;
29
+ private isOpen;
30
+ constructor(options: SwapperModalOptions);
31
+ open(): void;
32
+ close(): void;
33
+ isModalOpen(): boolean;
34
+ getIframe(): SwapperIframe | null;
35
+ private createModal;
36
+ private destroyModal;
37
+ destroy(): void;
38
+ }
39
+ export declare function openSwapperModal(options: SwapperModalOptions): SwapperModal;
40
+ //# sourceMappingURL=SwapperModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwapperModal.d.ts","sourceRoot":"","sources":["../src/SwapperModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKxC,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC;IAI3E,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,gBAAgB,CAAC,EAAE;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KACnC,CAAC;IAKF,UAAU,CAAC,EAAE;QAIX,YAAY,CAAC,EAAE,MAAM,CAAC;QAKtB,KAAK,CAAC,EAAE,MAAM,CAAC;QAKf,MAAM,CAAC,EAAE,MAAM,CAAC;QAKhB,YAAY,CAAC,EAAE,MAAM,CAAC;QAKtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAKhB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;IAKF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAKD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,MAAM,CAAkB;gBAEpB,OAAO,EAAE,mBAAmB;IAOjC,IAAI,IAAI,IAAI;IAYZ,KAAK,IAAI,IAAI;IAgBb,WAAW,IAAI,OAAO;IAOtB,SAAS,IAAI,aAAa,GAAG,IAAI;IAOxC,OAAO,CAAC,WAAW;IA0InB,OAAO,CAAC,YAAY;IAwBb,OAAO,IAAI,IAAI;CAGvB;AAOD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAI3E"}
@@ -0,0 +1 @@
1
+ import{SwapperIframe}from"./SwapperIframe";export class SwapperModal{constructor(e){this.iframe=null,this.overlay=null,this.modalContainer=null,this.iframeContainer=null,this.isOpen=!1,this.options=e}open(){this.isOpen||(this.createModal(),this.isOpen=!0)}close(){this.isOpen&&(this.destroyModal(),this.isOpen=!1,this.options.onClose&&this.options.onClose())}isModalOpen(){return this.isOpen}getIframe(){return this.iframe}createModal(){const e=this.options.modalStyle||{};if(this.overlay=document.createElement("div"),this.overlay.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: ${e.overlayColor||"rgba(0, 0, 0, 0.7)"};\n z-index: ${e.zIndex||1e4};\n display: flex;\n align-items: center;\n justify-content: center;\n animation: swapper-fade-in 0.2s ease-out;\n `,!document.getElementById("swapper-modal-styles")){const e=document.createElement("style");e.id="swapper-modal-styles",e.textContent="\n @keyframes swapper-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes swapper-scale-in {\n from {\n transform: scale(0.95);\n opacity: 0;\n }\n to {\n transform: scale(1);\n opacity: 1;\n }\n }\n ",document.head.appendChild(e)}this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.close()});const t=e=>{"Escape"===e.key&&(this.close(),document.removeEventListener("keydown",t))};if(document.addEventListener("keydown",t),this.modalContainer=document.createElement("div"),this.modalContainer.style.cssText=`\n position: relative;\n width: ${e.width||"480px"};\n height: ${e.height||"560px"};\n background: transparent;\n border-radius: ${e.borderRadius||"16px"};\n overflow: hidden;\n animation: swapper-scale-in 0.3s ease-out;\n `,!0===e.showCloseButton){const t=document.createElement("button");t.innerHTML="×",t.style.cssText=`\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n border: none;\n background: rgba(0, 0, 0, 0.5);\n color: white;\n font-size: 24px;\n line-height: 1;\n border-radius: 50%;\n cursor: pointer;\n z-index: ${(e.zIndex||1e4)+1};\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s ease;\n `,t.onmouseover=()=>{t.style.background="rgba(0, 0, 0, 0.7)"},t.onmouseout=()=>{t.style.background="rgba(0, 0, 0, 0.5)"},t.onclick=()=>this.close(),this.modalContainer.appendChild(t)}this.iframeContainer=document.createElement("div"),this.iframeContainer.style.cssText="\n width: 100%;\n height: 100%;\n ",this.modalContainer.appendChild(this.iframeContainer),this.overlay.appendChild(this.modalContainer),document.body.appendChild(this.overlay),document.body.style.overflow="hidden",this.iframe=new SwapperIframe({container:this.iframeContainer,integratorId:this.options.integratorId,dstChainId:this.options.dstChainId,dstTokenAddr:this.options.dstTokenAddr,depositWalletAddress:this.options.depositWalletAddress,styles:this.options.styles,customContractCalls:this.options.customContractCalls,iframeUrl:this.options.iframeUrl,iframeAttributes:{...this.options.iframeAttributes,width:"100%",height:"100%"}})}destroyModal(){this.iframe&&(this.iframe.destroy(),this.iframe=null),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay),document.body.style.overflow="",this.overlay=null,this.modalContainer=null,this.iframeContainer=null}destroy(){this.close()}}export function openSwapperModal(e){const t=new SwapperModal(e);return t.open(),t}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwapperModal.js","sourceRoot":"","sources":["../src/SwapperModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAoEhD,MAAM,OAAO,YAAY;IAQvB,YAAY,OAA4B;QAPhC,WAAM,GAAyB,IAAI,CAAC;QACpC,YAAO,GAA0B,IAAI,CAAC;QACtC,mBAAc,GAA0B,IAAI,CAAC;QAC7C,oBAAe,GAA0B,IAAI,CAAC;QAE9C,WAAM,GAAY,KAAK,CAAC;QAG9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKM,IAAI;QACT,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAKM,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACzB,IA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GlC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC9B,CAAC;IAKM,OAAO;QACZ,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AAOD,MAAM,UAAU,gBAAgB,CAAC,OAA4B;IAC3D,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC,KAAK,CAAC,IAAI,EAAE,CAAC;IACb,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { SwapperIframe } from "./SwapperIframe";
2
+ export { SwapperModal, openSwapperModal } from "./SwapperModal";
3
+ export type { SwapperModalOptions } from "./SwapperModal";
4
+ export { ThemeMode, BrandTheme, ComponentStyles, SwapperStyles, ContractCallType, ContractCall, SwapperConfig, SwapperIframeOptions, SwapperEvent, SwapperEventHandler, } from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,SAAS,EACT,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export{SwapperIframe}from"./SwapperIframe";export{SwapperModal,openSwapperModal}from"./SwapperModal";export{ContractCallType}from"./types";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAKL,gBAAgB,GAMjB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,68 @@
1
+ export type ThemeMode = "light" | "dark";
2
+ export interface BrandTheme {
3
+ primaryColor?: string;
4
+ secondaryColor?: string;
5
+ }
6
+ export interface ComponentStyles {
7
+ backgroundColor?: string;
8
+ borderRadius?: string;
9
+ width?: string;
10
+ textColor?: string;
11
+ primaryButtonBackground?: string;
12
+ primaryButtonText?: string;
13
+ secondaryButtonBackground?: string;
14
+ secondaryButtonText?: string;
15
+ disabledButtonBackground?: string;
16
+ disabledButtonText?: string;
17
+ successColor?: string;
18
+ warningColor?: string;
19
+ errorColor?: string;
20
+ primaryColor?: string;
21
+ secondaryColor?: string;
22
+ inputBackground?: string;
23
+ inputBorder?: string;
24
+ cardBackground?: string;
25
+ borderColor?: string;
26
+ }
27
+ export interface SwapperStyles {
28
+ themeMode?: ThemeMode;
29
+ brandTheme?: BrandTheme;
30
+ componentStyles?: ComponentStyles;
31
+ }
32
+ export declare enum ContractCallType {
33
+ CALL = 0,
34
+ DELEGATE_CALL = 1
35
+ }
36
+ export interface ContractCall {
37
+ callType: ContractCallType;
38
+ target: string;
39
+ value: string;
40
+ callData: string;
41
+ payload: string;
42
+ }
43
+ export interface SwapperConfig {
44
+ integratorId: string;
45
+ dstChainId: string;
46
+ dstTokenAddr: string;
47
+ depositWalletAddress: string;
48
+ styles?: SwapperStyles;
49
+ customContractCalls?: ContractCall[];
50
+ }
51
+ export interface SwapperIframeOptions extends SwapperConfig {
52
+ container?: HTMLElement | string;
53
+ iframeUrl?: string;
54
+ iframeAttributes?: {
55
+ width?: string;
56
+ height?: string;
57
+ title?: string;
58
+ allow?: string;
59
+ sandbox?: string;
60
+ [key: string]: string | undefined;
61
+ };
62
+ }
63
+ export interface SwapperEvent {
64
+ type: string;
65
+ data?: unknown;
66
+ }
67
+ export type SwapperEventHandler = (event: SwapperEvent) => void;
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAKzC,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD,MAAM,WAAW,eAAe;IAE9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAG5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,MAAM,WAAW,aAAa;IAI5B,SAAS,CAAC,EAAE,SAAS,CAAC;IAKtB,UAAU,CAAC,EAAE,UAAU,CAAC;IAKxB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAK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file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAwEA,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uDAAQ,CAAA;IACR,yEAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@swapper-finance/deposit-sdk",
3
+ "version": "0.0.2",
4
+ "description": "Easy iframe embedding for Swapper deposit widget with full TypeScript support",
5
+ "license": "ISC",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc && npm run minify",
16
+ "minify": "terser dist/SwapperIframe.js -o dist/SwapperIframe.js --compress --mangle && terser dist/SwapperModal.js -o dist/SwapperModal.js --compress --mangle && terser dist/types.js -o dist/types.js --compress --mangle && terser dist/index.js -o dist/index.js --compress --mangle",
17
+ "prepare": "npm run build",
18
+ "clean": "rm -rf dist",
19
+ "watch": "tsc --watch",
20
+ "test": "echo \"Error: no test specified\" && exit 1"
21
+ },
22
+ "keywords": [
23
+ "swapper",
24
+ "deposit",
25
+ "iframe",
26
+ "widget",
27
+ "sdk",
28
+ "embed",
29
+ "crypto",
30
+ "blockchain",
31
+ "web3"
32
+ ],
33
+ "devDependencies": {
34
+ "terser": "^5.27.0",
35
+ "typescript": "^5.3.3"
36
+ },
37
+ "engines": {
38
+ "node": ">=14.0.0"
39
+ }
40
+ }