@solana/spl-governance
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -18,3 +18,3 @@ "use strict"; | ||
const runtime_1 = require("../tools/sdk/runtime"); | ||
const withVoterWeightAccounts_1 = require("../governance/withVoterWeightAccounts"); | ||
const withRealmConfigAccounts_1 = require("../governance/withRealmConfigAccounts"); | ||
function withPostChatMessage(instructions, signers, chatProgramId, governanceProgramId, realm, governance, proposal, tokenOwnerRecord, governanceAuthority, payer, replyTo, body, voterWeightRecord) { | ||
@@ -82,3 +82,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
(0, withVoterWeightAccounts_1.withVoterWeightAccounts)(keys, governanceProgramId, realm, voterWeightRecord); | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, governanceProgramId, realm, voterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -85,0 +85,0 @@ keys, |
@@ -7,17 +7,24 @@ import { PublicKey } from '@solana/web3.js'; | ||
Uninitialized = 0, | ||
Realm = 1, | ||
TokenOwnerRecord = 2, | ||
AccountGovernance = 3, | ||
ProgramGovernance = 4, | ||
RealmV1 = 1, | ||
TokenOwnerRecordV1 = 2, | ||
GovernanceV1 = 3, | ||
ProgramGovernanceV1 = 4, | ||
ProposalV1 = 5, | ||
SignatoryRecord = 6, | ||
SignatoryRecordV1 = 6, | ||
VoteRecordV1 = 7, | ||
ProposalInstructionV1 = 8, | ||
MintGovernance = 9, | ||
TokenGovernance = 10, | ||
MintGovernanceV1 = 9, | ||
TokenGovernanceV1 = 10, | ||
RealmConfig = 11, | ||
VoteRecordV2 = 12, | ||
ProposalInstructionV2 = 13, | ||
ProposalTransactionV2 = 13, | ||
ProposalV2 = 14, | ||
ProgramMetadata = 14 | ||
ProgramMetadata = 15, | ||
RealmV2 = 16, | ||
TokenOwnerRecordV2 = 17, | ||
GovernanceV2 = 18, | ||
ProgramGovernanceV2 = 19, | ||
MintGovernanceV2 = 20, | ||
TokenGovernanceV2 = 21, | ||
SignatoryRecordV2 = 22 | ||
} | ||
@@ -27,3 +34,3 @@ export interface GovernanceAccount { | ||
} | ||
export declare type GovernanceAccountClass = typeof Realm | typeof TokenOwnerRecord | typeof Governance | typeof Proposal | typeof SignatoryRecord | typeof VoteRecord | typeof ProposalInstruction | typeof RealmConfigAccount | typeof ProgramMetadata; | ||
export declare type GovernanceAccountClass = typeof Realm | typeof TokenOwnerRecord | typeof Governance | typeof Proposal | typeof SignatoryRecord | typeof VoteRecord | typeof ProposalTransaction | typeof RealmConfigAccount | typeof ProgramMetadata; | ||
export declare function getAccountTypes(accountClass: GovernanceAccountClass): GovernanceAccountType[]; | ||
@@ -42,5 +49,6 @@ export declare function getAccountProgramVersion(accountType: GovernanceAccountType): 1 | 2; | ||
} | ||
export declare enum VoteWeightSource { | ||
Deposit = 0, | ||
Snapshot = 1 | ||
export declare enum VoteTipping { | ||
Strict = 0, | ||
Early = 1, | ||
Disabled = 2 | ||
} | ||
@@ -94,7 +102,9 @@ export declare enum InstructionExecutionStatus { | ||
useCommunityVoterWeightAddin: boolean; | ||
useMaxCommunityVoterWeightAddin: boolean; | ||
constructor(args: { | ||
useCouncilMint: boolean; | ||
minCommunityTokensToCreateGovernance: BN; | ||
communityMintMaxVoteWeightSource: MintMaxVoteWeightSource; | ||
minCommunityTokensToCreateGovernance: BN; | ||
useCommunityVoterWeightAddin: boolean; | ||
useMaxCommunityVoterWeightAddin: boolean; | ||
}); | ||
@@ -107,2 +117,3 @@ } | ||
useCommunityVoterWeightAddin: boolean; | ||
useMaxCommunityVoterWeightAddin: boolean; | ||
reserved: Uint8Array; | ||
@@ -115,2 +126,3 @@ constructor(args: { | ||
useCommunityVoterWeightAddin: boolean; | ||
useMaxCommunityVoterWeightAddin: boolean; | ||
}); | ||
@@ -123,2 +135,3 @@ } | ||
reserved: Uint8Array; | ||
votingProposalCount: number; | ||
authority: PublicKey | undefined; | ||
@@ -130,2 +143,3 @@ name: string; | ||
config: RealmConfig; | ||
votingProposalCount: number; | ||
authority: PublicKey | undefined; | ||
@@ -140,5 +154,7 @@ name: string; | ||
communityVoterWeightAddin: PublicKey | undefined; | ||
maxCommunityVoterWeightAddin: PublicKey | undefined; | ||
constructor(args: { | ||
realm: PublicKey; | ||
communityVoterWeightAddin: PublicKey | undefined; | ||
maxCommunityVoterWeightAddin: PublicKey | undefined; | ||
}); | ||
@@ -152,3 +168,3 @@ } | ||
maxVotingTime: number; | ||
voteWeightSource: VoteWeightSource; | ||
voteTipping: VoteTipping; | ||
proposalCoolOffTime: number; | ||
@@ -161,3 +177,3 @@ minCouncilTokensToCreateProposal: BN; | ||
maxVotingTime: number; | ||
voteWeightSource?: VoteWeightSource; | ||
voteTipping?: VoteTipping; | ||
proposalCoolOffTime?: number; | ||
@@ -174,2 +190,3 @@ minCouncilTokensToCreateProposal: BN; | ||
reserved?: Uint8Array; | ||
votingProposalCount: number; | ||
constructor(args: { | ||
@@ -182,2 +199,3 @@ realm: PublicKey; | ||
proposalCount: number; | ||
votingProposalCount: number; | ||
}); | ||
@@ -260,2 +278,6 @@ isProgramGovernance(): boolean; | ||
denyVoteWeight: BN | undefined; | ||
vetoVoteWeight: BN | undefined; | ||
abstainVoteWeight: BN | undefined; | ||
startVotingAt: BN | null; | ||
maxVotingTime: number | null; | ||
draftAt: BN; | ||
@@ -291,2 +313,6 @@ signingOffAt: BN | null; | ||
denyVoteWeight: BN | undefined; | ||
vetoVoteWeight: BN | undefined; | ||
abstainVoteWeight: BN | undefined; | ||
startVotingAt: BN | null; | ||
maxVotingTime: number | null; | ||
draftAt: BN; | ||
@@ -377,12 +403,14 @@ signingOffAt: BN | null; | ||
} | ||
export declare class ProposalInstruction { | ||
export declare class ProposalTransaction { | ||
accountType: GovernanceAccountType; | ||
proposal: PublicKey; | ||
instructionIndex: number; | ||
instruction: InstructionData; | ||
optionIndex: number; | ||
instructions: InstructionData[]; | ||
holdUpTime: number; | ||
instruction: InstructionData; | ||
executedAt: BN | null; | ||
executionStatus: InstructionExecutionStatus; | ||
constructor(args: { | ||
accountType: GovernanceAccountType; | ||
proposal: PublicKey; | ||
@@ -395,5 +423,8 @@ instructionIndex: number; | ||
executionStatus: InstructionExecutionStatus; | ||
instructions: InstructionData[]; | ||
}); | ||
getSingleInstruction(): InstructionData; | ||
getAllInstructions(): InstructionData[]; | ||
} | ||
export declare function getProposalInstructionAddress(programId: PublicKey, programVersion: number, proposal: PublicKey, optionIndex: number, instructionIndex: number): Promise<PublicKey>; | ||
export declare function getProposalTransactionAddress(programId: PublicKey, programVersion: number, proposal: PublicKey, optionIndex: number, transactionIndex: number): Promise<PublicKey>; | ||
export declare class ProgramMetadata { | ||
@@ -400,0 +431,0 @@ accountType: GovernanceAccountType; |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNativeTreasuryAddress = exports.getProgramMetadataAddress = exports.ProgramMetadata = exports.getProposalInstructionAddress = exports.ProposalInstruction = exports.InstructionData = exports.AccountMetaData = exports.getVoteRecordAddress = exports.VoteRecord = exports.VoteWeight = exports.getSignatoryRecordAddress = exports.SignatoryRecord = exports.Proposal = exports.ProposalOption = exports.OptionVoteResult = exports.ProposalState = exports.getTokenOwnerRecordAddress = exports.TokenOwnerRecord = exports.Governance = exports.GovernanceConfig = exports.getRealmConfigAddress = exports.RealmConfigAccount = exports.getTokenHoldingAddress = exports.Realm = exports.RealmConfig = exports.RealmConfigArgs = exports.VoteType = exports.VoteTypeKind = exports.MintMaxVoteWeightSource = exports.MintMaxVoteWeightSourceType = exports.InstructionExecutionFlags = exports.InstructionExecutionStatus = exports.VoteWeightSource = exports.VoteThresholdPercentage = exports.VoteThresholdPercentageType = exports.getAccountProgramVersion = exports.getAccountTypes = exports.GovernanceAccountType = exports.GOVERNANCE_PROGRAM_SEED = void 0; | ||
exports.getNativeTreasuryAddress = exports.getProgramMetadataAddress = exports.ProgramMetadata = exports.getProposalTransactionAddress = exports.ProposalTransaction = exports.InstructionData = exports.AccountMetaData = exports.getVoteRecordAddress = exports.VoteRecord = exports.VoteWeight = exports.getSignatoryRecordAddress = exports.SignatoryRecord = exports.Proposal = exports.ProposalOption = exports.OptionVoteResult = exports.ProposalState = exports.getTokenOwnerRecordAddress = exports.TokenOwnerRecord = exports.Governance = exports.GovernanceConfig = exports.getRealmConfigAddress = exports.RealmConfigAccount = exports.getTokenHoldingAddress = exports.Realm = exports.RealmConfig = exports.RealmConfigArgs = exports.VoteType = exports.VoteTypeKind = exports.MintMaxVoteWeightSource = exports.MintMaxVoteWeightSourceType = exports.InstructionExecutionFlags = exports.InstructionExecutionStatus = exports.VoteTipping = exports.VoteThresholdPercentage = exports.VoteThresholdPercentageType = exports.getAccountProgramVersion = exports.getAccountTypes = exports.GovernanceAccountType = exports.GOVERNANCE_PROGRAM_SEED = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
@@ -27,17 +27,24 @@ const bn_js_1 = __importDefault(require("bn.js")); | ||
GovernanceAccountType[GovernanceAccountType["Uninitialized"] = 0] = "Uninitialized"; | ||
GovernanceAccountType[GovernanceAccountType["Realm"] = 1] = "Realm"; | ||
GovernanceAccountType[GovernanceAccountType["TokenOwnerRecord"] = 2] = "TokenOwnerRecord"; | ||
GovernanceAccountType[GovernanceAccountType["AccountGovernance"] = 3] = "AccountGovernance"; | ||
GovernanceAccountType[GovernanceAccountType["ProgramGovernance"] = 4] = "ProgramGovernance"; | ||
GovernanceAccountType[GovernanceAccountType["RealmV1"] = 1] = "RealmV1"; | ||
GovernanceAccountType[GovernanceAccountType["TokenOwnerRecordV1"] = 2] = "TokenOwnerRecordV1"; | ||
GovernanceAccountType[GovernanceAccountType["GovernanceV1"] = 3] = "GovernanceV1"; | ||
GovernanceAccountType[GovernanceAccountType["ProgramGovernanceV1"] = 4] = "ProgramGovernanceV1"; | ||
GovernanceAccountType[GovernanceAccountType["ProposalV1"] = 5] = "ProposalV1"; | ||
GovernanceAccountType[GovernanceAccountType["SignatoryRecord"] = 6] = "SignatoryRecord"; | ||
GovernanceAccountType[GovernanceAccountType["SignatoryRecordV1"] = 6] = "SignatoryRecordV1"; | ||
GovernanceAccountType[GovernanceAccountType["VoteRecordV1"] = 7] = "VoteRecordV1"; | ||
GovernanceAccountType[GovernanceAccountType["ProposalInstructionV1"] = 8] = "ProposalInstructionV1"; | ||
GovernanceAccountType[GovernanceAccountType["MintGovernance"] = 9] = "MintGovernance"; | ||
GovernanceAccountType[GovernanceAccountType["TokenGovernance"] = 10] = "TokenGovernance"; | ||
GovernanceAccountType[GovernanceAccountType["MintGovernanceV1"] = 9] = "MintGovernanceV1"; | ||
GovernanceAccountType[GovernanceAccountType["TokenGovernanceV1"] = 10] = "TokenGovernanceV1"; | ||
GovernanceAccountType[GovernanceAccountType["RealmConfig"] = 11] = "RealmConfig"; | ||
GovernanceAccountType[GovernanceAccountType["VoteRecordV2"] = 12] = "VoteRecordV2"; | ||
GovernanceAccountType[GovernanceAccountType["ProposalInstructionV2"] = 13] = "ProposalInstructionV2"; | ||
GovernanceAccountType[GovernanceAccountType["ProposalTransactionV2"] = 13] = "ProposalTransactionV2"; | ||
GovernanceAccountType[GovernanceAccountType["ProposalV2"] = 14] = "ProposalV2"; | ||
GovernanceAccountType[GovernanceAccountType["ProgramMetadata"] = 14] = "ProgramMetadata"; | ||
GovernanceAccountType[GovernanceAccountType["ProgramMetadata"] = 15] = "ProgramMetadata"; | ||
GovernanceAccountType[GovernanceAccountType["RealmV2"] = 16] = "RealmV2"; | ||
GovernanceAccountType[GovernanceAccountType["TokenOwnerRecordV2"] = 17] = "TokenOwnerRecordV2"; | ||
GovernanceAccountType[GovernanceAccountType["GovernanceV2"] = 18] = "GovernanceV2"; | ||
GovernanceAccountType[GovernanceAccountType["ProgramGovernanceV2"] = 19] = "ProgramGovernanceV2"; | ||
GovernanceAccountType[GovernanceAccountType["MintGovernanceV2"] = 20] = "MintGovernanceV2"; | ||
GovernanceAccountType[GovernanceAccountType["TokenGovernanceV2"] = 21] = "TokenGovernanceV2"; | ||
GovernanceAccountType[GovernanceAccountType["SignatoryRecordV2"] = 22] = "SignatoryRecordV2"; | ||
})(GovernanceAccountType = exports.GovernanceAccountType || (exports.GovernanceAccountType = {})); | ||
@@ -47,5 +54,8 @@ function getAccountTypes(accountClass) { | ||
case Realm: | ||
return [GovernanceAccountType.Realm]; | ||
return [GovernanceAccountType.RealmV1, GovernanceAccountType.RealmV2]; | ||
case TokenOwnerRecord: | ||
return [GovernanceAccountType.TokenOwnerRecord]; | ||
return [ | ||
GovernanceAccountType.TokenOwnerRecordV1, | ||
GovernanceAccountType.TokenOwnerRecordV2, | ||
]; | ||
case Proposal: | ||
@@ -57,3 +67,6 @@ return [ | ||
case SignatoryRecord: | ||
return [GovernanceAccountType.SignatoryRecord]; | ||
return [ | ||
GovernanceAccountType.SignatoryRecordV1, | ||
GovernanceAccountType.SignatoryRecordV2, | ||
]; | ||
case VoteRecord: | ||
@@ -64,6 +77,6 @@ return [ | ||
]; | ||
case ProposalInstruction: | ||
case ProposalTransaction: | ||
return [ | ||
GovernanceAccountType.ProposalInstructionV1, | ||
GovernanceAccountType.ProposalInstructionV2, | ||
GovernanceAccountType.ProposalTransactionV2, | ||
]; | ||
@@ -74,6 +87,10 @@ case RealmConfigAccount: | ||
return [ | ||
GovernanceAccountType.AccountGovernance, | ||
GovernanceAccountType.ProgramGovernance, | ||
GovernanceAccountType.MintGovernance, | ||
GovernanceAccountType.TokenGovernance, | ||
GovernanceAccountType.GovernanceV1, | ||
GovernanceAccountType.ProgramGovernanceV1, | ||
GovernanceAccountType.MintGovernanceV1, | ||
GovernanceAccountType.TokenGovernanceV1, | ||
GovernanceAccountType.GovernanceV2, | ||
GovernanceAccountType.ProgramGovernanceV2, | ||
GovernanceAccountType.MintGovernanceV2, | ||
GovernanceAccountType.TokenGovernanceV2, | ||
]; | ||
@@ -90,3 +107,3 @@ case ProgramMetadata: | ||
case GovernanceAccountType.VoteRecordV2: | ||
case GovernanceAccountType.ProposalInstructionV2: | ||
case GovernanceAccountType.ProposalTransactionV2: | ||
case GovernanceAccountType.ProposalV2: | ||
@@ -111,7 +128,8 @@ return constants_1.PROGRAM_VERSION_V2; | ||
exports.VoteThresholdPercentage = VoteThresholdPercentage; | ||
var VoteWeightSource; | ||
(function (VoteWeightSource) { | ||
VoteWeightSource[VoteWeightSource["Deposit"] = 0] = "Deposit"; | ||
VoteWeightSource[VoteWeightSource["Snapshot"] = 1] = "Snapshot"; | ||
})(VoteWeightSource = exports.VoteWeightSource || (exports.VoteWeightSource = {})); | ||
var VoteTipping; | ||
(function (VoteTipping) { | ||
VoteTipping[VoteTipping["Strict"] = 0] = "Strict"; | ||
VoteTipping[VoteTipping["Early"] = 1] = "Early"; | ||
VoteTipping[VoteTipping["Disabled"] = 2] = "Disabled"; | ||
})(VoteTipping = exports.VoteTipping || (exports.VoteTipping = {})); | ||
var InstructionExecutionStatus; | ||
@@ -192,2 +210,3 @@ (function (InstructionExecutionStatus) { | ||
this.useCommunityVoterWeightAddin = args.useCommunityVoterWeightAddin; | ||
this.useMaxCommunityVoterWeightAddin = args.useMaxCommunityVoterWeightAddin; | ||
} | ||
@@ -204,2 +223,3 @@ } | ||
this.useCommunityVoterWeightAddin = !!args.useCommunityVoterWeightAddin; | ||
this.useMaxCommunityVoterWeightAddin = !!args.useMaxCommunityVoterWeightAddin; | ||
this.reserved = args.reserved; | ||
@@ -211,6 +231,7 @@ } | ||
constructor(args) { | ||
this.accountType = GovernanceAccountType.Realm; | ||
this.accountType = GovernanceAccountType.RealmV1; | ||
this.communityMint = args.communityMint; | ||
this.config = args.config; | ||
this.reserved = args.reserved; | ||
this.votingProposalCount = args.votingProposalCount; | ||
this.authority = args.authority; | ||
@@ -237,2 +258,3 @@ this.name = args.name; | ||
this.communityVoterWeightAddin = args.communityVoterWeightAddin; | ||
this.maxCommunityVoterWeightAddin = args.maxCommunityVoterWeightAddin; | ||
} | ||
@@ -256,3 +278,3 @@ } | ||
this.maxVotingTime = args.maxVotingTime; | ||
this.voteWeightSource = (_a = args.voteWeightSource) !== null && _a !== void 0 ? _a : VoteWeightSource.Deposit; | ||
this.voteTipping = (_a = args.voteTipping) !== null && _a !== void 0 ? _a : VoteTipping.Strict; | ||
this.proposalCoolOffTime = (_b = args.proposalCoolOffTime) !== null && _b !== void 0 ? _b : 0; | ||
@@ -272,14 +294,19 @@ this.minCouncilTokensToCreateProposal = | ||
this.proposalCount = args.proposalCount; | ||
this.votingProposalCount = args.votingProposalCount; | ||
} | ||
isProgramGovernance() { | ||
return this.accountType === GovernanceAccountType.ProgramGovernance; | ||
return (this.accountType === GovernanceAccountType.ProgramGovernanceV1 || | ||
this.accountType === GovernanceAccountType.ProgramGovernanceV2); | ||
} | ||
isAccountGovernance() { | ||
return this.accountType === GovernanceAccountType.AccountGovernance; | ||
return (this.accountType === GovernanceAccountType.GovernanceV1 || | ||
this.accountType === GovernanceAccountType.GovernanceV2); | ||
} | ||
isMintGovernance() { | ||
return this.accountType === GovernanceAccountType.MintGovernance; | ||
return (this.accountType === GovernanceAccountType.MintGovernanceV1 || | ||
this.accountType === GovernanceAccountType.MintGovernanceV2); | ||
} | ||
isTokenGovernance() { | ||
return this.accountType === GovernanceAccountType.TokenGovernance; | ||
return (this.accountType === GovernanceAccountType.TokenGovernanceV1 || | ||
this.accountType === GovernanceAccountType.TokenGovernanceV2); | ||
} | ||
@@ -290,3 +317,3 @@ } | ||
constructor(args) { | ||
this.accountType = GovernanceAccountType.TokenOwnerRecord; | ||
this.accountType = GovernanceAccountType.TokenOwnerRecordV1; | ||
this.realm = args.realm; | ||
@@ -366,2 +393,6 @@ this.governingTokenMint = args.governingTokenMint; | ||
this.denyVoteWeight = args.denyVoteWeight; | ||
this.vetoVoteWeight = args.vetoVoteWeight; | ||
this.abstainVoteWeight = args.abstainVoteWeight; | ||
this.startVotingAt = args.startVotingAt; | ||
this.maxVotingTime = args.maxVotingTime; | ||
this.draftAt = args.draftAt; | ||
@@ -506,3 +537,3 @@ this.signingOffAt = args.signingOffAt; | ||
constructor(args) { | ||
this.accountType = GovernanceAccountType.SignatoryRecord; | ||
this.accountType = GovernanceAccountType.SignatoryRecordV1; | ||
this.proposal = args.proposal; | ||
@@ -619,5 +650,5 @@ this.signatory = args.signatory; | ||
exports.InstructionData = InstructionData; | ||
class ProposalInstruction { | ||
class ProposalTransaction { | ||
constructor(args) { | ||
this.accountType = GovernanceAccountType.ProposalInstructionV1; | ||
this.accountType = args.accountType; | ||
this.proposal = args.proposal; | ||
@@ -630,11 +661,30 @@ this.instructionIndex = args.instructionIndex; | ||
this.executionStatus = args.executionStatus; | ||
this.instructions = args.instructions; | ||
} | ||
getSingleInstruction() { | ||
if (this.accountType === GovernanceAccountType.ProposalInstructionV1) { | ||
return this.instruction; | ||
} | ||
if (this.instructions.length === 0) { | ||
throw new Error(`Transaction has no instructions`); | ||
} | ||
if (this.instructions.length > 1) { | ||
throw new Error(`Transaction has multiple instructions`); | ||
} | ||
return this.instructions[0]; | ||
} | ||
getAllInstructions() { | ||
if (this.accountType === GovernanceAccountType.ProposalInstructionV1) { | ||
return [this.instruction]; | ||
} | ||
return this.instructions; | ||
} | ||
} | ||
exports.ProposalInstruction = ProposalInstruction; | ||
function getProposalInstructionAddress(programId, programVersion, proposal, optionIndex, instructionIndex) { | ||
exports.ProposalTransaction = ProposalTransaction; | ||
function getProposalTransactionAddress(programId, programVersion, proposal, optionIndex, transactionIndex) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let optionIndexBuffer = Buffer.alloc(2); | ||
optionIndexBuffer.writeInt16LE(optionIndex, 0); | ||
let optionIndexBuffer = Buffer.alloc(1); | ||
optionIndexBuffer.writeUInt8(optionIndex); | ||
let instructionIndexBuffer = Buffer.alloc(2); | ||
instructionIndexBuffer.writeInt16LE(instructionIndex, 0); | ||
instructionIndexBuffer.writeInt16LE(transactionIndex, 0); | ||
const seeds = programVersion === constants_1.PROGRAM_VERSION_V1 | ||
@@ -656,3 +706,3 @@ ? [ | ||
} | ||
exports.getProposalInstructionAddress = getProposalInstructionAddress; | ||
exports.getProposalTransactionAddress = getProposalTransactionAddress; | ||
class ProgramMetadata { | ||
@@ -659,0 +709,0 @@ constructor(args) { |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { MintMaxVoteWeightSource } from './accounts'; | ||
import BN from 'bn.js'; | ||
export declare function createSetRealmConfig(programId: PublicKey, programVersion: number, realm: PublicKey, realmAuthority: PublicKey, councilMint: PublicKey | undefined, communityMintMaxVoteWeightSource: MintMaxVoteWeightSource, minCommunityTokensToCreateGovernance: BN, communityVoterWeightAddin: PublicKey | undefined, payer: PublicKey): Promise<TransactionInstruction>; | ||
export declare function createSetRealmConfig(programId: PublicKey, programVersion: number, realm: PublicKey, realmAuthority: PublicKey, councilMint: PublicKey | undefined, communityMintMaxVoteWeightSource: MintMaxVoteWeightSource, minCommunityTokensToCreateGovernance: BN, communityVoterWeightAddin: PublicKey | undefined, maxCommunityVoterWeightAddin: PublicKey | undefined, payer: PublicKey): Promise<TransactionInstruction>; | ||
//# sourceMappingURL=createSetRealmConfig.d.ts.map |
@@ -13,76 +13,8 @@ "use strict"; | ||
exports.createSetRealmConfig = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
const accounts_1 = require("./accounts"); | ||
const instructions_1 = require("./instructions"); | ||
const serialisation_1 = require("./serialisation"); | ||
const borsh_1 = require("borsh"); | ||
const runtime_1 = require("../tools/sdk/runtime"); | ||
function createSetRealmConfig(programId, programVersion, realm, realmAuthority, councilMint, communityMintMaxVoteWeightSource, minCommunityTokensToCreateGovernance, communityVoterWeightAddin, payer) { | ||
const withSetRealmConfig_1 = require("./withSetRealmConfig"); | ||
function createSetRealmConfig(programId, programVersion, realm, realmAuthority, councilMint, communityMintMaxVoteWeightSource, minCommunityTokensToCreateGovernance, communityVoterWeightAddin, maxCommunityVoterWeightAddin, payer) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const configArgs = new accounts_1.RealmConfigArgs({ | ||
useCouncilMint: councilMint !== undefined, | ||
communityMintMaxVoteWeightSource, | ||
minCommunityTokensToCreateGovernance, | ||
useCommunityVoterWeightAddin: communityVoterWeightAddin !== undefined, | ||
}); | ||
const args = new instructions_1.SetRealmConfigArgs({ configArgs }); | ||
const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args)); | ||
let keys = [ | ||
{ | ||
pubkey: realm, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: realmAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}, | ||
]; | ||
if (councilMint) { | ||
const councilTokenHoldingAddress = yield (0, accounts_1.getTokenHoldingAddress)(programId, realm, councilMint); | ||
keys = [ | ||
...keys, | ||
{ | ||
pubkey: councilMint, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ | ||
pubkey: councilTokenHoldingAddress, | ||
isSigner: false, | ||
isWritable: true, | ||
}, | ||
]; | ||
} | ||
if (programVersion > 1) { | ||
keys.push({ | ||
pubkey: runtime_1.SYSTEM_PROGRAM_ID, | ||
isSigner: false, | ||
isWritable: false, | ||
}); | ||
const realmConfigAddress = yield (0, accounts_1.getRealmConfigAddress)(programId, realm); | ||
keys.push({ | ||
pubkey: realmConfigAddress, | ||
isSigner: false, | ||
isWritable: true, | ||
}); | ||
if (communityVoterWeightAddin) { | ||
keys.push({ | ||
pubkey: payer, | ||
isSigner: true, | ||
isWritable: true, | ||
}); | ||
keys.push({ | ||
pubkey: communityVoterWeightAddin, | ||
isWritable: false, | ||
isSigner: false, | ||
}); | ||
} | ||
} | ||
return new web3_js_1.TransactionInstruction({ | ||
keys, | ||
programId, | ||
data, | ||
}); | ||
const instructions = []; | ||
yield (0, withSetRealmConfig_1.withSetRealmConfig)(instructions, programId, programVersion, realm, realmAuthority, councilMint, communityMintMaxVoteWeightSource, minCommunityTokensToCreateGovernance, communityVoterWeightAddin, maxCommunityVoterWeightAddin, payer); | ||
return instructions[0]; | ||
}); | ||
@@ -89,0 +21,0 @@ } |
import { SendTransactionError } from '../tools/sdk/runtime'; | ||
export declare const GovernanceError: readonly ["Invalid instruction passed to program", "Realm with the given name and governing mints already exists", "Invalid realm", "Invalid Governing Token Mint", "Governing Token Owner must sign transaction", "Governing Token Owner or Delegate must sign transaction", "All votes must be relinquished to withdraw governing tokens", "Invalid Token Owner Record account address", "Invalid GoverningMint for TokenOwnerRecord", "Invalid Realm for TokenOwnerRecord", "Invalid Proposal for ProposalInstruction", "Invalid Signatory account address", "Signatory already signed off", "Signatory must sign", "Invalid Proposal Owner", "Invalid Proposal for VoterRecord", "Invalid GoverningTokenOwner for VoteRecord", "Invalid Governance config: Vote threshold percentage out of range", "Proposal for the given Governance, Governing Token Mint and index already exists", "Token Owner already voted on the Proposal", "Owner doesn't have enough governing tokens to create Proposal", "Invalid State: Can't edit Signatories", "Invalid Proposal state", "Invalid State: Can't edit instructions", "Invalid State: Can't execute instruction", "Can't execute instruction within its hold up time", "Instruction already executed", "Invalid Instruction index", "Instruction hold up time is below the min specified by Governance", "Instruction at the given index for the Proposal already exists", "Invalid State: Can't sign off", "Invalid State: Can't vote", "Invalid State: Can't finalize vote", "Invalid State: Can't cancel Proposal", "Vote already relinquished", "Can't finalize vote. Voting still in progress", "Proposal voting time expired", "Invalid Signatory Mint", "Proposal does not belong to the given Governance", "Proposal does not belong to given Governing Mint", "Current mint authority must sign transaction", "Invalid mint authority", "Mint has no authority", "Invalid Token account owner", "Invalid Mint account owner", "Token Account is not initialized", "Token Account doesn't exist", "Token account data is invalid", "Token mint account data is invalid", "Token Mint account is not initialized", "Token Mint account doesn't exist", "Invalid ProgramData account address", "Invalid ProgramData account Data", "Provided upgrade authority doesn't match current program upgrade authority", "Current program upgrade authority must sign transaction", "Given program is not upgradable", "Invalid token owner", "Current token owner must sign transaction", "Given VoteThresholdPercentageType is not supported", "Given VoteWeightSource is not supported", "Proposal cool off time is not supported", "Governance PDA must sign", "Instruction already flagged with error", "Invalid Realm for Governance", "Invalid Authority for Realm", "Realm has no authority", "Realm authority must sign", "Invalid governing token holding account", "Realm council mint change is not supported", "Not supported mint max vote weight source", "Invalid max vote weight supply fraction", "Owner doesn't have enough governing tokens to create Governance", "Too many outstanding proposals", "All proposals must be finalized to withdraw governing tokens", "Invalid VoterWeightRecord for Realm", "Invalid VoterWeightRecord for GoverningTokenMint", "Invalid VoterWeightRecord for TokenOwner", "VoterWeightRecord expired", "Invalid RealmConfig for Realm", "TokenOwnerRecord already exists", "Governing token deposits not allowed", "Invalid vote choice weight percentage", "Vote type not supported", "Invalid proposal options", "Proposal is not not executable", "Invalid vote", "Cannot execute defeated option"]; | ||
export declare const GovernanceError: readonly ["Invalid instruction passed to program", "Realm with the given name and governing mints already exists", "Invalid realm", "Invalid Governing Token Mint", "Governing Token Owner must sign transaction", "Governing Token Owner or Delegate must sign transaction", "All votes must be relinquished to withdraw governing tokens", "Invalid Token Owner Record account address", "Invalid GoverningMint for TokenOwnerRecord", "Invalid Realm for TokenOwnerRecord", "Invalid Proposal for ProposalTransaction", "Invalid Signatory account address", "Signatory already signed off", "Signatory must sign", "Invalid Proposal Owner", "Invalid Proposal for VoterRecord", "Invalid GoverningTokenOwner for VoteRecord", "Invalid Governance config: Vote threshold percentage out of range", "Proposal for the given Governance, Governing Token Mint and index already exists", "Token Owner already voted on the Proposal", "Owner doesn't have enough governing tokens to create Proposal", "Invalid State: Can't edit Signatories", "Invalid Proposal state", "Invalid State: Can't edit instructions", "Invalid State: Can't execute instruction", "Can't execute instruction within its hold up time", "Instruction already executed", "Invalid Instruction index", "Instruction hold up time is below the min specified by Governance", "Instruction at the given index for the Proposal already exists", "Invalid State: Can't sign off", "Invalid State: Can't vote", "Invalid State: Can't finalize vote", "Invalid State: Can't cancel Proposal", "Vote already relinquished", "Can't finalize vote. Voting still in progress", "Proposal voting time expired", "Invalid Signatory Mint", "Proposal does not belong to the given Governance", "Proposal does not belong to given Governing Mint", "Current mint authority must sign transaction", "Invalid mint authority", "Mint has no authority", "Invalid Token account owner", "Invalid Mint account owner", "Token Account is not initialized", "Token Account doesn't exist", "Token account data is invalid", "Token mint account data is invalid", "Token Mint account is not initialized", "Token Mint account doesn't exist", "Invalid ProgramData account address", "Invalid ProgramData account Data", "Provided upgrade authority doesn't match current program upgrade authority", "Current program upgrade authority must sign transaction", "Given program is not upgradable", "Invalid token owner", "Current token owner must sign transaction", "Given VoteThresholdPercentageType is not supported", "Given VoteWeightSource is not supported", "Proposal cool off time is not supported", "Governance PDA must sign", "Instruction already flagged with error", "Invalid Realm for Governance", "Invalid Authority for Realm", "Realm has no authority", "Realm authority must sign", "Invalid governing token holding account", "Realm council mint change is not supported", "Not supported mint max vote weight source", "Invalid max vote weight supply fraction", "Owner doesn't have enough governing tokens to create Governance", "Too many outstanding proposals", "All proposals must be finalized to withdraw governing tokens", "Invalid VoterWeightRecord for Realm", "Invalid VoterWeightRecord for GoverningTokenMint", "Invalid VoterWeightRecord for TokenOwner", "VoterWeightRecord expired", "Invalid RealmConfig for Realm", "TokenOwnerRecord already exists", "Governing token deposits not allowed", "Invalid vote choice weight percentage", "Vote type not supported", "Invalid proposal options", "Proposal is not not executable", "Invalid vote", "Cannot execute defeated option", "VoterWeightRecord invalid action", "VoterWeightRecord invalid action target", "Invalid MaxVoterWeightRecord for Realm", "MaxVoterWeightRecord expired", "Cannot execute defeated option", "Not supported VoteType", "RealmConfig change not allowed", "GovernanceConfig change not allowed"]; | ||
export declare const TokenError: readonly ["Lamport balance below rent-exempt threshold", "Insufficient funds", "Invalid Mint", "Account not associated with this Mint", "Owner does not match", "Fixed supply", "Already in use", "Invalid number of provided signers", "Invalid number of required signers", "State is uninitialized", "Instruction does not support native tokens", "Non-native account can only be closed if its balance is zero", "Invalid instruction", "State is invalid for requested operation", "Operation overflowed", "Account does not support specified authority type", "This token mint cannot freeze accounts", "Account is frozen", "The provided decimals value different from the Mint decimals"]; | ||
@@ -4,0 +4,0 @@ export declare const GovernanceToolsError: readonly ["Account already initialized", "Account doesn't exist", "Invalid account owner", "Invalid Account type"]; |
@@ -15,3 +15,3 @@ "use strict"; | ||
'Invalid Realm for TokenOwnerRecord', | ||
'Invalid Proposal for ProposalInstruction', | ||
'Invalid Proposal for ProposalTransaction', | ||
'Invalid Signatory account address', | ||
@@ -92,3 +92,11 @@ 'Signatory already signed off', | ||
'Invalid vote', | ||
'Cannot execute defeated option', // CannotExecuteDefeatedOption | ||
'Cannot execute defeated option', | ||
'VoterWeightRecord invalid action', | ||
'VoterWeightRecord invalid action target', | ||
'Invalid MaxVoterWeightRecord for Realm', | ||
'MaxVoterWeightRecord expired', | ||
'Cannot execute defeated option', | ||
'Not supported VoteType', | ||
'RealmConfig change not allowed', | ||
'GovernanceConfig change not allowed', // GovernanceConfigChangeNotAllowed | ||
]; | ||
@@ -95,0 +103,0 @@ exports.TokenError = [ |
@@ -13,3 +13,3 @@ export * from './accounts'; | ||
export * from './withCastVote'; | ||
export * from './withCreateAccountGovernance'; | ||
export * from './withCreateGovernance'; | ||
export * from './withCreateMintGovernance'; | ||
@@ -25,6 +25,6 @@ export * from './withCreateNativeTreasury'; | ||
export * from './withFinalizeVote'; | ||
export * from './withFlagInstructionError'; | ||
export * from './withInsertInstruction'; | ||
export * from './withFlagTransactionError'; | ||
export * from './withInsertTransaction'; | ||
export * from './withRelinquishVote'; | ||
export * from './withRemoveInstruction'; | ||
export * from './withRemoveTransaction'; | ||
export * from './withSetRealmAuthority'; | ||
@@ -31,0 +31,0 @@ export * from './withSignOffProposal'; |
@@ -25,3 +25,3 @@ "use strict"; | ||
__exportStar(require("./withCastVote"), exports); | ||
__exportStar(require("./withCreateAccountGovernance"), exports); | ||
__exportStar(require("./withCreateGovernance"), exports); | ||
__exportStar(require("./withCreateMintGovernance"), exports); | ||
@@ -37,6 +37,6 @@ __exportStar(require("./withCreateNativeTreasury"), exports); | ||
__exportStar(require("./withFinalizeVote"), exports); | ||
__exportStar(require("./withFlagInstructionError"), exports); | ||
__exportStar(require("./withInsertInstruction"), exports); | ||
__exportStar(require("./withFlagTransactionError"), exports); | ||
__exportStar(require("./withInsertTransaction"), exports); | ||
__exportStar(require("./withRelinquishVote"), exports); | ||
__exportStar(require("./withRemoveInstruction"), exports); | ||
__exportStar(require("./withRemoveTransaction"), exports); | ||
__exportStar(require("./withSetRealmAuthority"), exports); | ||
@@ -43,0 +43,0 @@ __exportStar(require("./withSignOffProposal"), exports); |
@@ -9,3 +9,3 @@ import { PublicKey } from '@solana/web3.js'; | ||
SetGovernanceDelegate = 3, | ||
CreateAccountGovernance = 4, | ||
CreateGovernance = 4, | ||
CreateProgramGovernance = 5, | ||
@@ -15,4 +15,4 @@ CreateProposal = 6, | ||
RemoveSignatory = 8, | ||
InsertInstruction = 9, | ||
RemoveInstruction = 10, | ||
InsertTransaction = 9, | ||
RemoveTransaction = 10, | ||
CancelProposal = 11, | ||
@@ -23,7 +23,7 @@ SignOffProposal = 12, | ||
RelinquishVote = 15, | ||
ExecuteInstruction = 16, | ||
ExecuteTransaction = 16, | ||
CreateMintGovernance = 17, | ||
CreateTokenGovernance = 18, | ||
SetGovernanceConfig = 19, | ||
FlagInstructionError = 20, | ||
FlagTransactionError = 20, | ||
SetRealmAuthority = 21, | ||
@@ -54,3 +54,3 @@ SetRealmConfig = 22, | ||
} | ||
export declare class CreateAccountGovernanceArgs { | ||
export declare class CreateGovernanceArgs { | ||
instruction: GovernanceInstruction; | ||
@@ -74,6 +74,6 @@ config: GovernanceConfig; | ||
config: GovernanceConfig; | ||
transferMintAuthority: boolean; | ||
transferMintAuthorities: boolean; | ||
constructor(args: { | ||
config: GovernanceConfig; | ||
transferMintAuthority: boolean; | ||
transferMintAuthorities: boolean; | ||
}); | ||
@@ -170,3 +170,3 @@ } | ||
} | ||
export declare class InsertInstructionArgs { | ||
export declare class InsertTransactionArgs { | ||
instruction: GovernanceInstruction; | ||
@@ -176,3 +176,4 @@ index: number; | ||
holdUpTime: number; | ||
instructionData: InstructionData; | ||
instructionData: InstructionData | undefined; | ||
instructions: InstructionData[] | undefined; | ||
constructor(args: { | ||
@@ -182,21 +183,27 @@ index: number; | ||
holdUpTime: number; | ||
instructionData: InstructionData; | ||
instructionData: InstructionData | undefined; | ||
instructions: InstructionData[] | undefined; | ||
}); | ||
} | ||
export declare class RemoveInstructionArgs { | ||
export declare class RemoveTransactionArgs { | ||
instruction: GovernanceInstruction; | ||
} | ||
export declare class ExecuteInstructionArgs { | ||
export declare class ExecuteTransactionArgs { | ||
instruction: GovernanceInstruction; | ||
} | ||
export declare class FlagInstructionErrorArgs { | ||
export declare class FlagTransactionErrorArgs { | ||
instruction: GovernanceInstruction; | ||
} | ||
export declare enum SetRealmAuthorityAction { | ||
SetUnchecked = 0, | ||
SetChecked = 1, | ||
Remove = 2 | ||
} | ||
export declare class SetRealmAuthorityArgs { | ||
instruction: GovernanceInstruction; | ||
newRealmAuthority: PublicKey | undefined; | ||
removeAuthority: boolean; | ||
action: SetRealmAuthorityAction | undefined; | ||
constructor(args: { | ||
newRealmAuthority: PublicKey | undefined; | ||
removeAuthority: boolean; | ||
action: SetRealmAuthorityAction | undefined; | ||
}); | ||
@@ -203,0 +210,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CreateNativeTreasuryArgs = exports.UpdateProgramMetadataArgs = exports.CreateTokenOwnerRecordArgs = exports.SetRealmConfigArgs = exports.SetRealmAuthorityArgs = exports.FlagInstructionErrorArgs = exports.ExecuteInstructionArgs = exports.RemoveInstructionArgs = exports.InsertInstructionArgs = exports.FinalizeVoteArgs = exports.RelinquishVoteArgs = exports.CastVoteArgs = exports.Vote = exports.VoteKind = exports.VoteChoice = exports.YesNoVote = exports.CancelProposalArgs = exports.SignOffProposalArgs = exports.AddSignatoryArgs = exports.CreateProposalArgs = exports.SetGovernanceConfigArgs = exports.CreateTokenGovernanceArgs = exports.CreateMintGovernanceArgs = exports.CreateProgramGovernanceArgs = exports.CreateAccountGovernanceArgs = exports.WithdrawGoverningTokensArgs = exports.DepositGoverningTokensArgs = exports.CreateRealmArgs = exports.GovernanceInstruction = void 0; | ||
exports.CreateNativeTreasuryArgs = exports.UpdateProgramMetadataArgs = exports.CreateTokenOwnerRecordArgs = exports.SetRealmConfigArgs = exports.SetRealmAuthorityArgs = exports.SetRealmAuthorityAction = exports.FlagTransactionErrorArgs = exports.ExecuteTransactionArgs = exports.RemoveTransactionArgs = exports.InsertTransactionArgs = exports.FinalizeVoteArgs = exports.RelinquishVoteArgs = exports.CastVoteArgs = exports.Vote = exports.VoteKind = exports.VoteChoice = exports.YesNoVote = exports.CancelProposalArgs = exports.SignOffProposalArgs = exports.AddSignatoryArgs = exports.CreateProposalArgs = exports.SetGovernanceConfigArgs = exports.CreateTokenGovernanceArgs = exports.CreateMintGovernanceArgs = exports.CreateProgramGovernanceArgs = exports.CreateGovernanceArgs = exports.WithdrawGoverningTokensArgs = exports.DepositGoverningTokensArgs = exports.CreateRealmArgs = exports.GovernanceInstruction = void 0; | ||
var GovernanceInstruction; | ||
@@ -10,3 +10,3 @@ (function (GovernanceInstruction) { | ||
GovernanceInstruction[GovernanceInstruction["SetGovernanceDelegate"] = 3] = "SetGovernanceDelegate"; | ||
GovernanceInstruction[GovernanceInstruction["CreateAccountGovernance"] = 4] = "CreateAccountGovernance"; | ||
GovernanceInstruction[GovernanceInstruction["CreateGovernance"] = 4] = "CreateGovernance"; | ||
GovernanceInstruction[GovernanceInstruction["CreateProgramGovernance"] = 5] = "CreateProgramGovernance"; | ||
@@ -16,4 +16,4 @@ GovernanceInstruction[GovernanceInstruction["CreateProposal"] = 6] = "CreateProposal"; | ||
GovernanceInstruction[GovernanceInstruction["RemoveSignatory"] = 8] = "RemoveSignatory"; | ||
GovernanceInstruction[GovernanceInstruction["InsertInstruction"] = 9] = "InsertInstruction"; | ||
GovernanceInstruction[GovernanceInstruction["RemoveInstruction"] = 10] = "RemoveInstruction"; | ||
GovernanceInstruction[GovernanceInstruction["InsertTransaction"] = 9] = "InsertTransaction"; | ||
GovernanceInstruction[GovernanceInstruction["RemoveTransaction"] = 10] = "RemoveTransaction"; | ||
GovernanceInstruction[GovernanceInstruction["CancelProposal"] = 11] = "CancelProposal"; | ||
@@ -24,7 +24,7 @@ GovernanceInstruction[GovernanceInstruction["SignOffProposal"] = 12] = "SignOffProposal"; | ||
GovernanceInstruction[GovernanceInstruction["RelinquishVote"] = 15] = "RelinquishVote"; | ||
GovernanceInstruction[GovernanceInstruction["ExecuteInstruction"] = 16] = "ExecuteInstruction"; | ||
GovernanceInstruction[GovernanceInstruction["ExecuteTransaction"] = 16] = "ExecuteTransaction"; | ||
GovernanceInstruction[GovernanceInstruction["CreateMintGovernance"] = 17] = "CreateMintGovernance"; | ||
GovernanceInstruction[GovernanceInstruction["CreateTokenGovernance"] = 18] = "CreateTokenGovernance"; | ||
GovernanceInstruction[GovernanceInstruction["SetGovernanceConfig"] = 19] = "SetGovernanceConfig"; | ||
GovernanceInstruction[GovernanceInstruction["FlagInstructionError"] = 20] = "FlagInstructionError"; | ||
GovernanceInstruction[GovernanceInstruction["FlagTransactionError"] = 20] = "FlagTransactionError"; | ||
GovernanceInstruction[GovernanceInstruction["SetRealmAuthority"] = 21] = "SetRealmAuthority"; | ||
@@ -57,9 +57,9 @@ GovernanceInstruction[GovernanceInstruction["SetRealmConfig"] = 22] = "SetRealmConfig"; | ||
exports.WithdrawGoverningTokensArgs = WithdrawGoverningTokensArgs; | ||
class CreateAccountGovernanceArgs { | ||
class CreateGovernanceArgs { | ||
constructor(args) { | ||
this.instruction = GovernanceInstruction.CreateAccountGovernance; | ||
this.instruction = GovernanceInstruction.CreateGovernance; | ||
this.config = args.config; | ||
} | ||
} | ||
exports.CreateAccountGovernanceArgs = CreateAccountGovernanceArgs; | ||
exports.CreateGovernanceArgs = CreateGovernanceArgs; | ||
class CreateProgramGovernanceArgs { | ||
@@ -77,3 +77,3 @@ constructor(args) { | ||
this.config = args.config; | ||
this.transferMintAuthority = !!args.transferMintAuthority; | ||
this.transferMintAuthorities = !!args.transferMintAuthorities; | ||
} | ||
@@ -202,30 +202,39 @@ } | ||
exports.FinalizeVoteArgs = FinalizeVoteArgs; | ||
class InsertInstructionArgs { | ||
class InsertTransactionArgs { | ||
constructor(args) { | ||
this.instruction = GovernanceInstruction.InsertInstruction; | ||
this.instruction = GovernanceInstruction.InsertTransaction; | ||
this.index = args.index; | ||
this.optionIndex = args.optionIndex; | ||
this.holdUpTime = args.holdUpTime; | ||
// V1 | ||
this.instructionData = args.instructionData; | ||
// V2 | ||
this.instructions = args.instructions; | ||
} | ||
} | ||
exports.InsertInstructionArgs = InsertInstructionArgs; | ||
class RemoveInstructionArgs { | ||
exports.InsertTransactionArgs = InsertTransactionArgs; | ||
class RemoveTransactionArgs { | ||
constructor() { | ||
this.instruction = GovernanceInstruction.RemoveInstruction; | ||
this.instruction = GovernanceInstruction.RemoveTransaction; | ||
} | ||
} | ||
exports.RemoveInstructionArgs = RemoveInstructionArgs; | ||
class ExecuteInstructionArgs { | ||
exports.RemoveTransactionArgs = RemoveTransactionArgs; | ||
class ExecuteTransactionArgs { | ||
constructor() { | ||
this.instruction = GovernanceInstruction.ExecuteInstruction; | ||
this.instruction = GovernanceInstruction.ExecuteTransaction; | ||
} | ||
} | ||
exports.ExecuteInstructionArgs = ExecuteInstructionArgs; | ||
class FlagInstructionErrorArgs { | ||
exports.ExecuteTransactionArgs = ExecuteTransactionArgs; | ||
class FlagTransactionErrorArgs { | ||
constructor() { | ||
this.instruction = GovernanceInstruction.FlagInstructionError; | ||
this.instruction = GovernanceInstruction.FlagTransactionError; | ||
} | ||
} | ||
exports.FlagInstructionErrorArgs = FlagInstructionErrorArgs; | ||
exports.FlagTransactionErrorArgs = FlagTransactionErrorArgs; | ||
var SetRealmAuthorityAction; | ||
(function (SetRealmAuthorityAction) { | ||
SetRealmAuthorityAction[SetRealmAuthorityAction["SetUnchecked"] = 0] = "SetUnchecked"; | ||
SetRealmAuthorityAction[SetRealmAuthorityAction["SetChecked"] = 1] = "SetChecked"; | ||
SetRealmAuthorityAction[SetRealmAuthorityAction["Remove"] = 2] = "Remove"; | ||
})(SetRealmAuthorityAction = exports.SetRealmAuthorityAction || (exports.SetRealmAuthorityAction = {})); | ||
class SetRealmAuthorityArgs { | ||
@@ -237,3 +246,3 @@ constructor(args) { | ||
// V2 | ||
this.removeAuthority = args.removeAuthority; | ||
this.action = args.action; | ||
} | ||
@@ -240,0 +249,0 @@ } |
@@ -124,6 +124,9 @@ "use strict"; | ||
// V1 of the program used restrictive instruction deserialisation which didn't allow additional data | ||
programVersion > constants_1.PROGRAM_VERSION_V1 | ||
? ['useCommunityVoterWeightAddin', 'u8'] | ||
: undefined, | ||
].filter(Boolean), | ||
...(programVersion > constants_1.PROGRAM_VERSION_V1 | ||
? [ | ||
['useCommunityVoterWeightAddin', 'u8'], | ||
['useMaxCommunityVoterWeightAddin', 'u8'], | ||
] | ||
: []), | ||
], | ||
}, | ||
@@ -161,3 +164,3 @@ ], | ||
[ | ||
instructions_1.CreateAccountGovernanceArgs, | ||
instructions_1.CreateGovernanceArgs, | ||
{ | ||
@@ -189,3 +192,3 @@ kind: 'struct', | ||
['config', accounts_1.GovernanceConfig], | ||
['transferMintAuthority', 'u8'], | ||
['transferMintAuthorities', 'u8'], | ||
], | ||
@@ -294,3 +297,3 @@ }, | ||
[ | ||
instructions_1.InsertInstructionArgs, | ||
instructions_1.InsertTransactionArgs, | ||
{ | ||
@@ -301,7 +304,9 @@ kind: 'struct', | ||
programVersion > constants_1.PROGRAM_VERSION_V1 | ||
? ['optionIndex', 'u16'] | ||
? ['optionIndex', 'u8'] | ||
: undefined, | ||
['index', 'u16'], | ||
['holdUpTime', 'u32'], | ||
['instructionData', accounts_1.InstructionData], | ||
programVersion > constants_1.PROGRAM_VERSION_V1 | ||
? ['instructions', [accounts_1.InstructionData]] | ||
: ['instructionData', accounts_1.InstructionData], | ||
].filter(Boolean), | ||
@@ -311,3 +316,3 @@ }, | ||
[ | ||
instructions_1.RemoveInstructionArgs, | ||
instructions_1.RemoveTransactionArgs, | ||
{ | ||
@@ -319,3 +324,3 @@ kind: 'struct', | ||
[ | ||
instructions_1.ExecuteInstructionArgs, | ||
instructions_1.ExecuteTransactionArgs, | ||
{ | ||
@@ -327,3 +332,3 @@ kind: 'struct', | ||
[ | ||
instructions_1.FlagInstructionErrorArgs, | ||
instructions_1.FlagTransactionErrorArgs, | ||
{ | ||
@@ -342,3 +347,3 @@ kind: 'struct', | ||
? [['newRealmAuthority', { kind: 'option', type: 'pubkey' }]] | ||
: [['removeAuthority', 'u8']]), | ||
: [['action', 'u8']]), | ||
], | ||
@@ -416,3 +421,4 @@ }, | ||
['useCommunityVoterWeightAddin', 'u8'], | ||
['reserved', [7]], | ||
['useMaxCommunityVoterWeightAddin', 'u8'], | ||
['reserved', [6]], | ||
['minCommunityTokensToCreateGovernance', 'u64'], | ||
@@ -432,3 +438,4 @@ ['communityMintMaxVoteWeightSource', accounts_1.MintMaxVoteWeightSource], | ||
['config', accounts_1.RealmConfig], | ||
['reserved', [8]], | ||
['reserved', [6]], | ||
['votingProposalCount', 'u16'], | ||
['authority', { kind: 'option', type: 'pubkey' }], | ||
@@ -447,2 +454,3 @@ ['name', 'string'], | ||
['communityVoterWeightAddin', { kind: 'option', type: 'pubkey' }], | ||
['maxCommunityVoterWeightAddin', { kind: 'option', type: 'pubkey' }], | ||
], | ||
@@ -461,3 +469,4 @@ }, | ||
['config', accounts_1.GovernanceConfig], | ||
['reserved', [8]], | ||
['reserved', [6]], | ||
['votingProposalCount', 'u16'], | ||
], | ||
@@ -485,3 +494,3 @@ }, | ||
['maxVotingTime', 'u32'], | ||
['voteWeightSource', 'u8'], | ||
['voteTipping', 'u8'], | ||
['proposalCoolOffTime', 'u32'], | ||
@@ -548,2 +557,5 @@ ['minCouncilTokensToCreateProposal', 'u64'], | ||
['denyVoteWeight', { kind: 'option', type: 'u64' }], | ||
['vetoVoteWeight', { kind: 'option', type: 'u64' }], | ||
['abstainVoteWeight', { kind: 'option', type: 'u64' }], | ||
['startVotingAt', { kind: 'option', type: 'u64' }], | ||
]), | ||
@@ -559,2 +571,5 @@ ['draftAt', 'u64'], | ||
['maxVoteWeight', { kind: 'option', type: 'u64' }], | ||
...(programVersion === constants_1.PROGRAM_VERSION_V1 | ||
? [] | ||
: [['maxVotingTime', { kind: 'option', type: 'u32' }]]), | ||
[ | ||
@@ -564,2 +579,5 @@ 'voteThresholdPercentage', | ||
], | ||
...(programVersion === constants_1.PROGRAM_VERSION_V1 | ||
? [] | ||
: [['reserved', [64]]]), | ||
['name', 'string'], | ||
@@ -611,3 +629,3 @@ ['descriptionLink', 'string'], | ||
[ | ||
accounts_1.ProposalInstruction, | ||
accounts_1.ProposalTransaction, | ||
{ | ||
@@ -619,7 +637,9 @@ kind: 'struct', | ||
programVersion > constants_1.PROGRAM_VERSION_V1 | ||
? ['optionIndex', 'u16'] | ||
? ['optionIndex', 'u8'] | ||
: undefined, | ||
['instructionIndex', 'u16'], | ||
['holdUpTime', 'u32'], | ||
['instruction', accounts_1.InstructionData], | ||
programVersion > constants_1.PROGRAM_VERSION_V1 | ||
? ['instructions', [accounts_1.InstructionData]] | ||
: ['instruction', accounts_1.InstructionData], | ||
['executedAt', { kind: 'option', type: 'u64' }], | ||
@@ -626,0 +646,0 @@ ['executionStatus', 'u8'], |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
export declare const withAddSignatory: (instructions: TransactionInstruction[], programId: PublicKey, proposal: PublicKey, tokenOwnerRecord: PublicKey, governanceAuthority: PublicKey, signatory: PublicKey, payer: PublicKey) => Promise<PublicKey>; | ||
export declare const withAddSignatory: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, proposal: PublicKey, tokenOwnerRecord: PublicKey, governanceAuthority: PublicKey, signatory: PublicKey, payer: PublicKey) => Promise<PublicKey>; | ||
//# sourceMappingURL=withAddSignatory.d.ts.map |
@@ -19,3 +19,4 @@ "use strict"; | ||
const runtime_1 = require("../tools/sdk/runtime"); | ||
const withAddSignatory = (instructions, programId, proposal, tokenOwnerRecord, governanceAuthority, signatory, payer) => __awaiter(void 0, void 0, void 0, function* () { | ||
const constants_1 = require("../registry/constants"); | ||
const withAddSignatory = (instructions, programId, programVersion, proposal, tokenOwnerRecord, governanceAuthority, signatory, payer) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.AddSignatoryArgs({ signatory }); | ||
@@ -55,8 +56,10 @@ const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
]; | ||
}); | ||
} | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -63,0 +66,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
export declare const withCancelProposal: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, proposal: PublicKey, proposalOwnerRecord: PublicKey, governanceAuthority: PublicKey, governance: PublicKey) => void; | ||
export declare const withCancelProposal: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governance: PublicKey, proposal: PublicKey, proposalOwnerRecord: PublicKey, governanceAuthority: PublicKey) => void; | ||
//# sourceMappingURL=withCancelProposal.d.ts.map |
@@ -9,32 +9,35 @@ "use strict"; | ||
const constants_1 = require("../registry/constants"); | ||
const withCancelProposal = (instructions, programId, programVersion, proposal, proposalOwnerRecord, governanceAuthority, governance) => { | ||
const withCancelProposal = (instructions, programId, programVersion, realm, governance, proposal, proposalOwnerRecord, governanceAuthority) => { | ||
const args = new instructions_1.CancelProposalArgs(); | ||
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
let keys = [ | ||
{ | ||
pubkey: proposal, | ||
let keys = []; | ||
if (programVersion > constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: realm, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: proposalOwnerRecord, | ||
}, { | ||
pubkey: governance, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}, | ||
{ | ||
}); | ||
} | ||
keys.push({ | ||
pubkey: proposal, | ||
isWritable: true, | ||
isSigner: false, | ||
}, { | ||
pubkey: proposalOwnerRecord, | ||
isWritable: true, | ||
isSigner: false, | ||
}, { | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}); | ||
if (programVersion == constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
]; | ||
if (programVersion > constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: governance, | ||
isWritable: false, | ||
isSigner: false, | ||
}); | ||
@@ -41,0 +44,0 @@ } |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { Vote } from './instructions'; | ||
export declare const withCastVote: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governance: PublicKey, proposal: PublicKey, proposalOwnerRecord: PublicKey, tokenOwnerRecord: PublicKey, governanceAuthority: PublicKey, governingTokenMint: PublicKey, vote: Vote, payer: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
export declare const withCastVote: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governance: PublicKey, proposal: PublicKey, proposalOwnerRecord: PublicKey, tokenOwnerRecord: PublicKey, governanceAuthority: PublicKey, governingTokenMint: PublicKey, vote: Vote, payer: PublicKey, voterWeightRecord?: PublicKey | undefined, maxVoterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
//# sourceMappingURL=withCastVote.d.ts.map |
@@ -20,4 +20,4 @@ "use strict"; | ||
const runtime_1 = require("../tools/sdk/runtime"); | ||
const withVoterWeightAccounts_1 = require("./withVoterWeightAccounts"); | ||
const withCastVote = (instructions, programId, programVersion, realm, governance, proposal, proposalOwnerRecord, tokenOwnerRecord, governanceAuthority, governingTokenMint, vote, payer, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const withRealmConfigAccounts_1 = require("./withRealmConfigAccounts"); | ||
const withCastVote = (instructions, programId, programVersion, realm, governance, proposal, proposalOwnerRecord, tokenOwnerRecord, governanceAuthority, governingTokenMint, vote, payer, voterWeightRecord, maxVoterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.CastVoteArgs(programVersion === constants_1.PROGRAM_VERSION_V1 | ||
@@ -28,6 +28,7 @@ ? { yesNoVote: vote.toYesNoVote(), vote: undefined } | ||
const voteRecordAddress = yield (0, accounts_1.getVoteRecordAddress)(programId, proposal, tokenOwnerRecord); | ||
const [realmIsWritable, governanceIsWritable] = programVersion === constants_1.PROGRAM_VERSION_V1 ? [false, false] : [true, true]; | ||
const keys = [ | ||
{ | ||
pubkey: realm, | ||
isWritable: false, | ||
isWritable: realmIsWritable, | ||
isSigner: false, | ||
@@ -37,3 +38,3 @@ }, | ||
pubkey: governance, | ||
isWritable: false, | ||
isWritable: governanceIsWritable, | ||
isSigner: false, | ||
@@ -81,14 +82,15 @@ }, | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ | ||
}, { | ||
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
]; | ||
(0, withVoterWeightAccounts_1.withVoterWeightAccounts)(keys, programId, realm, voterWeightRecord); | ||
}); | ||
} | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, programId, realm, voterWeightRecord, maxVoterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -95,0 +97,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { GovernanceConfig } from './accounts'; | ||
export declare const withCreateMintGovernance: (instructions: TransactionInstruction[], programId: PublicKey, realm: PublicKey, governedMint: PublicKey, config: GovernanceConfig, transferMintAuthority: boolean, mintAuthority: PublicKey, tokenOwnerRecord: PublicKey, payer: PublicKey, governanceAuthority: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
export declare const withCreateMintGovernance: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governedMint: PublicKey, config: GovernanceConfig, transferMintAuthorities: boolean, mintAuthority: PublicKey, tokenOwnerRecord: PublicKey, payer: PublicKey, governanceAuthority: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
//# sourceMappingURL=withCreateMintGovernance.d.ts.map |
@@ -19,7 +19,8 @@ "use strict"; | ||
const runtime_1 = require("../tools/sdk/runtime"); | ||
const withVoterWeightAccounts_1 = require("./withVoterWeightAccounts"); | ||
const withCreateMintGovernance = (instructions, programId, realm, governedMint, config, transferMintAuthority, mintAuthority, tokenOwnerRecord, payer, governanceAuthority, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const withRealmConfigAccounts_1 = require("./withRealmConfigAccounts"); | ||
const constants_1 = require("../registry/constants"); | ||
const withCreateMintGovernance = (instructions, programId, programVersion, realm, governedMint, config, transferMintAuthorities, mintAuthority, tokenOwnerRecord, payer, governanceAuthority, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.CreateMintGovernanceArgs({ | ||
config, | ||
transferMintAuthority, | ||
transferMintAuthorities: transferMintAuthorities, | ||
}); | ||
@@ -69,14 +70,16 @@ const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}, | ||
]; | ||
(0, withVoterWeightAccounts_1.withVoterWeightAccounts)(keys, programId, realm, voterWeightRecord); | ||
}); | ||
} | ||
keys.push({ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}); | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, programId, realm, voterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -83,0 +86,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { GovernanceConfig } from './accounts'; | ||
export declare const withCreateProgramGovernance: (instructions: TransactionInstruction[], programId: PublicKey, realm: PublicKey, governedProgram: PublicKey, config: GovernanceConfig, transferUpgradeAuthority: boolean, programUpgradeAuthority: PublicKey, tokenOwnerRecord: PublicKey, payer: PublicKey, governanceAuthority: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
export declare const withCreateProgramGovernance: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governedProgram: PublicKey, config: GovernanceConfig, transferUpgradeAuthority: boolean, programUpgradeAuthority: PublicKey, tokenOwnerRecord: PublicKey, payer: PublicKey, governanceAuthority: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
//# sourceMappingURL=withCreateProgramGovernance.d.ts.map |
@@ -19,4 +19,5 @@ "use strict"; | ||
const bpfUpgradeableLoader_1 = require("../tools/sdk/bpfUpgradeableLoader"); | ||
const withVoterWeightAccounts_1 = require("./withVoterWeightAccounts"); | ||
const withCreateProgramGovernance = (instructions, programId, realm, governedProgram, config, transferUpgradeAuthority, programUpgradeAuthority, tokenOwnerRecord, payer, governanceAuthority, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const withRealmConfigAccounts_1 = require("./withRealmConfigAccounts"); | ||
const constants_1 = require("../registry/constants"); | ||
const withCreateProgramGovernance = (instructions, programId, programVersion, realm, governedProgram, config, transferUpgradeAuthority, programUpgradeAuthority, tokenOwnerRecord, payer, governanceAuthority, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.CreateProgramGovernanceArgs({ | ||
@@ -79,14 +80,16 @@ config, | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}, | ||
]; | ||
(0, withVoterWeightAccounts_1.withVoterWeightAccounts)(keys, programId, realm, voterWeightRecord); | ||
}); | ||
} | ||
keys.push({ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}); | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, programId, realm, voterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -93,0 +96,0 @@ keys, |
@@ -20,3 +20,3 @@ "use strict"; | ||
const runtime_1 = require("../tools/sdk/runtime"); | ||
const withVoterWeightAccounts_1 = require("./withVoterWeightAccounts"); | ||
const withRealmConfigAccounts_1 = require("./withRealmConfigAccounts"); | ||
const withCreateProposal = (instructions, programId, programVersion, realm, governance, tokenOwnerRecord, name, descriptionLink, governingTokenMint, governanceAuthority, proposalIndex, voteType, options, useDenyOption, payer, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -40,3 +40,3 @@ const args = new instructions_1.CreateProposalArgs({ | ||
], programId); | ||
const keys = [ | ||
let keys = [ | ||
{ | ||
@@ -86,14 +86,16 @@ pubkey: realm, | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
}); | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
]; | ||
(0, withVoterWeightAccounts_1.withVoterWeightAccounts)(keys, programId, realm, voterWeightRecord); | ||
}); | ||
} | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, programId, realm, voterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -100,0 +102,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { MintMaxVoteWeightSource } from './accounts'; | ||
import BN from 'bn.js'; | ||
export declare function withCreateRealm(instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, name: string, realmAuthority: PublicKey, communityMint: PublicKey, payer: PublicKey, councilMint: PublicKey | undefined, communityMintMaxVoteWeightSource: MintMaxVoteWeightSource, minCommunityTokensToCreateGovernance: BN, communityVoterWeightAddin: PublicKey | undefined): Promise<PublicKey>; | ||
export declare function withCreateRealm(instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, name: string, realmAuthority: PublicKey, communityMint: PublicKey, payer: PublicKey, councilMint: PublicKey | undefined, communityMintMaxVoteWeightSource: MintMaxVoteWeightSource, minCommunityWeightToCreateGovernance: BN, communityVoterWeightAddin?: PublicKey | undefined, maxCommunityVoterWeightAddin?: PublicKey | undefined): Promise<PublicKey>; | ||
//# sourceMappingURL=withCreateRealm.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
const sdk_1 = require("../tools/sdk"); | ||
function withCreateRealm(instructions, programId, programVersion, name, realmAuthority, communityMint, payer, councilMint, communityMintMaxVoteWeightSource, minCommunityTokensToCreateGovernance, communityVoterWeightAddin) { | ||
function withCreateRealm(instructions, programId, programVersion, name, realmAuthority, communityMint, payer, councilMint, communityMintMaxVoteWeightSource, minCommunityWeightToCreateGovernance, communityVoterWeightAddin, maxCommunityVoterWeightAddin) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -28,5 +28,6 @@ if (communityVoterWeightAddin && programVersion < constants_1.PROGRAM_VERSION_V2) { | ||
useCouncilMint: councilMint !== undefined, | ||
minCommunityTokensToCreateGovernance, | ||
minCommunityTokensToCreateGovernance: minCommunityWeightToCreateGovernance, | ||
communityMintMaxVoteWeightSource, | ||
useCommunityVoterWeightAddin: communityVoterWeightAddin !== undefined, | ||
useMaxCommunityVoterWeightAddin: maxCommunityVoterWeightAddin !== undefined, | ||
}); | ||
@@ -98,8 +99,2 @@ const args = new instructions_1.CreateRealmArgs({ | ||
} | ||
const realmConfigAddress = yield (0, accounts_1.getRealmConfigAddress)(programId, realmAddress); | ||
keys.push({ | ||
pubkey: realmConfigAddress, | ||
isSigner: false, | ||
isWritable: true, | ||
}); | ||
if (communityVoterWeightAddin) { | ||
@@ -112,2 +107,17 @@ keys.push({ | ||
} | ||
if (maxCommunityVoterWeightAddin) { | ||
keys.push({ | ||
pubkey: maxCommunityVoterWeightAddin, | ||
isWritable: false, | ||
isSigner: false, | ||
}); | ||
} | ||
if (communityVoterWeightAddin || maxCommunityVoterWeightAddin) { | ||
const realmConfigAddress = yield (0, accounts_1.getRealmConfigAddress)(programId, realmAddress); | ||
keys.push({ | ||
pubkey: realmConfigAddress, | ||
isSigner: false, | ||
isWritable: true, | ||
}); | ||
} | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -114,0 +124,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { GovernanceConfig } from './accounts'; | ||
export declare const withCreateTokenGovernance: (instructions: TransactionInstruction[], programId: PublicKey, realm: PublicKey, governedToken: PublicKey, config: GovernanceConfig, transferTokenOwner: boolean, tokenOwner: PublicKey, tokenOwnerRecord: PublicKey, payer: PublicKey, governanceAuthority: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
export declare const withCreateTokenGovernance: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governedToken: PublicKey, config: GovernanceConfig, transferAccountAuthorities: boolean, tokenOwner: PublicKey, tokenOwnerRecord: PublicKey, payer: PublicKey, governanceAuthority: PublicKey, voterWeightRecord?: PublicKey | undefined) => Promise<PublicKey>; | ||
//# sourceMappingURL=withCreateTokenGovernance.d.ts.map |
@@ -19,7 +19,8 @@ "use strict"; | ||
const splToken_1 = require("../tools/sdk/splToken"); | ||
const withVoterWeightAccounts_1 = require("./withVoterWeightAccounts"); | ||
const withCreateTokenGovernance = (instructions, programId, realm, governedToken, config, transferTokenOwner, tokenOwner, tokenOwnerRecord, payer, governanceAuthority, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const withRealmConfigAccounts_1 = require("./withRealmConfigAccounts"); | ||
const constants_1 = require("../registry/constants"); | ||
const withCreateTokenGovernance = (instructions, programId, programVersion, realm, governedToken, config, transferAccountAuthorities, tokenOwner, tokenOwnerRecord, payer, governanceAuthority, voterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.CreateTokenGovernanceArgs({ | ||
config, | ||
transferTokenOwner, | ||
transferTokenOwner: transferAccountAuthorities, | ||
}); | ||
@@ -73,14 +74,16 @@ const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}, | ||
]; | ||
(0, withVoterWeightAccounts_1.withVoterWeightAccounts)(keys, programId, realm, voterWeightRecord); | ||
}); | ||
} | ||
keys.push({ | ||
pubkey: governanceAuthority, | ||
isWritable: false, | ||
isSigner: true, | ||
}); | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, programId, realm, voterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -87,0 +90,0 @@ keys, |
@@ -20,2 +20,3 @@ "use strict"; | ||
const splToken_1 = require("../tools/sdk/splToken"); | ||
const constants_1 = require("../registry/constants"); | ||
const withDepositGoverningTokens = (instructions, programId, programVersion, realm, governingTokenSource, governingTokenMint, governingTokenOwner, transferAuthority, payer, amount) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -76,8 +77,10 @@ const args = new instructions_1.DepositGoverningTokensArgs({ amount }); | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
]; | ||
}); | ||
} | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -84,0 +87,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
import { InstructionData } from './accounts'; | ||
export declare const withExecuteInstruction: (instructions: TransactionInstruction[], programId: PublicKey, governance: PublicKey, proposal: PublicKey, instructionAddress: PublicKey, instruction: InstructionData) => Promise<void>; | ||
export declare const withExecuteInstruction: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, governance: PublicKey, proposal: PublicKey, transactionAddress: PublicKey, transactionInstructions: InstructionData[]) => Promise<void>; | ||
//# sourceMappingURL=withExecuteInstruction.d.ts.map |
@@ -18,17 +18,7 @@ "use strict"; | ||
const accounts_1 = require("./accounts"); | ||
const withExecuteInstruction = (instructions, programId, governance, proposal, instructionAddress, instruction) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.ExecuteInstructionArgs(); | ||
const constants_1 = require("../registry/constants"); | ||
const withExecuteInstruction = (instructions, programId, programVersion, governance, proposal, transactionAddress, transactionInstructions) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.ExecuteTransactionArgs(); | ||
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
const nativeTreasury = yield (0, accounts_1.getNativeTreasuryAddress)(programId, governance); | ||
// When an instruction needs to be signed by the Governance PDA or the Native treasury then its isSigner flag has to be reset on AccountMeta | ||
// because the signature will be required during cpi call invoke_signed() and not when we send ExecuteInstruction | ||
instruction.accounts = instruction.accounts.map(a => (a.pubkey.toBase58() === governance.toBase58() || | ||
a.pubkey.toBase58() === nativeTreasury.toBase58()) && | ||
a.isSigner | ||
? new accounts_1.AccountMetaData({ | ||
pubkey: a.pubkey, | ||
isWritable: a.isWritable, | ||
isSigner: false, | ||
}) | ||
: a); | ||
let keys = [ | ||
@@ -46,18 +36,32 @@ { | ||
{ | ||
pubkey: instructionAddress, | ||
pubkey: transactionAddress, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ | ||
}); | ||
} | ||
for (let instruction of transactionInstructions) { | ||
// When an instruction needs to be signed by the Governance PDA or the Native treasury then its isSigner flag has to be reset on AccountMeta | ||
// because the signature will be required during cpi call invoke_signed() and not when we send ExecuteInstruction | ||
instruction.accounts = instruction.accounts.map(a => (a.pubkey.toBase58() === governance.toBase58() || | ||
a.pubkey.toBase58() === nativeTreasury.toBase58()) && | ||
a.isSigner | ||
? new accounts_1.AccountMetaData({ | ||
pubkey: a.pubkey, | ||
isWritable: a.isWritable, | ||
isSigner: false, | ||
}) | ||
: a); | ||
keys.push({ | ||
pubkey: instruction.programId, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
...instruction.accounts, | ||
]; | ||
}, ...instruction.accounts); | ||
} | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -64,0 +68,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
export declare const withFinalizeVote: (instructions: TransactionInstruction[], programId: PublicKey, realm: PublicKey, governance: PublicKey, proposal: PublicKey, proposalOwnerRecord: PublicKey, governingTokenMint: PublicKey) => Promise<void>; | ||
export declare const withFinalizeVote: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governance: PublicKey, proposal: PublicKey, proposalOwnerRecord: PublicKey, governingTokenMint: PublicKey, maxVoterWeightRecord?: PublicKey | undefined) => Promise<void>; | ||
//# sourceMappingURL=withFinalizeVote.d.ts.map |
@@ -17,9 +17,12 @@ "use strict"; | ||
const instructions_1 = require("./instructions"); | ||
const withFinalizeVote = (instructions, programId, realm, governance, proposal, proposalOwnerRecord, governingTokenMint) => __awaiter(void 0, void 0, void 0, function* () { | ||
const constants_1 = require("../registry/constants"); | ||
const withRealmConfigAccounts_1 = require("./withRealmConfigAccounts"); | ||
const withFinalizeVote = (instructions, programId, programVersion, realm, governance, proposal, proposalOwnerRecord, governingTokenMint, maxVoterWeightRecord) => __awaiter(void 0, void 0, void 0, function* () { | ||
const args = new instructions_1.FinalizeVoteArgs(); | ||
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
const [realmIsWritable, governanceIsWritable] = programVersion === constants_1.PROGRAM_VERSION_V1 ? [false, false] : [true, true]; | ||
let keys = [ | ||
{ | ||
pubkey: realm, | ||
isWritable: false, | ||
isWritable: realmIsWritable, | ||
isSigner: false, | ||
@@ -29,3 +32,3 @@ }, | ||
pubkey: governance, | ||
isWritable: false, | ||
isWritable: governanceIsWritable, | ||
isSigner: false, | ||
@@ -48,8 +51,11 @@ }, | ||
}, | ||
{ | ||
]; | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
]; | ||
}); | ||
} | ||
yield (0, withRealmConfigAccounts_1.withRealmConfigAccounts)(keys, programId, realm, undefined, maxVoterWeightRecord); | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -56,0 +62,0 @@ keys, |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
export declare const withSetRealmAuthority: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, realmAuthority: PublicKey, newRealmAuthority: PublicKey | undefined) => void; | ||
import { SetRealmAuthorityAction } from './instructions'; | ||
export declare const withSetRealmAuthority: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, realmAuthority: PublicKey, newRealmAuthority: PublicKey | undefined, action: SetRealmAuthorityAction | undefined) => void; | ||
//# sourceMappingURL=withSetRealmAuthority.d.ts.map |
@@ -9,6 +9,6 @@ "use strict"; | ||
const registry_1 = require("../registry"); | ||
const withSetRealmAuthority = (instructions, programId, programVersion, realm, realmAuthority, newRealmAuthority) => { | ||
const withSetRealmAuthority = (instructions, programId, programVersion, realm, realmAuthority, newRealmAuthority, action) => { | ||
const args = new instructions_1.SetRealmAuthorityArgs({ | ||
newRealmAuthority: newRealmAuthority, | ||
removeAuthority: newRealmAuthority == undefined, // V2 | ||
action: action, // V2 | ||
}); | ||
@@ -15,0 +15,0 @@ const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args)); |
import { PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
export declare const withSignOffProposal: (instructions: TransactionInstruction[], programId: PublicKey, proposal: PublicKey, signatoryRecord: PublicKey, signatory: PublicKey) => void; | ||
export declare const withSignOffProposal: (instructions: TransactionInstruction[], programId: PublicKey, programVersion: number, realm: PublicKey, governance: PublicKey, proposal: PublicKey, signatory: PublicKey, signatoryRecord: PublicKey | undefined, proposalOwnerRecord: PublicKey | undefined) => void; | ||
//# sourceMappingURL=withSignOffProposal.d.ts.map |
@@ -8,27 +8,59 @@ "use strict"; | ||
const instructions_1 = require("./instructions"); | ||
const withSignOffProposal = (instructions, programId, proposal, signatoryRecord, signatory) => { | ||
const constants_1 = require("../registry/constants"); | ||
const withSignOffProposal = (instructions, programId, programVersion, realm, governance, proposal, signatory, signatoryRecord, proposalOwnerRecord) => { | ||
const args = new instructions_1.SignOffProposalArgs(); | ||
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args)); | ||
const keys = [ | ||
{ | ||
pubkey: proposal, | ||
let keys = []; | ||
if (programVersion > constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: realm, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
}, { | ||
pubkey: governance, | ||
isWritable: true, | ||
isSigner: false, | ||
}); | ||
} | ||
keys.push({ | ||
pubkey: proposal, | ||
isWritable: true, | ||
isSigner: false, | ||
}); | ||
if (programVersion === constants_1.PROGRAM_VERSION_V1) { | ||
keys.push({ | ||
pubkey: signatoryRecord, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
}, { | ||
pubkey: signatory, | ||
isWritable: false, | ||
isSigner: true, | ||
}, | ||
{ | ||
}, { | ||
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
]; | ||
}); | ||
} | ||
else { | ||
keys.push({ | ||
pubkey: signatory, | ||
isWritable: false, | ||
isSigner: true, | ||
}); | ||
if (proposalOwnerRecord) { | ||
keys.push({ | ||
pubkey: proposalOwnerRecord, | ||
isWritable: false, | ||
isSigner: false, | ||
}); | ||
} | ||
else { | ||
keys.push({ | ||
pubkey: signatoryRecord, | ||
isWritable: true, | ||
isSigner: false, | ||
}); | ||
} | ||
} | ||
instructions.push(new web3_js_1.TransactionInstruction({ | ||
@@ -35,0 +67,0 @@ keys, |
{ | ||
"name": "@solana/spl-governance", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "SPL Governance Client API", | ||
@@ -5,0 +5,0 @@ "author": "Solana Maintainers <maintainers@solana.foundation>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
401644
250
5782