-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support custom MUD system ABI (#2296)
* MUD system tab placeholder * implement MUD system selector and fix proxy contract read/write * rollback changes of target contract address
- Loading branch information
Showing
18 changed files
with
265 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
ui/address/contract/methods/ContractImplementationAddress.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Box } from '@chakra-ui/react'; | ||
import { useRouter } from 'next/router'; | ||
import React from 'react'; | ||
|
||
import type { SmartContractMudSystemItem } from 'types/api/contract'; | ||
|
||
import useApiQuery from 'lib/api/useApiQuery'; | ||
import getQueryParamString from 'lib/router/getQueryParamString'; | ||
|
||
import ContractConnectWallet from './ContractConnectWallet'; | ||
import ContractMethods from './ContractMethods'; | ||
import type { Item } from './ContractSourceAddressSelector'; | ||
import ContractSourceAddressSelector from './ContractSourceAddressSelector'; | ||
import { enrichWithMethodId, isMethod } from './utils'; | ||
|
||
interface Props { | ||
items: Array<SmartContractMudSystemItem>; | ||
} | ||
|
||
const ContractMethodsMudSystem = ({ items }: Props) => { | ||
|
||
const router = useRouter(); | ||
|
||
const addressHash = getQueryParamString(router.query.hash); | ||
const contractAddress = getQueryParamString(router.query.source_address); | ||
|
||
const [ selectedItem, setSelectedItem ] = React.useState(items.find((item) => item.address === contractAddress) || items[0]); | ||
|
||
const systemInfoQuery = useApiQuery('contract_mud_system_info', { | ||
pathParams: { hash: addressHash, system_address: selectedItem.address }, | ||
queryOptions: { | ||
enabled: Boolean(selectedItem?.address), | ||
refetchOnMount: false, | ||
}, | ||
}); | ||
|
||
const handleItemSelect = React.useCallback((item: Item) => { | ||
setSelectedItem(item as SmartContractMudSystemItem); | ||
}, []); | ||
|
||
if (items.length === 0) { | ||
return <span>No MUD System found for this contract.</span>; | ||
} | ||
|
||
const abi = systemInfoQuery.data?.abi?.filter(isMethod).map(enrichWithMethodId) || []; | ||
|
||
return ( | ||
<Box> | ||
<ContractConnectWallet/> | ||
<ContractSourceAddressSelector | ||
items={ items } | ||
selectedItem={ selectedItem } | ||
onItemSelect={ handleItemSelect } | ||
label="System address" | ||
/> | ||
<ContractMethods | ||
key={ selectedItem.address } | ||
abi={ abi } | ||
isLoading={ systemInfoQuery.isPending } | ||
isError={ systemInfoQuery.isError } | ||
sourceAddress={ selectedItem.address } | ||
type="all" | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default React.memo(ContractMethodsMudSystem); |
Oops, something went wrong.