Skip to content

Commit

Permalink
feat: handle intermediate states (#412)
Browse files Browse the repository at this point in the history
* feat: add delegation service

* feat: add selegation storage

* feat: remove ordinal modal

* feat: update delegation statuses
  • Loading branch information
totraev authored Dec 3, 2024
1 parent a255568 commit ff97500
Show file tree
Hide file tree
Showing 12 changed files with 529 additions and 316 deletions.
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

0 comments on commit ff97500

Please sign in to comment.