From 2b92923e4326461acfce136f3bd652fb1503fe88 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 09:55:28 +0800 Subject: [PATCH 01/14] Add manifest --- public/manifest.json | 5 +++++ src/app/layout.tsx | 1 + 2 files changed, 6 insertions(+) create mode 100644 public/manifest.json diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..0529cd8 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,5 @@ +{ + "name": "Collactor Staking - Darwinia", + "description": "Collactor staking of Darwinia and Crab network", + "icons": [{ "src": "icon.svg", "sizes": "any" }] +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 2b21707..c5bf7ec 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -10,6 +10,7 @@ const fontJetBrainsMono = JetBrains_Mono({ subsets: ["latin", "latin-ext"] }); export const metadata = { title: "Darwinia Staking", description: "Darwinia and Crab network staking app", + manifest: "/manifest.json", }; export default function RootLayout({ children }: { children: React.ReactNode }) { From bd10ad9c28ac2b3f4dcf989d6fd159151ef9d4a4 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 09:56:03 +0800 Subject: [PATCH 02/14] Update title and description --- src/app/layout.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index c5bf7ec..9487874 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -8,8 +8,8 @@ import WrongChainAlert from "@/components/wrong-chain-alert"; const fontJetBrainsMono = JetBrains_Mono({ subsets: ["latin", "latin-ext"] }); export const metadata = { - title: "Darwinia Staking", - description: "Darwinia and Crab network staking app", + title: "Collactor Staking - Darwinia", + description: "Collactor staking of Darwinia and Crab network", manifest: "/manifest.json", }; From 52f50e7a38448e3b10a05a872d6853c1a30d7b7e Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 11:19:54 +0800 Subject: [PATCH 03/14] Adapt staking upgrade --- src/components/balance-input.tsx | 16 +- src/components/bond-more-deposit-modal.tsx | 8 +- src/components/bond-more-kton-modal.tsx | 10 +- src/components/bond-more-ring-modal.tsx | 8 +- src/components/bond-more-token-modal.tsx | 38 +++-- src/components/collator-selector.tsx | 15 +- src/components/do-deposit.tsx | 4 +- src/components/do-stake.tsx | 25 +-- src/components/login.tsx | 2 +- src/components/manage-collator-modal.tsx | 8 +- src/components/records-bonded-tokens.tsx | 12 +- src/components/records-select-collator.tsx | 4 +- src/components/unbond-all-staked.tsx | 8 +- src/components/unbond-deposit-modal.tsx | 8 +- src/components/unbond-kton-modal.tsx | 10 +- src/components/unbond-ring-modal.tsx | 8 +- src/components/unbond-token-modal.tsx | 9 +- src/components/unbonding-token-tooltip.tsx | 14 +- src/components/undelegate-modal.tsx | 4 +- src/config/abi/staking-v2.json | 167 --------------------- src/config/abi/staking.json | 64 +++++--- src/config/chains/crab.ts | 4 - src/providers/rainbow-provider.tsx | 66 ++++---- 23 files changed, 153 insertions(+), 359 deletions(-) delete mode 100644 src/config/abi/staking-v2.json diff --git a/src/components/balance-input.tsx b/src/components/balance-input.tsx index 9e808f0..cb116c3 100644 --- a/src/components/balance-input.tsx +++ b/src/components/balance-input.tsx @@ -71,10 +71,18 @@ export default function BalanceInput({ ); } -export function ExtraPower({ power, powerChanges = "more" }: { power: bigint; powerChanges?: PowerChanges }) { +export function ExtraPower({ + power, + className, + powerChanges = "more", +}: { + power: bigint; + className?: string; + powerChanges?: PowerChanges; +}) { return ( - {`${powerChanges === "more" ? "+" : "-"}${prettyNumber( - power - )} Power`} + {`${ + powerChanges === "more" ? "+" : "-" + }${prettyNumber(power)} Power`} ); } diff --git a/src/components/bond-more-deposit-modal.tsx b/src/components/bond-more-deposit-modal.tsx index 072d232..68b53c4 100644 --- a/src/components/bond-more-deposit-modal.tsx +++ b/src/components/bond-more-deposit-modal.tsx @@ -6,7 +6,6 @@ import { ExtraPower } from "./balance-input"; import { useApp, useStaking } from "@/hooks"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; -import { ChainID } from "@/types"; export default function BondMoreDepositModal({ commission, @@ -43,14 +42,9 @@ export default function BondMoreDepositModal({ const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "stake", args: [0n, 0n, checkedDeposits], }); diff --git a/src/components/bond-more-kton-modal.tsx b/src/components/bond-more-kton-modal.tsx index ef7f894..eda1ca6 100644 --- a/src/components/bond-more-kton-modal.tsx +++ b/src/components/bond-more-kton-modal.tsx @@ -5,7 +5,6 @@ import { useAccount, useBalance } from "wagmi"; import { useCallback, useState } from "react"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; -import { ChainID } from "@/types"; export default function BondMoreKtonModal({ commission, @@ -23,7 +22,7 @@ export default function BondMoreKtonModal({ const [inputAmount, setInputAmount] = useState(0n); const [busy, setBusy] = useState(false); - const { ktonToken, contract, explorer } = getChainConfig(activeChain); + const { ktonToken } = getChainConfig(activeChain); const { data: ktonBalance } = useBalance({ address, token: ktonToken?.address, watch: true }); const handleBond = useCallback(async () => { @@ -34,14 +33,9 @@ export default function BondMoreKtonModal({ const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "stake", args: [0n, inputAmount, []], }); diff --git a/src/components/bond-more-ring-modal.tsx b/src/components/bond-more-ring-modal.tsx index f891b0f..af68449 100644 --- a/src/components/bond-more-ring-modal.tsx +++ b/src/components/bond-more-ring-modal.tsx @@ -5,7 +5,6 @@ import { useApp, useStaking } from "@/hooks"; import { useCallback, useState } from "react"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; -import { ChainID } from "@/types"; export default function BondMoreRingModal({ commission, @@ -34,14 +33,9 @@ export default function BondMoreRingModal({ const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "stake", args: [inputAmount, 0n, []], }); diff --git a/src/components/bond-more-token-modal.tsx b/src/components/bond-more-token-modal.tsx index daf0da5..ff94950 100644 --- a/src/components/bond-more-token-modal.tsx +++ b/src/components/bond-more-token-modal.tsx @@ -28,29 +28,45 @@ export default function BondMoreTokenModal({ onClose?: () => void; onChange?: (amount: bigint) => void; }) { + const isKton = symbol.endsWith("KTON"); + return ( - + {isKton ? ( +
+ {`Please stake ${symbol} in`} + + https://kton-staking.darwinia.network + +
+ ) : ( + + )}
); } diff --git a/src/components/collator-selector.tsx b/src/components/collator-selector.tsx index fbf23d2..46cac11 100644 --- a/src/components/collator-selector.tsx +++ b/src/components/collator-selector.tsx @@ -24,7 +24,7 @@ export default function CollatorSelector({ collator, onSelect }: Props) { return ( <> {collator ? ( -
+

- Connect wallet to participate in staking and deposit in Darwinia. + Connect wallet to participate in collactor staking and deposit in Darwinia.

); diff --git a/src/components/manage-collator-modal.tsx b/src/components/manage-collator-modal.tsx index 69b09fa..b75b4fa 100644 --- a/src/components/manage-collator-modal.tsx +++ b/src/components/manage-collator-modal.tsx @@ -76,11 +76,9 @@ export default function ManageCollator({ setBusy(true); try { - const contractAbi = (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi: contractAbi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "collect", args: [commissionValue], }); @@ -105,11 +103,9 @@ export default function ManageCollator({ setBusy(true); try { - const contractAbi = (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi: contractAbi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "chill", args: [], }); diff --git a/src/components/records-bonded-tokens.tsx b/src/components/records-bonded-tokens.tsx index e2e6df6..1c96918 100644 --- a/src/components/records-bonded-tokens.tsx +++ b/src/components/records-bonded-tokens.tsx @@ -1,5 +1,5 @@ import { useApp } from "@/hooks"; -import { ChainID, StakingRecordsDataSource } from "@/types"; +import { StakingRecordsDataSource } from "@/types"; import { formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; import UnbondingTokenTooltip from "./unbonding-token-tooltip"; import UnbondingDepositTooltip from "./unbonding-deposit-tooltip"; @@ -35,17 +35,11 @@ export default function RecordsBondedTokens({ row }: { row: StakingRecordsDataSo const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const args = activeChain === ChainID.CRAB ? [ring, depositIds] : [ring, kton, depositIds]; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "restake", - args, + args: [ring, depositIds], }); const receipt = await waitForTransaction({ hash }); diff --git a/src/components/records-select-collator.tsx b/src/components/records-select-collator.tsx index 2d59519..0ceb871 100644 --- a/src/components/records-select-collator.tsx +++ b/src/components/records-select-collator.tsx @@ -19,11 +19,9 @@ export default function RecordsSelectCollator({ text }: { text: string }) { const chainConfig = getChainConfig(activeChain); try { - const contractAbi = (await import(`@/config/abi/${chainConfig.contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: chainConfig.contract.staking.address, - abi: contractAbi, + abi: (await import(`@/config/abi/${chainConfig.contract.staking.abiFile}`)).default, functionName: "nominate", args: [collator], }); diff --git a/src/components/unbond-all-staked.tsx b/src/components/unbond-all-staked.tsx index 1797f2e..28268da 100644 --- a/src/components/unbond-all-staked.tsx +++ b/src/components/unbond-all-staked.tsx @@ -4,7 +4,6 @@ import { useCallback, useState } from "react"; import { writeContract, waitForTransaction } from "@wagmi/core"; import { notification } from "./notification"; import { getChainConfig, notifyTransaction } from "@/utils"; -import { ChainID } from "@/types"; export default function UnbondAllStaked() { const { stakedRing, stakedKton, stakedDeposits } = useStaking(); @@ -16,14 +15,9 @@ export default function UnbondAllStaked() { setBusy(true); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "unstake", args: [stakedRing, stakedKton, stakedDeposits], }); diff --git a/src/components/unbond-deposit-modal.tsx b/src/components/unbond-deposit-modal.tsx index 2d08852..30cdf9f 100644 --- a/src/components/unbond-deposit-modal.tsx +++ b/src/components/unbond-deposit-modal.tsx @@ -6,7 +6,6 @@ import { ExtraPower } from "./balance-input"; import { useApp, useStaking } from "@/hooks"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; -import { ChainID } from "@/types"; export default function UnbondDepositModal({ commission, @@ -43,14 +42,9 @@ export default function UnbondDepositModal({ const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "unstake", args: [0n, 0n, checkedDeposits], }); diff --git a/src/components/unbond-kton-modal.tsx b/src/components/unbond-kton-modal.tsx index 5cd43f5..6fcb1cc 100644 --- a/src/components/unbond-kton-modal.tsx +++ b/src/components/unbond-kton-modal.tsx @@ -4,7 +4,6 @@ import { useApp, useStaking } from "@/hooks"; import { useCallback, useState } from "react"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; -import { ChainID } from "@/types"; export default function UnbondKtonModal({ commission, @@ -21,7 +20,7 @@ export default function UnbondKtonModal({ const [inputAmount, setInputAmount] = useState(0n); const [busy, setBusy] = useState(false); - const { ktonToken, contract, explorer } = getChainConfig(activeChain); + const { ktonToken } = getChainConfig(activeChain); const handleUnbond = useCallback(async () => { if (stakedKton < inputAmount) { @@ -36,14 +35,9 @@ export default function UnbondKtonModal({ const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "unstake", args: [0n, inputAmount, []], }); diff --git a/src/components/unbond-ring-modal.tsx b/src/components/unbond-ring-modal.tsx index 9ecde7a..110d43f 100644 --- a/src/components/unbond-ring-modal.tsx +++ b/src/components/unbond-ring-modal.tsx @@ -4,7 +4,6 @@ import { useApp, useStaking } from "@/hooks"; import { useCallback, useState } from "react"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; -import { ChainID } from "@/types"; export default function UnbondRingModal({ commission, @@ -36,14 +35,9 @@ export default function UnbondRingModal({ const { contract, explorer } = getChainConfig(activeChain); try { - const abi = - activeChain === ChainID.CRAB - ? (await import("@/config/abi/staking-v2.json")).default - : (await import(`@/config/abi/${contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: contract.staking.address, - abi, + abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default, functionName: "unstake", args: [inputAmount, 0n, []], }); diff --git a/src/components/unbond-token-modal.tsx b/src/components/unbond-token-modal.tsx index 53468b0..e2dc719 100644 --- a/src/components/unbond-token-modal.tsx +++ b/src/components/unbond-token-modal.tsx @@ -28,6 +28,8 @@ export default function UnbondTokenModal({ onClose?: () => void; onChange?: (amount: bigint) => void; }) { + const isKton = symbol.endsWith("KTON"); + return ( <> -

This unbonding process will take 14 days to complete.

+

+ This unbonding process will take 14 days to complete. +

+ {isKton && ( +

{`There is no longer a 14-day period for unbonding ${symbol}.`}

+ )}
onCancelUnbonding(isKton ? 0n : amount, isKton ? amount : 0n, [])} - > - Cancel Unbonding - + {isKton ? null : ( + onCancelUnbonding(isKton ? 0n : amount, isKton ? amount : 0n, [])} + > + Cancel Unbonding + + )}

))}
diff --git a/src/components/undelegate-modal.tsx b/src/components/undelegate-modal.tsx index 789f32c..3c0b425 100644 --- a/src/components/undelegate-modal.tsx +++ b/src/components/undelegate-modal.tsx @@ -21,11 +21,9 @@ export default function UndelegateModal({ isOpen, onClose = () => undefined }: P setBusy(true); try { - const contractAbi = (await import(`@/config/abi/${chainConfig.contract.staking.abiFile}`)).default; - const { hash } = await writeContract({ address: chainConfig.contract.staking.address, - abi: contractAbi, + abi: (await import(`@/config/abi/${chainConfig.contract.staking.abiFile}`)).default, functionName: "chill", args: [], }); diff --git a/src/config/abi/staking-v2.json b/src/config/abi/staking-v2.json deleted file mode 100644 index 9dbec17..0000000 --- a/src/config/abi/staking-v2.json +++ /dev/null @@ -1,167 +0,0 @@ -[ - { - "inputs": [], - "name": "chill", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "claim", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "commission", - "type": "uint32" - } - ], - "name": "collect", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "nominate", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "who", - "type": "address" - } - ], - "name": "payout", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "ringAmount", - "type": "uint256" - }, - { - "internalType": "uint16[]", - "name": "depositIds", - "type": "uint16[]" - } - ], - "name": "restake", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "ringAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "ktonAmount", - "type": "uint256" - }, - { - "internalType": "uint16[]", - "name": "depositIds", - "type": "uint16[]" - } - ], - "name": "stake", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "ringAmount", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "ktonAmount", - "type": "uint256" - }, - { - "internalType": "uint16[]", - "name": "depositIds", - "type": "uint16[]" - } - ], - "name": "unstake", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/config/abi/staking.json b/src/config/abi/staking.json index a6d10b4..9dbec17 100644 --- a/src/config/abi/staking.json +++ b/src/config/abi/staking.json @@ -5,7 +5,7 @@ "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], @@ -18,7 +18,7 @@ "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], @@ -37,7 +37,7 @@ "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], @@ -56,7 +56,7 @@ "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], @@ -66,26 +66,40 @@ { "inputs": [ { - "internalType": "uint256", - "name": "ring_amount", - "type": "uint256" - }, + "internalType": "address", + "name": "who", + "type": "address" + } + ], + "name": "payout", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ { "internalType": "uint256", - "name": "kton_amount", + "name": "ringAmount", "type": "uint256" }, { - "internalType": "uint8[]", - "name": "deposits", - "type": "uint8[]" + "internalType": "uint16[]", + "name": "depositIds", + "type": "uint16[]" } ], "name": "restake", "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], @@ -96,25 +110,25 @@ "inputs": [ { "internalType": "uint256", - "name": "ring_amount", + "name": "ringAmount", "type": "uint256" }, { "internalType": "uint256", - "name": "kton_amount", + "name": "ktonAmount", "type": "uint256" }, { - "internalType": "uint8[]", - "name": "deposits", - "type": "uint8[]" + "internalType": "uint16[]", + "name": "depositIds", + "type": "uint16[]" } ], "name": "stake", "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], @@ -125,25 +139,25 @@ "inputs": [ { "internalType": "uint256", - "name": "ring_amount", + "name": "ringAmount", "type": "uint256" }, { "internalType": "uint256", - "name": "kton_amount", + "name": "ktonAmount", "type": "uint256" }, { - "internalType": "uint8[]", - "name": "deposits", - "type": "uint8[]" + "internalType": "uint16[]", + "name": "depositIds", + "type": "uint16[]" } ], "name": "unstake", "outputs": [ { "internalType": "bool", - "name": "result", + "name": "", "type": "bool" } ], diff --git a/src/config/chains/crab.ts b/src/config/chains/crab.ts index b179c66..a90aedc 100644 --- a/src/config/chains/crab.ts +++ b/src/config/chains/crab.ts @@ -20,10 +20,6 @@ export const crabChainConfig: ChainConfig = { name: "Dwellir", url: "https://darwiniacrab-rpc.dwellir.com", }, - // { - // name: "OnFinality", - // url: "https://crab.api.onfinality.io/public-rpc", - // }, ], nativeToken: { symbol: "CRAB", diff --git a/src/providers/rainbow-provider.tsx b/src/providers/rainbow-provider.tsx index abc1260..4ace653 100644 --- a/src/providers/rainbow-provider.tsx +++ b/src/providers/rainbow-provider.tsx @@ -8,45 +8,40 @@ import { publicProvider } from "wagmi/providers/public"; import { APP_NAME_CONF } from "@/config"; import { getChainConfigs } from "@/utils"; -import { PropsWithChildren, useEffect, useState } from "react"; -import { useApp } from "@/hooks"; +import { PropsWithChildren } from "react"; const projectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_ID || ""; - -export function RainbowProvider({ children }: PropsWithChildren) { - const [mounted, setMounted] = useState(true); // temporarity set to true - const { activeChain, activeRpc } = useApp(); - - const { chains, publicClient } = configureChains( - getChainConfigs().map(({ chainId, name, nativeToken, explorer }) => ({ - id: chainId, - name, - network: name.toLowerCase().split(" ").join("-"), - nativeCurrency: { - name: nativeToken.symbol, - symbol: nativeToken.symbol, - decimals: nativeToken.decimals, +const { chains, publicClient } = configureChains( + getChainConfigs().map(({ chainId, name, nativeToken, explorer, rpcMetas }) => ({ + id: chainId, + name, + network: name.toLowerCase().split(" ").join("-"), + nativeCurrency: { + name: nativeToken.symbol, + symbol: nativeToken.symbol, + decimals: nativeToken.decimals, + }, + rpcUrls: { + default: { + http: rpcMetas.filter(({ url }) => url.startsWith("http")).map(({ url }) => url), + webSocket: rpcMetas.filter(({ url }) => url.startsWith("ws")).map(({ url }) => url), }, - rpcUrls: { - default: { - http: activeRpc.url.startsWith("http") ? [activeRpc.url] : [], - webSocket: activeRpc.url.startsWith("ws") ? [activeRpc.url] : [], - }, - public: { - http: activeRpc.url.startsWith("http") ? [activeRpc.url] : [], - webSocket: activeRpc.url.startsWith("ws") ? [activeRpc.url] : [], - }, + public: { + http: rpcMetas.filter(({ url }) => url.startsWith("http")).map(({ url }) => url), + webSocket: rpcMetas.filter(({ url }) => url.startsWith("ws")).map(({ url }) => url), }, - blockExplorers: { - default: { - url: explorer.url, - name: explorer.name, - }, + }, + blockExplorers: { + default: { + url: explorer.url, + name: explorer.name, }, - })), - [publicProvider()] - ); + }, + })), + [publicProvider()] +); +export function RainbowProvider({ children }: PropsWithChildren) { const { wallets } = getDefaultWallets({ appName: APP_NAME_CONF, projectId, @@ -73,17 +68,14 @@ export function RainbowProvider({ children }: PropsWithChildren) { publicClient, }); - useEffect(() => setMounted(true), []); - return ( - {mounted && children} + {children} ); From 2084e66f01c8507a9ab3ece26a25344497994e8d Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 12:08:41 +0800 Subject: [PATCH 04/14] Remove power --- src/components/balance-input.tsx | 25 +------- src/components/bond-more-deposit-modal.tsx | 25 +------- src/components/bond-more-kton-modal.tsx | 8 +-- src/components/bond-more-ring-modal.tsx | 8 +-- src/components/bond-more-token-modal.tsx | 3 - src/components/collator-select-modal.tsx | 59 +++++++++---------- src/components/do-stake.tsx | 45 ++------------ .../{power.tsx => latest-rewards.tsx} | 46 ++------------- src/components/records-bonded-tokens.tsx | 36 +++++------ src/components/reserved-in-staking.tsx | 14 +---- src/components/staking-dashboard.tsx | 4 +- src/components/staking-records.tsx | 36 +---------- src/components/unbond-deposit-modal.tsx | 25 +------- src/components/unbond-kton-modal.tsx | 7 +-- src/components/unbond-ring-modal.tsx | 7 +-- src/components/unbond-token-modal.tsx | 4 -- 16 files changed, 75 insertions(+), 277 deletions(-) rename src/components/{power.tsx => latest-rewards.tsx} (67%) diff --git a/src/components/balance-input.tsx b/src/components/balance-input.tsx index cb116c3..8ac1329 100644 --- a/src/components/balance-input.tsx +++ b/src/components/balance-input.tsx @@ -1,22 +1,18 @@ -import { formatBlanace, prettyNumber } from "@/utils"; +import { formatBlanace } from "@/utils"; import Image from "next/image"; import InputLabel from "./input-label"; import { parseUnits } from "viem"; import { useEffect, useRef, useState } from "react"; -type PowerChanges = "more" | "less"; - export default function BalanceInput({ isReset, balance, symbol, decimals, logoPath, - power, label, boldLabel, className, - powerChanges = "more", onChange = () => undefined, }: { isReset?: boolean; @@ -24,8 +20,6 @@ export default function BalanceInput({ symbol: string; decimals: number; logoPath?: string; - power?: bigint; - powerChanges?: PowerChanges; label?: string; boldLabel?: boolean; className?: string; @@ -66,23 +60,6 @@ export default function BalanceInput({ {symbol}
- {power !== undefined && } ); } - -export function ExtraPower({ - power, - className, - powerChanges = "more", -}: { - power: bigint; - className?: string; - powerChanges?: PowerChanges; -}) { - return ( - {`${ - powerChanges === "more" ? "+" : "-" - }${prettyNumber(power)} Power`} - ); -} diff --git a/src/components/bond-more-deposit-modal.tsx b/src/components/bond-more-deposit-modal.tsx index 68b53c4..0fa565d 100644 --- a/src/components/bond-more-deposit-modal.tsx +++ b/src/components/bond-more-deposit-modal.tsx @@ -1,39 +1,24 @@ -import { Key, useCallback, useMemo, useState } from "react"; +import { Key, useCallback, useState } from "react"; import Modal from "./modal"; import CheckboxGroup from "./checkbox-group"; -import { commissionWeightedPower, formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; -import { ExtraPower } from "./balance-input"; +import { formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; import { useApp, useStaking } from "@/hooks"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; export default function BondMoreDepositModal({ - commission, isOpen, onClose = () => undefined, }: { - commission: string; isOpen: boolean; onClose?: () => void; }) { - const { deposits, calcExtraPower } = useStaking(); + const { deposits } = useStaking(); const { activeChain } = useApp(); const [checkedDeposits, setCheckedDeposits] = useState([]); const [busy, setBusy] = useState(false); - const extraPower = useMemo( - () => - commissionWeightedPower( - calcExtraPower( - deposits.filter(({ id }) => checkedDeposits.includes(id)).reduce((acc, cur) => acc + cur.value, 0n), - 0n - ), - commission - ), - [deposits, commission, checkedDeposits, calcExtraPower] - ); - const availableDeposits = deposits.filter(({ inUse }) => !inUse); const { nativeToken } = getChainConfig(activeChain); @@ -94,10 +79,6 @@ export default function BondMoreDepositModal({ onChange={setCheckedDeposits as (values: Key[]) => void} className="max-h-80 overflow-y-auto" /> - -
- - ) : ( No more deposits to bond diff --git a/src/components/bond-more-kton-modal.tsx b/src/components/bond-more-kton-modal.tsx index eda1ca6..29a50ca 100644 --- a/src/components/bond-more-kton-modal.tsx +++ b/src/components/bond-more-kton-modal.tsx @@ -1,23 +1,20 @@ -import { commissionWeightedPower, getChainConfig, notifyTransaction } from "@/utils"; +import { getChainConfig, notifyTransaction } from "@/utils"; import BondMoreTokenModal from "./bond-more-token-modal"; -import { useApp, useStaking } from "@/hooks"; +import { useApp } from "@/hooks"; import { useAccount, useBalance } from "wagmi"; import { useCallback, useState } from "react"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; export default function BondMoreKtonModal({ - commission, isOpen, onClose = () => undefined, }: { - commission: string; isOpen: boolean; onClose?: () => void; }) { const { activeChain } = useApp(); const { address } = useAccount(); - const { calcExtraPower } = useStaking(); const [inputAmount, setInputAmount] = useState(0n); const [busy, setBusy] = useState(false); @@ -61,7 +58,6 @@ export default function BondMoreKtonModal({ isOpen={isOpen} symbol={ktonToken.symbol} decimals={ktonToken.decimals} - power={commissionWeightedPower(calcExtraPower(0n, inputAmount), commission)} balance={ktonBalance?.value || 0n} busy={busy} disabled={inputAmount <= 0n} diff --git a/src/components/bond-more-ring-modal.tsx b/src/components/bond-more-ring-modal.tsx index af68449..9ba3327 100644 --- a/src/components/bond-more-ring-modal.tsx +++ b/src/components/bond-more-ring-modal.tsx @@ -1,24 +1,21 @@ -import { commissionWeightedPower, getChainConfig, notifyTransaction } from "@/utils"; +import { getChainConfig, notifyTransaction } from "@/utils"; import BondMoreTokenModal from "./bond-more-token-modal"; import { useAccount, useBalance } from "wagmi"; -import { useApp, useStaking } from "@/hooks"; +import { useApp } from "@/hooks"; import { useCallback, useState } from "react"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; export default function BondMoreRingModal({ - commission, isOpen, onClose = () => undefined, }: { - commission: string; isOpen: boolean; onClose?: () => void; }) { const { activeChain } = useApp(); const { address } = useAccount(); const { data: ringBalance } = useBalance({ address, watch: true }); - const { calcExtraPower } = useStaking(); const [inputAmount, setInputAmount] = useState(0n); const [busy, setBusy] = useState(false); @@ -59,7 +56,6 @@ export default function BondMoreRingModal({ isOpen={isOpen} symbol={nativeToken.symbol} decimals={nativeToken.decimals} - power={commissionWeightedPower(calcExtraPower(inputAmount, 0n), commission)} balance={ringBalance?.value || 0n} busy={busy} disabled={inputAmount <= 0n} diff --git a/src/components/bond-more-token-modal.tsx b/src/components/bond-more-token-modal.tsx index ff94950..8407633 100644 --- a/src/components/bond-more-token-modal.tsx +++ b/src/components/bond-more-token-modal.tsx @@ -6,7 +6,6 @@ export default function BondMoreTokenModal({ symbol, decimals, balance, - power, busy, disabled, isReset, @@ -19,7 +18,6 @@ export default function BondMoreTokenModal({ symbol: string; decimals: number; balance: bigint; - power: bigint; busy?: boolean; disabled?: boolean; isReset?: boolean; @@ -62,7 +60,6 @@ export default function BondMoreTokenModal({ decimals={decimals} symbol={symbol} balance={balance} - power={power} isReset={isReset} onChange={onChange} /> diff --git a/src/components/collator-select-modal.tsx b/src/components/collator-select-modal.tsx index 9213825..d42c7f4 100644 --- a/src/components/collator-select-modal.tsx +++ b/src/components/collator-select-modal.tsx @@ -67,37 +67,34 @@ const columns: ColumnType[] = [ key: "power", dataIndex: "power", title: ( -
- Total-staked -
- (Power) - - {`The Collator's total-staked power is a dynamic value, inversely proportional to the commission set by - the Collator. Higher commission results in lower total-staked power and vice versa. `} - - Learn More - -
- } - enabledSafePolygon - contentClassName="w-80" - > - Info - -
+
+ Total-staked + + {`The Collator's total-staked is a dynamic value, inversely proportional to the commission set by + the Collator. Higher commission results in lower total-staked and vice versa. `} + + Learn More + +
+ } + enabledSafePolygon + contentClassName="w-80" + > + Info +
), render: (row) => {prettyNumber(row.power)}, diff --git a/src/components/do-stake.tsx b/src/components/do-stake.tsx index 1c491be..08a19e8 100644 --- a/src/components/do-stake.tsx +++ b/src/components/do-stake.tsx @@ -1,8 +1,8 @@ -import { commissionWeightedPower, getChainConfig, notifyTransaction } from "@/utils"; +import { getChainConfig, notifyTransaction } from "@/utils"; import ActiveDepositSelector from "./active-deposit-selector"; import CollatorSelector from "./collator-selector"; -import BalanceInput, { ExtraPower } from "./balance-input"; -import { useCallback, useEffect, useMemo, useState } from "react"; +import BalanceInput from "./balance-input"; +import { useCallback, useEffect, useState } from "react"; import { useApp, useStaking } from "@/hooks"; import { useAccount, useBalance, usePublicClient, useWalletClient } from "wagmi"; import EnsureMatchNetworkButton from "./ensure-match-network-button"; @@ -11,14 +11,7 @@ import { ChainID } from "@/types"; import { notification } from "./notification"; export default function DoStake() { - const { - deposits, - nominatorCollators, - collatorCommission, - isNominatorCollatorsLoading, - calcExtraPower, - updateNominatorCollators, - } = useStaking(); + const { nominatorCollators, isNominatorCollatorsLoading, updateNominatorCollators } = useStaking(); const [delegateCollator, setDelegateCollator] = useState(undefined); const [delegateRing, setDelegateRing] = useState(0n); const [delegateKton, setDelegateKton] = useState(0n); @@ -26,37 +19,12 @@ export default function DoStake() { const [busy, setBusy] = useState(false); const { activeChain } = useApp(); - const { nativeToken, ktonToken, explorer } = getChainConfig(activeChain); + const { nativeToken, explorer } = getChainConfig(activeChain); const publicClient = usePublicClient(); const { data: walletClient } = useWalletClient(); const { address } = useAccount(); const { data: ringBalance } = useBalance({ address, watch: true }); - const { data: ktonBalance } = useBalance({ address, watch: true, token: ktonToken?.address }); - - const commission = useMemo(() => { - return (delegateCollator && collatorCommission[delegateCollator]) || "0.00%"; - }, [delegateCollator, collatorCommission]); - - const ringExtraPower = useMemo( - () => commissionWeightedPower(calcExtraPower(delegateRing, 0n), commission), - [commission, delegateRing, calcExtraPower] - ); - const ktonExtraPower = useMemo( - () => commissionWeightedPower(calcExtraPower(0n, delegateKton), commission), - [commission, delegateKton, calcExtraPower] - ); - const depositsExtraPower = useMemo( - () => - commissionWeightedPower( - calcExtraPower( - deposits.filter(({ id }) => delegateDeposits.includes(id)).reduce((acc, cur) => acc + cur.value, 0n), - 0n - ), - commission - ), - [delegateDeposits, commission, deposits, calcExtraPower] - ); const handleStake = useCallback(async () => { if (delegateCollator && walletClient) { @@ -121,7 +89,6 @@ export default function DoStake() { symbol={nativeToken.symbol} logoPath={nativeToken.logoPath} decimals={nativeToken.decimals} - power={ringExtraPower} className="lg:flex-1" onChange={setDelegateRing} isReset={delegateRing <= 0} @@ -130,13 +97,11 @@ export default function DoStake() { {/* active deposit */}
-
{/* collator */}
-
diff --git a/src/components/power.tsx b/src/components/latest-rewards.tsx similarity index 67% rename from src/components/power.tsx rename to src/components/latest-rewards.tsx index 692eaa3..bdb57f8 100644 --- a/src/components/power.tsx +++ b/src/components/latest-rewards.tsx @@ -1,12 +1,11 @@ import { GET_LATEST_STAKING_REWARDS } from "@/config"; -import { useApp, useStaking } from "@/hooks"; -import { commissionWeightedPower, formatBlanace, getChainConfig, prettyNumber } from "@/utils"; +import { useApp } from "@/hooks"; +import { formatBlanace, getChainConfig } from "@/utils"; import { formatDistanceStrict } from "date-fns"; -import Image from "next/image"; import { getAddress } from "viem"; import { useAccount } from "wagmi"; import CountLoading from "./count-loading"; -import { useMemo, useRef } from "react"; +import { useRef } from "react"; import { CSSTransition } from "react-transition-group"; import { useQuery } from "@apollo/client"; @@ -34,18 +33,8 @@ interface QueryResult { stakingRecord: StakingRecord | null; } -export default function Power() { +export default function LatestRewards() { const loadingRef = useRef(null); - const { - power, - nominatorCollators, - collatorCommission, - isNominatorCollatorsInitialized, - isCollatorCommissionInitialized, - isLedgersInitialized, - isRingPoolInitialized, - isKtonPoolInitialized, - } = useStaking(); const { activeChain } = useApp(); const { address } = useAccount(); const { data: rewardData, loading: rewardLoading } = useQuery( @@ -55,37 +44,10 @@ export default function Power() { } ); - const thePower = useMemo(() => { - const isCollator = - address && Object.keys(collatorCommission).some((addr) => addr.toLowerCase() === address.toLowerCase()) - ? true - : false; - const collator = isCollator ? address : address ? nominatorCollators[address]?.at(0) : undefined; - const commission = collator ? collatorCommission[collator] : undefined; - return commissionWeightedPower(power, commission ?? "0.00%"); - }, [address, power, collatorCommission, nominatorCollators]); - const chainConfig = getChainConfig(activeChain); return (
- {/* power */} -
-
- Icon of Power - Power -
- {isLedgersInitialized && - isRingPoolInitialized && - isKtonPoolInitialized && - isNominatorCollatorsInitialized && - isCollatorCommissionInitialized ? ( - {prettyNumber(thePower)} - ) : ( - - )} -
- {/* reward records */}
Latest Staking Rewards diff --git a/src/components/records-bonded-tokens.tsx b/src/components/records-bonded-tokens.tsx index 1c96918..626fd9a 100644 --- a/src/components/records-bonded-tokens.tsx +++ b/src/components/records-bonded-tokens.tsx @@ -124,8 +124,8 @@ export default function RecordsBondedTokens({ row }: { row: StakingRecordsDataSo {row.collator.length > 0 && ( <> - - + + )}
@@ -153,8 +153,8 @@ export default function RecordsBondedTokens({ row }: { row: StakingRecordsDataSo {row.collator.length > 0 && ( <> - - + + )}
@@ -181,8 +181,8 @@ export default function RecordsBondedTokens({ row }: { row: StakingRecordsDataSo {row.collator.length > 0 && ( <> - - + + )} @@ -190,62 +190,62 @@ export default function RecordsBondedTokens({ row }: { row: StakingRecordsDataSo ); } -function BondMoreRing({ commission }: { commission: string }) { +function BondMoreRing() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} /> - setIsOpen(false)} /> + setIsOpen(false)} /> ); } -function BondMoreKton({ commission }: { commission: string }) { +function BondMoreKton() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} /> - setIsOpen(false)} /> + setIsOpen(false)} /> ); } -function BondMoreDeposit({ commission }: { commission: string }) { +function BondMoreDeposit() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} /> - setIsOpen(false)} /> + setIsOpen(false)} /> ); } -function UnbondRing({ commission }: { commission: string }) { +function UnbondRing() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} /> - setIsOpen(false)} /> + setIsOpen(false)} /> ); } -function UnbondKton({ commission }: { commission: string }) { +function UnbondKton() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} /> - setIsOpen(false)} /> + setIsOpen(false)} /> ); } -function UnbondDeposit({ commission }: { commission: string }) { +function UnbondDeposit() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} /> - setIsOpen(false)} /> + setIsOpen(false)} /> ); } diff --git a/src/components/reserved-in-staking.tsx b/src/components/reserved-in-staking.tsx index a83df62..f1d2062 100644 --- a/src/components/reserved-in-staking.tsx +++ b/src/components/reserved-in-staking.tsx @@ -4,10 +4,10 @@ import Image from "next/image"; import CountLoading from "./count-loading"; export default function ReservedInStaking() { - const { stakedRing, stakedKton, stakedDeposit, isLedgersInitialized } = useStaking(); + const { stakedRing, stakedDeposit, isLedgersInitialized } = useStaking(); const { activeChain } = useApp(); - const { nativeToken, ktonToken } = getChainConfig(activeChain); + const { nativeToken } = getChainConfig(activeChain); return (
@@ -22,16 +22,6 @@ export default function ReservedInStaking() { inDeposit={stakedDeposit} isNative /> -
- {ktonToken && ( - - )}
); } diff --git a/src/components/staking-dashboard.tsx b/src/components/staking-dashboard.tsx index 16a42ea..02d6d77 100644 --- a/src/components/staking-dashboard.tsx +++ b/src/components/staking-dashboard.tsx @@ -2,7 +2,7 @@ import { redirect } from "next/navigation"; import { useAccount } from "wagmi"; -import Power from "./power"; +import LatestRewards from "./latest-rewards"; import ReservedInStaking from "./reserved-in-staking"; import StakingDepositTabs from "./staking-deposit-tabs"; @@ -16,7 +16,7 @@ export default function StakingDashboard() { return ( <>
- +
diff --git a/src/components/staking-records.tsx b/src/components/staking-records.tsx index 9883b75..d1b94a7 100644 --- a/src/components/staking-records.tsx +++ b/src/components/staking-records.tsx @@ -39,7 +39,7 @@ export default function StakingRecords() { { key: "collator", dataIndex: "collator", - width: "22%", + width: "30%", title: Collator, render: (row) => { if (row.collator) { @@ -74,43 +74,9 @@ export default function StakingRecords() { return ; }, }, - { - key: "stakedPower", - dataIndex: "stakedPower", - title: Your staked (Power), - render: (row) => { - if (row.collator) { - return {prettyNumber(row.stakedPower)}; - } - - return ( -
- {prettyNumber(row.stakedPower)} - - The power is not working yet, You can delegate a collator to complete staking. - - } - className="w-fit" - contentClassName="w-64" - > - Collator tooltip - -
- ); - }, - }, { key: "bondedTokens", dataIndex: "bondedTokens", - width: "32%", title: Your bonded tokens, render: (row) => , }, diff --git a/src/components/unbond-deposit-modal.tsx b/src/components/unbond-deposit-modal.tsx index 30cdf9f..082b229 100644 --- a/src/components/unbond-deposit-modal.tsx +++ b/src/components/unbond-deposit-modal.tsx @@ -1,39 +1,24 @@ -import { Key, useCallback, useMemo, useState } from "react"; +import { Key, useCallback, useState } from "react"; import Modal from "./modal"; import CheckboxGroup from "./checkbox-group"; -import { commissionWeightedPower, formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; -import { ExtraPower } from "./balance-input"; +import { formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; import { useApp, useStaking } from "@/hooks"; import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; export default function UnbondDepositModal({ - commission, isOpen, onClose = () => undefined, }: { - commission: string; isOpen: boolean; onClose?: () => void; }) { - const { deposits, stakedDeposits, calcExtraPower } = useStaking(); + const { deposits, stakedDeposits } = useStaking(); const { activeChain } = useApp(); const [checkedDeposits, setCheckedDeposits] = useState([]); const [busy, setBusy] = useState(false); - const extraPower = useMemo( - () => - commissionWeightedPower( - calcExtraPower( - deposits.filter(({ id }) => checkedDeposits.includes(id)).reduce((acc, cur) => acc + cur.value, 0n), - 0n - ), - commission - ), - [deposits, commission, checkedDeposits, calcExtraPower] - ); - const availableDeposits = deposits.filter(({ id }) => stakedDeposits.includes(id)); const { nativeToken } = getChainConfig(activeChain); @@ -94,10 +79,6 @@ export default function UnbondDepositModal({ onChange={setCheckedDeposits as (values: Key[]) => void} className="max-h-80 overflow-y-auto" /> - -
- - ) : ( No deposits to unbond diff --git a/src/components/unbond-kton-modal.tsx b/src/components/unbond-kton-modal.tsx index 6fcb1cc..e05df15 100644 --- a/src/components/unbond-kton-modal.tsx +++ b/src/components/unbond-kton-modal.tsx @@ -1,4 +1,4 @@ -import { commissionWeightedPower, formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; +import { formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; import UnbondTokenModal from "./unbond-token-modal"; import { useApp, useStaking } from "@/hooks"; import { useCallback, useState } from "react"; @@ -6,16 +6,14 @@ import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; export default function UnbondKtonModal({ - commission, isOpen, onClose = () => undefined, }: { - commission: string; isOpen: boolean; onClose?: () => void; }) { const { activeChain } = useApp(); - const { stakedKton, calcExtraPower } = useStaking(); + const { stakedKton } = useStaking(); const [inputAmount, setInputAmount] = useState(0n); const [busy, setBusy] = useState(false); @@ -63,7 +61,6 @@ export default function UnbondKtonModal({ isOpen={isOpen} symbol={ktonToken.symbol} decimals={ktonToken.decimals} - power={commissionWeightedPower(calcExtraPower(0n, inputAmount), commission)} balance={stakedKton} busy={busy} disabled={inputAmount <= 0n} diff --git a/src/components/unbond-ring-modal.tsx b/src/components/unbond-ring-modal.tsx index 110d43f..dc5cdae 100644 --- a/src/components/unbond-ring-modal.tsx +++ b/src/components/unbond-ring-modal.tsx @@ -1,4 +1,4 @@ -import { commissionWeightedPower, formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; +import { formatBlanace, getChainConfig, notifyTransaction } from "@/utils"; import UnbondTokenModal from "./unbond-token-modal"; import { useApp, useStaking } from "@/hooks"; import { useCallback, useState } from "react"; @@ -6,16 +6,14 @@ import { notification } from "./notification"; import { writeContract, waitForTransaction } from "@wagmi/core"; export default function UnbondRingModal({ - commission, isOpen, onClose = () => undefined, }: { - commission: string; isOpen: boolean; onClose?: () => void; }) { const { activeChain } = useApp(); - const { stakedRing, calcExtraPower } = useStaking(); + const { stakedRing } = useStaking(); const [inputAmount, setInputAmount] = useState(0n); const [busy, setBusy] = useState(false); @@ -62,7 +60,6 @@ export default function UnbondRingModal({ isOpen={isOpen} symbol={nativeToken.symbol} decimals={nativeToken.decimals} - power={commissionWeightedPower(calcExtraPower(inputAmount, 0n), commission)} balance={stakedRing} busy={busy} disabled={inputAmount <= 0n} diff --git a/src/components/unbond-token-modal.tsx b/src/components/unbond-token-modal.tsx index e2dc719..bb934f5 100644 --- a/src/components/unbond-token-modal.tsx +++ b/src/components/unbond-token-modal.tsx @@ -6,7 +6,6 @@ export default function UnbondTokenModal({ symbol, decimals, balance, - power, busy, disabled, isReset, @@ -19,7 +18,6 @@ export default function UnbondTokenModal({ symbol: string; decimals: number; balance: bigint; - power: bigint; busy?: boolean; disabled?: boolean; isReset?: boolean; @@ -57,9 +55,7 @@ export default function UnbondTokenModal({ decimals={decimals} symbol={symbol} balance={balance} - power={power} isReset={isReset} - powerChanges="less" onChange={onChange} /> From f944d6371e5eb45da2e1890890aaa5cd6a4eb5ac Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 13:45:29 +0800 Subject: [PATCH 05/14] Improve header --- public/images/chain/crab.png | Bin 0 -> 1302 bytes public/images/chain/darwinia.png | Bin 0 -> 1099 bytes src/app/layout.tsx | 3 - src/components/custom-rpc/add-rpc-modal.tsx | 55 --------- src/components/custom-rpc/index.tsx | 57 --------- src/components/custom-rpc/rpc-selector.tsx | 66 ---------- .../ensure-match-network-button.tsx | 11 +- src/components/header/chain-switch.tsx | 114 ++++++++++++++++++ src/components/header/index.tsx | 18 +-- src/components/header/network-selector.tsx | 64 ---------- src/components/selector.tsx | 2 +- src/config/chains/crab.ts | 1 + src/config/chains/darwinia.ts | 1 + src/types/chain.ts | 1 + 14 files changed, 123 insertions(+), 270 deletions(-) create mode 100644 public/images/chain/crab.png create mode 100644 public/images/chain/darwinia.png delete mode 100644 src/components/custom-rpc/add-rpc-modal.tsx delete mode 100644 src/components/custom-rpc/index.tsx delete mode 100644 src/components/custom-rpc/rpc-selector.tsx create mode 100644 src/components/header/chain-switch.tsx delete mode 100644 src/components/header/network-selector.tsx diff --git a/public/images/chain/crab.png b/public/images/chain/crab.png new file mode 100644 index 0000000000000000000000000000000000000000..c0de690c5171c34768a431581af556a6145576c1 GIT binary patch literal 1302 zcmV+x1?l>UP)2A;YtaAy|LW!U%)#uhp5U5=*oAD+b5_Y=K*CWiyb7X0wg3PC26R$R zQve`el)>jJoVJ+&00fdrL_t(|+SQufva28rg^!~ACF%P=?x|2_6@p@GJDt6*_E^J5 zR)U*K|DDw|&t_THmF`;CWij*o?~*jYtkluE%+qHG1;8vKw}(W8IfKmgjLeb%a_dQi z6X#MslUYI7QRbNGUBogVfb%Y9G8^J{Qtx5r6^OH#b$;0?AkJf!>9sWE_Oj%KWF~_& zUQfoHvyg)l#eqYPzH=IQNZ{f1&l9Kz_={lTl@ySdtE!L zat7lwl(}0F`6NVoWm!;=kCo-iX2G!YW(mpg^4KtQWEOjCyC0La{wS{Qu<6Jwb~Zz* z@wR|yt#xvc3QcDdaW+GOjkp*sZJBJ8aqY*6M4KVuc|5t3V}{s+SfnyY#AiszsAqD_ zkT9qU5*fHc;Qyij79EyUHv^~O)IKVwO zRRblY{Lz~di;^;k>6q#j>@)c$5m-1B3LEaVuIK<=DpqaZ7|Ri|VL-?drDxf38K znM!03n6tiJImEGnbHWA(zViw+AN5ufnZqYiyj{M z7UJ`;xDWL|0cq_|(-o^!mPOqTV+bgE(nEjotqFn+~i z)I!rZ*k2cF48e-m;uwmyuIY7Gcyw1Nio6FgT}ZICVscGYIVf%qV*1<1sI1Z8nA{pu z@c%?NunSOL-s0M)N~~|&qNE4e+YvcY&*iEtL2^Z6`(#xVqO_6dnZ>sz+NA(zvFfCm zIjDMfXGpYJq1+LZye)I&Sh|SQ#h64=rL4Bxswe`p2vtx!H}x3|QzcP*qJWJP+eV(s zU4-&f6vFlxJ0i8=4r#Fd13wLr+;i4epQV~5dBme6%~uD>;Zk_i?ouHyy?2;UiK%hdU4W4=VL_^8~4|&j0`b M07*qoM6N<$f}`|tUjP6A literal 0 HcmV?d00001 diff --git a/public/images/chain/darwinia.png b/public/images/chain/darwinia.png new file mode 100644 index 0000000000000000000000000000000000000000..874eb2960a0aa19ae95d6062cb3a85425ba9ba9a GIT binary patch literal 1099 zcmV-R1ho5!P)vp z!TT&wJOUEJ5gJsy6_f}!0t#{?K#<-VF+d~IIY{aI8{C=hWMg-h?&F&@X_|cceedne z+cy(2Dcaor9I>~jEglJ{2klsuKrd5i>I z=u`;FkW)cHd@8za#1wqGnn$dB`@-t3W}SU`%FduT;C9X*3d3X))ko#8vp)c^@|7uo zjE^|mUe(IW{Pmh#0pPhZ2N-5pIrpMtr=M)Fz}1{wnYv)h05E?A0BI(+><^l#eB}V( zGL}Lxt_r4HV7&~|Wsq|#?-E-ateMr7^tK~DyRCk1a+k|KfVErA0M#N_eF{1 z3`mF3xXI^g4*arIH<$n>Lko67sLH7L&^%&!B<<=Dl5M+ArE=d&-uJS+#)) z<{+pL-TUqtp8hn#*6Moj@7!P4gtpYsy|8>*-6Kl>^@7?cHuUq z;)zvACQ}O&siV&}q`#xmfXqd#$mTl;0I%Jq6jhscF$;^1c>1jk)~F)fitWk&huyyb zFyg+)8+6dRlUg&1P&!>)V?rY99ulv%@qSxt^xaMY|Cb7^tOF~#FAMR*)p4O9Y6x)v z)<{yPkC(m|vOu4%v$iav9iyYOf?H$#dZi6MjD*DLqrzZ71o~lwe&nGatmwx#`XP~i6r~?{>BnmN;hla(K);AE zDjLX$rofAvI*AY%r@k~swAQ)lO8BpB=$BoTD>YPCYT - - diff --git a/src/components/custom-rpc/add-rpc-modal.tsx b/src/components/custom-rpc/add-rpc-modal.tsx deleted file mode 100644 index 7f8cde3..0000000 --- a/src/components/custom-rpc/add-rpc-modal.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { RpcMeta } from "@/types"; -import { ChangeEventHandler, useState } from "react"; -import Modal from "../modal"; - -export default function AddRpcModal({ - isOpen, - onClose = () => undefined, - onSave = () => undefined, -}: { - isOpen: boolean; - onClose?: () => void; - onSave?: (rpcMeta: RpcMeta) => void; -}) { - const [rpcMeta, setRpcMeta] = useState(); - - return ( - -
- setRpcMeta((prev) => ({ name: e.target.value, url: prev?.url || "" }))} - /> - setRpcMeta((prev) => ({ name: prev?.name, url: e.target.value }))} - /> - -
- - -
- - ); -} - -function Input({ label, onChange }: { label: string; onChange: ChangeEventHandler }) { - return ( -
- {label} - -
- ); -} diff --git a/src/components/custom-rpc/index.tsx b/src/components/custom-rpc/index.tsx deleted file mode 100644 index 2a101fe..0000000 --- a/src/components/custom-rpc/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -"use client"; - -import { - useFloating, - offset, - useTransitionStyles, - useClick, - useDismiss, - useInteractions, - FloatingPortal, -} from "@floating-ui/react"; -import Image from "next/image"; -import { useState } from "react"; -import RpcSelector from "./rpc-selector"; - -export default function CustomRpc() { - const [isOpen, setIsOpen] = useState(false); - - const { refs, context, floatingStyles } = useFloating({ - open: isOpen, - onOpenChange: setIsOpen, - placement: "bottom-end", - middleware: [offset(10)], - }); - - const { styles, isMounted } = useTransitionStyles(context, { - initial: { transform: "translateY(-20px)", opacity: 0 }, - open: { transform: "translateY(0)", opacity: 1 }, - close: { transform: "translateY(-20px)", opacity: 0 }, - }); - - const click = useClick(context); - const dismiss = useDismiss(context); - const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]); - - return ( - <> - - - {isMounted && ( - -
-
- setIsOpen(false)} /> -
-
-
- )} - - ); -} diff --git a/src/components/custom-rpc/rpc-selector.tsx b/src/components/custom-rpc/rpc-selector.tsx deleted file mode 100644 index f251dd6..0000000 --- a/src/components/custom-rpc/rpc-selector.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { useApp } from "@/hooks"; -import { RpcMeta } from "@/types"; -import { useState } from "react"; -import AddRpcModal from "./add-rpc-modal"; - -export default function RpcSelector({ onClose = () => undefined }: { onClose?: () => void }) { - const [isOpen, setIsOpen] = useState(false); - const { rpcMetas, setRpcMetas } = useApp(); - - return ( - <> -
-
-
- {rpcMetas.map((rpcMeta) => ( - - ))} -
-
- -
-
- or -
-
- - -
- - setIsOpen(false)} - onSave={(value) => { - setRpcMetas((prev) => (prev.some(({ url }) => url === value.url) ? prev : [...prev, value])); - setIsOpen(false); - }} - /> - - ); -} - -function RpcItem({ rpcMeta, onClose }: { rpcMeta: RpcMeta; onClose: () => void }) { - const { activeRpc, setActiveRpc } = useApp(); - - return ( -
{ - setActiveRpc(rpcMeta); - onClose(); - }} - > -
- via {rpcMeta.name ?? rpcMeta.url} -
- ); -} diff --git a/src/components/ensure-match-network-button.tsx b/src/components/ensure-match-network-button.tsx index 8a093ef..a2082a0 100644 --- a/src/components/ensure-match-network-button.tsx +++ b/src/components/ensure-match-network-button.tsx @@ -34,7 +34,6 @@ export default forwardRef< >(function EnsureMatchNetworkButton({ children, onClick, kind = "opacity", disabled, busy, ...rest }, ref) { const { activeChain } = useApp(); const { chain } = useNetwork(); - const { switchNetwork } = useSwitchNetwork(); const isMatch = useMemo(() => chain?.id === activeChain, [chain?.id, activeChain]); @@ -103,15 +102,7 @@ export default forwardRef<
-

- You are connected to the Wrong Chain.{" "} - switchNetwork && switchNetwork(activeChain)} - > - Switch network - -

+

You are connected to the Wrong Chain.

diff --git a/src/components/header/chain-switch.tsx b/src/components/header/chain-switch.tsx new file mode 100644 index 0000000..9a16256 --- /dev/null +++ b/src/components/header/chain-switch.tsx @@ -0,0 +1,114 @@ +"use client"; + +import { useApp } from "@/hooks"; +import { getChainConfig, getChainConfigs } from "@/utils"; +import { + FloatingPortal, + offset, + size, + useClick, + useDismiss, + useFloating, + useInteractions, + useTransitionStyles, +} from "@floating-ui/react"; +import Image from "next/image"; +import { useEffect, useState } from "react"; +import { useNetwork, useSwitchNetwork } from "wagmi"; + +const chainOptions = getChainConfigs(); + +export default function ChainSwitch() { + const { chain } = useNetwork(); + const { switchNetwork } = useSwitchNetwork(); + const { setActiveChain } = useApp(); + const [currentChain, setCurrentChain] = useState(chainOptions.find((option) => option.chainId === chain?.id)); + useEffect(() => { + const c = chainOptions.find((option) => option.chainId === chain?.id); + setCurrentChain(c); + c && setActiveChain(c.chainId); + }, [chain?.id, setActiveChain]); + + const [isOpen, setIsOpen] = useState(false); + const { refs, context, floatingStyles } = useFloating({ + open: isOpen, + onOpenChange: setIsOpen, + middleware: [ + offset(10), + size({ + apply({ rects, elements }) { + Object.assign(elements.floating.style, { width: `${rects.reference.width}px` }); + }, + }), + ], + }); + const { styles, isMounted } = useTransitionStyles(context, { + initial: { transform: "translateY(-20px)", opacity: 0 }, + open: { transform: "translateY(0)", opacity: 1 }, + close: { transform: "translateY(-20px)", opacity: 0 }, + }); + const click = useClick(context); + const dismiss = useDismiss(context); + const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]); + + return chain ? ( + <> + + + {isMounted && ( + +
+
+ {chainOptions.map((option) => ( + + ))} +
+
+
+ )} + + ) : null; +} + +function getChainLogo(fileName: string) { + return `/images/chain/${fileName}`; +} diff --git a/src/components/header/index.tsx b/src/components/header/index.tsx index 8844c2c..7b06898 100644 --- a/src/components/header/index.tsx +++ b/src/components/header/index.tsx @@ -1,7 +1,6 @@ import dynamic from "next/dynamic"; -import NetworkSelector from "./network-selector"; import Image from "next/image"; -import CustomRpc from "../custom-rpc"; +import ChainSwitch from "./chain-switch"; const User = dynamic(() => import("./user"), { ssr: false }); @@ -10,19 +9,10 @@ export default function Header({ className }: { className: string }) {
Logo -
- -
-
- -
-
- -
- - -
+
+ +
diff --git a/src/components/header/network-selector.tsx b/src/components/header/network-selector.tsx deleted file mode 100644 index a866eb9..0000000 --- a/src/components/header/network-selector.tsx +++ /dev/null @@ -1,64 +0,0 @@ -"use client"; - -import { useApp } from "@/hooks"; -import Selector from "../selector"; -import { getChainConfig, getChainConfigs } from "@/utils"; -import { useState } from "react"; -import ActionButton from "./action-button"; - -const chainConfigs = getChainConfigs(); - -export default function NetworkSelector() { - const [isOpen, setIsOpen] = useState(false); - const { activeChain, setActiveChain } = useApp(); - - const chainConfig = getChainConfig(activeChain); - - return ( - <> - {/* mobile */} -
- {chainConfig.name}} - menuClassName="border border-primary p-large flex flex-col items-start gap-large bg-app-black" - isOpen={isOpen} - setIsOpen={setIsOpen} - > - {chainConfigs.map(({ name, chainId }) => ( - { - setActiveChain(chainId); - setIsOpen(false); - }} - > - {name} - - ))} - -
- - {/* pc */} -
-
- {chainConfigs.map(({ name, chainId }) => ( - - ))} -
-
- - ); -} diff --git a/src/components/selector.tsx b/src/components/selector.tsx index 7b3d024..4642d4f 100644 --- a/src/components/selector.tsx +++ b/src/components/selector.tsx @@ -89,7 +89,7 @@ export const Button = forwardRef {children} diff --git a/src/config/chains/crab.ts b/src/config/chains/crab.ts index a90aedc..3301000 100644 --- a/src/config/chains/crab.ts +++ b/src/config/chains/crab.ts @@ -50,4 +50,5 @@ export const crabChainConfig: ChainConfig = { https: "https://crab-rpc.darwinia.network", }, }, + logo: "crab.png", }; diff --git a/src/config/chains/darwinia.ts b/src/config/chains/darwinia.ts index c8810bb..85ffd57 100644 --- a/src/config/chains/darwinia.ts +++ b/src/config/chains/darwinia.ts @@ -52,4 +52,5 @@ export const darwiniaChainConfig: ChainConfig = { https: "https://rpc.darwinia.network", }, }, + logo: "darwinia.png", }; diff --git a/src/types/chain.ts b/src/types/chain.ts index e347722..141bf6f 100644 --- a/src/types/chain.ts +++ b/src/types/chain.ts @@ -51,5 +51,6 @@ export interface ChainConfig { }; secondsPerBlock: number; substrate: Substrate; + logo: string; // File name isTestNet?: boolean; } From a955dbc370ba4acde62333134df07ba59d97b521 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 13:47:08 +0800 Subject: [PATCH 06/14] Improve scrollbar --- src/app/globals.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/globals.css b/src/app/globals.css index 8a4b86b..a07478f 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -2,6 +2,17 @@ @tailwind components; @tailwind utilities; +@layer base { + ::-webkit-scrollbar { + width: 6px; + } + ::-webkit-scrollbar-thumb { + border-radius: 10px; + box-shadow: inset 0 0 5x rgba(0, 0, 0, 0.2); + background: hsla(0, 0%, 100%, 0.4); + } +} + .app-header { height: 70px; position: fixed; From a9308c622f80a66a9ea04df0752c3ff69a2d3a18 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 13:52:55 +0800 Subject: [PATCH 07/14] Update wallets in rainbow provider --- src/providers/rainbow-provider.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/providers/rainbow-provider.tsx b/src/providers/rainbow-provider.tsx index 4ace653..190759a 100644 --- a/src/providers/rainbow-provider.tsx +++ b/src/providers/rainbow-provider.tsx @@ -2,7 +2,7 @@ import "@rainbow-me/rainbowkit/styles.css"; import { getDefaultWallets, RainbowKitProvider, connectorsForWallets, darkTheme } from "@rainbow-me/rainbowkit"; -import { trustWallet, imTokenWallet, okxWallet, talismanWallet, safeWallet } from "@rainbow-me/rainbowkit/wallets"; +import { okxWallet, talismanWallet, safeWallet, rabbyWallet } from "@rainbow-me/rainbowkit/wallets"; import { configureChains, createConfig, WagmiConfig } from "wagmi"; import { publicProvider } from "wagmi/providers/public"; @@ -53,10 +53,9 @@ export function RainbowProvider({ children }: PropsWithChildren) { { groupName: "More", wallets: [ - talismanWallet({ chains }), okxWallet({ projectId, chains }), - imTokenWallet({ projectId, chains }), - trustWallet({ projectId, chains }), + rabbyWallet({ chains }), + talismanWallet({ chains }), safeWallet({ chains }), ], }, From b51fbe4f2eadf305f3f39d23b86713aed198d651 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 13:57:43 +0800 Subject: [PATCH 08/14] Remove vercel.json --- vercel.json | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 vercel.json diff --git a/vercel.json b/vercel.json deleted file mode 100644 index 4a91e26..0000000 --- a/vercel.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "headers": [ - { - "source": "/(.*)", - "headers": [ - { - "key": "X-Content-Type-Options", - "value": "nosniff" - }, - { - "key": "Referrer-Policy", - "value": "origin-when-cross-origin" - }, - { - "key": "X-Frame-Options", - "value": "SAMEORIGIN" - }, - { - "key": "Strict-Transport-Security", - "value": "max-age=2592000" - } - ] - } - ], - "rewrites": [ - { - "source": "/(.*)", - "destination": "/index.html" - } - ] -} From c483bf65072f6e3cc695a2b1241502df19644ea5 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 14:47:49 +0800 Subject: [PATCH 09/14] Revert vercel.json --- vercel.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 vercel.json diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..4a91e26 --- /dev/null +++ b/vercel.json @@ -0,0 +1,31 @@ +{ + "headers": [ + { + "source": "/(.*)", + "headers": [ + { + "key": "X-Content-Type-Options", + "value": "nosniff" + }, + { + "key": "Referrer-Policy", + "value": "origin-when-cross-origin" + }, + { + "key": "X-Frame-Options", + "value": "SAMEORIGIN" + }, + { + "key": "Strict-Transport-Security", + "value": "max-age=2592000" + } + ] + } + ], + "rewrites": [ + { + "source": "/(.*)", + "destination": "/index.html" + } + ] +} From b64700e01e2e4e308274f497c7124cbf9ea0caaf Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 14:54:29 +0800 Subject: [PATCH 10/14] Update vercel.json --- vercel.json | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/vercel.json b/vercel.json index 4a91e26..f4ac3d4 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,22 @@ { "headers": [ + { + "source": "/manifest.json", + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "X-Requested-With, content-type, Authorization" + } + ] + }, { "source": "/(.*)", "headers": [ @@ -22,10 +39,5 @@ ] } ], - "rewrites": [ - { - "source": "/(.*)", - "destination": "/index.html" - } - ] + "rewrites": [{ "source": "/:path((?!manifest/).*)", "destination": "/index.html" }] } From 0167cd20ea72d009587fc5da55bff68ec97865c0 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 15:00:27 +0800 Subject: [PATCH 11/14] Remove X-Frame-Options header --- vercel.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vercel.json b/vercel.json index f4ac3d4..7f30e57 100644 --- a/vercel.json +++ b/vercel.json @@ -28,10 +28,6 @@ "key": "Referrer-Policy", "value": "origin-when-cross-origin" }, - { - "key": "X-Frame-Options", - "value": "SAMEORIGIN" - }, { "key": "Strict-Transport-Security", "value": "max-age=2592000" From 2664fbd2854726dc52b9c6816f8168e9ef234bf7 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Thu, 21 Mar 2024 15:10:43 +0800 Subject: [PATCH 12/14] Update vercel.json --- vercel.json | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/vercel.json b/vercel.json index 7f30e57..418a8a0 100644 --- a/vercel.json +++ b/vercel.json @@ -1,22 +1,5 @@ { "headers": [ - { - "source": "/manifest.json", - "headers": [ - { - "key": "Access-Control-Allow-Origin", - "value": "*" - }, - { - "key": "Access-Control-Allow-Methods", - "value": "GET" - }, - { - "key": "Access-Control-Allow-Headers", - "value": "X-Requested-With, content-type, Authorization" - } - ] - }, { "source": "/(.*)", "headers": [ @@ -35,5 +18,5 @@ ] } ], - "rewrites": [{ "source": "/:path((?!manifest/).*)", "destination": "/index.html" }] + "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] } From 298d2d37ac47655c75423b90cfd6a9b6150e4ecf Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Fri, 22 Mar 2024 09:56:03 +0800 Subject: [PATCH 13/14] Keep token decimals to display for balance input --- src/components/balance-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/balance-input.tsx b/src/components/balance-input.tsx index 8ac1329..9f8be37 100644 --- a/src/components/balance-input.tsx +++ b/src/components/balance-input.tsx @@ -43,7 +43,7 @@ export default function BalanceInput({ }`} > { const _hasError = Number.isNaN(Number(e.target.value)); From 75b42a0cab02b1ef9328f27bcb4ca759afd4ca1c Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Fri, 22 Mar 2024 09:57:45 +0800 Subject: [PATCH 14/14] Dynamic import ChainSwitch with ssr disabled --- src/components/header/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/header/index.tsx b/src/components/header/index.tsx index 7b06898..5e4bff4 100644 --- a/src/components/header/index.tsx +++ b/src/components/header/index.tsx @@ -1,7 +1,7 @@ import dynamic from "next/dynamic"; import Image from "next/image"; -import ChainSwitch from "./chain-switch"; +const ChainSwitch = dynamic(() => import("./chain-switch"), { ssr: false }); const User = dynamic(() => import("./user"), { ssr: false }); export default function Header({ className }: { className: string }) {