Skip to content

Commit

Permalink
🩹 Fix proposal view crashing due to high amounts of JOY on main (#4018)
Browse files Browse the repository at this point in the history
* Fix proposal view crashing due to high amounts of JOY

* Export bn helpers as part of `@common/utils`
  • Loading branch information
thesan authored Jan 5, 2023
1 parent d3fe8a2 commit 7e501b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions packages/ui/src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './utils/bn'

import { Reducer } from './types/helpers'

type Obj = Record<string, any>
Expand Down
27 changes: 14 additions & 13 deletions packages/ui/src/proposals/types/ProposalDetails.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import BN from 'bn.js'

import { KeysOfUnion } from '@/common/types/helpers'
import { asBN } from '@/common/utils'
import { asWorkingGroupName, GroupIdName } from '@/working-groups/types'

import { asMember, Member } from '../../memberships/types'
Expand Down Expand Up @@ -156,7 +157,7 @@ const asFundingRequest: DetailsCast<'FundingRequestProposalDetails'> = (fragment
type: 'fundingRequest',
destinations: fragment.destinationsList?.destinations.map((d) => ({
account: d.account,
amount: new BN(d.amount),
amount: asBN(d.amount),
})),
}
}
Expand All @@ -178,9 +179,9 @@ const asCreateLeadOpening: DetailsCast<'CreateWorkingGroupLeadOpeningProposalDet
return {
type: 'createWorkingGroupLeadOpening',
group,
stakeAmount: new BN(fragment.stakeAmount),
unstakingPeriod: new BN(fragment.unstakingPeriod),
rewardPerBlock: new BN(fragment.rewardPerBlock),
stakeAmount: asBN(fragment.stakeAmount),
unstakingPeriod: asBN(fragment.unstakingPeriod),
rewardPerBlock: asBN(fragment.rewardPerBlock),
openingDescription: fragment.metadata?.description ?? undefined,
}
}
Expand All @@ -194,7 +195,7 @@ const asLeadStakeDetails = (
) => {
return {
...asWorkerDetails(fragment.lead),
amount: new BN(fragment.amount),
amount: asBN(fragment.amount),
}
}

Expand All @@ -219,7 +220,7 @@ const asUpdateWorkingGroupBudget: DetailsCast<'UpdateWorkingGroupBudgetProposalD
fragment
): UpdateGroupBudgetDetails => ({
type: 'updateWorkingGroupBudget',
amount: new BN(fragment.amount),
amount: asBN(fragment.amount ?? 0),
group: {
id: fragment.group?.id as GroupIdName,
name: asWorkingGroupName(fragment.group?.name ?? 'Unknown'),
Expand Down Expand Up @@ -252,29 +253,29 @@ const asSetWorkingGroupLeadReward: DetailsCast<'SetWorkingGroupLeadRewardProposa
): SetWorkingGroupLeadRewardDetails => ({
type: 'setWorkingGroupLeadReward',
...asWorkerDetails(fragment.lead),
amount: new BN(fragment.newRewardPerBlock),
amount: asBN(fragment.newRewardPerBlock),
})

const asTerminateWorkingGroupLead: DetailsCast<'TerminateWorkingGroupLeadProposalDetails'> = (
fragment
): TerminateWorkingGroupLeadDetails => ({
type: 'terminateWorkingGroupLead',
...asWorkerDetails(fragment.lead),
amount: new BN(fragment.slashingAmount ?? 0),
amount: asBN(fragment.slashingAmount ?? 0),
})

const asSetMembershipPrice: DetailsCast<'SetMembershipPriceProposalDetails'> = (
fragment
): SetMembershipPriceDetails => ({
type: 'setMembershipPrice',
amount: new BN(fragment.newPrice),
amount: asBN(fragment.newPrice),
})

const asSetCouncilBudgetIncrement: DetailsCast<'SetCouncilBudgetIncrementProposalDetails'> = (
fragment
): SetCouncilBudgetIncrementDetails => ({
type: 'setCouncilBudgetIncrement',
amount: new BN(fragment.newAmount),
amount: asBN(fragment.newAmount),
})

const asSignal: DetailsCast<'SignalProposalDetails'> = (fragment): SignalDetails => ({
Expand All @@ -292,14 +293,14 @@ const asCancelGroupOpening: DetailsCast<'CancelWorkingGroupLeadOpeningProposalDe

const asSetReferralCut: DetailsCast<'SetReferralCutProposalDetails'> = (fragment): SetReferralCutDetails => ({
type: 'setReferralCut',
amount: new BN(fragment.newReferralCut),
amount: asBN(fragment.newReferralCut),
})

const asSetInitialInvitationBalance: DetailsCast<'SetInitialInvitationBalanceProposalDetails'> = (
fragment
): SetInitialInvitationBalanceDetails => ({
type: 'setInitialInvitationBalance',
amount: new BN(fragment.newInitialInvitationBalance),
amount: asBN(fragment.newInitialInvitationBalance),
})

const asSetInitialInvitationCount: DetailsCast<'SetInitialInvitationCountProposalDetails'> = (
Expand All @@ -313,7 +314,7 @@ const asSetCouncilorReward: DetailsCast<'SetCouncilorRewardProposalDetails'> = (
fragment
): SetCouncilorRewardDetails => ({
type: 'setCouncilorReward',
amount: new BN(fragment.newRewardPerBlock),
amount: asBN(fragment.newRewardPerBlock),
})

const asVeto: DetailsCast<'VetoProposalDetails'> = (fragment): VetoDetails => ({
Expand Down

1 comment on commit 7e501b1

@vercel
Copy link

@vercel vercel bot commented on 7e501b1 Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

dao – ./

dao.joystream.org
dao-joystream.vercel.app
dao-git-main-joystream.vercel.app
pioneerapp.xyz

Please sign in to comment.