@tribecahq/tribeca-sdk
Version:
The TypeScript SDK for Tribeca, an open standard and toolkit for launching DAOs on Solana.
50 lines • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.findProposalMetaAddress = exports.findVoteAddress = exports.findProposalAddress = exports.findGovernorAddress = void 0;
const tslib_1 = require("tslib");
const anchor_1 = require("@project-serum/anchor");
const web3_js_1 = require("@solana/web3.js");
const constants_1 = require("../../constants");
tslib_1.__exportStar(require("./pdaSync"), exports);
/**
* Finds the PDA of a Governor.
*/
const findGovernorAddress = async (base) => {
return await web3_js_1.PublicKey.findProgramAddress([anchor_1.utils.bytes.utf8.encode("TribecaGovernor"), base.toBuffer()], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.findGovernorAddress = findGovernorAddress;
/**
* Finds the PDA of a Proposal.
*/
const findProposalAddress = async (governorKey, index) => {
return await web3_js_1.PublicKey.findProgramAddress([
anchor_1.utils.bytes.utf8.encode("TribecaProposal"),
governorKey.toBuffer(),
index.toArrayLike(Buffer, "le", 8),
], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.findProposalAddress = findProposalAddress;
/**
* Finds the PDA of a Vote.
* @param proposalKey
* @param voterKey
* @returns
*/
const findVoteAddress = async (proposalKey, voterKey) => {
return await web3_js_1.PublicKey.findProgramAddress([
anchor_1.utils.bytes.utf8.encode("TribecaVote"),
proposalKey.toBuffer(),
voterKey.toBuffer(),
], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.findVoteAddress = findVoteAddress;
/**
* Finds the address of a ProposalMeta.
* @param proposalKey
* @returns
*/
const findProposalMetaAddress = async (proposalKey) => {
return await web3_js_1.PublicKey.findProgramAddress([anchor_1.utils.bytes.utf8.encode("TribecaProposalMeta"), proposalKey.toBuffer()], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.findProposalMetaAddress = findProposalMetaAddress;
//# sourceMappingURL=pda.js.map