MyCrypto/common/reducers/contracts.js
William O'Beirne e3505fd958 Contracts Tab Scaffolding (#70)
* Empty component, routes setup.

* Shared components for all Contracts inputs. Dont do anything yet.

* Check in reducer work so far. Still WIP.

* Header styling

* Check in input work so far, splitting to new branch.

* Strip down contracts inputs. Split out into form and explorer

* Contract selector

* Constantized config actions to use in contract saga.

* Interact explorer UI, no functionality

* Convert to constants, hook up errors

* Deploy and style cleanup.

* Remove unnecessary class.

* Fix flow errors with css modules

* Attempt at fixing all newly introduced flow errors in the contracts branch.

* Removed unused validator.

* Remove action constants, fix flow specificity in reducers

* Fix unit tests

* Move network contracts out of redux / sagas, and read directly from state with a selector in mapStateToProps.

* Fix initialState -> INITIAL_STATE rename

* foreach push -> concat
2017-07-27 19:31:59 -05:00

40 lines
829 B
JavaScript

import type {
AccessContractAction,
SetInteractiveContractAction
} from 'actions/contracts';
export type State = {
selectedAddress: ?string,
selectedABIJson: ?string,
selectedABIFunctions: ?Array
};
export const initialState: State = {
// Interact
selectedAddress: null,
selectedABIJson: null,
selectedABIFunctions: null
};
type Action = AccessContractAction | SetInteractiveContractAction;
export function contracts(state: State = initialState, action: Action) {
switch (action.type) {
case 'ACCESS_CONTRACT':
return {
...state,
selectedAddress: action.address,
selectedABIJson: action.abiJson
};
case 'SET_INTERACTIVE_CONTRACT':
return {
...state,
selectedABIFunctions: action.functions
};
default:
return state;
}
}