import { Address, QuantityInterface } from '@melonproject/token-math'; import { Contracts } from '../../Contracts'; import { Environment } from '../environment/Environment'; import { OptionsOrCallback, Options } from './prepareTransaction'; export declare type TransactionArg = number | number[] | string | string[]; export declare type TransactionArgs = TransactionArg[] | any; export interface UnsignedRawTransaction { from: string; to?: string; value?: string; gas?: string; gasPrice?: string; data?: string; nonce?: string; } export interface MelonTransaction { amguInEth: QuantityInterface; incentiveInEth: QuantityInterface; params: Args; rawTransaction: UnsignedRawTransaction; signedTransaction?: string; transactionArgs: TransactionArgs; } export declare type GuardFunction = (environment: Environment, params?: Args, contractAddress?: Address, options?: Options) => Promise; export declare type PrepareArgsFunction = (environment: Environment, params: Args, contractAddress?: Address) => Promise; export declare type PostProcessFunction = (environment: Environment, receipt: any, params?: Args, contractAddress?: Address) => Promise; export declare type TransactionFactory = (name: string, contract: Contracts, guard?: GuardFunction, prepareArgs?: PrepareArgsFunction, postProcess?: PostProcessFunction, defaultOptions?: OptionsOrCallback) => EnhancedExecute; declare type SendFunction = (environment: Environment, contractAddress: Address, signedTransactionData: string, params?: Args, options?: OptionsOrCallback) => Promise; declare type PrepareFunction = (environment: Environment, contractAddress: Address, params?: Args, options?: OptionsOrCallback) => Promise>; declare type ExecuteFunction = (environment: Environment, contractAddress: Address, params?: Args, options?: OptionsOrCallback) => Promise; export interface ExecuteMixin { send: SendFunction; prepare: PrepareFunction; } export declare type EnhancedExecute = ExecuteFunction & ExecuteMixin; export interface WithTransactionDecoratorOptions { guard?: GuardFunction; prepareArgs?: PrepareArgsFunction; postProcess?: PostProcessFunction; options?: OptionsOrCallback; } export declare type WithTransactionDecorator = (transaction: EnhancedExecute, decorator: WithTransactionDecoratorOptions) => EnhancedExecute; export declare const defaultGuard: GuardFunction; export declare const defaultPrepareArgs: PrepareArgsFunction; export declare const defaultPostProcess: PostProcessFunction; /** * The transaction factory returns a function "execute" (You have to rename it * to the actual name of the transaction, for example: "transfer"). As a * minimum, one needs to provide the transaction name and the contract path: * * ```typescript * const transfer = transactionFactory('transfer', Contract.Token); * ``` * * This transfer function can then be executed directly: * * ```typescript * await transfer(new Address('0xdeadbeef')); * ``` * * Or sliced into a prepare and a send part: * ```typescript * const preparedTransaction: PreparedTransaction = * await transfer.prepare(new Address('0xdeadbeef')); * * // pass that prepared transaction to the signer * const result = await transfer.send(new Address('0xdeadbeef'), * preparedTransaction); * ``` */ declare const transactionFactory: TransactionFactory; export { transactionFactory };