@rash2x/bridge-widget 0.2.10 → 0.3.0
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 +2 -0
- package/README.md +126 -157
- package/dist/evaa-bridge.cjs +1402 -673
- package/dist/evaa-bridge.cjs.map +1 -1
- package/dist/evaa-bridge.mjs +1406 -677
- package/dist/evaa-bridge.mjs.map +1 -1
- package/dist/index.d.ts +63 -3
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/assets/fonts/Gilroy-Black.ttf +0 -0
- package/dist/assets/fonts/Gilroy-Bold.ttf +0 -0
- package/dist/assets/fonts/Gilroy-ExtraBold.ttf +0 -0
- package/dist/assets/fonts/Gilroy-Heavy.ttf +0 -0
- package/dist/assets/fonts/Gilroy-Light.ttf +0 -0
- package/dist/assets/fonts/Gilroy-Medium.ttf +0 -0
- package/dist/assets/fonts/Gilroy-Regular.ttf +0 -0
- package/dist/assets/fonts/Gilroy-SemiBold.ttf +0 -0
- package/dist/assets/fonts/Gilroy-Thin.ttf +0 -0
- package/dist/assets/fonts/Gilroy-UltraLight.ttf +0 -0
- package/dist/assets/fonts/fonts.css +0 -81
- package/dist/assets/fonts/hanson-bold.woff +0 -0
- package/dist/assets/fonts/hanson-bold.woff2 +0 -0
package/LICENSE
CHANGED
|
@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Made by https://t.me/rashdeva special for EVAA
|
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ npx shadcn@latest add accordion button card dialog input skeleton switch tooltip
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
**Important:** Your project must have the following path aliases configured:
|
|
63
|
+
|
|
63
64
|
- `@/components/ui` - for UI components
|
|
64
65
|
- `@/lib/utils` - for the `cn` utility function
|
|
65
66
|
|
|
@@ -70,33 +71,113 @@ For detailed setup instructions, see [SHADCN_COMPONENTS.md](./SHADCN_COMPONENTS.
|
|
|
70
71
|
### 1. Basic Setup
|
|
71
72
|
|
|
72
73
|
```tsx
|
|
73
|
-
import {
|
|
74
|
-
import '
|
|
75
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
76
|
-
import { WagmiProvider } from 'wagmi';
|
|
77
|
-
import { TonConnectUIProvider } from '@tonconnect/ui-react';
|
|
74
|
+
import { animated, useSpring } from '@react-spring/web';
|
|
75
|
+
import { useTranslation } from 'react-i18next';
|
|
78
76
|
import { WalletProvider } from '@tronweb3/tronwallet-adapter-react-hooks';
|
|
79
77
|
import { TronLinkAdapter } from '@tronweb3/tronwallet-adapters';
|
|
78
|
+
import { ConnectKitProvider } from 'connectkit';
|
|
79
|
+
import { EvaaBridge } from '@rash2x/bridge-widget';
|
|
80
|
+
import { TransactionConfirmVector } from '@/components/vectors/TransactionConfirm';
|
|
81
|
+
import { TransactionProgressVector } from '@/components/vectors/TransactionProgress';
|
|
82
|
+
import { TransactionSuccessVector } from '@/components/vectors/TransactionSuccess';
|
|
83
|
+
import Fireworks from 'react-canvas-confetti/dist/presets/fireworks';
|
|
84
|
+
import { TransactionFailedVector } from '@/components/vectors/TransactionFailed';
|
|
80
85
|
import { useMemo } from 'react';
|
|
86
|
+
import { WagmiProvider, createConfig, http } from 'wagmi';
|
|
87
|
+
import { mainnet, arbitrum, polygon, base, bsc } from 'wagmi/chains';
|
|
88
|
+
import { injected, walletConnect, metaMask } from 'wagmi/connectors';
|
|
89
|
+
import { Card } from '@/components/ui/card';
|
|
90
|
+
|
|
91
|
+
const walletConnectProjectId = import.meta.env.VITE_WALLETCONNECT_PROJECT_ID || '5e81fa2f7739ab20482103c77a1b5cbf';
|
|
92
|
+
|
|
93
|
+
const config = createConfig({
|
|
94
|
+
chains: [mainnet, arbitrum, polygon, base, bsc],
|
|
95
|
+
connectors: [injected(), metaMask(), walletConnect({ projectId: walletConnectProjectId })],
|
|
96
|
+
transports: {
|
|
97
|
+
[mainnet.id]: http(),
|
|
98
|
+
[arbitrum.id]: http(),
|
|
99
|
+
[polygon.id]: http(),
|
|
100
|
+
[base.id]: http(),
|
|
101
|
+
[bsc.id]: http()
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export const BridgePage = () => {
|
|
106
|
+
const { t, i18n } = useTranslation();
|
|
107
|
+
const [props] = useSpring(() => ({
|
|
108
|
+
from: { opacity: 0 },
|
|
109
|
+
to: { opacity: 1 }
|
|
110
|
+
}));
|
|
81
111
|
|
|
82
|
-
const queryClient = new QueryClient();
|
|
83
|
-
|
|
84
|
-
function App() {
|
|
85
|
-
// Configure Tron wallet adapters
|
|
86
112
|
const tronAdapters = useMemo(() => [new TronLinkAdapter()], []);
|
|
87
113
|
|
|
114
|
+
const transactionIcons = useMemo(
|
|
115
|
+
() => ({
|
|
116
|
+
confirm: (
|
|
117
|
+
<>
|
|
118
|
+
<TransactionConfirmVector />
|
|
119
|
+
<div className="on-circle on-circle-confirm-small under-noise"></div>
|
|
120
|
+
<div className="on-circle on-circle-confirm-big under-noise"></div>
|
|
121
|
+
</>
|
|
122
|
+
),
|
|
123
|
+
progress: (
|
|
124
|
+
<>
|
|
125
|
+
<TransactionProgressVector className="progress-rocket" />
|
|
126
|
+
<div className="on-circle on-circle-progress-small under-noise"></div>
|
|
127
|
+
<div className="on-circle on-circle-progress-big under-noise"></div>
|
|
128
|
+
<div className="meteors-container under-noise">
|
|
129
|
+
<span></span>
|
|
130
|
+
<span></span>
|
|
131
|
+
<span></span>
|
|
132
|
+
<span></span>
|
|
133
|
+
<span></span>
|
|
134
|
+
<span></span>
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
),
|
|
138
|
+
success: (
|
|
139
|
+
<>
|
|
140
|
+
<TransactionSuccessVector />
|
|
141
|
+
<Fireworks
|
|
142
|
+
autorun={{
|
|
143
|
+
speed: 3,
|
|
144
|
+
duration: 1000,
|
|
145
|
+
delay: 300
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
<div className="on-circle on-circle-success-small under-noise"></div>
|
|
149
|
+
<div className="on-circle on-circle-success-big under-noise"></div>
|
|
150
|
+
</>
|
|
151
|
+
),
|
|
152
|
+
failed: (
|
|
153
|
+
<>
|
|
154
|
+
<TransactionFailedVector />
|
|
155
|
+
<div className="on-circle on-circle-failed-small under-noise"></div>
|
|
156
|
+
<div className="on-circle on-circle-failed-big under-noise"></div>
|
|
157
|
+
</>
|
|
158
|
+
)
|
|
159
|
+
}),
|
|
160
|
+
[]
|
|
161
|
+
);
|
|
162
|
+
|
|
88
163
|
return (
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
164
|
+
<animated.div style={props} className="space-y-4 pb-5 overflow-auto">
|
|
165
|
+
<Card className="bg-master rounded-lg py-6 px-5 md:grid md:grid-cols-2 gap-8 lg:gap-10">
|
|
166
|
+
<header className="px-5 space-y-3 md:px-0">
|
|
167
|
+
<h1 className="font-display font-black shrink-0 text-5xl">{t('bridge')}</h1>
|
|
168
|
+
<p className="text-sm text-muted-foreground">{t('bridgeDescription')}</p>
|
|
169
|
+
</header>
|
|
170
|
+
<WagmiProvider config={config}>
|
|
171
|
+
<ConnectKitProvider>
|
|
172
|
+
<WalletProvider adapters={tronAdapters} disableAutoConnectOnLoad={true}>
|
|
173
|
+
<EvaaBridge defaultLanguage={i18n.language} transactionIcons={transactionIcons} />
|
|
174
|
+
</WalletProvider>
|
|
175
|
+
</ConnectKitProvider>
|
|
176
|
+
</WagmiProvider>
|
|
177
|
+
</Card>
|
|
178
|
+
</animated.div>
|
|
98
179
|
);
|
|
99
|
-
}
|
|
180
|
+
};
|
|
100
181
|
```
|
|
101
182
|
|
|
102
183
|
### 2. With Event Handlers and Language
|
|
@@ -105,19 +186,19 @@ function App() {
|
|
|
105
186
|
<EvaaBridge
|
|
106
187
|
defaultLanguage="ru" // Set default language (en, ru)
|
|
107
188
|
onSwapSuccess={(data) => {
|
|
108
|
-
console.log(
|
|
189
|
+
console.log("Swap completed:", data);
|
|
109
190
|
}}
|
|
110
191
|
onSwapError={(error) => {
|
|
111
|
-
console.error(
|
|
192
|
+
console.error("Swap failed:", error);
|
|
112
193
|
}}
|
|
113
194
|
onInitialized={() => {
|
|
114
|
-
console.log(
|
|
195
|
+
console.log("Bridge initialized");
|
|
115
196
|
}}
|
|
116
197
|
onAmountChange={(amount) => {
|
|
117
|
-
console.log(
|
|
198
|
+
console.log("Amount changed:", amount);
|
|
118
199
|
}}
|
|
119
200
|
onChainChange={(data) => {
|
|
120
|
-
console.log(
|
|
201
|
+
console.log("Chain changed:", data);
|
|
121
202
|
}}
|
|
122
203
|
/>
|
|
123
204
|
```
|
|
@@ -126,85 +207,18 @@ function App() {
|
|
|
126
207
|
|
|
127
208
|
### EvaaBridgeProps
|
|
128
209
|
|
|
129
|
-
| Prop
|
|
130
|
-
|
|
131
|
-
| `className`
|
|
132
|
-
| `defaultLanguage` | `string`
|
|
133
|
-
| `tonClient`
|
|
134
|
-
| `tonApiKey`
|
|
135
|
-
| `onInitialized`
|
|
136
|
-
| `onSwapStart`
|
|
137
|
-
| `onSwapSuccess`
|
|
138
|
-
| `onSwapError`
|
|
139
|
-
| `onAmountChange`
|
|
140
|
-
| `onChainChange`
|
|
141
|
-
|
|
142
|
-
## Configuration
|
|
143
|
-
|
|
144
|
-
### Wagmi Config (for EVM chains)
|
|
145
|
-
|
|
146
|
-
```tsx
|
|
147
|
-
import { createConfig } from 'wagmi';
|
|
148
|
-
import { getDefaultConfig } from 'connectkit';
|
|
149
|
-
import { mainnet, arbitrum, polygon, base, bsc } from 'wagmi/chains';
|
|
150
|
-
|
|
151
|
-
const wagmiConfig = createConfig(
|
|
152
|
-
getDefaultConfig({
|
|
153
|
-
appName: 'Your App Name',
|
|
154
|
-
walletConnectProjectId: 'YOUR_PROJECT_ID',
|
|
155
|
-
chains: [mainnet, arbitrum, polygon, base, bsc],
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### TonConnect Manifest
|
|
161
|
-
|
|
162
|
-
Create a `tonconnect-manifest.json` file:
|
|
163
|
-
|
|
164
|
-
```json
|
|
165
|
-
{
|
|
166
|
-
"url": "https://your-app.com",
|
|
167
|
-
"name": "Your App Name",
|
|
168
|
-
"iconUrl": "https://your-app.com/icon.png"
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Tron Wallet Adapters
|
|
173
|
-
|
|
174
|
-
Configure Tron wallet adapters using the official `@tronweb3/tronwallet-adapter-react-hooks`:
|
|
175
|
-
|
|
176
|
-
```tsx
|
|
177
|
-
import { WalletProvider } from '@tronweb3/tronwallet-adapter-react-hooks';
|
|
178
|
-
import { TronLinkAdapter } from '@tronweb3/tronwallet-adapters';
|
|
179
|
-
import { useMemo } from 'react';
|
|
180
|
-
|
|
181
|
-
function App() {
|
|
182
|
-
const tronAdapters = useMemo(() => [
|
|
183
|
-
new TronLinkAdapter(),
|
|
184
|
-
// You can add other adapters here
|
|
185
|
-
], []);
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<WalletProvider adapters={tronAdapters}>
|
|
189
|
-
{/* Your app */}
|
|
190
|
-
</WalletProvider>
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Styling
|
|
196
|
-
|
|
197
|
-
The widget comes with pre-compiled Tailwind CSS styles. **You don't need to have Tailwind installed** in your project for the widget to work.
|
|
198
|
-
|
|
199
|
-
### Basic Usage
|
|
200
|
-
|
|
201
|
-
Simply import the styles and you're good to go:
|
|
202
|
-
|
|
203
|
-
```tsx
|
|
204
|
-
import '@evaa/bridge-widget/styles.css';
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
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.
|
|
210
|
+
| Prop | Type | Description |
|
|
211
|
+
| ----------------- | --------------------------------- | ----------------------------------------------------------------------- |
|
|
212
|
+
| `className` | `string` | Optional CSS class for custom styling |
|
|
213
|
+
| `defaultLanguage` | `string` | Language for the widget UI (default: `'en'`). Supported: `'en'`, `'ru'` |
|
|
214
|
+
| `tonClient` | `TonClient` | Optional TON client instance |
|
|
215
|
+
| `tonApiKey` | `string` | Optional TON API key |
|
|
216
|
+
| `onInitialized` | `() => void` | Callback when bridge is initialized |
|
|
217
|
+
| `onSwapStart` | `(data: SwapStartData) => void` | Callback when swap starts |
|
|
218
|
+
| `onSwapSuccess` | `(data: SwapSuccessData) => void` | Callback when swap succeeds |
|
|
219
|
+
| `onSwapError` | `(error: SwapErrorData) => void` | Callback when swap fails |
|
|
220
|
+
| `onAmountChange` | `(amount: string) => void` | Callback when amount changes |
|
|
221
|
+
| `onChainChange` | `(data: ChainChangeData) => void` | Callback when chain changes |
|
|
208
222
|
|
|
209
223
|
### Theme Customization
|
|
210
224
|
|
|
@@ -212,12 +226,12 @@ Customize the widget's appearance by overriding CSS variables in your own styles
|
|
|
212
226
|
|
|
213
227
|
```css
|
|
214
228
|
:root {
|
|
215
|
-
--primary: #0095f9;
|
|
216
|
-
--background: #ffffff;
|
|
217
|
-
--foreground: #171717;
|
|
218
|
-
--card: #f2f2f2;
|
|
219
|
-
--border: #00000029;
|
|
220
|
-
--radius: 0.625rem;
|
|
229
|
+
--primary: #0095f9; /* Primary brand color */
|
|
230
|
+
--background: #ffffff; /* Background color */
|
|
231
|
+
--foreground: #171717; /* Text color */
|
|
232
|
+
--card: #f2f2f2; /* Card background */
|
|
233
|
+
--border: #00000029; /* Border color */
|
|
234
|
+
--radius: 0.625rem; /* Border radius */
|
|
221
235
|
/* ... see dist/styles.css for all available variables */
|
|
222
236
|
}
|
|
223
237
|
|
|
@@ -229,46 +243,6 @@ Customize the widget's appearance by overriding CSS variables in your own styles
|
|
|
229
243
|
}
|
|
230
244
|
```
|
|
231
245
|
|
|
232
|
-
**Complete list of customizable CSS variables:**
|
|
233
|
-
- Color tokens: `--background`, `--foreground`, `--primary`, `--secondary`, `--muted`, `--accent`, `--destructive`, `--border`, `--input`, `--ring`
|
|
234
|
-
- Semantic colors: `--link`, `--filter`, `--swap`, `--settings-button`, `--modal-x`, `--input-icon`, `--balance-icon`, and many more
|
|
235
|
-
- Border radius: `--radius` (affects all rounded corners)
|
|
236
|
-
- See the `dist/styles.css` file for the complete list
|
|
237
|
-
|
|
238
|
-
**Note:** The widget will work perfectly fine without Tailwind in your consuming project. All necessary styles are pre-compiled and included in `styles.css`.
|
|
239
|
-
|
|
240
|
-
## Advanced Usage
|
|
241
|
-
|
|
242
|
-
### Using Stores Directly
|
|
243
|
-
|
|
244
|
-
```tsx
|
|
245
|
-
import {
|
|
246
|
-
useChainsStore,
|
|
247
|
-
useTokensStore,
|
|
248
|
-
useBridgeQuoteStore
|
|
249
|
-
} from '@evaa/bridge-widget';
|
|
250
|
-
|
|
251
|
-
function YourComponent() {
|
|
252
|
-
const { chains } = useChainsStore();
|
|
253
|
-
const { tokens } = useTokensStore();
|
|
254
|
-
const { quote } = useBridgeQuoteStore();
|
|
255
|
-
|
|
256
|
-
// Your logic here
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Type Exports
|
|
261
|
-
|
|
262
|
-
```tsx
|
|
263
|
-
import type {
|
|
264
|
-
Chain,
|
|
265
|
-
Token,
|
|
266
|
-
Quote,
|
|
267
|
-
EvaaBridgeProps,
|
|
268
|
-
SwapSuccessData
|
|
269
|
-
} from '@evaa/bridge-widget';
|
|
270
|
-
```
|
|
271
|
-
|
|
272
246
|
## Supported Chains
|
|
273
247
|
|
|
274
248
|
- Ethereum (Mainnet)
|
|
@@ -282,6 +256,7 @@ import type {
|
|
|
282
256
|
## API Integration
|
|
283
257
|
|
|
284
258
|
The widget integrates with Stargate Protocol API for:
|
|
259
|
+
|
|
285
260
|
- Cross-chain token swaps
|
|
286
261
|
- Real-time quotes
|
|
287
262
|
- Transaction routing
|
|
@@ -292,16 +267,9 @@ The widget integrates with Stargate Protocol API for:
|
|
|
292
267
|
The package is written in TypeScript and includes full type definitions.
|
|
293
268
|
|
|
294
269
|
```tsx
|
|
295
|
-
import type { EvaaBridgeProps, Chain, Token } from
|
|
270
|
+
import type { EvaaBridgeProps, Chain, Token } from "@evaa/bridge-widget";
|
|
296
271
|
```
|
|
297
272
|
|
|
298
|
-
## Browser Support
|
|
299
|
-
|
|
300
|
-
- Chrome (latest)
|
|
301
|
-
- Firefox (latest)
|
|
302
|
-
- Safari (latest)
|
|
303
|
-
- Edge (latest)
|
|
304
|
-
|
|
305
273
|
## Development
|
|
306
274
|
|
|
307
275
|
```bash
|
|
@@ -335,5 +303,6 @@ MIT © EVAA Finance
|
|
|
335
303
|
## Support
|
|
336
304
|
|
|
337
305
|
For issues and questions:
|
|
306
|
+
|
|
338
307
|
- GitHub Issues: https://github.com/evaa-finance/bridge-widget/issues
|
|
339
308
|
- Email: support@evaa.finance
|