@rash2x/bridge-widget 0.2.3 → 0.2.11

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/README.md CHANGED
@@ -47,24 +47,42 @@ npm install @tonconnect/ui-react @ton/core @ton/crypto @ton/ton
47
47
  npm install @tronweb3/tronwallet-adapter-react-hooks @tronweb3/tronwallet-adapters tronweb
48
48
  ```
49
49
 
50
+ ### Required shadcn/ui Components
51
+
52
+ This library requires certain shadcn/ui components to be installed in your project. The library does **not bundle** these components to avoid duplication and allow you to use your own styled versions.
53
+
54
+ **Required components:** `accordion`, `button`, `card`, `dialog`, `input`, `skeleton`, `switch`, `tooltip`
55
+
56
+ Install them using shadcn CLI:
57
+
58
+ ```bash
59
+ npx shadcn@latest add accordion button card dialog input skeleton switch tooltip
60
+ ```
61
+
62
+ **Important:** Your project must have the following path aliases configured:
63
+
64
+ - `@/components/ui` - for UI components
65
+ - `@/lib/utils` - for the `cn` utility function
66
+
67
+ For detailed setup instructions, see [SHADCN_COMPONENTS.md](./SHADCN_COMPONENTS.md).
68
+
50
69
  ## Quick Start
51
70
 
52
71
  ### 1. Basic Setup
53
72
 
54
73
  ```tsx
55
- import { EvaaBridge } from '@evaa/bridge-widget';
56
- import '@evaa/bridge-widget/styles.css';
57
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
58
- import { WagmiProvider } from 'wagmi';
59
- import { TonConnectUIProvider } from '@tonconnect/ui-react';
60
- import { WalletProvider } from '@tronweb3/tronwallet-adapter-react-hooks';
61
- import { TronLinkAdapter } from '@tronweb3/tronwallet-adapters';
62
- import { useMemo } from 'react';
74
+ import { EvaaBridge } from "@evaa/bridge-widget";
75
+ import "@evaa/bridge-widget/styles.css";
76
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
77
+ import { WagmiProvider } from "wagmi";
78
+ import { TonConnectUIProvider } from "@tonconnect/ui-react";
79
+ import { WalletProvider } from "@tronweb3/tronwallet-adapter-react-hooks";
80
+ import { TronLinkAdapter } from "@tronweb3/tronwallet-adapters";
81
+ import { useMemo } from "react";
63
82
 
64
83
  const queryClient = new QueryClient();
65
84
 
