Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Add support for the decrease council budget proposal #4816

Merged
merged 7 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
BRANCH=$(echo -n '${{ env.LABEL }}' | cut -d ':' -f2-)
fi

URL_BRANCH=$(echo -n "$BRANCH" | tr -d '#' | tr -c '[:alnum:]' '-' | tr '[:upper:]' '[:lower:]')
URL_BRANCH=$(echo -n "$BRANCH" | sed 's/\//-/' | tr -d '/#' | tr -c '[:alnum:]' '-' | tr '[:upper:]' '[:lower:]')
SUBDOMAIN="${{ env.PROJECT }}-${{ env.PREFIX }}-$URL_BRANCH-joystream"

if [ ${#SUBDOMAIN} -gt 63 ]; then
Expand Down
526 changes: 526 additions & 0 deletions .yarn/patches/@joystream-types-npm-4.3.0-542438a0b6.patch

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/parser": "~7.21.0",
"@babel/traverse": "~7.21.0",
"@babel/types": "~7.21.0",
"@joystream/types": "4.3.0",
"@joystream/types": "patch:@joystream/types@npm%3A4.3.0#./.yarn/patches/@joystream-types-npm-4.3.0-542438a0b6.patch",
"@polkadot/api": "10.1.4",
"@polkadot/api-contract": "10.1.4",
"@polkadot/api-derive": "10.1.4",
Expand Down
172 changes: 172 additions & 0 deletions packages/server/src/common/queries/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ enum EventTypeOptions {
CommentPinnedEvent
CommentReactedEvent
CommentTextUpdatedEvent
CouncilBudgetDecreasedEvent
CouncilBudgetFundedEvent
CouncilorRewardUpdatedEvent
EnglishAuctionSettledEvent
Expand Down Expand Up @@ -2590,6 +2591,7 @@ union ProposalDetails =
| UpdateChannelPayoutsProposalDetails
| UpdatePalletFrozenStatusProposalDetails
| UpdateGlobalNftLimitProposalDetails
| DecreaseCouncilBudgetProposalDetails

union ProposalStatus =
ProposalStatusDeciding
Expand Down Expand Up @@ -2976,6 +2978,13 @@ type DataObjectTypeVideoThumbnail {
video: Video
}

type DecreaseCouncilBudgetProposalDetails {
"""
Proposed amount of token to burn
"""
amount: BigInt!
}

type DecreaseWorkingGroupLeadStakeProposalDetails {
"""
The lead that should be affected
Expand Down Expand Up @@ -5261,6 +5270,17 @@ type CommentConnection {
pageInfo: PageInfo!
}

type CouncilBudgetDecreasedEventEdge {
node: CouncilBudgetDecreasedEvent!
cursor: String!
}

type CouncilBudgetDecreasedEventConnection {
totalCount: Int!
edges: [CouncilBudgetDecreasedEventEdge!]!
pageInfo: PageInfo!
}

type CouncilBudgetFundedEventEdge {
node: CouncilBudgetFundedEvent!
cursor: String!
Expand Down Expand Up @@ -22796,6 +22816,81 @@ input ChannelVisibilitySetByModeratorEventUpdateInput {
rationale: String
}

input CouncilBudgetDecreasedEventWhereInput {
id_eq: ID
id_in: [ID!]
createdAt_eq: DateTime
createdAt_lt: DateTime
createdAt_lte: DateTime
createdAt_gt: DateTime
createdAt_gte: DateTime
createdById_eq: ID
createdById_in: [ID!]
updatedAt_eq: DateTime
updatedAt_lt: DateTime
updatedAt_lte: DateTime
updatedAt_gt: DateTime
updatedAt_gte: DateTime
updatedById_eq: ID
updatedById_in: [ID!]
deletedAt_all: Boolean
deletedAt_eq: DateTime
deletedAt_lt: DateTime
deletedAt_lte: DateTime
deletedAt_gt: DateTime
deletedAt_gte: DateTime
deletedById_eq: ID
deletedById_in: [ID!]
inExtrinsic_eq: String
inExtrinsic_contains: String
inExtrinsic_startsWith: String
inExtrinsic_endsWith: String
inExtrinsic_in: [String!]
inBlock_eq: Int
inBlock_gt: Int
inBlock_gte: Int
inBlock_lt: Int
inBlock_lte: Int
inBlock_in: [Int!]
network_eq: Network
network_in: [Network!]
indexInBlock_eq: Int
indexInBlock_gt: Int
indexInBlock_gte: Int
indexInBlock_lt: Int
indexInBlock_lte: Int
indexInBlock_in: [Int!]
amount_eq: BigInt
amount_gt: BigInt
amount_gte: BigInt
amount_lt: BigInt
amount_lte: BigInt
amount_in: [BigInt!]
AND: [CouncilBudgetDecreasedEventWhereInput!]
OR: [CouncilBudgetDecreasedEventWhereInput!]
NOT: [CouncilBudgetDecreasedEventWhereInput!]
}

input CouncilBudgetDecreasedEventWhereUniqueInput {
id: ID!
}

input CouncilBudgetDecreasedEventCreateInput {
inExtrinsic: String
inBlock: Float!
network: Network!
indexInBlock: Float!
amount: String!
}

input CouncilBudgetDecreasedEventUpdateInput {
inExtrinsic: String
inBlock: Float
network: Network
indexInBlock: Float
amount: String
}

input CouncilBudgetFundedEventWhereInput {
id_eq: ID
id_in: [ID!]
Expand Down Expand Up @@ -29529,6 +29624,47 @@ type BudgetRefillPlannedEvent implements Event & BaseGraphQLObject {
nextRefillInBlock: Int!
}

type CouncilBudgetDecreasedEvent implements Event & BaseGraphQLObject {
id: ID!
createdAt: DateTime!
createdById: ID!
updatedAt: DateTime
updatedById: ID
deletedAt: DateTime
deletedById: ID
version: Int!

"""
Hash of the extrinsic which caused the event to be emitted
"""
inExtrinsic: String

"""
Blocknumber of the block in which the event was emitted.
"""
inBlock: Int!

"""
Network the block was produced in
"""
network: Network!

"""
Index of event in block from which it was emitted.
"""
indexInBlock: Int!

"""
Filtering options for interface implementers
"""
type: EventTypeOptions

"""
Funding amount.
"""
amount: BigInt!
}

type CouncilBudgetFundedEvent implements Event & BaseGraphQLObject {
id: ID!
createdAt: DateTime!
Expand Down Expand Up @@ -31193,6 +31329,23 @@ type Query {
where: CommentWhereInput
orderBy: [CommentOrderByInput!]
): CommentConnection!
councilBudgetDecreasedEvents(
offset: Int
limit: Int = 50
where: CouncilBudgetDecreasedEventWhereInput
orderBy: [CouncilBudgetDecreasedEventOrderByInput!]
): [CouncilBudgetDecreasedEvent!]!
councilBudgetDecreasedEventByUniqueInput(
where: CouncilBudgetDecreasedEventWhereUniqueInput!
): CouncilBudgetDecreasedEvent
councilBudgetDecreasedEventsConnection(
first: Int
after: String
last: Int
before: String
where: CouncilBudgetDecreasedEventWhereInput
orderBy: [CouncilBudgetDecreasedEventOrderByInput!]
): CouncilBudgetDecreasedEventConnection!
councilBudgetFundedEvents(
offset: Int
limit: Int = 50
Expand Down Expand Up @@ -34940,6 +35093,25 @@ enum CommentOrderByInput {
isEdited_DESC
}

enum CouncilBudgetDecreasedEventOrderByInput {
createdAt_ASC
createdAt_DESC
updatedAt_ASC
updatedAt_DESC
deletedAt_ASC
deletedAt_DESC
inExtrinsic_ASC
inExtrinsic_DESC
inBlock_ASC
inBlock_DESC
network_ASC
network_DESC
indexInBlock_ASC
indexInBlock_DESC
amount_ASC
amount_DESC
}

enum CouncilBudgetFundedEventOrderByInput {
createdAt_ASC
createdAt_DESC
Expand Down
34 changes: 34 additions & 0 deletions packages/ui/src/app/pages/Proposals/CurrentProposals.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1543,3 +1543,37 @@ export const SpecificParametersRuntimeUpgrade: Story = {
})
}),
}

export const SpecificParametersDecreaseCouncilBudget: Story = {
parameters: {
councilBudget: joy(500),
},
play: specificParametersTest('Decrease Council Budget', async ({ args, createProposal, modal, step }) => {
await createProposal(async () => {
const nextButton = getButtonByText(modal, 'Create proposal')
expect(nextButton).toBeDisabled()

const amountField = await modal.findByLabelText('Amount')

// Invalid price set to 0
await userEvent.type(amountField, '0')
expect(await modal.findByText('Amount must be greater than zero'))
expect(nextButton).toBeDisabled()

// Invalid price set to 0
await userEvent.clear(amountField)
await userEvent.type(amountField, '600')
expect(await modal.findByText('The current council budget is 500JOY'))
expect(nextButton).toBeDisabled()

// Valid
await userEvent.clear(amountField)
await userEvent.type(amountField, '8')
})

await step('Transaction parameters', () => {
const [, , specificParameters] = args.onCreateProposal.mock.calls.at(-1)
expect(specificParameters.toJSON()).toEqual({ decreaseCouncilBudget: 8_0000000000 })
})
}),
}
17 changes: 11 additions & 6 deletions packages/ui/src/app/pages/Proposals/ProposalPreview.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,6 @@ export default {
// ProposalPreview
// ----------------------------------------------------------------------------

export const AmendConstitution: Story = {
args: { type: 'AmendConstitutionProposalDetails', constitutionality: 2 },
parameters: {
statuses: ['ProposalStatusDeciding', 'ProposalStatusDormant', 'ProposalStatusDeciding'] satisfies ProposalStatus[],
},
}
export const CancelWorkingGroupLeadOpening: Story = {
args: { type: 'CancelWorkingGroupLeadOpeningProposalDetails' },
}
Expand Down Expand Up @@ -302,9 +296,20 @@ export const UpdatePalletFrozenStatus: Story = {
export const UpdateWorkingGroupBudget: Story = {
args: { type: 'UpdateWorkingGroupBudgetProposalDetails' },
}
export const DecreaseCouncilBudget: Story = {
args: { type: 'DecreaseCouncilBudgetProposalDetails' },
}

// Disabled proposals
export const Veto: Story = {
args: { type: 'VetoProposalDetails' },
}
export const AmendConstitution: Story = {
args: { type: 'AmendConstitutionProposalDetails', constitutionality: 2 },
parameters: {
statuses: ['ProposalStatusDeciding', 'ProposalStatusDormant', 'ProposalStatusDeciding'] satisfies ProposalStatus[],
},
}

// ----------------------------------------------------------------------------
// VoteForProposalModal
Expand Down
Loading
Loading