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