Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSW-374] feat: Create Swap Transaction Data #214

Merged
merged 7 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/web/src/common/utils/data-check-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ export const notNullNumberType = (v: any) => {
export const notEmptyStringType = (v: string) => {
return notNullStringType(v) && emptyStrCheckAfterTrim(v);
};

export function isAmount(str: string) {
const regex = /^\d+(\.\d*)?$/;
return regex.test(str);
}
2 changes: 1 addition & 1 deletion packages/web/src/common/values/data-constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type IncentivizedOptions =
export type StatusOptions = "SUCCESS" | "PENDING" | "FAILED";
export type ActiveStatusOptions = "ACTIVE" | "IN_ACTIVE" | "NONE";
export type TokenTableSelectType = "NATIVE" | "GRC20" | "ALL";
export type ExactTypeOption = "EXACT_IN" | "EXACT_OUT";
export type SwapDirectionType = "EXACT_IN" | "EXACT_OUT";
export enum NotificationType {
"Approve" = 0,
"CreatePool" = 1,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
component: EarnAddConfirm,
} as Meta<typeof EarnAddConfirm>;


const tokenA = {
info: {
chainId: "test3",
Expand Down Expand Up @@ -41,7 +42,11 @@ const tokenB = {

const amountInfo = {
tokenA: tokenA,
tokenAAmount: "123",
tokenAUSDPrice: "1234",
tokenB: tokenB,
tokenBAmount: "123",
tokenBUSDPrice: "1234",
feeRate: "0.30%"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { TokenAmountInputModel } from "@hooks/token/use-token-amount-input";
import DoubleLogo from "@components/common/double-logo/DoubleLogo";
import IconSettings from "@components/common/icons/IconSettings";
import Badge, { BADGE_TYPE } from "@components/common/badge/Badge";
import { TokenModel } from "@models/token/token-model";
import { PoolModel } from "@models/pool/pool-model";
import SelectPriceRange from "@components/common/select-price-range/SelectPriceRange";
import SelectPriceRangeSummary from "@components/common/select-price-range-summary/SelectPriceRangeSummary";
import { TokenModel } from "@models/token/token-model";

interface EarnAddLiquidityProps {
mode: AddLiquidityType;
Expand Down
9 changes: 8 additions & 1 deletion packages/web/src/components/home/home-swap/HomeSwap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import Button, { ButtonHierarchy } from "@components/common/button/Button";
import SelectPairButton from "@components/common/select-pair-button/SelectPairButton";
import IconSwapArrowDown from "@components/common/icons/IconSwapArrowDown";
import { DeviceSize } from "@styles/media";
import { SwapTokenModel } from "@models/swap/swap-token-model";
import { TokenModel } from "@models/token/token-model";

interface SwapTokenModel {
token: TokenModel;
amount: string;
price: string;
balance: string;
}

interface HomeSwapProps {
from: SwapTokenModel;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,79 @@ import { css } from "@emotion/react";
import { action } from "@storybook/addon-actions";

import ConfirmSwapModal from "./ConfirmSwapModal";
import { dummySwapGasInfo } from "@containers/swap-container/SwapContainer";
import { DEVICE_TYPE } from "@styles/media";
import { SwapSummaryInfo } from "@models/swap/swap-summary-info";
import { SwapTokenInfo } from "@models/swap/swap-token-info";

const swapTokenInfo: SwapTokenInfo = {
tokenA: {
chainId: "test3",
address: "0x111111111117dC0aa78b770fA6A738034120C302",
path: "gno.land/r/demo/1inch",
name: "1inch",
symbol: "1INCH",
decimals: 6,
logoURI: "https://assets.coingecko.com/coins/images/13469/thumb/1inch-token.png?1608803028",
priceId: "1inch",
createdAt: "1999-01-01T00:00:01Z"
},
tokenAAmount: "",
tokenABalance: "",
tokenAUSD: 0,
tokenB: {
chainId: "test3",
address: "0x111111111117dC0aa78b770fA6A738034120C302",
path: "gno.land/r/demo/1inch",
name: "1inch",
symbol: "1INCH",
decimals: 6,
logoURI: "https://assets.coingecko.com/coins/images/13469/thumb/1inch-token.png?1608803028",
priceId: "1inch",
createdAt: "1999-01-01T00:00:01Z"
},
tokenBAmount: "",
tokenBBalance: "",
tokenBUSD: 0,
direction: "EXACT_IN",
slippage: 10
};

const swapSummaryInfo: SwapSummaryInfo = {
tokenA: {
chainId: "test3",
address: "0x111111111117dC0aa78b770fA6A738034120C302",
path: "gno.land/r/demo/1inch",
name: "1inch",
symbol: "1INCH",
decimals: 6,
logoURI: "https://assets.coingecko.com/coins/images/13469/thumb/1inch-token.png?1608803028",
priceId: "1inch",
createdAt: "1999-01-01T00:00:01Z"
},
tokenB: {
chainId: "test3",
address: "0x111111111117dC0aa78b770fA6A738034120C302",
path: "gno.land/r/demo/1inch",
name: "1inch",
symbol: "1INCH",
decimals: 6,
logoURI: "https://assets.coingecko.com/coins/images/13469/thumb/1inch-token.png?1608803028",
priceId: "1inch",
createdAt: "1999-01-01T00:00:01Z"
},
swapDirection: "EXACT_IN",
swapRate: 1.14,
swapRateUSD: 1.14,
priceImpact: 0.3,
guaranteedAmount: {
amount: 45124,
currency: "GNOT"
},
gasFee: {
amount: 0.000001,
currency: "GNOT"
},
gasFeeUSD: 0.1
};

export default {
title: "swap/ConfirmSwapModal",
Expand All @@ -22,35 +93,12 @@ const Template: ComponentStory<typeof ConfirmSwapModal> = args => (

export const Default = Template.bind({});
Default.args = {
onConfirmModal: action("onConfirmModal"),
submitSwap: action("submitSwap"),
swapGasInfo: dummySwapGasInfo,
breakpoint: DEVICE_TYPE.WEB,
tolerance: "5",
submit: false,
isFetching: true,
from: {
token: "USDCoin",
symbol: "USDC",
amount: "121",
price: "$0.00",
gnosExchangePrice: "1250",
usdExchangePrice: "($1541.55)",
balance: "0",
logoURI:
"https://raw.githubusercontent.com/Uniswap/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
},
to: {
token: "HEX",
symbol: "HEX",
amount: "5000",
price: "$0.00",
gnosExchangePrice: "1250",
usdExchangePrice: "($1541.55)",
balance: "0",
logoURI:
"https://raw.githubusercontent.com/Uniswap/assets/master/blockchains/ethereum/assets/0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39/logo.png",
},
submitted: false,
swapTokenInfo,
swapSummaryInfo,
swapResult: null,
swap: action("swap"),
close: action("close"),
};

const wrapper = () => css`
Expand Down
Loading