Bump deps (#7879)
* Bump deps * Additional * Prev pool reward info * Adjust Account for V0
This commit is contained in:
parent
7287eabab1
commit
a54b71c2a4
34
package.json
34
package.json
@ -68,13 +68,13 @@
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@crustio/crust-pin": "^1.0.0",
|
||||
"@pinata/sdk": "^1.1.26",
|
||||
"@polkadot/dev": "^0.67.76",
|
||||
"@polkadot/dev": "^0.67.79",
|
||||
"@types/chart.js": "^2.9.37",
|
||||
"@types/file-saver": "^2.0.5",
|
||||
"@types/jest": "^28.1.4",
|
||||
"@types/jest": "^28.1.6",
|
||||
"@types/react-beautiful-dnd": "^13.1.2",
|
||||
"@types/react-copy-to-clipboard": "^5.0.2",
|
||||
"@types/react-dom": "^18.0.5",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/store": "^2.0.2",
|
||||
"@types/styled-components": "^5.1.25",
|
||||
@ -95,24 +95,24 @@
|
||||
"webpack-cli": "^4.10.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@polkadot/api": "^8.12.2",
|
||||
"@polkadot/api-augment": "^8.12.2",
|
||||
"@polkadot/api-base": "^8.12.2",
|
||||
"@polkadot/api-contract": "^8.12.2",
|
||||
"@polkadot/api-derive": "^8.12.2",
|
||||
"@polkadot/api": "^8.13.1",
|
||||
"@polkadot/api-augment": "^8.13.1",
|
||||
"@polkadot/api-base": "^8.13.1",
|
||||
"@polkadot/api-contract": "^8.13.1",
|
||||
"@polkadot/api-derive": "^8.13.1",
|
||||
"@polkadot/hw-ledger": "^10.0.2",
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/networks": "^10.0.2",
|
||||
"@polkadot/phishing": "^0.17.2",
|
||||
"@polkadot/rpc-augment": "^8.12.2",
|
||||
"@polkadot/rpc-core": "^8.12.2",
|
||||
"@polkadot/rpc-provider": "^8.12.2",
|
||||
"@polkadot/types": "^8.12.2",
|
||||
"@polkadot/types-augment": "^8.12.2",
|
||||
"@polkadot/types-codec": "^8.12.2",
|
||||
"@polkadot/types-create": "^8.12.2",
|
||||
"@polkadot/types-known": "^8.12.2",
|
||||
"@polkadot/types-support": "^8.12.2",
|
||||
"@polkadot/rpc-augment": "^8.13.1",
|
||||
"@polkadot/rpc-core": "^8.13.1",
|
||||
"@polkadot/rpc-provider": "^8.13.1",
|
||||
"@polkadot/types": "^8.13.1",
|
||||
"@polkadot/types-augment": "^8.13.1",
|
||||
"@polkadot/types-codec": "^8.13.1",
|
||||
"@polkadot/types-create": "^8.13.1",
|
||||
"@polkadot/types-known": "^8.13.1",
|
||||
"@polkadot/types-support": "^8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/wasm-crypto": "^6.2.3",
|
||||
|
||||
@ -31,10 +31,10 @@
|
||||
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
|
||||
"@parallel-finance/type-definitions": "1.7.7",
|
||||
"@phala/typedefs": "0.2.30",
|
||||
"@polkadot/api": "^8.12.2",
|
||||
"@polkadot/api-derive": "^8.12.2",
|
||||
"@polkadot/api": "^8.13.1",
|
||||
"@polkadot/api-derive": "^8.13.1",
|
||||
"@polkadot/networks": "^10.0.2",
|
||||
"@polkadot/types": "^8.12.2",
|
||||
"@polkadot/types": "^8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/x-fetch": "^10.0.2",
|
||||
"@polymathnetwork/polymesh-types": "0.0.2",
|
||||
@ -49,6 +49,6 @@
|
||||
"lodash": "^4.17.21",
|
||||
"moonbeam-types-bundle": "2.0.7",
|
||||
"pontem-types-bundle": "1.0.15",
|
||||
"rxjs": "^7.5.5"
|
||||
"rxjs": "^7.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,13 +14,13 @@
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/polyfill": "^7.12.1",
|
||||
"@polkadot/dev": "^0.67.76",
|
||||
"@polkadot/dev": "^0.67.79",
|
||||
"@polkadot/react-components": "^0.117.4-3-x",
|
||||
"electron-log": "^4.4.8",
|
||||
"electron-updater": "^4.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-dom": "^18.0.5",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
"@types/tmp": "^0.2.3",
|
||||
"babel-loader": "^8.2.5",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/apps-config": "^0.117.4-3-x",
|
||||
"@polkadot/apps-routing": "^0.117.4-3-x",
|
||||
"@polkadot/dev": "^0.67.76",
|
||||
"@polkadot/dev": "^0.67.79",
|
||||
"@polkadot/react-api": "^0.117.4-3-x",
|
||||
"@polkadot/react-components": "^0.117.4-3-x",
|
||||
"@polkadot/react-hooks": "^0.117.4-3-x",
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
"@polkadot/react-components": "^0.117.4-3-x",
|
||||
"@polkadot/react-hooks": "^0.117.4-3-x",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/vanitygen": "^0.51.15",
|
||||
"@polkadot/vanitygen": "^0.51.16",
|
||||
"detect-browser": "^5.3.0",
|
||||
"file-saver": "^2.0.5"
|
||||
},
|
||||
|
||||
@ -14,6 +14,6 @@
|
||||
"version": "0.117.4-3-x",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api-contract": "^8.12.2"
|
||||
"@polkadot/api-contract": "^8.13.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import type { DeriveSessionProgress, DeriveUnlocking } from '@polkadot/api-deriv
|
||||
import type { PalletNominationPoolsPoolMember, PalletNominationPoolsPoolRoles } from '@polkadot/types/lookup';
|
||||
import type { PoolInfo } from '../../Pools/types';
|
||||
import type { SortedTargets } from '../../types';
|
||||
import type { PalletNominationPoolsPoolMemberV0 } from './types';
|
||||
|
||||
import React, { useCallback, useContext, useMemo } from 'react';
|
||||
|
||||
@ -41,7 +42,7 @@ function extractRoles (accountId: string, { nominator, root }: PalletNominationP
|
||||
};
|
||||
}
|
||||
|
||||
function calcUnbonding (accountId: string, stashId: string, { activeEra }: DeriveSessionProgress, { unbondingEras }: PalletNominationPoolsPoolMember): { accountId: string, controllerId: string, redeemable: BN, stashId: string, unlocking: DeriveUnlocking[] } {
|
||||
function calcUnbonding (accountId: string, stashId: string, { activeEra }: DeriveSessionProgress, { unbondingEras }: PalletNominationPoolsPoolMemberV0 | PalletNominationPoolsPoolMember): { accountId: string, controllerId: string, redeemable: BN, stashId: string, unlocking: DeriveUnlocking[] } {
|
||||
const unlocking: DeriveUnlocking[] = [];
|
||||
const redeemable = new BN(0);
|
||||
|
||||
|
||||
13
packages/page-staking/src/Actions/Pool/is.ts
Normal file
13
packages/page-staking/src/Actions/Pool/is.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool } from '@polkadot/types/lookup';
|
||||
import type { PalletNominationPoolsPoolMemberV0, PalletNominationPoolsRewardPoolV0 } from './types';
|
||||
|
||||
export function isPrevMember (member?: PalletNominationPoolsPoolMember | PalletNominationPoolsPoolMemberV0 | null): member is PalletNominationPoolsPoolMemberV0 {
|
||||
return !!(member && (member as PalletNominationPoolsPoolMemberV0).rewardPoolTotalEarnings);
|
||||
}
|
||||
|
||||
export function isPrevPool (pool?: PalletNominationPoolsRewardPool | PalletNominationPoolsRewardPoolV0 | null): pool is PalletNominationPoolsRewardPoolV0 {
|
||||
return !!(pool && (pool as PalletNominationPoolsRewardPoolV0).totalEarnings);
|
||||
}
|
||||
@ -1,10 +1,25 @@
|
||||
// Copyright 2017-2022 @polkadot/app-staking authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { PalletNominationPoolsPoolMember } from '@polkadot/types/lookup';
|
||||
import type { BTreeMap, u32, u128, U256 } from '@polkadot/types';
|
||||
// import type { PalletNominationPoolsPoolMember } from '@polkadot/types/lookup';
|
||||
import type { BN } from '@polkadot/util';
|
||||
|
||||
export interface PalletNominationPoolsPoolMemberV0 {
|
||||
readonly poolId: u32;
|
||||
readonly points: u128;
|
||||
readonly rewardPoolTotalEarnings: u128;
|
||||
readonly unbondingEras: BTreeMap<u32, u128>;
|
||||
}
|
||||
|
||||
export interface PalletNominationPoolsRewardPoolV0 {
|
||||
readonly balance: u128;
|
||||
readonly totalEarnings: u128;
|
||||
readonly points: U256;
|
||||
}
|
||||
|
||||
export interface AccountInfo {
|
||||
claimable: BN;
|
||||
member: PalletNominationPoolsPoolMember;
|
||||
// TODO current version rewards
|
||||
member: PalletNominationPoolsPoolMemberV0;
|
||||
}
|
||||
|
||||
@ -4,19 +4,21 @@
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool } from '@polkadot/types/lookup';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { AccountInfo } from './types';
|
||||
import type { AccountInfo, PalletNominationPoolsPoolMemberV0, PalletNominationPoolsRewardPoolV0 } from './types';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
|
||||
import { BN_ZERO, bnMax } from '@polkadot/util';
|
||||
|
||||
import { isPrevMember, isPrevPool } from './is';
|
||||
|
||||
const OPT_DEL = {
|
||||
transform: (opt: Option<PalletNominationPoolsPoolMember>): PalletNominationPoolsPoolMember | null =>
|
||||
transform: (opt: Option<PalletNominationPoolsPoolMember>): PalletNominationPoolsPoolMember | PalletNominationPoolsPoolMemberV0 | null =>
|
||||
opt.unwrapOr(null)
|
||||
};
|
||||
|
||||
function createInfo (member: PalletNominationPoolsPoolMember, rewardPool: PalletNominationPoolsRewardPool, poolPoints: BN, currentBalance: BN): AccountInfo {
|
||||
function createInfoPrev (member: PalletNominationPoolsPoolMemberV0, rewardPool: PalletNominationPoolsRewardPoolV0, poolPoints: BN, currentBalance: BN): AccountInfo {
|
||||
const lastTotalEarnings = rewardPool.totalEarnings;
|
||||
const currTotalEarnings = bnMax(BN_ZERO, currentBalance.sub(rewardPool.balance)).add(rewardPool.totalEarnings);
|
||||
const newEarnings = bnMax(BN_ZERO, currTotalEarnings.sub(lastTotalEarnings));
|
||||
@ -38,7 +40,13 @@ function useAccountInfoImpl (accountId: string, rewardPool: PalletNominationPool
|
||||
const member = useCall(api.query.nominationPools.poolMembers, [accountId], OPT_DEL);
|
||||
|
||||
return useMemo(
|
||||
() => member && createInfo(member, rewardPool, poolPoints, rewardClaimable),
|
||||
() => isPrevPool(rewardPool)
|
||||
? member && (
|
||||
isPrevMember(member)
|
||||
? createInfoPrev(member, rewardPool, poolPoints, rewardClaimable)
|
||||
: null
|
||||
)
|
||||
: null,
|
||||
[member, poolPoints, rewardPool, rewardClaimable]
|
||||
);
|
||||
}
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
"version": "0.117.4-3-x",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api": "^8.12.2",
|
||||
"@polkadot/api": "^8.13.1",
|
||||
"@polkadot/extension-compat-metamask": "^0.44.2-4",
|
||||
"@polkadot/extension-dapp": "^0.44.2-4",
|
||||
"@polkadot/rpc-provider": "^8.12.2",
|
||||
"@polkadot/rpc-provider": "^8.13.1",
|
||||
"fflate": "^0.7.3",
|
||||
"rxjs": "^7.5.5"
|
||||
"rxjs": "^7.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"chart.js": "^3.8.0",
|
||||
"codeflask": "^1.4.1",
|
||||
"i18next": "^21.8.13",
|
||||
"i18next": "^21.8.14",
|
||||
"i18next-browser-languagedetector": "^6.1.4",
|
||||
"owasp-password-strength-test": "^1.3.0",
|
||||
"react": "^18.2.0",
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
"testcontainers": "^8.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types-support": "^8.12.2",
|
||||
"@polkadot/types-support": "^8.13.1",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"tsconfig-paths": "^4.0.0"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user