Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/spl-governance

Package Overview
Dependencies
Maintainers
12
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/spl-governance - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

16

lib/chat/accounts.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatMessage = exports.ChatMessageBody = exports.ChatMessageBodyType = exports.GovernanceChatAccountType = exports.GOVERNANCE_CHAT_PROGRAM_ID = void 0;
var web3_js_1 = require("@solana/web3.js");
const web3_js_1 = require("@solana/web3.js");
exports.GOVERNANCE_CHAT_PROGRAM_ID = new web3_js_1.PublicKey('gCHAtYKrUUktTVzE4hEnZdLV4LXrdBf6Hh9qMaJALET');

@@ -16,12 +16,11 @@ var GovernanceChatAccountType;

})(ChatMessageBodyType = exports.ChatMessageBodyType || (exports.ChatMessageBodyType = {}));
var ChatMessageBody = /** @class */ (function () {
function ChatMessageBody(args) {
class ChatMessageBody {
constructor(args) {
this.type = args.type;
this.value = args.value;
}
return ChatMessageBody;
}());
}
exports.ChatMessageBody = ChatMessageBody;
var ChatMessage = /** @class */ (function () {
function ChatMessage(args) {
class ChatMessage {
constructor(args) {
this.accountType = GovernanceChatAccountType.ChatMessage;

@@ -34,5 +33,4 @@ this.proposal = args.proposal;

}
return ChatMessage;
}());
}
exports.ChatMessage = ChatMessage;
//# sourceMappingURL=accounts.js.map
import { Connection, PublicKey } from '@solana/web3.js';
import { ChatMessage } from './accounts';
export declare function getGovernanceChatMessages(connection: Connection, proposal: PublicKey): Promise<{
[pubKey: string]: import("..").ProgramAccount<ChatMessage>;
}>;
export declare function getGovernanceChatMessagesByVoter(connection: Connection, voter: PublicKey): Promise<{
[pubKey: string]: import("..").ProgramAccount<ChatMessage>;
}>;
export declare function getGovernanceChatMessages(connection: Connection, proposal: PublicKey): Promise<import("..").ProgramAccount<ChatMessage>[]>;
export declare function getGovernanceChatMessagesByVoter(connection: Connection, voter: PublicKey): Promise<import("..").ProgramAccount<ChatMessage>[]>;
//# sourceMappingURL=api.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGovernanceChatMessagesByVoter = exports.getGovernanceChatMessages = void 0;
var api_1 = require("../core/api");
var accounts_1 = require("./accounts");
var serialisation_1 = require("./serialisation");
const api_1 = require("../core/api");
const accounts_1 = require("./accounts");
const serialisation_1 = require("./serialisation");
function getGovernanceChatMessages(connection, proposal) {
return (0, api_1.getBorshProgramAccounts)(connection, accounts_1.GOVERNANCE_CHAT_PROGRAM_ID, function (_) { return serialisation_1.GOVERNANCE_CHAT_SCHEMA; }, accounts_1.ChatMessage, [(0, api_1.pubkeyFilter)(1, proposal)]);
return (0, api_1.getBorshProgramAccounts)(connection, accounts_1.GOVERNANCE_CHAT_PROGRAM_ID, _ => serialisation_1.GOVERNANCE_CHAT_SCHEMA, accounts_1.ChatMessage, [(0, api_1.pubkeyFilter)(1, proposal)]);
}
exports.getGovernanceChatMessages = getGovernanceChatMessages;
function getGovernanceChatMessagesByVoter(connection, voter) {
return (0, api_1.getBorshProgramAccounts)(connection, accounts_1.GOVERNANCE_CHAT_PROGRAM_ID, function (_) { return serialisation_1.GOVERNANCE_CHAT_SCHEMA; }, accounts_1.ChatMessage, [(0, api_1.pubkeyFilter)(33, voter)]);
return (0, api_1.getBorshProgramAccounts)(connection, accounts_1.GOVERNANCE_CHAT_PROGRAM_ID, _ => serialisation_1.GOVERNANCE_CHAT_SCHEMA, accounts_1.ChatMessage, [(0, api_1.pubkeyFilter)(33, voter)]);
}
exports.getGovernanceChatMessagesByVoter = getGovernanceChatMessagesByVoter;
//# sourceMappingURL=api.js.map

@@ -8,10 +8,9 @@ "use strict";

})(GovernanceChatInstruction = exports.GovernanceChatInstruction || (exports.GovernanceChatInstruction = {}));
var PostChatMessageArgs = /** @class */ (function () {
function PostChatMessageArgs(args) {
class PostChatMessageArgs {
constructor(args) {
this.instruction = GovernanceChatInstruction.PostMessage;
this.body = args.body;
}
return PostChatMessageArgs;
}());
}
exports.PostChatMessageArgs = PostChatMessageArgs;
//# sourceMappingURL=instructions.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatAccountParser = exports.GOVERNANCE_CHAT_SCHEMA = void 0;
var accounts_1 = require("./accounts");
var serialisation_1 = require("../core/serialisation");
var instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const serialisation_1 = require("../core/serialisation");
const instructions_1 = require("./instructions");
exports.GOVERNANCE_CHAT_SCHEMA = new Map([

@@ -43,6 +43,4 @@ [

]);
var ChatAccountParser = function (classType) {
return (0, serialisation_1.BorshAccountParser)(classType, function (_) { return exports.GOVERNANCE_CHAT_SCHEMA; });
};
const ChatAccountParser = (classType) => (0, serialisation_1.BorshAccountParser)(classType, _ => exports.GOVERNANCE_CHAT_SCHEMA);
exports.ChatAccountParser = ChatAccountParser;
//# sourceMappingURL=serialisation.js.map

@@ -11,103 +11,73 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withPostChatMessage = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const runtime_1 = require("../tools/sdk/runtime");
function withPostChatMessage(instructions, signers, governanceProgramId, governance, proposal, tokenOwnerRecord, governanceAuthority, payer, replyTo, body) {
return __awaiter(this, void 0, void 0, function () {
var args, data, chatMessage, keys;
return __generator(this, function (_a) {
args = new instructions_1.PostChatMessageArgs({
body: body,
return __awaiter(this, void 0, void 0, function* () {
const args = new instructions_1.PostChatMessageArgs({
body,
});
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_CHAT_SCHEMA, args));
const chatMessage = new web3_js_1.Keypair();
signers.push(chatMessage);
let keys = [
{
pubkey: governanceProgramId,
isWritable: false,
isSigner: false,
},
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: chatMessage.publicKey,
isWritable: true,
isSigner: true,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
];
if (replyTo) {
keys.push({
pubkey: replyTo,
isWritable: false,
isSigner: false,
});
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_CHAT_SCHEMA, args));
chatMessage = new web3_js_1.Keypair();
signers.push(chatMessage);
keys = [
{
pubkey: governanceProgramId,
isWritable: false,
isSigner: false,
},
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: chatMessage.publicKey,
isWritable: true,
isSigner: true,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
];
if (replyTo) {
keys.push({
pubkey: replyTo,
isWritable: false,
isSigner: false,
});
}
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: accounts_1.GOVERNANCE_CHAT_PROGRAM_ID,
data: data,
}));
return [2 /*return*/, chatMessage.publicKey];
});
}
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId: accounts_1.GOVERNANCE_CHAT_PROGRAM_ID,
data,
}));
return chatMessage.publicKey;
});

@@ -114,0 +84,0 @@ }

@@ -25,5 +25,3 @@ /// <reference types="node" />

export declare const booleanFilter: (offset: number, value: boolean) => MemcmpFilter;
export declare function getBorshProgramAccounts<TAccount extends ProgramAccountWithType>(connection: Connection, programId: PublicKey, getSchema: (accountType: number) => Schema, accountFactory: new (args: any) => TAccount, filters?: MemcmpFilter[], accountType?: number): Promise<{
[pubKey: string]: ProgramAccount<TAccount>;
}>;
export declare function getBorshProgramAccounts<TAccount extends ProgramAccountWithType>(connection: Connection, programId: PublicKey, getSchema: (accountType: number) => Schema, accountFactory: new (args: any) => TAccount, filters?: MemcmpFilter[], accountType?: number): Promise<ProgramAccount<TAccount>[]>;
//# sourceMappingURL=api.d.ts.map

