Skip to content

Commit

Permalink
Update dependency to @polkadot/api (#4995)
Browse files Browse the repository at this point in the history
* Update dependency to @polkadot/api

- Update delegation list when removed my delegation

* Remove disable status for delegation removing button

* Reduce delegation updation times

* Fix lint errors
  • Loading branch information
wliyongfeng authored Oct 30, 2024
1 parent aa55c58 commit a50faf2
Show file tree
Hide file tree
Showing 6 changed files with 377 additions and 599 deletions.
4 changes: 2 additions & 2 deletions packages/kintsugi-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"dependencies": {
"@interlay/monetary-js": "^0.5.3",
"@next/env": "^13.3.0",
"@osn/icons": "^1.144.0",
"@polkadot/util-crypto": "^13.1.1",
"@osn/icons": "^1.146.0",
"@polkadot/util-crypto": "^13.2.2",
"@svgr/webpack": "^7.0.0",
"bignumber.js": "^9.0.2",
"clsx": "^1.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCallback } from "react";
import SimpleTxPopup from "next-common/components/simpleTxPopup";
import { useContextApi } from "next-common/context/api";

export default function UndelegatePopup({ trackId, onClose }) {
export default function UndelegatePopup({ trackId, onClose, onInBlock }) {
const api = useContextApi();

const getTxFunc = useCallback(async () => {
Expand All @@ -15,6 +15,7 @@ export default function UndelegatePopup({ trackId, onClose }) {
title="Undelegate"
getTxFunc={getTxFunc}
onClose={onClose}
onInBlock={onInBlock}
noSwitchSigner
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import RemoveButton from "next-common/components/removeButton";
import { useState } from "react";
import { useCallback, useState } from "react";
import { useDispatch } from "react-redux";
import { incMyReferendaDelegationsTrigger } from "next-common/store/reducers/myOnChainData/referenda/myReferendaDelegations";
import {
incMyReferendaDelegationsTrigger,
} from "next-common/store/reducers/myOnChainData/referenda/myReferendaDelegations";
import Tooltip from "next-common/components/tooltip";
import dynamicPopup from "next-common/lib/dynamic/popup";
import getChainSettings from "next-common/utils/consts/settings";
import { defaultBlockTime } from "next-common/utils/constants";
import { sleep } from "next-common/utils";

const UndelegatePopup = dynamicPopup(() =>
import("../delegation/undelegatePopup"),
Expand All @@ -12,22 +17,28 @@ const UndelegatePopup = dynamicPopup(() =>
export default function RemoveDelegation({ trackId }) {
const dispatch = useDispatch();
const [showPopup, setShowPopup] = useState(false);
const [isLoading, setIsLoading] = useState(false);

const updateDelegationsFn = useCallback(async () => {
const blockTime =
getChainSettings(process.env.NEXT_PUBLIC_CHAIN).blockTime ||
defaultBlockTime;

for (let i = 0; i < 3; i++) {
dispatch(incMyReferendaDelegationsTrigger());
await sleep(blockTime);
}
}, [dispatch]);

return (
<>
<Tooltip content={"Remove"}>
<RemoveButton disabled={isLoading} onClick={() => setShowPopup(true)} />
<RemoveButton onClick={() => setShowPopup(true)} />
</Tooltip>
{showPopup && (
<UndelegatePopup
trackId={trackId}
onClose={() => setShowPopup(false)}
isLoading={isLoading}
setIsLoading={setIsLoading}
onInBlock={() => {
dispatch(incMyReferendaDelegationsTrigger());
}}
onInBlock={updateDelegationsFn}
/>
)}
</>
Expand Down
8 changes: 4 additions & 4 deletions packages/next-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"@osn/provider-options": "1.1.0",
"@osn/react-cmdk": "^1.2.1",
"@osn/rich-text-editor": "^0.7.2",
"@polkadot/api": "^13.2.1",
"@polkadot/extension-dapp": "^0.52.3",
"@polkadot/util": "^13.1.1",
"@polkadot/util-crypto": "^13.1.1",
"@polkadot/api": "14.2.1",
"@polkadot/extension-dapp": "0.55.1",
"@polkadot/util": "13.2.2",
"@polkadot/util-crypto": "13.2.2",
"@polkagate/extension-dapp": "^0.48.2",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-hover-card": "^1.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@next/env": "^13.3.0",
"@osn/icons": "^1.144.0",
"@osn/icons": "^1.146.0",
"@svgr/webpack": "^7.0.0",
"bignumber.js": "^9.0.2",
"chartjs-plugin-gradient": "^0.6.1",
Expand Down
Loading

0 comments on commit a50faf2

Please sign in to comment.