|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import { ContractData } from '@remix-project/core-plugin' |
|
|
|
|
import { ContractList, DeployOptions, RunTabState } from '../types' |
|
|
|
|
import { ADD_INSTANCE, ADD_PINNED_INSTANCE, UPDATE_INSTANCES_BALANCE, ADD_PROVIDER, CLEAR_INSTANCES, CLEAR_PINNED_INSTANCES, CLEAR_RECORDER_COUNT, DISPLAY_NOTIFICATION, DISPLAY_POPUP_MESSAGE, FETCH_ACCOUNTS_LIST_FAILED, FETCH_ACCOUNTS_LIST_REQUEST, FETCH_ACCOUNTS_LIST_SUCCESS, FETCH_CONTRACT_LIST_FAILED, FETCH_CONTRACT_LIST_REQUEST, FETCH_CONTRACT_LIST_SUCCESS, FETCH_PROVIDER_LIST_FAILED, FETCH_PROVIDER_LIST_REQUEST, FETCH_PROVIDER_LIST_SUCCESS, HIDE_NOTIFICATION, HIDE_POPUP_MESSAGE, REMOVE_INSTANCE, REMOVE_PROVIDER, RESET_STATE, SET_BASE_FEE_PER_GAS, SET_CONFIRM_SETTINGS, SET_CHAIN_ID, SET_CURRENT_CONTRACT, SET_CURRENT_FILE, SET_DECODED_RESPONSE, SET_DEPLOY_OPTIONS, SET_EXECUTION_ENVIRONMENT, SET_EXTERNAL_WEB3_ENDPOINT, SET_GAS_LIMIT, SET_GAS_PRICE, SET_GAS_PRICE_STATUS, SET_IPFS_CHECKED_STATE, SET_LOAD_TYPE, SET_MATCH_PASSPHRASE, SET_MAX_FEE, SET_MAX_PRIORITY_FEE, SET_NETWORK_NAME, SET_PASSPHRASE, SET_PATH_TO_SCENARIO, SET_PERSONAL_MODE, SET_RECORDER_COUNT, SET_SELECTED_ACCOUNT, SET_SEND_UNIT, SET_SEND_VALUE, ADD_DEPLOY_OPTION, REMOVE_DEPLOY_OPTION, SET_REMIXD_ACTIVATED, FETCH_PROXY_DEPLOYMENTS, NEW_PROXY_DEPLOYMENT, RESET_PROXY_DEPLOYMENTS, EXTRACT_COMPILER_VERSION } from '../constants' |
|
|
|
|
import { ADD_INSTANCE, PIN_INSTANCE, UNPIN_INSTANCE, UPDATE_INSTANCES_BALANCE, ADD_PROVIDER, CLEAR_INSTANCES, CLEAR_RECORDER_COUNT, DISPLAY_NOTIFICATION, DISPLAY_POPUP_MESSAGE, FETCH_ACCOUNTS_LIST_FAILED, FETCH_ACCOUNTS_LIST_REQUEST, FETCH_ACCOUNTS_LIST_SUCCESS, FETCH_CONTRACT_LIST_FAILED, FETCH_CONTRACT_LIST_REQUEST, FETCH_CONTRACT_LIST_SUCCESS, FETCH_PROVIDER_LIST_FAILED, FETCH_PROVIDER_LIST_REQUEST, FETCH_PROVIDER_LIST_SUCCESS, HIDE_NOTIFICATION, HIDE_POPUP_MESSAGE, REMOVE_INSTANCE, REMOVE_PROVIDER, RESET_STATE, SET_BASE_FEE_PER_GAS, SET_CONFIRM_SETTINGS, SET_CHAIN_ID, SET_CURRENT_CONTRACT, SET_CURRENT_FILE, SET_DECODED_RESPONSE, SET_DEPLOY_OPTIONS, SET_EXECUTION_ENVIRONMENT, SET_EXTERNAL_WEB3_ENDPOINT, SET_GAS_LIMIT, SET_GAS_PRICE, SET_GAS_PRICE_STATUS, SET_IPFS_CHECKED_STATE, SET_LOAD_TYPE, SET_MATCH_PASSPHRASE, SET_MAX_FEE, SET_MAX_PRIORITY_FEE, SET_NETWORK_NAME, SET_PASSPHRASE, SET_PATH_TO_SCENARIO, SET_PERSONAL_MODE, SET_RECORDER_COUNT, SET_SELECTED_ACCOUNT, SET_SEND_UNIT, SET_SEND_VALUE, ADD_DEPLOY_OPTION, REMOVE_DEPLOY_OPTION, SET_REMIXD_ACTIVATED, FETCH_PROXY_DEPLOYMENTS, NEW_PROXY_DEPLOYMENT, RESET_PROXY_DEPLOYMENTS, EXTRACT_COMPILER_VERSION } from '../constants' |
|
|
|
|
|
|
|
|
|
declare const window: any |
|
|
|
|
interface Action { |
|
|
|
@ -64,10 +64,6 @@ export const runTabInitialState: RunTabState = { |
|
|
|
|
instanceList: [], |
|
|
|
|
error: null |
|
|
|
|
}, |
|
|
|
|
pinnedInstances: { |
|
|
|
|
instanceList: [], |
|
|
|
|
error: null |
|
|
|
|
}, |
|
|
|
|
recorder: { |
|
|
|
|
pathToScenario: 'scenario.json', |
|
|
|
|
transactionCount: 0 |
|
|
|
@ -488,7 +484,7 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case ADD_INSTANCE: { |
|
|
|
|
const payload: { contractData: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record<number, any> } = action.payload |
|
|
|
|
const payload: { contractData?: ContractData, address: string, name: string, abi?: any, isPinned?: boolean, pinnedAt?: number } = action.payload |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
@ -499,17 +495,6 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case ADD_PINNED_INSTANCE: { |
|
|
|
|
const payload: { contractData: ContractData, address: string, name: string, abi?: any, pinnedAt: number, decodedResponse?: Record<number, any> } = action.payload |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
pinnedInstances: { |
|
|
|
|
...state.pinnedInstances, |
|
|
|
|
instanceList: [...state.pinnedInstances.instanceList, payload] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case UPDATE_INSTANCES_BALANCE: { |
|
|
|
|
const payload: Array<{ contractData: ContractData, address: string, balance: number, name: string, abi?: any, decodedResponse?: Record<number, any> }> = action.payload |
|
|
|
|
|
|
|
|
@ -523,28 +508,8 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case REMOVE_INSTANCE: { |
|
|
|
|
const payload: { index: number, isPinnedContract: boolean, shouldDelete: boolean } = action.payload |
|
|
|
|
|
|
|
|
|
if (payload.isPinnedContract) { |
|
|
|
|
if (payload.shouldDelete) return { |
|
|
|
|
...state, |
|
|
|
|
pinnedInstances: { |
|
|
|
|
...state.pinnedInstances, |
|
|
|
|
instanceList: state.pinnedInstances.instanceList.filter((_, index) => index !== payload.index) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else return { |
|
|
|
|
...state, |
|
|
|
|
pinnedInstances: { |
|
|
|
|
...state.pinnedInstances, |
|
|
|
|
instanceList: state.pinnedInstances.instanceList.filter((_, index) => index !== payload.index) |
|
|
|
|
}, |
|
|
|
|
instances: { |
|
|
|
|
...state.instances, |
|
|
|
|
instanceList: [...state.instances.instanceList, state.pinnedInstances.instanceList[payload.index]] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else return { |
|
|
|
|
const payload: { index: number } = action.payload |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
instances: { |
|
|
|
|
...state.instances, |
|
|
|
@ -553,20 +518,34 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case CLEAR_INSTANCES: { |
|
|
|
|
case PIN_INSTANCE: { |
|
|
|
|
const payload: { index: number, pinnedAt: number, filePath: string } = action.payload |
|
|
|
|
state.instances.instanceList[payload.index].isPinned = true |
|
|
|
|
state.instances.instanceList[payload.index].pinnedAt = payload.pinnedAt |
|
|
|
|
state.instances.instanceList[payload.index].filePath = payload.filePath |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
instances: { |
|
|
|
|
instanceList: [], |
|
|
|
|
error: null |
|
|
|
|
...state.instances, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case CLEAR_PINNED_INSTANCES: { |
|
|
|
|
case UNPIN_INSTANCE: { |
|
|
|
|
const payload: { index: number } = action.payload |
|
|
|
|
state.instances.instanceList[payload.index].isPinned = false |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
pinnedInstances: { |
|
|
|
|
instances: { |
|
|
|
|
...state.instances, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case CLEAR_INSTANCES: { |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
instances: { |
|
|
|
|
instanceList: [], |
|
|
|
|
error: null |
|
|
|
|
} |
|
|
|
@ -574,29 +553,17 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case SET_DECODED_RESPONSE: { |
|
|
|
|
const payload: { instanceIndex: number, funcIndex: number, response: any, isPinnedContract: boolean } = action.payload |
|
|
|
|
if (action.payload.isPinnedContract) |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
pinnedInstances: { |
|
|
|
|
...state.pinnedInstances, |
|
|
|
|
instanceList: state.pinnedInstances.instanceList.map((instance, index) => { |
|
|
|
|
if (payload.instanceIndex === index) instance.decodedResponse[payload.funcIndex] = payload.response |
|
|
|
|
return instance |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
instances: { |
|
|
|
|
...state.instances, |
|
|
|
|
instanceList: state.instances.instanceList.map((instance, index) => { |
|
|
|
|
if (payload.instanceIndex === index) instance.decodedResponse[payload.funcIndex] = payload.response |
|
|
|
|
return instance |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
const payload: { instanceIndex: number, funcIndex: number, response: any } = action.payload |
|
|
|
|
return { |
|
|
|
|
...state, |
|
|
|
|
instances: { |
|
|
|
|
...state.instances, |
|
|
|
|
instanceList: state.instances.instanceList.map((instance, index) => { |
|
|
|
|
if (payload.instanceIndex === index) instance.decodedResponse[payload.funcIndex] = payload.response |
|
|
|
|
return instance |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case SET_PATH_TO_SCENARIO: { |
|
|
|
|