@@ -11,38 +11,2 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -53,10 +17,10 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.getBorshProgramAccounts = exports.booleanFilter = exports.pubkeyFilter = exports.MemcmpFilter = exports.RpcContext = void 0;
var web3_js_1 = require("@solana/web3.js");
var bs58_1 = __importDefault(require("bs58"));
var script_1 = require("../tools/script");
var borsh_1 = require("../tools/borsh");
var walletAdapter_1 = require("../tools/walletAdapter");
const web3_js_1 = require("@solana/web3.js");
const bs58_1 = __importDefault(require("bs58"));
const script_1 = require("../tools/script");
const borsh_1 = require("../tools/borsh");
const walletAdapter_1 = require("../tools/walletAdapter");
// Context to make RPC calls for given clone programId, current connection, endpoint and wallet
var RpcContext = /** @class */ (function () {
function RpcContext(programId, programVersion, wallet, connection, endpoint) {
class RpcContext {
constructor(programId, programVersion, wallet, connection, endpoint) {
this.programId = programId;

@@ -68,33 +32,24 @@ this.wallet = wallet;

}
Object.defineProperty(RpcContext.prototype, "walletPubkey", {
get: function () {
var _a;
if (!((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.publicKey)) {
throw new walletAdapter_1.WalletNotConnectedError();
}
return this.wallet.publicKey;
},
enumerable: false,
configurable: true
});
Object.defineProperty(RpcContext.prototype, "programIdBase58", {
get: function () {
return this.programId.toBase58();
},
enumerable: false,
configurable: true
});
return RpcContext;
}());
get walletPubkey() {
var _a;
if (!((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.publicKey)) {
throw new walletAdapter_1.WalletNotConnectedError();
}
return this.wallet.publicKey;
}
get programIdBase58() {
return this.programId.toBase58();
}
}
exports.RpcContext = RpcContext;
var MemcmpFilter = /** @class */ (function () {
function MemcmpFilter(offset, bytes) {
class MemcmpFilter {
constructor(offset, bytes) {
this.offset = offset;
this.bytes = bytes;
}
MemcmpFilter.prototype.isMatch = function (buffer) {
isMatch(buffer) {
if (this.offset + this.bytes.length > buffer.length) {
return false;
}
for (var i = 0; i < this.bytes.length; i++) {
for (let i = 0; i < this.bytes.length; i++) {
if (this.bytes[i] !== buffer[this.offset + i])

@@ -104,57 +59,45 @@ return false;

return true;
};
return MemcmpFilter;
}());
}
}
exports.MemcmpFilter = MemcmpFilter;
// PublicKey MemcmpFilter
var pubkeyFilter = function (offset, pubkey) { return (!pubkey ? undefined : new MemcmpFilter(offset, pubkey.toBuffer())); };
const pubkeyFilter = (offset, pubkey) => (!pubkey ? undefined : new MemcmpFilter(offset, pubkey.toBuffer()));
exports.pubkeyFilter = pubkeyFilter;
// Boolean MemcmpFilter
var booleanFilter = function (offset, value) {
return new MemcmpFilter(offset, Buffer.from(value ? [1] : [0]));
};
const booleanFilter = (offset, value) => new MemcmpFilter(offset, Buffer.from(value ? [1] : [0]));
exports.booleanFilter = booleanFilter;
function getBorshProgramAccounts(connection, programId, getSchema, accountFactory, filters, accountType) {
if (filters === void 0) { filters = []; }
return __awaiter(this, void 0, void 0, function () {
var programAccounts, accounts, _i, programAccounts_1, rawAccount, data, accountType_1, account;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
accountType = accountType !== null && accountType !== void 0 ? accountType : new accountFactory({}).accountType;
return [4 /*yield*/, connection.getProgramAccounts(programId, {
commitment: connection.commitment,
filters: __spreadArray([
{
memcmp: {
offset: 0,
bytes: bs58_1.default.encode([accountType]),
},
}
], filters.map(function (f) { return ({
memcmp: { offset: f.offset, bytes: bs58_1.default.encode(f.bytes) },
}); }), true),
})];
case 1:
programAccounts = _a.sent();
accounts = {};
for (_i = 0, programAccounts_1 = programAccounts; _i < programAccounts_1.length; _i++) {
rawAccount = programAccounts_1[_i];
try {
data = rawAccount.account.data;
accountType_1 = data[0];
account = {
pubkey: new web3_js_1.PublicKey(rawAccount.pubkey),
account: (0, borsh_1.deserializeBorsh)(getSchema(accountType_1), accountFactory, data),
owner: rawAccount.account.owner,
};
accounts[account.pubkey.toBase58()] = account;
}
catch (ex) {
console.info("Can't deserialize ".concat(accountFactory.name, " @ ").concat(rawAccount.pubkey, "."), (0, script_1.getErrorMessage)(ex));
}
}
return [2 /*return*/, accounts];
function getBorshProgramAccounts(connection, programId, getSchema, accountFactory, filters = [], accountType) {
return __awaiter(this, void 0, void 0, function* () {
accountType = accountType !== null && accountType !== void 0 ? accountType : new accountFactory({}).accountType;
const programAccounts = yield connection.getProgramAccounts(programId, {
commitment: connection.commitment,
filters: [
{
memcmp: {
offset: 0,
bytes: bs58_1.default.encode([accountType]),
},
},
...filters.map(f => ({
memcmp: { offset: f.offset, bytes: bs58_1.default.encode(f.bytes) },
})),
],
});
let accounts = [];
for (let rawAccount of programAccounts) {
try {
const data = rawAccount.account.data;
const accountType = data[0];
const account = {
pubkey: new web3_js_1.PublicKey(rawAccount.pubkey),
account: (0, borsh_1.deserializeBorsh)(getSchema(accountType), accountFactory, data),
owner: rawAccount.account.owner,
};
accounts.push(account);
}
});
catch (ex) {
console.info(`Can't deserialize ${accountFactory.name} @ ${rawAccount.pubkey}.`, (0, script_1.getErrorMessage)(ex));
}
}
return accounts;
});

@@ -161,0 +104,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BorshAccountParser = void 0;
var borsh_1 = require("../tools/borsh");
const borsh_1 = require("../tools/borsh");
function BorshAccountParser(classFactory, getSchema) {
return function (pubKey, info) {
var buffer = Buffer.from(info.data);
var data = (0, borsh_1.deserializeBorsh)(getSchema(info.data[0]), classFactory, buffer);
return (pubKey, info) => {
const buffer = Buffer.from(info.data);
const data = (0, borsh_1.deserializeBorsh)(getSchema(info.data[0]), classFactory, buffer);
return {

@@ -10,0 +10,0 @@ pubkey: pubKey,

@@ -11,29 +11,2 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -44,8 +17,8 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

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;
var web3_js_1 = require("@solana/web3.js");
var bn_js_1 = __importDefault(require("bn.js"));
var bignumber_js_1 = __importDefault(require("bignumber.js"));
var instructions_1 = require("./instructions");
var constants_1 = require("../registry/constants");
var moment_1 = __importDefault(require("moment"));
const web3_js_1 = require("@solana/web3.js");
const bn_js_1 = __importDefault(require("bn.js"));
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const instructions_1 = require("./instructions");
const constants_1 = require("../registry/constants");
const moment_1 = __importDefault(require("moment"));
/// Seed prefix for Governance Program PDAs

@@ -107,3 +80,3 @@ exports.GOVERNANCE_PROGRAM_SEED = 'governance';

default:
throw Error("".concat(accountClass, " account is not supported"));
throw Error(`${accountClass} account is not supported`);
}

@@ -128,9 +101,8 @@ }

})(VoteThresholdPercentageType = exports.VoteThresholdPercentageType || (exports.VoteThresholdPercentageType = {}));
var VoteThresholdPercentage = /** @class */ (function () {
function VoteThresholdPercentage(args) {
class VoteThresholdPercentage {
constructor(args) {
this.type = VoteThresholdPercentageType.YesVote;
this.value = args.value;
}
return VoteThresholdPercentage;
}());
}
exports.VoteThresholdPercentage = VoteThresholdPercentage;

@@ -159,12 +131,12 @@ var VoteWeightSource;

})(MintMaxVoteWeightSourceType = exports.MintMaxVoteWeightSourceType || (exports.MintMaxVoteWeightSourceType = {}));
var MintMaxVoteWeightSource = /** @class */ (function () {
function MintMaxVoteWeightSource(args) {
class MintMaxVoteWeightSource {
constructor(args) {
this.type = MintMaxVoteWeightSourceType.SupplyFraction;
this.value = args.value;
}
MintMaxVoteWeightSource.prototype.isFullSupply = function () {
isFullSupply() {
return (this.type === MintMaxVoteWeightSourceType.SupplyFraction &&
this.value.cmp(MintMaxVoteWeightSource.SUPPLY_FRACTION_BASE) === 0);
};
MintMaxVoteWeightSource.prototype.getSupplyFraction = function () {
}
getSupplyFraction() {
if (this.type !== MintMaxVoteWeightSourceType.SupplyFraction) {

@@ -174,16 +146,15 @@ throw new Error('Max vote weight is not fraction');

return this.value;
};
MintMaxVoteWeightSource.prototype.fmtSupplyFractionPercentage = function () {
}
fmtSupplyFractionPercentage() {
return new bignumber_js_1.default(this.getSupplyFraction())
.shiftedBy(-MintMaxVoteWeightSource.SUPPLY_FRACTION_DECIMALS + 2)
.toFormat();
};
MintMaxVoteWeightSource.SUPPLY_FRACTION_BASE = new bn_js_1.default(10000000000);
MintMaxVoteWeightSource.SUPPLY_FRACTION_DECIMALS = 10;
MintMaxVoteWeightSource.FULL_SUPPLY_FRACTION = new MintMaxVoteWeightSource({
value: MintMaxVoteWeightSource.SUPPLY_FRACTION_BASE,
});
return MintMaxVoteWeightSource;
}());
}
}
exports.MintMaxVoteWeightSource = MintMaxVoteWeightSource;
MintMaxVoteWeightSource.SUPPLY_FRACTION_BASE = new bn_js_1.default(10000000000);
MintMaxVoteWeightSource.SUPPLY_FRACTION_DECIMALS = 10;
MintMaxVoteWeightSource.FULL_SUPPLY_FRACTION = new MintMaxVoteWeightSource({
value: MintMaxVoteWeightSource.SUPPLY_FRACTION_BASE,
});
var VoteTypeKind;

@@ -194,25 +165,22 @@ (function (VoteTypeKind) {

})(VoteTypeKind = exports.VoteTypeKind || (exports.VoteTypeKind = {}));
var VoteType = /** @class */ (function () {
function VoteType(args) {
class VoteType {
constructor(args) {
this.type = args.type;
this.choiceCount = args.choiceCount;
}
VoteType.prototype.isSingleChoice = function () {
isSingleChoice() {
return this.type === VoteTypeKind.SingleChoice;
};
VoteType.SINGLE_CHOICE = new VoteType({
type: VoteTypeKind.SingleChoice,
choiceCount: undefined,
});
VoteType.MULTI_CHOICE = function (choiceCount) {
return new VoteType({
type: VoteTypeKind.MultiChoice,
choiceCount: choiceCount,
});
};
return VoteType;
}());
}
}
exports.VoteType = VoteType;
var RealmConfigArgs = /** @class */ (function () {
function RealmConfigArgs(args) {
VoteType.SINGLE_CHOICE = new VoteType({
type: VoteTypeKind.SingleChoice,
choiceCount: undefined,
});
VoteType.MULTI_CHOICE = (choiceCount) => new VoteType({
type: VoteTypeKind.MultiChoice,
choiceCount: choiceCount,
});
class RealmConfigArgs {
constructor(args) {
this.useCouncilMint = !!args.useCouncilMint;

@@ -225,7 +193,6 @@ this.communityMintMaxVoteWeightSource =

}
return RealmConfigArgs;
}());
}
exports.RealmConfigArgs = RealmConfigArgs;
var RealmConfig = /** @class */ (function () {
function RealmConfig(args) {
class RealmConfig {
constructor(args) {
this.councilMint = args.councilMint;

@@ -239,7 +206,6 @@ this.communityMintMaxVoteWeightSource =

}
return RealmConfig;
}());
}
exports.RealmConfig = RealmConfig;
var Realm = /** @class */ (function () {
function Realm(args) {
class Realm {
constructor(args) {
this.accountType = GovernanceAccountType.Realm;

@@ -252,25 +218,17 @@ this.communityMint = args.communityMint;

}
return Realm;
}());
}
exports.Realm = Realm;
function getTokenHoldingAddress(programId, realm, governingTokenMint) {
return __awaiter(this, void 0, void 0, function () {
var tokenHoldingAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
], programId)];
case 1:
tokenHoldingAddress = (_a.sent())[0];
return [2 /*return*/, tokenHoldingAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [tokenHoldingAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
], programId);
return tokenHoldingAddress;
});
}
exports.getTokenHoldingAddress = getTokenHoldingAddress;
var RealmConfigAccount = /** @class */ (function () {
function RealmConfigAccount(args) {
class RealmConfigAccount {
constructor(args) {
this.accountType = GovernanceAccountType.RealmConfig;

@@ -280,21 +238,13 @@ this.realm = args.realm;

}
return RealmConfigAccount;
}());
}
exports.RealmConfigAccount = RealmConfigAccount;
function getRealmConfigAddress(programId, realm) {
return __awaiter(this, void 0, void 0, function () {
var realmConfigAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([Buffer.from('realm-config'), realm.toBuffer()], programId)];
case 1:
realmConfigAddress = (_a.sent())[0];
return [2 /*return*/, realmConfigAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [realmConfigAddress] = yield web3_js_1.PublicKey.findProgramAddress([Buffer.from('realm-config'), realm.toBuffer()], programId);
return realmConfigAddress;
});
}
exports.getRealmConfigAddress = getRealmConfigAddress;
var GovernanceConfig = /** @class */ (function () {
function GovernanceConfig(args) {
class GovernanceConfig {
constructor(args) {
var _a, _b;

@@ -311,7 +261,6 @@ this.voteThresholdPercentage = args.voteThresholdPercentage;

}
return GovernanceConfig;
}());
}
exports.GovernanceConfig = GovernanceConfig;
var Governance = /** @class */ (function () {
function Governance(args) {
class Governance {
constructor(args) {
this.accountType = args.accountType;

@@ -324,19 +273,18 @@ this.realm = args.realm;

}
Governance.prototype.isProgramGovernance = function () {
isProgramGovernance() {
return this.accountType === GovernanceAccountType.ProgramGovernance;
};
Governance.prototype.isAccountGovernance = function () {
}
isAccountGovernance() {
return this.accountType === GovernanceAccountType.AccountGovernance;
};
Governance.prototype.isMintGovernance = function () {
}
isMintGovernance() {
return this.accountType === GovernanceAccountType.MintGovernance;
};
Governance.prototype.isTokenGovernance = function () {
}
isTokenGovernance() {
return this.accountType === GovernanceAccountType.TokenGovernance;
};
return Governance;
}());
}
}
exports.Governance = Governance;
var TokenOwnerRecord = /** @class */ (function () {
function TokenOwnerRecord(args) {
class TokenOwnerRecord {
constructor(args) {
this.accountType = GovernanceAccountType.TokenOwnerRecord;

@@ -352,21 +300,13 @@ this.realm = args.realm;

}
return TokenOwnerRecord;
}());
}
exports.TokenOwnerRecord = TokenOwnerRecord;
function getTokenOwnerRecordAddress(programId, realm, governingTokenMint, governingTokenOwner) {
return __awaiter(this, void 0, void 0, function () {
var tokenOwnerRecordAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
governingTokenOwner.toBuffer(),
], programId)];
case 1:
tokenOwnerRecordAddress = (_a.sent())[0];
return [2 /*return*/, tokenOwnerRecordAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [tokenOwnerRecordAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
governingTokenOwner.toBuffer(),
], programId);
return tokenOwnerRecordAddress;
});

@@ -393,4 +333,4 @@ }

})(OptionVoteResult = exports.OptionVoteResult || (exports.OptionVoteResult = {}));
var ProposalOption = /** @class */ (function () {
function ProposalOption(args) {
class ProposalOption {
constructor(args) {
this.label = args.label;

@@ -403,7 +343,6 @@ this.voteWeight = args.voteWeight;

}
return ProposalOption;
}());
}
exports.ProposalOption = ProposalOption;
var Proposal = /** @class */ (function () {
function Proposal(args) {
class Proposal {
constructor(args) {
this.accountType = args.accountType;

@@ -441,3 +380,3 @@ this.governance = args.governance;

/// Returns true if Proposal is in state when no voting can happen any longer
Proposal.prototype.isVoteFinalized = function () {
isVoteFinalized() {
switch (this.state) {

@@ -456,4 +395,4 @@ case ProposalState.Succeeded:

}
};
Proposal.prototype.isFinalState = function () {
}
isFinalState() {
// 1) ExecutingWithErrors is not really a final state, it's undefined.

@@ -477,4 +416,4 @@ // However it usually indicates none recoverable execution error so we treat is as final for the ui purposes

}
};
Proposal.prototype.getStateTimestamp = function () {
}
getStateTimestamp() {
switch (this.state) {

@@ -497,4 +436,4 @@ case ProposalState.Succeeded:

}
};
Proposal.prototype.getStateSortRank = function () {
}
getStateSortRank() {
// Always show proposals in voting state at the top

@@ -506,8 +445,8 @@ if (this.state === ProposalState.Voting) {

return this.isFinalState() ? 0 : 1;
};
}
/// Returns true if Proposal has not been voted on yet
Proposal.prototype.isPreVotingState = function () {
isPreVotingState() {
return !this.votingAtSlot;
};
Proposal.prototype.getYesVoteOption = function () {
}
getYesVoteOption() {
if (this.options.length !== 1 && !this.voteType.isSingleChoice()) {

@@ -517,4 +456,4 @@ throw new Error('Proposal is not Yes/No vote');

return this.options[0];
};
Proposal.prototype.getYesVoteCount = function () {
}
getYesVoteCount() {
switch (this.accountType) {

@@ -526,6 +465,6 @@ case GovernanceAccountType.ProposalV1:

default:
throw new Error("Invalid account type ".concat(this.accountType));
throw new Error(`Invalid account type ${this.accountType}`);
}
};
Proposal.prototype.getNoVoteCount = function () {
}
getNoVoteCount() {
switch (this.accountType) {

@@ -537,8 +476,8 @@ case GovernanceAccountType.ProposalV1:

default:
throw new Error("Invalid account type ".concat(this.accountType));
throw new Error(`Invalid account type ${this.accountType}`);
}
};
Proposal.prototype.getTimeToVoteEnd = function (governance) {
}
getTimeToVoteEnd(governance) {
var _a, _b;
var now = (0, moment_1.default)().unix();
const now = (0, moment_1.default)().unix();
return this.isPreVotingState()

@@ -549,7 +488,7 @@ ? governance.config.maxVotingTime

now;
};
Proposal.prototype.hasVoteTimeEnded = function (governance) {
}
hasVoteTimeEnded(governance) {
return this.getTimeToVoteEnd(governance) <= 0;
};
Proposal.prototype.canCancel = function (governance) {
}
canCancel(governance) {
if (this.state === ProposalState.Draft ||

@@ -564,4 +503,4 @@ this.state === ProposalState.SigningOff) {

return false;
};
Proposal.prototype.canWalletCancel = function (governance, proposalOwner, walletPk) {
}
canWalletCancel(governance, proposalOwner, walletPk) {
var _a;

@@ -573,8 +512,7 @@ if (!this.canCancel(governance)) {

((_a = proposalOwner.governanceDelegate) === null || _a === void 0 ? void 0 : _a.equals(walletPk)));
};
return Proposal;
}());
}
}
exports.Proposal = Proposal;
var SignatoryRecord = /** @class */ (function () {
function SignatoryRecord(args) {
class SignatoryRecord {
constructor(args) {
this.accountType = GovernanceAccountType.SignatoryRecord;

@@ -585,34 +523,25 @@ this.proposal = args.proposal;

}
return SignatoryRecord;
}());
}
exports.SignatoryRecord = SignatoryRecord;
function getSignatoryRecordAddress(programId, proposal, signatory) {
return __awaiter(this, void 0, void 0, function () {
var signatoryRecordAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
signatory.toBuffer(),
], programId)];
case 1:
signatoryRecordAddress = (_a.sent())[0];
return [2 /*return*/, signatoryRecordAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [signatoryRecordAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
signatory.toBuffer(),
], programId);
return signatoryRecordAddress;
});
}
exports.getSignatoryRecordAddress = getSignatoryRecordAddress;
var VoteWeight = /** @class */ (function () {
function VoteWeight(args) {
class VoteWeight {
constructor(args) {
this.yes = args.yes;
this.no = args.no;
}
return VoteWeight;
}());
}
exports.VoteWeight = VoteWeight;
var VoteRecord = /** @class */ (function () {
class VoteRecord {
// -------------------------------
function VoteRecord(args) {
constructor(args) {
this.accountType = args.accountType;

@@ -629,3 +558,3 @@ this.proposal = args.proposal;

}
VoteRecord.prototype.getNoVoteWeight = function () {
getNoVoteWeight() {
var _a, _b;

@@ -649,6 +578,6 @@ switch (this.accountType) {

default:
throw new Error("Invalid account type ".concat(this.accountType, " "));
throw new Error(`Invalid account type ${this.accountType} `);
}
};
VoteRecord.prototype.getYesVoteWeight = function () {
}
getYesVoteWeight() {
var _a, _b;

@@ -672,28 +601,20 @@ switch (this.accountType) {

default:
throw new Error("Invalid account type ".concat(this.accountType, " "));
throw new Error(`Invalid account type ${this.accountType} `);
}
};
return VoteRecord;
}());
}
}
exports.VoteRecord = VoteRecord;
function getVoteRecordAddress(programId, proposal, tokenOwnerRecord) {
return __awaiter(this, void 0, void 0, function () {
var voteRecordAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
tokenOwnerRecord.toBuffer(),
], programId)];
case 1:
voteRecordAddress = (_a.sent())[0];
return [2 /*return*/, voteRecordAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [voteRecordAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
tokenOwnerRecord.toBuffer(),
], programId);
return voteRecordAddress;
});
}
exports.getVoteRecordAddress = getVoteRecordAddress;
var AccountMetaData = /** @class */ (function () {
function AccountMetaData(args) {
class AccountMetaData {
constructor(args) {
this.pubkey = args.pubkey;

@@ -703,7 +624,6 @@ this.isSigner = !!args.isSigner;

}
return AccountMetaData;
}());
}
exports.AccountMetaData = AccountMetaData;
var InstructionData = /** @class */ (function () {
function InstructionData(args) {
class InstructionData {
constructor(args) {
this.programId = args.programId;

@@ -713,7 +633,6 @@ this.accounts = args.accounts;

}
return InstructionData;
}());
}
exports.InstructionData = InstructionData;
var ProposalInstruction = /** @class */ (function () {
function ProposalInstruction(args) {
class ProposalInstruction {
constructor(args) {
this.accountType = GovernanceAccountType.ProposalInstructionV1;

@@ -728,38 +647,29 @@ this.proposal = args.proposal;

}
return ProposalInstruction;
}());
}
exports.ProposalInstruction = ProposalInstruction;
function getProposalInstructionAddress(programId, programVersion, proposal, optionIndex, instructionIndex) {
return __awaiter(this, void 0, void 0, function () {
var optionIndexBuffer, instructionIndexBuffer, seeds, instructionAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
optionIndexBuffer = Buffer.alloc(2);
optionIndexBuffer.writeInt16LE(optionIndex, 0);
instructionIndexBuffer = Buffer.alloc(2);
instructionIndexBuffer.writeInt16LE(instructionIndex, 0);
seeds = programVersion === constants_1.PROGRAM_VERSION_V1
? [
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
instructionIndexBuffer,
]
: [
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
optionIndexBuffer,
instructionIndexBuffer,
];
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress(seeds, programId)];
case 1:
instructionAddress = (_a.sent())[0];
return [2 /*return*/, instructionAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
let optionIndexBuffer = Buffer.alloc(2);
optionIndexBuffer.writeInt16LE(optionIndex, 0);
let instructionIndexBuffer = Buffer.alloc(2);
instructionIndexBuffer.writeInt16LE(instructionIndex, 0);
const seeds = programVersion === constants_1.PROGRAM_VERSION_V1
? [
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
instructionIndexBuffer,
]
: [
Buffer.from(exports.GOVERNANCE_PROGRAM_SEED),
proposal.toBuffer(),
optionIndexBuffer,
instructionIndexBuffer,
];
const [instructionAddress] = yield web3_js_1.PublicKey.findProgramAddress(seeds, programId);
return instructionAddress;
});
}
exports.getProposalInstructionAddress = getProposalInstructionAddress;
var ProgramMetadata = /** @class */ (function () {
function ProgramMetadata(args) {
class ProgramMetadata {
constructor(args) {
this.accountType = GovernanceAccountType.ProgramMetadata;

@@ -770,16 +680,8 @@ this.updatedAt = args.updatedAt;

}
return ProgramMetadata;
}());
}
exports.ProgramMetadata = ProgramMetadata;
function getProgramMetadataAddress(programId) {
return __awaiter(this, void 0, void 0, function () {
var signatoryRecordAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([Buffer.from('metadata')], programId)];
case 1:
signatoryRecordAddress = (_a.sent())[0];
return [2 /*return*/, signatoryRecordAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [signatoryRecordAddress] = yield web3_js_1.PublicKey.findProgramAddress([Buffer.from('metadata')], programId);
return signatoryRecordAddress;
});

@@ -789,12 +691,5 @@ }

function getNativeTreasuryAddress(programId, governance) {
return __awaiter(this, void 0, void 0, function () {
var signatoryRecordAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([Buffer.from('native-treasury'), governance.toBuffer()], programId)];
case 1:
signatoryRecordAddress = (_a.sent())[0];
return [2 /*return*/, signatoryRecordAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [signatoryRecordAddress] = yield web3_js_1.PublicKey.findProgramAddress([Buffer.from('native-treasury'), governance.toBuffer()], programId);
return signatoryRecordAddress;
});

@@ -801,0 +696,0 @@ }

@@ -6,8 +6,4 @@ import { Connection, PublicKey } from '@solana/web3.js';

export declare function getRealm(connection: Connection, realm: PublicKey): Promise<ProgramAccount<Realm>>;
export declare function getRealms(connection: Connection, programId: PublicKey): Promise<{
[pubKey: string]: ProgramAccount<Realm>;
}>;
export declare function getVoteRecordsByVoter(connection: Connection, programId: PublicKey, voter: PublicKey): Promise<{
[pubKey: string]: ProgramAccount<VoteRecord>;
}>;
export declare function getRealms(connection: Connection, programId: PublicKey): Promise<ProgramAccount<Realm>[]>;
export declare function getVoteRecordsByVoter(connection: Connection, programId: PublicKey, voter: PublicKey): Promise<ProgramAccount<VoteRecord>[]>;
export declare function getTokenOwnerRecordForRealm(connection: Connection, programId: PublicKey, realm: PublicKey, governingTokenMint: PublicKey, governingTokenOwner: PublicKey): Promise<ProgramAccount<TokenOwnerRecord>>;

@@ -23,11 +19,7 @@ /**

*/
export declare function getTokenOwnerRecordsByOwner(connection: Connection, programId: PublicKey, governingTokenOwner: PublicKey): Promise<{
[pubKey: string]: ProgramAccount<TokenOwnerRecord>;
}>;
export declare function getTokenOwnerRecordsByOwner(connection: Connection, programId: PublicKey, governingTokenOwner: PublicKey): Promise<ProgramAccount<TokenOwnerRecord>[]>;
export declare function getGovernance(connection: Connection, governance: PublicKey): Promise<ProgramAccount<Governance>>;
export declare function getProposal(connection: Connection, proposal: PublicKey): Promise<ProgramAccount<Proposal>>;
export declare function getGovernanceAccounts<TAccount extends GovernanceAccount>(connection: Connection, programId: PublicKey, accountClass: new (args: any) => TAccount, filters?: MemcmpFilter[]): Promise<{
[pubKey: string]: ProgramAccount<TAccount>;
}>;
export declare function getGovernanceAccounts<TAccount extends GovernanceAccount>(connection: Connection, programId: PublicKey, accountClass: new (args: any) => TAccount, filters?: MemcmpFilter[]): Promise<ProgramAccount<TAccount>[]>;
export declare function getGovernanceAccount<TAccount extends GovernanceAccount>(connection: Connection, accountPk: PublicKey, accountClass: new (args: any) => TAccount): Promise<ProgramAccount<TAccount>>;
//# sourceMappingURL=api.d.ts.map
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -22,40 +11,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGovernanceAccount = exports.getGovernanceAccounts = exports.getProposal = exports.getGovernance = exports.getTokenOwnerRecordsByOwner = exports.getTokenOwnerRecordForRealm = exports.getVoteRecordsByVoter = exports.getRealms = exports.getRealm = void 0;
var serialisation_1 = require("./serialisation");
var accounts_1 = require("./accounts");
var api_1 = require("../core/api");
const serialisation_1 = require("./serialisation");
const accounts_1 = require("./accounts");
const api_1 = require("../core/api");
// Realms
function getRealm(connection, realm) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, getGovernanceAccount(connection, realm, accounts_1.Realm)];
});
return __awaiter(this, void 0, void 0, function* () {
return getGovernanceAccount(connection, realm, accounts_1.Realm);
});

@@ -65,6 +25,4 @@ }

function getRealms(connection, programId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, getGovernanceAccounts(connection, programId, accounts_1.Realm)];
});
return __awaiter(this, void 0, void 0, function* () {
return getGovernanceAccounts(connection, programId, accounts_1.Realm);
});

@@ -75,8 +33,6 @@ }

function getVoteRecordsByVoter(connection, programId, voter) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, getGovernanceAccounts(connection, programId, accounts_1.VoteRecord, [
(0, api_1.pubkeyFilter)(33, voter),
])];
});
return __awaiter(this, void 0, void 0, function* () {
return getGovernanceAccounts(connection, programId, accounts_1.VoteRecord, [
(0, api_1.pubkeyFilter)(33, voter),
]);
});

@@ -87,12 +43,5 @@ }

function getTokenOwnerRecordForRealm(connection, programId, realm, governingTokenMint, governingTokenOwner) {
return __awaiter(this, void 0, void 0, function () {
var tokenOwnerRecordPk;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, accounts_1.getTokenOwnerRecordAddress)(programId, realm, governingTokenMint, governingTokenOwner)];
case 1:
tokenOwnerRecordPk = _a.sent();
return [2 /*return*/, getGovernanceAccount(connection, tokenOwnerRecordPk, accounts_1.TokenOwnerRecord)];
}
});
return __awaiter(this, void 0, void 0, function* () {
const tokenOwnerRecordPk = yield (0, accounts_1.getTokenOwnerRecordAddress)(programId, realm, governingTokenMint, governingTokenOwner);
return getGovernanceAccount(connection, tokenOwnerRecordPk, accounts_1.TokenOwnerRecord);
});

@@ -111,8 +60,6 @@ }

function getTokenOwnerRecordsByOwner(connection, programId, governingTokenOwner) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, getGovernanceAccounts(connection, programId, accounts_1.TokenOwnerRecord, [
(0, api_1.pubkeyFilter)(1 + 32 + 32, governingTokenOwner),
])];
});
return __awaiter(this, void 0, void 0, function* () {
return getGovernanceAccounts(connection, programId, accounts_1.TokenOwnerRecord, [
(0, api_1.pubkeyFilter)(1 + 32 + 32, governingTokenOwner),
]);
});

