Skip to content

Commit cc75c7a

Browse files
committed
add amountIn to onSuccess
1 parent f6ac12d commit cc75c7a

File tree

9 files changed

+38
-23
lines changed

9 files changed

+38
-23
lines changed

widget/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
WidgetState,
2323
Placement,
2424
ObligatedToken,
25+
SuccessDetails,
2526
} from "./src/types";
2627

2728
type WidgetProps = WidgetComponentProps & {
@@ -170,4 +171,5 @@ export type {
170171
Placement,
171172
ObligatedToken,
172173
SystemConfig,
174+
SuccessDetails,
173175
};

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.54",
3+
"version": "1.0.60",
44
"type": "module",
55
"homepage": "https://www.enso.build/",
66
"repository": {

widget/src/components/RouteIndication.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import {
1010
import { ChevronsRight } from "lucide-react";
1111
import { type Address, isAddress } from "viem";
1212
import { type RouteData } from "@ensofinance/sdk";
13-
import { type Token, useTokenFromList } from "@/util/common";
13+
import { useTokenFromList } from "@/util/common";
1414
import { useEnsoToken } from "@/util/enso";
1515
import { TokenIcon } from "@/components/TokenIndicator";
16+
import { Token } from "@/types";
1617

1718
const TokenBadge = ({
1819
address,

widget/src/components/TokenIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Box, Flex, Text } from "@chakra-ui/react";
2-
import { type Token } from "@/util/common";
32
import {
43
MOCK_IMAGE_URL,
54
SupportedChainId,
65
STARGATE_CHAIN_NAMES,
76
} from "@/constants";
87
import { formatCompactUsd } from "@/util";
8+
import { Token } from "@/types";
99

1010
const GECKO_HOSTNAME = "coingecko";
1111

widget/src/components/TokenSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { useMemo } from "react";
1212
import { Address, isAddress } from "viem";
1313
import { FixedSizeList as List } from "react-window";
14-
import { Token, useCurrentChainList } from "@/util/common";
14+
import { useCurrentChainList } from "@/util/common";
1515
import { formatNumber, normalizeValue } from "@/util";
1616
import { useEnsoBalances, useEnsoToken } from "@/util/enso";
1717
import { SupportedChainId } from "@/constants";
@@ -25,7 +25,7 @@ import {
2525
import { TokenIndicator } from "@/components/TokenIndicator";
2626
import ChainSelector from "./ChainSelector";
2727
import ProjectSelector from "./ProjectSelector";
28-
import { ProjectFilter } from "@/types";
28+
import { ProjectFilter, Token } from "@/types";
2929

3030
type TokenWithBalance = Token & {
3131
balance?: string;

widget/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Address } from "viem";
2-
import { Token } from "@/util/common";
2+
import { Token } from "@/types";
33

44
export const ERROR_MSG =
55
"Swap not found for a required underlying of defi route, please make sure your amount is within an acceptable range";

widget/src/types.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
import { RouteData } from "@ensofinance/sdk";
12
import { Address } from "viem";
23

4+
export type Token = {
5+
address: Address;
6+
name: string;
7+
symbol: string;
8+
decimals: number;
9+
logoURI: string;
10+
underlyingTokens?: Token[];
11+
type?: string;
12+
apy?: number;
13+
tvl?: number;
14+
};
15+
16+
export type SuccessDetails = {
17+
amountIn: string;
18+
tokenIn: Token;
19+
tokenOut: Token;
20+
slippage: number;
21+
routerData: RouteData;
22+
};
23+
324
export type Placement =
425
| "top-start"
526
| "top"
@@ -22,7 +43,7 @@ export type ProjectFilter = {
2243
};
2344

2445
export type WidgetComponentProps = {
25-
onSuccess?: (hash: string, details?: any) => void;
46+
onSuccess?: (hash: string, details?: SuccessDetails) => void;
2647
adaptive?: boolean;
2748
tokenOut?: Address;
2849
tokenIn?: Address;

widget/src/util/common.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@ import {
99
SupportedChainId,
1010
} from "@/constants";
1111
import { useStore } from "@/store";
12-
13-
export type Token = {
14-
address: Address;
15-
name: string;
16-
symbol: string;
17-
decimals: number;
18-
logoURI: string;
19-
underlyingTokens?: Token[];
20-
type?: string;
21-
apy?: number;
22-
tvl?: number;
23-
};
12+
import { Token } from "@/types";
2413

2514
export const compareCaseInsensitive = (a: string, b: string) => {
2615
return !!(a && b && a?.toLowerCase() === b?.toLowerCase());

widget/src/util/enso.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
type BundleAction,
88
type BundleParams,
99
BundleActionType,
10+
type RouteData,
1011
} from "@ensofinance/sdk";
1112
import { type Address, isAddress } from "viem";
1213
import {
13-
type Token,
1414
usePriorityChainId,
1515
useOutChainId,
1616
useTokenFromList,
@@ -25,6 +25,7 @@ import {
2525
} from "@/constants";
2626
import { formatNumber, normalizeValue } from ".";
2727
import { useTxTracker } from "./useTracker";
28+
import { SuccessDetails, Token } from "@/types";
2829

2930
let ensoClient: EnsoClient | null = null;
3031

@@ -322,7 +323,7 @@ export const useEnsoData = (
322323
tokenOut: Address,
323324
slippage: number,
324325
referralCode?: string,
325-
onSuccess?: (hash: string, details?: any) => void
326+
onSuccess?: (hash: string, details?: SuccessDetails) => void
326327
) => {
327328
const { address = VITALIK_ADDRESS } = useAccount();
328329
const chainId = usePriorityChainId();
@@ -386,8 +387,9 @@ export const useEnsoData = (
386387
});
387388

388389
const details = {
389-
tokenIn: tokenToData,
390-
tokenOut: tokenFromData,
390+
amountIn,
391+
tokenIn: tokenFromData,
392+
tokenOut: tokenToData,
391393
slippage,
392394
routerData: routerData.data,
393395
};

0 commit comments

Comments
 (0)