This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dab0ac
commit 7a7eaca
Showing
5 changed files
with
72 additions
and
102 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 |
---|---|---|
@@ -1,40 +1,34 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present'; | ||
import { BalanceFetcher } from '~balance/balance-fetcher.interface'; | ||
import { Network } from '~types/network.interface'; | ||
import { VotiumRewardsBalancesHelper } from '../helpers/votium.rewards.balance-helper'; | ||
|
||
import { VotiumClaimableBalancesHelper } from '../helpers/votium.rewards.balance-helper'; | ||
import { VOTIUM_DEFINITION } from '../votium.definition'; | ||
|
||
const network = Network.ETHEREUM_MAINNET; | ||
|
||
@Register.BalanceFetcher(VOTIUM_DEFINITION.id, network) | ||
export class EthereumVotiumBalanceFetcher implements BalanceFetcher { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(VotiumRewardsBalancesHelper) | ||
private readonly rewardsBalancesHelper: VotiumRewardsBalancesHelper, | ||
constructor( | ||
@Inject(VotiumClaimableBalancesHelper) | ||
private readonly rewardsBalancesHelper: VotiumClaimableBalancesHelper, | ||
) {} | ||
|
||
private async getRewardsBalances(address: string) { | ||
private async getRewardsBalances(address: string) { | ||
return this.rewardsBalancesHelper.getBalances({ address }); | ||
} | ||
|
||
async getBalances(address: string) { | ||
const [rewardsBalances] = await Promise.all([ | ||
this.getRewardsBalances(address) | ||
async getBalances(address: string) { | ||
const [rewardsBalances] = await Promise.all([this.getRewardsBalances(address)]); | ||
|
||
return presentBalanceFetcherResponse([ | ||
{ | ||
label: 'Claimable', | ||
assets: rewardsBalances, | ||
}, | ||
]); | ||
const rewards = await Promise.all( | ||
rewardsBalances.map(async (rewardData) => { | ||
return rewardData | ||
}) | ||
); | ||
return presentBalanceFetcherResponse([{ | ||
label: 'Claimable', | ||
assets: rewards, | ||
}]) | ||
} | ||
} |
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
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