@@ -123,6 +70,4 @@ }

function getGovernance(connection, governance) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, getGovernanceAccount(connection, governance, accounts_1.Governance)];
});
return __awaiter(this, void 0, void 0, function* () {
return getGovernanceAccount(connection, governance, accounts_1.Governance);
});

@@ -133,6 +78,4 @@ }

function getProposal(connection, proposal) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, getGovernanceAccount(connection, proposal, accounts_1.Proposal)];
});
return __awaiter(this, void 0, void 0, function* () {
return getGovernanceAccount(connection, proposal, accounts_1.Proposal);
});

@@ -142,21 +85,10 @@ }

// Generic API
function getGovernanceAccounts(connection, programId, accountClass, filters) {
if (filters === void 0) { filters = []; }
return __awaiter(this, void 0, void 0, function () {
var accountTypes, all;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
accountTypes = (0, accounts_1.getAccountTypes)(accountClass);
if (accountTypes.length === 1) {
return [2 /*return*/, (0, api_1.getBorshProgramAccounts)(connection, programId, function (at) { return (0, serialisation_1.getGovernanceSchemaForAccount)(at); }, accountClass, filters, accountTypes[0])];
}
return [4 /*yield*/, Promise.all(accountTypes.map(function (at) {
return (0, api_1.getBorshProgramAccounts)(connection, programId, function (at) { return (0, serialisation_1.getGovernanceSchemaForAccount)(at); }, accountClass, filters, at);
}))];
case 1:
all = _a.sent();
return [2 /*return*/, all.reduce(function (res, r) { return (__assign(__assign({}, res), r)); }, {})];
}
});
function getGovernanceAccounts(connection, programId, accountClass, filters = []) {
return __awaiter(this, void 0, void 0, function* () {
const accountTypes = (0, accounts_1.getAccountTypes)(accountClass);
if (accountTypes.length === 1) {
return (0, api_1.getBorshProgramAccounts)(connection, programId, at => (0, serialisation_1.getGovernanceSchemaForAccount)(at), accountClass, filters, accountTypes[0]);
}
const all = yield Promise.all(accountTypes.map(at => (0, api_1.getBorshProgramAccounts)(connection, programId, at => (0, serialisation_1.getGovernanceSchemaForAccount)(at), accountClass, filters, at)));
return all.flatMap(a => a);
});

@@ -166,15 +98,8 @@ }

function getGovernanceAccount(connection, accountPk, accountClass) {
return __awaiter(this, void 0, void 0, function () {
var accountInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, connection.getAccountInfo(accountPk)];
case 1:
accountInfo = _a.sent();
if (!accountInfo) {
throw new Error("Account ".concat(accountPk, " of type ").concat(accountClass.name, " not found"));
}
return [2 /*return*/, (0, serialisation_1.GovernanceAccountParser)(accountClass)(accountPk, accountInfo)];
}
});
return __awaiter(this, void 0, void 0, function* () {
const accountInfo = yield connection.getAccountInfo(accountPk);
if (!accountInfo) {
throw new Error(`Account ${accountPk} of type ${accountClass.name} not found`);
}
return (0, serialisation_1.GovernanceAccountParser)(accountClass)(accountPk, accountInfo);
});

