decode response for saved contract

pull/4538/head
aniket-engg 9 months ago committed by Aniket
parent d595e3fccc
commit f60e3e3211
  1. 3
      libs/remix-ui/run-tab/src/lib/actions/deploy.ts
  2. 2
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  3. 5
      libs/remix-ui/run-tab/src/lib/actions/payload.ts
  4. 1
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  5. 1
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  6. 41
      libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
  7. 2
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -282,6 +282,7 @@ export const runTransactions = (
plugin: RunTab,
dispatch: React.Dispatch<any>,
instanceIndex: number,
isSavedContract: boolean,
lookupOnly: boolean,
funcABI: FuncABI,
inputsValues: string,
@ -318,7 +319,7 @@ export const runTransactions = (
(returnValue) => {
const response = txFormat.decodeResponse(returnValue, funcABI)
dispatch(setDecodedResponse(instanceIndex, response, funcIndex))
dispatch(setDecodedResponse(instanceIndex, response, funcIndex, isSavedContract))
},
(network, tx, gasEstimation, continueTxExecution, cancelCb) => {
confirmationHandler(plugin, dispatch, mainnetPrompt, network, tx, gasEstimation, continueTxExecution, cancelCb)

@ -50,7 +50,7 @@ export const setMaxPriorityFee = (fee: string) => updateMaxPriorityFee(dispatch,
export const removeInstances = () => clearInstances(dispatch)
export const removeSingleInstance = (index: number) => removeInstance(dispatch, index)
export const getExecutionContext = () => getContext(plugin)
export const executeTransactions = (instanceIndex: number, lookupOnly: boolean, funcABI: FuncABI, inputsValues: string, contractName: string, contractABI, contract, address, logMsg:string, mainnetPrompt: MainnetPrompt, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, funcIndex?: number) => runTransactions(plugin, dispatch, instanceIndex, lookupOnly, funcABI, inputsValues, contractName, contractABI, contract, address, logMsg, mainnetPrompt, gasEstimationPrompt, passphrasePrompt, funcIndex)
export const executeTransactions = (instanceIndex: number, isSavedContract: boolean, lookupOnly: boolean, funcABI: FuncABI, inputsValues: string, contractName: string, contractABI, contract, address, logMsg:string, mainnetPrompt: MainnetPrompt, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, funcIndex?: number) => runTransactions(plugin, dispatch, instanceIndex, isSavedContract, lookupOnly, funcABI, inputsValues, contractName, contractABI, contract, address, logMsg, mainnetPrompt, gasEstimationPrompt, passphrasePrompt, funcIndex)
export const loadFromAddress = (contract: ContractData, address: string) => loadAddress(plugin, dispatch, contract, address)
export const storeNewScenario = async (prompt: (msg: string, defaultValue: string) => JSX.Element) => storeScenario(plugin, dispatch, prompt)
export const runScenario = (liveMode: boolean, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => runCurrentScenario(liveMode, plugin, dispatch, gasEstimationPrompt, passphrasePrompt, confirmDialogContent)

@ -250,13 +250,14 @@ export const clearAllInstances = () => {
}
}
export const setDecodedResponse = (instanceIndex: number, response, funcIndex?: number) => {
export const setDecodedResponse = (instanceIndex: number, response, funcIndex?: number, isSavedContract?: boolean) => {
return {
type: SET_DECODED_RESPONSE,
payload: {
instanceIndex,
funcIndex,
response
response,
isSavedContract
}
}
}

@ -96,6 +96,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
<UniversalDappUI
key={index}
instance={instance}
isSavedContract={false}
context={props.getContext()}
removeInstance={props.removeInstance}
index={index}

@ -145,6 +145,7 @@ export function UniversalDappUI(props: UdappProps) {
props.runTransactions(
props.index,
props.isSavedContract,
lookupOnly,
funcABI,
inputsValues,

@ -538,26 +538,29 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
}
case SET_DECODED_RESPONSE: {
const payload: { instanceIndex: number, funcIndex: number, response: any } = action.payload
return {
...state,
instances: {
...state.instances,
instanceList: state.instances.instanceList.map((instance, index) => {
console.log('indexxxxx=====>', index)
if (payload.instanceIndex === index) instance.decodedResponse[payload.funcIndex] = payload.response
return instance
})
},
savedInstances: {
...state.savedInstances,
instanceList: state.savedInstances.instanceList.map((instance, index) => {
console.log('indexxxxx==saved===>', index)
if (payload.instanceIndex === index) instance.decodedResponse[payload.funcIndex] = payload.response
return instance
})
const payload: { instanceIndex: number, funcIndex: number, response: any, isSavedContract: boolean } = action.payload
if (action.payload.isSavedContract)
return {
...state,
savedInstances: {
...state.savedInstances,
instanceList: state.savedInstances.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
})
}
}
}
}
case SET_PATH_TO_SCENARIO: {

@ -322,6 +322,7 @@ export interface InstanceContainerProps {
getContext: () => 'memory' | 'blockchain',
runTransactions: (
instanceIndex: number,
isSavedContract: boolean,
lookupOnly: boolean,
funcABI: FuncABI,
inputsValues: string,
@ -429,6 +430,7 @@ export interface UdappProps {
mainnetPrompt: (tx: Tx, network: Network, amount: string, gasEstimation: string, gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void, determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void) => JSX.Element,
runTransactions: (
instanceIndex: number,
isSavedContract: boolean,
lookupOnly: boolean,
funcABI: FuncABI,
inputsValues: string,

Loading…
Cancel
Save