UNPKG

@tribecahq/tribeca-sdk

Version:

The TypeScript SDK for Tribeca, an open standard and toolkit for launching DAOs on Solana.

41 lines 1.29 kB
import { utils } from "@project-serum/anchor"; import { getProgramAddress } from "@saberhq/solana-contrib"; import { TRIBECA_ADDRESSES } from "../../constants"; /** * gets the PDA of a Governor. */ export const getGovernorAddress = (base) => { return getProgramAddress([utils.bytes.utf8.encode("TribecaGovernor"), base.toBuffer()], TRIBECA_ADDRESSES.Govern); }; /** * gets the PDA of a Proposal. */ export const getProposalAddress = (governorKey, index) => { return getProgramAddress([ utils.bytes.utf8.encode("TribecaProposal"), governorKey.toBuffer(), index.toArrayLike(Buffer, "le", 8), ], TRIBECA_ADDRESSES.Govern); }; /** * gets the PDA of a Vote. * @param proposalKey * @param voterKey * @returns */ export const getVoteAddress = (proposalKey, voterKey) => { return getProgramAddress([ utils.bytes.utf8.encode("TribecaVote"), proposalKey.toBuffer(), voterKey.toBuffer(), ], TRIBECA_ADDRESSES.Govern); }; /** * gets the address of a ProposalMeta. * @param proposalKey * @returns */ export const getProposalMetaAddress = (proposalKey) => { return getProgramAddress([utils.bytes.utf8.encode("TribecaProposalMeta"), proposalKey.toBuffer()], TRIBECA_ADDRESSES.Govern); }; //# sourceMappingURL=pdaSync.js.map