Skip to content

Commit

Permalink
revert add signatory (#882)
Browse files Browse the repository at this point in the history
* revert add signatory

* fix
  • Loading branch information
abrzezinski94 authored Jul 21, 2022
1 parent d64718d commit 7323716
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
24 changes: 22 additions & 2 deletions actions/createProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TokenOwnerRecord,
VoteType,
withCreateProposal,
getSignatoryRecordAddress,
} from '@solana/spl-governance'
import { RpcContext } from '@solana/spl-governance'
import { withInsertTransaction } from '@solana/spl-governance'
Expand All @@ -29,6 +30,7 @@ import { chunks } from '@utils/helpers'
import { UiInstruction } from '@utils/uiTypes/proposalCreationTypes'
import { VotingClient } from '@utils/uiTypes/VotePlugin'
import { NftVoterClient } from '@solana/governance-program-library'
import { withAddSignatory } from '@solana/spl-governance'

export interface InstructionDataWithHoldUpTime {
data: InstructionData | null
Expand Down Expand Up @@ -132,6 +134,24 @@ export const createProposal = async (
plugin?.voterWeightPk
)

await withAddSignatory(
instructions,
programId,
programVersion,
proposalAddress,
tokenOwnerRecord.pubkey,
governanceAuthority,
signatory,
payer
)

// TODO: Return signatoryRecordAddress from the SDK call
const signatoryRecordAddress = await getSignatoryRecordAddress(
programId,
proposalAddress,
signatory
)

const insertInstructions: TransactionInstruction[] = []
const splitToChunkByDefault = instructionsData.filter(
(x) => x.chunkSplitByDefault
Expand Down Expand Up @@ -180,8 +200,8 @@ export const createProposal = async (
governance,
proposalAddress,
signatory,
undefined,
tokenOwnerRecord.pubkey
signatoryRecordAddress,
undefined
)
}

Expand Down
10 changes: 5 additions & 5 deletions actions/signOffProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const signOffProposal = async (
{ connection, wallet, programId }: RpcContext,
realmPk: PublicKey,
proposal: ProgramAccount<Proposal>,
signatoryRecord: ProgramAccount<SignatoryRecord> | undefined
signatoryRecord: ProgramAccount<SignatoryRecord>
) => {
const instructions: TransactionInstruction[] = []
const signers: Keypair[] = []
Expand All @@ -30,17 +30,17 @@ export const signOffProposal = async (
connection,
programId
)
const hasNoSignatories = proposal.account.signatoriesCount === 0

withSignOffProposal(
instructions,
programId,
programVersion,
realmPk,
proposal.account.governance,
proposal.pubkey,
!hasNoSignatories ? signatoryRecord!.account.signatory : wallet.publicKey!,
!hasNoSignatories ? signatoryRecord!.pubkey! : undefined,
!hasNoSignatories ? undefined : proposal.account.tokenOwnerRecord
signatoryRecord.account.signatory,
signatoryRecord?.pubkey,
undefined
)

const transaction = new Transaction()
Expand Down
8 changes: 2 additions & 6 deletions components/ProposalActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ProposalActionsPanel = () => {
const { governance, proposal, proposalOwner } = useWalletStore(
(s) => s.selectedProposal
)
const { realmInfo, ownTokenRecord, ownCouncilTokenRecord } = useRealm()
const { realmInfo } = useRealm()
const wallet = useWalletStore((s) => s.current)
const connected = useWalletStore((s) => s.connected)
const hasVoteTimeExpired = useHasVoteTimeExpired(governance, proposal!)
Expand Down Expand Up @@ -57,11 +57,7 @@ const ProposalActionsPanel = () => {
}, [proposal, realmInfo, walletPk])

const canSignOff =
(signatoryRecord ||
proposal?.account.tokenOwnerRecord.toBase58() ===
ownTokenRecord?.pubkey.toBase58() ||
proposal?.account.tokenOwnerRecord.toBase58() ===
ownCouncilTokenRecord?.pubkey.toBase58()) &&
signatoryRecord &&
(proposal?.account.state === ProposalState.Draft ||
proposal?.account.state === ProposalState.SigningOff)

Expand Down
4 changes: 2 additions & 2 deletions hooks/useGovernanceAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export default function useGovernanceAssets() {
id: Instructions.UpdateTokenMetadata,
name: 'Update Token Metadata',
isVisible: canUseAuthorityInstruction,
},
{
},
{
id: Instructions.SagaPreOrder,
name: 'Pre-order Saga Phone',
isVisible: canUseTokenTransferInstruction,
Expand Down

1 comment on commit 7323716

@vercel
Copy link

@vercel vercel bot commented on 7323716 Jul 21, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.