///
import { Transaction as EthereumJsTx, TxOptions } from '@ethereumjs/tx';
import { Interfaces, Models } from '@open-rights-exchange/chain-js';
import { EthereumChainState } from './ethChainState';
import { EthereumPrivateKey, EthereumRawTransaction, EthereumSignature, EthereumTransactionOptions, EthereumTransactionHeader, EthereumTransactionAction, EthereumAddress, EthereumAddressBuffer, EthereumPublicKey, EthereumActionHelperInput, EthereumSetDesiredFeeOptions } from './models';
import { EthereumMultisigPlugin, EthereumMultisigPluginRawTransaction, EthereumMultisigPluginTransaction } from './plugins/multisig/ethereumMultisigPlugin';
export declare class EthereumTransaction implements Interfaces.Transaction {
private _actionHelper;
private _chainState;
private _actualCost;
/** estimated fee for transacton (in Wei) - encoded as string to handle big numbers */
private _desiredFee;
/** estimated gas for transacton - encoded as string to handle big numbers */
private _estimatedGas;
private _executionPriority;
private _maxFeeIncreasePercentage;
private _isValidated;
private _options;
private _multisigPlugin;
private _multisigTransaction;
private _parentTransaction;
constructor(chainState: EthereumChainState, options?: EthereumTransactionOptions, multisigPlugin?: EthereumMultisigPlugin);
init(): Promise;
get multisigPlugin(): EthereumMultisigPlugin;
get multisigTransaction(): EthereumMultisigPluginTransaction;
private applyOptions;
private applyDefaultOptions;
get ethereumJsChainOptions(): TxOptions;
/** Returns whether the transaction is a multisig transaction */
get isMultisig(): boolean;
/** Whether transaction has been validated - via validate() */
get isValidated(): boolean;
/** Address from which transaction is being sent- from action.from (if provided) or derived from attached signature */
get senderAddress(): any;
/** Address retrieved from attached signature - Returns null if no signature attached */
get signedByAddress(): EthereumAddress;
/** Public Key retrieved from attached signature - Returns null if no from value or signature attached */
get signedByPublicKey(): EthereumPublicKey;
/** Header includes values included in transaction when sent to the chain
* These values are set by setRawProperties() is called since it includes gasPrice, gasLimit, etc.
*/
get header(): EthereumTransactionHeader;
/** Options provided when the transaction class was created */
get options(): EthereumTransactionOptions;
/** Raw transaction body - all values are Buffer types */
get raw(): EthereumRawTransaction;
/** Whether the raw transaction body has been set (via setting action or setTransaction()) */
get hasRaw(): boolean;
/** Ethereum chain module, returns a transaction instance that provides helper functions to sign, serialize etc... */
get ethereumJsTx(): EthereumJsTx;
/** Ethereum doesn't have any native multi-sig functionality */
get supportsMultisigTransaction(): boolean;
/** Ethereum transaction action (transfer & contract functions)
* Returns null or an array with exactly one action
*/
get actions(): EthereumTransactionAction[];
/** Private property for the Ethereum contract action - uses _actionHelper */
private get action();
/** Sets actions array
* Array length has to be exactly 1 because ethereum doesn't support multiple actions
*/
set actions(actions: EthereumTransactionAction[]);
/** Add action to the transaction body
* throws if transaction.actions already has a value
* Ignores asFirstAction parameter since only one action is supported in ethereum */
addAction(action: EthereumTransactionAction, asFirstAction?: boolean): void;
/**
* Updates 'raw' transaction properties using the actions attached
* Creates and sets private _ethereumJsTx (web3 EthereumJsTx object)
* Also adds header values (nonce, gasPrice, gasLimit) if not already set in action
*/
private setRawProperties;
/** Set the body of the transaction using Hex raw transaction data */
setTransaction(transaction: EthereumActionHelperInput | EthereumMultisigPluginRawTransaction): Promise;
/**
* Checks to see if gasPrice or GasLimit have been set at either the Action or the Transactino level
* The value set at the Action Level takes precidence and will overwrite the value set at the transaction level
* If it is found that GasPrice of GasLimit is set at the transaction or Action level, then explicitGasPriceOrGasLimitIsProvided is set to true
*/
getExplictlySetGasPriceAndGasLimit(): {
explicitGasPriceValue: string;
explicitGasLimitValue: string;
explicitGasPriceOrGasLimitIsProvided: boolean;
};
/**
* Updates nonce and gas fees (if necessary) - these values must be present
*/
prepareToBeSigned(): Promise;
/**
* If an explicit gasPrice was provided then set gasPriceOverride to that value
* If not then calculate a suggested fee
* If a explicit GasLimit was supplied then set that in the overide options
*/
private getExplicitGasFeeOrLimitAndCalculateSuggestedFeeIfNotexplicitlyProvided;
/** calculates a unique nonce value for the tx (if not already set) by using the chain transaction count for a given address */
setNonceIfEmpty(fromAddress: EthereumAddress | EthereumAddressBuffer): Promise;
/** Verifies that raw trx exists, sets nonce (using sender's address) if not already set
* Throws if any problems */
validate(): Promise;
/** Get signature attached to transaction - returns null if no signature */
get signatures(): EthereumSignature[];
/** Add signature to raw transaction - Accepts array with exactly one signature */
addSignatures: (signatures: EthereumSignature[]) => Promise;
/** Throws if signatures isn't properly formatted */
private assertValidSignature;
/** Whether there is an attached signature */
get hasAnySignatures(): boolean;
/** Throws if any signatures are attached */
private assertNoSignatures;
/** Throws if transaction is missing any signatures */
private assertHasSignature;
/** Whether there is an attached signature for the provided publicKey */
hasSignatureForPublicKey: (publicKey: EthereumPublicKey) => boolean;
/** Whether there is an attached signature for the publicKey of the address */
hasSignatureForAuthorization(authorization: EthereumAddress): Promise;
/** Whether signature is attached to transaction (and/or whether the signature is correct)
* If a specific action.from is specifed, ensure that attached signature matches its address/public key */
get hasAllRequiredSignatures(): boolean;
/** Throws if transaction is missing any signatures */
private assertHasAllRequiredSignature;
/** Returns address, for which, a matching signature must be attached to transaction
* ... always an array of length 1 because ethereum only supports one signature
* If no action.from is set, and no signature attached, throws an error since from addr cant be determined
* Throws if action.from is not a valid address */
get missingSignatures(): EthereumAddress[];
/** A transction in the pending pool can be cancelled */
get supportsCancel(): boolean;
/** Ethereum does not require chain resources for a transaction */
get supportsResources(): boolean;
/** Ethereum transactions do not require chain resources */
resourcesRequired(): Promise;
/** Gets estimated cost in units of gas to execute this transaction (at current chain rates) */
updateEstimatedGas(): Promise<{
gas: string;
}>;
/** Gets the estimated gas cost for this transaction in Wei
* if refresh = true, get updated cost from chain */
getEstimatedGas(refresh?: boolean): Promise;
/** Fee multipliers effective for this transaction - uses default values if not set via transaction options */
get feeMultipliers(): Models.TransactionFeePriorityMultipliers;
/** Get the suggested Eth fee (in Wei) for this transaction */
getSuggestedFee(priority?: Models.TxExecutionPriority): Promise<{
estimationType: Models.ResourceEstimationType;
feeStringified: string;
}>;
/** get the desired fee (in Ether) to spend on sending the transaction */
getDesiredFee(): Promise;
/** set the fee that you would like to pay (in Wei) - this will set the gasPrice and gasLimit (based on maxFeeIncreasePercentage)
* If gasLimitOverride is provided, gasPrice will be calculated and gasLimit will be set to gasLimitOverride
* desiredFeeStringified is stringified JSON object object of type: { fee: '123' } where string value is in Wei
* clear fees by passing in desiredFeeStringified = null
*/
setDesiredFee(desiredFeeStringified: string, options?: EthereumSetDesiredFeeOptions): Promise;
/** Hash of transaction - signature must be present to determine transactionId */
get transactionId(): string;
/** Returns fee after transaction execution is done in wei format */
get actualCost(): Models.ActualCost;
/** get the actual cost (in Ether) for executing the transaction */
private setActualCost;
get maxFeeIncreasePercentage(): number;
/** The maximum percentage increase over the desiredGas */
set maxFeeIncreasePercentage(percentage: number);
/** throws if required fee properties aren't set */
private assertHasFeeSetting;
/** Get the execution priority for the transaction - higher value attaches more fees */
get executionPriority(): Models.TxExecutionPriority;
set executionPriority(value: Models.TxExecutionPriority);
/** Returns address specified by actions[].from property
* throws if actions[].from is not a valid address - needed to determine the required signature */
get requiredAuthorizations(): EthereumAddress[];
/** Return the one signature address required */
private get requiredAuthorization();
/** Buffer encoding of transaction data/hash to sign */
get signBuffer(): Buffer;
private signAndAddSignatures;
/** Returns realted parent (to multisig) transaction (if appropriate for this tx)
* For a multisig tx, the parent is the tx sent to the mutlsig contract on the chain
* Throws if parent is not yet set or isnt required - use requiresParentTransaction() and hasParentTransaction() to check first */
get parentTransaction(): EthereumTransaction;
/** Whether parent transaction has been set yet */
get hasParentTransaction(): boolean;
/** Wether multisigPlugin requires transaction body to be wrapped in a parent transaction */
get requiresParentTransaction(): boolean;
/** Sign the transaction body with private key and add to attached signatures
* If Multisig, i gives priority for multisigSign until no plugin.missingSignatures is empty
* Then it automatically signs parent transaction with the first element of the privateKeys array
* This parent signature can be overriden by calling sign after all multisig signing is done.
*/
sign(privateKeys: EthereumPrivateKey[]): Promise;
/** Broadcast a signed transaction to the chain
* waitForConfirm specifies whether to wait for a transaction to appear in a block before returning */
send(waitForConfirm?: Models.ConfirmType, communicationSettings?: Models.ChainSettingsCommunicationSettings): Promise;
/** Updates the multisig parent transaction for this transaction - if enough signatures are attached
* ParentTransaction is the transaction sent to chain - e.g. sent to multisig contract.
* Action (e.g transfer token) is embedded as data in parent transaction
*/
updateMultisigParentTransaction(): Promise;
/** Throws if parentTransaction isnt supported or missing */
assertHasParentTransaction(): void;
/** Throws if not yet connected to chain - via chain.connect() */
private assertIsConnected;
/** Throws if not validated */
private assertIsValidated;
/** Whether action.from (if present) is a valid ethereum address - also checks that from is provided if data was */
private assertFromIsValid;
/** Throws if an action isn't attached to this transaction */
private assertHasAction;
/** Throws if no raw transaction body */
private assertHasRaw;
/** If multisig plugin is required, make sure its initialized */
private assertHasMultisigPlugin;
/** If multisig plugin is required, make sure its initialized */
private assertMultisigPluginIsInitialized;
private isFromAValidAddressOrEmpty;
/** Whether the from address is null or empty */
private isFromEmptyOrNullAddress;
/** JSON representation of transaction data */
toJson(): any;
/** Ensures that the value comforms to a well-formed signature */
toSignature(value: any): EthereumSignature;
/** 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;
}