Skip to content

Commit

Permalink
Merge branch 'add-memeContract' into add-memeContract-btcWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
naturexie committed Jan 20, 2025
2 parents d700135 + 2f9ced6 commit 5a9598b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
16 changes: 10 additions & 6 deletions components/HashResultModal/ModalWithCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ interface PositionResultProps {
type?: "Long" | "Short";
positionSize?: {
amount: string;
symbol: string;
baseTokenSymbol: string;
quoteTokenSymbol: string;
totalPrice: string;
entryPrice: string;
};
Expand All @@ -32,7 +33,8 @@ const ModalWithCountdown = ({
type = "Long",
positionSize = {
amount: "0",
symbol: "NEAR",
baseTokenSymbol: "",
quoteTokenSymbol: "",
totalPrice: "$0.00",
entryPrice: "0",
},
Expand Down Expand Up @@ -106,7 +108,6 @@ const ModalWithCountdown = ({
</div>
<div className="fc">
<div className="fc">
{/* <NearIconMini /> */}
<span className="font-normal text-base pr-2">{title}</span>
<div
className={`text-sm ${
Expand All @@ -120,7 +121,7 @@ const ModalWithCountdown = ({
textOverflow: "ellipsis",
}}
>
{type} {positionSize.symbol}
{type} {positionSize.baseTokenSymbol}
</div>
</div>
<div className="text-[#6FA300] text-sm ml-auto flex items-center">
Expand All @@ -130,12 +131,15 @@ const ModalWithCountdown = ({
</div>
<div className="fc justify-between text-sm font-normal">
<span className="text-gray-300">Entry Price</span>
<span>${beautifyPrice(Number(positionSize.entryPrice))}</span>
<span className="flex items-center gap-0.5">
{beautifyPrice(Number(positionSize.entryPrice))}
<span className="text-xs text-gray-30">({positionSize.quoteTokenSymbol})</span>
</span>
</div>
<div className="fc justify-between text-sm font-normal">
<span className="text-gray-300">Position Size</span>
<span>
{beautifyPrice(Number(positionSize.amount))} {positionSize.symbol}
{beautifyPrice(Number(positionSize.amount))} {positionSize.baseTokenSymbol}
<span className="text-xs text-gray-300">
(${beautifyPrice(Number(positionSize.totalPrice))})
</span>
Expand Down
6 changes: 2 additions & 4 deletions components/HashResultModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ interface ShowPositionResultParams {
transactionHashes?: string;
positionSize?: {
amount: string;
symbol: string;
totalPrice: string;
entryPrice: string;
baseTokenSymbol: string;
quoteTokenSymbol: string;
};
}

Expand Down Expand Up @@ -57,9 +58,6 @@ export const showPositionResult = (params: ShowPositionResultParams) => {

root?.render(<ModalWithCountdown show onClose={handleClose} {...params} />);
};

// ... existing code ...

export const showPositionFailure = (params: {
title?: string;
errorMessage?: string;
Expand Down
25 changes: 8 additions & 17 deletions screens/Trading/components/ConfirmMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
}) => {
const theme = useTheme();
const [selectedCollateralType, setSelectedCollateralType] = useState(DEFAULT_POSITION);
const { ReduxcategoryAssets1 } = useAppSelector((state) => state.category);
const { ReduxcategoryAssets1, ReduxcategoryAssets2 } = useAppSelector((state) => state.category);
const actionShowRedColor = action === "Long";
const [isDisabled, setIsDisabled] = useState<boolean>(false);
const [isMinTokenPAmount, setIsMinTokenPAmount] = useState<boolean>(false);
Expand Down Expand Up @@ -78,10 +78,11 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
const decimalsD = +assetD.config.extra_decimals + +assetD.metadata.decimals;
const decimalsP = +assetP.config.extra_decimals + +assetP.metadata.decimals;
const decimalsC = action === "Long" ? decimalsD : decimalsP;
const cateSymbol = getSymbolById(
const baseTokenSymbol = getSymbolById(
ReduxcategoryAssets1?.token_id,
ReduxcategoryAssets1?.metadata?.symbol,
);
const quoteTokenSymbol = ReduxcategoryAssets2?.metadata.symbol;
const min_amount_out_estimate = confirmInfo.estimateData.min_amount_out;
const expand_amount_in_estimate = confirmInfo.estimateData.expand_amount_in;
const in_extra_decimals = confirmInfo?.longInputName?.config?.extra_decimals || 0;
Expand Down Expand Up @@ -116,16 +117,6 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
setIsDisabled(true);
let hasError = false;
try {
const { decimals: localDecimals } = getAssetDetails(
isMainStream
? getAssetById(
action === "Long" ? openPositionParams.token_p_id : openPositionParams.token_d_id,
)
: getAssetByIdMEME(
action === "Long" ? openPositionParams.token_p_id : openPositionParams.token_d_id,
),
);

// Swap Out Trial Calculation Result Verification
const minTokenPAmount = Number(shrinkToken(openPositionParams.min_token_p_amount, decimalsP));
const tokenDAmount = shrinkToken(openPositionParams.token_d_amount, decimalsD);
Expand Down Expand Up @@ -158,8 +149,8 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
localStorage.setItem(
"cateSymbolAndDecimals",
JSON.stringify({
cateSymbol,
decimals: localDecimals,
baseTokenSymbol,
quoteTokenSymbol,
amount: confirmInfo.longOutput,
totalPrice: confirmInfo.longOutputUsd,
entryPrice:
Expand Down Expand Up @@ -221,7 +212,7 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
actionShowRedColor ? "bg-primary text-primary" : "bg-red-50 text-red-50"
}`}
>
{action} {cateSymbol} {confirmInfo.rangeMount}X
{action} {baseTokenSymbol} {confirmInfo.rangeMount}X
</div>
</div>
<div className="cursor-pointer">
Expand Down Expand Up @@ -325,7 +316,7 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
{isDisabled ? (
<BeatLoader size={5} color="#14162B" />
) : (
` Confirm ${action} ${cateSymbol} ${confirmInfo.rangeMount}X`
` Confirm ${action} ${baseTokenSymbol} ${confirmInfo.rangeMount}X`
)}
</YellowSolidButton>
) : (
Expand All @@ -337,7 +328,7 @@ const ConfirmMobile: React.FC<IConfirmMobileProps | any> = ({
{isDisabled ? (
<BeatLoader size={5} color="#14162B" />
) : (
` Confirm ${action} ${cateSymbol} ${confirmInfo.rangeMount}X`
` Confirm ${action} ${baseTokenSymbol} ${confirmInfo.rangeMount}X`
)}
</RedSolidButton>
)}
Expand Down
3 changes: 2 additions & 1 deletion services/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ function showPositionResultWrapper(
positionSize: {
amount: cateSymbolAndDecimals?.amount || "",
totalPrice: cateSymbolAndDecimals?.totalPrice || "",
symbol: cateSymbolAndDecimals?.cateSymbol || "NEAR",
baseTokenSymbol: cateSymbolAndDecimals?.baseTokenSymbol || "",
quoteTokenSymbol: cateSymbolAndDecimals?.quoteTokenSymbol || "",
entryPrice: cateSymbolAndDecimals?.entryPrice || "0",
},
});
Expand Down
6 changes: 6 additions & 0 deletions utils/transactionUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum TRANSACTION_ERROR_TYPE {
TOKEN_FROZEN = "Token Frozen",
POOL_BALANCE_LESS = "Pool Balance Less Than MIN_RESERVE",
NETH_ERROR = "Smart contract panicked",
UNKNOWN_ERROR = "Smart contract panicked",
}

export const getErrorMessage = (receipts_outcome: any) => {
Expand Down Expand Up @@ -67,6 +68,9 @@ export const getErrorMessage = (receipts_outcome: any) => {
outcome?.outcome?.status?.Failure?.ActionError?.kind?.FunctionCallError?.ExecutionError,
);
});
const isOtherError = receipts_outcome.some((outcome: any) => {
return outcome?.outcome?.status?.Failure;
});

if (isSlippageError) {
return TRANSACTION_ERROR_TYPE.SLIPPAGE_VIOLATION;
Expand All @@ -84,6 +88,8 @@ export const getErrorMessage = (receipts_outcome: any) => {
return TRANSACTION_ERROR_TYPE.POOL_BALANCE_LESS;
} else if (isNETHErrpr) {
return TRANSACTION_ERROR_TYPE.NETH_ERROR;
} else if (isOtherError) {
return TRANSACTION_ERROR_TYPE.UNKNOWN_ERROR;
} else {
return null;
}
Expand Down

0 comments on commit 5a9598b

Please sign in to comment.