@@ -181,0 +106,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSetGovernanceConfig = void 0;
var web3_js_1 = require("@solana/web3.js");
var instructions_1 = require("./instructions");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
const web3_js_1 = require("@solana/web3.js");
const instructions_1 = require("./instructions");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
function createSetGovernanceConfig(programId, governance, governanceConfig) {
var args = new instructions_1.SetGovernanceConfigArgs({ config: governanceConfig });
var data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
var keys = [
const args = new instructions_1.SetGovernanceConfigArgs({ config: governanceConfig });
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const keys = [
{

@@ -19,5 +19,5 @@ pubkey: governance,

return new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
keys,
programId,
data,
});

@@ -24,0 +24,0 @@ }

@@ -11,123 +11,77 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSetRealmConfig = void 0;
var web3_js_1 = require("@solana/web3.js");
var accounts_1 = require("./accounts");
var instructions_1 = require("./instructions");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var runtime_1 = require("../tools/sdk/runtime");
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) {
return __awaiter(this, void 0, void 0, function () {
var configArgs, args, data, keys, councilTokenHoldingAddress, realmConfigAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
configArgs = new accounts_1.RealmConfigArgs({
useCouncilMint: councilMint !== undefined,
communityMintMaxVoteWeightSource: communityMintMaxVoteWeightSource,
minCommunityTokensToCreateGovernance: minCommunityTokensToCreateGovernance,
useCommunityVoterWeightAddin: communityVoterWeightAddin !== undefined,
});
args = new instructions_1.SetRealmConfigArgs({ configArgs: configArgs });
data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
keys = [
{
pubkey: realm,
isWritable: true,
isSigner: false,
},
{
pubkey: realmAuthority,
isWritable: false,
isSigner: true,
},
];
if (!councilMint) return [3 /*break*/, 2];
return [4 /*yield*/, (0, accounts_1.getTokenHoldingAddress)(programId, realm, councilMint)];
case 1:
councilTokenHoldingAddress = _a.sent();
keys = __spreadArray(__spreadArray([], keys, true), [
{
pubkey: councilMint,
isSigner: false,
isWritable: false,
},
{
pubkey: councilTokenHoldingAddress,
isSigner: false,
isWritable: true,
},
], false);
_a.label = 2;
case 2:
if (!(programVersion > 1)) return [3 /*break*/, 4];
keys.push({
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
});
return [4 /*yield*/, (0, accounts_1.getRealmConfigAddress)(programId, realm)];
case 3:
realmConfigAddress = _a.sent();
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,
});
}
_a.label = 4;
case 4: return [2 /*return*/, new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
})];
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,
});

@@ -134,0 +88,0 @@ });

