@celo/contractkit
Version:
Celo's ContractKit to interact with Celo network
219 lines (218 loc) • 9.45 kB
TypeScript
import { Accounts } from '@celo/abis/web3/Accounts';
import { StrongAddress } from '@celo/base';
import { Signature } from '@celo/base/lib/signatureUtils';
import { Address, CeloTransactionObject } from '@celo/connect';
import { BaseWrapper } from './BaseWrapper';
interface AccountSummary {
address: string;
name: string;
authorizedSigners: {
vote: Address;
validator: Address;
attestation: Address;
};
metadataURL: string;
wallet: Address;
dataEncryptionKey: string;
}
/**
* Contract for handling deposits needed for voting.
*/
export declare class AccountsWrapper extends BaseWrapper<Accounts> {
private RELEASE_4_VERSION;
/**
* Creates an account.
*/
createAccount: () => CeloTransactionObject<boolean>;
/**
* Returns the attestation signer for the specified account.
* @param account The address of the account.
* @return The address with which the account can vote.
*/
getAttestationSigner: (account: string) => Promise<StrongAddress>;
/**
* Returns if the account has authorized an attestation signer
* @param account The address of the account.
* @return If the account has authorized an attestation signer
*/
hasAuthorizedAttestationSigner: (account: string) => Promise<boolean>;
/**
* Returns the vote signer for the specified account.
* @param account The address of the account.
* @return The address with which the account can vote.
*/
getVoteSigner: (account: string) => Promise<StrongAddress>;
/**
* Returns the validator signer for the specified account.
* @param account The address of the account.
* @return The address with which the account can register a validator or group.
*/
getValidatorSigner: (account: string) => Promise<StrongAddress>;
/**
* Returns the account address given the signer for voting
* @param signer Address that is authorized to sign the tx as voter
* @return The Account address
*/
voteSignerToAccount: (signer: Address) => Promise<StrongAddress>;
/**
* Returns the account address given the signer for validating
* @param signer Address that is authorized to sign the tx as validator
* @return The Account address
*/
validatorSignerToAccount: (signer: Address) => Promise<StrongAddress>;
/**
* Returns the account associated with `signer`.
* @param signer The address of the account or previously authorized signer.
* @dev Fails if the `signer` is not an account or previously authorized signer.
* @return The associated account.
*/
signerToAccount: (signer: Address) => Promise<StrongAddress>;
/**
* Check if an account already exists.
* @param account The address of the account
* @return Returns `true` if account exists. Returns `false` otherwise.
*/
isAccount: (account: string) => Promise<boolean>;
/**
* Check if an address is a signer address
* @param address The address of the account
* @return Returns `true` if account exists. Returns `false` otherwise.
*/
isSigner: (address: string) => Promise<boolean>;
getCurrentSigners(address: string): Promise<string[]>;
getAccountSummary(account: string): Promise<AccountSummary>;
/**
* Authorize an attestation signing key on behalf of this account to another address.
* @param signer The address of the signing key to authorize.
* @param proofOfSigningKeyPossession The account address signed by the signer address.
* @return A CeloTransactionObject
*/
authorizeAttestationSigner(signer: Address, proofOfSigningKeyPossession: Signature): Promise<CeloTransactionObject<void>>;
/**
* Authorizes an address to sign votes on behalf of the account.
* @param signer The address of the vote signing key to authorize.
* @param proofOfSigningKeyPossession The account address signed by the signer address.
* @return A CeloTransactionObject
*/
authorizeVoteSigner(signer: Address, proofOfSigningKeyPossession: Signature): Promise<CeloTransactionObject<void>>;
/**
* Authorizes an address to sign consensus messages on behalf of the account.
* @param signer The address of the signing key to authorize.
* @param proofOfSigningKeyPossession The account address signed by the signer address.
* @return A CeloTransactionObject
*/
authorizeValidatorSigner(signer: Address, proofOfSigningKeyPossession: Signature, validatorsWrapper: {
isValidator: (account: string) => Promise<boolean>;
}): Promise<CeloTransactionObject<void>>;
/**
* @deprecated use `authorizeValidatorSignerWithPublicKey`
*/
authorizeValidatorSignerAndBls(signer: Address, proofOfSigningKeyPossession: Signature): Promise<CeloTransactionObject<void>>;
/**
* Authorizes an address to sign consensus messages on behalf of the account. Also switch BLS key at the same time.
* @param signer The address of the signing key to authorize.
* @param proofOfSigningKeyPossession The account address signed by the signer address.
* @return A CeloTransactionObject
*/
authorizeValidatorSignerWithPublicKey(signer: Address, proofOfSigningKeyPossession: Signature): Promise<CeloTransactionObject<void>>;
authorizeSigner(signer: Address, role: string): Promise<CeloTransactionObject<void>>;
startSignerAuthorization(signer: Address, role: string): Promise<CeloTransactionObject<void>>;
completeSignerAuthorization(account: Address, role: string): Promise<CeloTransactionObject<void>>;
/**
* Removes the currently authorized attestation signer for the account
* @returns A CeloTransactionObject
*/
removeAttestationSigner(): Promise<CeloTransactionObject<void>>;
generateProofOfKeyPossession(account: Address, signer: Address): Promise<{
v: number;
r: string;
s: string;
}>;
generateProofOfKeyPossessionLocally(account: Address, signer: Address, privateKey: string): Promise<{
v: number;
r: string;
s: string;
}>;
/**
* Returns the set name for the account
* @param account Account
* @param blockNumber Height of result, defaults to tip.
*/
getName(account: Address, blockNumber?: number): Promise<string>;
/**
* Returns the set data encryption key for the account
* @param account Account
*/
getDataEncryptionKey: (account: string) => Promise<string>;
/**
* Returns the set wallet address for the account
* @param account Account
*/
getWalletAddress: (account: string) => Promise<string>;
/**
* Returns the metadataURL for the account
* @param account Account
*/
getMetadataURL: (account: string) => Promise<string>;
/**
* Sets the data encryption of the account
* @param encryptionKey The key to set
*/
setAccountDataEncryptionKey: (dataEncryptionKey: string | number[]) => CeloTransactionObject<void>;
/**
* Convenience Setter for the dataEncryptionKey and wallet address for an account
* @param name A string to set as the name of the account
* @param dataEncryptionKey secp256k1 public key for data encryption. Preferably compressed.
* @param walletAddress The wallet address to set for the account
* @param proofOfPossession Signature from the wallet address key over the sender's address
*/
setAccount(name: string, dataEncryptionKey: string, walletAddress: Address, proofOfPossession?: Signature | null): CeloTransactionObject<void>;
/**
* Sets the name for the account
* @param name The name to set
*/
setName: (name: string) => CeloTransactionObject<void>;
/**
* Sets the metadataURL for the account
* @param url The url to set
*/
setMetadataURL: (metadataURL: string) => CeloTransactionObject<void>;
/**
* Set a validator's payment delegation settings.
* @param beneficiary The address that should receive a portion of validator
* payments.
* @param fraction The fraction of the validator's payment that should be
* diverted to `beneficiary` every epoch, given as FixidityLib value. Must not
* be greater than 1.
* @dev Use `deletePaymentDelegation` to unset the payment delegation.
*/
setPaymentDelegation: (beneficiary: string, fraction: string | number) => CeloTransactionObject<void>;
/**
* Remove a validator's payment delegation by setting beneficiary and
* fraction to 0.
*/
deletePaymentDelegation: () => CeloTransactionObject<void>;
/**
* Get a validator's payment delegation settings.
* @param account Account of the validator.
* @return Beneficiary address and fraction of payment delegated.
*/
getPaymentDelegation: (account: string) => Promise<{
0: string;
1: string;
}>;
/**
* Sets the wallet address for the account
* @param address The address to set
*/
setWalletAddress(walletAddress: Address, proofOfPossession?: Signature | null): CeloTransactionObject<void>;
parseSignatureOfAddress(address: Address, signer: string, signature: string): {
v: number;
r: string;
s: string;
};
private getParsedSignatureOfAddress;
private keccak256;
}
export type AccountsWrapperType = AccountsWrapper;
export {};