66
85
  function App() {
67
- // Configure Tron wallet adapters
68
86
  const tronAdapters = useMemo(() => [new TronLinkAdapter()], []);
69
87
 
70
88
  return (
@@ -87,19 +105,19 @@ function App() {
87
105
  <EvaaBridge
88
106
  defaultLanguage="ru" // Set default language (en, ru)
89
107
  onSwapSuccess={(data) => {
90
- console.log('Swap completed:', data);
108
+ console.log("Swap completed:", data);
91
109
  }}
92
110
  onSwapError={(error) => {
93
- console.error('Swap failed:', error);
111
+ console.error("Swap failed:", error);
94
112
  }}
95
113
  onInitialized={() => {
96
- console.log('Bridge initialized');
114
+ console.log("Bridge initialized");
97
115
  }}
98
116
  onAmountChange={(amount) => {
99
- console.log('Amount changed:', amount);
117
+ console.log("Amount changed:", amount);
100
118
  }}
101
119
  onChainChange={(data) => {
102
- console.log('Chain changed:', data);
120
+ console.log("Chain changed:", data);
103
121
  }}
104
122
  />
105
123
  ```
@@ -108,32 +126,32 @@ function App() {
108
126
 
109
127
  ### EvaaBridgeProps
110
128
 
111
- | Prop | Type | Description |
112
- |------|------|-------------|
113
- | `className` | `string` | Optional CSS class for custom styling |
114
- | `defaultLanguage` | `string` | Language for the widget UI (default: `'en'`). Supported: `'en'`, `'ru'` |
115
- | `tonClient` | `TonClient` | Optional TON client instance |
116
- | `tonApiKey` | `string` | Optional TON API key |
117
- | `onInitialized` | `() => void` | Callback when bridge is initialized |
118
- | `onSwapStart` | `(data: SwapStartData) => void` | Callback when swap starts |
119
- | `onSwapSuccess` | `(data: SwapSuccessData) => void` | Callback when swap succeeds |
120
- | `onSwapError` | `(error: SwapErrorData) => void` | Callback when swap fails |
121
- | `onAmountChange` | `(amount: string) => void` | Callback when amount changes |
122
- | `onChainChange` | `(data: ChainChangeData) => void` | Callback when chain changes |
129
+ | Prop | Type | Description |
130
+ | ----------------- | --------------------------------- | ----------------------------------------------------------------------- |
131
+ | `className` | `string` | Optional CSS class for custom styling |
132
+ | `defaultLanguage` | `string` | Language for the widget UI (default: `'en'`). Supported: `'en'`, `'ru'` |
133
+ | `tonClient` | `TonClient` | Optional TON client instance |
134
+ | `tonApiKey` | `string` | Optional TON API key |
135
+ | `onInitialized` | `() => void` | Callback when bridge is initialized |
136
+ | `onSwapStart` | `(data: SwapStartData) => void` | Callback when swap starts |
137
+ | `onSwapSuccess` | `(data: SwapSuccessData) => void` | Callback when swap succeeds |
138
+ | `onSwapError` | `(error: SwapErrorData) => void` | Callback when swap fails |
139
+ | `onAmountChange` | `(amount: string) => void` | Callback when amount changes |
140
+ | `onChainChange` | `(data: ChainChangeData) => void` | Callback when chain changes |
123
141
 
124
142
  ## Configuration
125
143
 
126
144
  ### Wagmi Config (for EVM chains)
127
145
 
128
146
  ```tsx
129
- import { createConfig } from 'wagmi';
130
- import { getDefaultConfig } from 'connectkit';
131
- import { mainnet, arbitrum, polygon, base, bsc } from 'wagmi/chains';
147
+ import { createConfig } from "wagmi";
148
+ import { getDefaultConfig } from "connectkit";
149
+ import { mainnet, arbitrum, polygon, base, bsc } from "wagmi/chains";
132
150
 
133
151
  const wagmiConfig = createConfig(
134
152
  getDefaultConfig({
135
- appName: 'Your App Name',
136
- walletConnectProjectId: 'YOUR_PROJECT_ID',
153
+ appName: "Your App Name",
154
+ walletConnectProjectId: "YOUR_PROJECT_ID",
137
155
  chains: [mainnet, arbitrum, polygon, base, bsc],
138
156
  })
139
157
  );
@@ -156,20 +174,21 @@ Create a `tonconnect-manifest.json` file:
156
174
  Configure Tron wallet adapters using the official `@tronweb3/tronwallet-adapter-react-hooks`:
157
175
 
158
176
  ```tsx
159
- import { WalletProvider } from '@tronweb3/tronwallet-adapter-react-hooks';
160
- import { TronLinkAdapter } from '@tronweb3/tronwallet-adapters';
161
- import { useMemo } from 'react';
177
+ import { WalletProvider } from "@tronweb3/tronwallet-adapter-react-hooks";
178
+ import { TronLinkAdapter } from "@tronweb3/tronwallet-adapters";
179
+ import { useMemo } from "react";
162
180
 
163
181
  function App() {
164
- const tronAdapters = useMemo(() => [
165
- new TronLinkAdapter(),
166
- // You can add other adapters here
167
- ], []);
182
+ const tronAdapters = useMemo(
183
+ () => [
184
+ new TronLinkAdapter(),
185
+ // You can add other adapters here
186
+ ],
187
+ []
188
+ );
168
189
 
169
190
  return (
170
- <WalletProvider adapters={tronAdapters}>
171
- {/* Your app */}
172
- </WalletProvider>
191
+ <WalletProvider adapters={tronAdapters}>{/* Your app */}</WalletProvider>
173
192
  );
174
193
  }
175
194
  ```
@@ -183,7 +202,7 @@ The widget comes with pre-compiled Tailwind CSS styles. **You don't need to have
183
202
  Simply import the styles and you're good to go:
184
203
 
185
204
  ```tsx
186
- import '@evaa/bridge-widget/styles.css';
205
+ import "@evaa/bridge-widget/styles.css";
187
206
  ```
188
207
 
189
208
  All Tailwind utility classes used by the widget are already included in the compiled CSS. The widget has its own Tailwind configuration that ensures all necessary classes are bundled during the library build process.
@@ -194,12 +213,12 @@ Customize the widget's appearance by overriding CSS variables in your own styles
194
213
 
195
214
  ```css
196
215
  :root {
197
- --primary: #0095f9; /* Primary brand color */
198
- --background: #ffffff; /* Background color */
199
- --foreground: #171717; /* Text color */
200
- --card: #f2f2f2; /* Card background */
201
- --border: #00000029; /* Border color */
202
- --radius: 0.625rem; /* Border radius */
216
+ --primary: #0095f9; /* Primary brand color */
217
+ --background: #ffffff; /* Background color */
218
+ --foreground: #171717; /* Text color */
219
+ --card: #f2f2f2; /* Card background */
220
+ --border: #00000029; /* Border color */
221
+ --radius: 0.625rem; /* Border radius */
203
222
  /* ... see dist/styles.css for all available variables */
204
223
  }
205
224
 
@@ -212,6 +231,7 @@ Customize the widget's appearance by overriding CSS variables in your own styles
212
231
  ```
213
232
 
214
233
  **Complete list of customizable CSS variables:**
234
+
215
235
  - Color tokens: `--background`, `--foreground`, `--primary`, `--secondary`, `--muted`, `--accent`, `--destructive`, `--border`, `--input`, `--ring`
216
236
  - Semantic colors: `--link`, `--filter`, `--swap`, `--settings-button`, `--modal-x`, `--input-icon`, `--balance-icon`, and many more
217
237
  - Border radius: `--radius` (affects all rounded corners)
@@ -227,8 +247,8 @@ Customize the widget's appearance by overriding CSS variables in your own styles
227
247
  import {
228
248
  useChainsStore,
229
249
  useTokensStore,
230
- useBridgeQuoteStore
231
- } from '@evaa/bridge-widget';
250
+ useBridgeQuoteStore,
251
+ } from "@evaa/bridge-widget";
232
252
 
233
253
  function YourComponent() {
234
254
  const { chains } = useChainsStore();
@@ -247,8 +267,8 @@ import type {
247
267
  Token,
248
268
  Quote,
249
269
  EvaaBridgeProps,
250
- SwapSuccessData
251
- } from '@evaa/bridge-widget';
270
+ SwapSuccessData,
271
+ } from "@evaa/bridge-widget";
252
272
  ```
253
273
 
254
274
  ## Supported Chains
@@ -264,6 +284,7 @@ import type {
264
284
  ## API Integration
265
285
 
266
286
  The widget integrates with Stargate Protocol API for:
287
+
267
288
  - Cross-chain token swaps
268
289
  - Real-time quotes
269
290
  - Transaction routing
@@ -274,7 +295,7 @@ The widget integrates with Stargate Protocol API for:
274
295
  The package is written in TypeScript and includes full type definitions.
275
296
 
276
297
  ```tsx
277
- import type { EvaaBridgeProps, Chain, Token } from '@evaa/bridge-widget';
298
+ import type { EvaaBridgeProps, Chain, Token } from "@evaa/bridge-widget";
278
299
  ```
279
300
 
280
301
  ## Browser Support
@@ -317,5 +338,6 @@ MIT © EVAA Finance
317
338
  ## Support
318
339
 
319
340
  For issues and questions:
341
+
320
342
  - GitHub Issues: https://github.com/evaa-finance/bridge-widget/issues
321
343
  - Email: support@evaa.finance