@@ -120,7 +120,7 @@ "use strict";

];
var governanceErrorOffset = 500;
var governanceToolsErrorOffset = 1100;
const governanceErrorOffset = 500;
const governanceToolsErrorOffset = 1100;
function getTransactionErrorMsg(error) {
try {
var instructionError = error.txError.InstructionError[1];
const instructionError = error.txError.InstructionError[1];
if (instructionError.Custom !== undefined) {

@@ -137,3 +137,3 @@ if (instructionError.Custom >= governanceToolsErrorOffset) {

// For now the most common scenario is an error returned from the token program so I'm mapping the custom errors to it with the 'possible' warning
return "Possible error: ".concat(exports.TokenError[instructionError.Custom]);
return `Possible error: ${exports.TokenError[instructionError.Custom]}`;
}

@@ -140,0 +140,0 @@ }

@@ -33,4 +33,4 @@ "use strict";

})(GovernanceInstruction = exports.GovernanceInstruction || (exports.GovernanceInstruction = {}));
var CreateRealmArgs = /** @class */ (function () {
function CreateRealmArgs(args) {
class CreateRealmArgs {
constructor(args) {
this.instruction = GovernanceInstruction.CreateRealm;

@@ -40,30 +40,26 @@ this.name = args.name;

}
return CreateRealmArgs;
}());
}
exports.CreateRealmArgs = CreateRealmArgs;
var DepositGoverningTokensArgs = /** @class */ (function () {
function DepositGoverningTokensArgs(args) {
class DepositGoverningTokensArgs {
constructor(args) {
this.instruction = GovernanceInstruction.DepositGoverningTokens;
this.amount = args.amount;
}
return DepositGoverningTokensArgs;
}());
}
exports.DepositGoverningTokensArgs = DepositGoverningTokensArgs;
var WithdrawGoverningTokensArgs = /** @class */ (function () {
function WithdrawGoverningTokensArgs() {
class WithdrawGoverningTokensArgs {
constructor() {
this.instruction = GovernanceInstruction.WithdrawGoverningTokens;
}
return WithdrawGoverningTokensArgs;
}());
}
exports.WithdrawGoverningTokensArgs = WithdrawGoverningTokensArgs;
var CreateAccountGovernanceArgs = /** @class */ (function () {
function CreateAccountGovernanceArgs(args) {
class CreateAccountGovernanceArgs {
constructor(args) {
this.instruction = GovernanceInstruction.CreateAccountGovernance;
this.config = args.config;
}
return CreateAccountGovernanceArgs;
}());
}
exports.CreateAccountGovernanceArgs = CreateAccountGovernanceArgs;
var CreateProgramGovernanceArgs = /** @class */ (function () {
function CreateProgramGovernanceArgs(args) {
class CreateProgramGovernanceArgs {
constructor(args) {
this.instruction = GovernanceInstruction.CreateProgramGovernance;

@@ -73,7 +69,6 @@ this.config = args.config;

}
return CreateProgramGovernanceArgs;
}());
}
exports.CreateProgramGovernanceArgs = CreateProgramGovernanceArgs;
var CreateMintGovernanceArgs = /** @class */ (function () {
function CreateMintGovernanceArgs(args) {
class CreateMintGovernanceArgs {
constructor(args) {
this.instruction = GovernanceInstruction.CreateMintGovernance;

@@ -83,7 +78,6 @@ this.config = args.config;

}
return CreateMintGovernanceArgs;
}());
}
exports.CreateMintGovernanceArgs = CreateMintGovernanceArgs;
var CreateTokenGovernanceArgs = /** @class */ (function () {
function CreateTokenGovernanceArgs(args) {
class CreateTokenGovernanceArgs {
constructor(args) {
this.instruction = GovernanceInstruction.CreateTokenGovernance;

@@ -93,16 +87,14 @@ this.config = args.config;

}
return CreateTokenGovernanceArgs;
}());
}
exports.CreateTokenGovernanceArgs = CreateTokenGovernanceArgs;
var SetGovernanceConfigArgs = /** @class */ (function () {
function SetGovernanceConfigArgs(args) {
class SetGovernanceConfigArgs {
constructor(args) {
this.instruction = GovernanceInstruction.SetGovernanceConfig;
this.config = args.config;
}
return SetGovernanceConfigArgs;
}());
}
exports.SetGovernanceConfigArgs = SetGovernanceConfigArgs;
var CreateProposalArgs = /** @class */ (function () {
class CreateProposalArgs {
// --------------------------------
function CreateProposalArgs(args) {
constructor(args) {
this.instruction = GovernanceInstruction.CreateProposal;

@@ -116,26 +108,22 @@ this.name = args.name;

}
return CreateProposalArgs;
}());
}
exports.CreateProposalArgs = CreateProposalArgs;
var AddSignatoryArgs = /** @class */ (function () {
function AddSignatoryArgs(args) {
class AddSignatoryArgs {
constructor(args) {
this.instruction = GovernanceInstruction.AddSignatory;
this.signatory = args.signatory;
}
return AddSignatoryArgs;
}());
}
exports.AddSignatoryArgs = AddSignatoryArgs;
var SignOffProposalArgs = /** @class */ (function () {
function SignOffProposalArgs() {
class SignOffProposalArgs {
constructor() {
this.instruction = GovernanceInstruction.SignOffProposal;
}
return SignOffProposalArgs;
}());
}
exports.SignOffProposalArgs = SignOffProposalArgs;
var CancelProposalArgs = /** @class */ (function () {
function CancelProposalArgs() {
class CancelProposalArgs {
constructor() {
this.instruction = GovernanceInstruction.CancelProposal;
}
return CancelProposalArgs;
}());
}
exports.CancelProposalArgs = CancelProposalArgs;

@@ -147,9 +135,8 @@ var YesNoVote;

})(YesNoVote = exports.YesNoVote || (exports.YesNoVote = {}));
var VoteChoice = /** @class */ (function () {
function VoteChoice(args) {
class VoteChoice {
constructor(args) {
this.rank = args.rank;
this.weightPercentage = args.weightPercentage;
}
return VoteChoice;
}());
}
exports.VoteChoice = VoteChoice;

@@ -161,4 +148,4 @@ var VoteKind;

})(VoteKind = exports.VoteKind || (exports.VoteKind = {}));
var Vote = /** @class */ (function () {
function Vote(args) {
class Vote {
constructor(args) {
this.voteType = args.voteType;

@@ -168,3 +155,3 @@ this.approveChoices = args.approveChoices;

}
Vote.prototype.toYesNoVote = function () {
toYesNoVote() {
switch (this.voteType) {

@@ -178,4 +165,4 @@ case VoteKind.Deny: {

}
};
Vote.fromYesNoVote = function (yesNoVote) {
}
static fromYesNoVote(yesNoVote) {
switch (yesNoVote) {

@@ -197,8 +184,7 @@ case YesNoVote.Yes: {

}
};
return Vote;
}());
}
}
exports.Vote = Vote;
var CastVoteArgs = /** @class */ (function () {
function CastVoteArgs(args) {
class CastVoteArgs {
constructor(args) {
this.instruction = GovernanceInstruction.CastVote;

@@ -208,21 +194,18 @@ this.yesNoVote = args.yesNoVote;

}
return CastVoteArgs;
}());
}
exports.CastVoteArgs = CastVoteArgs;
var RelinquishVoteArgs = /** @class */ (function () {
function RelinquishVoteArgs() {
class RelinquishVoteArgs {
constructor() {
this.instruction = GovernanceInstruction.RelinquishVote;
}
return RelinquishVoteArgs;
}());
}
exports.RelinquishVoteArgs = RelinquishVoteArgs;
var FinalizeVoteArgs = /** @class */ (function () {
function FinalizeVoteArgs() {
class FinalizeVoteArgs {
constructor() {
this.instruction = GovernanceInstruction.FinalizeVote;
}
return FinalizeVoteArgs;
}());
}
exports.FinalizeVoteArgs = FinalizeVoteArgs;
var InsertInstructionArgs = /** @class */ (function () {
function InsertInstructionArgs(args) {
class InsertInstructionArgs {
constructor(args) {
this.instruction = GovernanceInstruction.InsertInstruction;

@@ -234,63 +217,54 @@ this.index = args.index;

}
return InsertInstructionArgs;
}());
}
exports.InsertInstructionArgs = InsertInstructionArgs;
var RemoveInstructionArgs = /** @class */ (function () {
function RemoveInstructionArgs() {
class RemoveInstructionArgs {
constructor() {
this.instruction = GovernanceInstruction.RemoveInstruction;
}
return RemoveInstructionArgs;
}());
}
exports.RemoveInstructionArgs = RemoveInstructionArgs;
var ExecuteInstructionArgs = /** @class */ (function () {
function ExecuteInstructionArgs() {
class ExecuteInstructionArgs {
constructor() {
this.instruction = GovernanceInstruction.ExecuteInstruction;
}
return ExecuteInstructionArgs;
}());
}
exports.ExecuteInstructionArgs = ExecuteInstructionArgs;
var FlagInstructionErrorArgs = /** @class */ (function () {
function FlagInstructionErrorArgs() {
class FlagInstructionErrorArgs {
constructor() {
this.instruction = GovernanceInstruction.FlagInstructionError;
}
return FlagInstructionErrorArgs;
}());
}
exports.FlagInstructionErrorArgs = FlagInstructionErrorArgs;
var SetRealmAuthorityArgs = /** @class */ (function () {
function SetRealmAuthorityArgs(args) {
class SetRealmAuthorityArgs {
constructor(args) {
this.instruction = GovernanceInstruction.SetRealmAuthority;
this.newRealmAuthority = args.newRealmAuthority;
}
return SetRealmAuthorityArgs;
}());
}
exports.SetRealmAuthorityArgs = SetRealmAuthorityArgs;
var SetRealmConfigArgs = /** @class */ (function () {
function SetRealmConfigArgs(args) {
class SetRealmConfigArgs {
constructor(args) {
this.instruction = GovernanceInstruction.SetRealmConfig;
this.configArgs = args.configArgs;
}
return SetRealmConfigArgs;
}());
}
exports.SetRealmConfigArgs = SetRealmConfigArgs;
var CreateTokenOwnerRecordArgs = /** @class */ (function () {
function CreateTokenOwnerRecordArgs() {
class CreateTokenOwnerRecordArgs {
constructor() {
this.instruction = GovernanceInstruction.CreateTokenOwnerRecord;
}
return CreateTokenOwnerRecordArgs;
}());
}
exports.CreateTokenOwnerRecordArgs = CreateTokenOwnerRecordArgs;
var UpdateProgramMetadataArgs = /** @class */ (function () {
function UpdateProgramMetadataArgs() {
class UpdateProgramMetadataArgs {
constructor() {
this.instruction = GovernanceInstruction.UpdateProgramMetadata;
}
return UpdateProgramMetadataArgs;
}());
}
exports.UpdateProgramMetadataArgs = UpdateProgramMetadataArgs;
var CreateNativeTreasuryArgs = /** @class */ (function () {
function CreateNativeTreasuryArgs() {
class CreateNativeTreasuryArgs {
constructor() {
this.instruction = GovernanceInstruction.CreateNativeTreasury;
}
return CreateNativeTreasuryArgs;
}());
}
exports.CreateNativeTreasuryArgs = CreateNativeTreasuryArgs;
//# sourceMappingURL=instructions.js.map
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInstructionDataFromBase64 = exports.GovernanceAccountParser = exports.getGovernanceSchemaForAccount = exports.getGovernanceSchema = exports.GOVERNANCE_SCHEMA = exports.GOVERNANCE_SCHEMA_V1 = exports.serializeInstructionToBase64 = void 0;
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var borsh_2 = require("borsh");
var serialisation_1 = require("../core/serialisation");
var constants_1 = require("../registry/constants");
var borsh_3 = require("../tools/borsh");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const borsh_2 = require("borsh");
const serialisation_1 = require("../core/serialisation");
const constants_1 = require("../registry/constants");
const borsh_3 = require("../tools/borsh");
// ------------ u16 ------------
// Temp. workaround to support u16.
borsh_1.BinaryReader.prototype.readU16 = function () {
var reader = this;
var value = reader.buf.readUInt16LE(reader.offset);
const reader = this;
const value = reader.buf.readUInt16LE(reader.offset);
reader.offset += 2;

@@ -30,3 +21,3 @@ return value;

borsh_1.BinaryWriter.prototype.writeU16 = function (value) {
var writer = this;
const writer = this;
writer.maybeResize();

@@ -38,4 +29,4 @@ writer.buf.writeUInt16LE(value, writer.length);

borsh_1.BinaryReader.prototype.readVoteType = function () {
var reader = this;
var value = reader.buf.readUInt8(reader.offset);
const reader = this;
const value = reader.buf.readUInt8(reader.offset);
reader.offset += 1;

@@ -45,7 +36,7 @@ if (value === accounts_1.VoteTypeKind.SingleChoice) {

}
var choiceCount = reader.buf.readUInt16LE(reader.offset);
const choiceCount = reader.buf.readUInt16LE(reader.offset);
return accounts_1.VoteType.MULTI_CHOICE(choiceCount);
};
borsh_1.BinaryWriter.prototype.writeVoteType = function (value) {
var writer = this;
const writer = this;
writer.maybeResize();

@@ -61,4 +52,4 @@ writer.buf.writeUInt8(value.type, writer.length);

borsh_1.BinaryReader.prototype.readVote = function () {
var reader = this;
var value = reader.buf.readUInt8(reader.offset);
const reader = this;
const value = reader.buf.readUInt8(reader.offset);
reader.offset += 1;

@@ -68,7 +59,7 @@ if (value === instructions_1.VoteKind.Deny) {

}
var approveChoices = [];
reader.readArray(function () {
var rank = reader.buf.readUInt8(reader.offset);
let approveChoices = [];
reader.readArray(() => {
const rank = reader.buf.readUInt8(reader.offset);
reader.offset += 1;
var weightPercentage = reader.buf.readUInt8(reader.offset);
const weightPercentage = reader.buf.readUInt8(reader.offset);
reader.offset += 1;

@@ -84,3 +75,3 @@ approveChoices.push(new instructions_1.VoteChoice({ rank: rank, weightPercentage: weightPercentage }));

borsh_1.BinaryWriter.prototype.writeVote = function (value) {
var writer = this;
const writer = this;
writer.maybeResize();

@@ -90,3 +81,3 @@ writer.buf.writeUInt8(value.voteType, writer.length);

if (value.voteType === instructions_1.VoteKind.Approve) {
writer.writeArray(value.approveChoices, function (item) {
writer.writeArray(value.approveChoices, (item) => {
writer.buf.writeUInt8(item.rank, writer.length);

@@ -100,13 +91,11 @@ writer.length += 1;

// Serializes sdk instruction into InstructionData and encodes it as base64 which then can be entered into the UI form
var serializeInstructionToBase64 = function (instruction) {
var data = new accounts_1.InstructionData({
const serializeInstructionToBase64 = (instruction) => {
let data = new accounts_1.InstructionData({
programId: instruction.programId,
data: instruction.data,
accounts: instruction.keys.map(function (k) {
return new accounts_1.AccountMetaData({
pubkey: k.pubkey,
isSigner: k.isSigner,
isWritable: k.isWritable,
});
}),
accounts: instruction.keys.map(k => new accounts_1.AccountMetaData({
pubkey: k.pubkey,
isSigner: k.isSigner,
isWritable: k.isWritable,
})),
});

@@ -230,13 +219,14 @@ return Buffer.from((0, borsh_2.serialize)(exports.GOVERNANCE_SCHEMA, data)).toString('base64');

kind: 'struct',
fields: __spreadArray([
fields: [
['instruction', 'u8'],
['name', 'string'],
['descriptionLink', 'string']
], (programVersion === constants_1.PROGRAM_VERSION_V1
? [['governingTokenMint', 'pubkey']]
: [
['voteType', 'voteType'],
['options', ['string']],
['useDenyOption', 'u8'],
]), true),
['descriptionLink', 'string'],
...(programVersion === constants_1.PROGRAM_VERSION_V1
? [['governingTokenMint', 'pubkey']]
: [
['voteType', 'voteType'],
['options', ['string']],
['useDenyOption', 'u8'],
]),
],
},

@@ -526,3 +516,3 @@ ],

kind: 'struct',
fields: __spreadArray(__spreadArray([
fields: [
['accountType', 'u8'],

@@ -534,16 +524,16 @@ ['governance', 'pubkey'],

['signatoriesCount', 'u8'],
['signatoriesSignedOffCount', 'u8']
], (programVersion === constants_1.PROGRAM_VERSION_V1
? [
['yesVotesCount', 'u64'],
['noVotesCount', 'u64'],
['instructionsExecutedCount', 'u16'],
['instructionsCount', 'u16'],
['instructionsNextIndex', 'u16'],
]
: [
['voteType', 'voteType'],
['options', [accounts_1.ProposalOption]],
['denyVoteWeight', { kind: 'option', type: 'u64' }],
]), true), [
['signatoriesSignedOffCount', 'u8'],
...(programVersion === constants_1.PROGRAM_VERSION_V1
? [
['yesVotesCount', 'u64'],
['noVotesCount', 'u64'],
['instructionsExecutedCount', 'u16'],
['instructionsCount', 'u16'],
['instructionsNextIndex', 'u16'],
]
: [
['voteType', 'voteType'],
['options', [accounts_1.ProposalOption]],
['denyVoteWeight', { kind: 'option', type: 'u64' }],
]),
['draftAt', 'u64'],

@@ -564,3 +554,3 @@ ['signingOffAt', { kind: 'option', type: 'u64' }],

['descriptionLink', 'string'],
], false),
],
},

@@ -594,13 +584,14 @@ ],

kind: 'struct',
fields: __spreadArray([
fields: [
['accountType', 'u8'],
['proposal', 'pubkey'],
['governingTokenOwner', 'pubkey'],
['isRelinquished', 'u8']
], (programVersion === constants_1.PROGRAM_VERSION_V1
? [['voteWeight', accounts_1.VoteWeight]]
: [
['voterWeight', 'u64'],
['vote', 'vote'],
]), true),
['isRelinquished', 'u8'],
...(programVersion === constants_1.PROGRAM_VERSION_V1
? [['voteWeight', accounts_1.VoteWeight]]
: [
['voterWeight', 'u64'],
['vote', 'vote'],
]),
],
},

@@ -644,11 +635,7 @@ ],

exports.getGovernanceSchemaForAccount = getGovernanceSchemaForAccount;
var GovernanceAccountParser = function (classType) {
return (0, serialisation_1.BorshAccountParser)(classType, function (accountType) {
return getGovernanceSchemaForAccount(accountType);
});
};
const GovernanceAccountParser = (classType) => (0, serialisation_1.BorshAccountParser)(classType, (accountType) => getGovernanceSchemaForAccount(accountType));
exports.GovernanceAccountParser = GovernanceAccountParser;
function getInstructionDataFromBase64(instructionDataBase64) {
var instructionDataBin = Buffer.from(instructionDataBase64, 'base64');
var instructionData = (0, borsh_3.deserializeBorsh)(exports.GOVERNANCE_SCHEMA, accounts_1.InstructionData, instructionDataBin);
const instructionDataBin = Buffer.from(instructionDataBase64, 'base64');
const instructionData = (0, borsh_3.deserializeBorsh)(exports.GOVERNANCE_SCHEMA, accounts_1.InstructionData, instructionDataBin);
return instructionData;

@@ -655,0 +642,0 @@ }

@@ -11,29 +11,2 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -44,88 +17,72 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.getGovernanceProgramVersion = void 0;
var web3_js_1 = require("@solana/web3.js");
var bn_js_1 = __importDefault(require("bn.js"));
var constants_1 = require("../registry/constants");
var numbers_1 = require("../tools/numbers");
var bpfUpgradeableLoader_1 = require("../tools/sdk/bpfUpgradeableLoader");
var runtime_1 = require("../tools/sdk/runtime");
var version_1 = require("../tools/version");
var accounts_1 = require("./accounts");
var serialisation_1 = require("./serialisation");
var withUpdateProgramMetadata_1 = require("./withUpdateProgramMetadata");
const web3_js_1 = require("@solana/web3.js");
const bn_js_1 = __importDefault(require("bn.js"));
const constants_1 = require("../registry/constants");
const numbers_1 = require("../tools/numbers");
const bpfUpgradeableLoader_1 = require("../tools/sdk/bpfUpgradeableLoader");
const runtime_1 = require("../tools/sdk/runtime");
const version_1 = require("../tools/version");
const accounts_1 = require("./accounts");
const serialisation_1 = require("./serialisation");
const withUpdateProgramMetadata_1 = require("./withUpdateProgramMetadata");
function getGovernanceProgramVersion(connection, programId, env) {
return __awaiter(this, void 0, void 0, function () {
var programMetadataPk, programMetadataInfo, programMetadata, deploySlot, programData, _a, version, _b, instructions, walletPk, transaction, getVersion, prefix_1, simVersion, ex_1;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, (0, accounts_1.getProgramMetadataAddress)(programId)];
case 1:
programMetadataPk = _c.sent();
_c.label = 2;
case 2:
_c.trys.push([2, 9, , 10]);
return [4 /*yield*/, connection.getAccountInfo(programMetadataPk)];
case 3:
programMetadataInfo = _c.sent();
if (!programMetadataInfo) return [3 /*break*/, 8];
programMetadata = (0, serialisation_1.GovernanceAccountParser)(accounts_1.ProgramMetadata)(programMetadataPk, programMetadataInfo);
deploySlot = numbers_1.BN_ZERO;
_c.label = 4;
case 4:
_c.trys.push([4, 6, , 7]);
return [4 /*yield*/, (0, bpfUpgradeableLoader_1.getProgramDataAccount)(connection, new web3_js_1.PublicKey(programId))];
case 5:
programData = _c.sent();
return __awaiter(this, void 0, void 0, function* () {
// Try get program metadata
const programMetadataPk = yield (0, accounts_1.getProgramMetadataAddress)(programId);
try {
const programMetadataInfo = yield connection.getAccountInfo(programMetadataPk);
// If ProgramMetadata exists then use it to get latest updated version
if (programMetadataInfo) {
const programMetadata = (0, serialisation_1.GovernanceAccountParser)(accounts_1.ProgramMetadata)(programMetadataPk, programMetadataInfo);
let deploySlot = numbers_1.BN_ZERO;
try {
const programData = yield (0, bpfUpgradeableLoader_1.getProgramDataAccount)(connection, new web3_js_1.PublicKey(programId));
deploySlot = new bn_js_1.default(programData.slot);
return [3 /*break*/, 7];
case 6:
_a = _c.sent();
return [3 /*break*/, 7];
case 7:
// Check if ProgramMetadata is not stale
if (programMetadata.account.updatedAt.gte(deploySlot)) {
version = (0, version_1.parseVersion)(programMetadata.account.version);
console.log('Program version (metadata)', version);
return [2 /*return*/, version.major];
}
_c.label = 8;
case 8: return [3 /*break*/, 10];
case 9:
_b = _c.sent();
return [3 /*break*/, 10];
case 10:
_c.trys.push([10, 13, , 14]);
instructions = [];
walletPk = new web3_js_1.PublicKey('ENmcpFCpxN1CqyUjuog9yyUVfdXBKF3LVCwLr7grJZpk');
return [4 /*yield*/, (0, withUpdateProgramMetadata_1.withUpdateProgramMetadata)(instructions, programId, walletPk)];
case 11:
_c.sent();
transaction = new web3_js_1.Transaction({ feePayer: walletPk });
transaction.add.apply(transaction, instructions);
return [4 /*yield*/, (0, runtime_1.simulateTransaction)(connection, transaction, 'recent')];
case 12:
getVersion = _c.sent();
if (!getVersion.value.err && getVersion.value.logs) {
prefix_1 = 'PROGRAM-VERSION:"';
simVersion = getVersion.value.logs
.filter(function (l) { return l.includes(prefix_1); })
.map(function (l) {
var versionStart = l.indexOf(prefix_1);
return (0, version_1.parseVersion)(l.substring(versionStart + prefix_1.length, l.length - 1));
})[0];
console.log('Program version (simulation)', simVersion);
return [2 /*return*/, simVersion.major];
}
return [3 /*break*/, 14];
case 13:
ex_1 = _c.sent();
console.log("Can't determine program version", ex_1);
return [3 /*break*/, 14];
case 14:
// If we can't determine the version using the program instance and running localnet then use the latest version
if (env === 'localnet') {
return [2 /*return*/, constants_1.PROGRAM_VERSION];
}
return [2 /*return*/, constants_1.PROGRAM_VERSION_V1];
}
catch (_a) {
// If the program is not upgradable for example on localnet then there is no ProgramData account
// and Metadata must be more recent
}
// Check if ProgramMetadata is not stale
if (programMetadata.account.updatedAt.gte(deploySlot)) {
const version = (0, version_1.parseVersion)(programMetadata.account.version);
console.log('Program version (metadata)', version);
return version.major;
}
}
});
}
catch (_b) {
// nop, let's try simulation
}
try {
// If we don't have the programMetadata info then simulate UpdateProgramMetadata
let instructions = [];
// The wallet can be any existing account for the simulation
// Note: when running a local validator ensure the account is copied from devnet: --clone ENmcpFCpxN1CqyUjuog9yyUVfdXBKF3LVCwLr7grJZpk -ud
let walletPk = new web3_js_1.PublicKey('ENmcpFCpxN1CqyUjuog9yyUVfdXBKF3LVCwLr7grJZpk');
yield (0, withUpdateProgramMetadata_1.withUpdateProgramMetadata)(instructions, programId, walletPk);
const transaction = new web3_js_1.Transaction({ feePayer: walletPk });
transaction.add(...instructions);
// TODO: Once return values are supported change the simulation call to the actual one
const getVersion = yield (0, runtime_1.simulateTransaction)(connection, transaction, 'recent');
if (!getVersion.value.err && getVersion.value.logs) {
const prefix = 'PROGRAM-VERSION:"';
const simVersion = getVersion.value.logs
.filter(l => l.includes(prefix))
.map(l => {
const versionStart = l.indexOf(prefix);
return (0, version_1.parseVersion)(l.substring(versionStart + prefix.length, l.length - 1));
})[0];
console.log('Program version (simulation)', simVersion);
return simVersion.major;
}
}
catch (ex) {
console.log("Can't determine program version", ex);
}
// If we can't determine the version using the program instance and running localnet then use the latest version
if (env === 'localnet') {
return constants_1.PROGRAM_VERSION;
}
return constants_1.PROGRAM_VERSION_V1;
});

@@ -132,0 +89,0 @@ }

@@ -11,94 +11,59 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withAddSignatory = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
var withAddSignatory = function (instructions, programId, proposal, tokenOwnerRecord, governanceAuthority, signatory, payer) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, signatoryRecordAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.AddSignatoryArgs({ signatory: signatory });
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, (0, accounts_1.getSignatoryRecordAddress)(programId, proposal, signatory)];
case 1:
signatoryRecordAddress = _a.sent();
keys = [
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: signatoryRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, signatoryRecordAddress];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
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 args = new instructions_1.AddSignatoryArgs({ signatory });
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const signatoryRecordAddress = yield (0, accounts_1.getSignatoryRecordAddress)(programId, proposal, signatory);
const keys = [
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: signatoryRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return signatoryRecordAddress;
});
exports.withAddSignatory = withAddSignatory;
//# sourceMappingURL=withAddSignatory.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCancelProposal = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var constants_1 = require("../registry/constants");
var withCancelProposal = function (instructions, programId, programVersion, proposal, proposalOwnerRecord, governanceAuthority, governance) {
var args = new instructions_1.CancelProposalArgs();
var data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
var keys = [
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const constants_1 = require("../registry/constants");
const withCancelProposal = (instructions, programId, programVersion, proposal, proposalOwnerRecord, governanceAuthority, governance) => {
const args = new instructions_1.CancelProposalArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
let keys = [
{

@@ -42,5 +42,5 @@ pubkey: proposal,

instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
keys,
programId,
data,
}));

@@ -47,0 +47,0 @@ };

@@ -11,122 +11,87 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCastVote = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var constants_1 = require("../registry/constants");
var runtime_1 = require("../tools/sdk/runtime");
var withCastVote = function (instructions, programId, programVersion, realm, governance, proposal, proposalOwnerRecord, tokenOwnerRecord, governanceAuthority, governingTokenMint, vote, payer) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, voteRecordAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CastVoteArgs(programVersion === constants_1.PROGRAM_VERSION_V1
? { yesNoVote: vote.toYesNoVote(), vote: undefined }
: { yesNoVote: undefined, vote: vote });
data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
return [4 /*yield*/, (0, accounts_1.getVoteRecordAddress)(programId, proposal, tokenOwnerRecord)];
case 1:
voteRecordAddress = _a.sent();
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: proposalOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: voteRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, voteRecordAddress];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const constants_1 = require("../registry/constants");
const runtime_1 = require("../tools/sdk/runtime");
const withCastVote = (instructions, programId, programVersion, realm, governance, proposal, proposalOwnerRecord, tokenOwnerRecord, governanceAuthority, governingTokenMint, vote, payer) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CastVoteArgs(programVersion === constants_1.PROGRAM_VERSION_V1
? { yesNoVote: vote.toYesNoVote(), vote: undefined }
: { yesNoVote: undefined, vote: vote });
const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
const voteRecordAddress = yield (0, accounts_1.getVoteRecordAddress)(programId, proposal, tokenOwnerRecord);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: proposalOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: voteRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return voteRecordAddress;
});
exports.withCastVote = withCastVote;
//# sourceMappingURL=withCastVote.js.map

@@ -11,102 +11,67 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateAccountGovernance = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var runtime_1 = require("../tools/sdk/runtime");
var withCreateAccountGovernance = function (instructions, programId, realm, governedAccount, config, tokenOwnerRecord, payer, governanceAuthority) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, governanceAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateAccountGovernanceArgs({ config: config });
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from('account-governance'),
realm.toBuffer(),
governedAccount.toBuffer(),
], programId)];
case 1:
governanceAddress = (_a.sent())[0];
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedAccount,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, { governanceAddress: governanceAddress }];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const runtime_1 = require("../tools/sdk/runtime");
const withCreateAccountGovernance = (instructions, programId, realm, governedAccount, config, tokenOwnerRecord, payer, governanceAuthority) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateAccountGovernanceArgs({ config });
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const [governanceAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from('account-governance'),
realm.toBuffer(),
governedAccount.toBuffer(),
], programId);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedAccount,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return { governanceAddress };
});
exports.withCreateAccountGovernance = withCreateAccountGovernance;
//# sourceMappingURL=withCreateAccountGovernance.js.map

@@ -11,112 +11,77 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateMintGovernance = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var splToken_1 = require("../tools/sdk/splToken");
var runtime_1 = require("../tools/sdk/runtime");
var withCreateMintGovernance = function (instructions, programId, realm, governedMint, config, transferMintAuthority, mintAuthority, tokenOwnerRecord, payer, governanceAuthority) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, mintGovernanceAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateMintGovernanceArgs({
config: config,
transferMintAuthority: transferMintAuthority,
});
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([Buffer.from('mint-governance'), realm.toBuffer(), governedMint.toBuffer()], programId)];
case 1:
mintGovernanceAddress = (_a.sent())[0];
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: mintGovernanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedMint,
isWritable: true,
isSigner: false,
},
{
pubkey: mintAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, { governanceAddress: mintGovernanceAddress }];
}
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const splToken_1 = require("../tools/sdk/splToken");
const runtime_1 = require("../tools/sdk/runtime");
const withCreateMintGovernance = (instructions, programId, realm, governedMint, config, transferMintAuthority, mintAuthority, tokenOwnerRecord, payer, governanceAuthority) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateMintGovernanceArgs({
config,
transferMintAuthority,
});
}); };
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const [mintGovernanceAddress] = yield web3_js_1.PublicKey.findProgramAddress([Buffer.from('mint-governance'), realm.toBuffer(), governedMint.toBuffer()], programId);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: mintGovernanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedMint,
isWritable: true,
isSigner: false,
},
{
pubkey: mintAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return { governanceAddress: mintGovernanceAddress };
});
exports.withCreateMintGovernance = withCreateMintGovernance;
//# sourceMappingURL=withCreateMintGovernance.js.map

@@ -11,79 +11,44 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateNativeTreasury = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
var withCreateNativeTreasury = function (instructions, programId, governancePk, payer) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, nativeTreasuryAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateNativeTreasuryArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, (0, accounts_1.getNativeTreasuryAddress)(programId, governancePk)];
case 1:
nativeTreasuryAddress = _a.sent();
keys = [
{
pubkey: governancePk,
isWritable: false,
isSigner: false,
},
{
pubkey: nativeTreasuryAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: true,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, nativeTreasuryAddress];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const runtime_1 = require("../tools/sdk/runtime");
const withCreateNativeTreasury = (instructions, programId, governancePk, payer) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateNativeTreasuryArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const nativeTreasuryAddress = yield (0, accounts_1.getNativeTreasuryAddress)(programId, governancePk);
const keys = [
{
pubkey: governancePk,
isWritable: false,
isSigner: false,
},
{
pubkey: nativeTreasuryAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: true,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return nativeTreasuryAddress;
});
exports.withCreateNativeTreasury = withCreateNativeTreasury;
//# sourceMappingURL=withCreateNativeTreasury.js.map

@@ -11,124 +11,87 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateProgramGovernance = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var runtime_1 = require("../tools/sdk/runtime");
var bpfUpgradeableLoader_1 = require("../tools/sdk/bpfUpgradeableLoader");
var withCreateProgramGovernance = function (instructions, programId, realm, governedProgram, config, transferUpgradeAuthority, programUpgradeAuthority, tokenOwnerRecord, payer, governanceAuthority) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, governanceAddress, programDataAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateProgramGovernanceArgs({
config: config,
transferUpgradeAuthority: transferUpgradeAuthority,
});
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from('program-governance'),
realm.toBuffer(),
governedProgram.toBuffer(),
], programId)];
case 1:
governanceAddress = (_a.sent())[0];
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([governedProgram.toBuffer()], bpfUpgradeableLoader_1.BPF_UPGRADE_LOADER_ID)];
case 2:
programDataAddress = (_a.sent())[0];
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedProgram,
isWritable: false,
isSigner: false,
},
{
pubkey: programDataAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: programUpgradeAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: bpfUpgradeableLoader_1.BPF_UPGRADE_LOADER_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, { governanceAddress: governanceAddress }];
}
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const runtime_1 = require("../tools/sdk/runtime");
const bpfUpgradeableLoader_1 = require("../tools/sdk/bpfUpgradeableLoader");
const withCreateProgramGovernance = (instructions, programId, realm, governedProgram, config, transferUpgradeAuthority, programUpgradeAuthority, tokenOwnerRecord, payer, governanceAuthority) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateProgramGovernanceArgs({
config,
transferUpgradeAuthority,
});
}); };
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const [governanceAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from('program-governance'),
realm.toBuffer(),
governedProgram.toBuffer(),
], programId);
const [programDataAddress] = yield web3_js_1.PublicKey.findProgramAddress([governedProgram.toBuffer()], bpfUpgradeableLoader_1.BPF_UPGRADE_LOADER_ID);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedProgram,
isWritable: false,
isSigner: false,
},
{
pubkey: programDataAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: programUpgradeAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: bpfUpgradeableLoader_1.BPF_UPGRADE_LOADER_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return { governanceAddress };
});
exports.withCreateProgramGovernance = withCreateProgramGovernance;
//# sourceMappingURL=withCreateProgramGovernance.js.map

@@ -11,137 +11,93 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateProposal = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var constants_1 = require("../registry/constants");
var runtime_1 = require("../tools/sdk/runtime");
var withCreateProposal = function (instructions, programId, programVersion, realm, governance, tokenOwnerRecord, name, descriptionLink, governingTokenMint, governanceAuthority, proposalIndex, voteType, options, useDenyOption, payer) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, proposalIndexBuffer, proposalAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateProposalArgs({
name: name,
descriptionLink: descriptionLink,
governingTokenMint: governingTokenMint,
voteType: voteType,
options: options,
useDenyOption: useDenyOption,
});
data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
proposalIndexBuffer = Buffer.alloc(4);
proposalIndexBuffer.writeInt32LE(proposalIndex, 0);
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
governance.toBuffer(),
governingTokenMint.toBuffer(),
proposalIndexBuffer,
], programId)];
case 1:
proposalAddress = (_a.sent())[0];
keys = __spreadArray(__spreadArray([
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: proposalAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governance,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: true,
isSigner: false,
}
], (programVersion > constants_1.PROGRAM_VERSION_V1
? [
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
]
: []), true), [
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isWritable: false,
isSigner: false,
},
], false);
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, proposalAddress];
}
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const constants_1 = require("../registry/constants");
const runtime_1 = require("../tools/sdk/runtime");
const withCreateProposal = (instructions, programId, programVersion, realm, governance, tokenOwnerRecord, name, descriptionLink, governingTokenMint, governanceAuthority, proposalIndex, voteType, options, useDenyOption, payer) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateProposalArgs({
name,
descriptionLink,
governingTokenMint,
voteType,
options,
useDenyOption,
});
}); };
const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
let proposalIndexBuffer = Buffer.alloc(4);
proposalIndexBuffer.writeInt32LE(proposalIndex, 0);
const [proposalAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
governance.toBuffer(),
governingTokenMint.toBuffer(),
proposalIndexBuffer,
], programId);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: proposalAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governance,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: true,
isSigner: false,
},
...(programVersion > constants_1.PROGRAM_VERSION_V1
? [
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
]
: []),
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isWritable: false,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return proposalAddress;
});
exports.withCreateProposal = withCreateProposal;
//# sourceMappingURL=withCreateProposal.js.map

