import { AnyAction } from "redux" ; import { Dispatch } from "react-redux" ; import { MultisigTransaction } from "@joincivil/core/build/src/contracts/multisig/multisigtransaction" ; import { CivilHelper } from "../../apis/CivilHelper" ; export enum governmentActions { ADD_OR_UPDATE_GOVT_PROPOSAL = "ADD_OR_UPDATE_GOVT_PROPOSAL" , SET_GOVT_PARAMETER = "SET_GOVT_PARAMETER" , MULTI_SET_GOVT_PARAMETERS = "MULTI_SET_GOVT_PARAMETERS" , ADD_GOVERNMENT_DATA = "ADD_GOVERNMENT_DATA" , SET_CONSTITUTION_DATA = "SET_CONSTITUTION_DATA" , SET_APPELLATE = "SET_APPELLATE" , SET_CONTROLLER = "SET_CONTROLLER" , SET_APPELLATE_MEMBERS = "SET_APPELLATE_MEMBERS" , ADD_COUNCIL_MULTISIG_TRANSACTION = "ADD_COUNCIL_MULTISIG_TRANSACTION" } export const setGovernmentParameter = ( paramName , paramValue ) : AnyAction => { return { type : governmentActions . SET_GOVT_PARAMETER , paramName , paramValue , } ; } ; export const multiSetGovtParameters = ( paramsObj ) : AnyAction => { return { type : governmentActions . MULTI_SET_GOVT_PARAMETERS , params : paramsObj , } ; } ; export const addOrUpdateGovtProposal = ( proposal ) : AnyAction => { return { type : governmentActions . ADD_OR_UPDATE_GOVT_PROPOSAL , proposal , } ; } ; export const addGovernmentData = ( governmentDataKey , governmentDataValue ) : AnyAction => { return { type : governmentActions . ADD_GOVERNMENT_DATA , data : { key : governmentDataKey , value : governmentDataValue , } , } ; } ; export const setConstitutionData = ( constitutionDataKey , constitutionDataValue ) : AnyAction => { return { type : governmentActions . SET_CONSTITUTION_DATA , data : { key : constitutionDataKey , value : constitutionDataValue , } , } ; } ; export const setAppellate = ( appellate ) : AnyAction => { return { type : governmentActions . SET_APPELLATE , data : appellate , } ; } ; export const setController = ( controller ) : AnyAction => { return { type : governmentActions . SET_CONTROLLER , data : controller , } ; } ; export const setAppellateMembers = ( members ) : AnyAction => { return { type : governmentActions . SET_APPELLATE_MEMBERS , data : members , } ; } ; export const addCouncilMultisigTransaction = ( transaction ) : AnyAction => { return { type : governmentActions . ADD_COUNCIL_MULTISIG_TRANSACTION , data : transaction , } ; } ; export const checkAndUpdateGovtParameterProposalState = ( helper , paramPropID ) : any => { return async ( dispatch , getState ) : Promise < AnyAction | undefined > => { const { proposals } = getState ( ) . networkDependent ; const paramProposal = proposals . get ( paramPropID ) ; if ( ! paramProposal ) { return ; } const tcr = await helper . getTCR ( ) ; const government = await tcr . getGovernment ( ) ; const paramProposalState = await government . getPropState ( paramPropID ) ; if ( paramProposalState !== paramProposal . state ) { return dispatch ( addOrUpdateGovtProposal ( { ... paramProposal , state : paramProposalState } ) ) ; } return ; } ; } ;