Skip to content

Commit

Permalink
refactor staking app
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Nov 28, 2023
1 parent c6ea11b commit d908096
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/extensions/staking/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const getDelegationProvidersRequest = async (provider: ApiNetworkProvider
(r: any) =>
({
...r,
contract: r.provider,
stake: new BigNumber(res.stake || 0),
delegationCap: new BigNumber(res.delegationCap || 0),
} as DelegationProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export const DelegationsSection = (props: Props) => (
)

const findProvider = (providers: DelegationProvider[], contract: string) =>
providers.find((provider) => provider.provider === contract) || null
providers.find((provider) => provider.contract === contract) || null
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const _DelegateProviderList = (props: Props) => (
<tbody className="block divide-y divide-gray-200 dark:divide-gray-700 max-h-80 overflow-y-auto">
{props.providers.map((provider) => (
<tr
key={provider.provider}
key={provider.contract}
role="button"
onClick={() => props.onSelect(provider)}
className="flex w-full hover:bg-gray-200 dark:hover:bg-gray-700"
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/staking/src/delegation/_DelegationsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export const _DelegationsRow = (props: Props) => {

const handleRewardClaim = (e: SyntheticEvent) => {
e.stopPropagation()
app.requestProposalAction(props.provider!.provider, Config.Endpoints.ClaimRewards, 0, [], [])
app.requestProposalAction(props.provider!.contract, Config.Endpoints.ClaimRewards, 0, [], [])
}

const handleRewardStake = (e: SyntheticEvent) => {
e.stopPropagation()
app.requestProposalAction(props.provider!.provider, Config.Endpoints.ReDelegateRewards, 0, [], [])
app.requestProposalAction(props.provider!.contract, Config.Endpoints.ReDelegateRewards, 0, [], [])
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/staking/src/delegation/_Delegator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const _Delegator = (props: Props) => {
app.showToast('Insufficient balance', 'error')
return
}
app.requestProposalAction(props.provider.provider, Config.Endpoints.Delegate, valueBig, [], [])
app.requestProposalAction(props.provider.contract, Config.Endpoints.Delegate, valueBig, [], [])
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/staking/src/delegation/_Withdrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const _Withdrawer = (props: Props) => {
app.showToast('Can not unstake more than is staked', 'error')
return
}
app.requestProposalAction(props.provider.provider, Config.Endpoints.UnDelegate, 0, [valueBig], [])
app.requestProposalAction(props.provider.contract, Config.Endpoints.UnDelegate, 0, [valueBig], [])
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/staking/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type DelegationProvider = {
stake: BigNumber
topUp: string
locked: string
provider: string
contract: string
owner: string
featured: boolean
serviceFee: number
Expand Down

0 comments on commit d908096

Please sign in to comment.