UNPKG

@algofi/js-sdk

Version:

The official Algofi JavaScript SDK

83 lines (82 loc) 3.9 kB
import { Algodv2, Account, Transaction } from "algosdk"; import AlgofiUser from "../../algofiUser"; import Market from "./market"; export default class Manager { localMinBalance: number; algod: Algodv2; appId: number; address: string; /** * Constructor for the manager class. * * @param algod - an algod client * @param appId - app id of the manager */ constructor(algod: Algodv2, appId: number); /** * Constructs a series of transactions that opt the user into the manager. * * @param user - algofi user representing the user we want to opt in * @param storageAccount - storage account for the user * @returns a series of transactions that opt the user into the manager. */ getOptInTxns(user: AlgofiUser, storageAccount: Account): Promise<Transaction[]>; /** * Constructs a series of transactions that opt the user out of the manager. * * @param user - algofi user representing the user we want to opt in * @returns a series of transactions that opt the user out of the manager. */ getOptOutTxns(user: AlgofiUser): Promise<Transaction[]>; /** * Constructs a series of transactions that opt the user into a market. * * @param user - algofi user representing the user we want to opt in * @param market - the market we want to opt the user into * @returns a series of transactions that opt the user into a market. */ getMarketOptInTxns(user: AlgofiUser, market: Market): Promise<Transaction[]>; /** * Constructs a series of transactions that opt the user out of a market. * * @param user - algofi user representing the user we want to opt in * @param market - the market we want to opt the user out of * @returns a series of transactions that opt the user out of a market. */ getMarketOptOutTxns(user: AlgofiUser, market: Market): Promise<Transaction[]>; /** * Constructs a series of transactions that sends a governance transaction from the user. * * @param user - algofi user representing the user we want to opt in * @param targetAddress - the target address we are sending the gov transaction to * @param note - a note to put in the governance transaction * @returns a series of transactions that sends a governance transaction from the user. */ getGovernanceTxns(user: AlgofiUser, targetAddress: string, note: string): Promise<Transaction[]>; /** * Constructs a series of transactions that send a keyreg transaction for * governance from the user. * * @param user - algofi user representing the user we want to send the keyreg * txn on behalf * @param votePK -root participation public key * @param selectionPK - the VRF public key * @param stateProofPK - the 64 byte state proof public key commitment * @param voteFirst - the first round that hte participation key is valid * @param voteLast - The last round that th eparticipatin key is valid * @param voteKeyDilution - The dilution for the 2-level participation key * @returns a series of transactions that send a keyreg transaction for * governance from the user. */ getKeyregTxns(user: AlgofiUser, votePK: string, selectionPK: string, stateProofPK: string, voteFirst: number, voteLast: number, voteKeyDilution: number): Promise<Transaction[]>; /** * Constructs a series of transactions that send an offlinek eyreg * transaction. * * @param user - algofi user representing the user we want to send the offline * keyreg transaction on behalf * @returns - a series of transactions that send an offlinek eyreg * transaction. */ getKeyregOfflineTxns(user: AlgofiUser): Promise<Transaction[]>; }