@tribecahq/tribeca-sdk
Version:
The TypeScript SDK for Tribeca, an open standard and toolkit for launching DAOs on Solana.
48 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProposalMetaAddress = exports.getVoteAddress = exports.getProposalAddress = exports.getGovernorAddress = void 0;
const anchor_1 = require("@project-serum/anchor");
const solana_contrib_1 = require("@saberhq/solana-contrib");
const constants_1 = require("../../constants");
/**
* gets the PDA of a Governor.
*/
const getGovernorAddress = (base) => {
return (0, solana_contrib_1.getProgramAddress)([anchor_1.utils.bytes.utf8.encode("TribecaGovernor"), base.toBuffer()], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.getGovernorAddress = getGovernorAddress;
/**
* gets the PDA of a Proposal.
*/
const getProposalAddress = (governorKey, index) => {
return (0, solana_contrib_1.getProgramAddress)([
anchor_1.utils.bytes.utf8.encode("TribecaProposal"),
governorKey.toBuffer(),
index.toArrayLike(Buffer, "le", 8),
], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.getProposalAddress = getProposalAddress;
/**
* gets the PDA of a Vote.
* @param proposalKey
* @param voterKey
* @returns
*/
const getVoteAddress = (proposalKey, voterKey) => {
return (0, solana_contrib_1.getProgramAddress)([
anchor_1.utils.bytes.utf8.encode("TribecaVote"),
proposalKey.toBuffer(),
voterKey.toBuffer(),
], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.getVoteAddress = getVoteAddress;
/**
* gets the address of a ProposalMeta.
* @param proposalKey
* @returns
*/
const getProposalMetaAddress = (proposalKey) => {
return (0, solana_contrib_1.getProgramAddress)([anchor_1.utils.bytes.utf8.encode("TribecaProposalMeta"), proposalKey.toBuffer()], constants_1.TRIBECA_ADDRESSES.Govern);
};
exports.getProposalMetaAddress = getProposalMetaAddress;
//# sourceMappingURL=pdaSync.js.map