2017-09-25 02:06:28 +00:00
|
|
|
import {
|
2017-07-28 00:31:59 +00:00
|
|
|
AccessContractAction,
|
|
|
|
SetInteractiveContractAction
|
|
|
|
} from 'actions/contracts';
|
2017-09-25 02:06:28 +00:00
|
|
|
import { TypeKeys } from 'actions/contracts/constants';
|
|
|
|
export interface State {
|
|
|
|
selectedAddress?: string | null;
|
|
|
|
selectedABIJson?: string | null;
|
|
|
|
selectedABIFunctions?: any[] | null;
|
|
|
|
}
|
2017-07-28 00:31:59 +00:00
|
|
|
|
|
|
|
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) {
|
2017-09-25 02:06:28 +00:00
|
|
|
case TypeKeys.ACCESS_CONTRACT:
|
2017-07-28 00:31:59 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
selectedAddress: action.address,
|
|
|
|
selectedABIJson: action.abiJson
|
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
case TypeKeys.SET_INTERACTIVE_CONTRACT:
|
2017-07-28 00:31:59 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
selectedABIFunctions: action.functions
|
|
|
|
};
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|