UNPKG

@algofi/js-sdk

Version:

The official Algofi JavaScript SDK

50 lines (49 loc) 2.02 kB
import { Account, Algodv2, Transaction } from "algosdk"; import AlgofiClient from "../../algofiClient"; import { Network } from "../../globals"; import AlgofiUser from "../../algofiUser"; import GovernanceConfig from "./governanceConfig"; import VotingEscrow from "./votingEscrow"; import governanceUser from "./governanceUser"; import Admin from "./admin"; import RewardsManager from "./rewardsManager"; export default class GovernanceClient { algofiClient: AlgofiClient; algod: Algodv2; network: Network; admin: Admin; votingEscrow: VotingEscrow; rewardsManager: RewardsManager; governanceConfig: GovernanceConfig; /** * Constructor for the algofi governance client. * * @param algofiClient - an instance of an algofi client */ constructor(algofiClient: AlgofiClient); /** * Creates new admin, voting escrow, and rewards managers on the algofi client * object and loads their state. */ loadState(): Promise<void>; /** * Gets an algofi governance user given an address. * * @param address - the address of the user we are interested in. * @returns an algofi governance user. */ getUser(address: string): governanceUser; /** * Constructs a series of transactions to opt the user and their storage * account into all of the necessary applications for governance including the * admin, the voting escrow, and the rewards manager. * * @param user - user we are opting into the contracts * @param storageAccount - a newly created account that will serve as the * storage account for the user on the protocol * @returns a series of transactions to opt the user and their storage * account into all of the necessary applications for governance including the * admin, the voting escrow, and the rewards manager. */ getOptInTxns(user: AlgofiUser, storageAccount: Account): Promise<Transaction[]>; }