@@ -11,155 +11,106 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateRealm = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var constants_1 = require("../registry/constants");
var sdk_1 = require("../tools/sdk");
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const constants_1 = require("../registry/constants");
const sdk_1 = require("../tools/sdk");
function withCreateRealm(instructions, programId, programVersion, name, realmAuthority, communityMint, payer, councilMint, communityMintMaxVoteWeightSource, minCommunityTokensToCreateGovernance, communityVoterWeightAddin) {
return __awaiter(this, void 0, void 0, function () {
var configArgs, args, data, realmAddress, communityTokenHoldingAddress, keys, councilTokenHoldingAddress, realmConfigAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (communityVoterWeightAddin && programVersion < constants_1.PROGRAM_VERSION_V2) {
throw new Error("Voter weight addin is not supported in version ".concat(programVersion));
}
configArgs = new accounts_1.RealmConfigArgs({
useCouncilMint: councilMint !== undefined,
minCommunityTokensToCreateGovernance: minCommunityTokensToCreateGovernance,
communityMintMaxVoteWeightSource: communityMintMaxVoteWeightSource,
useCommunityVoterWeightAddin: communityVoterWeightAddin !== undefined,
});
args = new instructions_1.CreateRealmArgs({
configArgs: configArgs,
name: name,
});
data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED), Buffer.from(args.name)], programId)];
case 1:
realmAddress = (_a.sent())[0];
return [4 /*yield*/, (0, accounts_1.getTokenHoldingAddress)(programId, realmAddress, communityMint)];
case 2:
communityTokenHoldingAddress = _a.sent();
keys = [
{
pubkey: realmAddress,
isSigner: false,
isWritable: true,
},
{
pubkey: realmAuthority,
isSigner: false,
isWritable: false,
},
{
pubkey: communityMint,
isSigner: false,
isWritable: false,
},
{
pubkey: communityTokenHoldingAddress,
isSigner: false,
isWritable: true,
},
{
pubkey: payer,
isSigner: true,
isWritable: false,
},
{
pubkey: sdk_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: sdk_1.TOKEN_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
if (!councilMint) return [3 /*break*/, 4];
return [4 /*yield*/, (0, accounts_1.getTokenHoldingAddress)(programId, realmAddress, councilMint)];
case 3:
councilTokenHoldingAddress = _a.sent();
keys = __spreadArray(__spreadArray([], keys, true), [
{
pubkey: councilMint,
isSigner: false,
isWritable: false,
},
{
pubkey: councilTokenHoldingAddress,
isSigner: false,
isWritable: true,
},
], false);
_a.label = 4;
case 4: return [4 /*yield*/, (0, accounts_1.getRealmConfigAddress)(programId, realmAddress)];
case 5:
realmConfigAddress = _a.sent();
keys.push({
pubkey: realmConfigAddress,
isSigner: false,
isWritable: true,
});
if (communityVoterWeightAddin) {
keys.push({
pubkey: communityVoterWeightAddin,
isWritable: false,
isSigner: false,
});
}
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, realmAddress];
}
return __awaiter(this, void 0, void 0, function* () {
if (communityVoterWeightAddin && programVersion < constants_1.PROGRAM_VERSION_V2) {
throw new Error(`Voter weight addin is not supported in version ${programVersion}`);
}
const configArgs = new accounts_1.RealmConfigArgs({
useCouncilMint: councilMint !== undefined,
minCommunityTokensToCreateGovernance,
communityMintMaxVoteWeightSource,
useCommunityVoterWeightAddin: communityVoterWeightAddin !== undefined,
});
const args = new instructions_1.CreateRealmArgs({
configArgs,
name,
});
const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
const [realmAddress] = yield web3_js_1.PublicKey.findProgramAddress([Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED), Buffer.from(args.name)], programId);
const communityTokenHoldingAddress = yield (0, accounts_1.getTokenHoldingAddress)(programId, realmAddress, communityMint);
let keys = [
{
pubkey: realmAddress,
isSigner: false,
isWritable: true,
},
{
pubkey: realmAuthority,
isSigner: false,
isWritable: false,
},
{
pubkey: communityMint,
isSigner: false,
isWritable: false,
},
{
pubkey: communityTokenHoldingAddress,
isSigner: false,
isWritable: true,
},
{
pubkey: payer,
isSigner: true,
isWritable: false,
},
{
pubkey: sdk_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: sdk_1.TOKEN_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
if (councilMint) {
const councilTokenHoldingAddress = yield (0, accounts_1.getTokenHoldingAddress)(programId, realmAddress, councilMint);
keys = [
...keys,
{
pubkey: councilMint,
isSigner: false,
isWritable: false,
},
{
pubkey: councilTokenHoldingAddress,
isSigner: false,
isWritable: true,
},
];
}
const realmConfigAddress = yield (0, accounts_1.getRealmConfigAddress)(programId, realmAddress);
keys.push({
pubkey: realmConfigAddress,
isSigner: false,
isWritable: true,
});
if (communityVoterWeightAddin) {
keys.push({
pubkey: communityVoterWeightAddin,
isWritable: false,
isSigner: false,
});
}
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return realmAddress;
});

@@ -166,0 +117,0 @@ }

