types.ts
1 import { Wei, Data, Address, Nonce } from 'libs/units'; 2 3 export interface TransactionFieldsState { 4 to: SetToFieldAction['payload']; 5 data: SetDataFieldAction['payload']; 6 nonce: SetNonceFieldAction['payload']; 7 value: { raw: string; value: Wei | null }; // TODO: fix this workaround since some of the payload is optional 8 gasLimit: SetGasLimitFieldAction['payload']; 9 gasPrice: { raw: string; value: Wei }; 10 } 11 12 export enum TransactionFieldsActions { 13 GAS_LIMIT_INPUT = 'GAS_LIMIT_INPUT', 14 GAS_PRICE_INPUT = 'GAS_PRICE_INPUT', 15 GAS_PRICE_INPUT_INTENT = 'GAS_PRICE_INPUT_INTENT', 16 DATA_FIELD_INPUT = 'DATA_FIELD_INPUT', 17 NONCE_INPUT = 'NONCE_INPUT', 18 GAS_LIMIT_FIELD_SET = 'GAS_LIMIT_FIELD_SET', 19 DATA_FIELD_SET = 'DATA_FIELD_SET', 20 TO_FIELD_SET = 'TO_FIELD_SET', 21 VALUE_FIELD_SET = 'VALUE_FIELD_SET', 22 NONCE_FIELD_SET = 'NONCE_FIELD_SET', 23 GAS_PRICE_FIELD_SET = 'GAS_PRICE_FIELD_SET' 24 } 25 26 export interface InputGasLimitAction { 27 type: TransactionFieldsActions.GAS_LIMIT_INPUT; 28 payload: string; 29 } 30 31 export interface InputGasPriceAction { 32 type: TransactionFieldsActions.GAS_PRICE_INPUT; 33 payload: string; 34 } 35 36 export interface InputGasPriceIntentAction { 37 type: TransactionFieldsActions.GAS_PRICE_INPUT_INTENT; 38 payload: string; 39 } 40 41 export interface InputDataAction { 42 type: TransactionFieldsActions.DATA_FIELD_INPUT; 43 payload: string; 44 } 45 46 export interface InputNonceAction { 47 type: TransactionFieldsActions.NONCE_INPUT; 48 payload: string; 49 } 50 51 export interface SetGasLimitFieldAction { 52 type: TransactionFieldsActions.GAS_LIMIT_FIELD_SET; 53 payload: { 54 raw: string; 55 value: Wei | null; 56 }; 57 } 58 59 export interface SetGasPriceFieldAction { 60 type: TransactionFieldsActions.GAS_PRICE_FIELD_SET; 61 payload: { 62 raw: string; 63 value: Wei | null; 64 }; 65 } 66 67 export interface SetDataFieldAction { 68 type: TransactionFieldsActions.DATA_FIELD_SET; 69 payload: { 70 raw: string; 71 value: Data | null; 72 }; 73 } 74 75 export interface SetToFieldAction { 76 type: TransactionFieldsActions.TO_FIELD_SET; 77 payload: { 78 raw: string; 79 value: Address | null; 80 }; 81 } 82 83 export interface SetNonceFieldAction { 84 type: TransactionFieldsActions.NONCE_FIELD_SET; 85 payload: { 86 raw: string; 87 value: Nonce | null; 88 }; 89 } 90 91 export interface SetValueFieldAction { 92 type: TransactionFieldsActions.VALUE_FIELD_SET; 93 payload: { 94 raw: string; 95 value: Wei | null; 96 }; 97 } 98 99 export type InputFieldAction = InputNonceAction | InputGasLimitAction | InputDataAction; 100 101 export type TransactionFieldAction = 102 | SetGasLimitFieldAction 103 | SetDataFieldAction 104 | SetToFieldAction 105 | SetNonceFieldAction 106 | SetValueFieldAction 107 | SetGasPriceFieldAction;