Skip to content

Commit

Permalink
feat: support cancelling unbondings
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Mar 7, 2024
1 parent a6ce1fc commit c08361c
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 269 deletions.
244 changes: 31 additions & 213 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@burnt-labs/abstraxion": "^1.0.0-alpha.38",
"@burnt-labs/constants": "^0.1.0-alpha.6",
"@burnt-labs/ui": "^0.1.0-alpha.7",
"@cosmjs/cosmwasm-stargate": "^0.31.3",
"@cosmjs/cosmwasm-stargate": "^0.32.2",
"@cosmjs/proto-signing": "^0.32.2",
"@cosmjs/stargate": "^0.32.2",
"@mui/base": "^5.0.0-beta.38",
Expand Down
20 changes: 4 additions & 16 deletions src/features/core/context/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { CoreState } from "./state";

export type CoreAction =
| {
content: CoreState["isLoadingBlocking"];
type: "SET_IS_LOADING_BLOCKING";
}
| {
content: CoreState["popupOpenId"];
type: "SET_POPUP_OPEN_ID";
}
| {
content: never;
type: never;
};

type Content<T extends CoreAction["type"]> = Extract<
Expand All @@ -22,23 +22,11 @@ export const setPopupOpenId = (
type: "SET_POPUP_OPEN_ID",
});

// @TODO: Confirm if needed
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const setIsLoadingBlocking = (
content: Content<"SET_IS_LOADING_BLOCKING">,
): CoreAction => ({
content,
type: "SET_IS_LOADING_BLOCKING",
});

export const reducer = (state: CoreState, action: CoreAction) => {
switch (action.type) {
case "SET_POPUP_OPEN_ID":
return { ...state, popupOpenId: action.content };

case "SET_IS_LOADING_BLOCKING":
return { ...state, isLoadingBlocking: action.content };

default:
action satisfies never;

Expand Down
2 changes: 0 additions & 2 deletions src/features/core/context/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createContext } from "react";
import type { CoreAction } from "./reducer";

export type CoreState = {
isLoadingBlocking: boolean;
popupOpenId: null | string;
};

Expand All @@ -14,7 +13,6 @@ export type CoreContextType = {
};

export const defaultState: CoreState = {
isLoadingBlocking: false,
popupOpenId: null,
};

Expand Down
4 changes: 2 additions & 2 deletions src/features/staking/components/delegation-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { StakingContextType, StakingState } from "../context/state";
import { useValidatorLogo } from "../hooks";
import { coinIsPositive } from "../lib/core/coins";
import { menu, pointer } from "../lib/core/icons";
import { cancelUnstake } from "../lib/core/tx";
import { cancelUnbonding } from "../lib/core/tx";
import {
formatCoin,
formatCommission,
Expand Down Expand Up @@ -251,7 +251,7 @@ const UnbondingRow = ({
validator: unbonding.validator,
};

cancelUnstake(addresses, client);
cancelUnbonding(addresses, unbonding, client);
}}
variant="danger"
>
Expand Down
Loading

0 comments on commit c08361c

Please sign in to comment.