/// import { Models, Interfaces } from '@open-rights-exchange/chain-js'; import { EosAccount } from './eosAccount'; import { EosChainState } from './eosChainState'; import { EosAuthorization, EosActionStruct, EosPublicKey, EosSignature, EosPrivateKey, EosTransactionOptions, EosSerializedTransaction, EosAuthorizationPerm, PermissionMapCache, EosTransactionResources, EosTxResult } from './models'; export declare class EosTransaction implements Interfaces.Transaction { private _publicKeyMap; private _cachedAccounts; private _actions; private _chainState; private _header; private _options; private _signatures; /** Transaction prepared for signing (raw transaction) */ private _raw; private _sendReceipt; private _signBuffer; private _requiredAuthorizations; private _isValidated; private _transactionId; private _actualCost; constructor(chainState: EosChainState, options?: EosTransactionOptions); init(): Promise; /** The header that is included when the transaction is sent to the chain * It is part of the transaction body (in the signBuffer) which is signed * The header changes every time prepareToBeSigned() is called since it includes latest block time, etc. */ get header(): any; /** The options provided when the transaction class was created */ get options(): EosTransactionOptions; /** The transaction body in raw format (by prepareForSigning) */ get raw(): Uint8Array; /** Returns a parent transaction - not used for Eos */ get parentTransaction(): never; /** Whether parent transaction has been set yet - Not used for Eos */ get hasParentTransaction(): boolean; /** Whether the raw transaction has been prepared */ get hasRaw(): boolean; /** Wether a transaction must be wrapped in a parent transaction */ get requiresParentTransaction(): boolean; get sendReceipt(): EosTxResult; /** EOSIO provides the functionality to sign a transaction using multiple signatures */ get supportsMultisigTransaction(): boolean; /** Generate the raw transaction body using the actions attached * Also adds a header to the transaction that is included when transaction is signed */ prepareToBeSigned(): Promise; /** Extract header from raw transaction body (eosjs refers to raw as serialized) */ private setHeaderFromRaw; /** Accepts either a raw transaction or an array of actions */ setTransaction(transactionOrActions: EosActionStruct[] | EosSerializedTransaction): Promise; /** Set the body of the transaction using Hex raw transaction data * This is one of the ways to set the actions for the transaction * Sets transaction data from raw transaction - supports both raw/serialized formats (JSON bytes array and hex) * This is an ASYNC call since it fetches (cached) action contract schema from chain in order to deserialize action data */ private setFromRaw; /** Creates a sign buffer using raw transaction body */ private setSignBuffer; /** Deserializes the transaction header and actions - fetches from the chain to deserialize action data */ private deRawifyWithActions; /** The contract actions executed by the transaction */ get actions(): EosActionStruct[]; /** Sets the Array of actions */ set actions(actions: EosActionStruct[]); /** Add one action to the transaction body * Setting asFirstAction = true places the new transaction at the top */ addAction(action: EosActionStruct, asFirstAction?: boolean): void; /** Verifies that all accounts and permisison for actions exist on chain. * Throws if any problems */ validate(): Promise; get isValidated(): boolean; /** Throws if transction doesnt have a raw value */ assertHasRaw(): void; /** Throws if not validated */ private assertIsValidated; /** Throws if transaction expired */ assertTransactionNotExpired(): Promise; /** Whether transaction has expired */ isExpired(): Promise; /** Date (and time) when transaction can first be sent to the chain (before which the transaction will fail) */ validOn(): Promise; /** Whether transaction has expired */ expiresOn(): Promise; /** Throw if action is missing basic action fields */ assertActionWellFormed(action: EosActionStruct): void; /** Signatures attached to transaction */ get signatures(): EosSignature[]; /** Add a signature to the set of attached signatures. Automatically de-duplicates values. */ addSignatures(signatures: EosSignature[]): Promise; /** Throws if signatures isn't properly formatted */ private assertValidSignature; /** Throws if any signatures are attached */ private assertNoSignatures; /** Whether there are any signatures attached */ get hasAnySignatures(): boolean; private checkAuthSigned; /** Whether there is an attached signature for every authorization (e.g. account/permission) in all actions */ get hasAllRequiredSignatures(): boolean; /** Throws if transaction is missing any signatures */ private assertHasAllRequiredSignature; /** An array of authorizations (e.g. account/permission) that do not have an attached signature * Retuns null if no signatures are missing */ get missingSignatures(): EosAuthorizationPerm[]; /** Whether there is an attached signature for the provided publicKey */ hasSignatureForPublicKey(publicKey: EosPublicKey): boolean; /** Whether there is an attached signature for the publicKey for the authoization (e.g. account/permission) * May need to call chain (async) to fetch publicKey(s) for authorization(s) * TODO support accounts not just keys */ hasSignatureForAuthorization(authorization: EosAuthorization): Promise; /** The transaction data needed to create a transaction signature. * It should be signed with a private key. */ get signBuffer(): Buffer; get isMultisig(): boolean; /** Sign the transaction body with private key(s) and add to attached signatures */ sign(privateKeys: EosPrivateKey[]): Promise; private setTransactionId; get transactionId(): string; /** An array of the unique set of account/permission/publicKey for all actions in transaction * Also fetches the related accounts from the chain (to get public keys) * NOTE: EOS requires async fecting, thus this getter requires validate() to be called * call fetchAuthorizationsRequired() if needed before validate() */ get requiredAuthorizations(): EosAuthorizationPerm[]; /** Collect unique set of account/permission for all actions in transaction * Retrieves public keys from the chain by retrieving account(s) when needed */ fetchAuthorizationsRequired(): Promise; /** Fetch the public key (from the chain) for the provided account and permission * Also caches permission/publicKey mappings - the cache can be set externally via appendPublicKeyCache */ private getAuthorizationForPermission; /** Fetches account names from the chain (and adds to private cache) */ private getAccount; /** Use an already fetched account instead of trying to refect from the chain * Can improve performance * Also neccessary for creating an inline transaction for an new account which isnt yet on the chain */ appendAccountToCache(account: EosAccount): Promise; /** Use an already fetched map of account/permission to public keys * Can improve performance - otherwise this class needs to retrieve accounts from the chain * Also neccessary for creating a new account which isnt yet on the chain */ appendPermissionCache(permissionMap: PermissionMapCache[]): void; /** Fetches public keys (from the chain) for each account/permission pair * Fetches accounts from the chain (if not already cached) */ private addAuthToPermissions; /** Broadcast a signed transaction to the chain * waitForConfirm specifies whether to wait for a transaction to appear in a block (or irreversable block) before returning */ send(waitForConfirm?: Models.ConfirmType, communicationSettings?: Models.ChainSettingsCommunicationSettings): Promise; /** Throws if not yet connected to chain - via chain.connect() */ private assertIsConnected; /** JSON representation of transaction data */ toJson(): any; /** Ensures that the value comforms to a well-formed EOS signature */ toSignature(value: any): Models.SignatureBrand; /** Accepts either an object where each value is the uint8 array value * ex: {'0': 24, ... '3': 93 } => [24,241,213,93] * OR a packed transaction as a string of hex bytes * */ private rawToUint8Array; get supportsCancel(): boolean; /** EOS requires chain resources for a transaction */ get supportsResources(): boolean; /** Chain resources required for Transaction */ resourcesRequired(): Promise; setDesiredFee(): Promise; getSuggestedFee(): Promise; private setActualCost; get actualCost(): Models.ActualCost; /** Placeholder */ anyEosSpecificFunction: () => void; }