/// import { Transaction as AlgoTransactionClass } from 'algosdk'; import { Models, Interfaces } from '@open-rights-exchange/chain-js'; import { AlgorandChainState } from './algoChainState'; import { AlgorandAddress, AlgorandPrivateKey, AlgorandPublicKey, AlgorandRawTransactionMultisigStruct, AlgorandRawTransactionStruct, AlgorandSignature, AlgorandTransactionOptions, AlgorandTxAction, AlgorandTxActionRaw, AlgorandTxActionSdkEncoded, AlgorandTxHeaderParams } from './models'; import { AlgorandActionHelper } from './algoAction'; export declare class AlgorandTransaction implements Interfaces.Transaction { private _actionHelper; /** Instance of Algorand SDK's Algorand Transaction Class */ private _algoSdkTransaction; private _chainState; private _options; /** Raw transaction object including signature (if any) */ private _rawTransaction; /** Raw multisig transaction object including signature(s) (if any) */ private _rawTransactionMultisig; /** Public Key used to sign transaction - set by sign() */ private _signedByPublicKey; private _isValidated; private _actualCost; constructor(chainState: AlgorandChainState, options?: AlgorandTransactionOptions); init(): Promise; /** Returns a parent transaction - not used for Algorand */ get parentTransaction(): never; /** Whether parent transaction has been set yet - not used for Algorand */ get hasParentTransaction(): boolean; /** Wether multisigPlugin requires transaction body to be wrapped in a parent transaction - not used for Algorand */ get requiresParentTransaction(): boolean; /** Chain-specific values included in the transaction sent to the chain */ get header(): AlgorandTxHeaderParams; /** Options provided when the transaction class was created */ get options(): AlgorandTransactionOptions; /** Raw tranasction body (prepared for signing) */ get raw(): AlgorandRawTransactionStruct | AlgorandRawTransactionMultisigStruct; /** Whether the raw transaction body has been set or prepared */ get hasRaw(): 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; private addSignerKeyToRawTransactionIfNeeded; /** Set the transaction by using any one of many valid formats * Valid formats for transaction param include: * JSON with verbose key names and string values (or values encoded by AlgoSDK) * the blob from the results of an Algo SDK sign function * Supports either encoded as Uint8Array or JSON object of raw transaction * Example format: { txn: {}, sig: {}, sngr: {}, msig: {} } */ setTransaction(transaction: AlgorandTxAction | AlgorandTxActionRaw | AlgorandTxActionSdkEncoded | AlgorandRawTransactionStruct | AlgorandRawTransactionMultisigStruct | Uint8Array): Promise; /** actionHelper provides different formats of action - Use only to READ data */ get actionHelper(): AlgorandActionHelper; /** Algorand transaction action (transfer & asset related functions) */ get actions(): (AlgorandTxAction | AlgorandTxActionRaw | AlgorandTxActionSdkEncoded | AlgorandRawTransactionStruct | AlgorandRawTransactionMultisigStruct)[]; /** Private property for the Algorand action - uses _actionHelper */ private get action(); get algoSdkTransaction(): AlgoTransactionClass; /** update the private instance of AlgorandTransaction object using action info */ setAlgoSdkTransactionFromAction(): void; /** Sets actions array * Array length has to be exactly 1 because algorand doesn't support multiple actions */ set actions(actions: (AlgorandTxAction | AlgorandTxActionRaw | AlgorandTxActionSdkEncoded | AlgorandRawTransactionStruct | AlgorandRawTransactionMultisigStruct)[]); /** Add action to the transaction body * throws if transaction.actions already has a value * Ignores asFirstAction parameter since only one action is supported in algorand */ addAction(action: AlgorandTxAction | AlgorandTxActionRaw | AlgorandTxActionSdkEncoded, asFirstAction?: boolean): void; /** Throws if transaction has expired */ assertTransactionNotExpired(): Promise; /** Whether transaction is expired */ isExpired(): Promise; /** Date (and time) when transaction can first be sent to the chain (before which the transaction will fail) */ validOn(): Promise; /** Date (and time) when transaction expires */ expiresOn(): Promise; /** Verifies that raw trx exists * Throws if any problems */ validate(): Promise; /** Whether transaction has been validated - via validate() */ get isValidated(): boolean; /** Throws if not validated */ private assertIsValidated; /** Signatures attached to transaction */ get signatures(): AlgorandSignature[]; /** Add signatures to raw transaction * Only allows signatures that use the publicKey(s) required for the transaction (from accnt, rekeyed spending key, or mulisig keys) * Signatures are hexstring encoded Uint8Array */ addSignatures: (signaturesIn: AlgorandSignature[]) => Promise; /** Throws if signatures isn't properly formatted */ private assertValidSignatures; /** Whether there is an attached signature */ get hasAnySignatures(): boolean; /** Throws if any signatures are attached */ private assertNoSignatures; /** Throws if an action isn't attached to this transaction */ private assertHasAction; /** Whether there is an attached signature for the provided publicKey */ hasSignatureForPublicKey(publicKey: AlgorandPublicKey): boolean; /** Returns public keys of the signatures attached to the signed transaction * For a typical transaction, there is only signature, multiSig transactions can have more */ private getPublicKeysForSignaturesFromRawTx; /** Whether there is an attached signature for the publicKey of the address */ hasSignatureForAuthorization(address: AlgorandAddress): Promise; /** Whether signature is attached to transaction (and/or whether the signature is correct) */ get hasAllRequiredSignatures(): boolean; /** Returns whether the transaction is a multisig transaction */ get isMultisig(): boolean; /** Returns address, for which, a matching signature must be attached to transaction */ get missingSignatures(): AlgorandAddress[]; /** Multisig transaction options */ private get multiSigOptions(); /** Get the raw transaction (either regular or multisig) */ get rawTransaction(): AlgorandRawTransactionStruct | AlgorandRawTransactionMultisigStruct; get encodedRawTransaction(): string; /** Determine standard multisig options from raw msig struct */ private multisigOptionsFromRawTransactionMultisig; /** Public Key of account that has signed (or will sign) this transaction (for non-multisig) * Usually the same as the from address's PK - unless the account has been rekeyed in which case this is the rekeyed PK * If sign() function is used, this value will be set automatically * If using addSignature() for a rekeyed account, this value must be set in transaction options */ private get signerPublicKey(); /** Returns array of the required addresses for a transaction/multisig transaction * Returns the from address in the action or addresses from multisig options for multisig transaction */ get requiredAuthorizations(): AlgorandAddress[]; get signBuffer(): Buffer; /** Algorand provides the functionality to sign a transaction using multi-signature account */ get supportsMultisigTransaction(): boolean; /** Hexstring encoded hash of txn + tag (if any) - generated by Algo SDK Transaction object */ get transactionId(): string; /** Sign the transaction body with private key and add to attached signatures */ sign(privateKeys: AlgorandPrivateKey[]): Promise; /** Generate signed multisig transaction object and add signatures for every private key provided * Merge signatures with any we might already have in signedTransactionMultisig */ private signMultiSigTransaction; /** 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; /** apply options and/or use defaults */ private applyOptions; /** Throws if not yet connected to chain - via chain.connect() */ private assertIsConnected; /** Throws if transaction is missing any signatures */ private assertHasAllRequiredSignature; /** Throws if no raw transaction body */ private assertHasRaw; /** Whether action.from is a valid address (and not null or empty) */ private isFromAValidAddress; /** Throws if from is not null or empty algorand argument */ private assertFromIsValidAddress; /** Throws if from is not null or empty algorand argument */ private assertValidOptions; /** Whether the transaction signature is valid for this transaction body and publicKey provided */ private isValidTxSignatureForPublicKey; /** extract 'from' address from various action types and confirm it matches multisig options */ private assertMultisigFromMatchesOptions; /** Set the raw trasaction properties from the packed results from using Algo SDK to sign tx */ private setRawTransactionFromSignResults; /** JSON representation of transaction data */ toJson(): any; get supportsCancel(): boolean; /** Algorand does not require chain resources for a transaction */ get supportsResources(): boolean; /** Algorand transactions do not require chain resources */ resourcesRequired(): Promise; /** Returns Algorand specific transaction resource unit (bytes) */ cost(): Promise<{ bytes: number; }>; /** Sets transaction fee property as flatfee * desiredFeeStringified is stringified JSON object object of type: { fee: '.01' } where string value is in Algos * clear fees by passing in desiredFeeStringified = null */ setDesiredFee(desiredFeeStringified: string): Promise; /** Ensures that the value comforms to a well-formed EOS signature */ toSignature(value: any): Models.SignatureBrand; /** Fee multipliers effective for this transaction - uses default values if not set via transaction options */ get feeMultipliers(): Models.TransactionFeePriorityMultipliers; /** Returns transaction fee in units of microalgos (expressed as a string) */ getSuggestedFee(priority: Models.TxExecutionPriority): Promise<{ estimationType: Models.ResourceEstimationType; feeStringified: string; }>; /** Returns the actual cost of executing the transaction in units of Algos */ get actualCost(): Models.ActualCost; private setActualCost; }