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

pull from source repo #7

Merged
merged 21 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eb56756
Fix wallet connection (#138)
abrzezinski94 Dec 15, 2021
945be39
Vote by switch (#139)
abrzezinski94 Dec 15, 2021
34177d5
Fix uncharted realm navigation (#140)
SebastianBor Dec 15, 2021
dcb5d6e
fix: import WalletAdapter from wallet-adapter-base lib
johnrees Dec 15, 2021
605ae72
rename types.tsx to types.ts and import type
johnrees Dec 15, 2021
9b33cdf
Merge pull request #141 from johnrees/fix-walletadapter-import
mschneider Dec 15, 2021
60396c0
test: fix `yarn test` (#142)
johnrees Dec 15, 2021
0eb810c
Feature: Proposals Actions (#133)
Mury12 Dec 15, 2021
61e6245
vote by label change
abrzezinski94 Dec 16, 2021
35e3747
fix: remove `ProgramVersion` circular dependency
johnrees Dec 16, 2021
06207f5
Merge pull request #145 from johnrees/circular-deps
SebastianBor Dec 17, 2021
93ae537
Merge pull request #144 from abrzezinski94/fix/vote-by-council-label
SebastianBor Dec 17, 2021
a3e2288
install tsconfig-paths & put ts-node config in tsconfig.json
johnrees Dec 17, 2021
dbe8822
Setup MonkeDAO (#148)
SebastianBor Dec 17, 2021
56bf3cc
move `ConnectionContext` out of tsx file
johnrees Dec 17, 2021
a54a6a8
update eslint deps to suppress `yarn test-all` warning
johnrees Dec 17, 2021
6532c89
Fix cancel button and ux issues (#136)
Dec 17, 2021
cb647c9
globally disable `@typescript-eslint/no-non-null-assertion` rule (#150)
johnrees Dec 18, 2021
c03f8e3
Merge pull request #149 from solana-labs/jr/fix-notifier
SebastianBor Dec 18, 2021
b084f1b
fix: FAFD logo
SebastianBor Dec 18, 2021
0a77b3e
Merge pull request #151 from SebastianBor/fix-fafd-logo
SebastianBor Dec 18, 2021
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@typescript-eslint/indent": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-use-before-define": 0,
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
pull_request:
types: [opened, synchronize]

jobs:
test:
name: yarn test-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
cache: yarn
- run: yarn install
- run: yarn test-all
2 changes: 1 addition & 1 deletion @types/types.tsx → @types/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccountInfo, PublicKey } from '@solana/web3.js'
import type { AccountInfo, PublicKey } from '@solana/web3.js'

export interface EndpointInfo {
name: string
Expand Down
37 changes: 37 additions & 0 deletions actions/cancelProposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Account, Transaction, TransactionInstruction } from '@solana/web3.js'

import { RpcContext } from '../models/core/api'
import { Proposal } from '@models/accounts'
import { ParsedAccount } from 'models/core/accounts'
import { sendTransaction } from 'utils/send'
import { withCancelProposal } from '@models/withCancelProposal'

export const cancelProposal = async (
{ connection, wallet, programId, walletPubkey }: RpcContext,
proposal: ParsedAccount<Proposal> | undefined
) => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []
const governanceAuthority = walletPubkey

withCancelProposal(
instructions,
programId,
proposal!.pubkey,
proposal!.info.tokenOwnerRecord,
governanceAuthority
)

const transaction = new Transaction({ feePayer: walletPubkey })

transaction.add(...instructions)

await sendTransaction({
transaction,
wallet,
connection,
signers,
sendingMessage: 'Cancelling proposal',
successMessage: 'Proposal cancelled',
})
}
3 changes: 2 additions & 1 deletion actions/createProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const createProposal = async (
signatory,
payer
)

for (const [index, instruction] of instructionsData
.filter((x) => x.data)
.entries()) {
Expand All @@ -84,7 +85,7 @@ export const createProposal = async (
}

if (!isDraft) {
await withSignOffProposal(
withSignOffProposal(
instructions,
programId,
proposalAddress,
Expand Down
39 changes: 39 additions & 0 deletions actions/executeInstruction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Account, Transaction, TransactionInstruction } from '@solana/web3.js'

import { Proposal, ProposalInstruction } from '../models/accounts'

import { withExecuteInstruction } from '../models/withExecuteInstruction'
import { RpcContext } from '@models/core/api'
import { ParsedAccount } from '@models/core/accounts'
import { sendTransaction } from '@utils/send'

export const executeInstruction = async (
{ connection, wallet, programId }: RpcContext,
proposal: ParsedAccount<Proposal>,
instruction: ParsedAccount<ProposalInstruction>
) => {
const signers: Account[] = []
const instructions: TransactionInstruction[] = []

await withExecuteInstruction(
instructions,
programId,
proposal.info.governance,
proposal.pubkey,
instruction.pubkey,
instruction.info.instruction
)

const transaction = new Transaction()

transaction.add(...instructions)

await sendTransaction({
transaction,
wallet,
connection,
signers,
sendingMessage: 'Executing instruction',
successMessage: 'Execution finalized',
})
}
43 changes: 43 additions & 0 deletions actions/finalizeVotes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ParsedAccount } from '@models/core/accounts'
import { RpcContext } from '@models/core/api'
import {
Account,
PublicKey,
Transaction,
TransactionInstruction,
} from '@solana/web3.js'
import { sendTransaction } from '@utils/send'
import { Proposal } from '../models/accounts'
import { withFinalizeVote } from '../models/withFinalizeVote'

export const finalizeVote = async (
{ connection, wallet, programId }: RpcContext,
realm: PublicKey,
proposal: ParsedAccount<Proposal>
) => {
const signers: Account[] = []
const instructions: TransactionInstruction[] = []

withFinalizeVote(
instructions,
programId,
realm,
proposal.info.governance,
proposal.pubkey,
proposal.info.tokenOwnerRecord,
proposal.info.governingTokenMint
)

const transaction = new Transaction()

transaction.add(...instructions)

await sendTransaction({
transaction,
wallet,
connection,
signers,
sendingMessage: 'Finalizing votes',
successMessage: 'Votes finalized',
})
}
46 changes: 46 additions & 0 deletions actions/flagInstructionError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
Account,
PublicKey,
Transaction,
TransactionInstruction,
} from '@solana/web3.js'

import { Proposal } from '../models/accounts'

import { withFlagInstructionError } from '../models/withFlagInstructionError'
import { RpcContext } from '../models/core/api'
import { ParsedAccount } from '@models/core/accounts'
import { sendTransaction } from '@utils/send'

export const flagInstructionError = async (
{ connection, wallet, programId, walletPubkey }: RpcContext,
proposal: ParsedAccount<Proposal>,
proposalInstruction: PublicKey
) => {
const governanceAuthority = walletPubkey

const signers: Account[] = []
const instructions: TransactionInstruction[] = []

withFlagInstructionError(
instructions,
programId,
proposal.pubkey,
proposal.info.tokenOwnerRecord,
governanceAuthority,
proposalInstruction
)

const transaction = new Transaction({ feePayer: walletPubkey })

transaction.add(...instructions)

await sendTransaction({
transaction,
connection,
wallet,
signers,
sendingMessage: 'Flagging instruction as broken',
successMessage: 'Instruction flagged as broken',
})
}
36 changes: 36 additions & 0 deletions actions/signOffProposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Account, Transaction, TransactionInstruction } from '@solana/web3.js'

import { RpcContext } from '../models/core/api'
import { SignatoryRecord } from '@models/accounts'
import { ParsedAccount } from 'models/core/accounts'
import { sendTransaction } from 'utils/send'
import { withSignOffProposal } from '@models/withSignOffProposal'

export const signOffProposal = async (
{ connection, wallet, programId, walletPubkey }: RpcContext,
signatoryRecord: ParsedAccount<SignatoryRecord>
) => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []

withSignOffProposal(
instructions,
programId,
signatoryRecord?.info.proposal,
signatoryRecord?.pubkey,
walletPubkey
)

const transaction = new Transaction()

transaction.add(...instructions)

await sendTransaction({
transaction,
wallet,
connection,
signers,
sendingMessage: 'Signing off proposal',
successMessage: 'Proposal signed off',
})
}
77 changes: 77 additions & 0 deletions components/CancelProposalModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react'
import { RpcContext } from 'models/core/api'
import useWalletStore from 'stores/useWalletStore'
import useRealm from 'hooks/useRealm'
import Button, { SecondaryButton } from '@components/Button'
import { notify } from 'utils/notifications'
import Modal from '@components/Modal'
import { Proposal } from 'models/accounts'
import { ParsedAccount } from 'models/core/accounts'
import { cancelProposal } from 'actions/cancelProposal'
import useProposal from '@hooks/useProposal'

type CancelProposalModalProps = {
onClose: () => void
isOpen: boolean
}

const CancelProposalModal = ({ onClose, isOpen }: CancelProposalModalProps) => {
const wallet = useWalletStore((s) => s.current)
const connection = useWalletStore((s) => s.connection)
const fetchRealm = useWalletStore((s) => s.actions.fetchRealm)
const { realmInfo } = useRealm()
const { proposal } = useProposal()

const handleCancelProposal = async (
proposal: ParsedAccount<Proposal> | undefined
) => {
try {
if (proposal && realmInfo) {
const rpcContext = new RpcContext(
proposal.account.owner,
realmInfo?.programVersion,
wallet,
connection.current,
connection.endpoint
)

await cancelProposal(rpcContext, proposal)

onClose()

await fetchRealm(realmInfo.programId, realmInfo.realmId)
}
} catch (error) {
notify({
type: 'error',
message: `Error: Could not cancel proposal.`,
})

onClose()

console.log('error cancelling proposal', error)
}
}

return (
<Modal onClose={onClose} isOpen={isOpen}>
<h2>Cancel proposal</h2>

<p className="text-left mt-5 mb-8">
Do you want to cancel this proposal?
</p>

<div className="flex items-center justify-center">
<SecondaryButton className="w-44 mr-4" onClick={onClose}>
No
</SecondaryButton>

<Button className="w-44" onClick={() => handleCancelProposal(proposal)}>
Yes, cancel
</Button>
</div>
</Modal>
)
}

export default CancelProposalModal
Loading