mirror of https://github.com/certusone/oyster.git
feat: constrain active proposals per wallet
This commit is contained in:
parent
b11588d442
commit
277d2cfbee
|
@ -26,6 +26,7 @@ export const castVote = async (
|
|||
realm,
|
||||
proposal.info.governance,
|
||||
proposal.pubkey,
|
||||
proposal.info.tokenOwnerRecord,
|
||||
tokeOwnerRecord,
|
||||
governanceAuthority,
|
||||
proposal.info.governingTokenMint,
|
||||
|
|
|
@ -21,6 +21,7 @@ export const finalizeVote = async (
|
|||
realm,
|
||||
proposal.info.governance,
|
||||
proposal.pubkey,
|
||||
proposal.info.tokenOwnerRecord,
|
||||
proposal.info.governingTokenMint,
|
||||
);
|
||||
|
||||
|
|
|
@ -298,6 +298,8 @@ export class TokenOwnerRecord {
|
|||
|
||||
totalVotesCount: number;
|
||||
|
||||
outstandingProposalCount: number;
|
||||
|
||||
reserved: Uint8Array;
|
||||
|
||||
governanceDelegate?: PublicKey;
|
||||
|
@ -309,6 +311,7 @@ export class TokenOwnerRecord {
|
|||
governingTokenDepositAmount: BN;
|
||||
unrelinquishedVotesCount: number;
|
||||
totalVotesCount: number;
|
||||
outstandingProposalCount: number;
|
||||
reserved: Uint8Array;
|
||||
}) {
|
||||
this.realm = args.realm;
|
||||
|
@ -317,6 +320,7 @@ export class TokenOwnerRecord {
|
|||
this.governingTokenDepositAmount = args.governingTokenDepositAmount;
|
||||
this.unrelinquishedVotesCount = args.unrelinquishedVotesCount;
|
||||
this.totalVotesCount = args.totalVotesCount;
|
||||
this.outstandingProposalCount = args.outstandingProposalCount;
|
||||
this.reserved = args.reserved;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ export const GovernanceError: Record<number, string> = [
|
|||
'Not supported mint max vote weight source', // MintMaxVoteWeightSourceNotSupported
|
||||
'Invalid max vote weight supply fraction', // InvalidMaxVoteWeightSupplyFraction
|
||||
"Owner doesn't have enough governing tokens to create Governance", // NotEnoughTokensToCreateGovernance
|
||||
'Too many outstanding proposals', // TooManyOutstandingProposals
|
||||
'All proposals must be finalized to withdraw governing tokens', // AllProposalsMustBeFinalisedToWithdrawGoverningTokens
|
||||
];
|
||||
|
||||
export const TokenError: Record<number, string> = [
|
||||
|
|
|
@ -398,7 +398,8 @@ export const GOVERNANCE_SCHEMA = new Map<any, any>([
|
|||
['governingTokenDepositAmount', 'u64'],
|
||||
['unrelinquishedVotesCount', 'u32'],
|
||||
['totalVotesCount', 'u32'],
|
||||
['reserved', [8]],
|
||||
['outstandingProposalCount', 'u8'],
|
||||
['reserved', [7]],
|
||||
['governanceDelegate', { kind: 'option', type: 'pubkey' }],
|
||||
],
|
||||
},
|
||||
|
|
|
@ -25,7 +25,7 @@ export const withCancelProposal = (
|
|||
},
|
||||
{
|
||||
pubkey: tokenOwnerRecord,
|
||||
isWritable: false,
|
||||
isWritable: true,
|
||||
isSigner: false,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@ export const withCastVote = async (
|
|||
realm: PublicKey,
|
||||
governance: PublicKey,
|
||||
proposal: PublicKey,
|
||||
proposalOwnerRecord: PublicKey,
|
||||
tokenOwnerRecord: PublicKey,
|
||||
governanceAuthority: PublicKey,
|
||||
governingTokenMint: PublicKey,
|
||||
|
@ -49,6 +50,11 @@ export const withCastVote = async (
|
|||
isWritable: true,
|
||||
isSigner: false,
|
||||
},
|
||||
{
|
||||
pubkey: proposalOwnerRecord,
|
||||
isWritable: true,
|
||||
isSigner: false,
|
||||
},
|
||||
{
|
||||
pubkey: tokenOwnerRecord,
|
||||
isWritable: true,
|
||||
|
|
|
@ -63,7 +63,7 @@ export const withCreateProposal = async (
|
|||
},
|
||||
{
|
||||
pubkey: tokenOwnerRecord,
|
||||
isWritable: false,
|
||||
isWritable: true,
|
||||
isSigner: false,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ export const withFinalizeVote = async (
|
|||
realm: PublicKey,
|
||||
governance: PublicKey,
|
||||
proposal: PublicKey,
|
||||
proposalOwnerRecord: PublicKey,
|
||||
governingTokenMint: PublicKey,
|
||||
) => {
|
||||
const args = new FinalizeVoteArgs();
|
||||
|
@ -34,6 +35,11 @@ export const withFinalizeVote = async (
|
|||
isWritable: true,
|
||||
isSigner: false,
|
||||
},
|
||||
{
|
||||
pubkey: proposalOwnerRecord,
|
||||
isWritable: true,
|
||||
isSigner: false,
|
||||
},
|
||||
{
|
||||
pubkey: governingTokenMint,
|
||||
isWritable: false,
|
||||
|
|
Loading…
Reference in New Issue