Skip to content

Commit 7f88c3a

Browse files
committed
update readme
1 parent 8a13094 commit 7f88c3a

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
</div>
77

8-
# Shortcuts Widget
8+
# Cross-chain Shortcuts Widget
99

1010
## Overview
1111

12-
This widget is a React component designed to provide a user-friendly interface for swapping tokens. It integrates with Enso API to allow not only simple swaps but also operations like zap-in.
12+
This widget is a React component that utilizes Enso API. It is designed to provide a user-friendly interface for swapping, bridging and executing DeFi action
1313

1414
## Features
1515

1616
- Swap any-to-any tokens
17+
- Bridge any-to-any tokens
18+
- Deposit/withdraw into DeFi protocols
1719
- Perform zap-in operations
1820
- Display token details including balance, USD cost, slippage, etc.
1921
- Enable DeFi operations composition since Enso API is used
@@ -40,8 +42,8 @@ const App = () => {
4042
return (
4143
<div>
4244
<SwapWidget apiKey={"YOUR_API_KEY"} />
43-
</div>
44-
);
45+
</div>
46+
);
4547
};
4648

4749
export default App;

app/src/App.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function App() {
3535
// Use a single state object instead of multiple state variables
3636
const [state, setState] = useState<AppState>({});
3737

38-
// Parse URL params on initial load and location changes
38+
// Parse URL params and save to sate on initial load
3939
useEffect(() => {
4040
const searchParams = new URLSearchParams(location.search);
4141
const tokenInParam = searchParams.get("tokenIn");
@@ -45,10 +45,8 @@ function App() {
4545
const outProjectParam = searchParams.get("outProject");
4646
const obligated = searchParams.get("obligated");
4747

48-
// Create a new state object with URL parameters
4948
const newState: AppState = {};
5049

51-
// Set initial state from URL parameters
5250
if (chainIdParam) newState.chainId = parseInt(chainIdParam);
5351
if (outChainIdParam) newState.outChainId = parseInt(outChainIdParam);
5452
if (isAddress(tokenInParam)) newState.tokenIn = tokenInParam as Address;
@@ -64,22 +62,22 @@ function App() {
6462

6563
// Update URL when parameters change
6664
useEffect(() => {
67-
const searchParams = new URLSearchParams();
65+
// Get current search params first to preserve any params not managed by this component
66+
const searchParams = new URLSearchParams(location.search);
6867

68+
// Only update params that are in state
6969
if (state.tokenIn) searchParams.set("tokenIn", state.tokenIn);
7070

71-
if (state.tokenOut) {
72-
state.tokenOut && searchParams.set("tokenOut", state.tokenOut);
73-
state.outChainId &&
74-
searchParams.set("outChainId", state.outChainId.toString());
75-
}
71+
if (state.tokenOut) searchParams.set("tokenOut", state.tokenOut);
7672

73+
if (state.outChainId)
74+
searchParams.set("outChainId", state.outChainId.toString());
7775
if (state.chainId) searchParams.set("chainId", state.chainId.toString());
7876
if (state.obligateSelection)
7977
searchParams.set("obligated", state.obligateSelection.toString());
8078

8179
navigate({ search: searchParams.toString() }, { replace: true });
82-
}, [state, navigate]);
80+
}, [state, navigate, location.search]);
8381

8482
// Handler for state changes coming from the widget
8583
const handleStateChange = useCallback((newWidgetState: Partial<AppState>) => {

widget/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
</div>
77

8-
# Shortcuts Widget
8+
# Cross-chain Shortcuts Widget
99

1010
## Overview
1111

12-
This widget is a React component designed to provide a user-friendly interface for swapping tokens. It integrates with Enso API to allow not only simple swaps but also operations like zap-in.
12+
This widget is a React component that utilizes Enso API. It is designed to provide a user-friendly interface for swapping, bridging and executing DeFi action
1313

1414
## Features
1515

1616
- Swap any-to-any tokens
17+
- Bridge any-to-any tokens
18+
- Deposit/withdraw into DeFi protocols
1719
- Perform zap-in operations
1820
- Display token details including balance, USD cost, slippage, etc.
1921
- Enable DeFi operations composition since Enso API is used

widget/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ensofinance/shortcuts-widget",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"type": "module",
55
"homepage": "https://www.enso.build/",
66
"repository": {

widget/src/components/SwapWidget.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,6 @@ const SwapWidget = ({
196196
const tokenOutUsdPrice =
197197
+(outUsdPrice?.price ?? 0) *
198198
+normalizeValue(routerData?.amountOut?.toString(), tokenOutInfo?.decimals);
199-
200-
const urlToCopy = useMemo(() => {
201-
const url = new URL(window.location.href);
202-
return url.toString();
203-
}, []);
204-
205199
const priceImpactValue = (routerData as any)?.priceImpact;
206200

207201
const shouldWarnPriceImpact =
@@ -439,7 +433,7 @@ const SwapWidget = ({
439433
<Flex w={"100%"}>
440434
{enableShare && (
441435
<Box color={"gray.500"}>
442-
<ClipboardRoot value={urlToCopy} position={"absolute"}>
436+
<ClipboardRoot value={window.location.href} position={"absolute"}>
443437
<ClipboardLink textStyle={"xs"} cursor={"pointer"} />
444438
</ClipboardRoot>
445439
</Box>

widget/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const STARGATE_CHAIN_NAMES: { [key in SupportedChainId]: string } = {
133133
[SupportedChainId.UNICHAIN]: "unichain",
134134
[SupportedChainId.INK]: "ink",
135135
[SupportedChainId.SONEIUM]: "soneium",
136-
[SupportedChainId.PLUME]: "plume",
136+
[SupportedChainId.PLUME]: "plumephoenix",
137137
};
138138

139139
export const MOCK_IMAGE_URL =

0 commit comments

Comments
 (0)