added known types to actions

pull/1342/head
davidzagi93@gmail.com 3 years ago
parent 4c7211f275
commit 748e955f82
  1. 21
      libs/remix-ui/terminal/src/lib/actions/terminalAction.ts

@ -1,6 +1,7 @@
import React from 'react'
import { EmptyBlock, KnownTransaction, NewBlock, NewCall, NewTransaction, UnknownTransaction } from '../types/terminalTypes' import { EmptyBlock, KnownTransaction, NewBlock, NewCall, NewTransaction, UnknownTransaction } from '../types/terminalTypes'
export const registerCommandAction = (name, command, activate, dispatch) => { export const registerCommandAction = (name: string, command, activate, dispatch: React.Dispatch<any>) => {
const commands: any = {} const commands: any = {}
const _commands: any = {} const _commands: any = {}
_commands[name] = command _commands[name] = command
@ -69,7 +70,7 @@ export const registerCommandAction = (name, command, activate, dispatch) => {
} }
} }
export const filterFnAction = (name, filterFn, dispatch) => { export const filterFnAction = (name: string, filterFn, dispatch: React.Dispatch<any>) => {
const data: any = { const data: any = {
filterFns: {} filterFns: {}
} }
@ -77,43 +78,39 @@ export const filterFnAction = (name, filterFn, dispatch) => {
dispatch({ type: name, payload: { data: data } }) dispatch({ type: name, payload: { data: data } })
} }
export const registerLogScriptRunnerAction = (on, commandName, commandFn, dispatch) => { export const registerLogScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch<any>) => {
on('scriptRunner', commandName, (msg) => { on('scriptRunner', commandName, (msg) => {
commandFn.log.apply(commandFn, msg.data) commandFn.log.apply(commandFn, msg.data)
dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) dispatch({ type: commandName, payload: { commandFn, message: msg.data } })
}) })
} }
export const registerInfoScriptRunnerAction = (on, commandName, commandFn, dispatch) => { export const registerInfoScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch<any>) => {
on('scriptRunner', commandName, (msg) => { on('scriptRunner', commandName, (msg) => {
commandFn.info.apply(commandFn, msg.data) commandFn.info.apply(commandFn, msg.data)
dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) dispatch({ type: commandName, payload: { commandFn, message: msg.data } })
}) })
} }
export const registerWarnScriptRunnerAction = (on, commandName, commandFn, dispatch) => { export const registerWarnScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch<any>) => {
on('scriptRunner', commandName, (msg) => { on('scriptRunner', commandName, (msg) => {
commandFn.warn.apply(commandFn, msg.data) commandFn.warn.apply(commandFn, msg.data)
dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) dispatch({ type: commandName, payload: { commandFn, message: msg.data } })
}) })
} }
export const registerErrorScriptRunnerAction = (on, commandName, commandFn, dispatch) => { export const registerErrorScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch<any>) => {
on('scriptRunner', commandName, (msg) => { on('scriptRunner', commandName, (msg) => {
commandFn.error.apply(commandFn, msg.data) commandFn.error.apply(commandFn, msg.data)
dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) dispatch({ type: commandName, payload: { commandFn, message: msg.data } })
}) })
} }
// export const registerRemixWelcomeTextAction = (welcomeText, dispatch) => {
// dispatch({ type: 'welcomeText', payload: { welcomeText } })
// }
export const listenOnNetworkAction = async (event, isListening) => { export const listenOnNetworkAction = async (event, isListening) => {
event.trigger('listenOnNetWork', [isListening]) event.trigger('listenOnNetWork', [isListening])
} }
export const initListeningOnNetwork = (props, dispatch) => { export const initListeningOnNetwork = (props, dispatch: React.Dispatch<any>) => {
props.txListener.event.register(NewBlock, (block) => { props.txListener.event.register(NewBlock, (block) => {
if (!block.transactions || (block.transactions && !block.transactions.length)) { if (!block.transactions || (block.transactions && !block.transactions.length)) {
dispatch({ type: EmptyBlock, payload: { message: 0 } }) dispatch({ type: EmptyBlock, payload: { message: 0 } })
@ -129,7 +126,7 @@ export const initListeningOnNetwork = (props, dispatch) => {
log(props, tx, receipt, dispatch) log(props, tx, receipt, dispatch)
}) })
const log = async (props, tx, receipt, dispatch) => { const log = async (props, tx, receipt, dispatch: React.Dispatch<any>) => {
const resolvedTransaction = await props.txListener.resolvedTransaction(tx.hash) const resolvedTransaction = await props.txListener.resolvedTransaction(tx.hash)
if (resolvedTransaction) { if (resolvedTransaction) {
let compiledContracts = null let compiledContracts = null

Loading…
Cancel
Save