polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 354 forks source link

Update api.derive.staking calls with breaking changes #5860

Closed TarikGul closed 6 months ago

TarikGul commented 6 months ago

This updates the staking derives with the updated breaking changes. More info here: 5771 and https://github.com/polkadot-js/apps/issues/10004

Changes

api.derive.staking.ownExposure:

Now takes in a 3rd param page to allow for paged calls, since it internally uses erasStakersPaged. If no page is passed in, it will default to 0.

The output has new additions. This includes exposurePaged, and exposureMeta. The old fields remain since _ownExposures internally is used by other calls that may query a historical range.

export interface DeriveOwnExposure {
  clipped: SpStakingExposure;
  exposurePaged: Option<SpStakingExposurePage>;
  era: EraIndex;
  exposure: SpStakingExposure;
  exposureMeta: Option<SpStakingPagedExposureMetadata>;
}

api.derive.staking.ownExposures:

Now takes in a 4th param page to allow for paged calls, since it internally uses erasStakersPaged. If no page is passed in, it will default to 0.

The output has new additions. This includes exposurePaged, and exposureMeta. The old fields remain since _ownExposures internally is used by other calls that may query a historical range.

export interface DeriveOwnExposure {
  clipped: SpStakingExposure;
  exposurePaged: Option<SpStakingExposurePage>;
  era: EraIndex;
  exposure: SpStakingExposure;
  exposureMeta: Option<SpStakingPagedExposureMetadata>;
}

api.derive.staking.query:

Now takes in a 3rd param page to allow for paged calls, since it internally uses erasStakersPaged. If no page is passed in, it will default to 0.

The output has additions and changes. This includes the addition of the exposureMeta field, and the change of exposure to exposurePaged.

export interface DeriveStakingStash {
  controllerId: AccountId | null;
  exposurePaged: Option<SpStakingExposurePage>;
  exposureMeta: Option<SpStakingPagedExposureMetadata>;
  nominators: AccountId[];
  rewardDestination: PalletStakingRewardDestination | null;
  stashId: AccountId;
  validatorPrefs: PalletStakingValidatorPrefs;
}
export interface DeriveStakingQuery extends DeriveStakingStash {
  accountId: AccountId;
  stakingLedger: PalletStakingStakingLedger;
}

api.derive.staking.nextElected && api.derive.staking.validators:

Just an internal change but nextElected now uses erasStakersPaged.keys to get all validator accounts which is threaded to validators.

Derives to fix:

polkadot-js-bot commented 6 months ago

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.