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

feat: handle intermediate states #412

Merged
merged 4 commits into from
Dec 3, 2024
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: 2 additions & 3 deletions src/app/api/getNetworkInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ export const getNetworkInfo = async (): Promise<NetworkInfo> => {
"/v2/network-info",
"Error getting network info",
)) as AxiosResponse<NetworkInfoDataResponse>;

const { params, staking_status } = data.data;

const stakingVersions = params.bbn
const stakingVersions = (params.bbn || [])
.sort((a, b) => a.version - b.version) // Sort by version ascending
.map((v) => ({
version: v.version,
Expand Down Expand Up @@ -85,7 +84,7 @@ export const getNetworkInfo = async (): Promise<NetworkInfo> => {
);

// Map the BTC checkpoint params to the expected format
const epochCheckVersions = params.btc
const epochCheckVersions = (params.btc || [])
.sort((a, b) => a.version - b.version) // Sort by version ascending
.map((v) => ({
version: v.version,
Expand Down
105 changes: 0 additions & 105 deletions src/app/components/Modals/FilterOrdinalsModal.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions src/app/components/Staking/Staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
} from "@/app/hooks/services/useTransactionService";
import { useHealthCheck } from "@/app/hooks/useHealthCheck";
import { useAppState } from "@/app/state";
import { useDelegationV2State } from "@/app/state/DelegationV2State";
import { DelegationV2StakingState } from "@/app/types/delegationsV2";
import { ErrorHandlerParam, ErrorState } from "@/app/types/errors";
import {
FinalityProvider,
Expand Down Expand Up @@ -74,6 +76,7 @@ export const Staking = () => {
useLocalStorage<boolean>("bbn-staking-cancelFeedbackModalOpened ", false);

const { createDelegationEoi, estimateStakingFee } = useTransactionService();
const { addDelegation } = useDelegationV2State();
const { networkInfo } = useAppState();
const latestParam = networkInfo?.params.bbnStakingParams?.latestParam;
const stakingStatus = networkInfo?.stakingStatus;
Expand Down Expand Up @@ -226,6 +229,13 @@ export const Staking = () => {
signingCallback,
);

addDelegation({
stakingAmount: stakingAmountSat,
stakingTxHashHex,
startHeight: 0,
state: DelegationV2StakingState.INTERMEDIATE_PENDING_VERIFICATION,
});

setStakingTxHashHex(stakingTxHashHex);
setPendingVerificationOpen(true);
} catch (error: Error | any) {
Expand Down
10 changes: 10 additions & 0 deletions src/app/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
export const ONE_SECOND = 1000;
export const ONE_MINUTE = 60 * ONE_SECOND;

export const DELEGATION_ACTIONS = {
STAKE: "STAKE",
UNBOUND: "UNBOUND",
WITHDRAW_ON_EARLY_UNBOUNDING: "WITHDRAW_ON_EARLY_UNBOUNDING",
WITHDRAW_ON_TIMELOCK: "WITHDRAW_ON_TIMELOCK",
WITHDRAW_ON_TIMELOCK_SLASHING: "WITHDRAW_ON_TIMELOCK_SLASHING",
WITHDRAW_ON_EARLY_UNBOUNDING_SLASHING:
"WITHDRAW_ON_EARLY_UNBOUNDING_SLASHING",
} as const;
Loading