@@ -11,116 +11,81 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateTokenGovernance = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var runtime_1 = require("../tools/sdk/runtime");
var splToken_1 = require("../tools/sdk/splToken");
var withCreateTokenGovernance = function (instructions, programId, realm, governedToken, config, transferTokenOwner, tokenOwner, tokenOwnerRecord, payer, governanceAuthority) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, tokenGovernanceAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateTokenGovernanceArgs({
config: config,
transferTokenOwner: transferTokenOwner,
});
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from('token-governance'),
realm.toBuffer(),
governedToken.toBuffer(),
], programId)];
case 1:
tokenGovernanceAddress = (_a.sent())[0];
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenGovernanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedToken,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwner,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, { governanceAddress: tokenGovernanceAddress }];
}
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const runtime_1 = require("../tools/sdk/runtime");
const splToken_1 = require("../tools/sdk/splToken");
const withCreateTokenGovernance = (instructions, programId, realm, governedToken, config, transferTokenOwner, tokenOwner, tokenOwnerRecord, payer, governanceAuthority) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateTokenGovernanceArgs({
config,
transferTokenOwner,
});
}); };
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const [tokenGovernanceAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from('token-governance'),
realm.toBuffer(),
governedToken.toBuffer(),
], programId);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenGovernanceAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governedToken,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwner,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return { governanceAddress: tokenGovernanceAddress };
});
exports.withCreateTokenGovernance = withCreateTokenGovernance;
//# sourceMappingURL=withCreateTokenGovernance.js.map

@@ -11,89 +11,54 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateTokenOwnerRecord = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
var withCreateTokenOwnerRecord = function (instructions, programId, realm, governingTokenOwner, governingTokenMint, payer) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, tokenOwnerRecordAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.CreateTokenOwnerRecordArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, (0, accounts_1.getTokenOwnerRecordAddress)(programId, realm, governingTokenMint, governingTokenOwner)];
case 1:
tokenOwnerRecordAddress = _a.sent();
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governingTokenOwner,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenOwnerRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: true,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, tokenOwnerRecordAddress];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const runtime_1 = require("../tools/sdk/runtime");
const withCreateTokenOwnerRecord = (instructions, programId, realm, governingTokenOwner, governingTokenMint, payer) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.CreateTokenOwnerRecordArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const tokenOwnerRecordAddress = yield (0, accounts_1.getTokenOwnerRecordAddress)(programId, realm, governingTokenMint, governingTokenOwner);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governingTokenOwner,
isWritable: false,
isSigner: false,
},
{
pubkey: tokenOwnerRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
{
pubkey: payer,
isWritable: true,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return tokenOwnerRecordAddress;
});
exports.withCreateTokenOwnerRecord = withCreateTokenOwnerRecord;
//# sourceMappingURL=withCreateTokenOwnerRecord.js.map

@@ -11,117 +11,80 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withDepositGoverningTokens = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
var splToken_1 = require("../tools/sdk/splToken");
var withDepositGoverningTokens = function (instructions, programId, programVersion, realm, governingTokenSource, governingTokenMint, governingTokenOwner, transferAuthority, payer, amount) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, tokenOwnerRecordAddress, governingTokenHoldingAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.DepositGoverningTokensArgs({ amount: amount });
data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
return [4 /*yield*/, (0, accounts_1.getTokenOwnerRecordAddress)(programId, realm, governingTokenMint, governingTokenOwner)];
case 1:
tokenOwnerRecordAddress = _a.sent();
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
], programId)];
case 2:
governingTokenHoldingAddress = (_a.sent())[0];
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governingTokenHoldingAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenSource,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenOwner,
isWritable: false,
isSigner: true,
},
{
pubkey: transferAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, tokenOwnerRecordAddress];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const runtime_1 = require("../tools/sdk/runtime");
const splToken_1 = require("../tools/sdk/splToken");
const withDepositGoverningTokens = (instructions, programId, programVersion, realm, governingTokenSource, governingTokenMint, governingTokenOwner, transferAuthority, payer, amount) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.DepositGoverningTokensArgs({ amount });
const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
const tokenOwnerRecordAddress = yield (0, accounts_1.getTokenOwnerRecordAddress)(programId, realm, governingTokenMint, governingTokenOwner);
const [governingTokenHoldingAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
], programId);
const keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governingTokenHoldingAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenSource,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenOwner,
isWritable: false,
isSigner: true,
},
{
pubkey: transferAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isWritable: false,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return tokenOwnerRecordAddress;
});
exports.withDepositGoverningTokens = withDepositGoverningTokens;
//# sourceMappingURL=withDepositGoverningTokens.js.map

@@ -11,105 +11,59 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withExecuteInstruction = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var withExecuteInstruction = function (instructions, programId, governance, proposal, instructionAddress, instruction) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, nativeTreasury, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.ExecuteInstructionArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, (0, accounts_1.getNativeTreasuryAddress)(programId, governance)];
case 1:
nativeTreasury = _a.sent();
// 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(function (a) {
return (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 = __spreadArray([
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: instructionAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: instruction.programId,
isWritable: false,
isSigner: false,
}
], instruction.accounts, true);
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
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 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 = [
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: instructionAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
{
pubkey: instruction.programId,
isWritable: false,
isSigner: false,
},
...instruction.accounts,
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
});
exports.withExecuteInstruction = withExecuteInstruction;
//# sourceMappingURL=withExecuteInstruction.js.map

@@ -11,81 +11,50 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withFinalizeVote = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var withFinalizeVote = function (instructions, programId, realm, governance, proposal, proposalOwnerRecord, governingTokenMint) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, keys;
return __generator(this, function (_a) {
args = new instructions_1.FinalizeVoteArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: proposalOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/];
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const withFinalizeVote = (instructions, programId, realm, governance, proposal, proposalOwnerRecord, governingTokenMint) => __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));
let keys = [
{
pubkey: realm,
isWritable: false,
isSigner: false,
},
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: proposalOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
{
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
});
exports.withFinalizeVote = withFinalizeVote;
//# sourceMappingURL=withFinalizeVote.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withFlagInstructionError = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var withFlagInstructionError = function (instructions, programId, proposal, tokenOwnerRecord, governanceAuthority, proposalInstruction) {
var args = new instructions_1.FlagInstructionErrorArgs();
var data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
var keys = [
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const withFlagInstructionError = (instructions, programId, proposal, tokenOwnerRecord, governanceAuthority, proposalInstruction) => {
const args = new instructions_1.FlagInstructionErrorArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const keys = [
{

@@ -39,5 +39,5 @@ pubkey: proposal,

instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
keys,
programId,
data,
}));

@@ -44,0 +44,0 @@ };

@@ -11,105 +11,70 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withInsertInstruction = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
var withInsertInstruction = function (instructions, programId, programVersion, governance, proposal, tokenOwnerRecord, governanceAuthority, index, holdUpTime, instructionData, payer) { return __awaiter(void 0, void 0, void 0, function () {
var optionIndex, args, data, proposalInstructionAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
optionIndex = 0;
args = new instructions_1.InsertInstructionArgs({
index: index,
optionIndex: 0,
holdUpTime: holdUpTime,
instructionData: instructionData,
});
data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
return [4 /*yield*/, (0, accounts_1.getProposalInstructionAddress)(programId, programVersion, proposal, optionIndex, index)];
case 1:
proposalInstructionAddress = _a.sent();
keys = [
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: proposalInstructionAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/, proposalInstructionAddress];
}
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const runtime_1 = require("../tools/sdk/runtime");
const withInsertInstruction = (instructions, programId, programVersion, governance, proposal, tokenOwnerRecord, governanceAuthority, index, holdUpTime, instructionData, payer) => __awaiter(void 0, void 0, void 0, function* () {
const optionIndex = 0;
const args = new instructions_1.InsertInstructionArgs({
index,
optionIndex: 0,
holdUpTime,
instructionData: instructionData,
});
}); };
const data = Buffer.from((0, borsh_1.serialize)((0, serialisation_1.getGovernanceSchema)(programVersion), args));
const proposalInstructionAddress = yield (0, accounts_1.getProposalInstructionAddress)(programId, programVersion, proposal, optionIndex, index);
const keys = [
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: proposalInstructionAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: false,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
{
pubkey: web3_js_1.SYSVAR_RENT_PUBKEY,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
return proposalInstructionAddress;
});
exports.withInsertInstruction = withInsertInstruction;
//# sourceMappingURL=withInsertInstruction.js.map

@@ -11,99 +11,59 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withRelinquishVote = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var withRelinquishVote = function (instructions, programId, governance, proposal, tokenOwnerRecord, governingTokenMint, voteRecord, governanceAuthority, beneficiary) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, keys, existingVoteKeys;
return __generator(this, function (_a) {
args = new instructions_1.RelinquishVoteArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
keys = [
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const withRelinquishVote = (instructions, programId, governance, proposal, tokenOwnerRecord, governingTokenMint, voteRecord, governanceAuthority, beneficiary) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.RelinquishVoteArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
let keys = [
{
pubkey: governance,
isWritable: false,
isSigner: false,
},
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: voteRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
];
const existingVoteKeys = governanceAuthority && beneficiary
? [
{
pubkey: governance,
pubkey: governanceAuthority,
isWritable: false,
isSigner: false,
isSigner: true,
},
{
pubkey: proposal,
pubkey: beneficiary,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: voteRecord,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenMint,
isWritable: false,
isSigner: false,
},
];
existingVoteKeys = governanceAuthority && beneficiary
? [
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: beneficiary,
isWritable: true,
isSigner: false,
},
]
: [];
instructions.push(new web3_js_1.TransactionInstruction({
keys: __spreadArray(__spreadArray([], keys, true), existingVoteKeys, true),
programId: programId,
data: data,
}));
return [2 /*return*/];
});
}); };
]
: [];
instructions.push(new web3_js_1.TransactionInstruction({
keys: [...keys, ...existingVoteKeys],
programId,
data,
}));
});
exports.withRelinquishVote = withRelinquishVote;
//# sourceMappingURL=withRelinquishVote.js.map

