show saved on

pull/4538/head
aniket-engg 9 months ago committed by Aniket
parent 71d25fb293
commit 4012a49b8e
  1. 2
      apps/remix-ide/src/app/tabs/locales/en/udapp.json
  2. 4
      apps/remix-ide/src/app/udapp/run-tab.js
  3. 2
      libs/remix-ui/run-tab/src/lib/actions/actions.ts
  4. 4
      libs/remix-ui/run-tab/src/lib/actions/events.ts
  5. 2
      libs/remix-ui/run-tab/src/lib/actions/payload.ts
  6. 2
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  7. 11
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  8. 3
      libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
  9. 9
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -73,6 +73,8 @@
"udapp.savedContracts": "Saved Contracts",
"udapp.NoSavedInstanceText": "Currently you have no saved contracts to interact with.",
"udapp.tooltipTextUnsave": "Delete from saved list",
"udapp.savedOn": "Saved On",

@ -84,8 +84,8 @@ export class RunTab extends ViewPlugin {
this.emit('addInstanceReducer', address, abi, name)
}
addSavedInstance(address, abi, name) {
this.emit('addSavedInstanceReducer', address, abi, name)
addSavedInstance(address, abi, name, savedOn) {
this.emit('addSavedInstanceReducer', address, abi, name, savedOn)
}
createVMAccount(newAccount) {

@ -70,7 +70,7 @@ export const addInstance = (dispatch: React.Dispatch<any>, instance: { contractD
dispatch(addNewInstance(instance))
}
export const addSavedInstance = (dispatch: React.Dispatch<any>, instance: { contractData?: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record<number, any> }) => {
export const addSavedInstance = (dispatch: React.Dispatch<any>, instance: { contractData?: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record<number, any>, savedOn?: number }) => {
instance.decodedResponse = {}
dispatch(addNewSavedInstance(instance))
}

@ -83,8 +83,8 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => {
addInstance(dispatch, { abi, address, name })
})
plugin.on('udapp', 'addSavedInstanceReducer', (address, abi, name) => {
addSavedInstance(dispatch, { abi, address, name })
plugin.on('udapp', 'addSavedInstanceReducer', (address, abi, name, savedOn) => {
addSavedInstance(dispatch, { abi, address, name, savedOn })
})
plugin.on('filePanel', 'setWorkspace', () => {

@ -230,7 +230,7 @@ export const addNewInstance = (instance: { contractData?: ContractData, address:
}
}
export const addNewSavedInstance = (instance: { contractData?: ContractData, address: string, name: string, abi?: any }) => {
export const addNewSavedInstance = (instance: { contractData?: ContractData, address: string, name: string, abi?: any, savedOn?: number }) => {
return {
type: ADD_SAVED_INSTANCE,
payload: instance

@ -19,7 +19,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
if (savedContracts[env] && savedContracts[env][network.id]) {
const instances = savedContracts[env][network.id]
for (const inst of instances)
if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name)
if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name, inst.savedOn)
}
}
}

@ -52,6 +52,7 @@ export function UniversalDappUI(props: UdappProps) {
}, [props.instance.contractData])
useEffect(() => {
console.log('props====>', props)
if (props.instance.balance) {
setInstanceBalance(props.instance.balance)
}
@ -142,10 +143,11 @@ export function UniversalDappUI(props: UdappProps) {
objToSave[env][network.id] = []
}
}
props.instance.savedOn = Date.now()
objToSave[env][network.id].push(props.instance)
localStorage.setItem('savedContracts', JSON.stringify(objToSave))
// Add contract to saved contracts list on UI
await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.contractData.abi, props.instance.name)
await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.contractData.abi, props.instance.name, props.instance.savedOn)
// Remove contract from deployed contracts list on UI
props.removeInstance(props.index, false)
}
@ -288,6 +290,13 @@ export function UniversalDappUI(props: UdappProps) {
<FormattedMessage id="udapp.balance" />: {instanceBalance} ETH
</label>
</div>
{ props.isSavedContract && props.instance.savedOn ? (
<div className="d-flex" data-id="instanceContractSavedOn">
<label>
<FormattedMessage id="udapp.savedOn" />: {(new Date(props.instance.savedOn)).toUTCString()}
</label>
</div>
) : null }
{contractABI &&
contractABI.map((funcABI, index) => {
if (funcABI.type !== 'function') return null

@ -492,8 +492,7 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
}
case ADD_SAVED_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, savedOn: number, decodedResponse?: Record<number, any> } = action.payload
return {
...state,
savedInstances: {

@ -103,7 +103,8 @@ export interface RunTabState {
balance?: number,
name: string,
decodedResponse?: Record<number, any>,
abi?: any
abi?: any,
savedOn?: number
}[],
error: string
},
@ -313,7 +314,8 @@ export interface InstanceContainerProps {
balance?: number,
name: string,
decodedResponse?: Record<number, any>,
abi?: any
abi?: any,
savedOn?: number
}[],
error: string
},
@ -419,7 +421,8 @@ export interface UdappProps {
balance?: number,
name: string,
decodedResponse?: Record<number, any>,
abi?: any
abi?: any,
savedOn?: number
},
context: 'memory' | 'blockchain',
isSavedContract?: boolean

Loading…
Cancel
Save