UNPKG

@meterio/devkit

Version:

Typescript library to aid DApp development on Meter network

393 lines (392 loc) 14.1 kB
/// <reference types="node" /> import { RLP } from './rlp'; import { abi } from './abi'; export declare namespace ScriptEngine { const SCRIPT_ENGINE_PREFIX = "ffffffff"; const SCRIPT_ENGINE_VERSION = 0; const SCRIPT_DATA_PREFIX = "deadbeef"; const STAKING_VERSION = 0; const AUCTION_VERSION = 0; const EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000"; const EMPTY_BYTE32 = "0x0000000000000000000000000000000000000000000000000000000000000000"; enum ModuleID { Staking = 1000, Auction = 1001, AccountLock = 1002 } enum Token { Meter = 0, MeterGov = 1 } enum StakingOpCode { Bound = 1, Unbound = 2, Candidate = 3, Uncandidate = 4, Delegate = 5, Undelegate = 6, CandidateUpdate = 7, BucketUpdate = 8, DelegateStats = 101, BailOut = 102, FlushAllStats = 103, Governing = 10001 } const NativeBucketOpenABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketCloseABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketDepositABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketMergeABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketTransferFundABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketUpdateCandidateABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketWithdrawABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeAuctionEndABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeAuctionStartABI: { anonymous: boolean; inputs: { indexed: boolean; internalType: string; name: string; type: string; }[]; name: string; type: string; }; const NativeBucketOpen: abi.Event; const NativeBucketClose: abi.Event; const NativeBucketDeposit: abi.Event; const NativeBucketWithdraw: abi.Event; const NativeBucketMerge: abi.Event; const NativeBucketTransferFund: abi.Event; const NativeBucketUpdateCandidate: abi.Event; const NativeAuctionEnd: abi.Event; const NativeAuctionStart: abi.Event; const explainStakingOpCode: (opCode: StakingOpCode) => "Bound" | "Unbound" | "Candidate" | "Uncandidate" | "Delegate" | "Undelegate" | "UpdateCandidate" | "UpdateBucket" | "DelegateStats" | "BailOut" | "FlushStats" | "Govern"; enum StakingOption { Empty = 0, OneWeekLock = 1, TwoWeekLock = 2, ThreeWeekLock = 3, FourWeekLock = 4 } enum BucketUpdateOption { Add = 0, Sub = 1 } enum AuctionOpCode { Start = 1, End = 2, Bid = 3 } enum AuctionOption { Userbid = 0, Autobid = 1 } const explainAuctionOpCode: (opCode: AuctionOpCode, option: AuctionOption) => "StartAuction" | "EndAuction" | "Userbid" | "Autobid" | "Bid"; enum AccountLockOpCode { Add = 1, Remove = 2, Transfer = 3, Governing = 100 } const explainAccountLockOpCode: (opCode: AccountLockOpCode) => "AddAcctLock" | "RemoveAcctLock" | "TransferAcctLock" | "GovernAcctLock"; function IsScriptEngineData(hexStr: string): boolean; function encodeScriptData(moduleID: ModuleID, body: StakingBody | AuctionBody): string; function decodeScriptData(input: Buffer | string): DecodedScriptData; function decodeStakingBody(input: Buffer | string): DecodedStakingBody; function decodeAuctionBody(input: Buffer | string): AuctionBody; function decodeAccountLockBody(input: Buffer | string): AccountLockBody; function decodeStakingGoverningExtra(input: Buffer | string): RewardInfo[]; function decodeStakingGoverningV2Extra(input: Buffer | string): RewardInfoV2[]; function decodeStakingStatExtra(input: Buffer | string): Infraction; function getAuctionTxFromAuctionBody(body: AuctionBody): AuctionTx | undefined; const ScriptDataProfile: RLP.Profile; class ScriptDataHeader { version: number; modId: number; constructor(version: number, modId: number); } class DecodedScriptData { header: { version: number; modId: number; }; payload: string; action: string; body: AuctionBody | DecodedStakingBody | AccountLockBody | undefined; constructor(data: ScriptData, action: string, body?: AuctionBody | DecodedStakingBody | AccountLockBody | undefined); } class ScriptData { header: ScriptDataHeader; payload: string; constructor(modId: number, payload: string); encode(): string; } const StakingGoverningExtraProfile: RLP.Profile; const StakingGoverningV2ExtraProfile: RLP.Profile; class RewardInfo { address: string; amount: string; constructor(address: string, amount: string); } class RewardInfoV2 { address: string; distAmount: string; autobidAmount: string; constructor(address: string, distAmount: string, autobidAmount: string); } class RoundInfo { epoch: number; round: number; constructor(epoch: number, round: number); } class HeightInfo { epoch: number; height: number; constructor(epoch: number, height: number); } class MissingLeader { counter: number; info: RoundInfo[]; constructor(counter: number, info: RoundInfo[]); } class MissingProposer { counter: number; info: HeightInfo[]; constructor(counter: number, info: HeightInfo[]); } class MissingVoter { counter: number; info: HeightInfo[]; constructor(counter: number, info: HeightInfo[]); } class DoubleSign { counter: number; info: HeightInfo[]; constructor(counter: number, info: HeightInfo[]); } class Infraction { missingLeader: MissingLeader; missingProposer: MissingProposer; missingVoter: MissingVoter; doubleSign: DoubleSign; constructor(missingLeader: MissingLeader, missingProposer: MissingProposer, missingVoter: MissingVoter, doubleSign: DoubleSign); encode(): string; } const MissingLeaderProfile: RLP.Profile; const MissingProposerProfile: RLP.Profile; const MissingVoterProfile: RLP.Profile; const DoubleSignProfile: RLP.Profile; const InfractionProfile: RLP.Profile; const StakingBodyProfile: RLP.Profile; const BucketIDProfile: RLP.Profile; class DecodedStakingBody { opCode: StakingOpCode; version: number; option: number; holderAddr: string; candidateAddr: string; candidateName: string; candidateDescription: string; candidatePubKey: string; candidateIP: string; candidatePort: number; bucketID: string; amount: string; token: Token; autobid: number; timestamp: number; nonce: number; extra: undefined | Infraction | RewardInfo[] | RewardInfoV2[]; constructor(sb: StakingBody, extra: undefined | Infraction | RewardInfo[] | RewardInfoV2[]); } class StakingBody { opCode: StakingOpCode; version: number; option: number; holderAddr: string; candidateAddr: string; candidateName: string; candidateDescription: string; candidatePubKey: string; candidateIP: string; candidatePort: number; bucketID: string; amount: string; token: Token; autobid: number; timestamp: number; nonce: number; extra: string; constructor(op: StakingOpCode, option: number, holderAddr: string, candidateAddr: string, candidateName: string, candidateDescription: string, candidatePubKey: string, candidateIP: string, candidatePort: number, bucketID: string, amount: string | number, token: Token, autobid: number, timestamp?: number, nonce?: number); encode(): string; } /** * @deprecated * @param sb * @returns */ function jsonFromStakingBody(sb: StakingBody): any; function getBoundData(option: number, holderAddr: string, candidateAddr: string, amount: number | string, timestamp?: number, nonce?: number, autobid?: number): string; function getUnboundData(holderAddr: string, stakingIDStr: string, amount: number | string, timestamp?: number, nonce?: number): string; function getBucketAddData(holderAddr: string, bucketID: string, amount: number | string, timestamp?: number, nonce?: number): string; function getBucketSubData(holderAddr: string, bucketID: string, amount: number | string, timestamp?: number, nonce?: number): string; function getCandidateData(holderAddr: string, candidateName: string, candidateDescription: string, candidatePubKey: string, candidateIP: string, candidatePort: number, amount: number | string, commission: number, timestamp?: number, nonce?: number, autobid?: number): string; function getUncandidateData(candidateAddr: string, timestamp?: number, nonce?: number): string; function getDelegateData(holderAddr: string, candidateAddr: string, bucketID: string, amount: string | number, timestamp?: number, nonce?: number, autobid?: number): string; function getUndelegateData(holderAddr: string, stakingIDStr: string, amount: number | string, timestamp?: number, nonce?: number): string; function getCandidateUpdateData(holderAddr: string, candidateName: string, candidateDescription: string, candidatePubKey: string, candidateIP: string, candidatePort: number, commission: number, timestamp?: number, nonce?: number, autobid?: number): string; function getBailOutData(holderAddr: string, timestamp?: number, nonce?: number): string; const AuctionControlBlockProfile: RLP.Profile; class AuctionControlBlock { startHeight: number; startEpoch: number; endHeight: number; endEpoch: number; rlsdMTRG: string; rsvdMTRG: string; rsvdPrice: string; createTime: number; constructor(startHeight: number, startEpoch: number, endHeight: number, endEpoch: number, rlsdMTRG: string | number, rsvdMTRG: string | number, rsvdPrice: string | number, createTime: number); ID(): string; } const AuctionTxProfile: RLP.Profile; class AuctionTx { address: Buffer; amount: string; type: number; timestamp: number; nonce: string; constructor(address: string, amount: string | number, type: number, timestamp: number, nonce: string | number); ID(): string; } const AuctionBodyProfile: RLP.Profile; class AuctionBody { opCode: AuctionOpCode; version: number; option: AuctionOption; startHeight: number; startEpoch: number; endHeight: number; endEpoch: number; sequence: number; auctionID: string; bidder: string; amount: string; reserveAmount: string; token: Token; timestamp: number; nonce: number; constructor(opCode: AuctionOpCode, option: number, auctionID: string, bidder: string, amount: string | number, timestamp?: number, nonce?: number); encode(): string; } /** * @deprecated * @param ab * @returns */ function jsonFromAuctionBody(ab: AuctionBody): object; function getBidData(bidder: string, amount: number | string, timestamp?: number, nonce?: number): string; const AccountLockBodyProfile: RLP.Profile; class AccountLockBody { opCode: AccountLockOpCode; version: number; option: number; lockEpoch: number; releaseEpoch: number; fromAddr: string; toAddr: string; meterAmount: string; meterGovAmount: string; memo: string; constructor(op: AccountLockOpCode, lockEpoch: number, releaseEpoch: number, fromAddr: string, toAddr: string, meterAmount: number | string, meterGovAmount: number | string, memo: string); encode(): string; } /** * @deprecated * @param alb * @returns */ function jsonFromAccountLockBody(alb: AccountLockBody): object; function getLockedTransferData(lockEpoch: number, releaseEpoch: number, fromAddr: string, toAddr: string, meterAmount: number | string, meterGovAmount: number | string, memo: string): string; function getBucketID(owner: string, nonce: number, timestamp: number): string; }