@celo/contractkit
Version:
Celo's ContractKit to interact with Celo network
157 lines (156 loc) • 6.91 kB
TypeScript
import { Attestations } from '@celo/abis/web3/Attestations';
import { StableToken } from '@celo/base';
import { Address, Connection } from '@celo/connect';
import BigNumber from 'bignumber.js';
import { AccountsWrapper } from './Accounts';
import { BaseWrapper } from './BaseWrapper';
import { StableTokenWrapper } from './StableTokenWrapper';
export interface AttestationStat {
completed: number;
total: number;
}
export interface AttestationStateForIssuer {
attestationState: AttestationState;
}
export interface AttestationsToken {
address: Address;
fee: BigNumber;
}
export interface AttestationsConfig {
attestationExpiryBlocks: number;
attestationRequestFees: AttestationsToken[];
}
/**
* Contract for managing identities
*/
export declare enum AttestationState {
None = 0,
Incomplete = 1,
Complete = 2
}
export interface UnselectedRequest {
blockNumber: number;
attestationsRequested: number;
attestationRequestFeeToken: string;
}
export type IdentifierLookupResult = Record<string, Record<Address, AttestationStat | undefined> | undefined>;
interface ContractsForAttestation {
getAccounts(): Promise<AccountsWrapper>;
getStableToken(stableToken: StableToken): Promise<StableTokenWrapper>;
}
export declare class AttestationsWrapper extends BaseWrapper<Attestations> {
protected readonly connection: Connection;
protected readonly contract: Attestations;
protected readonly contracts: ContractsForAttestation;
constructor(connection: Connection, contract: Attestations, contracts: ContractsForAttestation);
/**
* Returns the time an attestation can be completable before it is considered expired
*/
attestationExpiryBlocks: () => Promise<number>;
/**
* Returns the attestation request fee in a given currency.
* @param address Token address.
* @returns The fee as big number.
*/
attestationRequestFees: (arg0: string) => Promise<BigNumber>;
selectIssuersWaitBlocks: () => Promise<number>;
/**
* @notice Returns the unselected attestation request for an identifier/account pair, if any.
* @param identifier Attestation identifier (e.g. phone hash)
* @param account Address of the account
*/
getUnselectedRequest: (identifier: string | number[], account: string) => Promise<{
blockNumber: number;
attestationsRequested: number;
attestationRequestFeeToken: string;
}>;
/**
* @notice Checks if attestation request is expired.
* @param attestationRequestBlockNumber Attestation Request Block Number to be checked
*/
isAttestationExpired: (attestationRequestBlockNumber: number) => Promise<boolean>;
/**
* Returns the issuers of attestations for a phoneNumber/account combo
* @param identifier Attestation identifier (e.g. phone hash)
* @param account Address of the account
*/
getAttestationIssuers: (identifier: string | number[], account: string) => Promise<string[]>;
/**
* Returns the attestation state of a phone number/account/issuer tuple
* @param identifier Attestation identifier (e.g. phone hash)
* @param account Address of the account
*/
getAttestationState: (identifier: string, account: Address, issuer: Address) => Promise<AttestationStateForIssuer>;
/**
* Returns the attestation stats of a identifer/account pair
* @param identifier Attestation identifier (e.g. phone hash)
* @param account Address of the account
*/
getAttestationStat: (identifier: string, account: Address) => Promise<AttestationStat>;
/**
* Returns the verified status of an identifier/account pair indicating whether the attestation
* stats for a given pair are completed beyond a certain threshold of confidence (aka "verified")
* @param identifier Attestation identifier (e.g. phone hash)
* @param account Address of the account
* @param numAttestationsRequired Optional number of attestations required. Will default to
* hardcoded value if absent.
* @param attestationThreshold Optional threshold for fraction attestations completed. Will
* default to hardcoded value if absent.
*/
getVerifiedStatus(identifier: string, account: Address, numAttestationsRequired?: number, attestationThreshold?: number): Promise<{
isVerified: boolean;
numAttestationsRemaining: number;
total: number;
completed: number;
}>;
/**
* Calculates the amount of StableToken required to request Attestations
* @param attestationsRequested The number of attestations to request
*/
getAttestationFeeRequired(attestationsRequested: number): Promise<BigNumber>;
/**
* Approves the necessary amount of StableToken to request Attestations
* @param attestationsRequested The number of attestations to request
*/
approveAttestationFee(attestationsRequested: number): Promise<import("@celo/connect").CeloTransactionObject<boolean>>;
/**
* Returns the attestation signer for the specified account.
* @param account The address of token rewards are accumulated in.
* @param account The address of the account.
* @return The reward amount.
*/
getPendingWithdrawals: (token: string, account: string) => Promise<BigNumber>;
/**
* Allows issuers to withdraw accumulated attestation rewards
* @param address The address of the token that will be withdrawn
*/
withdraw: (token: string) => import("@celo/connect").CeloTransactionObject<void>;
/**
* Returns the current configuration parameters for the contract.
* @param tokens List of tokens used for attestation fees. use CeloTokens.getAddresses() to get
* @return AttestationsConfig object
*/
getConfig(tokens: string[]): Promise<AttestationsConfig>;
/**
* @dev Returns human readable configuration of the attestations contract
* @param tokens List of tokens used for attestation fees. use CeloTokens.getAddresses() to get
* @return AttestationsConfig object
*/
getHumanReadableConfig(tokens: string[]): Promise<{
attestationRequestFees: AttestationsToken[];
attestationExpiry: string;
}>;
/**
* Returns the list of accounts associated with an identifier.
* @param identifier Attestation identifier (e.g. phone hash)
*/
lookupAccountsForIdentifier: (identifier: string | number[]) => Promise<string[]>;
/**
* Lookup mapped wallet addresses for a given list of identifiers
* @param identifiers Attestation identifiers (e.g. phone hashes)
*/
lookupIdentifiers(identifiers: string[]): Promise<IdentifierLookupResult>;
revoke(identifer: string, account: Address): Promise<import("@celo/connect").CeloTransactionObject<void>>;
}
export type AttestationsWrapperType = AttestationsWrapper;
export {};