UNPKG

@aeternity/aepp-sdk

Version:

SDK for the æternity blockchain

108 lines (107 loc) 4.23 kB
import BigNumber from 'bignumber.js'; import { Encoded } from '../../utils/encoder.js'; import { AensName } from './constants.js'; /** * JavaScript-based Transaction builder helper function's */ /** * Build a contract address * @category contract * @param owner - Address of contract owner * @param nonce - Nonce of ContractCreateTx or state channel round when contract was created * @returns Contract address */ export declare function buildContractId(owner: Encoded.AccountAddress, nonce: number | BigNumber): Encoded.ContractAddress; /** * Build a oracle query id * @category oracle * @param senderId - The public key of the sender account * @param nonce - the nonce of the transaction * @param oracleId - The oracle public key * @returns Contract public key */ export declare function oracleQueryId(senderId: Encoded.AccountAddress, nonce: number | BigNumber | string, oracleId: Encoded.OracleAddress): Encoded.OracleQueryId; export declare function nameToPunycode(maybeName: string): AensName; /** * Encode an AENS name * @category AENS * @param name - Name to encode * @returns `nm_` prefixed encoded AENS name */ export declare function produceNameId(name: AensName): Encoded.Name; /** * Generate the commitment hash by hashing the salt and * name, base 58 encoding the result and prepending 'cm_' * @category transaction builder * @param name - Name to be registered * @param salt - Random number * @returns Commitment hash */ export declare function commitmentHash(name: AensName, salt?: number): Encoded.Commitment; /** * Utility function to convert bytes to int * @category utils * @param buffer - Value * @returns Buffer Buffer from number(BigEndian) * @deprecated use `BigInt('0x' + <buffer>.toString('hex')).toString()` instead */ export declare function readInt(buffer?: Uint8Array): string; /** * Ensure that name is valid AENS name, would throw an exception otherwise * @category AENS * @param maybeName - AENS name */ export declare function ensureName(maybeName: string): asserts maybeName is AensName; /** * Is AENS name valid * @category AENS * @param maybeName - AENS name */ export declare function isName(maybeName: string): maybeName is AensName; declare const encodingToPointerKey: readonly [readonly [Encoded.Encoding.AccountAddress, "account_pubkey"], readonly [Encoded.Encoding.OracleAddress, "oracle_pubkey"], readonly [Encoded.Encoding.ContractAddress, "contract_pubkey"], readonly [Encoded.Encoding.Channel, "channel"]]; /** * @category AENS * @param identifier - account/oracle/contract address, or channel * @returns default AENS pointer key */ export declare function getDefaultPointerKey(identifier: Encoded.Generic<(typeof encodingToPointerKey)[number][0]>): (typeof encodingToPointerKey)[number][1]; /** * Get the minimum AENS name fee * @category AENS * @param name - the AENS name to get the fee for * @returns the minimum fee for the AENS name auction */ export declare function getMinimumNameFee(name: AensName): BigNumber; /** * Compute bid fee for AENS auction * @category AENS * @param name - the AENS name to get the fee for * @param options - Options * @param options.startFee - Auction start fee * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1) * @returns Bid fee */ export declare function computeBidFee(name: AensName, { startFee, increment, }?: { startFee?: number | string | BigNumber; increment?: number; }): BigNumber; /** * Compute approximate auction end height. * * From Ceres, each time a new (successful!) bid is made for a name the auction is extended for up * to 120 key-blocks/generations. I.e. after the bid there is always at least 120 generations to * make a higher bid. * * @category AENS * @param name - Name to compute auction end for * @param claimHeight - Auction starting height * @see {@link https://github.com/aeternity/protocol/blob/cfb19ce/AENS.md#from-ceres-protocol-upgrade} * @returns Auction end height */ export declare function computeAuctionEndBlock(name: AensName, claimHeight: number): number; /** * Is name accept going to auction * @category AENS */ export declare function isAuctionName(name: AensName): boolean; export {};