From 4c10b192612f557128b3eb23af68a24a993f41e7 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Wed, 4 Dec 2024 14:36:17 +0700 Subject: [PATCH] feat(refactor): Remove semi (#2356) --- env.d.ts | 4 +- eslint.config.js | 29 +- package.json | 2 +- packages/app/index.html | 4 +- packages/app/src/App.tsx | 14 +- packages/app/src/Providers.tsx | 86 ++-- packages/app/src/Router.tsx | 90 ++-- packages/app/src/Themes.tsx | 26 +- packages/app/src/api/base.ts | 12 +- .../app/src/api/entries/bondedPoolsEntries.ts | 46 +- .../api/entries/erasStakersPagedEntries.tsx | 8 +- .../app/src/api/entries/validatorsEntries.ts | 8 +- packages/app/src/api/index.ts | 194 ++++---- packages/app/src/api/query/claimedRewards.ts | 20 +- packages/app/src/api/query/era.ts | 20 +- .../app/src/api/query/erasRewardPoints.ts | 16 +- .../app/src/api/query/erasStakersOverview.tsx | 8 +- .../app/src/api/query/erasValidatorReward.ts | 16 +- packages/app/src/api/query/networkMeta.ts | 28 +- .../app/src/api/query/paraSessionAccounts.ts | 16 +- packages/app/src/api/query/proxiesQuery.ts | 16 +- .../app/src/api/query/sessionValidators.ts | 12 +- packages/app/src/api/query/validatorPrefs.ts | 20 +- .../app/src/api/queryMulti/bondedMulti.ts | 16 +- .../api/queryMulti/erasRewardPointsMulti.ts | 16 +- .../queryMulti/erasValidatorRewardMulti.ts | 16 +- .../app/src/api/queryMulti/identityOfMulti.ts | 16 +- .../app/src/api/queryMulti/nominatorsMulti.ts | 22 +- .../src/api/queryMulti/poolMetadataMulti.ts | 16 +- .../app/src/api/queryMulti/superOfMulti.ts | 16 +- .../app/src/api/queryMulti/validatorsMulti.ts | 16 +- .../src/api/runtimeApi/poolPendingRewards.ts | 16 +- .../src/api/runtimeApi/poolPointsToBalance.ts | 20 +- .../api/subscribe/accountBalances/index.ts | 118 ++--- .../src/api/subscribe/accountProxies/index.ts | 38 +- .../src/api/subscribe/accountProxies/types.ts | 16 +- .../app/src/api/subscribe/activeEra/index.ts | 54 +-- .../api/subscribe/activePoolAccount/index.ts | 90 ++-- .../src/api/subscribe/blockNumber/index.ts | 32 +- .../src/api/subscribe/blockNumber/types.ts | 2 +- .../app/src/api/subscribe/bonded/index.tsx | 42 +- .../api/subscribe/fastUnstakeConfig/index.ts | 42 +- .../api/subscribe/fastUnstakeConfig/types.ts | 8 +- .../api/subscribe/fastUnstakeQueue/index.ts | 40 +- .../src/api/subscribe/networkMetrics/index.ts | 38 +- .../src/api/subscribe/poolMembers/index.ts | 52 +-- .../src/api/subscribe/poolMembers/types.ts | 12 +- .../src/api/subscribe/poolsConfig/index.ts | 48 +- .../src/api/subscribe/stakingMetrics/index.ts | 50 +- packages/app/src/api/tx/createPool.ts | 44 +- .../app/src/api/tx/fastUnstakeDeregister.ts | 10 +- .../app/src/api/tx/fastUnstakeRegister.ts | 10 +- packages/app/src/api/tx/joinPool.ts | 32 +- packages/app/src/api/tx/newNominator.ts | 24 +- .../app/src/api/tx/payoutStakersByPage.ts | 22 +- packages/app/src/api/tx/poolBondExtra.ts | 20 +- packages/app/src/api/tx/poolChill.ts | 14 +- .../app/src/api/tx/poolClaimCommission.ts | 14 +- packages/app/src/api/tx/poolClaimPayout.ts | 10 +- packages/app/src/api/tx/poolNominate.ts | 18 +- .../app/src/api/tx/poolSetClaimPermission.ts | 16 +- packages/app/src/api/tx/poolSetCommission.ts | 18 +- .../src/api/tx/poolSetCommissionChangeRate.ts | 22 +- .../app/src/api/tx/poolSetCommissionMax.ts | 18 +- packages/app/src/api/tx/poolSetMetadata.ts | 20 +- packages/app/src/api/tx/poolSetState.ts | 20 +- packages/app/src/api/tx/poolUnbond.ts | 18 +- packages/app/src/api/tx/poolUpdateRoles.ts | 20 +- packages/app/src/api/tx/poolWithdraw.ts | 18 +- packages/app/src/api/tx/proxy.ts | 18 +- packages/app/src/api/tx/stakingBondExtra.ts | 14 +- packages/app/src/api/tx/stakingChill.ts | 10 +- packages/app/src/api/tx/stakingNominate.ts | 14 +- packages/app/src/api/tx/stakingRebond.ts | 14 +- packages/app/src/api/tx/stakingSetPayee.ts | 16 +- packages/app/src/api/tx/stakingUnbond.ts | 14 +- packages/app/src/api/tx/stakingWithdraw.ts | 14 +- packages/app/src/api/tx/transferKeepAlive.ts | 18 +- packages/app/src/api/txSubmission.ts | 34 +- packages/app/src/api/types.ts | 68 +-- .../app/src/canvas/CreatePool/Bond/index.tsx | 64 +-- .../src/canvas/CreatePool/PoolName/Input.tsx | 34 +- .../src/canvas/CreatePool/PoolName/index.tsx | 52 +-- .../src/canvas/CreatePool/PoolRoles/index.tsx | 54 +-- .../src/canvas/CreatePool/Summary/Wrapper.ts | 4 +- .../src/canvas/CreatePool/Summary/index.tsx | 92 ++-- packages/app/src/canvas/CreatePool/index.tsx | 32 +- packages/app/src/canvas/JoinPool/Header.tsx | 36 +- .../src/canvas/JoinPool/Nominations/index.tsx | 26 +- .../JoinPool/Overview/AddressSection.tsx | 20 +- .../canvas/JoinPool/Overview/Addresses.tsx | 16 +- .../src/canvas/JoinPool/Overview/JoinForm.tsx | 114 ++--- .../JoinPool/Overview/PerformanceGraph.tsx | 80 ++-- .../src/canvas/JoinPool/Overview/Roles.tsx | 22 +- .../src/canvas/JoinPool/Overview/Stats.tsx | 66 +-- .../src/canvas/JoinPool/Overview/index.tsx | 30 +- .../app/src/canvas/JoinPool/Preloader.tsx | 52 +-- packages/app/src/canvas/JoinPool/Wrappers.ts | 18 +- packages/app/src/canvas/JoinPool/index.tsx | 74 +-- packages/app/src/canvas/JoinPool/types.ts | 36 +- .../Prompts/FavoritesPrompt.tsx | 65 ++- .../Prompts/RevertPrompt.tsx | 16 +- .../src/canvas/ManageNominations/index.tsx | 126 ++--- .../app/src/canvas/ManageNominations/types.ts | 8 +- .../src/canvas/NominatorSetup/Bond/index.tsx | 64 +-- .../src/canvas/NominatorSetup/Payee/index.tsx | 68 +-- .../canvas/NominatorSetup/Summary/Wrapper.ts | 4 +- .../canvas/NominatorSetup/Summary/index.tsx | 88 ++-- .../app/src/canvas/NominatorSetup/index.tsx | 30 +- .../canvas/PoolMembers/Lists/FetchPage.tsx | 100 ++-- .../src/canvas/PoolMembers/Lists/Member.tsx | 106 ++--- .../app/src/canvas/PoolMembers/Lists/types.ts | 10 +- .../app/src/canvas/PoolMembers/Members.tsx | 36 +- .../PoolMembers/Prompts/UnbondMember.tsx | 104 ++--- .../PoolMembers/Prompts/WithdrawMember.tsx | 102 ++-- packages/app/src/canvas/PoolMembers/index.tsx | 20 +- packages/app/src/canvas/Wrappers.ts | 8 +- packages/app/src/common-types.ts | 194 ++++---- packages/app/src/config/help.ts | 4 +- packages/app/src/config/ledger.ts | 8 +- packages/app/src/config/networks.ts | 26 +- packages/app/src/config/pages.ts | 20 +- packages/app/src/config/plugins.ts | 4 +- packages/app/src/config/proxies.ts | 16 +- packages/app/src/config/tips.ts | 8 +- packages/app/src/config/util.ts | 30 +- packages/app/src/config/validators/Amforc.tsx | 4 +- .../src/config/validators/ApertureMining.tsx | 4 +- .../app/src/config/validators/Blockseeker.tsx | 4 +- .../app/src/config/validators/Blockshard.tsx | 4 +- .../src/config/validators/CoinbaseCloud.tsx | 4 +- .../app/src/config/validators/Crifferent.tsx | 4 +- .../app/src/config/validators/Decentradot.tsx | 4 +- .../app/src/config/validators/Dionysus.tsx | 4 +- .../app/src/config/validators/Dozenodes.tsx | 4 +- .../app/src/config/validators/DragonStake.tsx | 4 +- .../app/src/config/validators/Gatotech.tsx | 4 +- packages/app/src/config/validators/Gdot.tsx | 4 +- .../src/config/validators/GenericChain.tsx | 4 +- packages/app/src/config/validators/GoOpen.tsx | 4 +- .../app/src/config/validators/Helikon.tsx | 4 +- .../app/src/config/validators/Highstake.tsx | 4 +- .../app/src/config/validators/Metaspan.tsx | 4 +- packages/app/src/config/validators/P2POrg.tsx | 4 +- packages/app/src/config/validators/PDP.tsx | 4 +- .../app/src/config/validators/Paranodes.tsx | 4 +- .../src/config/validators/PioneerStake.tsx | 4 +- .../app/src/config/validators/Polkachu.tsx | 4 +- .../src/config/validators/Polkadotters.tsx | 4 +- .../PythagorasCapitalInvestment.tsx | 4 +- .../app/src/config/validators/SekoyaLabs.tsx | 4 +- .../app/src/config/validators/StakeWorld.tsx | 4 +- .../app/src/config/validators/Stakely.tsx | 4 +- .../app/src/config/validators/Stakenode.tsx | 4 +- .../app/src/config/validators/Stakepile.tsx | 4 +- .../app/src/config/validators/Stakeplus.tsx | 4 +- .../app/src/config/validators/StakerSpace.tsx | 4 +- .../app/src/config/validators/Staking4All.tsx | 4 +- .../config/validators/StakingFacilities.tsx | 4 +- .../app/src/config/validators/TurboFlakes.tsx | 4 +- .../src/config/validators/VFValidierung.tsx | 4 +- packages/app/src/config/validators/Wojdot.tsx | 4 +- .../app/src/config/validators/bLdNodes.tsx | 4 +- .../src/contexts/ActiveAccounts/defaults.ts | 4 +- .../app/src/contexts/ActiveAccounts/index.tsx | 52 +-- .../app/src/contexts/ActiveAccounts/types.ts | 22 +- packages/app/src/contexts/Api/defaults.ts | 20 +- packages/app/src/contexts/Api/index.tsx | 332 +++++++------ packages/app/src/contexts/Api/types.ts | 112 ++--- packages/app/src/contexts/Balances/Utils.ts | 16 +- .../app/src/contexts/Balances/defaults.ts | 8 +- packages/app/src/contexts/Balances/index.tsx | 100 ++-- packages/app/src/contexts/Balances/types.ts | 80 ++-- packages/app/src/contexts/Bonded/defaults.ts | 8 +- packages/app/src/contexts/Bonded/index.tsx | 103 ++-- packages/app/src/contexts/Bonded/types.ts | 10 +- .../app/src/contexts/Community/defaults.ts | 4 +- packages/app/src/contexts/Community/index.tsx | 24 +- packages/app/src/contexts/Community/types.ts | 4 +- .../Connect/ExternalAccounts/Utils.ts | 32 +- .../Connect/ExternalAccounts/defaults.ts | 4 +- .../Connect/ExternalAccounts/index.tsx | 64 +-- .../Connect/ExternalAccounts/types.ts | 12 +- .../Connect/ImportedAccounts/defaults.ts | 4 +- .../Connect/ImportedAccounts/index.tsx | 102 ++-- .../Connect/ImportedAccounts/types.ts | 14 +- .../Connect/OtherAccounts/defaults.ts | 4 +- .../contexts/Connect/OtherAccounts/index.tsx | 146 +++--- .../contexts/Connect/OtherAccounts/types.ts | 22 +- packages/app/src/contexts/Connect/Utils.ts | 28 +- .../app/src/contexts/FastUnstake/defaults.ts | 6 +- .../app/src/contexts/FastUnstake/index.tsx | 222 ++++----- .../app/src/contexts/FastUnstake/types.ts | 34 +- packages/app/src/contexts/Filters/defaults.ts | 8 +- packages/app/src/contexts/Filters/index.tsx | 152 +++--- packages/app/src/contexts/Filters/types.ts | 46 +- packages/app/src/contexts/Help/defaults.ts | 4 +- packages/app/src/contexts/Help/index.tsx | 40 +- packages/app/src/contexts/Help/types.ts | 48 +- .../app/src/contexts/LedgerHardware/Utils.tsx | 40 +- .../src/contexts/LedgerHardware/defaults.ts | 6 +- .../app/src/contexts/LedgerHardware/index.tsx | 216 +++++---- .../contexts/LedgerHardware/static/ledger.ts | 80 ++-- .../app/src/contexts/LedgerHardware/types.ts | 84 ++-- packages/app/src/contexts/Menu/defaults.ts | 4 +- packages/app/src/contexts/Menu/index.tsx | 72 +-- packages/app/src/contexts/Menu/types.ts | 30 +- packages/app/src/contexts/Migrate/index.tsx | 56 +-- packages/app/src/contexts/Network/defaults.ts | 8 +- packages/app/src/contexts/Network/index.tsx | 58 ++- packages/app/src/contexts/Network/types.ts | 12 +- packages/app/src/contexts/Payouts/Utils.ts | 42 +- packages/app/src/contexts/Payouts/defaults.ts | 6 +- packages/app/src/contexts/Payouts/index.tsx | 268 +++++------ packages/app/src/contexts/Payouts/types.ts | 22 +- packages/app/src/contexts/Plugins/Utils.ts | 8 +- packages/app/src/contexts/Plugins/defaults.ts | 4 +- packages/app/src/contexts/Plugins/index.tsx | 66 +-- packages/app/src/contexts/Plugins/types.ts | 8 +- .../src/contexts/Pools/ActivePool/defaults.ts | 10 +- .../src/contexts/Pools/ActivePool/index.tsx | 148 +++--- .../src/contexts/Pools/ActivePool/types.ts | 24 +- .../contexts/Pools/BondedPools/defaults.ts | 4 +- .../src/contexts/Pools/BondedPools/index.tsx | 260 +++++------ .../src/contexts/Pools/BondedPools/types.ts | 40 +- .../contexts/Pools/FavoritePools/defaults.ts | 8 +- .../contexts/Pools/FavoritePools/index.tsx | 48 +- .../src/contexts/Pools/FavoritePools/types.ts | 6 +- .../src/contexts/Pools/JoinPools/defaults.ts | 6 +- .../src/contexts/Pools/JoinPools/index.tsx | 66 +-- .../app/src/contexts/Pools/JoinPools/types.ts | 6 +- .../contexts/Pools/PoolMembers/defaults.ts | 4 +- .../src/contexts/Pools/PoolMembers/index.tsx | 146 +++--- .../src/contexts/Pools/PoolMembers/types.ts | 20 +- .../Pools/PoolPerformance/defaults.ts | 10 +- .../contexts/Pools/PoolPerformance/index.tsx | 144 +++--- .../contexts/Pools/PoolPerformance/types.ts | 16 +- packages/app/src/contexts/Pools/types.ts | 22 +- packages/app/src/contexts/Pools/util.ts | 20 +- packages/app/src/contexts/Prompt/defaults.tsx | 4 +- packages/app/src/contexts/Prompt/index.tsx | 44 +- packages/app/src/contexts/Prompt/types.ts | 34 +- packages/app/src/contexts/Proxies/defaults.ts | 4 +- packages/app/src/contexts/Proxies/index.tsx | 196 ++++---- packages/app/src/contexts/Proxies/types.ts | 52 +-- packages/app/src/contexts/Setup/defaults.ts | 8 +- packages/app/src/contexts/Setup/index.tsx | 182 ++++---- packages/app/src/contexts/Setup/types.ts | 62 +-- packages/app/src/contexts/Staking/Utils.ts | 36 +- packages/app/src/contexts/Staking/defaults.ts | 8 +- packages/app/src/contexts/Staking/index.tsx | 202 ++++---- packages/app/src/contexts/Staking/types.ts | 72 +-- packages/app/src/contexts/Themes/defaults.ts | 4 +- packages/app/src/contexts/Themes/index.tsx | 50 +- packages/app/src/contexts/Themes/types.ts | 6 +- packages/app/src/contexts/Tooltip/defaults.ts | 4 +- packages/app/src/contexts/Tooltip/index.tsx | 58 +-- packages/app/src/contexts/Tooltip/types.ts | 18 +- .../app/src/contexts/TransferOptions/Utils.ts | 30 +- .../src/contexts/TransferOptions/defaults.ts | 8 +- .../src/contexts/TransferOptions/index.tsx | 103 ++-- .../app/src/contexts/TransferOptions/types.ts | 46 +- packages/app/src/contexts/TxMeta/defaults.ts | 4 +- packages/app/src/contexts/TxMeta/index.tsx | 36 +- packages/app/src/contexts/TxMeta/types.ts | 8 +- packages/app/src/contexts/UI/defaults.ts | 4 +- packages/app/src/contexts/UI/index.tsx | 70 +-- packages/app/src/contexts/UI/types.ts | 18 +- .../Validators/FavoriteValidators/defaults.ts | 8 +- .../Validators/FavoriteValidators/index.tsx | 71 ++- packages/app/src/contexts/Validators/Utils.ts | 92 ++-- .../Validators/ValidatorEntries/defaults.ts | 12 +- .../Validators/ValidatorEntries/index.tsx | 440 +++++++++--------- packages/app/src/contexts/Validators/types.ts | 96 ++-- .../src/contexts/WalletConnect/defaults.ts | 4 +- .../app/src/contexts/WalletConnect/index.tsx | 218 ++++----- .../app/src/contexts/WalletConnect/types.ts | 24 +- .../src/controllers/ActivePools/defaults.ts | 2 +- .../app/src/controllers/ActivePools/index.ts | 88 ++-- packages/app/src/controllers/Apis/index.tsx | 49 +- .../app/src/controllers/Balances/defaults.ts | 16 +- .../app/src/controllers/Balances/index.ts | 58 +-- .../app/src/controllers/Identities/index.ts | 45 +- .../src/controllers/Notifications/index.ts | 20 +- .../src/controllers/Notifications/types.ts | 22 +- .../src/controllers/OnlineStatus/index.tsx | 10 +- .../app/src/controllers/OnlineStatus/types.ts | 2 +- .../app/src/controllers/PolkaWatch/index.ts | 10 +- packages/app/src/controllers/Subscan/index.ts | 172 ++++--- packages/app/src/controllers/Subscan/types.ts | 102 ++-- .../src/controllers/Subscriptions/index.ts | 20 +- .../src/controllers/Subscriptions/types.ts | 30 +- .../app/src/controllers/Syncs/defaults.ts | 4 +- packages/app/src/controllers/Syncs/index.ts | 34 +- packages/app/src/controllers/Syncs/types.ts | 12 +- packages/app/src/controllers/utils.ts | 2 +- .../app/src/hooks/useActiveBalances/index.tsx | 128 ++--- .../app/src/hooks/useActivePools/index.tsx | 68 +-- .../app/src/hooks/useActivePools/types.ts | 10 +- .../hooks/useAverageRewardRate/defaults.ts | 6 +- .../src/hooks/useAverageRewardRate/index.tsx | 56 +-- .../src/hooks/useAverageRewardRate/types.ts | 10 +- packages/app/src/hooks/useBatchCall/index.tsx | 38 +- .../src/hooks/useBondGreatestFee/index.tsx | 58 +-- .../useControllerSignerAvailable/index.tsx | 34 +- .../src/hooks/useCreatePoolAccounts/index.tsx | 32 +- .../src/hooks/useDotLottieButton/index.tsx | 58 +-- .../app/src/hooks/useEraTimeLeft/index.tsx | 34 +- .../app/src/hooks/useErasPerDay/index.tsx | 24 +- .../app/src/hooks/useErasToTimeLeft/index.tsx | 22 +- .../app/src/hooks/useFillVariables/index.tsx | 40 +- .../app/src/hooks/useFillVariables/types.ts | 4 +- .../src/hooks/useNominationStatus/index.tsx | 76 +-- .../app/src/hooks/usePayeeConfig/index.tsx | 32 +- .../app/src/hooks/usePoolCommission/index.tsx | 14 +- .../app/src/hooks/usePoolFilters/index.tsx | 92 ++-- .../app/src/hooks/useProxySupported/index.tsx | 46 +- .../app/src/hooks/useSignerWarnings/index.tsx | 40 +- .../src/hooks/useSubmitExtrinsic/index.tsx | 198 ++++---- .../app/src/hooks/useSubmitExtrinsic/types.ts | 26 +- .../app/src/hooks/useSubscanData/index.tsx | 84 ++-- packages/app/src/hooks/useSyncing/index.tsx | 46 +- packages/app/src/hooks/useUnstaking/index.tsx | 62 +-- .../src/hooks/useValidatorFilters/index.tsx | 136 +++--- packages/app/src/kits/Overlay/Background.tsx | 34 +- packages/app/src/kits/Overlay/Canvas.tsx | 58 +-- packages/app/src/kits/Overlay/Modal.tsx | 94 ++-- .../app/src/kits/Overlay/Provider/defaults.ts | 10 +- .../app/src/kits/Overlay/Provider/index.tsx | 132 +++--- .../app/src/kits/Overlay/Provider/types.ts | 96 ++-- packages/app/src/kits/Overlay/index.tsx | 10 +- .../src/kits/Overlay/structure/CanvasCard.tsx | 4 +- .../Overlay/structure/CanvasContainer.tsx | 6 +- .../kits/Overlay/structure/CanvasContent.tsx | 4 +- .../kits/Overlay/structure/CanvasScroll.tsx | 8 +- .../src/kits/Overlay/structure/ModalCard.tsx | 10 +- .../Overlay/structure/ModalConnectItem.tsx | 6 +- .../kits/Overlay/structure/ModalContainer.tsx | 6 +- .../kits/Overlay/structure/ModalContent.tsx | 8 +- .../Overlay/structure/ModalCustomHeader.tsx | 4 +- .../Overlay/structure/ModalFixedTitle.tsx | 12 +- .../kits/Overlay/structure/ModalFooter.tsx | 4 +- .../Overlay/structure/ModalHardwareItem.tsx | 4 +- .../structure/ModalMotionThreeSection.tsx | 6 +- .../structure/ModalMotionTwoSection.tsx | 6 +- .../src/kits/Overlay/structure/ModalNotes.tsx | 6 +- .../kits/Overlay/structure/ModalOverlay.tsx | 6 +- .../kits/Overlay/structure/ModalPadding.tsx | 12 +- .../kits/Overlay/structure/ModalScroll.tsx | 12 +- .../kits/Overlay/structure/ModalSection.tsx | 6 +- .../kits/Overlay/structure/ModalSeparator.tsx | 2 +- .../kits/Overlay/structure/ModalWarnings.tsx | 6 +- packages/app/src/kits/Overlay/types.ts | 50 +- .../src/library/Account/DefaultAccount.tsx | 30 +- .../app/src/library/Account/PoolAccount.tsx | 38 +- packages/app/src/library/Account/Wrapper.ts | 4 +- packages/app/src/library/Account/types.ts | 14 +- .../app/src/library/AccountInput/Wrapper.ts | 4 +- .../app/src/library/AccountInput/index.tsx | 160 +++---- .../app/src/library/AccountInput/types.ts | 24 +- .../app/src/library/ActionItem/Wrapper.ts | 4 +- packages/app/src/library/ActionItem/index.tsx | 22 +- packages/app/src/library/ActionItem/types.ts | 18 +- .../app/src/library/Announcements/Header.tsx | 14 +- .../app/src/library/Announcements/Wrappers.ts | 12 +- .../app/src/library/Announcements/types.ts | 16 +- .../app/src/library/BarChart/BarSegment.tsx | 6 +- .../app/src/library/BarChart/BondedChart.tsx | 40 +- .../app/src/library/BarChart/LegendItem.tsx | 12 +- packages/app/src/library/BarChart/Wrappers.ts | 8 +- packages/app/src/library/BarChart/defaults.ts | 2 +- packages/app/src/library/BarChart/types.ts | 22 +- .../app/src/library/CallToAction/index.tsx | 4 +- packages/app/src/library/Card/Wrappers.ts | 10 +- packages/app/src/library/Countdown/index.tsx | 18 +- packages/app/src/library/Countdown/types.ts | 6 +- .../app/src/library/ErrorBoundary/Wrapper.ts | 4 +- .../app/src/library/ErrorBoundary/index.tsx | 36 +- .../app/src/library/EstimatedTxFee/Wrapper.ts | 4 +- .../app/src/library/EstimatedTxFee/index.tsx | 30 +- .../app/src/library/EstimatedTxFee/types.ts | 4 +- packages/app/src/library/Filter/Container.tsx | 6 +- packages/app/src/library/Filter/Item.tsx | 12 +- packages/app/src/library/Filter/LargeItem.tsx | 10 +- packages/app/src/library/Filter/Tabs.tsx | 32 +- packages/app/src/library/Filter/Wrappers.ts | 12 +- packages/app/src/library/Filter/defaults.ts | 4 +- packages/app/src/library/Filter/types.ts | 64 +-- .../src/library/Form/Bond/BondFeedback.tsx | 122 ++--- .../app/src/library/Form/Bond/BondInput.tsx | 62 +-- .../Form/ClaimPermissionInput/index.tsx | 32 +- .../Form/ClaimPermissionInput/types.ts | 8 +- .../Form/CreatePoolStatusBar/Wrapper.ts | 4 +- .../Form/CreatePoolStatusBar/index.tsx | 34 +- .../src/library/Form/MinDelayInput/Wrapper.ts | 4 +- .../src/library/Form/MinDelayInput/index.tsx | 42 +- .../src/library/Form/MinDelayInput/types.ts | 8 +- .../library/Form/NominateStatusBar/Wrapper.ts | 4 +- .../library/Form/NominateStatusBar/index.tsx | 44 +- .../library/Form/Unbond/UnbondFeedback.tsx | 116 ++--- .../src/library/Form/Unbond/UnbondInput.tsx | 64 +-- .../app/src/library/Form/Warning/Wrapper.ts | 4 +- .../app/src/library/Form/Warning/index.tsx | 6 +- packages/app/src/library/Form/Wrappers.ts | 10 +- packages/app/src/library/Form/types.ts | 116 ++--- .../library/GenerateNominations/Wrapper.ts | 4 +- .../src/library/GenerateNominations/index.tsx | 210 ++++----- .../src/library/GenerateNominations/types.ts | 18 +- .../GenerateNominations/useFetchMethods.tsx | 160 +++---- packages/app/src/library/Graphs/EraPoints.tsx | 32 +- packages/app/src/library/Graphs/GeoDonut.tsx | 52 +-- packages/app/src/library/Graphs/PayoutBar.tsx | 84 ++-- .../app/src/library/Graphs/PayoutLine.tsx | 78 ++-- packages/app/src/library/Graphs/Utils.ts | 234 +++++----- packages/app/src/library/Graphs/Wrapper.ts | 4 +- packages/app/src/library/Graphs/types.ts | 58 +-- .../Hardware/HardwareAddress/Wrapper.ts | 4 +- .../Hardware/HardwareAddress/index.tsx | 60 +-- .../library/Hardware/HardwareAddress/types.ts | 34 +- .../Hardware/HardwareStatusBar/Wrapper.ts | 6 +- .../Hardware/HardwareStatusBar/index.tsx | 16 +- .../Hardware/HardwareStatusBar/types.ts | 30 +- packages/app/src/library/Headers/Connect.tsx | 28 +- .../app/src/library/Headers/Connected.tsx | 38 +- .../src/library/Headers/SideMenuToggle.tsx | 16 +- packages/app/src/library/Headers/Spinner.tsx | 6 +- packages/app/src/library/Headers/Sync.tsx | 52 +-- packages/app/src/library/Headers/Wrappers.ts | 18 +- packages/app/src/library/Headers/index.tsx | 12 +- .../library/Help/Items/ActiveDefinition.tsx | 6 +- .../app/src/library/Help/Items/Definition.tsx | 24 +- .../app/src/library/Help/Items/External.tsx | 20 +- packages/app/src/library/Help/Items/types.ts | 12 +- packages/app/src/library/Help/Wrappers.ts | 12 +- packages/app/src/library/Help/index.tsx | 114 ++--- packages/app/src/library/Import/Confirm.tsx | 42 +- packages/app/src/library/Import/Heading.tsx | 20 +- .../app/src/library/Import/NoAccounts.tsx | 26 +- packages/app/src/library/Import/Remove.tsx | 44 +- packages/app/src/library/Import/Wrappers.ts | 12 +- packages/app/src/library/Import/types.ts | 50 +- .../app/src/library/List/MotionContainer.tsx | 10 +- packages/app/src/library/List/Pagination.tsx | 32 +- packages/app/src/library/List/SearchInput.tsx | 8 +- packages/app/src/library/List/Selectable.tsx | 29 +- packages/app/src/library/List/context.tsx | 46 +- packages/app/src/library/List/defaults.ts | 12 +- packages/app/src/library/List/index.ts | 22 +- packages/app/src/library/List/types.ts | 58 +-- .../src/library/ListItem/Labels/Blocked.tsx | 24 +- .../library/ListItem/Labels/Commission.tsx | 16 +- .../library/ListItem/Labels/CopyAddress.tsx | 24 +- .../src/library/ListItem/Labels/EraStatus.tsx | 26 +- .../library/ListItem/Labels/FavoritePool.tsx | 40 +- .../ListItem/Labels/FavoriteValidator.tsx | 40 +- .../src/library/ListItem/Labels/Identity.tsx | 28 +- .../src/library/ListItem/Labels/Members.tsx | 20 +- .../src/library/ListItem/Labels/Metrics.tsx | 14 +- .../app/src/library/ListItem/Labels/More.tsx | 36 +- .../ListItem/Labels/NominationStatus.tsx | 38 +- .../library/ListItem/Labels/ParaValidator.tsx | 28 +- .../library/ListItem/Labels/PoolBonded.tsx | 34 +- .../ListItem/Labels/PoolCommission.tsx | 18 +- .../src/library/ListItem/Labels/PoolId.tsx | 20 +- .../library/ListItem/Labels/PoolIdentity.tsx | 22 +- .../ListItem/Labels/PoolMemberBonded.tsx | 54 +-- .../ListItem/Labels/PoolNominateStatus.tsx | 46 +- .../src/library/ListItem/Labels/Quartile.tsx | 25 +- .../library/ListItem/Labels/RewardShare.tsx | 20 +- .../src/library/ListItem/Labels/Select.tsx | 22 +- packages/app/src/library/ListItem/Wrappers.ts | 30 +- packages/app/src/library/ListItem/types.ts | 51 +- .../app/src/library/Loader/Announcement.tsx | 4 +- .../app/src/library/Loader/CallToAction.tsx | 4 +- packages/app/src/library/Loader/Wrappers.ts | 4 +- packages/app/src/library/Menu/List.tsx | 20 +- packages/app/src/library/Menu/Wrappers.ts | 6 +- packages/app/src/library/Menu/index.tsx | 36 +- packages/app/src/library/Modal/Close.tsx | 12 +- packages/app/src/library/Modal/Title.tsx | 42 +- packages/app/src/library/Modal/Wrappers.ts | 10 +- .../app/src/library/NetworkBar/Status.tsx | 14 +- .../app/src/library/NetworkBar/TokenPrice.tsx | 38 +- .../app/src/library/NetworkBar/Wrappers.ts | 10 +- packages/app/src/library/NetworkBar/index.tsx | 62 +-- .../app/src/library/Nominations/Wrapper.ts | 4 +- .../app/src/library/Nominations/index.tsx | 78 ++-- packages/app/src/library/Nominations/types.ts | 24 +- .../library/NotificationPrompts/Wrapper.ts | 4 +- .../src/library/NotificationPrompts/index.tsx | 58 +-- packages/app/src/library/Offline/Wrapper.ts | 4 +- packages/app/src/library/Offline/index.tsx | 34 +- .../app/src/library/PageWithTitle/index.tsx | 20 +- .../app/src/library/PayeeInput/Wrapper.ts | 4 +- packages/app/src/library/PayeeInput/index.tsx | 92 ++-- packages/app/src/library/PayeeInput/types.ts | 14 +- .../app/src/library/PluginLabel/Wrapper.ts | 4 +- .../app/src/library/PluginLabel/index.tsx | 18 +- packages/app/src/library/PluginLabel/types.ts | 4 +- packages/app/src/library/Pool/Rewards.tsx | 94 ++-- packages/app/src/library/Pool/index.tsx | 40 +- packages/app/src/library/Pool/types.ts | 32 +- packages/app/src/library/PoolList/context.tsx | 20 +- packages/app/src/library/PoolList/defaults.ts | 6 +- packages/app/src/library/PoolList/index.tsx | 154 +++--- packages/app/src/library/PoolList/types.ts | 20 +- packages/app/src/library/PoolSync/Bar.tsx | 24 +- packages/app/src/library/PoolSync/Loader.ts | 4 +- packages/app/src/library/PoolSync/index.tsx | 28 +- packages/app/src/library/Prompt/Title.tsx | 40 +- packages/app/src/library/Prompt/Wrappers.ts | 20 +- packages/app/src/library/Prompt/index.tsx | 14 +- packages/app/src/library/QRCode/Display.tsx | 80 ++-- .../app/src/library/QRCode/DisplayPayload.tsx | 24 +- packages/app/src/library/QRCode/Scan.tsx | 76 +-- .../app/src/library/QRCode/ScanSignature.tsx | 16 +- packages/app/src/library/QRCode/Wrappers.ts | 6 +- packages/app/src/library/QRCode/qrcode.ts | 10 +- packages/app/src/library/QRCode/types.ts | 66 +-- packages/app/src/library/QRCode/util.ts | 32 +- packages/app/src/library/SelectItems/Item.tsx | 12 +- .../app/src/library/SelectItems/Wrapper.ts | 20 +- .../app/src/library/SelectItems/index.tsx | 70 +-- packages/app/src/library/SelectItems/types.ts | 38 +- .../src/library/SetupSteps/Footer/Wrapper.ts | 4 +- .../src/library/SetupSteps/Footer/index.tsx | 24 +- .../src/library/SetupSteps/Header/Wrapper.ts | 4 +- .../src/library/SetupSteps/Header/index.tsx | 30 +- .../library/SetupSteps/MotionContainer.tsx | 12 +- .../app/src/library/SetupSteps/Nominate.tsx | 44 +- packages/app/src/library/SetupSteps/types.ts | 30 +- .../src/library/SideMenu/Heading/Heading.tsx | 6 +- .../src/library/SideMenu/Heading/Wrapper.ts | 4 +- packages/app/src/library/SideMenu/Main.tsx | 104 ++--- .../src/library/SideMenu/Primary/Wrappers.ts | 6 +- .../src/library/SideMenu/Primary/index.tsx | 40 +- .../library/SideMenu/Secondary/Wrappers.ts | 12 +- .../src/library/SideMenu/Secondary/index.tsx | 14 +- packages/app/src/library/SideMenu/Wrapper.ts | 14 +- packages/app/src/library/SideMenu/index.tsx | 88 ++-- packages/app/src/library/SideMenu/types.ts | 42 +- .../app/src/library/Signers/LedgerSigner.ts | 48 +- .../src/library/Signers/VaultSigner/index.ts | 77 ++- .../src/library/Signers/VaultSigner/types.ts | 10 +- packages/app/src/library/Signers/util.ts | 38 +- packages/app/src/library/SimplePie/index.tsx | 78 ++-- packages/app/src/library/Stat/Wrapper.ts | 4 +- packages/app/src/library/Stat/index.tsx | 72 +-- packages/app/src/library/Stat/types.ts | 36 +- packages/app/src/library/StatBoxList/Item.tsx | 28 +- .../app/src/library/StatBoxList/Number.tsx | 20 +- packages/app/src/library/StatBoxList/Pie.tsx | 34 +- packages/app/src/library/StatBoxList/Text.tsx | 18 +- .../app/src/library/StatBoxList/Timeleft.tsx | 22 +- .../app/src/library/StatBoxList/Wrapper.ts | 12 +- .../app/src/library/StatBoxList/index.tsx | 8 +- packages/app/src/library/StatBoxList/types.ts | 60 +-- .../app/src/library/StatusButton/Wrapper.ts | 4 +- .../app/src/library/StatusButton/index.tsx | 14 +- .../app/src/library/StatusButton/types.ts | 6 +- .../app/src/library/StatusLabel/Wrapper.ts | 6 +- .../app/src/library/StatusLabel/index.tsx | 44 +- packages/app/src/library/StatusLabel/types.ts | 16 +- .../app/src/library/StyledSlider/Wrapper.ts | 4 +- .../app/src/library/StyledSlider/index.tsx | 8 +- .../app/src/library/StyledSlider/types.ts | 12 +- .../library/SubmitTx/ButtonSubmitLarge.tsx | 10 +- packages/app/src/library/SubmitTx/Default.tsx | 30 +- .../SubmitTx/ManualSign/Ledger/Submit.tsx | 44 +- .../SubmitTx/ManualSign/Ledger/index.tsx | 84 ++-- .../SubmitTx/ManualSign/Vault/SignPrompt.tsx | 38 +- .../SubmitTx/ManualSign/Vault/index.tsx | 56 +-- .../ManualSign/WalletConnect/index.tsx | 78 ++-- .../src/library/SubmitTx/ManualSign/index.tsx | 38 +- packages/app/src/library/SubmitTx/index.tsx | 82 ++-- packages/app/src/library/SubmitTx/types.ts | 64 +-- packages/app/src/library/Tips/Tip.tsx | 46 +- packages/app/src/library/Tips/Wrappers.ts | 6 +- packages/app/src/library/Tips/types.ts | 6 +- packages/app/src/library/Tooltip/Wrapper.ts | 4 +- packages/app/src/library/Tooltip/index.tsx | 42 +- packages/app/src/library/Tx/Signer.tsx | 10 +- packages/app/src/library/Tx/Wrapper.ts | 6 +- packages/app/src/library/Tx/index.tsx | 10 +- packages/app/src/library/Tx/types.ts | 18 +- .../app/src/library/UpdateHeader/Wrapper.ts | 4 +- .../app/src/library/UpdateHeader/index.tsx | 22 +- .../ValidatorList/FilterValidators.tsx | 32 +- .../ValidatorList/Filters/FilterBadges.tsx | 40 +- .../ValidatorList/Filters/FilterHeaders.tsx | 38 +- .../library/ValidatorList/OrderValidators.tsx | 26 +- .../ValidatorList/ValidatorItem/Default.tsx | 86 ++-- .../ValidatorItem/Nomination.tsx | 44 +- .../ValidatorList/ValidatorItem/Pulse.tsx | 102 ++-- .../ValidatorList/ValidatorItem/Utils.tsx | 58 +-- .../ValidatorList/ValidatorItem/index.tsx | 12 +- .../ValidatorList/ValidatorItem/types.ts | 36 +- .../app/src/library/ValidatorList/index.tsx | 242 +++++----- .../app/src/library/ValidatorList/types.ts | 52 +-- .../app/src/library/WithdrawPrompt/index.tsx | 70 +-- packages/app/src/main.tsx | 30 +- packages/app/src/modals/Accounts/Account.tsx | 70 +-- .../src/modals/Accounts/Delegates/Wrapper.ts | 4 +- .../src/modals/Accounts/Delegates/index.tsx | 22 +- packages/app/src/modals/Accounts/Wrappers.ts | 6 +- packages/app/src/modals/Accounts/index.tsx | 122 ++--- packages/app/src/modals/Accounts/types.ts | 40 +- packages/app/src/modals/BalanceTest/index.tsx | 48 +- packages/app/src/modals/Bio/Wrapper.ts | 4 +- packages/app/src/modals/Bio/index.tsx | 14 +- packages/app/src/modals/Bond/index.tsx | 128 ++--- .../src/modals/ChangePoolRoles/RoleChange.tsx | 14 +- .../app/src/modals/ChangePoolRoles/Wrapper.ts | 6 +- .../app/src/modals/ChangePoolRoles/index.tsx | 48 +- .../app/src/modals/ChangePoolRoles/types.ts | 6 +- .../app/src/modals/ChooseLanguage/Wrapper.ts | 6 +- .../app/src/modals/ChooseLanguage/index.tsx | 26 +- .../app/src/modals/ClaimPayouts/Forms.tsx | 125 +++-- packages/app/src/modals/ClaimPayouts/Item.tsx | 30 +- .../app/src/modals/ClaimPayouts/Overview.tsx | 30 +- packages/app/src/modals/ClaimPayouts/Utils.ts | 6 +- .../app/src/modals/ClaimPayouts/Wrappers.ts | 6 +- .../app/src/modals/ClaimPayouts/index.tsx | 80 ++-- packages/app/src/modals/ClaimPayouts/types.ts | 28 +- packages/app/src/modals/ClaimReward/index.tsx | 82 ++-- packages/app/src/modals/Connect/Extension.tsx | 78 ++-- packages/app/src/modals/Connect/Ledger.tsx | 36 +- packages/app/src/modals/Connect/Proxies.tsx | 46 +- packages/app/src/modals/Connect/ReadOnly.tsx | 64 +-- packages/app/src/modals/Connect/Utils.ts | 12 +- packages/app/src/modals/Connect/Vault.tsx | 34 +- .../app/src/modals/Connect/WalletConnect.tsx | 30 +- packages/app/src/modals/Connect/Wrappers.ts | 16 +- packages/app/src/modals/Connect/index.tsx | 118 ++--- packages/app/src/modals/Connect/types.ts | 34 +- .../app/src/modals/DiscordSupport/Wrapper.ts | 4 +- .../app/src/modals/DiscordSupport/index.tsx | 22 +- packages/app/src/modals/DismissTips/index.tsx | 26 +- .../app/src/modals/ImportLedger/Addresses.tsx | 74 +-- .../app/src/modals/ImportLedger/Manage.tsx | 56 +-- .../app/src/modals/ImportLedger/Reset.tsx | 58 +-- .../app/src/modals/ImportLedger/Splash.tsx | 54 +-- .../app/src/modals/ImportLedger/Wrappers.ts | 6 +- .../app/src/modals/ImportLedger/index.tsx | 116 ++--- .../app/src/modals/ImportVault/Reader.tsx | 64 +-- packages/app/src/modals/ImportVault/index.tsx | 82 ++-- .../src/modals/ImportWalletConnect/index.tsx | 82 ++-- .../app/src/modals/MailSupport/Wrapper.ts | 4 +- packages/app/src/modals/MailSupport/index.tsx | 18 +- .../src/modals/ManageFastUnstake/index.tsx | 124 ++--- .../Forms/ClaimCommission/index.tsx | 84 ++-- .../ManagePool/Forms/LeavePool/index.tsx | 120 ++--- .../Forms/ManageCommission/ChangeRate.tsx | 96 ++-- .../ManageCommission/CommissionCurrent.tsx | 50 +- .../Forms/ManageCommission/MaxCommission.tsx | 40 +- .../Forms/ManageCommission/index.tsx | 176 +++---- .../ManageCommission/provider/defaults.ts | 4 +- .../Forms/ManageCommission/provider/index.tsx | 126 ++--- .../Forms/ManageCommission/provider/types.ts | 40 +- .../ManagePool/Forms/RenamePool/index.tsx | 96 ++-- .../Forms/SetClaimPermission/index.tsx | 94 ++-- .../ManagePool/Forms/SetPoolState/index.tsx | 134 +++--- .../app/src/modals/ManagePool/Forms/index.tsx | 30 +- .../app/src/modals/ManagePool/Forms/types.ts | 22 +- packages/app/src/modals/ManagePool/Tasks.tsx | 86 ++-- .../app/src/modals/ManagePool/Wrappers.ts | 10 +- packages/app/src/modals/ManagePool/index.tsx | 73 ++- packages/app/src/modals/ManagePool/types.ts | 6 +- .../src/modals/Networks/ProvidersPrompt.tsx | 38 +- packages/app/src/modals/Networks/Wrapper.ts | 16 +- packages/app/src/modals/Networks/index.tsx | 80 ++-- packages/app/src/modals/Networks/types.ts | 2 +- packages/app/src/modals/Settings/index.tsx | 20 +- .../app/src/modals/StopNominations/index.tsx | 100 ++-- packages/app/src/modals/Unbond/index.tsx | 174 +++---- .../app/src/modals/UnlockChunks/Chunk.tsx | 68 +-- .../app/src/modals/UnlockChunks/Forms.tsx | 142 +++--- .../app/src/modals/UnlockChunks/Overview.tsx | 100 ++-- .../app/src/modals/UnlockChunks/Wrappers.ts | 6 +- .../app/src/modals/UnlockChunks/index.tsx | 115 +++-- packages/app/src/modals/UnlockChunks/types.ts | 20 +- packages/app/src/modals/Unstake/index.tsx | 127 +++-- packages/app/src/modals/UpdatePayee/index.tsx | 108 ++--- .../app/src/modals/UpdateReserve/index.tsx | 82 ++-- packages/app/src/modals/Utils/StaticNote.tsx | 26 +- .../app/src/modals/ValidatorGeo/index.tsx | 88 ++-- .../app/src/modals/ValidatorMetrics/index.tsx | 108 ++--- packages/app/src/overlay/index.tsx | 72 +-- packages/app/src/pages/Community/Entity.tsx | 60 +-- packages/app/src/pages/Community/Item.tsx | 52 +-- packages/app/src/pages/Community/List.tsx | 38 +- packages/app/src/pages/Community/Wrappers.ts | 12 +- packages/app/src/pages/Community/context.tsx | 38 +- packages/app/src/pages/Community/defaults.ts | 6 +- packages/app/src/pages/Community/index.tsx | 26 +- packages/app/src/pages/Community/types.ts | 36 +- .../src/pages/Nominate/Active/ManageBond.tsx | 76 +-- .../Active/Stats/ActiveNominators.tsx | 26 +- .../Active/Stats/MinimumActiveStake.tsx | 22 +- .../Active/Stats/MinimumNominatorBond.tsx | 22 +- .../Nominate/Active/Status/NewNominator.tsx | 40 +- .../Active/Status/NominationStatus.tsx | 66 +-- .../Active/Status/PayoutDestinationStatus.tsx | 58 +-- .../Active/Status/UnclaimedPayoutsStatus.tsx | 44 +- .../pages/Nominate/Active/Status/index.tsx | 32 +- .../pages/Nominate/Active/UnstakePrompts.tsx | 50 +- .../app/src/pages/Nominate/Active/index.tsx | 72 +-- .../app/src/pages/Nominate/Active/types.ts | 14 +- .../NominationGeo/NominationGeoList/Node.tsx | 20 +- .../NominationGeo/NominationGeoList/index.tsx | 40 +- .../NominationGeo/Stats/AnalyzedDays.tsx | 12 +- .../NominationGeo/Stats/AnalyzedEras.tsx | 14 +- .../NominationGeo/Stats/AnalyzedPayouts.tsx | 18 +- .../pages/Nominate/NominationGeo/Wrappers.ts | 4 +- .../pages/Nominate/NominationGeo/index.tsx | 133 +++--- .../src/pages/Nominate/NominationGeo/types.ts | 20 +- packages/app/src/pages/Nominate/Wrappers.ts | 8 +- packages/app/src/pages/Nominate/index.tsx | 28 +- .../Overview/AccountBalance/BalanceChart.tsx | 116 ++--- .../Overview/AccountBalance/BalanceLinks.tsx | 28 +- .../Overview/AccountBalance/FiatValue.tsx | 34 +- .../pages/Overview/AccountControls/Item.tsx | 50 +- .../Overview/AccountControls/Wrappers.ts | 6 +- .../pages/Overview/AccountControls/index.tsx | 12 +- .../pages/Overview/AccountControls/types.ts | 6 +- .../Overview/NetworkSats/Announcements.tsx | 68 +-- .../src/pages/Overview/NetworkSats/index.tsx | 34 +- packages/app/src/pages/Overview/Payouts.tsx | 86 ++-- .../pages/Overview/StakeStatus/Tips/Items.tsx | 54 +-- .../Overview/StakeStatus/Tips/PageToggle.tsx | 28 +- .../Overview/StakeStatus/Tips/Syncing.tsx | 14 +- .../Overview/StakeStatus/Tips/Wrappers.ts | 16 +- .../pages/Overview/StakeStatus/Tips/index.tsx | 156 +++---- .../pages/Overview/StakeStatus/Tips/types.ts | 40 +- .../pages/Overview/StakeStatus/Wrappers.ts | 6 +- .../src/pages/Overview/StakeStatus/index.tsx | 22 +- .../Overview/Stats/ActiveEraTimeLeft.tsx | 54 +-- .../Overview/Stats/AveragelRewardRate.tsx | 18 +- .../src/pages/Overview/Stats/SupplyStaked.tsx | 32 +- packages/app/src/pages/Overview/Wrappers.ts | 10 +- packages/app/src/pages/Overview/index.tsx | 36 +- .../src/pages/Payouts/PayoutList/context.tsx | 22 +- .../src/pages/Payouts/PayoutList/index.tsx | 116 ++--- .../src/pages/Payouts/Stats/LastEraPayout.tsx | 24 +- packages/app/src/pages/Payouts/Wrappers.ts | 6 +- packages/app/src/pages/Payouts/index.tsx | 90 ++-- packages/app/src/pages/Payouts/types.ts | 12 +- .../src/pages/Pools/Home/ClosurePrompts.tsx | 61 ++- .../src/pages/Pools/Home/Favorites/index.tsx | 52 +-- .../app/src/pages/Pools/Home/ManageBond.tsx | 62 +-- .../pages/Pools/Home/ManagePool/Wrappers.ts | 6 +- .../src/pages/Pools/Home/ManagePool/index.tsx | 44 +- .../Pools/Home/PoolStats/Announcements.tsx | 58 +-- .../src/pages/Pools/Home/PoolStats/index.tsx | 74 +-- .../pages/Pools/Home/Stats/ActivePools.tsx | 16 +- .../pages/Pools/Home/Stats/MinCreateBond.tsx | 22 +- .../pages/Pools/Home/Stats/MinJoinBond.tsx | 22 +- .../Pools/Home/Status/MembershipStatus.tsx | 60 +-- .../src/pages/Pools/Home/Status/NewMember.tsx | 54 +-- .../pages/Pools/Home/Status/PoolStatus.tsx | 48 +- .../pages/Pools/Home/Status/RewardsStatus.tsx | 50 +- .../app/src/pages/Pools/Home/Status/index.tsx | 42 +- .../app/src/pages/Pools/Home/Status/types.ts | 8 +- .../Pools/Home/Status/useStatusButtons.tsx | 60 +-- packages/app/src/pages/Pools/Home/context.tsx | 26 +- packages/app/src/pages/Pools/Home/index.tsx | 70 +-- .../src/pages/Pools/PoolAccount/Wrapper.ts | 4 +- .../app/src/pages/Pools/PoolAccount/index.tsx | 46 +- .../Pools/Roles/RoleEditInput/Wrapper.ts | 4 +- .../pages/Pools/Roles/RoleEditInput/index.tsx | 52 +-- packages/app/src/pages/Pools/Roles/index.tsx | 130 +++--- packages/app/src/pages/Pools/Roles/types.ts | 26 +- packages/app/src/pages/Pools/index.tsx | 4 +- packages/app/src/pages/Pools/types.ts | 16 +- .../src/pages/Validators/AllValidators.tsx | 30 +- .../app/src/pages/Validators/Favorites.tsx | 24 +- .../Validators/Stats/ActiveValidators.tsx | 26 +- .../Validators/Stats/AverageCommission.tsx | 16 +- .../Validators/Stats/TotalValidators.tsx | 22 +- packages/app/src/pages/Validators/context.tsx | 30 +- packages/app/src/pages/Validators/index.tsx | 30 +- packages/app/src/vite-env.d.ts | 2 +- packages/app/src/workers/poolPerformance.ts | 60 +-- packages/app/src/workers/stakers.ts | 120 ++--- packages/app/src/workers/types.ts | 48 +- packages/app/tests/graphs.test.ts | 82 ++-- packages/app/vite.config.ts | 14 +- packages/consts/src/index.ts | 28 +- packages/locales/.scripts/localeOrderKeys.cjs | 32 +- packages/locales/.scripts/localeValidate.cjs | 56 +-- packages/locales/.scripts/utils.cjs | 56 +-- packages/locales/src/index.ts | 44 +- packages/locales/src/types.ts | 10 +- packages/locales/src/util.ts | 102 ++-- packages/plugin-staking-api/src/Client.tsx | 8 +- packages/plugin-staking-api/src/index.tsx | 8 +- .../src/queries/useTokenPrice.tsx | 24 +- packages/plugin-staking-api/src/types.ts | 18 +- packages/types/src/accounts.ts | 2 +- packages/types/src/common.ts | 2 +- packages/types/src/identity.ts | 12 +- packages/types/src/index.ts | 10 +- packages/types/src/nominate.ts | 8 +- packages/types/src/pools.ts | 148 +++--- packages/ui-buttons/src/ButtonHelp/index.tsx | 18 +- packages/ui-buttons/src/ButtonHelp/types.ts | 10 +- packages/ui-buttons/src/ButtonMono/index.tsx | 20 +- packages/ui-buttons/src/ButtonMono/types.ts | 10 +- .../ui-buttons/src/ButtonMonoInvert/index.tsx | 20 +- .../ui-buttons/src/ButtonMonoInvert/types.ts | 10 +- .../ui-buttons/src/ButtonOption/index.tsx | 22 +- packages/ui-buttons/src/ButtonOption/types.ts | 8 +- .../ui-buttons/src/ButtonPrimary/index.tsx | 20 +- .../ui-buttons/src/ButtonPrimary/types.ts | 12 +- .../src/ButtonPrimaryInvert/index.tsx | 20 +- .../src/ButtonPrimaryInvert/types.ts | 12 +- .../ui-buttons/src/ButtonSecondary/index.tsx | 20 +- .../ui-buttons/src/ButtonSecondary/types.ts | 10 +- .../ui-buttons/src/ButtonSubmit/index.tsx | 20 +- packages/ui-buttons/src/ButtonSubmit/types.ts | 14 +- .../src/ButtonSubmitInvert/index.tsx | 20 +- .../src/ButtonSubmitInvert/types.ts | 10 +- packages/ui-buttons/src/ButtonTab/index.tsx | 20 +- packages/ui-buttons/src/ButtonTab/types.ts | 14 +- .../ui-buttons/src/ButtonTertiary/index.tsx | 20 +- .../ui-buttons/src/ButtonTertiary/types.ts | 8 +- packages/ui-buttons/src/ButtonText/index.tsx | 20 +- packages/ui-buttons/src/ButtonText/types.ts | 8 +- packages/ui-buttons/src/index.tsx | 24 +- packages/ui-buttons/src/types.ts | 36 +- packages/ui-buttons/src/util.ts | 10 +- packages/ui-structure/src/Body/index.tsx | 6 +- packages/ui-structure/src/ButtonRow/index.tsx | 12 +- packages/ui-structure/src/Entry/index.tsx | 12 +- packages/ui-structure/src/Main/index.tsx | 12 +- packages/ui-structure/src/Page/index.tsx | 8 +- .../ui-structure/src/PageHeading/index.tsx | 6 +- packages/ui-structure/src/PageRow/index.tsx | 12 +- packages/ui-structure/src/PageTitle/index.tsx | 36 +- .../ui-structure/src/PageTitleTabs/index.tsx | 14 +- .../ui-structure/src/RowSection/index.tsx | 20 +- packages/ui-structure/src/RowSection/types.ts | 10 +- packages/ui-structure/src/Separator/index.tsx | 6 +- packages/ui-structure/src/Side/index.tsx | 16 +- packages/ui-structure/src/Side/types.ts | 10 +- .../ui-structure/src/StatBoxRow/index.tsx | 12 +- packages/ui-structure/src/index.tsx | 26 +- packages/ui-structure/src/types.ts | 38 +- packages/utils/src/index.ts | 58 +-- 849 files changed, 15976 insertions(+), 16065 deletions(-) diff --git a/env.d.ts b/env.d.ts index 4071af3e13..79e1c50033 100644 --- a/env.d.ts +++ b/env.d.ts @@ -2,6 +2,6 @@ // SPDX-License-Identifier: GPL-3.0-only declare module '*.module.scss' { - const classes: Record; - export default classes; + const classes: Record + export default classes } diff --git a/eslint.config.js b/eslint.config.js index ec662f3060..4ed4a15e1d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import pluginJs from '@eslint/js'; -import importPlugin from 'eslint-plugin-import'; -import preferArrowFunctions from 'eslint-plugin-prefer-arrow-functions'; -import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; -import react from 'eslint-plugin-react'; -import reactHooks from 'eslint-plugin-react-hooks'; -import unusedImports from 'eslint-plugin-unused-imports'; -import globals from 'globals'; -import tseslint from 'typescript-eslint'; +import pluginJs from '@eslint/js' +import importPlugin from 'eslint-plugin-import' +import preferArrowFunctions from 'eslint-plugin-prefer-arrow-functions' +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' +import react from 'eslint-plugin-react' +import reactHooks from 'eslint-plugin-react-hooks' +import unusedImports from 'eslint-plugin-unused-imports' +import globals from 'globals' +import tseslint from 'typescript-eslint' /** @type {import('eslint').Linter.Config[]} */ export default [ @@ -83,6 +83,13 @@ export default [ }, }, rules: { + // Prettier + 'prettier/prettier': [ + 'error', + { + semi: false, + }, + ], // Stylistic curly: 'error', 'arrow-body-style': ['error', 'as-needed'], @@ -104,7 +111,7 @@ export default [ caughtErrors: 'none', }, ], - semi: [2, 'always'], + semi: ['error', 'never'], 'import/extensions': [ 'error', 'ignorePackages', @@ -144,4 +151,4 @@ export default [ '@typescript-eslint/no-shadow': 'error', }, }, -]; +] diff --git a/package.json b/package.json index 20bb57693c..acbbb75aea 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "arrowParens": "always", "trailingComma": "es5", "tabWidth": 2, - "semi": true, + "semi": false, "singleQuote": true, "endOfLine": "auto", "plugins": [ diff --git a/packages/app/index.html b/packages/app/index.html index 55d24f6139..2b4adda68b 100644 --- a/packages/app/index.html +++ b/packages/app/index.html @@ -75,8 +75,8 @@ /> diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index edbe9e0db8..b58daa5b3f 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -1,12 +1,12 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { ActiveAccountsProvider } from 'contexts/ActiveAccounts'; -import { NetworkProvider } from 'contexts/Network'; -import { ThemesProvider } from 'contexts/Themes'; -import { i18next } from 'locales'; -import { Providers } from 'Providers'; -import { I18nextProvider } from 'react-i18next'; +import { ActiveAccountsProvider } from 'contexts/ActiveAccounts' +import { NetworkProvider } from 'contexts/Network' +import { ThemesProvider } from 'contexts/Themes' +import { i18next } from 'locales' +import { Providers } from 'Providers' +import { I18nextProvider } from 'react-i18next' export const App = () => ( @@ -18,4 +18,4 @@ export const App = () => ( -); +) diff --git a/packages/app/src/Providers.tsx b/packages/app/src/Providers.tsx index e5b42b674d..bc2e1c4dea 100644 --- a/packages/app/src/Providers.tsx +++ b/packages/app/src/Providers.tsx @@ -1,58 +1,58 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { withProviders } from '@w3ux/factories'; +import { withProviders } from '@w3ux/factories' import { ExtensionAccountsProvider, ExtensionsProvider, LedgerAccountsProvider, VaultAccountsProvider, WCAccountsProvider, -} from '@w3ux/react-connect-kit'; -import { DappName } from 'consts'; -import { useActiveAccounts } from 'contexts/ActiveAccounts'; -import { APIProvider } from 'contexts/Api'; -import { BalancesProvider } from 'contexts/Balances'; -import { BondedProvider } from 'contexts/Bonded'; -import { CommunityProvider } from 'contexts/Community'; -import { ExternalAccountsProvider } from 'contexts/Connect/ExternalAccounts'; -import { ImportedAccountsProvider } from 'contexts/Connect/ImportedAccounts'; -import { OtherAccountsProvider } from 'contexts/Connect/OtherAccounts'; -import { FastUnstakeProvider } from 'contexts/FastUnstake'; -import { FiltersProvider } from 'contexts/Filters'; -import { HelpProvider } from 'contexts/Help'; -import { LedgerHardwareProvider } from 'contexts/LedgerHardware'; -import { MenuProvider } from 'contexts/Menu'; -import { MigrateProvider } from 'contexts/Migrate'; -import { useNetwork } from 'contexts/Network'; -import { PayoutsProvider } from 'contexts/Payouts'; -import { PluginsProvider } from 'contexts/Plugins'; -import { ActivePoolProvider } from 'contexts/Pools/ActivePool'; -import { BondedPoolsProvider } from 'contexts/Pools/BondedPools'; -import { FavoritePoolsProvider } from 'contexts/Pools/FavoritePools'; -import { JoinPoolsProvider } from 'contexts/Pools/JoinPools'; -import { PoolMembersProvider } from 'contexts/Pools/PoolMembers'; -import { PoolPerformanceProvider } from 'contexts/Pools/PoolPerformance'; -import { PromptProvider } from 'contexts/Prompt'; -import { ProxiesProvider } from 'contexts/Proxies'; -import { SetupProvider } from 'contexts/Setup'; -import { StakingProvider } from 'contexts/Staking'; -import { TooltipProvider } from 'contexts/Tooltip'; -import { TransferOptionsProvider } from 'contexts/TransferOptions'; -import { TxMetaProvider } from 'contexts/TxMeta'; -import { UIProvider } from 'contexts/UI'; -import { FavoriteValidatorsProvider } from 'contexts/Validators/FavoriteValidators'; -import { ValidatorsProvider } from 'contexts/Validators/ValidatorEntries'; -import { WalletConnectProvider } from 'contexts/WalletConnect'; -import { OverlayProvider } from 'kits/Overlay/Provider'; -import { ThemedRouter } from 'Themes'; +} from '@w3ux/react-connect-kit' +import { DappName } from 'consts' +import { useActiveAccounts } from 'contexts/ActiveAccounts' +import { APIProvider } from 'contexts/Api' +import { BalancesProvider } from 'contexts/Balances' +import { BondedProvider } from 'contexts/Bonded' +import { CommunityProvider } from 'contexts/Community' +import { ExternalAccountsProvider } from 'contexts/Connect/ExternalAccounts' +import { ImportedAccountsProvider } from 'contexts/Connect/ImportedAccounts' +import { OtherAccountsProvider } from 'contexts/Connect/OtherAccounts' +import { FastUnstakeProvider } from 'contexts/FastUnstake' +import { FiltersProvider } from 'contexts/Filters' +import { HelpProvider } from 'contexts/Help' +import { LedgerHardwareProvider } from 'contexts/LedgerHardware' +import { MenuProvider } from 'contexts/Menu' +import { MigrateProvider } from 'contexts/Migrate' +import { useNetwork } from 'contexts/Network' +import { PayoutsProvider } from 'contexts/Payouts' +import { PluginsProvider } from 'contexts/Plugins' +import { ActivePoolProvider } from 'contexts/Pools/ActivePool' +import { BondedPoolsProvider } from 'contexts/Pools/BondedPools' +import { FavoritePoolsProvider } from 'contexts/Pools/FavoritePools' +import { JoinPoolsProvider } from 'contexts/Pools/JoinPools' +import { PoolMembersProvider } from 'contexts/Pools/PoolMembers' +import { PoolPerformanceProvider } from 'contexts/Pools/PoolPerformance' +import { PromptProvider } from 'contexts/Prompt' +import { ProxiesProvider } from 'contexts/Proxies' +import { SetupProvider } from 'contexts/Setup' +import { StakingProvider } from 'contexts/Staking' +import { TooltipProvider } from 'contexts/Tooltip' +import { TransferOptionsProvider } from 'contexts/TransferOptions' +import { TxMetaProvider } from 'contexts/TxMeta' +import { UIProvider } from 'contexts/UI' +import { FavoriteValidatorsProvider } from 'contexts/Validators/FavoriteValidators' +import { ValidatorsProvider } from 'contexts/Validators/ValidatorEntries' +import { WalletConnectProvider } from 'contexts/WalletConnect' +import { OverlayProvider } from 'kits/Overlay/Provider' +import { ThemedRouter } from 'Themes' export const Providers = () => { const { network, networkData: { ss58 }, - } = useNetwork(); - const { activeAccount, setActiveAccount } = useActiveAccounts(); + } = useNetwork() + const { activeAccount, setActiveAccount } = useActiveAccounts() return withProviders( // !! Provider order matters. @@ -103,5 +103,5 @@ export const Providers = () => { CommunityProvider, ], ThemedRouter - ); -}; + ) +} diff --git a/packages/app/src/Router.tsx b/packages/app/src/Router.tsx index 6b0e2da513..cb139e817b 100644 --- a/packages/app/src/Router.tsx +++ b/packages/app/src/Router.tsx @@ -1,81 +1,81 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { extractUrlValue } from '@w3ux/utils'; -import { PagesConfig } from 'config/pages'; -import { useActiveAccounts } from 'contexts/ActiveAccounts'; -import { useImportedAccounts } from 'contexts/Connect/ImportedAccounts'; -import { useOtherAccounts } from 'contexts/Connect/OtherAccounts'; -import { useNetwork } from 'contexts/Network'; -import { useUi } from 'contexts/UI'; -import { Notifications } from 'controllers/Notifications'; -import { ErrorFallbackApp, ErrorFallbackRoutes } from 'library/ErrorBoundary'; -import { Headers } from 'library/Headers'; -import { Help } from 'library/Help'; -import { Menu } from 'library/Menu'; -import { NetworkBar } from 'library/NetworkBar'; -import { NotificationPrompts } from 'library/NotificationPrompts'; -import { Offline } from 'library/Offline'; -import { PageWithTitle } from 'library/PageWithTitle'; -import { Prompt } from 'library/Prompt'; -import { SideMenu } from 'library/SideMenu'; -import { Tooltip } from 'library/Tooltip'; -import { Overlays } from 'overlay'; -import { useEffect, useRef } from 'react'; -import { ErrorBoundary } from 'react-error-boundary'; -import { useTranslation } from 'react-i18next'; +import { extractUrlValue } from '@w3ux/utils' +import { PagesConfig } from 'config/pages' +import { useActiveAccounts } from 'contexts/ActiveAccounts' +import { useImportedAccounts } from 'contexts/Connect/ImportedAccounts' +import { useOtherAccounts } from 'contexts/Connect/OtherAccounts' +import { useNetwork } from 'contexts/Network' +import { useUi } from 'contexts/UI' +import { Notifications } from 'controllers/Notifications' +import { ErrorFallbackApp, ErrorFallbackRoutes } from 'library/ErrorBoundary' +import { Headers } from 'library/Headers' +import { Help } from 'library/Help' +import { Menu } from 'library/Menu' +import { NetworkBar } from 'library/NetworkBar' +import { NotificationPrompts } from 'library/NotificationPrompts' +import { Offline } from 'library/Offline' +import { PageWithTitle } from 'library/PageWithTitle' +import { Prompt } from 'library/Prompt' +import { SideMenu } from 'library/SideMenu' +import { Tooltip } from 'library/Tooltip' +import { Overlays } from 'overlay' +import { useEffect, useRef } from 'react' +import { ErrorBoundary } from 'react-error-boundary' +import { useTranslation } from 'react-i18next' import { HashRouter, Navigate, Route, Routes, useLocation, -} from 'react-router-dom'; -import { Body, Main } from 'ui-structure'; +} from 'react-router-dom' +import { Body, Main } from 'ui-structure' const RouterInner = () => { - const { t } = useTranslation(); - const { network } = useNetwork(); - const { pathname } = useLocation(); - const { setContainerRefs } = useUi(); - const { accounts } = useImportedAccounts(); - const { accountsInitialised } = useOtherAccounts(); - const { activeAccount, setActiveAccount } = useActiveAccounts(); + const { t } = useTranslation() + const { network } = useNetwork() + const { pathname } = useLocation() + const { setContainerRefs } = useUi() + const { accounts } = useImportedAccounts() + const { accountsInitialised } = useOtherAccounts() + const { activeAccount, setActiveAccount } = useActiveAccounts() // References to outer container. - const mainInterfaceRef = useRef(null); + const mainInterfaceRef = useRef(null) // Scroll to top of the window on every page change or network change. useEffect(() => { - window.scrollTo(0, 0); - }, [pathname, network]); + window.scrollTo(0, 0) + }, [pathname, network]) // Set container references to UI context and make available throughout app. useEffect(() => { setContainerRefs({ mainInterface: mainInterfaceRef, - }); - }, []); + }) + }, []) // Open default account modal if url var present and accounts initialised. useEffect(() => { if (accountsInitialised) { - const aUrl = extractUrlValue('a'); + const aUrl = extractUrlValue('a') if (aUrl) { - const account = accounts.find((a) => a.address === aUrl); + const account = accounts.find((a) => a.address === aUrl) if (account && aUrl !== activeAccount) { - setActiveAccount(account.address || null); + setActiveAccount(account.address || null) Notifications.emit({ title: t('accountConnected', { ns: 'library' }), subtitle: `${t('connectedTo', { ns: 'library' })} ${ account.name || aUrl }.`, - }); + }) } } } - }, [accountsInitialised]); + }, [accountsInitialised]) return ( @@ -110,11 +110,11 @@ const RouterInner = () => { - ); -}; + ) +} export const Router = () => ( -); +) diff --git a/packages/app/src/Themes.tsx b/packages/app/src/Themes.tsx index fe245eda0d..fe26c44f80 100644 --- a/packages/app/src/Themes.tsx +++ b/packages/app/src/Themes.tsx @@ -1,26 +1,26 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Router } from 'Router'; -import { useNetwork } from 'contexts/Network'; -import { useTheme } from 'contexts/Themes'; -import { useEffect } from 'react'; -import { ThemeProvider } from 'styled-components'; -import { Entry } from 'ui-structure'; +import { Router } from 'Router' +import { useNetwork } from 'contexts/Network' +import { useTheme } from 'contexts/Themes' +import { useEffect } from 'react' +import { ThemeProvider } from 'styled-components' +import { Entry } from 'ui-structure' // light / dark `mode` added to styled-components provider export const ThemedRouter = () => { - const { mode } = useTheme(); - const { network } = useNetwork(); + const { mode } = useTheme() + const { network } = useNetwork() // Update body background to `--background-default` color upon theme change. useEffect(() => { - const elem = document.querySelector('.core-entry'); + const elem = document.querySelector('.core-entry') if (elem) { document.getElementsByTagName('body')[0].style.backgroundColor = - getComputedStyle(elem).getPropertyValue('--background-default'); + getComputedStyle(elem).getPropertyValue('--background-default') } - }, [mode]); + }, [mode]) return ( @@ -28,5 +28,5 @@ export const ThemedRouter = () => { - ); -}; + ) +} diff --git a/packages/app/src/api/base.ts b/packages/app/src/api/base.ts index 25b0206f9c..62ac22014b 100644 --- a/packages/app/src/api/base.ts +++ b/packages/app/src/api/base.ts @@ -1,18 +1,18 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { ChainId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { PolkadotClient } from 'polkadot-api'; +import type { ChainId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { PolkadotClient } from 'polkadot-api' export class Base { - #client: PolkadotClient; + #client: PolkadotClient constructor(network: ChainId) { - this.#client = Apis.getClient(network); + this.#client = Apis.getClient(network) } get unsafeApi() { - return this.#client.getUnsafeApi(); + return this.#client.getUnsafeApi() } } diff --git a/packages/app/src/api/entries/bondedPoolsEntries.ts b/packages/app/src/api/entries/bondedPoolsEntries.ts index 2e4a51f6dd..8939e2e6e5 100644 --- a/packages/app/src/api/entries/bondedPoolsEntries.ts +++ b/packages/app/src/api/entries/bondedPoolsEntries.ts @@ -1,65 +1,65 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import BigNumber from 'bignumber.js'; -import type { AnyApi, ChainId } from 'common-types'; -import { perbillToPercent } from 'utils'; +import { Base } from 'api/base' +import BigNumber from 'bignumber.js' +import type { AnyApi, ChainId } from 'common-types' +import { perbillToPercent } from 'utils' export class BondedPoolsEntries extends Base { - bondedPools: AnyApi = {}; + bondedPools: AnyApi = {} constructor(network: ChainId) { - super(network); + super(network) } async fetch() { this.bondedPools = await this.unsafeApi.query.NominationPools.BondedPools.getEntries({ at: 'best', - }); - return this; + }) + return this } async fetchOne(id: number) { const result = await this.unsafeApi.query.NominationPools.BondedPools.getValue(id, { at: 'best', - }); + }) if (!result) { - return null; + return null } - return this.formatPool(result); + return this.formatPool(result) } format(entry?: AnyApi) { return Object.fromEntries( (entry ? [entry] : this.bondedPools).map( ({ keyArgs, value }: { keyArgs: [number]; value: AnyApi }) => { - const id = keyArgs[0]; - const pool = this.formatPool(value); - return [id, pool]; + const id = keyArgs[0] + const pool = this.formatPool(value) + return [id, pool] } ) - ); + ) } formatPool(value: AnyApi) { - const maybeCommissionCurrent = value.commission.current; + const maybeCommissionCurrent = value.commission.current const commissionCurrent = !maybeCommissionCurrent ? null : [ perbillToPercent(maybeCommissionCurrent[0]).toString(), maybeCommissionCurrent[1], - ]; + ] - const commissionMax = value.commission.max; + const commissionMax = value.commission.max const commissionMaxPercent = !commissionMax ? null - : perbillToPercent(new BigNumber(value.commission.max)); + : perbillToPercent(new BigNumber(value.commission.max)) - const commissionChangeRate = value.commission.change_rate; + const commissionChangeRate = value.commission.change_rate const commission = { current: commissionCurrent, @@ -67,7 +67,7 @@ export class BondedPoolsEntries extends Base { max: commissionMaxPercent, changeRate: commissionChangeRate || null, throttleFrom: value.commission.throttle_from || null, - }; + } const pool = { commission, @@ -75,8 +75,8 @@ export class BondedPoolsEntries extends Base { memberCounter: value.member_counter.toString(), roles: value.roles, state: value.state.type, - }; + } - return pool; + return pool } } diff --git a/packages/app/src/api/entries/erasStakersPagedEntries.tsx b/packages/app/src/api/entries/erasStakersPagedEntries.tsx index 71317d404e..24612a2f84 100644 --- a/packages/app/src/api/entries/erasStakersPagedEntries.tsx +++ b/packages/app/src/api/entries/erasStakersPagedEntries.tsx @@ -1,12 +1,12 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ErasStakersPagedEntries extends Base { constructor(network: ChainId) { - super(network); + super(network) } async fetch(era: number, validator: string) { @@ -14,6 +14,6 @@ export class ErasStakersPagedEntries extends Base { era, validator, { at: 'best' } - ); + ) } } diff --git a/packages/app/src/api/entries/validatorsEntries.ts b/packages/app/src/api/entries/validatorsEntries.ts index 474d7a0e84..e041c0ae2b 100644 --- a/packages/app/src/api/entries/validatorsEntries.ts +++ b/packages/app/src/api/entries/validatorsEntries.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ValidatorsEntries extends Base { constructor(network: ChainId) { - super(network); + super(network) } async fetch() { return await this.unsafeApi.query.Staking.Validators.getEntries({ at: 'best', - }); + }) } } diff --git a/packages/app/src/api/index.ts b/packages/app/src/api/index.ts index 2a806cafca..d1e68744e5 100644 --- a/packages/app/src/api/index.ts +++ b/packages/app/src/api/index.ts @@ -1,16 +1,16 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { ChainId } from 'common-types'; -import { NetworkList, SystemChainList } from 'config/networks'; -import { getLightClientMetadata } from 'config/util'; -import { Subscriptions } from 'controllers/Subscriptions'; -import type { PolkadotClient } from 'polkadot-api'; -import { createClient } from 'polkadot-api'; -import { getSmProvider } from 'polkadot-api/sm-provider'; -import { startFromWorker } from 'polkadot-api/smoldot/from-worker'; -import SmWorker from 'polkadot-api/smoldot/worker?worker'; -import { getWsProvider } from 'polkadot-api/ws-provider/web'; +import type { ChainId } from 'common-types' +import { NetworkList, SystemChainList } from 'config/networks' +import { getLightClientMetadata } from 'config/util' +import { Subscriptions } from 'controllers/Subscriptions' +import type { PolkadotClient } from 'polkadot-api' +import { createClient } from 'polkadot-api' +import { getSmProvider } from 'polkadot-api/sm-provider' +import { startFromWorker } from 'polkadot-api/smoldot/from-worker' +import SmWorker from 'polkadot-api/smoldot/worker?worker' +import { getWsProvider } from 'polkadot-api/ws-provider/web' import type { ApiChainType, APIEventDetail, @@ -18,122 +18,122 @@ import type { EventApiStatus, PapiChainSpec, PapiReadyEvent, -} from './types'; +} from './types' export class Api { - // The network name associated with this Api instance. - network: ChainId; + // The network name associated with this Api instance + network: ChainId - // The type of chain being connected to. - #chainType: ApiChainType; + // The type of chain being connected to + #chainType: ApiChainType // API client. - #apiClient: PolkadotClient; + #apiClient: PolkadotClient - // The fetched chain spec. - #chainSpec: PapiChainSpec; + // The fetched chain spec + #chainSpec: PapiChainSpec - // The current RPC endpoint. - #rpcEndpoint: string; + // The current RPC endpoint + #rpcEndpoint: string - // The current connection type. - #connectionType: ConnectionType; + // The current connection type + #connectionType: ConnectionType get apiClient() { - return this.#apiClient; + return this.#apiClient } get unsafeApi() { - return this.#apiClient.getUnsafeApi(); + return this.#apiClient.getUnsafeApi() } get chainSpec() { - return this.#chainSpec; + return this.#chainSpec } get connectionType() { - return this.#connectionType; + return this.#connectionType } constructor(network: ChainId, chainType: ApiChainType) { - this.network = network; - this.#chainType = chainType; + this.network = network + this.#chainType = chainType } - // Class initialization. Sets the `provider` and `api` class members. + // Class initialization. Sets the `provider` and `api` class members async initialize(type: ConnectionType, rpcEndpoint: string) { // Set connection metadata. - this.#rpcEndpoint = rpcEndpoint; - this.#connectionType = type; + this.#rpcEndpoint = rpcEndpoint + this.#connectionType = type // Connect to api. - await this.connect(); + await this.connect() } - // Connect to Api instance. + // Connect to Api instance async connect() { try { - // Initiate provider based on connection type. + // Initiate provider based on connection type if (this.#connectionType === 'ws') { - this.initWsProvider(); + this.initWsProvider() } else { - await this.initScProvider(); + await this.initScProvider() } - // Tell UI api is connecting. - this.dispatchEvent(this.ensureEventStatus('connecting')); + // Tell UI api is connecting + this.dispatchEvent(this.ensureEventStatus('connecting')) - // Fetch chain spec and metadata from PAPI client. - await this.fetchChainSpec(); + // Fetch chain spec and metadata from api client + await this.fetchChainSpec() } catch (e) { - // TODO: Handle unsupported chains in UI. + // TODO: Handle unsupported chains in UI // this.dispatchEvent(this.ensureEventStatus('error')); } } - // Initiate Websocket Provider. + // Initiate Websocket Provider initWsProvider() { const endpoint = this.#chainType === 'relay' ? NetworkList[this.network].endpoints.rpcEndpoints[this.#rpcEndpoint] : SystemChainList[this.network].endpoints.rpcEndpoints[ this.#rpcEndpoint - ]; + ] - // Initialize Polkadot API Client. - this.#apiClient = createClient(getWsProvider(endpoint)); + // Initialize Polkadot API Client + this.#apiClient = createClient(getWsProvider(endpoint)) } - // Dynamically load and connect to Substrate Connect. + // Dynamically load and connect to Substrate Connect async initScProvider() { - // Initialise light client. - const smoldot = startFromWorker(new SmWorker()); - const smMetadata = getLightClientMetadata(this.#chainType, this.network); - const { chainSpec: relayChainSpec } = await smMetadata.relay.fn(); + // Initialise light client + const smoldot = startFromWorker(new SmWorker()) + const smMetadata = getLightClientMetadata(this.#chainType, this.network) + const { chainSpec: relayChainSpec } = await smMetadata.relay.fn() - let chain; + let chain if (this.#chainType === 'relay') { - chain = smoldot.addChain({ chainSpec: relayChainSpec }); - this.#apiClient = createClient(getSmProvider(chain)); + chain = smoldot.addChain({ chainSpec: relayChainSpec }) + this.#apiClient = createClient(getSmProvider(chain)) } else { - const { chainSpec: paraChainSpec } = await smMetadata!.para!.fn(); + const { chainSpec: paraChainSpec } = await smMetadata!.para!.fn() chain = smoldot.addChain({ chainSpec: paraChainSpec, potentialRelayChains: [ await smoldot.addChain({ chainSpec: relayChainSpec }), ], - }); - this.#apiClient = createClient(getSmProvider(chain)); + }) + this.#apiClient = createClient(getSmProvider(chain)) } } async fetchChainSpec() { try { - const chainSpecData = await this.#apiClient.getChainSpecData(); - const version = await this.unsafeApi.constants.System.Version(); + const chainSpecData = await this.#apiClient.getChainSpecData() + const version = await this.unsafeApi.constants.System.Version() - const { genesisHash, properties } = chainSpecData; - const { ss58Format, tokenDecimals, tokenSymbol } = properties; + const { genesisHash, properties } = chainSpecData + const { ss58Format, tokenDecimals, tokenSymbol } = properties const { authoring_version: authoringVersion, impl_name: implName, @@ -142,7 +142,7 @@ export class Api { spec_version: specVersion, state_version: stateVersion, transaction_version: transactionVersion, - } = version; + } = version this.#chainSpec = { genesisHash, @@ -156,17 +156,17 @@ export class Api { specVersion, stateVersion, transactionVersion, - }; + } - // Dispatch ready eventd to let contexts populate constants. - this.dispatchReadyEvent(); + // Dispatch ready eventd to let contexts populate constants + this.dispatchReadyEvent() } catch (e) { - // TODO: Handle unsupported chains in UI. + // TODO: Handle unsupported chains in UI //this.dispatchEvent(this.ensureEventStatus('error'), { err: 'ChainSpecError' }); } } - // Get a pallet constant, with a fallback value. + // Get a pallet constant, with a fallback value getConstant = async ( pallet: string, key: string, @@ -174,35 +174,35 @@ export class Api { formatter?: 'asBytes' ): Promise => { try { - const result = await this.unsafeApi.constants[pallet][key](); + const result = await this.unsafeApi.constants[pallet][key]() switch (formatter) { case 'asBytes': - return result.asBytes(); + return result.asBytes() default: - return result; + return result } } catch (e) { - return fallback; + return fallback } - }; + } - // Handler for dispatching ready events. + // Handler for dispatching ready events dispatchReadyEvent() { const detail: PapiReadyEvent = { network: this.network, chainType: this.#chainType, ...this.#chainSpec, - }; - this.dispatchEvent(this.ensureEventStatus('ready')); - document.dispatchEvent(new CustomEvent('api-ready', { detail })); + } + this.dispatchEvent(this.ensureEventStatus('ready')) + document.dispatchEvent(new CustomEvent('api-ready', { detail })) } - // Handler for dispatching `api-status` events. + // Handler for dispatching `api-status` events dispatchEvent( status: EventApiStatus, options?: { - err?: string; + err?: string } ) { const detail: APIEventDetail = { @@ -211,14 +211,14 @@ export class Api { status, connectionType: this.#connectionType, rpcEndpoint: this.#rpcEndpoint, - }; + } if (options?.err) { - detail['err'] = options.err; + detail['err'] = options.err } - document.dispatchEvent(new CustomEvent('api-status', { detail })); + document.dispatchEvent(new CustomEvent('api-status', { detail })) } - // Ensures the provided status is a valid `EventStatus` being passed, or falls back to `error`. + // Ensures the provided status is a valid `EventStatus` being passed, or falls back to `error` ensureEventStatus = (status: string | EventApiStatus): EventApiStatus => { const eventStatus: string[] = [ 'connecting', @@ -227,38 +227,38 @@ export class Api { 'ready', 'error', 'destroyed', - ]; + ] if (eventStatus.includes(status)) { - return status as EventApiStatus; + return status as EventApiStatus } - return 'error' as EventApiStatus; - }; + return 'error' as EventApiStatus + } - // Unsubscribe from all active subscriptions and remove them from subscriptions controller. + // Unsubscribe from all active subscriptions and remove them from subscriptions controller unsubscribe = () => { - const subs = Subscriptions.getAll(this.network); + const subs = Subscriptions.getAll(this.network) if (subs) { Object.entries(subs).forEach(([subscriptionId, subscription]) => { - subscription.unsubscribe(); - Subscriptions.remove(this.network, subscriptionId); - }); + subscription.unsubscribe() + Subscriptions.remove(this.network, subscriptionId) + }) } - }; + } - // Disconnect gracefully from API and provider. + // Disconnect gracefully from API and provider async disconnect(destroy = false) { - this.unsubscribe(); + this.unsubscribe() // Disconnect client. try { - this.#apiClient?.destroy(); + this.#apiClient?.destroy() } catch (e) { - // Suppress subscription errors. + // Suppress subscription errors } - // Tell UI Api has been disconnected. + // Tell UI Api has been disconnected if (destroy) { - this.dispatchEvent(this.ensureEventStatus('disconnected')); + this.dispatchEvent(this.ensureEventStatus('disconnected')) } } } diff --git a/packages/app/src/api/query/claimedRewards.ts b/packages/app/src/api/query/claimedRewards.ts index 1fe178988c..e2df0903a2 100644 --- a/packages/app/src/api/query/claimedRewards.ts +++ b/packages/app/src/api/query/claimedRewards.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ClaimedRewards extends Base { - #era: number; - #address: string; + #era: number + #address: string constructor(network: ChainId, era: number, address: string) { - super(network); - this.#era = era; - this.#address = address; + super(network) + this.#era = era + this.#address = address } async fetch() { @@ -22,12 +22,12 @@ export class ClaimedRewards extends Base { { at: 'best', } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return undefined; + return undefined } } diff --git a/packages/app/src/api/query/era.ts b/packages/app/src/api/query/era.ts index bc680d7594..8fc30cf498 100644 --- a/packages/app/src/api/query/era.ts +++ b/packages/app/src/api/query/era.ts @@ -1,31 +1,31 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import BigNumber from 'bignumber.js'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import BigNumber from 'bignumber.js' +import type { ChainId } from 'common-types' export class Era extends Base { constructor(network: ChainId) { - super(network); + super(network) } async fetch() { let era = { start: 0n, index: 0, - }; + } try { const result = await this.unsafeApi.query.Staking.ActiveEra.getValue({ at: 'best', - }); + }) if (result) { era = { start: result?.start || 0n, index: result.index, - }; + } } } catch (e) { // Silent fail. @@ -35,17 +35,17 @@ export class Era extends Base { const activeEra = { start: new BigNumber(era.start.toString()), index: new BigNumber(era.index), - }; + } // Get previous era. const previousEra = BigNumber.max( 0, new BigNumber(activeEra.index).minus(1) - ); + ) return { activeEra, previousEra, - }; + } } } diff --git a/packages/app/src/api/query/erasRewardPoints.ts b/packages/app/src/api/query/erasRewardPoints.ts index d97714b26b..4cbd66e754 100644 --- a/packages/app/src/api/query/erasRewardPoints.ts +++ b/packages/app/src/api/query/erasRewardPoints.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ErasRewardPoints extends Base { - #era: number; + #era: number constructor(network: ChainId, era: number) { - super(network); - this.#era = era; + super(network) + this.#era = era } async fetch() { @@ -20,12 +20,12 @@ export class ErasRewardPoints extends Base { { at: 'best', } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/query/erasStakersOverview.tsx b/packages/app/src/api/query/erasStakersOverview.tsx index 3086aea082..9f33e0b25d 100644 --- a/packages/app/src/api/query/erasStakersOverview.tsx +++ b/packages/app/src/api/query/erasStakersOverview.tsx @@ -1,12 +1,12 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ErasStakersOverview extends Base { constructor(network: ChainId) { - super(network); + super(network) } async fetch(era: number) { @@ -15,6 +15,6 @@ export class ErasStakersOverview extends Base { { at: 'best', } - ); + ) } } diff --git a/packages/app/src/api/query/erasValidatorReward.ts b/packages/app/src/api/query/erasValidatorReward.ts index e77a565363..5784e93d66 100644 --- a/packages/app/src/api/query/erasValidatorReward.ts +++ b/packages/app/src/api/query/erasValidatorReward.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ErasValidatorReward extends Base { - #era: number; + #era: number constructor(network: ChainId, era: number) { - super(network); - this.#era = era; + super(network) + this.#era = era } async fetch() { @@ -20,12 +20,12 @@ export class ErasValidatorReward extends Base { { at: 'best', } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/query/networkMeta.ts b/packages/app/src/api/query/networkMeta.ts index 6d54b1a780..88c5548f44 100644 --- a/packages/app/src/api/query/networkMeta.ts +++ b/packages/app/src/api/query/networkMeta.ts @@ -1,22 +1,22 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import BigNumber from 'bignumber.js'; -import type { ChainId } from 'common-types'; -import type { APIActiveEra } from 'contexts/Api/types'; -import { perbillToPercent, stringToBn } from 'utils'; +import { Base } from 'api/base' +import BigNumber from 'bignumber.js' +import type { ChainId } from 'common-types' +import type { APIActiveEra } from 'contexts/Api/types' +import { perbillToPercent, stringToBn } from 'utils' export class NetworkMeta extends Base { constructor(network: ChainId) { - super(network); + super(network) } // Fetch network constants. async fetch(activeEra: APIActiveEra, previousEra: BigNumber) { - const at = { at: 'best' }; + const at = { at: 'best' } const totalIssuance = - await this.unsafeApi.query.Balances.TotalIssuance.getValue(at); + await this.unsafeApi.query.Balances.TotalIssuance.getValue(at) const [ auctionCounter, @@ -73,25 +73,25 @@ export class NetworkMeta extends Base { activeEra.index.toNumber(), at ), - ]); + ]) // Format globalMaxCommission from a perbill to a percent. const globalMaxCommissionAsPercent = !globalMaxCommission ? new BigNumber(0) - : perbillToPercent(globalMaxCommission); + : perbillToPercent(globalMaxCommission) // Format max pool members to be a BigNumber, or null if it's not set. const maxPoolMembers = maxPoolMembersRaw ? new BigNumber(maxPoolMembersRaw.toString()) - : null; + : null // Format max pool members per pool to be a BigNumber, or null if it's not set. const maxPoolMembersPerPool = maxPoolMembersPerPoolRaw ? new BigNumber(maxPoolMembersPerPoolRaw.toString()) - : null; + : null // Format max pools to be a BigNumber, or null if it's not set. - const maxPools = maxPoolsRaw ? new BigNumber(maxPoolsRaw.toString()) : null; + const maxPools = maxPoolsRaw ? new BigNumber(maxPoolsRaw.toString()) : null return { networkMetrics: { @@ -123,6 +123,6 @@ export class NetworkMeta extends Base { totalStaked: stringToBn(activeEraErasTotalStake.toString()), counterForNominators: stringToBn(counterForNominators.toString()), }, - }; + } } } diff --git a/packages/app/src/api/query/paraSessionAccounts.ts b/packages/app/src/api/query/paraSessionAccounts.ts index 56d08ba965..c8eac8372d 100644 --- a/packages/app/src/api/query/paraSessionAccounts.ts +++ b/packages/app/src/api/query/paraSessionAccounts.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ParaSessionAccounts extends Base { - #session: number; + #session: number constructor(network: ChainId, session: number) { - super(network); - this.#session = session; + super(network) + this.#session = session } async fetch() { @@ -18,15 +18,15 @@ export class ParaSessionAccounts extends Base { await this.unsafeApi.query.ParaSessionInfo.AccountKeys.getValue( this.#session, { at: 'best' } - ); + ) if (result) { - return result; + return result } } catch (e) { // Silent fail } - return []; + return [] } } diff --git a/packages/app/src/api/query/proxiesQuery.ts b/packages/app/src/api/query/proxiesQuery.ts index fd6d74dfe6..921bacab35 100644 --- a/packages/app/src/api/query/proxiesQuery.ts +++ b/packages/app/src/api/query/proxiesQuery.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ProxiesQuery extends Base { - #address: string; + #address: string constructor(network: ChainId, address: string) { - super(network); - this.#address = address; + super(network) + this.#address = address } async fetch() { @@ -17,12 +17,12 @@ export class ProxiesQuery extends Base { const result = await this.unsafeApi.query.Proxy.Proxies.getValue( this.#address, { at: 'best' } - ); - return result; + ) + return result } catch (e) { // Subscription failed. } - return undefined; + return undefined } } diff --git a/packages/app/src/api/query/sessionValidators.ts b/packages/app/src/api/query/sessionValidators.ts index 4db3e33cd3..af7c303e00 100644 --- a/packages/app/src/api/query/sessionValidators.ts +++ b/packages/app/src/api/query/sessionValidators.ts @@ -1,12 +1,12 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class SessionValidators extends Base { constructor(network: ChainId) { - super(network); + super(network) } // Fetch network constants. @@ -14,11 +14,11 @@ export class SessionValidators extends Base { try { const result = await this.unsafeApi.query.Session.Validators.getValue({ at: 'best', - }); - return result; + }) + return result } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/query/validatorPrefs.ts b/packages/app/src/api/query/validatorPrefs.ts index 5e13cf76cb..11285928c2 100644 --- a/packages/app/src/api/query/validatorPrefs.ts +++ b/packages/app/src/api/query/validatorPrefs.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ValidatorPrefs extends Base { - #era: number; - #address: string; + #era: number + #address: string constructor(network: ChainId, era: number, address: string) { - super(network); - this.#era = era; - this.#address = address; + super(network) + this.#era = era + this.#address = address } async fetch() { @@ -21,12 +21,12 @@ export class ValidatorPrefs extends Base { this.#era, this.#address, { at: 'best' } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return undefined; + return undefined } } diff --git a/packages/app/src/api/queryMulti/bondedMulti.ts b/packages/app/src/api/queryMulti/bondedMulti.ts index 2a08334ea5..3fac0cb5ed 100644 --- a/packages/app/src/api/queryMulti/bondedMulti.ts +++ b/packages/app/src/api/queryMulti/bondedMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class BondedMulti extends Base { - #addresses: [string][]; + #addresses: [string][] constructor(network: ChainId, eras: [string][]) { - super(network); - this.#addresses = eras; + super(network) + this.#addresses = eras } async fetch() { @@ -19,12 +19,12 @@ export class BondedMulti extends Base { { at: 'best', } - ); - return results; + ) + return results } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/queryMulti/erasRewardPointsMulti.ts b/packages/app/src/api/queryMulti/erasRewardPointsMulti.ts index 1435752d11..01006b8c6b 100644 --- a/packages/app/src/api/queryMulti/erasRewardPointsMulti.ts +++ b/packages/app/src/api/queryMulti/erasRewardPointsMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ErasRewardPointsMulti extends Base { - #eras: [number][]; + #eras: [number][] constructor(network: ChainId, eras: [number][]) { - super(network); - this.#eras = eras; + super(network) + this.#eras = eras } async fetch() { @@ -20,12 +20,12 @@ export class ErasRewardPointsMulti extends Base { { at: 'best', } - ); - return results; + ) + return results } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/queryMulti/erasValidatorRewardMulti.ts b/packages/app/src/api/queryMulti/erasValidatorRewardMulti.ts index 2306b8ac5a..03def2df64 100644 --- a/packages/app/src/api/queryMulti/erasValidatorRewardMulti.ts +++ b/packages/app/src/api/queryMulti/erasValidatorRewardMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ErasValidatorRewardMulti extends Base { - #eras: [number][]; + #eras: [number][] constructor(network: ChainId, eras: [number][]) { - super(network); - this.#eras = eras; + super(network) + this.#eras = eras } async fetch() { @@ -20,12 +20,12 @@ export class ErasValidatorRewardMulti extends Base { { at: 'best', } - ); - return results; + ) + return results } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/queryMulti/identityOfMulti.ts b/packages/app/src/api/queryMulti/identityOfMulti.ts index 85055cd79b..43b9bd6932 100644 --- a/packages/app/src/api/queryMulti/identityOfMulti.ts +++ b/packages/app/src/api/queryMulti/identityOfMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class IdentityOfMulti extends Base { - #addresses: [string][]; + #addresses: [string][] constructor(network: ChainId, addresses: [string][]) { - super(network); - this.#addresses = addresses; + super(network) + this.#addresses = addresses } async fetch() { @@ -19,12 +19,12 @@ export class IdentityOfMulti extends Base { { at: 'best', } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return null; + return null } } diff --git a/packages/app/src/api/queryMulti/nominatorsMulti.ts b/packages/app/src/api/queryMulti/nominatorsMulti.ts index 0bed485fc5..f87fa549b2 100644 --- a/packages/app/src/api/queryMulti/nominatorsMulti.ts +++ b/packages/app/src/api/queryMulti/nominatorsMulti.ts @@ -1,39 +1,39 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class NominatorsMulti extends Base { - #addresses: [string][]; + #addresses: [string][] constructor(network: ChainId, addresses: [string][]) { - super(network); - this.#addresses = addresses; + super(network) + this.#addresses = addresses } async fetch() { - let result; + let result try { result = await this.unsafeApi.query.Staking.Nominators.getValues( this.#addresses, { at: 'best' } - ); + ) return result.map((nominator) => { if (!nominator) { - return undefined; + return undefined } return { submittedIn: String(nominator.submitted_in), suppressed: nominator.suppressed, targets: nominator.targets, - }; - }); + } + }) } catch (e) { // Silently fail. } - return null; + return null } } diff --git a/packages/app/src/api/queryMulti/poolMetadataMulti.ts b/packages/app/src/api/queryMulti/poolMetadataMulti.ts index 144f2e61dd..3a7c6d8678 100644 --- a/packages/app/src/api/queryMulti/poolMetadataMulti.ts +++ b/packages/app/src/api/queryMulti/poolMetadataMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolMetadataMulti extends Base { - #ids: [number][]; + #ids: [number][] constructor(network: ChainId, ids: [number][]) { - super(network); - this.#ids = ids; + super(network) + this.#ids = ids } async fetch() { @@ -18,12 +18,12 @@ export class PoolMetadataMulti extends Base { await this.unsafeApi.query.NominationPools.Metadata.getValues( this.#ids, { at: 'best' } - ); - return result.map((metadata) => metadata.asText()); + ) + return result.map((metadata) => metadata.asText()) } catch (e) { // Silently fail. } - return []; + return [] } } diff --git a/packages/app/src/api/queryMulti/superOfMulti.ts b/packages/app/src/api/queryMulti/superOfMulti.ts index cb31a74b52..91b4b30ecf 100644 --- a/packages/app/src/api/queryMulti/superOfMulti.ts +++ b/packages/app/src/api/queryMulti/superOfMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class SuperOfMulti extends Base { - #addresses: [string][]; + #addresses: [string][] constructor(network: ChainId, addresses: [string][]) { - super(network); - this.#addresses = addresses; + super(network) + this.#addresses = addresses } async fetch() { @@ -17,12 +17,12 @@ export class SuperOfMulti extends Base { const result = await this.unsafeApi.query.Identity.SuperOf.getValues( this.#addresses, { at: 'best' } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return null; + return null } } diff --git a/packages/app/src/api/queryMulti/validatorsMulti.ts b/packages/app/src/api/queryMulti/validatorsMulti.ts index 0907f9f869..4f36b4c62f 100644 --- a/packages/app/src/api/queryMulti/validatorsMulti.ts +++ b/packages/app/src/api/queryMulti/validatorsMulti.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class ValidatorsMulti extends Base { - #addresses: [string][]; + #addresses: [string][] constructor(network: ChainId, addresses: [string][]) { - super(network); - this.#addresses = addresses; + super(network) + this.#addresses = addresses } async fetch() { @@ -17,12 +17,12 @@ export class ValidatorsMulti extends Base { const result = await this.unsafeApi.query.Staking.Validators.getValues( this.#addresses, { at: 'best' } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return null; + return null } } diff --git a/packages/app/src/api/runtimeApi/poolPendingRewards.ts b/packages/app/src/api/runtimeApi/poolPendingRewards.ts index a07ddc7fb4..d922f7931e 100644 --- a/packages/app/src/api/runtimeApi/poolPendingRewards.ts +++ b/packages/app/src/api/runtimeApi/poolPendingRewards.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolPendingRewards extends Base { - #who: string; + #who: string constructor(network: ChainId, who: string) { - super(network); - this.#who = who; + super(network) + this.#who = who } async fetch() { @@ -20,11 +20,11 @@ export class PoolPendingRewards extends Base { { at: 'best', } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return undefined; + return undefined } } diff --git a/packages/app/src/api/runtimeApi/poolPointsToBalance.ts b/packages/app/src/api/runtimeApi/poolPointsToBalance.ts index 2580a48db4..614882d0be 100644 --- a/packages/app/src/api/runtimeApi/poolPointsToBalance.ts +++ b/packages/app/src/api/runtimeApi/poolPointsToBalance.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolPointsToBalance extends Base { - #poolId: number; - #points: bigint; + #poolId: number + #points: bigint constructor(network: ChainId, poolId: number, points: bigint) { - super(network); - this.#poolId = poolId; - this.#points = points; + super(network) + this.#poolId = poolId + this.#points = points } async fetch() { @@ -21,11 +21,11 @@ export class PoolPointsToBalance extends Base { this.#poolId, this.#points, { at: 'best' } - ); - return result; + ) + return result } catch (e) { // Silently fail. } - return undefined; + return undefined } } diff --git a/packages/app/src/api/subscribe/accountBalances/index.ts b/packages/app/src/api/subscribe/accountBalances/index.ts index 7b700709c9..35fb90b225 100644 --- a/packages/app/src/api/subscribe/accountBalances/index.ts +++ b/packages/app/src/api/subscribe/accountBalances/index.ts @@ -1,56 +1,56 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import BigNumber from 'bignumber.js'; -import type { AnyApi, NetworkId } from 'common-types'; -import type { Balances as IBalances, Ledger } from 'contexts/Balances/types'; -import type { PoolMembership } from 'contexts/Pools/types'; -import type { PayeeConfig } from 'contexts/Setup/types'; -import { Apis } from 'controllers/Apis'; -import { Balances } from 'controllers/Balances'; -import { defaultNominations } from 'controllers/Balances/defaults'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { UnsafeApi } from 'polkadot-api'; -import type { Subscription } from 'rxjs'; -import { combineLatest } from 'rxjs'; -import type { Nominations } from 'types'; -import { stringToBn } from 'utils'; +import BigNumber from 'bignumber.js' +import type { AnyApi, NetworkId } from 'common-types' +import type { Balances as IBalances, Ledger } from 'contexts/Balances/types' +import type { PoolMembership } from 'contexts/Pools/types' +import type { PayeeConfig } from 'contexts/Setup/types' +import { Apis } from 'controllers/Apis' +import { Balances } from 'controllers/Balances' +import { defaultNominations } from 'controllers/Balances/defaults' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { UnsafeApi } from 'polkadot-api' +import type { Subscription } from 'rxjs' +import { combineLatest } from 'rxjs' +import type { Nominations } from 'types' +import { stringToBn } from 'utils' export class AccountBalances implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // Active subscription. - #sub: Subscription; + #sub: Subscription // Account to subscribe to. - #address: string; + #address: string // Account ledger. - ledger: Ledger | undefined; + ledger: Ledger | undefined // Account balances. - balance: IBalances; + balance: IBalances // Payee config. - payee: PayeeConfig | undefined; + payee: PayeeConfig | undefined // Pool membership. - poolMembership: PoolMembership | undefined; + poolMembership: PoolMembership | undefined // Account nominations. - nominations: Nominations; + nominations: Nominations constructor(network: NetworkId, address: string) { - this.#network = network; - this.#address = address; - this.subscribe(); + this.#network = network + this.#address = address + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); - const bestOrFinalized = 'best'; + const api = Apis.getApi(this.#network) + const bestOrFinalized = 'best' if (api && this.#sub === undefined) { const sub = combineLatest([ @@ -80,12 +80,12 @@ export class AccountBalances implements Unsubscribable { claimPermissions, nominators, ]) => { - this.handleLedger(ledger); - this.handleAccount(account, locks); - this.handlePayee(payee); + this.handleLedger(ledger) + this.handleAccount(account, locks) + this.handlePayee(payee) - await this.handlePoolMembership(api, poolMembers, claimPermissions); - this.handleNominations(nominators); + await this.handlePoolMembership(api, poolMembers, claimPermissions) + this.handleNominations(nominators) // Send updated account state back to UI. const accountBalance = { @@ -95,28 +95,28 @@ export class AccountBalances implements Unsubscribable { payee: this.payee, poolMembership: this.poolMembership, nominations: this.nominations, - }; + } document.dispatchEvent( new CustomEvent('new-account-balance', { detail: accountBalance }) - ); + ) } - ); + ) - this.#sub = sub; + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Handle ledger result. handleLedger = (ledger: AnyApi): void => { // If ledger is null, remove from class. if (!ledger) { - this.ledger = undefined; + this.ledger = undefined } else { - const { stash, total, active, unlocking } = ledger; + const { stash, total, active, unlocking } = ledger // Send stash address to UI as event if not presently imported. if (!Balances.accounts.includes(stash.toString())) { @@ -124,7 +124,7 @@ export class AccountBalances implements Unsubscribable { new CustomEvent('new-external-account', { detail: { address: stash.toString() }, }) - ); + ) } this.ledger = { @@ -137,9 +137,9 @@ export class AccountBalances implements Unsubscribable { value: stringToBn(value.toString()), }) ), - }; + } } - }; + } // Handle account callback. handleAccount = ( @@ -157,20 +157,20 @@ export class AccountBalances implements Unsubscribable { id: lock.id.asText().trim(), amount: stringToBn(lock.amount.toString()), })), - }; - }; + } + } // Handle payee callback. handlePayee = (result: AnyApi): void => { if (result === undefined) { - this.payee = undefined; + this.payee = undefined } else { this.payee = { destination: result.type || null, account: result.value || undefined, - }; + } } - }; + } // Handle pool membership and claim commission callback. handlePoolMembership = async ( @@ -182,22 +182,22 @@ export class AccountBalances implements Unsubscribable { // This skips claim permission data as well as user would not have claim permissions if they are // not in a pool. if (!poolMembers) { - this.poolMembership = undefined; - return; + this.poolMembership = undefined + return } const unlocking = poolMembers?.unbonding_eras.map(([e, v]: AnyApi) => ({ era: e, value: new BigNumber((v as bigint).toString()), - })); + })) const apiResult = await api.apis.NominationPoolsApi.points_to_balance( poolMembers.pool_id, poolMembers.points, { at: 'best' } - ); - const balance = new BigNumber(apiResult?.toString() || 0); - const claimPermission = claimPermissionResult?.type || 'Permissioned'; + ) + const balance = new BigNumber(apiResult?.toString() || 0) + const claimPermission = claimPermissionResult?.type || 'Permissioned' this.poolMembership = { address: this.#address, @@ -209,8 +209,8 @@ export class AccountBalances implements Unsubscribable { unbondingEras: unlocking, // NOTE: This is a duplicate of `unlocking`. claimPermission, unlocking, - }; - }; + } + } // Handle nominations callback. handleNominations = (nominators: AnyApi): void => { @@ -219,13 +219,13 @@ export class AccountBalances implements Unsubscribable { : { targets: nominators.targets, submittedIn: nominators.submitted_in, - }; - }; + } + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/accountProxies/index.ts b/packages/app/src/api/subscribe/accountProxies/index.ts index f8d444ce3a..c0d40a210e 100644 --- a/packages/app/src/api/subscribe/accountProxies/index.ts +++ b/packages/app/src/api/subscribe/accountProxies/index.ts @@ -1,36 +1,36 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { AnyApi, NetworkId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; +import type { AnyApi, NetworkId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' export class AccountProxies implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // The proxy delegator address. - #address: string; + #address: string // The bonded address. - proxies: AnyApi; + proxies: AnyApi // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId, address: string) { - this.#network = network; - this.#address = address; - this.subscribe(); + this.#network = network + this.#address = address + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const unsub = api.query.Proxy.Proxies.watchValue( this.#address, bestOrFinalized @@ -39,19 +39,19 @@ export class AccountProxies implements Unsubscribable { new CustomEvent('new-account-proxies', { detail: { address: this.#address, proxies }, }) - ); - }); - this.#sub = unsub; + ) + }) + this.#sub = unsub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/accountProxies/types.ts b/packages/app/src/api/subscribe/accountProxies/types.ts index 3e2f791555..b42f4c5a2b 100644 --- a/packages/app/src/api/subscribe/accountProxies/types.ts +++ b/packages/app/src/api/subscribe/accountProxies/types.ts @@ -3,17 +3,17 @@ export type AccountProxy = [ { - delay: number; - delegate: string; + delay: number + delegate: string proxy_type: { - type: string; - value: undefined; - }; + type: string + value: undefined + } }[], bigint, -]; +] export interface AccountProxiesEvent { - address: string; - proxies: AccountProxy; + address: string + proxies: AccountProxy } diff --git a/packages/app/src/api/subscribe/activeEra/index.ts b/packages/app/src/api/subscribe/activeEra/index.ts index 1803c33377..23ddaf6875 100644 --- a/packages/app/src/api/subscribe/activeEra/index.ts +++ b/packages/app/src/api/subscribe/activeEra/index.ts @@ -1,38 +1,38 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import BigNumber from 'bignumber.js'; -import type { NetworkId } from 'common-types'; -import { defaultActiveEra } from 'contexts/Api/defaults'; -import type { APIActiveEra } from 'contexts/Api/types'; -import { Apis } from 'controllers/Apis'; -import { Subscriptions } from 'controllers/Subscriptions'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; -import { StakingMetrics } from '../stakingMetrics'; +import BigNumber from 'bignumber.js' +import type { NetworkId } from 'common-types' +import { defaultActiveEra } from 'contexts/Api/defaults' +import type { APIActiveEra } from 'contexts/Api/types' +import { Apis } from 'controllers/Apis' +import { Subscriptions } from 'controllers/Subscriptions' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' +import { StakingMetrics } from '../stakingMetrics' export class ActiveEra implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // Active subscription. - #sub: Subscription; + #sub: Subscription // Store the active era. - activeEra: APIActiveEra = defaultActiveEra; + activeEra: APIActiveEra = defaultActiveEra constructor(network: NetworkId) { - this.#network = network; - this.subscribe(); + this.#network = network + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { // Testing the active era subscription. - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const sub = api.query.Staking.ActiveEra.watchValue( bestOrFinalized ).subscribe((activeEra) => { @@ -40,17 +40,17 @@ export class ActiveEra implements Unsubscribable { this.activeEra = { index: new BigNumber(activeEra?.index.toString() || 0), start: new BigNumber(activeEra?.start?.toString() || 0), - }; + } // Unsubscribe to staking metrics if it exists. const subStakingMetrics = Subscriptions.get( this.#network, 'stakingMetrics' - ); + ) if (subStakingMetrics) { - subStakingMetrics.subscribe(); - Subscriptions.remove(this.#network, 'stakingMetrics'); + subStakingMetrics.subscribe() + Subscriptions.remove(this.#network, 'stakingMetrics') } // Subscribe to staking metrics with new active era. @@ -62,25 +62,25 @@ export class ActiveEra implements Unsubscribable { this.activeEra, BigNumber.max(0, this.activeEra.index.minus(1)) ) - ); + ) document.dispatchEvent( new CustomEvent('new-active-era', { detail: { activeEra }, }) - ); - }); - this.#sub = sub; + ) + }) + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/activePoolAccount/index.ts b/packages/app/src/api/subscribe/activePoolAccount/index.ts index 5a74204070..6fe35d2e06 100644 --- a/packages/app/src/api/subscribe/activePoolAccount/index.ts +++ b/packages/app/src/api/subscribe/activePoolAccount/index.ts @@ -1,46 +1,46 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { PoolPendingRewards } from 'api/runtimeApi/poolPendingRewards'; -import type { AnyApi, ChainId, SystemChainId } from 'common-types'; -import { defaultPoolNominations } from 'contexts/Pools/ActivePool/defaults'; -import { Apis } from 'controllers/Apis'; -import { Identities } from 'controllers/Identities'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import { combineLatest, type Subscription } from 'rxjs'; -import type { ActivePool, ActivePoolItem, Nominations, PoolRoles } from 'types'; +import { PoolPendingRewards } from 'api/runtimeApi/poolPendingRewards' +import type { AnyApi, ChainId, SystemChainId } from 'common-types' +import { defaultPoolNominations } from 'contexts/Pools/ActivePool/defaults' +import { Apis } from 'controllers/Apis' +import { Identities } from 'controllers/Identities' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import { combineLatest, type Subscription } from 'rxjs' +import type { ActivePool, ActivePoolItem, Nominations, PoolRoles } from 'types' export class ActivePoolAccount implements Unsubscribable { // The associated network for this instance. - #network: ChainId; + #network: ChainId // Active subscription. - #sub: Subscription; + #sub: Subscription // Active pool item - pool: ActivePoolItem; + pool: ActivePoolItem // Address associated with this pool. - address: string; + address: string // Active pool of the address. - activePool: ActivePool | null; + activePool: ActivePool | null // Active pool nominations. - poolNominations: Nominations; + poolNominations: Nominations constructor(network: ChainId, address: string, pool: ActivePoolItem) { - this.#network = network; - this.pool = pool; - this.address = address; - this.subscribe(); + this.#network = network + this.pool = pool + this.address = address + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); - const peopleApiId = `people-${this.#network}` as SystemChainId; - const bestOrFinalized = 'best'; + const api = Apis.getApi(this.#network) + const peopleApiId = `people-${this.#network}` as SystemChainId + const bestOrFinalized = 'best' const sub = combineLatest([ api.query.NominationPools.BondedPools.watchValue( @@ -65,8 +65,8 @@ export class ActivePoolAccount implements Unsubscribable { bondedPool, rewardPool, account - ); - this.handleNominatorsCallback(nominators); + ) + this.handleNominatorsCallback(nominators) if (this.activePool && this.poolNominations) { document.dispatchEvent( @@ -77,15 +77,15 @@ export class ActivePoolAccount implements Unsubscribable { nominations: this.poolNominations, }, }) - ); + ) } - }); + }) - this.#sub = sub; + this.#sub = sub } catch (e) { // Subscription failed. } - }; + } // Handle active pool callback. handleActivePoolCallback = async ( @@ -94,15 +94,15 @@ export class ActivePoolAccount implements Unsubscribable { rewardPool: AnyApi, account: AnyApi ): Promise => { - const balance = account.data; - const rewardAccountBalance = balance?.free.toString(); + const balance = account.data + const rewardAccountBalance = balance?.free.toString() if (Apis.getClient(peopleApiId)) { // Fetch identities for roles and expand `bondedPool` state to store them. bondedPool.roleIdentities = await Identities.fetch( peopleApiId, this.getUniqueRoleAddresses(bondedPool.roles) - ); + ) } const bondedPoolFormatted = { @@ -111,7 +111,7 @@ export class ActivePoolAccount implements Unsubscribable { roles: bondedPool.roles, roleIdentities: bondedPool.roleIdentities, state: bondedPool.state.type, - }; + } const rewardPoolFormatted = { lastRecordedRewardCounter: @@ -121,10 +121,10 @@ export class ActivePoolAccount implements Unsubscribable { totalCommissionClaimed: rewardPool.total_commission_claimed.toString(), totalCommissionPending: rewardPool.total_commission_pending.toString(), totalRewardsClaimed: rewardPool.total_rewards_claimed.toString(), - }; + } const pendingRewards = - (await new PoolPendingRewards(this.#network, this.address).fetch()) || 0n; + (await new PoolPendingRewards(this.#network, this.address).fetch()) || 0n // Only persist the active pool to class state (and therefore dispatch an event) if both the // bonded pool and reward pool are returned. @@ -136,14 +136,14 @@ export class ActivePoolAccount implements Unsubscribable { rewardPool: rewardPoolFormatted, rewardAccountBalance, pendingRewards, - }; + } - this.activePool = newPool; + this.activePool = newPool } else { // Invalid pools were returned. To signal pool was synced, set active pool to `null`. - this.activePool = null; + this.activePool = null } - }; + } // Handle nominators callback. handleNominatorsCallback = (nominators: AnyApi): void => { @@ -152,22 +152,22 @@ export class ActivePoolAccount implements Unsubscribable { : { targets: nominators.targets, submittedIn: nominators.submitted_in, - }; - this.poolNominations = newNominations; - }; + } + this.poolNominations = newNominations + } // Gets unique role addresses from a bonded pool's `roles` record. getUniqueRoleAddresses = (roles: PoolRoles): string[] => { const roleAddresses: string[] = [ ...new Set(Object.values(roles).filter((role) => role !== undefined)), - ]; - return roleAddresses; - }; + ] + return roleAddresses + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/blockNumber/index.ts b/packages/app/src/api/subscribe/blockNumber/index.ts index 17e2e5c3ac..b960806f8c 100644 --- a/packages/app/src/api/subscribe/blockNumber/index.ts +++ b/packages/app/src/api/subscribe/blockNumber/index.ts @@ -1,32 +1,32 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { NetworkId } from 'common-types'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; +import { Base } from 'api/base' +import type { NetworkId } from 'common-types' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' export class BlockNumber extends Base implements Unsubscribable { // The current block number. - blockNumber = '0'; + blockNumber = '0' // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId) { - super(network); - this.subscribe(); + super(network) + this.subscribe() } subscribe = async (): Promise => { try { if (this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const unsub = this.unsafeApi.query.System.Number.watchValue( bestOrFinalized ).subscribe((num) => { // Update class block number. - this.blockNumber = num.toString(); + this.blockNumber = num.toString() // Send block number to UI. document.dispatchEvent( @@ -35,19 +35,19 @@ export class BlockNumber extends Base implements Unsubscribable { blockNumber: num.toString(), }, }) - ); - }); - this.#sub = unsub; + ) + }) + this.#sub = unsub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/blockNumber/types.ts b/packages/app/src/api/subscribe/blockNumber/types.ts index 962c00ea23..38b314359f 100644 --- a/packages/app/src/api/subscribe/blockNumber/types.ts +++ b/packages/app/src/api/subscribe/blockNumber/types.ts @@ -2,5 +2,5 @@ // SPDX-License-Identifier: GPL-3.0-only export interface BlockNumberEventDetail { - blockNumber: number; + blockNumber: number } diff --git a/packages/app/src/api/subscribe/bonded/index.tsx b/packages/app/src/api/subscribe/bonded/index.tsx index d052692fbb..476f4fc536 100644 --- a/packages/app/src/api/subscribe/bonded/index.tsx +++ b/packages/app/src/api/subscribe/bonded/index.tsx @@ -1,37 +1,37 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { NetworkId } from 'common-types'; -import type { BondedAccount } from 'contexts/Bonded/types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; +import type { NetworkId } from 'common-types' +import type { BondedAccount } from 'contexts/Bonded/types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' export class Bonded implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // The stash address. - #address: string; + #address: string // The bonded address. - bonded: string; + bonded: string // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId, address: string) { - this.#network = network; - this.#address = address; - this.subscribe(); + this.#network = network + this.#address = address + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const unsub = api.query.Staking.Bonded.watchValue( this.#address, bestOrFinalized @@ -39,7 +39,7 @@ export class Bonded implements Unsubscribable { const account: BondedAccount = { address: this.#address, bonded: controller || undefined, - }; + } // Send bonded account to UI. document.dispatchEvent( @@ -48,19 +48,19 @@ export class Bonded implements Unsubscribable { account, }, }) - ); - }); - this.#sub = unsub; + ) + }) + this.#sub = unsub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/fastUnstakeConfig/index.ts b/packages/app/src/api/subscribe/fastUnstakeConfig/index.ts index e95b241edf..2626d36414 100644 --- a/packages/app/src/api/subscribe/fastUnstakeConfig/index.ts +++ b/packages/app/src/api/subscribe/fastUnstakeConfig/index.ts @@ -1,33 +1,33 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { NetworkId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; -import { combineLatest } from 'rxjs'; -import type { FastUnstakeConfigResult } from './types'; +import type { NetworkId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' +import { combineLatest } from 'rxjs' +import type { FastUnstakeConfigResult } from './types' export class FastUnstakeConfig implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // Active subscription. - #sub: Subscription; + #sub: Subscription - config: FastUnstakeConfigResult; + config: FastUnstakeConfigResult constructor(network: NetworkId) { - this.#network = network; - this.subscribe(); + this.#network = network + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const sub = combineLatest([ api.query.FastUnstake.Head.watchValue(bestOrFinalized), @@ -39,28 +39,28 @@ export class FastUnstakeConfig implements Unsubscribable { checked: [], }, counterForQueue, - }; + } - this.config = config; + this.config = config document.dispatchEvent( new CustomEvent('new-fast-unstake-config', { detail: { ...config }, }) - ); - }); + ) + }) - this.#sub = sub; + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/fastUnstakeConfig/types.ts b/packages/app/src/api/subscribe/fastUnstakeConfig/types.ts index 8d64f3c59f..90e944e35b 100644 --- a/packages/app/src/api/subscribe/fastUnstakeConfig/types.ts +++ b/packages/app/src/api/subscribe/fastUnstakeConfig/types.ts @@ -2,11 +2,11 @@ // SPDX-License-Identifier: GPL-3.0-only export interface FastUnstakeConfigResult { - head: FastUnstakeHead; - counterForQueue: number; + head: FastUnstakeHead + counterForQueue: number } export interface FastUnstakeHead { - stashes: [string, bigint][]; - checked: number[]; + stashes: [string, bigint][] + checked: number[] } diff --git a/packages/app/src/api/subscribe/fastUnstakeQueue/index.ts b/packages/app/src/api/subscribe/fastUnstakeQueue/index.ts index 3667849ddf..3f2364a956 100644 --- a/packages/app/src/api/subscribe/fastUnstakeQueue/index.ts +++ b/packages/app/src/api/subscribe/fastUnstakeQueue/index.ts @@ -1,41 +1,41 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { NetworkId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; +import type { NetworkId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' export class FastUnstakeQueue implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // The depositor address. - #address: string; + #address: string // The deposit. - queue: bigint; + queue: bigint // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId, address: string) { - this.#network = network; - this.#address = address; - this.subscribe(); + this.#network = network + this.#address = address + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const unsub = api.query.FastUnstake.Queue.watchValue( this.#address, bestOrFinalized ).subscribe((queue) => { - this.queue = queue || 0n; + this.queue = queue || 0n document.dispatchEvent( new CustomEvent('new-fast-unstake-deposit', { @@ -44,19 +44,19 @@ export class FastUnstakeQueue implements Unsubscribable { deposit: queue || 0n, }, }) - ); - }); - this.#sub = unsub; + ) + }) + this.#sub = unsub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/networkMetrics/index.ts b/packages/app/src/api/subscribe/networkMetrics/index.ts index e86c21c54a..a26363a49f 100644 --- a/packages/app/src/api/subscribe/networkMetrics/index.ts +++ b/packages/app/src/api/subscribe/networkMetrics/index.ts @@ -1,31 +1,31 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import BigNumber from 'bignumber.js'; -import type { NetworkId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; -import { combineLatest } from 'rxjs'; +import BigNumber from 'bignumber.js' +import type { NetworkId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' +import { combineLatest } from 'rxjs' export class NetworkMetrics implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId) { - this.#network = network; - this.subscribe(); + this.#network = network + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const sub = combineLatest([ api.query.Balances.TotalIssuance.watchValue(bestOrFinalized), api.query.Auctions.AuctionCounter.watchValue(bestOrFinalized), @@ -48,27 +48,27 @@ export class NetworkMetrics implements Unsubscribable { earliestStoredSession: new BigNumber(earliestStoredSession), fastUnstakeErasToCheckPerBlock: Number(erasToCheckPerBlock), minimumActiveStake: new BigNumber(minimumActiveStake.toString()), - }; + } document.dispatchEvent( new CustomEvent('new-network-metrics', { detail: { networkMetrics }, }) - ); + ) } - ); + ) - this.#sub = sub; + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/poolMembers/index.ts b/packages/app/src/api/subscribe/poolMembers/index.ts index 3fbeb00bad..7fa8b8060a 100644 --- a/packages/app/src/api/subscribe/poolMembers/index.ts +++ b/packages/app/src/api/subscribe/poolMembers/index.ts @@ -1,36 +1,36 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { AnyApi, NetworkId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import { combineLatest, type Subscription } from 'rxjs'; -import type { PoolMemberBatchEvent } from './types'; +import type { AnyApi, NetworkId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import { combineLatest, type Subscription } from 'rxjs' +import type { PoolMemberBatchEvent } from './types' export class PoolMembers implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // The batch key. - #key: string; - #addresses: string[]; - result: AnyApi; + #key: string + #addresses: string[] + result: AnyApi // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId, key: string, addresses: string[]) { - this.#network = network; - this.#key = key; - this.#addresses = addresses; - this.subscribe(); + this.#network = network + this.#key = key + this.#addresses = addresses + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const sub = combineLatest( this.#addresses.map((address) => @@ -43,7 +43,7 @@ export class PoolMembers implements Unsubscribable { const formatted = results .map((result) => { if (!result) { - return undefined; + return undefined } return { @@ -59,34 +59,34 @@ export class PoolMembers implements Unsubscribable { ] ) ), - }; + } }) - .filter((result) => result !== undefined); + .filter((result) => result !== undefined) const detail: PoolMemberBatchEvent = { key: this.#key, addresses: this.#addresses, poolMembers: formatted, - }; + } document.dispatchEvent( new CustomEvent('new-pool-members-batch', { detail, }) - ); - }); + ) + }) - this.#sub = sub; + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/poolMembers/types.ts b/packages/app/src/api/subscribe/poolMembers/types.ts index ed7b855149..4f6e6d6926 100644 --- a/packages/app/src/api/subscribe/poolMembers/types.ts +++ b/packages/app/src/api/subscribe/poolMembers/types.ts @@ -2,14 +2,14 @@ // SPDX-License-Identifier: GPL-3.0-only export interface PoolMemberBatchEvent { - key: string; - addresses: string[]; + key: string + addresses: string[] poolMembers: Record< number, { - poolId: string; - points: string; - unbondingEras: Record; + poolId: string + points: string + unbondingEras: Record } - >; + > } diff --git a/packages/app/src/api/subscribe/poolsConfig/index.ts b/packages/app/src/api/subscribe/poolsConfig/index.ts index 688fb8b73d..3d3ef6dcb5 100644 --- a/packages/app/src/api/subscribe/poolsConfig/index.ts +++ b/packages/app/src/api/subscribe/poolsConfig/index.ts @@ -1,34 +1,34 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import BigNumber from 'bignumber.js'; -import type { NetworkId } from 'common-types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; -import { combineLatest } from 'rxjs'; -import { stringToBn } from 'utils'; +import BigNumber from 'bignumber.js' +import type { NetworkId } from 'common-types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' +import { combineLatest } from 'rxjs' +import { stringToBn } from 'utils' export class PoolsConfig implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId // Active subscription. - #sub: Subscription; + #sub: Subscription constructor(network: NetworkId) { - this.#network = network; + this.#network = network // Subscribe immediately. - this.subscribe(); + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const sub = combineLatest([ api.query.NominationPools.CounterForPoolMembers.watchValue( bestOrFinalized @@ -66,22 +66,22 @@ export class PoolsConfig implements Unsubscribable { // Format globalMaxCommission from a perbill to a percent. const globalMaxCommissionAsPercent = globalMaxCommission ? BigInt(globalMaxCommission) / 1000000n - : 100n; + : 100n // Format max pool members to be a BigNumber, or null if it's not set. const maxPoolMembers = maxPoolMembersRaw ? new BigNumber(maxPoolMembersRaw.toString()) - : null; + : null // Format max pool members per pool to be a BigNumber, or null if it's not set. const maxPoolMembersPerPool = maxPoolMembersPerPoolRaw ? new BigNumber(maxPoolMembersPerPoolRaw.toString()) - : null; + : null // Format max pools to be a BigNumber, or null if it's not set. const maxPools = maxPoolsRaw ? new BigNumber(maxPoolsRaw.toString()) - : null; + : null const poolsConfig = { counterForPoolMembers: stringToBn( @@ -102,26 +102,26 @@ export class PoolsConfig implements Unsubscribable { globalMaxCommission: Number( globalMaxCommissionAsPercent.toString() ), - }; + } document.dispatchEvent( new CustomEvent('new-pools-config', { detail: { poolsConfig }, }) - ); + ) } - ); - this.#sub = sub; + ) + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/subscribe/stakingMetrics/index.ts b/packages/app/src/api/subscribe/stakingMetrics/index.ts index 7d7e255528..f709c915a4 100644 --- a/packages/app/src/api/subscribe/stakingMetrics/index.ts +++ b/packages/app/src/api/subscribe/stakingMetrics/index.ts @@ -1,45 +1,45 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type BigNumber from 'bignumber.js'; -import type { NetworkId } from 'common-types'; -import type { APIActiveEra } from 'contexts/Api/types'; -import { Apis } from 'controllers/Apis'; -import type { Unsubscribable } from 'controllers/Subscriptions/types'; -import type { Subscription } from 'rxjs'; -import { combineLatest } from 'rxjs'; -import { stringToBn } from 'utils'; +import type BigNumber from 'bignumber.js' +import type { NetworkId } from 'common-types' +import type { APIActiveEra } from 'contexts/Api/types' +import { Apis } from 'controllers/Apis' +import type { Unsubscribable } from 'controllers/Subscriptions/types' +import type { Subscription } from 'rxjs' +import { combineLatest } from 'rxjs' +import { stringToBn } from 'utils' export class StakingMetrics implements Unsubscribable { // The associated network for this instance. - #network: NetworkId; + #network: NetworkId - #activeEra: APIActiveEra; + #activeEra: APIActiveEra - #previousEra: BigNumber; + #previousEra: BigNumber // Active subscription. - #sub: Subscription; + #sub: Subscription constructor( network: NetworkId, activeEra: APIActiveEra, previousEra: BigNumber ) { - this.#network = network; - this.#activeEra = activeEra; - this.#previousEra = previousEra; + this.#network = network + this.#activeEra = activeEra + this.#previousEra = previousEra // Subscribe immediately. - this.subscribe(); + this.subscribe() } subscribe = async (): Promise => { try { - const api = Apis.getApi(this.#network); + const api = Apis.getApi(this.#network) if (api && this.#sub === undefined) { - const bestOrFinalized = 'best'; + const bestOrFinalized = 'best' const sub = combineLatest([ api.query.Staking.CounterForValidators.watchValue(bestOrFinalized), api.query.Staking.MaxValidatorsCount.watchValue(bestOrFinalized), @@ -80,26 +80,26 @@ export class StakingMetrics implements Unsubscribable { minNominatorBond: stringToBn(minNominatorBond.toString()), totalStaked: stringToBn(totalStaked.toString()), counterForNominators: stringToBn(counterForNominators.toString()), - }; + } document.dispatchEvent( new CustomEvent('new-staking-metrics', { detail: { stakingMetrics }, }) - ); + ) } - ); - this.#sub = sub; + ) + this.#sub = sub } } catch (e) { // Subscription failed. } - }; + } // Unsubscribe from class subscription. unsubscribe = (): void => { if (typeof this.#sub?.unsubscribe === 'function') { - this.#sub.unsubscribe(); + this.#sub.unsubscribe() } - }; + } } diff --git a/packages/app/src/api/tx/createPool.ts b/packages/app/src/api/tx/createPool.ts index 1c0caad6a8..fde29aa050 100644 --- a/packages/app/src/api/tx/createPool.ts +++ b/packages/app/src/api/tx/createPool.ts @@ -1,18 +1,18 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import { Binary } from 'polkadot-api'; -import type { PoolRoles } from 'types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import { Binary } from 'polkadot-api' +import type { PoolRoles } from 'types' export class CreatePool extends Base { - #from: string; - #poolId: number; - #bond: bigint; - #metadata: string; - #nominees: string[]; - #roles?: PoolRoles | null; + #from: string + #poolId: number + #bond: bigint + #metadata: string + #nominees: string[] + #roles?: PoolRoles | null constructor( network: ChainId, @@ -23,19 +23,19 @@ export class CreatePool extends Base { nominees: string[], roles: PoolRoles | null ) { - super(network); - this.#from = from; - this.#poolId = poolId; - this.#bond = bond; - this.#metadata = metadata; - this.#nominees = nominees; - this.#roles = roles; + super(network) + this.#from = from + this.#poolId = poolId + this.#bond = bond + this.#metadata = metadata + this.#nominees = nominees + this.#roles = roles } tx() { - const root = this.#roles?.root || this.#from; - const nominator = this.#roles?.nominator || this.#from; - const bouncer = this.#roles?.bouncer || this.#from; + const root = this.#roles?.root || this.#from + const nominator = this.#roles?.nominator || this.#from + const bouncer = this.#roles?.bouncer || this.#from try { return [ @@ -63,9 +63,9 @@ export class CreatePool extends Base { pool_id: this.#poolId, metadata: Binary.fromText(this.#metadata), }), - ]; + ] } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/fastUnstakeDeregister.ts b/packages/app/src/api/tx/fastUnstakeDeregister.ts index 7fa3800448..487a303a72 100644 --- a/packages/app/src/api/tx/fastUnstakeDeregister.ts +++ b/packages/app/src/api/tx/fastUnstakeDeregister.ts @@ -1,19 +1,19 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class FastUnstakeDeregister extends Base { constructor(network: ChainId) { - super(network); + super(network) } tx() { try { - return this.unsafeApi.tx.FastUnstake.deregister(); + return this.unsafeApi.tx.FastUnstake.deregister() } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/fastUnstakeRegister.ts b/packages/app/src/api/tx/fastUnstakeRegister.ts index 0bfbaf1e1e..72d6054011 100644 --- a/packages/app/src/api/tx/fastUnstakeRegister.ts +++ b/packages/app/src/api/tx/fastUnstakeRegister.ts @@ -1,19 +1,19 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class FastUnstakeRegister extends Base { constructor(network: ChainId) { - super(network); + super(network) } tx() { try { - return this.unsafeApi.tx.FastUnstake.register_fast_unstake(); + return this.unsafeApi.tx.FastUnstake.register_fast_unstake() } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/joinPool.ts b/packages/app/src/api/tx/joinPool.ts index 4f494a2c8f..ca3facd8b5 100644 --- a/packages/app/src/api/tx/joinPool.ts +++ b/packages/app/src/api/tx/joinPool.ts @@ -1,15 +1,15 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { ClaimPermission } from 'contexts/Pools/types'; -import { defaultClaimPermission } from 'controllers/ActivePools/defaults'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { ClaimPermission } from 'contexts/Pools/types' +import { defaultClaimPermission } from 'controllers/ActivePools/defaults' export class JoinPool extends Base { - #poolId: number; - #bond: bigint; - #claimPermission: ClaimPermission; + #poolId: number + #bond: bigint + #claimPermission: ClaimPermission constructor( network: ChainId, @@ -17,10 +17,10 @@ export class JoinPool extends Base { bond: bigint, claimPermission: ClaimPermission ) { - super(network); - this.#poolId = poolId; - this.#bond = bond; - this.#claimPermission = claimPermission; + super(network) + this.#poolId = poolId + this.#bond = bond + this.#claimPermission = claimPermission } tx() { @@ -30,22 +30,22 @@ export class JoinPool extends Base { amount: this.#bond, pool_id: this.#poolId, }), - ]; + ] if (this.#claimPermission !== defaultClaimPermission) { txs.push( this.unsafeApi.tx.NominationPools.set_claim_permission({ permission: { type: this.#claimPermission, value: undefined }, }) - ); + ) } if (txs.length === 1) { - return txs[0]; + return txs[0] } - return txs; + return txs } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/newNominator.ts b/packages/app/src/api/tx/newNominator.ts index 494b2d5795..e1879161e2 100644 --- a/packages/app/src/api/tx/newNominator.ts +++ b/packages/app/src/api/tx/newNominator.ts @@ -1,14 +1,14 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { PayeeSubmit } from 'contexts/Setup/types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { PayeeSubmit } from 'contexts/Setup/types' export class NewNominator extends Base { - #payee: PayeeSubmit; - #bond: bigint; - #nominees: { type: string; value: string }[]; + #payee: PayeeSubmit + #bond: bigint + #nominees: { type: string; value: string }[] constructor( network: ChainId, @@ -16,10 +16,10 @@ export class NewNominator extends Base { payee: PayeeSubmit, nominees: { type: string; value: string }[] ) { - super(network); - this.#bond = bond; - this.#payee = payee; - this.#nominees = nominees; + super(network) + this.#bond = bond + this.#payee = payee + this.#nominees = nominees } tx() { @@ -32,9 +32,9 @@ export class NewNominator extends Base { this.unsafeApi.tx.Staking.nominate({ targets: this.#nominees, }), - ]; + ] } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/payoutStakersByPage.ts b/packages/app/src/api/tx/payoutStakersByPage.ts index cf44333ecf..5017ac2d6c 100644 --- a/packages/app/src/api/tx/payoutStakersByPage.ts +++ b/packages/app/src/api/tx/payoutStakersByPage.ts @@ -1,19 +1,19 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PayoutStakersByPage extends Base { - #validator: string; - #era: number; - #page: number; + #validator: string + #era: number + #page: number constructor(network: ChainId, validator: string, era: number, page: number) { - super(network); - this.#validator = validator; - this.#era = era; - this.#page = page; + super(network) + this.#validator = validator + this.#era = era + this.#page = page } tx() { @@ -22,9 +22,9 @@ export class PayoutStakersByPage extends Base { validator_stash: this.#validator, era: this.#era, page: this.#page, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolBondExtra.ts b/packages/app/src/api/tx/poolBondExtra.ts index e6a954c91a..d7f3db03b0 100644 --- a/packages/app/src/api/tx/poolBondExtra.ts +++ b/packages/app/src/api/tx/poolBondExtra.ts @@ -1,21 +1,21 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolBondExtra extends Base { - #type: 'FreeBalance' | 'Rewards'; - #bond: bigint; + #type: 'FreeBalance' | 'Rewards' + #bond: bigint constructor( network: ChainId, type: 'FreeBalance' | 'Rewards', bond?: bigint ) { - super(network); - this.#type = type; - this.#bond = bond || 0n; + super(network) + this.#type = type + this.#bond = bond || 0n } tx() { @@ -26,13 +26,13 @@ export class PoolBondExtra extends Base { type: this.#type, value: this.#bond, } - : { type: 'Rewards', value: undefined }; + : { type: 'Rewards', value: undefined } return this.unsafeApi.tx.NominationPools.bond_extra({ extra, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolChill.ts b/packages/app/src/api/tx/poolChill.ts index 3c9a799c61..9f055bd57a 100644 --- a/packages/app/src/api/tx/poolChill.ts +++ b/packages/app/src/api/tx/poolChill.ts @@ -1,22 +1,22 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolChill extends Base { - #poolId: number; + #poolId: number constructor(network: ChainId, poolId: number) { - super(network); - this.#poolId = poolId; + super(network) + this.#poolId = poolId } tx() { try { - return this.unsafeApi.tx.NominationPools.chill({ pool_id: this.#poolId }); + return this.unsafeApi.tx.NominationPools.chill({ pool_id: this.#poolId }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolClaimCommission.ts b/packages/app/src/api/tx/poolClaimCommission.ts index 77e974be02..027ec1ae66 100644 --- a/packages/app/src/api/tx/poolClaimCommission.ts +++ b/packages/app/src/api/tx/poolClaimCommission.ts @@ -1,24 +1,24 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolClaimCommission extends Base { - #poolId: number; + #poolId: number constructor(network: ChainId, poolId: number) { - super(network); - this.#poolId = poolId; + super(network) + this.#poolId = poolId } tx() { try { return this.unsafeApi.tx.NominationPools.claim_commission({ pool_id: this.#poolId, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolClaimPayout.ts b/packages/app/src/api/tx/poolClaimPayout.ts index 85a30b23d0..9f4ac5efac 100644 --- a/packages/app/src/api/tx/poolClaimPayout.ts +++ b/packages/app/src/api/tx/poolClaimPayout.ts @@ -1,19 +1,19 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolClaimPayout extends Base { constructor(network: ChainId) { - super(network); + super(network) } tx() { try { - return this.unsafeApi.tx.NominationPools.claim_payout(); + return this.unsafeApi.tx.NominationPools.claim_payout() } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolNominate.ts b/packages/app/src/api/tx/poolNominate.ts index a6309aeffd..dd61f4c801 100644 --- a/packages/app/src/api/tx/poolNominate.ts +++ b/packages/app/src/api/tx/poolNominate.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolNominate extends Base { - #poolId: number; - #nominees: string[]; + #poolId: number + #nominees: string[] constructor(network: ChainId, poolId: number, nominees: string[]) { - super(network); - this.#poolId = poolId; - this.#nominees = nominees; + super(network) + this.#poolId = poolId + this.#nominees = nominees } tx() { @@ -19,9 +19,9 @@ export class PoolNominate extends Base { return this.unsafeApi.tx.NominationPools.nominate({ pool_id: this.#poolId, validators: this.#nominees, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolSetClaimPermission.ts b/packages/app/src/api/tx/poolSetClaimPermission.ts index b6a8f5ecf1..9e71b274f8 100644 --- a/packages/app/src/api/tx/poolSetClaimPermission.ts +++ b/packages/app/src/api/tx/poolSetClaimPermission.ts @@ -1,16 +1,16 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { ClaimPermission } from 'contexts/Pools/types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { ClaimPermission } from 'contexts/Pools/types' export class PoolSetClaimPermission extends Base { - #claimPermission: ClaimPermission; + #claimPermission: ClaimPermission constructor(network: ChainId, claimPermission: ClaimPermission) { - super(network); - this.#claimPermission = claimPermission; + super(network) + this.#claimPermission = claimPermission } tx() { @@ -20,9 +20,9 @@ export class PoolSetClaimPermission extends Base { type: this.#claimPermission, value: undefined, }, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolSetCommission.ts b/packages/app/src/api/tx/poolSetCommission.ts index 7d3bf7f2d6..56a3072f24 100644 --- a/packages/app/src/api/tx/poolSetCommission.ts +++ b/packages/app/src/api/tx/poolSetCommission.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolSetCommission extends Base { - #poolId: number; - #commission?: [number, string]; + #poolId: number + #commission?: [number, string] constructor(network: ChainId, poolId: number, commission?: [number, string]) { - super(network); - this.#poolId = poolId; - this.#commission = commission; + super(network) + this.#poolId = poolId + this.#commission = commission } tx() { @@ -19,9 +19,9 @@ export class PoolSetCommission extends Base { return this.unsafeApi.tx.NominationPools.set_commission({ pool_id: this.#poolId, new_commission: this.#commission, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolSetCommissionChangeRate.ts b/packages/app/src/api/tx/poolSetCommissionChangeRate.ts index 682ed4aa18..4d8bf21f4c 100644 --- a/packages/app/src/api/tx/poolSetCommissionChangeRate.ts +++ b/packages/app/src/api/tx/poolSetCommissionChangeRate.ts @@ -1,13 +1,13 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolSetCommissionChangeRate extends Base { - #poolId: number; - #maxIncrease?: number; - #minDelay?: number; + #poolId: number + #maxIncrease?: number + #minDelay?: number constructor( network: ChainId, @@ -15,10 +15,10 @@ export class PoolSetCommissionChangeRate extends Base { maxIncrease: number, minDelay: number ) { - super(network); - this.#poolId = poolId; - this.#maxIncrease = maxIncrease; - this.#minDelay = minDelay; + super(network) + this.#poolId = poolId + this.#maxIncrease = maxIncrease + this.#minDelay = minDelay } tx() { @@ -29,9 +29,9 @@ export class PoolSetCommissionChangeRate extends Base { max_increase: this.#maxIncrease, min_delay: this.#minDelay, }, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolSetCommissionMax.ts b/packages/app/src/api/tx/poolSetCommissionMax.ts index 0a8ab71ac6..b93fe8c32a 100644 --- a/packages/app/src/api/tx/poolSetCommissionMax.ts +++ b/packages/app/src/api/tx/poolSetCommissionMax.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolSetCommissionMax extends Base { - #poolId: number; - #max?: number; + #poolId: number + #max?: number constructor(network: ChainId, poolId: number, max: number) { - super(network); - this.#poolId = poolId; - this.#max = max; + super(network) + this.#poolId = poolId + this.#max = max } tx() { @@ -19,9 +19,9 @@ export class PoolSetCommissionMax extends Base { return this.unsafeApi.tx.NominationPools.set_commission_max({ pool_id: this.#poolId, max_commission: this.#max, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolSetMetadata.ts b/packages/app/src/api/tx/poolSetMetadata.ts index 54d34c882a..eea1e5880f 100644 --- a/packages/app/src/api/tx/poolSetMetadata.ts +++ b/packages/app/src/api/tx/poolSetMetadata.ts @@ -1,18 +1,18 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { Binary } from 'polkadot-api'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { Binary } from 'polkadot-api' export class PoolSetMetadata extends Base { - #poolId: number; - #metadata: Binary; + #poolId: number + #metadata: Binary constructor(network: ChainId, poolId: number, metadata: Binary) { - super(network); - this.#poolId = poolId; - this.#metadata = metadata; + super(network) + this.#poolId = poolId + this.#metadata = metadata } tx() { @@ -20,9 +20,9 @@ export class PoolSetMetadata extends Base { return this.unsafeApi.tx.NominationPools.set_metadata({ pool_id: this.#poolId, metadata: this.#metadata, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolSetState.ts b/packages/app/src/api/tx/poolSetState.ts index 5985daf716..ea4cdbb5c3 100644 --- a/packages/app/src/api/tx/poolSetState.ts +++ b/packages/app/src/api/tx/poolSetState.ts @@ -1,18 +1,18 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { PoolState } from 'types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { PoolState } from 'types' export class PoolSetState extends Base { - #poolId: number; - #state: PoolState; + #poolId: number + #state: PoolState constructor(network: ChainId, poolId: number, state: PoolState) { - super(network); - this.#poolId = poolId; - this.#state = state; + super(network) + this.#poolId = poolId + this.#state = state } tx() { @@ -20,9 +20,9 @@ export class PoolSetState extends Base { return this.unsafeApi.tx.NominationPools.set_state({ pool_id: this.#poolId, state: { type: this.#state, value: undefined }, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolUnbond.ts b/packages/app/src/api/tx/poolUnbond.ts index 0736f0cd46..f76b0bfde8 100644 --- a/packages/app/src/api/tx/poolUnbond.ts +++ b/packages/app/src/api/tx/poolUnbond.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolUnbond extends Base { - #who: string; - #bond: bigint; + #who: string + #bond: bigint constructor(network: ChainId, who: string, bond: bigint) { - super(network); - this.#who = who; - this.#bond = bond; + super(network) + this.#who = who + this.#bond = bond } tx() { @@ -22,9 +22,9 @@ export class PoolUnbond extends Base { value: this.#who, }, unbonding_points: this.#bond, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolUpdateRoles.ts b/packages/app/src/api/tx/poolUpdateRoles.ts index 37b3913e9b..486d00a197 100644 --- a/packages/app/src/api/tx/poolUpdateRoles.ts +++ b/packages/app/src/api/tx/poolUpdateRoles.ts @@ -1,18 +1,18 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { PoolRoles } from 'types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { PoolRoles } from 'types' export class PoolUpdateRoles extends Base { - #poolId: number; - #roles: PoolRoles; + #poolId: number + #roles: PoolRoles constructor(network: ChainId, poolId: number, roles: PoolRoles) { - super(network); - this.#poolId = poolId; - this.#roles = roles; + super(network) + this.#poolId = poolId + this.#roles = roles } tx() { @@ -30,9 +30,9 @@ export class PoolUpdateRoles extends Base { new_bouncer: this.#roles.bouncer ? { type: 'Set', value: this.#roles.bouncer } : { type: 'Remove', value: undefined }, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/poolWithdraw.ts b/packages/app/src/api/tx/poolWithdraw.ts index cb46e69e2a..015138eb6c 100644 --- a/packages/app/src/api/tx/poolWithdraw.ts +++ b/packages/app/src/api/tx/poolWithdraw.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class PoolWithdraw extends Base { - #who: string; - #numSlashingSpans: number; + #who: string + #numSlashingSpans: number constructor(network: ChainId, who: string, numSlashingSpans: number) { - super(network); - this.#who = who; - this.#numSlashingSpans = numSlashingSpans; + super(network) + this.#who = who + this.#numSlashingSpans = numSlashingSpans } tx() { @@ -22,9 +22,9 @@ export class PoolWithdraw extends Base { value: this.#who, }, num_slashing_spans: this.#numSlashingSpans, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/proxy.ts b/packages/app/src/api/tx/proxy.ts index 1d0ea84545..81f09f26d9 100644 --- a/packages/app/src/api/tx/proxy.ts +++ b/packages/app/src/api/tx/proxy.ts @@ -1,19 +1,19 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class Proxy extends Base { - #who: string; + #who: string // eslint-disable-next-line @typescript-eslint/no-explicit-any - #proxiedTx: any; + #proxiedTx: any // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(network: ChainId, who: string, proxiedTx: any) { - super(network); - this.#who = who; - this.#proxiedTx = proxiedTx; + super(network) + this.#who = who + this.#proxiedTx = proxiedTx } tx() { @@ -25,9 +25,9 @@ export class Proxy extends Base { }, force_proxy_type: undefined, call: this.#proxiedTx.decodedCall, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingBondExtra.ts b/packages/app/src/api/tx/stakingBondExtra.ts index e9d3bee67d..1048d3a3ce 100644 --- a/packages/app/src/api/tx/stakingBondExtra.ts +++ b/packages/app/src/api/tx/stakingBondExtra.ts @@ -1,24 +1,24 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class StakingBondExtra extends Base { - #bond: bigint; + #bond: bigint constructor(network: ChainId, bond: bigint) { - super(network); - this.#bond = bond; + super(network) + this.#bond = bond } tx() { try { return this.unsafeApi.tx.Staking.bond_extra({ max_additional: this.#bond, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingChill.ts b/packages/app/src/api/tx/stakingChill.ts index 2d18c423c3..1ed9706513 100644 --- a/packages/app/src/api/tx/stakingChill.ts +++ b/packages/app/src/api/tx/stakingChill.ts @@ -1,19 +1,19 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class StakingChill extends Base { constructor(network: ChainId) { - super(network); + super(network) } tx() { try { - return this.unsafeApi.tx.Staking.chill(); + return this.unsafeApi.tx.Staking.chill() } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingNominate.ts b/packages/app/src/api/tx/stakingNominate.ts index a65386b64d..198b5b7287 100644 --- a/packages/app/src/api/tx/stakingNominate.ts +++ b/packages/app/src/api/tx/stakingNominate.ts @@ -1,24 +1,24 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class StakingNominate extends Base { - #nominees: { type: string; value: string }[]; + #nominees: { type: string; value: string }[] constructor(network: ChainId, nominees: { type: string; value: string }[]) { - super(network); - this.#nominees = nominees; + super(network) + this.#nominees = nominees } tx() { try { return this.unsafeApi.tx.Staking.nominate({ targets: this.#nominees, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingRebond.ts b/packages/app/src/api/tx/stakingRebond.ts index d017e6c9a6..8c1c78d0d9 100644 --- a/packages/app/src/api/tx/stakingRebond.ts +++ b/packages/app/src/api/tx/stakingRebond.ts @@ -1,24 +1,24 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class StakingRebond extends Base { - #bond: bigint; + #bond: bigint constructor(network: ChainId, bond: bigint) { - super(network); - this.#bond = bond; + super(network) + this.#bond = bond } tx() { try { return this.unsafeApi.tx.Staking.rebond({ value: this.#bond, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingSetPayee.ts b/packages/app/src/api/tx/stakingSetPayee.ts index 47acbda979..356b8f57d2 100644 --- a/packages/app/src/api/tx/stakingSetPayee.ts +++ b/packages/app/src/api/tx/stakingSetPayee.ts @@ -1,25 +1,25 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; -import type { PayeeSubmit } from 'contexts/Setup/types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' +import type { PayeeSubmit } from 'contexts/Setup/types' export class StakingSetPayee extends Base { - #payee: PayeeSubmit; + #payee: PayeeSubmit constructor(network: ChainId, payee: PayeeSubmit) { - super(network); - this.#payee = payee; + super(network) + this.#payee = payee } tx() { try { return this.unsafeApi.tx.Staking.set_payee({ payee: this.#payee, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingUnbond.ts b/packages/app/src/api/tx/stakingUnbond.ts index 57745f0ce4..cd01ebd7ac 100644 --- a/packages/app/src/api/tx/stakingUnbond.ts +++ b/packages/app/src/api/tx/stakingUnbond.ts @@ -1,22 +1,22 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class StakingUnbond extends Base { - #bond: bigint; + #bond: bigint constructor(network: ChainId, bond: bigint) { - super(network); - this.#bond = bond; + super(network) + this.#bond = bond } tx() { try { - return this.unsafeApi.tx.Staking.unbond({ value: this.#bond }); + return this.unsafeApi.tx.Staking.unbond({ value: this.#bond }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/stakingWithdraw.ts b/packages/app/src/api/tx/stakingWithdraw.ts index e70df261ab..61df045d8d 100644 --- a/packages/app/src/api/tx/stakingWithdraw.ts +++ b/packages/app/src/api/tx/stakingWithdraw.ts @@ -1,24 +1,24 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class StakingWithdraw extends Base { - #numSlashingSpans: number; + #numSlashingSpans: number constructor(network: ChainId, numSlashingSpans: number) { - super(network); - this.#numSlashingSpans = numSlashingSpans; + super(network) + this.#numSlashingSpans = numSlashingSpans } tx() { try { return this.unsafeApi.tx.Staking.withdraw_unbonded({ num_slashing_spans: this.#numSlashingSpans, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/tx/transferKeepAlive.ts b/packages/app/src/api/tx/transferKeepAlive.ts index a56132416a..f51e729ab1 100644 --- a/packages/app/src/api/tx/transferKeepAlive.ts +++ b/packages/app/src/api/tx/transferKeepAlive.ts @@ -1,17 +1,17 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { Base } from 'api/base'; -import type { ChainId } from 'common-types'; +import { Base } from 'api/base' +import type { ChainId } from 'common-types' export class TransferKeepAlive extends Base { - #to: string; - #value: bigint; + #to: string + #value: bigint constructor(network: ChainId, to: string, value: bigint) { - super(network); - this.#to = to; - this.#value = value; + super(network) + this.#to = to + this.#value = value } tx() { @@ -22,9 +22,9 @@ export class TransferKeepAlive extends Base { value: this.#to, }, value: this.#value, - }); + }) } catch (e) { - return null; + return null } } } diff --git a/packages/app/src/api/txSubmission.ts b/packages/app/src/api/txSubmission.ts index edbdd186b9..788bcd01fb 100644 --- a/packages/app/src/api/txSubmission.ts +++ b/packages/app/src/api/txSubmission.ts @@ -1,44 +1,44 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { MaybeAddress } from 'types'; -import type { TxSubmissionItem } from './types'; +import type { MaybeAddress } from 'types' +import type { TxSubmissionItem } from './types' export class TxSubmission { - static uids: TxSubmissionItem[] = []; + static uids: TxSubmissionItem[] = [] static getUid(id: number) { - return this.uids.find((item) => item.uid === id); + return this.uids.find((item) => item.uid === id) } static addUid({ from, tag }: { from: MaybeAddress; tag?: string }) { // If tag already exists, delete the entry. if (tag) { - this.uids = this.uids.filter((item) => item.tag !== tag); + this.uids = this.uids.filter((item) => item.tag !== tag) } - const newUid = this.uids.length + 1; - this.uids.push({ uid: newUid, processing: false, from, fee: 0n, tag }); - this.dispatchEvent(); - return newUid; + const newUid = this.uids.length + 1 + this.uids.push({ uid: newUid, processing: false, from, fee: 0n, tag }) + this.dispatchEvent() + return newUid } static updateFee(uid: number, fee: bigint) { this.uids = this.uids.map((item) => item.uid === uid ? { ...item, fee } : item - ); - this.dispatchEvent(); + ) + this.dispatchEvent() } static removeUid(id: number) { - this.uids = this.uids.filter(({ uid }) => uid !== id); - this.dispatchEvent(); + this.uids = this.uids.filter(({ uid }) => uid !== id) + this.dispatchEvent() } static setUidProcessing(id: number, newProcessing: boolean) { this.uids = this.uids.map((item) => item.uid === id ? { ...item, processing: newProcessing } : item - ); - this.dispatchEvent(); + ) + this.dispatchEvent() } static dispatchEvent = () => { @@ -48,6 +48,6 @@ export class TxSubmission { uids: this.uids, }, }) - ); - }; + ) + } } diff --git a/packages/app/src/api/types.ts b/packages/app/src/api/types.ts index 5893592900..6c815f4331 100644 --- a/packages/app/src/api/types.ts +++ b/packages/app/src/api/types.ts @@ -1,54 +1,54 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import type { ChainId } from 'common-types'; -import type { MaybeAddress } from 'types'; +import type { ChainId } from 'common-types' +import type { MaybeAddress } from 'types' export interface APIConfig { - type: ConnectionType; - rpcEndpoint: string; + type: ConnectionType + rpcEndpoint: string } export interface APIEventDetail { - status: EventApiStatus; - network: ChainId; - chainType: ApiChainType; - connectionType: ConnectionType; - rpcEndpoint: string; - err?: string; + status: EventApiStatus + network: ChainId + chainType: ApiChainType + connectionType: ConnectionType + rpcEndpoint: string + err?: string } export interface PapiChainSpec { - genesisHash: string; - ss58Format: number; - tokenDecimals: number; - tokenSymbol: string; - authoringVersion: number; - implName: string; - implVersion: number; - specName: string; - specVersion: number; - stateVersion: number; - transactionVersion: number; + genesisHash: string + ss58Format: number + tokenDecimals: number + tokenSymbol: string + authoringVersion: number + implName: string + implVersion: number + specName: string + specVersion: number + stateVersion: number + transactionVersion: number } export type PapiReadyEvent = PapiChainSpec & { - network: ChainId; - chainType: string; -}; + network: ChainId + chainType: string +} -export type ConnectionType = 'ws' | 'sc'; +export type ConnectionType = 'ws' | 'sc' -export type ApiStatus = 'connecting' | 'connected' | 'disconnected' | 'ready'; +export type ApiStatus = 'connecting' | 'connected' | 'disconnected' | 'ready' -export type EventApiStatus = ApiStatus | 'error'; +export type EventApiStatus = ApiStatus | 'error' -export type ApiChainType = 'relay' | 'system'; +export type ApiChainType = 'relay' | 'system' export type TxSubmissionItem = { - uid: number; - tag?: string; - fee: bigint; - from: MaybeAddress; - processing: boolean; -}; + uid: number + tag?: string + fee: bigint + from: MaybeAddress + processing: boolean +} diff --git a/packages/app/src/canvas/CreatePool/Bond/index.tsx b/packages/app/src/canvas/CreatePool/Bond/index.tsx index a2280a1838..da8151ab32 100644 --- a/packages/app/src/canvas/CreatePool/Bond/index.tsx +++ b/packages/app/src/canvas/CreatePool/Bond/index.tsx @@ -1,61 +1,61 @@ // Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import BigNumber from 'bignumber.js'; -import { useActiveAccounts } from 'contexts/ActiveAccounts'; -import { useSetup } from 'contexts/Setup'; -import { useTxMeta } from 'contexts/TxMeta'; -import { BondFeedback } from 'library/Form/Bond/BondFeedback'; -import { CreatePoolStatusBar } from 'library/Form/CreatePoolStatusBar'; -import { Footer } from 'library/SetupSteps/Footer'; -import { Header } from 'library/SetupSteps/Header'; -import { MotionContainer } from 'library/SetupSteps/MotionContainer'; -import type { SetupStepProps } from 'library/SetupSteps/types'; -import { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; +import BigNumber from 'bignumber.js' +import { useActiveAccounts } from 'contexts/ActiveAccounts' +import { useSetup } from 'contexts/Setup' +import { useTxMeta } from 'contexts/TxMeta' +import { BondFeedback } from 'library/Form/Bond/BondFeedback' +import { CreatePoolStatusBar } from 'library/Form/CreatePoolStatusBar' +import { Footer } from 'library/SetupSteps/Footer' +import { Header } from 'library/SetupSteps/Header' +import { MotionContainer } from 'library/SetupSteps/MotionContainer' +import type { SetupStepProps } from 'library/SetupSteps/types' +import { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' export const Bond = ({ section }: SetupStepProps) => { - const { t } = useTranslation('pages'); - const { getTxSubmissionByTag } = useTxMeta(); - const { activeAccount } = useActiveAccounts(); - const { getPoolSetup, setActiveAccountSetup } = useSetup(); + const { t } = useTranslation('pages') + const { getTxSubmissionByTag } = useTxMeta() + const { activeAccount } = useActiveAccounts() + const { getPoolSetup, setActiveAccountSetup } = useSetup() - const txSubmission = getTxSubmissionByTag('createPool'); - const fee = txSubmission?.fee || 0n; + const txSubmission = getTxSubmissionByTag('createPool') + const fee = txSubmission?.fee || 0n - const setup = getPoolSetup(activeAccount); - const { progress } = setup; + const setup = getPoolSetup(activeAccount) + const { progress } = setup // either free to bond or existing setup value - const initialBondValue = progress.bond === '0' ? '' : progress.bond; + const initialBondValue = progress.bond === '0' ? '' : progress.bond // store local bond amount for form control const [bond, setBond] = useState<{ bond: string }>({ bond: initialBondValue, - }); + }) // bond valid - const [bondValid, setBondValid] = useState(false); + const [bondValid, setBondValid] = useState(false) // handler for updating bond const handleSetBond = (value: { bond: BigNumber }) => { // set this form's bond value. setBond({ bond: value.bond.toString(), - }); + }) // set pool progress bond value. setActiveAccountSetup('pool', { ...progress, bond: value.bond.toString(), - }); - }; + }) + } // update bond on account change useEffect(() => { setBond({ bond: initialBondValue, - }); - }, [activeAccount]); + }) + }, [activeAccount]) // apply initial bond value to setup progress useEffect(() => { @@ -64,9 +64,9 @@ export const Bond = ({ section }: SetupStepProps) => { setActiveAccountSetup('pool', { ...progress, bond: initialBondValue, - }); + }) } - }, [setup.section]); + }, [setup.section]) return ( <> @@ -92,5 +92,5 @@ export const Bond = ({ section }: SetupStepProps) => {