diff --git a/README.md b/README.md index d484211..c50c0c0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Xion Staking +# XION Staking -A proof of concept application to stake tokens in Xion, using the native +A proof of concept application to stake tokens in XION, using the native authentication via the dashboard. diff --git a/src/features/core/components/base.tsx b/src/features/core/components/base.tsx index dec7424..b60c07f 100644 --- a/src/features/core/components/base.tsx +++ b/src/features/core/components/base.tsx @@ -95,7 +95,7 @@ export const ButtonPill = ({ {...props} className={[ "cursor-pointer rounded-full bg-bg-550 px-[8px] py-[4px] text-white hover:bg-bg-600 disabled:cursor-not-allowed disabled:bg-bg-600 disabled:text-typo-150", - variant === "danger" ? "[&]:text-danger" : "", + variant === "danger" ? "[&]:bg-dangerBg [&]:text-danger" : "", className, ].join(" ")} /> diff --git a/src/features/staking/components/delegation-details.tsx b/src/features/staking/components/delegation-details.tsx index 0126446..674d14c 100644 --- a/src/features/staking/components/delegation-details.tsx +++ b/src/features/staking/components/delegation-details.tsx @@ -254,8 +254,8 @@ const UnbondingRow = ({ onClick={() => { staking.dispatch( setModalOpened({ - content: { unbonding }, - type: "cancel-staking", + content: { unbondings: [unbonding] }, + type: "cancel-unstaking", }), ); }} diff --git a/src/features/staking/components/modals/cancel-unstaking.tsx b/src/features/staking/components/modals/cancel-unstaking.tsx index cfb8292..15a0841 100644 --- a/src/features/staking/components/modals/cancel-unstaking.tsx +++ b/src/features/staking/components/modals/cancel-unstaking.tsx @@ -6,10 +6,10 @@ import CommonModal, { ModalDescription, } from "@/features/core/components/common-modal"; -import { cancelUnstakingAction } from "../../context/actions"; +import { fetchUserDataAction } from "../../context/actions"; import { useStaking } from "../../context/hooks"; import { setModalOpened } from "../../context/reducer"; -import type { StakeAddresses } from "../../lib/core/tx"; +import { type StakeAddresses, cancelUnbonding } from "../../lib/core/tx"; type Step = "completed" | "confirm"; @@ -24,13 +24,13 @@ const CancelUnstakingModal = () => { const { modal } = staking.state; - const isOpen = modal?.type === "cancel-staking"; + const isOpen = modal?.type === "cancel-unstaking"; if (!isOpen) return null; - const { unbonding } = modal?.content || {}; + const { unbondings } = modal?.content || {}; - if (!unbonding) return null; + if (!unbondings?.length) return null; const content = (() => { if (currentStep === "confirm") { @@ -52,14 +52,21 @@ const CancelUnstakingModal = () => { setIsLoading(true); - const addresses: StakeAddresses = { - delegator: account.bech32Address, - validator: unbonding.validator, - }; + unbondings + .reduce(async (promise, unbonding) => { + await promise; + + const addresses: StakeAddresses = { + delegator: account.bech32Address, + validator: unbonding.validator, + }; + + await cancelUnbonding(addresses, unbonding, client); + }, Promise.resolve()) + .then(() => { + // Don't await for this so the button can be enabled earlier + fetchUserDataAction(account.bech32Address, staking); - cancelUnstakingAction(addresses, unbonding, client, staking) - .then((fetchFn) => { - fetchFn(); setStep("completed"); }) .catch(() => { diff --git a/src/features/staking/components/validator-delegation.tsx b/src/features/staking/components/validator-delegation.tsx index ae5977f..dcd2c41 100644 --- a/src/features/staking/components/validator-delegation.tsx +++ b/src/features/staking/components/validator-delegation.tsx @@ -71,6 +71,7 @@ export default function ValidatorDelegation() { const totalRewards = getTotalRewards(null, staking.state); const canShowDetail = getCanShowDetails(staking.state); + const unbondings = staking.state.unbondings?.items || []; const content = !isConnected ? (