From 5feecd58187397d94440f52bb1c4403ff7f3ef7b Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Wed, 8 May 2024 11:38:11 +0800 Subject: [PATCH 1/2] Fix config hasAssetLimit for Darwinia --- src/config/chains/darwinia-chain.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config/chains/darwinia-chain.ts b/src/config/chains/darwinia-chain.ts index d140aee..bf565f7 100644 --- a/src/config/chains/darwinia-chain.ts +++ b/src/config/chains/darwinia-chain.ts @@ -66,6 +66,7 @@ export const darwiniaChain: ChainConfig = { ], wallets: [WalletID.RAINBOW, WalletID.TALISMAN], addressType: "evm", + hasAssetLimit: true, /** * Substrate From cb18754cc3f6b39ebdfedb1bbaf81899e4d2fdc0 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Wed, 8 May 2024 11:41:05 +0800 Subject: [PATCH 2/2] Support max input --- src/components/asset-select.tsx | 2 +- src/components/balance-input.tsx | 34 +++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/components/asset-select.tsx b/src/components/asset-select.tsx index 5bff412..a99fd01 100644 --- a/src/components/asset-select.tsx +++ b/src/components/asset-select.tsx @@ -21,7 +21,7 @@ export default function AssetSelect({ value, options, disabled, onChange = () => } disabled={disabled} sameWidth - labelClassName="flex items-center gap-middle shrink-0 w-32 justify-between bg-component h-full border-radius px-1 hover:opacity-80 transition-[transform,color] disabled:translate-y-0 disabled:opacity-100 disabled:cursor-not-allowed" + labelClassName="flex items-center gap-middle shrink-0 w-32 justify-between bg-component h-full rounded-r-2xl px-1 hover:opacity-80 transition-[transform,color] disabled:translate-y-0 disabled:opacity-100 disabled:cursor-not-allowed" childClassName="flex flex-col py-small bg-component border-primary border border-radius gap-[1px]" > {options?.length ? ( diff --git a/src/components/balance-input.tsx b/src/components/balance-input.tsx index 0fcad8f..9c4ea7e 100644 --- a/src/components/balance-input.tsx +++ b/src/components/balance-input.tsx @@ -4,7 +4,7 @@ import { BN, BN_ZERO, bnToBn } from "@polkadot/util"; import AssetSelect from "./asset-select"; import { ChangeEventHandler, useCallback, useEffect, useMemo, useRef, useState } from "react"; import { formatBalance } from "@/utils"; -import { parseUnits } from "viem"; +import { formatUnits, parseUnits } from "viem"; import { InputAlert } from "./input-alert"; interface Value { @@ -19,7 +19,7 @@ interface Props { placeholder?: string; balance?: BN; cross?: Cross; - asset?: Asset; + asset: Asset; assetSupply?: BN; assetLimit?: BN; assetOptions?: Asset[]; @@ -119,7 +119,35 @@ export default function BalanceInput({ value={value?.input} onChange={handleInputChange} /> - {asset ? : null} +
+ + +
{/* Alert */} {requireLimit ? (