Skip to content

Commit 3d50cf2

Browse files
authored
Merge pull request #2 from SailFish-Finance/feat-ui-for-bridge
Feat UI for bridge
2 parents bb608ec + 830af95 commit 3d50cf2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+18597
-3807
lines changed

Diff for: .gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ coverage/
3737

3838
# System files
3939
Thumbs.db
40-
Desktop.ini
40+
Desktop.ini
41+
42+
examples/nextjs-test-sdk/.next/
43+
examples/nextjs-test-sdk/out/
44+
examples/nextjs-test-sdk/node_modules/
45+
examples/nextjs-test-sdk/.env
46+
examples/nextjs-test-sdk/.env.local

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ npm install @sailfishdex/v3-sdk
1919
- **Multi-hop Support**: Full support for multi-hop routes
2020
- **Token Approval**: Methods for checking and approving token allowances
2121
- **Token Bridging**: Bridge EDU tokens between BSC, Arbitrum, and EDUCHAIN
22+
- **UI Components**: Ready-to-use React components for token bridging
2223

2324
## Usage
2425

@@ -338,6 +339,7 @@ The SDK includes several examples in the `examples` directory:
338339
- **multihop-wiser-esd.js**: Specific example of a multi-hop swap between WISER and ESD tokens using WEDU as an intermediary token
339340
- **bridge-edu.js**: Shows how to bridge EDU tokens from BSC to Arbitrum using LayerZero
340341
- **bridge-arb-to-edu.js**: Shows how to bridge EDU tokens from Arbitrum to EDUCHAIN
342+
- **bridge-widget-usage.js**: Demonstrates how to use the BridgeWidget React component in a web application
341343

342344
## Contract Addresses
343345

Diff for: examples/bridge-arb-to-edu.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Example of bridging EDU tokens from Arbitrum to EDUCHAIN
22

33
const { ethers } = require("ethers");
4-
const { Bridge } = require("../dist");
4+
const { Bridge } = require("../dist/index.cjs");
55

66
// This example requires a private key to sign transactions
77
// Replace with your own private key and NEVER share it or commit it to version control
8-
const PRIVATE_KEY = '';
8+
const PRIVATE_KEY = 'PRIVATE_KEY';
99

1010
async function main() {
1111
try {

Diff for: examples/bridge-edu.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Example of bridging EDU tokens from BSC to Arbitrum using LayerZero
22

33
const { ethers } = require("ethers");
4-
const { Bridge } = require("../dist");
4+
const { Bridge } = require("../dist/index.cjs");
55

66
// This example requires a private key to sign transactions
77
// Replace with your own private key and NEVER share it or commit it to version control

Diff for: examples/execute-swap-singleswap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Example of executing a swap using the SailFish DEX v3 SDK
22

33
const { ethers } = require("ethers");
4-
const { Quoter, Router, TradeType } = require("../dist");
4+
const { Quoter, Router, TradeType } = require("../dist/index.cjs");
55

66
// This example requires a private key to sign transactions
77
// Replace with your own private key and NEVER share it or commit it to version control

Diff for: examples/get-quote-multiswap.js

+4-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Example of multi-hop swaps using the SailFish DEX v3 SDK
22

33
const { ethers } = require("ethers");
4-
const { Quoter, Router, TradeType } = require("../dist");
4+
const { Quoter, Router, TradeType } = require("../dist/index.cjs");
55

66
async function main() {
77
try {
@@ -66,36 +66,9 @@ async function main() {
6666

6767
// For multi-hop routes, we can also demonstrate how to execute them
6868
if (bestRoute.type === "indirect") {
69-
console.log("\nTo execute this multi-hop swap, see multihop-wiser-esd.js in examples folder.");
70-
// console.log("1. Create a path by encoding the tokens and fees");
71-
// console.log(
72-
// "2. Use the router.exactInput method instead of exactInputSingle"
73-
// );
74-
75-
// Example code for creating the path (not executed)
76-
// console.log("\nExample code:");
77-
// console.log(`
78-
// const path = ethers.solidityPacked(
79-
// ['address', 'uint24', 'address', 'uint24', 'address'],
80-
// [
81-
// WISER,
82-
// bestRoute.path[0].feeTier,
83-
// bestRoute.intermediaryToken.address,
84-
// bestRoute.path[1].feeTier,
85-
// ESD
86-
// ]
87-
// );
88-
89-
// const params = {
90-
// path,
91-
// recipient: YOUR_ADDRESS,
92-
// deadline: Math.floor(Date.now() / 1000) + 60 * 20, // 20 minutes
93-
// amountIn: ethers.parseEther('1.0'),
94-
// amountOutMinimum: ethers.parseUnits(quote.amountOut, 6) * 995n / 1000n // 0.5% slippage
95-
// };
96-
97-
// const tx = await router.exactInput(params);
98-
// `);
69+
console.log(
70+
"\nTo execute this multi-hop swap, see multihop-wiser-esd.js in examples folder."
71+
);
9972
}
10073
} else {
10174
throw new Error("No routes found for WISER -> ESD");

Diff for: examples/get-quote-single-swap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Example of using the SailFish DEX v3 SDK
22

33
const { ethers } = require("ethers");
4-
const { Quoter, Router, TradeType } = require("../dist");
4+
const { Quoter, Router, TradeType } = require("../dist/index.cjs");
55

66
async function main() {
77
try {

Diff for: examples/multihop-wiser-esd.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Example of a multi-hop swap between WISER and ESD using WEDU as intermediary token
22

33
const { ethers } = require("ethers");
4-
const { Quoter, Router, TradeType } = require("../dist");
4+
const { Quoter, Router, TradeType } = require("../dist/index.cjs");
55

66
// This example requires a private key to sign transactions
77
// Replace with your own private key and NEVER share it or commit it to version control
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Diff for: examples/nextjs-test-sdk/.env.example

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NEXT_PUBLIC_PROJECT_ID = WALLET_CONNECT_PROJECT_ID
2+
NEXT_PUBLIC_EXPLORER = https://opencampus-codex.blockscout.com
3+
NEXT_PUBLIC_CHAIN_ID = 656476
4+
NEXT_PUBLIC_RPC_URL = https://rpc.open-campus-codex.gelato.digital
5+
NEXT_PUBLIC_BLOCK_SCOUT = https://opencampus-codex.blockscout.com

Diff for: examples/nextjs-test-sdk/.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

Diff for: examples/nextjs-test-sdk/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

Diff for: examples/nextjs-test-sdk/eslint.config.mjs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { FlatCompat } from "@eslint/eslintrc";
2+
import { dirname } from "path";
3+
import { fileURLToPath } from "url";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
8+
const compat = new FlatCompat({
9+
baseDirectory: __dirname,
10+
});
11+
12+
const eslintConfig = [
13+
...compat.extends("next/core-web-vitals", "next/typescript"),
14+
{
15+
rules: {
16+
"@typescript-eslint/no-explicit-any": "off", // Disables the rule
17+
},
18+
},
19+
];
20+
21+
export default eslintConfig;

Diff for: examples/nextjs-test-sdk/next.config.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
reactStrictMode: false,
6+
webpack: (config) => {
7+
config.resolve.fallback = { fs: false, net: false, tls: false };
8+
config.externals.push("pino-pretty", "lokijs", "encoding");
9+
return config;
10+
},
11+
};
12+
13+
export default nextConfig;

0 commit comments

Comments
 (0)