mirror of https://github.com/certusone/oyster.git
Governance: devnet program api update (#101)
* chore: use single create instruction to create governance * chore: remove yes/no dump accounts * chore: remove single value enums * chore: remove token from proposal account * chore: remove governance program account from createEmptyGovernanceVotingRecord * chore: remove number_of_extra_accounts from Execute * chore: update program id
This commit is contained in:
parent
3a9e3854fc
commit
39b1fa63ef
|
@ -88,7 +88,7 @@ export const PROGRAM_IDS = [
|
|||
{
|
||||
name: 'testnet',
|
||||
governance: () => ({
|
||||
programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'),
|
||||
programId: new PublicKey('A9KW1nhwZUr1kMX8C6rgzZvAE9AwEEUi2C77SiVvEiuN'),
|
||||
}),
|
||||
wormhole: () => ({
|
||||
pubkey: new PublicKey('5gQf5AUhAgWYgUCt9ouShm9H7dzzXUsLdssYwe5krKhg'),
|
||||
|
@ -103,10 +103,11 @@ export const PROGRAM_IDS = [
|
|||
legacy: [],
|
||||
}),
|
||||
},
|
||||
|
||||
{
|
||||
name: 'devnet',
|
||||
governance: () => ({
|
||||
programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'),
|
||||
programId: new PublicKey('A9KW1nhwZUr1kMX8C6rgzZvAE9AwEEUi2C77SiVvEiuN'),
|
||||
}),
|
||||
wormhole: () => ({
|
||||
pubkey: new PublicKey('WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC'),
|
||||
|
|
|
@ -69,8 +69,6 @@ export const createProposal = async (
|
|||
adminValidationAccount,
|
||||
adminDestinationAccount,
|
||||
sigDestinationAccount,
|
||||
yesVoteDumpAccount,
|
||||
noVoteDumpAccount,
|
||||
sourceHoldingAccount,
|
||||
authority,
|
||||
instructions: associatedInstructions,
|
||||
|
@ -137,8 +135,6 @@ export const createProposal = async (
|
|||
voteValidationAccount,
|
||||
adminDestinationAccount,
|
||||
sigDestinationAccount,
|
||||
yesVoteDumpAccount,
|
||||
noVoteDumpAccount,
|
||||
sourceHoldingAccount,
|
||||
useGovernance
|
||||
? governance.info.governanceMint
|
||||
|
@ -193,8 +189,6 @@ interface ValidationReturn {
|
|||
adminValidationAccount: PublicKey;
|
||||
adminDestinationAccount: PublicKey;
|
||||
sigDestinationAccount: PublicKey;
|
||||
yesVoteDumpAccount: PublicKey;
|
||||
noVoteDumpAccount: PublicKey;
|
||||
sourceHoldingAccount: PublicKey;
|
||||
authority: PublicKey;
|
||||
signers: Account[][];
|
||||
|
@ -329,24 +323,6 @@ async function getAssociatedAccountsAndInstructions(
|
|||
let holdingSigners: Account[] = [];
|
||||
let holdingInstructions: TransactionInstruction[] = [];
|
||||
|
||||
const yesVoteDumpAccount = createTokenAccount(
|
||||
holdingInstructions,
|
||||
wallet.publicKey,
|
||||
accountRentExempt,
|
||||
yesVoteMint,
|
||||
authority,
|
||||
holdingSigners,
|
||||
);
|
||||
|
||||
const noVoteDumpAccount = createTokenAccount(
|
||||
holdingInstructions,
|
||||
wallet.publicKey,
|
||||
accountRentExempt,
|
||||
noVoteMint,
|
||||
authority,
|
||||
holdingSigners,
|
||||
);
|
||||
|
||||
const sourceHoldingAccount = createTokenAccount(
|
||||
holdingInstructions,
|
||||
wallet.publicKey,
|
||||
|
@ -369,8 +345,6 @@ async function getAssociatedAccountsAndInstructions(
|
|||
adminValidationAccount,
|
||||
adminDestinationAccount,
|
||||
sigDestinationAccount,
|
||||
yesVoteDumpAccount,
|
||||
noVoteDumpAccount,
|
||||
sourceHoldingAccount,
|
||||
authority,
|
||||
signers: [
|
||||
|
|
|
@ -7,16 +7,9 @@ import {
|
|||
import { contexts, utils, actions, SequenceType } from '@oyster/common';
|
||||
|
||||
import { AccountLayout, MintLayout, Token } from '@solana/spl-token';
|
||||
import {
|
||||
GOVERNANCE_AUTHORITY_SEED,
|
||||
ExecutionType,
|
||||
Governance,
|
||||
GovernanceType,
|
||||
VotingEntryRule,
|
||||
} from '../models/governance';
|
||||
import { initGovernanceInstruction } from '../models/initGovernance';
|
||||
import { GOVERNANCE_AUTHORITY_SEED, Governance } from '../models/governance';
|
||||
import { createGovernanceInstruction } from '../models/createGovernance';
|
||||
import BN from 'bn.js';
|
||||
import { createEmptyGovernanceInstruction } from '../models/createEmptyGovernance';
|
||||
|
||||
const { sendTransactions } = contexts.Connection;
|
||||
const { createMint, createTokenAccount } = actions;
|
||||
|
@ -126,29 +119,18 @@ export const registerProgramGovernance = async (
|
|||
);
|
||||
|
||||
instructions.push(
|
||||
createEmptyGovernanceInstruction(
|
||||
createGovernanceInstruction(
|
||||
governanceKey,
|
||||
uninitializedGovernance.program,
|
||||
programDataAccount,
|
||||
wallet.publicKey,
|
||||
uninitializedGovernance.governanceMint,
|
||||
wallet.publicKey,
|
||||
uninitializedGovernance.councilMint,
|
||||
),
|
||||
);
|
||||
instructions.push(
|
||||
initGovernanceInstruction(
|
||||
governanceKey,
|
||||
uninitializedGovernance.program,
|
||||
uninitializedGovernance.governanceMint,
|
||||
|
||||
uninitializedGovernance.voteThreshold!,
|
||||
uninitializedGovernance.executionType || ExecutionType.Independent,
|
||||
uninitializedGovernance.governanceType || GovernanceType.Governance,
|
||||
uninitializedGovernance.votingEntryRule || VotingEntryRule.Anytime,
|
||||
uninitializedGovernance.minimumSlotWaitingPeriod || new BN(0),
|
||||
uninitializedGovernance.timeLimit || new BN(0),
|
||||
uninitializedGovernance.name || '',
|
||||
wallet.publicKey,
|
||||
uninitializedGovernance.councilMint,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -136,8 +136,6 @@ export const withdrawVotingTokens = async (
|
|||
existingNoVoteAccount,
|
||||
destinationAccount,
|
||||
proposal.info.sourceHolding,
|
||||
proposal.info.yesVotingDump,
|
||||
proposal.info.noVotingDump,
|
||||
proposal.info.votingMint,
|
||||
proposal.info.yesVotingMint,
|
||||
proposal.info.noVotingMint,
|
||||
|
|
|
@ -108,10 +108,9 @@ export const LABELS = {
|
|||
GOVERNANCE_MINT: 'Governance Mint ID',
|
||||
USE_COUNCIL_MINT: 'Allow Council Mint?',
|
||||
COUNCIL_MINT: 'Council Mint ID',
|
||||
PROPOSAL_TYPE: 'Proposal Type',
|
||||
EXECUTION_TYPE: 'Execution Type',
|
||||
|
||||
VOTE_PERCENT_THRESHOLD: 'Vote Threshold (%)',
|
||||
VOTING_ENTRY_RULES: 'Voting Entry Rules',
|
||||
|
||||
SELECT_PROPOSAL_TYPE: 'Select the type of proposals this app will generate',
|
||||
SELECT_EXECUTION_TYPE: 'Select how transactions will be executed',
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
||||
import { utils } from '@oyster/common';
|
||||
import * as BufferLayout from 'buffer-layout';
|
||||
import { GovernanceInstruction } from './governance';
|
||||
|
||||
/// 0. `[]` Governance account. The account pubkey needs to be set to PDA with the following seeds:
|
||||
/// 1) 'governance' const prefix, 2) Governed Program account key
|
||||
/// 1. `[]` Account of the Program governed by this Governance account
|
||||
/// 2. `[writable]` Program Data account of the Program governed by this Governance account
|
||||
/// 3. `[signer]` Current Upgrade Authority account of the Program governed by this Governance account
|
||||
/// 4. `[signer]` Payer
|
||||
/// 5. `[]` System account.
|
||||
/// 6. `[]` bpf_upgrade_loader account.
|
||||
export const createEmptyGovernanceInstruction = (
|
||||
governanceAccount: PublicKey,
|
||||
programAccount: PublicKey,
|
||||
programDataAccount: PublicKey,
|
||||
programUpgradeAuthority: PublicKey,
|
||||
governanceMint: PublicKey,
|
||||
payer: PublicKey,
|
||||
councilMint?: PublicKey,
|
||||
): TransactionInstruction => {
|
||||
const PROGRAM_IDS = utils.programIds();
|
||||
|
||||
const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
|
||||
|
||||
const data = Buffer.alloc(dataLayout.span);
|
||||
|
||||
dataLayout.encode(
|
||||
{
|
||||
instruction: GovernanceInstruction.CreateEmptyGovernance,
|
||||
},
|
||||
data,
|
||||
);
|
||||
|
||||
const keys = [
|
||||
{ pubkey: governanceAccount, isSigner: false, isWritable: false },
|
||||
{ pubkey: programAccount, isSigner: false, isWritable: false },
|
||||
{ pubkey: programDataAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: programUpgradeAuthority, isSigner: true, isWritable: false },
|
||||
|
||||
{ pubkey: payer, isSigner: true, isWritable: false },
|
||||
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
|
||||
{
|
||||
pubkey: PROGRAM_IDS.bpf_upgrade_loader,
|
||||
isSigner: false,
|
||||
isWritable: false,
|
||||
},
|
||||
];
|
||||
|
||||
return new TransactionInstruction({
|
||||
keys,
|
||||
programId: PROGRAM_IDS.governance.programId,
|
||||
data,
|
||||
});
|
||||
};
|
|
@ -34,11 +34,7 @@ export const createEmptyGovernanceVotingRecordInstruction = (
|
|||
{ pubkey: proposalAccount, isSigner: false, isWritable: false },
|
||||
{ pubkey: votingAccount, isSigner: false, isWritable: false },
|
||||
{ pubkey: payer, isSigner: true, isWritable: false },
|
||||
{
|
||||
pubkey: PROGRAM_IDS.governance.programId,
|
||||
isSigner: false,
|
||||
isWritable: false,
|
||||
},
|
||||
|
||||
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
|
||||
];
|
||||
return new TransactionInstruction({
|
||||
|
|
|
@ -1,47 +1,49 @@
|
|||
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
||||
import { utils } from '@oyster/common';
|
||||
import * as BufferLayout from 'buffer-layout';
|
||||
import { CONFIG_NAME_LENGTH, GovernanceInstruction } from './governance';
|
||||
import { GOVERNANCE_NAME_LENGTH, GovernanceInstruction } from './governance';
|
||||
import BN from 'bn.js';
|
||||
import * as Layout from '../utils/layout';
|
||||
|
||||
/// 0. `[writable]` Governance account. The account pubkey needs to be set to PDA with the following seeds:
|
||||
/// 1) 'governance' const prefix, 2) Governed Program account key
|
||||
/// 1. `[]` Account of the Program governed by this Governance account
|
||||
/// 2. `[]` Governance mint that this Governance uses
|
||||
/// 3. `[]` Council mint that this Governance uses [Optional]
|
||||
export const initGovernanceInstruction = (
|
||||
/// 2. `[writable]` Program Data account of the Program governed by this Governance account
|
||||
/// 3. `[signer]` Current Upgrade Authority account of the Program governed by this Governance account
|
||||
/// 4. `[]` Governance mint that this Governance uses
|
||||
/// 5. `[signer]` Payer
|
||||
/// 6. `[]` System account.
|
||||
/// 7. `[]` bpf_upgrade_loader account.
|
||||
/// 8. `[]` Council mint that this Governance uses [Optional]
|
||||
export const createGovernanceInstruction = (
|
||||
governanceAccount: PublicKey,
|
||||
programAccount: PublicKey,
|
||||
governedProgramAccount: PublicKey,
|
||||
governedProgramDataAccount: PublicKey,
|
||||
governedProgramUpgradeAuthority: PublicKey,
|
||||
governanceMint: PublicKey,
|
||||
voteThreshold: number,
|
||||
executionType: number,
|
||||
governanceType: number,
|
||||
votingEntryRule: number,
|
||||
minimumSlotWaitingPeriod: BN,
|
||||
timeLimit: BN,
|
||||
name: string,
|
||||
payer: PublicKey,
|
||||
councilMint?: PublicKey,
|
||||
): TransactionInstruction => {
|
||||
const PROGRAM_IDS = utils.programIds();
|
||||
|
||||
if (name.length > CONFIG_NAME_LENGTH) {
|
||||
throw new Error('Name is more than ' + CONFIG_NAME_LENGTH);
|
||||
if (name.length > GOVERNANCE_NAME_LENGTH) {
|
||||
throw new Error('Name is more than ' + GOVERNANCE_NAME_LENGTH);
|
||||
}
|
||||
|
||||
const dataLayout = BufferLayout.struct([
|
||||
BufferLayout.u8('instruction'),
|
||||
BufferLayout.u8('voteThreshold'),
|
||||
BufferLayout.u8('executionType'),
|
||||
BufferLayout.u8('governanceType'),
|
||||
BufferLayout.u8('votingEntryRule'),
|
||||
Layout.uint64('minimumSlotWaitingPeriod'),
|
||||
Layout.uint64('timeLimit'),
|
||||
BufferLayout.seq(BufferLayout.u8(), CONFIG_NAME_LENGTH, 'name'),
|
||||
BufferLayout.seq(BufferLayout.u8(), GOVERNANCE_NAME_LENGTH, 'name'),
|
||||
]);
|
||||
|
||||
const nameAsBytes = utils.toUTF8Array(name);
|
||||
for (let i = nameAsBytes.length; i <= CONFIG_NAME_LENGTH - 1; i++) {
|
||||
for (let i = nameAsBytes.length; i <= GOVERNANCE_NAME_LENGTH - 1; i++) {
|
||||
nameAsBytes.push(0);
|
||||
}
|
||||
|
||||
|
@ -49,11 +51,8 @@ export const initGovernanceInstruction = (
|
|||
|
||||
dataLayout.encode(
|
||||
{
|
||||
instruction: GovernanceInstruction.InitGovernance,
|
||||
instruction: GovernanceInstruction.CreateGovernance,
|
||||
voteThreshold,
|
||||
executionType,
|
||||
governanceType,
|
||||
votingEntryRule,
|
||||
minimumSlotWaitingPeriod,
|
||||
timeLimit,
|
||||
name: nameAsBytes,
|
||||
|
@ -63,8 +62,21 @@ export const initGovernanceInstruction = (
|
|||
|
||||
const keys = [
|
||||
{ pubkey: governanceAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: programAccount, isSigner: false, isWritable: false },
|
||||
{ pubkey: governedProgramAccount, isSigner: false, isWritable: false },
|
||||
{ pubkey: governedProgramDataAccount, isSigner: false, isWritable: true },
|
||||
{
|
||||
pubkey: governedProgramUpgradeAuthority,
|
||||
isSigner: true,
|
||||
isWritable: false,
|
||||
},
|
||||
{ pubkey: governanceMint, isSigner: false, isWritable: false },
|
||||
{ pubkey: payer, isSigner: true, isWritable: false },
|
||||
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
|
||||
{
|
||||
pubkey: PROGRAM_IDS.bpf_upgrade_loader,
|
||||
isSigner: false,
|
||||
isWritable: false,
|
||||
},
|
||||
];
|
||||
|
||||
if (councilMint) {
|
|
@ -27,17 +27,15 @@ export const executeInstruction = (
|
|||
): TransactionInstruction => {
|
||||
const PROGRAM_IDS = utils.programIds();
|
||||
|
||||
const dataLayout = BufferLayout.struct([
|
||||
BufferLayout.u8('instruction'),
|
||||
BufferLayout.u8('numberOfExtraAccounts'),
|
||||
]);
|
||||
const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
|
||||
|
||||
const data = Buffer.alloc(dataLayout.span);
|
||||
|
||||
console.log('ACCTS', accountInfos);
|
||||
|
||||
dataLayout.encode(
|
||||
{
|
||||
instruction: GovernanceInstruction.Execute,
|
||||
numberOfExtraAccounts: accountInfos.length,
|
||||
},
|
||||
data,
|
||||
);
|
||||
|
|
|
@ -6,7 +6,7 @@ import { utils } from '@oyster/common';
|
|||
|
||||
export const DESC_SIZE = 200;
|
||||
export const NAME_SIZE = 32;
|
||||
export const CONFIG_NAME_LENGTH = 32;
|
||||
export const GOVERNANCE_NAME_LENGTH = 32;
|
||||
export const INSTRUCTION_LIMIT = 450;
|
||||
export const MAX_TRANSACTIONS = 5;
|
||||
export const TEMP_FILE_TXN_SIZE = 1000;
|
||||
|
@ -21,13 +21,12 @@ export enum GovernanceInstruction {
|
|||
AddCustomSingleSignerTransaction = 4,
|
||||
Sign = 8,
|
||||
Vote = 9,
|
||||
InitGovernance = 10,
|
||||
CreateGovernance = 10,
|
||||
|
||||
Execute = 11,
|
||||
DepositGovernanceTokens = 12,
|
||||
WithdrawVotingTokens = 13,
|
||||
CreateEmptyGovernance = 14,
|
||||
CreateGovernanceVotingRecord = 15,
|
||||
CreateGovernanceVotingRecord = 14,
|
||||
}
|
||||
|
||||
export interface GovernanceVotingRecord {
|
||||
|
@ -63,12 +62,7 @@ export interface Governance {
|
|||
accountType: GovernanceAccountType;
|
||||
/// Vote threshold
|
||||
voteThreshold: number;
|
||||
/// Execution type
|
||||
executionType: ExecutionType;
|
||||
/// Governance Type
|
||||
governanceType: GovernanceType;
|
||||
/// Voting entry rule
|
||||
votingEntryRule: VotingEntryRule;
|
||||
|
||||
/// Minimum slot time-distance from creation of proposal for an instruction to be placed
|
||||
minimumSlotWaitingPeriod: BN;
|
||||
/// Governance mint
|
||||
|
@ -98,33 +92,18 @@ export const GovernanceLayout: typeof BufferLayout.Structure = BufferLayout.stru
|
|||
[
|
||||
BufferLayout.u8('accountType'),
|
||||
BufferLayout.u8('voteThreshold'),
|
||||
BufferLayout.u8('executionType'),
|
||||
BufferLayout.u8('governanceType'),
|
||||
BufferLayout.u8('votingEntryRule'),
|
||||
Layout.uint64('minimumSlotWaitingPeriod'),
|
||||
Layout.publicKey('governanceMint'),
|
||||
BufferLayout.u8('councilMintOption'),
|
||||
Layout.publicKey('councilMint'),
|
||||
Layout.publicKey('program'),
|
||||
Layout.uint64('timeLimit'),
|
||||
BufferLayout.seq(BufferLayout.u8(), CONFIG_NAME_LENGTH, 'name'),
|
||||
BufferLayout.seq(BufferLayout.u8(), GOVERNANCE_NAME_LENGTH, 'name'),
|
||||
BufferLayout.u32('count'),
|
||||
BufferLayout.seq(BufferLayout.u8(), 295, 'padding'),
|
||||
],
|
||||
);
|
||||
|
||||
export enum VotingEntryRule {
|
||||
Anytime = 0,
|
||||
}
|
||||
|
||||
export enum ExecutionType {
|
||||
Independent = 0,
|
||||
}
|
||||
|
||||
export enum GovernanceType {
|
||||
Governance = 0,
|
||||
}
|
||||
|
||||
export enum ProposalStateStatus {
|
||||
/// Draft
|
||||
Draft = 0,
|
||||
|
@ -180,7 +159,6 @@ export const ProposalLayout: typeof BufferLayout.Structure = BufferLayout.struct
|
|||
[
|
||||
BufferLayout.u8('accountType'),
|
||||
Layout.publicKey('config'),
|
||||
Layout.publicKey('tokenProgramId'),
|
||||
Layout.publicKey('state'),
|
||||
Layout.publicKey('signatoryMint'),
|
||||
Layout.publicKey('adminMint'),
|
||||
|
@ -192,8 +170,7 @@ export const ProposalLayout: typeof BufferLayout.Structure = BufferLayout.struct
|
|||
Layout.publicKey('adminValidation'),
|
||||
Layout.publicKey('votingValidation'),
|
||||
Layout.publicKey('sourceHolding'),
|
||||
Layout.publicKey('yesVotingDump'),
|
||||
Layout.publicKey('noVotingDump'),
|
||||
|
||||
BufferLayout.seq(BufferLayout.u8(), 300, 'padding'),
|
||||
],
|
||||
);
|
||||
|
@ -225,9 +202,6 @@ export interface Proposal {
|
|||
/// configuration values
|
||||
config: PublicKey;
|
||||
|
||||
/// Token Program ID
|
||||
tokenProgramId: PublicKey;
|
||||
|
||||
/// state values
|
||||
state: PublicKey;
|
||||
|
||||
|
@ -262,12 +236,6 @@ export interface Proposal {
|
|||
|
||||
/// Governance holding account
|
||||
sourceHolding: PublicKey;
|
||||
|
||||
/// Yes Voting dump account for exchanged vote tokens
|
||||
yesVotingDump: PublicKey;
|
||||
|
||||
/// No Voting dump account for exchanged vote tokens
|
||||
noVotingDump: PublicKey;
|
||||
}
|
||||
|
||||
export const CustomSingleSignerTransactionLayout: typeof BufferLayout.Structure = BufferLayout.struct(
|
||||
|
@ -309,7 +277,6 @@ export const ProposalParser = (
|
|||
info: {
|
||||
accountType: data.accountType,
|
||||
config: data.config,
|
||||
tokenProgramId: data.tokenProgramId,
|
||||
state: data.state,
|
||||
signatoryMint: data.signatoryMint,
|
||||
adminMint: data.adminMint,
|
||||
|
@ -321,8 +288,6 @@ export const ProposalParser = (
|
|||
adminValidation: data.adminValidation,
|
||||
votingValidation: data.votingValidation,
|
||||
sourceHolding: data.sourceHolding,
|
||||
yesVotingDump: data.yesVotingDump,
|
||||
noVotingDump: data.noVotingDump,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -431,9 +396,7 @@ export const GovernanceParser = (
|
|||
info: {
|
||||
accountType: data.accountType,
|
||||
voteThreshold: data.voteThreshold,
|
||||
executionType: data.executionType,
|
||||
governanceType: data.governanceType,
|
||||
votingEntryRule: data.votingEntryRule,
|
||||
|
||||
minimumSlotWaitingPeriod: data.minimumSlotWaitingPeriod,
|
||||
governanceMint: data.governanceMint,
|
||||
councilMint: data.councilMintOption === 1 ? data.councilMint : null,
|
||||
|
|
|
@ -23,8 +23,6 @@ import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './governance';
|
|||
/// 10. `[writable]` Initialized Voting Validation account
|
||||
/// 11. `[writable]` Initialized Destination account for first admin token
|
||||
/// 12. `[writable]` Initialized Destination account for first signatory token
|
||||
/// 13. `[writable]` Initialized Yes voting dump account
|
||||
/// 14. `[writable]` Initialized No voting dump account
|
||||
/// 15. `[writable]` Initialized source holding account
|
||||
/// 16. `[]` Source mint
|
||||
/// 17. `[]` Governance minting authority (pda with seed of Proposal key)
|
||||
|
@ -44,8 +42,6 @@ export const initProposalInstruction = (
|
|||
votingValidationAccount: PublicKey,
|
||||
destinationAdminAccount: PublicKey,
|
||||
destinationSignatoryAccount: PublicKey,
|
||||
yesVotingDumpAccount: PublicKey,
|
||||
noVotingDumpAccount: PublicKey,
|
||||
sourceHoldingAccount: PublicKey,
|
||||
sourceMintAccount: PublicKey,
|
||||
authority: PublicKey,
|
||||
|
@ -101,8 +97,6 @@ export const initProposalInstruction = (
|
|||
{ pubkey: votingValidationAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: destinationAdminAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: destinationSignatoryAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: yesVotingDumpAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: noVotingDumpAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: sourceHoldingAccount, isSigner: false, isWritable: true },
|
||||
{
|
||||
pubkey: sourceMintAccount,
|
||||
|
|
|
@ -15,8 +15,6 @@ import BN from 'bn.js';
|
|||
/// 3. `[writable]` Initialized No Voting account from which to remove your voting tokens.
|
||||
/// 4. `[writable]` User token account that you wish your actual tokens to be returned to.
|
||||
/// 5. `[writable]` Source holding account owned by the Governance that will has the actual tokens in escrow.
|
||||
/// 6. `[writable]` Initialized Yes Voting dump account owned by Proposal to which to send your voting tokens.
|
||||
/// 7. `[writable]` Initialized No Voting dump account owned by Proposal to which to send your voting tokens.
|
||||
/// 8. `[writable]` Voting mint account.
|
||||
/// 9. `[writable]` Yes Voting mint account.
|
||||
/// 10. `[writable]` No Voting mint account.
|
||||
|
@ -32,8 +30,6 @@ export const withdrawVotingTokensInstruction = (
|
|||
noVotingAccount: PublicKey,
|
||||
destinationAccount: PublicKey,
|
||||
sourceHoldingAccount: PublicKey,
|
||||
yesVotingDump: PublicKey,
|
||||
noVotingDump: PublicKey,
|
||||
votingMint: PublicKey,
|
||||
yesVotingMint: PublicKey,
|
||||
noVotingMint: PublicKey,
|
||||
|
@ -67,8 +63,6 @@ export const withdrawVotingTokensInstruction = (
|
|||
{ pubkey: noVotingAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: destinationAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: sourceHoldingAccount, isSigner: false, isWritable: true },
|
||||
{ pubkey: yesVotingDump, isSigner: false, isWritable: true },
|
||||
{ pubkey: noVotingDump, isSigner: false, isWritable: true },
|
||||
{ pubkey: votingMint, isSigner: false, isWritable: true },
|
||||
{ pubkey: yesVotingMint, isSigner: false, isWritable: true },
|
||||
{ pubkey: noVotingMint, isSigner: false, isWritable: true },
|
||||
|
|
|
@ -9,12 +9,7 @@ import {
|
|||
deserializeMint,
|
||||
ParsedAccount,
|
||||
} from '@oyster/common';
|
||||
import {
|
||||
ExecutionType,
|
||||
Governance,
|
||||
GovernanceType,
|
||||
VotingEntryRule,
|
||||
} from '../../models/governance';
|
||||
import { Governance } from '../../models/governance';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
import { Table } from 'antd';
|
||||
import MintSourceTokens from '../../components/Proposal/MintSourceTokens';
|
||||
|
@ -32,24 +27,7 @@ const columns = [
|
|||
key: 'voteThreshold',
|
||||
render: (number: number) => <span>{number}</span>,
|
||||
},
|
||||
{
|
||||
title: LABELS.EXECUTION_TYPE,
|
||||
dataIndex: 'executionType',
|
||||
key: 'executionType',
|
||||
render: (number: number) => <span>{ExecutionType[number]}</span>,
|
||||
},
|
||||
{
|
||||
title: LABELS.PROPOSAL_TYPE,
|
||||
dataIndex: 'governanceType',
|
||||
key: 'governanceType',
|
||||
render: (number: number) => <span>{GovernanceType[number]}</span>,
|
||||
},
|
||||
{
|
||||
title: LABELS.VOTING_ENTRY_RULES,
|
||||
dataIndex: 'votingEntryRule',
|
||||
key: 'votingEntryRule',
|
||||
render: (number: number) => <span>{VotingEntryRule[number]}</span>,
|
||||
},
|
||||
|
||||
{
|
||||
title: LABELS.MINIMUM_SLOT_WAITING_PERIOD,
|
||||
dataIndex: 'minimumSlotWaitingPeriod',
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
import React, { useState } from 'react';
|
||||
import { Button, ButtonProps, InputNumber, Modal, Switch } from 'antd';
|
||||
import { Form, Input, Select } from 'antd';
|
||||
import { Form, Input } from 'antd';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
import {
|
||||
CONFIG_NAME_LENGTH,
|
||||
ExecutionType,
|
||||
GovernanceType,
|
||||
VotingEntryRule,
|
||||
} from '../../models/governance';
|
||||
import { GOVERNANCE_NAME_LENGTH } from '../../models/governance';
|
||||
import { LABELS } from '../../constants';
|
||||
import { contexts, utils, tryParseKey } from '@oyster/common';
|
||||
import { registerProgramGovernance } from '../../actions/registerProgramGovernance';
|
||||
|
@ -16,7 +11,6 @@ import BN from 'bn.js';
|
|||
|
||||
const { useWallet } = contexts.Wallet;
|
||||
const { useConnection } = contexts.Connection;
|
||||
const { Option } = Select;
|
||||
const { notify } = utils;
|
||||
|
||||
const layout = {
|
||||
|
@ -68,10 +62,8 @@ export function NewForm({
|
|||
const wallet = useWallet();
|
||||
const connection = useConnection();
|
||||
const onFinish = async (values: {
|
||||
governanceType: GovernanceType;
|
||||
executionType: ExecutionType;
|
||||
voteThreshold: number;
|
||||
votingEntryRule: VotingEntryRule;
|
||||
|
||||
minimumSlotWaitingPeriod: string;
|
||||
timeLimit: string;
|
||||
governanceMint: string;
|
||||
|
@ -120,10 +112,8 @@ export function NewForm({
|
|||
}
|
||||
|
||||
const uninitializedGovernance = {
|
||||
governanceType: values.governanceType,
|
||||
executionType: values.executionType,
|
||||
voteThreshold: values.voteThreshold,
|
||||
votingEntryRule: values.votingEntryRule,
|
||||
|
||||
minimumSlotWaitingPeriod: new BN(values.minimumSlotWaitingPeriod),
|
||||
governanceMint: values.governanceMint
|
||||
? new PublicKey(values.governanceMint)
|
||||
|
@ -154,7 +144,7 @@ export function NewForm({
|
|||
>
|
||||
<Form {...layout} form={form} name="control-hooks" onFinish={onFinish}>
|
||||
<Form.Item name="name" label="Name" rules={[{ required: true }]}>
|
||||
<Input maxLength={CONFIG_NAME_LENGTH} />
|
||||
<Input maxLength={GOVERNANCE_NAME_LENGTH} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="program"
|
||||
|
@ -204,36 +194,6 @@ export function NewForm({
|
|||
>
|
||||
<InputNumber maxLength={3} min={1} max={100} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="executionType"
|
||||
label={LABELS.EXECUTION_TYPE}
|
||||
rules={[{ required: true }]}
|
||||
initialValue={ExecutionType.Independent}
|
||||
>
|
||||
<Select placeholder={LABELS.SELECT_EXECUTION_TYPE}>
|
||||
<Option value={ExecutionType.Independent}>Independent</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="governanceType"
|
||||
label={LABELS.PROPOSAL_TYPE}
|
||||
rules={[{ required: true }]}
|
||||
initialValue={GovernanceType.Governance}
|
||||
>
|
||||
<Select placeholder={LABELS.SELECT_PROPOSAL_TYPE}>
|
||||
<Option value={GovernanceType.Governance}>Single Signer</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="votingEntryRule"
|
||||
label={LABELS.VOTING_ENTRY_RULES}
|
||||
rules={[{ required: true }]}
|
||||
initialValue={VotingEntryRule.Anytime}
|
||||
>
|
||||
<Select placeholder={LABELS.SELECT_VOTING_ENTRY_RULE}>
|
||||
<Option value={VotingEntryRule.Anytime}>At any time</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue