Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump polkadot-js deps #10106

Merged
merged 7 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,34 @@
"source-map-explorer": "^2.5.3"
},
"resolutions": {
"@polkadot/api": "^10.11.1",
"@polkadot/api-augment": "^10.11.1",
"@polkadot/api-base": "^10.11.1",
"@polkadot/api-contract": "^10.11.1",
"@polkadot/api-derive": "^10.11.1",
"@polkadot/hw-ledger": "^12.6.1",
"@polkadot/keyring": "^12.6.1",
"@polkadot/networks": "^12.6.1",
"@polkadot/api": "^10.11.2",
"@polkadot/api-augment": "^10.11.2",
"@polkadot/api-base": "^10.11.2",
"@polkadot/api-contract": "^10.11.2",
"@polkadot/api-derive": "^10.11.2",
"@polkadot/hw-ledger": "^12.6.2",
"@polkadot/keyring": "^12.6.2",
"@polkadot/networks": "^12.6.2",
"@polkadot/phishing": "^0.22.1",
"@polkadot/rpc-augment": "^10.11.1",
"@polkadot/rpc-core": "^10.11.1",
"@polkadot/rpc-provider": "^10.11.1",
"@polkadot/types": "^10.11.1",
"@polkadot/types-augment": "^10.11.1",
"@polkadot/types-codec": "^10.11.1",
"@polkadot/types-create": "^10.11.1",
"@polkadot/types-known": "^10.11.1",
"@polkadot/types-support": "^10.11.1",
"@polkadot/util": "^12.6.1",
"@polkadot/util-crypto": "^12.6.1",
"@polkadot/wasm-crypto": "^7.3.1",
"@polkadot/x-bigint": "^12.6.1",
"@polkadot/x-fetch": "^12.6.1",
"@polkadot/x-global": "^12.6.1",
"@polkadot/x-randomvalues": "^12.6.1",
"@polkadot/x-textdecoder": "^12.6.1",
"@polkadot/x-textencoder": "^12.6.1",
"@polkadot/x-ws": "^12.6.1",
"typescript": "^5.2.2"
"@polkadot/rpc-augment": "^10.11.2",
"@polkadot/rpc-core": "^10.11.2",
"@polkadot/rpc-provider": "^10.11.2",
"@polkadot/types": "^10.11.2",
"@polkadot/types-augment": "^10.11.2",
"@polkadot/types-codec": "^10.11.2",
"@polkadot/types-create": "^10.11.2",
"@polkadot/types-known": "^10.11.2",
"@polkadot/types-support": "^10.11.2",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@polkadot/wasm-crypto": "^7.3.2",
"@polkadot/x-bigint": "^12.6.2",
"@polkadot/x-fetch": "^12.6.2",
"@polkadot/x-global": "^12.6.2",
"@polkadot/x-randomvalues": "^12.6.2",
"@polkadot/x-textdecoder": "^12.6.2",
"@polkadot/x-textencoder": "^12.6.2",
"@polkadot/x-ws": "^12.6.2",
"typescript": "^5.3.3"
}
}
16 changes: 8 additions & 8 deletions packages/apps-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@
"@peaqnetwork/type-definitions": "0.0.4",
"@pendulum-chain/type-definitions": "0.3.7",
"@phala/typedefs": "0.2.33",
"@polkadot/api": "^10.11.1",
"@polkadot/api-derive": "^10.11.1",
"@polkadot/networks": "^12.6.1",
"@polkadot/api": "^10.11.2",
"@polkadot/api-derive": "^10.11.2",
"@polkadot/networks": "^12.6.2",
"@polkadot/react-identicon": "^3.6.4",
"@polkadot/types": "^10.11.1",
"@polkadot/types-codec": "^10.11.1",
"@polkadot/util": "^12.6.1",
"@polkadot/types": "^10.11.2",
"@polkadot/types-codec": "^10.11.2",
"@polkadot/util": "^12.6.2",
"@polkadot/wasm-util": "^7.3.2",
"@polkadot/x-fetch": "^12.6.1",
"@polkadot/x-ws": "^12.6.1",
"@polkadot/x-fetch": "^12.6.2",
"@polkadot/x-ws": "^12.6.2",
"@polymeshassociation/polymesh-types": "5.5.2",
"@snowfork/snowbridge-types": "0.2.7",
"@sora-substrate/type-definitions": "1.20.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/page-accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"type": "module",
"version": "0.133.2-27-x",
"dependencies": {
"@polkadot/hw-ledger": "^12.6.1",
"@polkadot/hw-ledger": "^12.6.2",
"@polkadot/phishing": "^0.22.1",
"@polkadot/react-components": "^0.133.2-27-x",
"@polkadot/react-hooks": "^0.133.2-27-x",
"@polkadot/util": "^12.6.1",
"@polkadot/vanitygen": "^0.56.1",
"@polkadot/util": "^12.6.2",
"@polkadot/vanitygen": "^0.56.2",
"detect-browser": "^5.3.0",
"file-saver": "^2.0.5"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/page-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "module",
"version": "0.133.2-27-x",
"dependencies": {
"@polkadot/api-contract": "^10.11.1",
"@polkadot/api-contract": "^10.11.2",
"eventemitter3": "^5.0.1"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import type { DeriveBalancesAll } from '@polkadot/api-derive/types';
import type { Option } from '@polkadot/types';
import type { AccountId, StakingLedger } from '@polkadot/types/interfaces';
import type { AccountId } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';

import React, { useEffect, useState } from 'react';

Expand Down Expand Up @@ -32,7 +33,7 @@ const OPT_BOND = {
};

const OPT_STASH = {
transform: (value: Option<StakingLedger>): string | null =>
transform: (value: Option<PalletStakingStakingLedger>): string | null =>
value.isSome
? value.unwrap().stash.toString()
: null
Expand Down
4 changes: 2 additions & 2 deletions packages/page-staking/src/Actions/Account/Unbond.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { StakingLedger } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';

import React, { useState } from 'react';
Expand All @@ -18,7 +18,7 @@ import useUnbondDuration from '../useUnbondDuration.js';
interface Props {
controllerId?: string | null;
onClose: () => void;
stakingLedger?: StakingLedger;
stakingLedger?: PalletStakingStakingLedger;
stashId: string;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/page-staking/src/Actions/partials/Nominate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { u32 } from '@polkadot/types';
import type { BN } from '@polkadot/util';
import type { SortedTargets } from '../../types.js';
import type { NominateInfo } from './types.js';
Expand Down Expand Up @@ -59,9 +60,9 @@ function Nominate ({ className = '', controllerId, nominating, onChange, poolId,
}, [api, onChange, poolId, selected]);

const maxNominations = api.consts.staking.maxNominatorRewardedPerValidator
? api.consts.staking.maxNominatorRewardedPerValidator.toNumber()
? (api.consts.staking.maxNominatorRewardedPerValidator as u32).toNumber()
: api.consts.staking.maxNominations
? (api.consts.staking.maxNominations as unknown as BN).toNumber()
? (api.consts.staking.maxNominations as u32).toNumber()
: MAX_NOMINATIONS;

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/page-staking/src/Actions/useInactives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { ApiPromise } from '@polkadot/api';
import type { QueryableStorageMultiArg } from '@polkadot/api/types';
import type { DeriveSessionIndexes } from '@polkadot/api-derive/types';
import type { Option } from '@polkadot/types';
import type { Option, u32 } from '@polkadot/types';
import type { EraIndex, Exposure, Nominations, SlashingSpans } from '@polkadot/types/interfaces';

import { useEffect, useState } from 'react';
Expand All @@ -21,7 +21,7 @@ interface Inactives {
}

function extractState (api: ApiPromise, stashId: string, slashes: Option<SlashingSpans>[], nominees: string[], { activeEra }: DeriveSessionIndexes, submittedIn: EraIndex, exposures: Exposure[]): Inactives {
const max = api.consts.staking?.maxNominatorRewardedPerValidator;
const max = api.consts.staking?.maxNominatorRewardedPerValidator as u32;

// chilled
// NOTE With the introduction of the SlashReported event,
Expand Down
4 changes: 3 additions & 1 deletion packages/page-staking/src/MaxBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { u32 } from '@polkadot/types';

import React from 'react';

import { Badge } from '@polkadot/react-components';
Expand All @@ -13,7 +15,7 @@ interface Props {
function MaxBadge ({ numNominators }: Props): React.ReactElement<Props> | null {
const { api } = useApi();

const max = api.consts.staking?.maxNominatorRewardedPerValidator;
const max = api.consts.staking?.maxNominatorRewardedPerValidator as u32;

if (!numNominators || !max || max.gten(numNominators)) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion packages/page-staking/src/Payouts/PayButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import type { ApiPromise } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { u32 } from '@polkadot/types';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PayoutValidator } from './types.js';

Expand Down Expand Up @@ -61,7 +62,7 @@ function PayButton ({ className, isAll, isDisabled, payout }: Props): React.Reac
const [txs, setTxs] = useState<SubmittableExtrinsic<'promise'>[] | null>(null);
const batchOpts = useMemo(
() => ({
max: 36 * 64 / (api.consts.staking.maxNominatorRewardedPerValidator?.toNumber() || 64)
max: 36 * 64 / ((api.consts.staking.maxNominatorRewardedPerValidator as u32)?.toNumber() || 64)
}),
[api]
);
Expand Down
2 changes: 1 addition & 1 deletion packages/page-staking/src/Targets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function Targets ({ className = '', isInElection, nominatedBy, ownStashes, targe
daysPayout,
isBabe: !!api.consts.babe,
isQueryFiltered,
maxPaid: api.consts.staking?.maxNominatorRewardedPerValidator
maxPaid: api.consts.staking?.maxNominatorRewardedPerValidator as u32
}),
[api, daysPayout, isQueryFiltered, toggles]
);
Expand Down
3 changes: 2 additions & 1 deletion packages/page-staking/src/Validators/Address/StakeOther.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { u32 } from '@polkadot/types';
import type { NominatorValue } from './types.js';

import React, { useMemo } from 'react';
Expand Down Expand Up @@ -63,7 +64,7 @@ function StakeOther ({ nominators, stakeOther }: Props): React.ReactElement<Prop
const { api } = useApi();

const [rewarded, rewardedTotal, unrewarded, unrewardedTotal] = useMemo(
() => extractTotals(api.consts.staking?.maxNominatorRewardedPerValidator, nominators, stakeOther),
() => extractTotals(api.consts.staking?.maxNominatorRewardedPerValidator as u32, nominators, stakeOther),
[api, nominators, stakeOther]
);

Expand Down
19 changes: 15 additions & 4 deletions packages/page-staking/src/useSortedTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import type { ApiPromise } from '@polkadot/api';
import type { DeriveSessionInfo, DeriveStakingElected, DeriveStakingWaiting } from '@polkadot/api-derive/types';
import type { Inflation } from '@polkadot/react-hooks/types';
import type { Option, u32 } from '@polkadot/types';
import type { Option, u32, Vec } from '@polkadot/types';
import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type { SortedTargets, TargetSortBy, ValidatorInfo } from './types.js';

import { useMemo } from 'react';
Expand All @@ -30,6 +31,10 @@ interface MultiResult {
totalIssuance?: BN;
}

interface OldLedger {
claimedRewards: Vec<u32>;
}

const EMPTY_PARTIAL: Partial<SortedTargets> = {};
const DEFAULT_FLAGS_ELECTED = { withController: true, withExposure: true, withPrefs: true };
const DEFAULT_FLAGS_WAITING = { withController: true, withPrefs: true };
Expand Down Expand Up @@ -63,6 +68,10 @@ const OPT_MULTI = {
})
};

function getLegacyRewards (ledger: PalletStakingStakingLedger): u32[] {
return ledger.legacyClaimedRewards || (ledger as unknown as OldLedger).claimedRewards || [];
}

function mapIndex (mapBy: TargetSortBy): (info: ValidatorInfo, index: number) => ValidatorInfo {
return (info, index): ValidatorInfo => {
info[mapBy] = index + 1;
Expand Down Expand Up @@ -147,8 +156,10 @@ function extractSingle (api: ApiPromise, allAccounts: string[], derive: DeriveSt
}, BN_ZERO);

const key = accountId.toString();
const rewards = getLegacyRewards(stakingLedger);

const lastEraPayout = !lastEra.isZero()
? stakingLedger.claimedRewards[stakingLedger.claimedRewards.length - 1]
? rewards[rewards.length - 1]
: undefined;

list[i] = {
Expand All @@ -171,15 +182,15 @@ function extractSingle (api: ApiPromise, allAccounts: string[], derive: DeriveSt
return isNominating || allAccounts.includes(nominator);
}, allAccounts.includes(key)),
key,
knownLength: activeEra.sub(stakingLedger.claimedRewards[0] || activeEra),
knownLength: activeEra.sub(rewards[0] || activeEra),
// only use if it is more recent than historyDepth
lastPayout: earliestEra && lastEraPayout && lastEraPayout.gt(earliestEra) && !sessionLength.eq(BN_ONE)
? lastEra.sub(lastEraPayout).mul(eraLength)
: undefined,
minNominated,
numNominators: (exposure.others || []).length,
numRecentPayouts: earliestEra
? stakingLedger.claimedRewards.filter((era) => era.gte(earliestEra)).length
? rewards.filter((era) => era.gte(earliestEra)).length
: 0,
rankBondOther: 0,
rankBondOwn: 0,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"path": false
},
"dependencies": {
"@polkadot/api": "^10.11.1",
"@polkadot/api": "^10.11.2",
"@polkadot/extension-compat-metamask": "^0.46.6",
"@polkadot/extension-dapp": "^0.46.6",
"@polkadot/rpc-provider": "^10.11.1",
"@polkadot/rpc-provider": "^10.11.2",
"fflate": "^0.8.1",
"rxjs": "^7.8.1"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@polkadot/keyring": "^12.6.1",
"@polkadot/keyring": "^12.6.2",
"@polkadot/react-api": "^0.133.2-27-x",
"@polkadot/react-identicon": "^3.6.4",
"@polkadot/react-qr": "^3.6.4",
"@polkadot/react-query": "^0.133.2-27-x",
"@polkadot/ui-keyring": "^3.6.4",
"@polkadot/ui-settings": "^3.6.4",
"@polkadot/util": "^12.6.1",
"@polkadot/util-crypto": "^12.6.1",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"chart.js": "^4.4.1",
"chartjs-plugin-annotation": "^3.0.1",
"chartjs-plugin-crosshair": "^1.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"type": "module",
"version": "0.133.2-27-x",
"dependencies": {
"@polkadot/hw-ledger": "^12.6.1",
"@polkadot/hw-ledger-transports": "^12.6.1",
"@polkadot/hw-ledger": "^12.6.2",
"@polkadot/hw-ledger-transports": "^12.6.2",
"is-ipfs": "^8.0.1"
},
"peerDependencies": {
Expand Down
11 changes: 6 additions & 5 deletions packages/react-hooks/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import type { ApiPromise } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { DeriveAccountFlags, DeriveAccountRegistration } from '@polkadot/api-derive/types';
import type { DisplayedJudgement } from '@polkadot/react-components/types';
import type { AccountId, Balance, BlockNumber, Call, Exposure, Hash, RewardDestination, SessionIndex, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { PalletPreimageRequestStatus } from '@polkadot/types/lookup';
import type { u128 } from '@polkadot/types';
import type { AccountId, BlockNumber, Call, Exposure, Hash, RewardDestination, SessionIndex, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { PalletPreimageRequestStatus, PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type { ICompact, IExtrinsic, INumber, Registry } from '@polkadot/types/types';
import type { KeyringJson$Meta } from '@polkadot/ui-keyring/types';
import type { BN } from '@polkadot/util';
Expand Down Expand Up @@ -52,14 +53,14 @@ export interface Inflation {

export interface Slash {
accountId: AccountId;
amount: Balance;
amount: u128;
}

export interface SessionRewards {
blockHash: Hash;
blockNumber: BlockNumber;
isEventsEmpty: boolean;
reward: Balance;
reward: u128;
sessionIndex: SessionIndex;
slashes: Slash[];
}
Expand Down Expand Up @@ -153,7 +154,7 @@ export interface StakerState {
isStashValidating: boolean;
nominating?: string[];
sessionIds: string[];
stakingLedger?: StakingLedger;
stakingLedger?: PalletStakingStakingLedger;
stashId: string;
validatorPrefs?: ValidatorPrefs;
}
Expand Down
Loading