@@ -11,76 +11,45 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withRemoveInstruction = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var withRemoveInstruction = function (instructions, programId, proposal, tokenOwnerRecord, governanceAuthority, proposalInstruction, beneficiary) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, keys;
return __generator(this, function (_a) {
args = new instructions_1.RemoveInstructionArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
keys = [
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: proposalInstruction,
isWritable: true,
isSigner: false,
},
{
pubkey: beneficiary,
isWritable: true,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/];
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const withRemoveInstruction = (instructions, programId, proposal, tokenOwnerRecord, governanceAuthority, proposalInstruction, beneficiary) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.RemoveInstructionArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const keys = [
{
pubkey: proposal,
isWritable: true,
isSigner: false,
},
{
pubkey: tokenOwnerRecord,
isWritable: false,
isSigner: false,
},
{
pubkey: governanceAuthority,
isWritable: false,
isSigner: true,
},
{
pubkey: proposalInstruction,
isWritable: true,
isSigner: false,
},
{
pubkey: beneficiary,
isWritable: true,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
});
exports.withRemoveInstruction = withRemoveInstruction;
//# sourceMappingURL=withRemoveInstruction.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withSetRealmAuthority = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var withSetRealmAuthority = function (instructions, programId, realm, realmAuthority, newRealmAuthority) {
var args = new instructions_1.SetRealmAuthorityArgs({ newRealmAuthority: newRealmAuthority });
var data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
var keys = [
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const withSetRealmAuthority = (instructions, programId, realm, realmAuthority, newRealmAuthority) => {
const args = new instructions_1.SetRealmAuthorityArgs({ newRealmAuthority });
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const keys = [
{

@@ -24,5 +24,5 @@ pubkey: realm,

instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
keys,
programId,
data,
}));

@@ -29,0 +29,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withSignOffProposal = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var withSignOffProposal = function (instructions, programId, proposal, signatoryRecord, signatory) {
var args = new instructions_1.SignOffProposalArgs();
var data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
var keys = [
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const withSignOffProposal = (instructions, programId, proposal, signatoryRecord, signatory) => {
const args = new instructions_1.SignOffProposalArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const keys = [
{

@@ -34,5 +34,5 @@ pubkey: proposal,

instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
keys,
programId,
data,
}));

@@ -39,0 +39,0 @@ };

@@ -11,74 +11,38 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withUpdateProgramMetadata = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var runtime_1 = require("../tools/sdk/runtime");
var withUpdateProgramMetadata = function (instructions, programId, payer) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, programMetadataAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.UpdateProgramMetadataArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, (0, accounts_1.getProgramMetadataAddress)(programId)];
case 1:
programMetadataAddress = _a.sent();
keys = [
{
pubkey: programMetadataAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: true,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const runtime_1 = require("../tools/sdk/runtime");
const withUpdateProgramMetadata = (instructions, programId, payer) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.UpdateProgramMetadataArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const programMetadataAddress = yield (0, accounts_1.getProgramMetadataAddress)(programId);
const keys = [
{
pubkey: programMetadataAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: payer,
isWritable: true,
isSigner: true,
},
{
pubkey: runtime_1.SYSTEM_PROGRAM_ID,
isSigner: false,
isWritable: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
});
exports.withUpdateProgramMetadata = withUpdateProgramMetadata;
//# sourceMappingURL=withUpdateProgramMetadata.js.map

@@ -11,97 +11,59 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withWithdrawGoverningTokens = void 0;
var web3_js_1 = require("@solana/web3.js");
var serialisation_1 = require("./serialisation");
var borsh_1 = require("borsh");
var instructions_1 = require("./instructions");
var accounts_1 = require("./accounts");
var splToken_1 = require("../tools/sdk/splToken");
var withWithdrawGoverningTokens = function (instructions, programId, realm, governingTokenDestination, governingTokenMint, governingTokenOwner) { return __awaiter(void 0, void 0, void 0, function () {
var args, data, tokenOwnerRecordAddress, governingTokenHoldingAddress, keys;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
args = new instructions_1.WithdrawGoverningTokensArgs();
data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
governingTokenOwner.toBuffer(),
], programId)];
case 1:
tokenOwnerRecordAddress = (_a.sent())[0];
return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
], programId)];
case 2:
governingTokenHoldingAddress = (_a.sent())[0];
keys = [
{ pubkey: realm, isWritable: false, isSigner: false },
{
pubkey: governingTokenHoldingAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenDestination,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenOwner,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys: keys,
programId: programId,
data: data,
}));
return [2 /*return*/];
}
});
}); };
const web3_js_1 = require("@solana/web3.js");
const serialisation_1 = require("./serialisation");
const borsh_1 = require("borsh");
const instructions_1 = require("./instructions");
const accounts_1 = require("./accounts");
const splToken_1 = require("../tools/sdk/splToken");
const withWithdrawGoverningTokens = (instructions, programId, realm, governingTokenDestination, governingTokenMint, governingTokenOwner) => __awaiter(void 0, void 0, void 0, function* () {
const args = new instructions_1.WithdrawGoverningTokensArgs();
const data = Buffer.from((0, borsh_1.serialize)(serialisation_1.GOVERNANCE_SCHEMA, args));
const [tokenOwnerRecordAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
governingTokenOwner.toBuffer(),
], programId);
const [governingTokenHoldingAddress] = yield web3_js_1.PublicKey.findProgramAddress([
Buffer.from(accounts_1.GOVERNANCE_PROGRAM_SEED),
realm.toBuffer(),
governingTokenMint.toBuffer(),
], programId);
const keys = [
{ pubkey: realm, isWritable: false, isSigner: false },
{
pubkey: governingTokenHoldingAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenDestination,
isWritable: true,
isSigner: false,
},
{
pubkey: governingTokenOwner,
isWritable: false,
isSigner: true,
},
{
pubkey: tokenOwnerRecordAddress,
isWritable: true,
isSigner: false,
},
{
pubkey: splToken_1.TOKEN_PROGRAM_ID,
isWritable: false,
isSigner: false,
},
];
instructions.push(new web3_js_1.TransactionInstruction({
keys,
programId,
data,
}));
});
exports.withWithdrawGoverningTokens = withWithdrawGoverningTokens;
//# sourceMappingURL=withWithdrawGoverningTokens.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeBorsh = void 0;
var web3_js_1 = require("@solana/web3.js");
var borsh_1 = require("borsh");
const web3_js_1 = require("@solana/web3.js");
const borsh_1 = require("borsh");
borsh_1.BinaryReader.prototype.readPubkey = function () {
var reader = this;
var array = reader.readFixedArray(32);
const reader = this;
const array = reader.readFixedArray(32);
return new web3_js_1.PublicKey(array);
};
borsh_1.BinaryWriter.prototype.writePubkey = function (value) {
var writer = this;
const writer = this;
writer.writeFixedArray(value.toBuffer());

@@ -21,3 +21,3 @@ };

if (typeof fieldType === 'string') {
return reader["read".concat(capitalizeFirstLetter(fieldType))]();
return reader[`read${capitalizeFirstLetter(fieldType)}`]();
}

@@ -28,8 +28,6 @@ if (fieldType instanceof Array) {

}
return reader.readArray(function () {
return deserializeField(schema, fieldName, fieldType[0], reader);
});
return reader.readArray(() => deserializeField(schema, fieldName, fieldType[0], reader));
}
if (fieldType.kind === 'option') {
var option = reader.readU8();
const option = reader.readU8();
if (option) {

@@ -50,11 +48,9 @@ return deserializeField(schema, fieldName, fieldType.type, reader);

function deserializeStruct(schema, classType, reader) {
var _a;
var structSchema = schema.get(classType);
const structSchema = schema.get(classType);
if (!structSchema) {
throw new borsh_1.BorshError("Class ".concat(classType.name, " is missing in schema"));
throw new borsh_1.BorshError(`Class ${classType.name} is missing in schema`);
}
if (structSchema.kind === 'struct') {
var result = {};
for (var _i = 0, _b = schema.get(classType).fields; _i < _b.length; _i++) {
var _c = _b[_i], fieldName = _c[0], fieldType = _c[1];
const result = {};
for (const [fieldName, fieldType] of schema.get(classType).fields) {
result[fieldName] = deserializeField(schema, fieldName, fieldType, reader);

@@ -65,15 +61,15 @@ }

if (structSchema.kind === 'enum') {
var idx = reader.readU8();
const idx = reader.readU8();
if (idx >= structSchema.values.length) {
throw new borsh_1.BorshError("Enum index: ".concat(idx, " is out of range"));
throw new borsh_1.BorshError(`Enum index: ${idx} is out of range`);
}
var _d = structSchema.values[idx], fieldName = _d[0], fieldType = _d[1];
var fieldValue = deserializeField(schema, fieldName, fieldType, reader);
return new classType((_a = {}, _a[fieldName] = fieldValue, _a));
const [fieldName, fieldType] = structSchema.values[idx];
const fieldValue = deserializeField(schema, fieldName, fieldType, reader);
return new classType({ [fieldName]: fieldValue });
}
throw new borsh_1.BorshError("Unexpected schema kind: ".concat(structSchema.kind, " for ").concat(classType.constructor.name));
throw new borsh_1.BorshError(`Unexpected schema kind: ${structSchema.kind} for ${classType.constructor.name}`);
}
/// Deserializes object from bytes using schema.
function deserializeBorsh(schema, classType, buffer) {
var reader = new borsh_1.BinaryReader(buffer);
const reader = new borsh_1.BinaryReader(buffer);
return deserializeStruct(schema, classType, reader);

@@ -80,0 +76,0 @@ }

@@ -7,4 +7,4 @@ "use strict";

exports.BN_ZERO = void 0;
var bn_js_1 = __importDefault(require("bn.js"));
const bn_js_1 = __importDefault(require("bn.js"));
exports.BN_ZERO = new bn_js_1.default(0);
//# sourceMappingURL=numbers.js.map

@@ -11,38 +11,11 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProgramDataAccount = exports.getProgramDataAddress = exports.ProgramDataAccountInfo = exports.PublicKeyFromString = exports.BPF_UPGRADE_LOADER_ID = void 0;
var web3_js_1 = require("@solana/web3.js");
var superstruct_1 = require("superstruct");
const web3_js_1 = require("@solana/web3.js");
const superstruct_1 = require("superstruct");
exports.BPF_UPGRADE_LOADER_ID = new web3_js_1.PublicKey('BPFLoaderUpgradeab1e11111111111111111111111');
// Copied from Explorer code https://github.com/solana-labs/solana/blob/master/explorer/src/validators/accounts/upgradeable-program.ts
var superstruct_2 = require("superstruct");
var superstruct_3 = require("superstruct");
exports.PublicKeyFromString = (0, superstruct_3.coerce)((0, superstruct_3.instance)(web3_js_1.PublicKey), (0, superstruct_3.string)(), function (value) { return new web3_js_1.PublicKey(value); });
const superstruct_2 = require("superstruct");
const superstruct_3 = require("superstruct");
exports.PublicKeyFromString = (0, superstruct_3.coerce)((0, superstruct_3.instance)(web3_js_1.PublicKey), (0, superstruct_3.string)(), value => new web3_js_1.PublicKey(value));
exports.ProgramDataAccountInfo = (0, superstruct_2.type)({

@@ -54,12 +27,5 @@ authority: (0, superstruct_2.nullable)(exports.PublicKeyFromString),

function getProgramDataAddress(programId) {
return __awaiter(this, void 0, void 0, function () {
var programDataAddress;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([programId.toBuffer()], exports.BPF_UPGRADE_LOADER_ID)];
case 1:
programDataAddress = (_a.sent())[0];
return [2 /*return*/, programDataAddress];
}
});
return __awaiter(this, void 0, void 0, function* () {
const [programDataAddress] = yield web3_js_1.PublicKey.findProgramAddress([programId.toBuffer()], exports.BPF_UPGRADE_LOADER_ID);
return programDataAddress;
});

@@ -69,24 +35,15 @@ }

function getProgramDataAccount(connection, programId) {
return __awaiter(this, void 0, void 0, function () {
var programDataAddress, account, accountInfo, programData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, getProgramDataAddress(programId)];
case 1:
programDataAddress = _a.sent();
return [4 /*yield*/, connection.getParsedAccountInfo(programDataAddress)];
case 2:
account = _a.sent();
if (!account || !account.value) {
throw new Error("Program data account ".concat(programDataAddress.toBase58(), " for program ").concat(programId.toBase58(), " not found"));
}
accountInfo = account.value;
if (!('parsed' in accountInfo.data &&
accountInfo.data.program === 'bpf-upgradeable-loader')) {
throw new Error("Invalid program data account ".concat(programDataAddress.toBase58(), " for program ").concat(programId.toBase58()));
}
programData = (0, superstruct_1.create)(accountInfo.data.parsed.info, exports.ProgramDataAccountInfo);
return [2 /*return*/, programData];
}
});
return __awaiter(this, void 0, void 0, function* () {
const programDataAddress = yield getProgramDataAddress(programId);
const account = yield connection.getParsedAccountInfo(programDataAddress);
if (!account || !account.value) {
throw new Error(`Program data account ${programDataAddress.toBase58()} for program ${programId.toBase58()} not found`);
}
const accountInfo = account.value;
if (!('parsed' in accountInfo.data &&
accountInfo.data.program === 'bpf-upgradeable-loader')) {
throw new Error(`Invalid program data account ${programDataAddress.toBase58()} for program ${programId.toBase58()}`);
}
let programData = (0, superstruct_1.create)(accountInfo.data.parsed.info, exports.ProgramDataAccountInfo);
return programData;
});

@@ -93,0 +50,0 @@ }

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -26,75 +11,35 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SendTransactionError = exports.simulateTransaction = exports.SYSTEM_PROGRAM_ID = void 0;
var web3_js_1 = require("@solana/web3.js");
const web3_js_1 = require("@solana/web3.js");
exports.SYSTEM_PROGRAM_ID = new web3_js_1.PublicKey('11111111111111111111111111111111');
function simulateTransaction(connection, transaction, commitment) {
return __awaiter(this, void 0, void 0, function () {
var _a, signData, wireTransaction, encodedTransaction, config, args, res;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
// @ts-ignore
_a = transaction;
return [4 /*yield*/, connection._recentBlockhash(
// @ts-ignore
connection._disableBlockhashCaching)];
case 1:
// @ts-ignore
_a.recentBlockhash = _b.sent();
signData = transaction.serializeMessage();
wireTransaction = transaction._serialize(signData);
encodedTransaction = wireTransaction.toString('base64');
config = { encoding: 'base64', commitment: commitment };
args = [encodedTransaction, config];
return [4 /*yield*/, connection._rpcRequest('simulateTransaction', args)];
case 2:
res = _b.sent();
if (res.error) {
throw new Error('failed to simulate transaction: ' + res.error.message);
}
return [2 /*return*/, res.result];
}
});
return __awaiter(this, void 0, void 0, function* () {
// @ts-ignore
transaction.recentBlockhash = yield connection._recentBlockhash(
// @ts-ignore
connection._disableBlockhashCaching);
const signData = transaction.serializeMessage();
// @ts-ignore
const wireTransaction = transaction._serialize(signData);
const encodedTransaction = wireTransaction.toString('base64');
const config = { encoding: 'base64', commitment };
const args = [encodedTransaction, config];
// @ts-ignore
const res = yield connection._rpcRequest('simulateTransaction', args);
if (res.error) {
throw new Error('failed to simulate transaction: ' + res.error.message);
}
return res.result;
});
}
exports.simulateTransaction = simulateTransaction;
var SendTransactionError = /** @class */ (function (_super) {
__extends(SendTransactionError, _super);
function SendTransactionError(message, txId, txError) {
var _this = _super.call(this, message) || this;
_this.txError = txError;
_this.txId = txId;
return _this;
class SendTransactionError extends Error {
constructor(message, txId, txError) {
super(message);
this.txError = txError;
this.txId = txId;
}
return SendTransactionError;
}(Error));
}
exports.SendTransactionError = SendTransactionError;
//# sourceMappingURL=runtime.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TOKEN_PROGRAM_ID = void 0;
var web3_js_1 = require("@solana/web3.js");
const web3_js_1 = require("@solana/web3.js");
exports.TOKEN_PROGRAM_ID = new web3_js_1.PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
//# sourceMappingURL=splToken.js.map

@@ -11,5 +11,5 @@ "use strict";

return {
major: major,
minor: minor,
patch: patch,
major,
minor,
patch,
};

@@ -16,0 +16,0 @@ }

{
"name": "@solana/spl-governance",
"version": "0.0.12",
"version": "0.0.13",
"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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc