-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Nominator Rewards from Staking API, discontinue Subscan nominat…
…or rewards (#2365)
- Loading branch information
Showing
43 changed files
with
958 additions
and
1,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import { useApi } from 'contexts/Api' | ||
import { useNetwork } from 'contexts/Network' | ||
import { usePayouts } from 'contexts/Payouts' | ||
import { ApolloProvider, client, useUnclaimedRewards } from 'plugin-staking-api' | ||
import { useEffect } from 'react' | ||
|
||
interface Props { | ||
activeAccount: string | ||
} | ||
|
||
const Inner = ({ activeAccount }: Props) => { | ||
const { activeEra } = useApi() | ||
const { network } = useNetwork() | ||
const { setUnclaimedRewards } = usePayouts() | ||
|
||
const { data, loading, error } = useUnclaimedRewards({ | ||
chain: network, | ||
who: activeAccount, | ||
fromEra: Math.max(activeEra.index.minus(1).toNumber(), 0), | ||
}) | ||
|
||
useEffect(() => { | ||
if (!loading && !error && data?.unclaimedRewards) { | ||
setUnclaimedRewards(data?.unclaimedRewards) | ||
} | ||
}, [data?.unclaimedRewards.total]) | ||
|
||
return null | ||
} | ||
|
||
export const StakingApi = (props: Props) => ( | ||
<ApolloProvider client={client}> | ||
<Inner {...props} /> | ||
</ApolloProvider> | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.