@algofi/js-sdk
Version:
The official Algofi JavaScript SDK
121 lines (120 loc) • 5.19 kB
TypeScript
import { Algodv2, Transaction } from "algosdk";
import AlgofiUser from "../../algofiUser";
import GovernanceClient from "./governanceClient";
import Proposal from "./proposal";
export default class Admin {
governanceClient: GovernanceClient;
algod: Algodv2;
adminAppId: number;
adminAddress: string;
quorumValue: number;
superMajority: number;
proposalDuration: number;
proposalExecutionDelay: number;
proposalFactoryAppId: number;
proposalFactoryAddress: string;
govToken: number;
proposalTemplateId: number;
minimumVeBankToPropose: number;
proposals: {
[key: number]: Proposal;
};
/**
* Constructor for the Admin class.
*
* @param governanceClient - algofi governance client
*/
constructor(governanceClient: GovernanceClient);
/**
* Function to refresh and load all of the global and local state we need to
* keep track of on the admin, including all of the proposals that have been
* created.
*/
loadState(): Promise<void>;
/**
* Constructs a series of transactions to update a target user's vebank.
*
* @param userCalling - the user who is calling the transaction
* @param userUpdating - the user who is being updated
* @returns a series of transactions to update a target user's vebank.
*/
getUpdateUserVeBankDataTxns(userCalling: AlgofiUser, userUpdating: AlgofiUser): Promise<Transaction[]>;
/**
* Constructs a series of transactions to vote on a proposal.
*
* @param user - user who is voting
* @param proposal - proposal being voted on
* @returns a series of transactions to vote on a proposal.
*/
getVoteTxns(user: AlgofiUser, proposal: Proposal, forOrAgainst: number): Promise<Transaction[]>;
/**
* Constructs a series of transactions to delegate a user's votes to another
* user.
*
* @param user - user who is delegating
* @param delegatee - user who is being delegated to
* @returns a series of transactions to delegate a user's votes to another
* user.
*/
getDelegateTxns(user: AlgofiUser, delegatee: AlgofiUser): Promise<Transaction[]>;
/**
* Constructs a series of transactions that will validate a specific proposal.
*
* @param user - user who is trying to validate a proposal
* @param proposal - the proposal to validate
* @returns a series of transactions that will validate a specific proposal.
*/
getValidateTxns(user: AlgofiUser, proposal: Proposal): Promise<Transaction[]>;
/**
* Constructs a series of transactions that will undelegate a user from their
* current delegatee.
*
* @param user - user who is undelegating
* @returns a series of transactions that will undelegate a user from their
* current delegatee.
*/
getUndelegateTxns(user: AlgofiUser): Promise<Transaction[]>;
/**
* Constructs a series of transactions that will make a user vote on a
* proposal as their delegatee has.
*
* @param callingUser - user who is calling the delegated vote transaction
* @param votingUser - user who is voting
* @param proposal - proposal being voted on
* @returns a series of transactions that will make a user vote on a proposal
* as their delegatee has.
*/
getDelegatedVoteTxns(callingUser: AlgofiUser, votingUser: AlgofiUser, proposal: Proposal): Promise<Transaction[]>;
/**
* Constructs a series of transactions which will close out a target user from a proposal.
*
* @param userCalling - user who is calling the transaction
* @param userClosingOut - user who is closing out
* @param proposal - proposal being closed out of
* @returns a series of transactions which will close out a target user from a proposal.
*/
getCloseOutFromProposalTxns(userCalling: AlgofiUser, userClosingOut: AlgofiUser, proposal: Proposal): Promise<Transaction[]>;
/**
* Constructs a series of tranactions to set a user open to delegation.
*
* @param user - user who is setting themselves open to delegation
* @returns a series of tranactions to set a user open to delegation.
*/
getSetOpenToDelegationTxns(user: AlgofiUser): Promise<Transaction[]>;
/**
* Constructs a series of tranactions to set a user not open to delegation.
*
* @param user - user who is setting themselves not open to delegation
* @returns a series of tranactions to set a user not open to delegation.
*/
getSetNotOpenToDelegationTxns(user: AlgofiUser): Promise<Transaction[]>;
/**
* Constructs a series of transactions to create a proposal.
*
* @param user - user who is trying to create the transaction
* @param title - title of the proposal to be created
* @param link - link of the proposal to be created
* @returns a series of transactions to create a proposal.
*/
getCreateProposalTxns(user: AlgofiUser, title: string, link: string): Promise<Transaction[]>;
}