-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0e0c35
commit 37ed21a
Showing
27 changed files
with
928 additions
and
344 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
export default defineAppConfig({ | ||
// ui: { | ||
// notifications: { | ||
// // Show toasts at the top right of the screen | ||
// position: 'top-0 end-0', | ||
// } | ||
// } | ||
}) |
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script setup lang="ts"> | ||
import type { DisplayContent, ResultFontSize } from './DisplayTxResult.vue' | ||
defineProps<{ | ||
values: DisplayContent[] | ||
size: ResultFontSize | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-y-1"> | ||
{{ values.length ? 'array' : '[]' }} | ||
<ObjectFieldDisplay | ||
v-for="(value, key) in values" | ||
:key="key" :name="`[${key}]`" :value="value" :size="size" | ||
/> | ||
</div> | ||
</template> |
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,51 @@ | ||
<script setup lang="ts"> | ||
import type { ContractName } from '~/utils/scaffold-eth/contract' | ||
const props = defineProps<{ | ||
contractName: ContractName | ||
}>() | ||
const { targetNetwork } = useTargetNetwork() | ||
const networkColor = useNetworkColor() | ||
const { data: deployedContractData, isLoading: deployedContractDataLoading } = useDeployedContractInfo(props.contractName) | ||
</script> | ||
|
||
<template> | ||
<div v-if="deployedContractDataLoading" class="mt-14"> | ||
<span class="loading loading-spinner loading-lg" /> | ||
</div> | ||
<p v-else-if="!deployedContractData" class="text-3xl mt-14"> | ||
{{ `No contract found by the name of "${contractName}" on chain "${targetNetwork.name}"!` }} | ||
</p> | ||
<div v-else class="grid grid-cols-1 lg:grid-cols-6 px-6 lg:px-10 lg:gap-12 w-full max-w-7xl my-0"> | ||
<div class="col-span-5 grid grid-cols-1 lg:grid-cols-3 gap-8 lg:gap-10"> | ||
<div class="col-span-1 flex flex-col"> | ||
<div class="bg-base-100 border-base-300 border shadow-md shadow-secondary rounded-3xl px-6 lg:px-8 mb-6 space-y-1 py-4"> | ||
<div class="flex"> | ||
<div class="flex flex-col gap-1"> | ||
<span class="font-bold">{{ contractName }}</span> | ||
<Address :address="deployedContractData.address" /> | ||
<div class="flex gap-1 items-center"> | ||
<span class="font-bold text-sm">Balance:</span> | ||
<Balance | ||
:address="deployedContractData.address" | ||
class="px-0 h-1.5 max-height-[0.375rem]" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<p v-if="targetNetwork" class="my-0 text-sm gap-1 flex"> | ||
<span class="font-bold">network:</span> | ||
<span :style="{ color: networkColor }">{{ targetNetwork.name }}</span> | ||
</p> | ||
</div> | ||
<div class="bg-base-300 rounded-3xl px-6 lg:px-8 py-4 shadow-lg shadow-base-300"> | ||
<ContractVariables | ||
:refresh-display-variables="true" | ||
:deployed-contract-data="deployedContractData" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
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,35 @@ | ||
<script setup lang="ts"> | ||
import type { Abi, AbiFunction } from 'viem' | ||
import type { Contract, ContractName, GenericContract, InheritedFunctions } from '~/utils/scaffold-eth/contract' | ||
const props = defineProps<{ | ||
refreshDisplayVariables: boolean | ||
deployedContractData: Contract<ContractName> | ||
}>() | ||
const functionsToData = computed(() => { | ||
return ((props.deployedContractData.abi as Abi).filter(part => part.type === 'function') as AbiFunction[]) | ||
.filter(fn => (fn.stateMutability === 'view' || fn.stateMutability === 'pure') && fn.inputs.length === 0) | ||
.map(fn => ({ | ||
fn, | ||
inheritedFrom: ((props.deployedContractData as GenericContract)?.inheritedFunctions as InheritedFunctions)?.[fn.name], | ||
})) | ||
.sort((a, b) => b.inheritedFrom ? b.inheritedFrom.localeCompare(a.inheritedFrom) : 1) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div v-if="!functionsToData.length"> | ||
No contract variables | ||
</div> | ||
<DisplayVariable | ||
v-for="{ fn, inheritedFrom } in functionsToData" | ||
v-else | ||
:key="fn.name" | ||
:abi-function="fn" | ||
:abi="deployedContractData.abi" | ||
:contract-address="deployedContractData.address" | ||
:refresh-display-variables="refreshDisplayVariables" | ||
:inherited-form="inheritedFrom" | ||
/> | ||
</template> |
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,60 @@ | ||
<script setup lang="tsx"> | ||
import { type TransactionBase, type TransactionReceipt, isAddress, isHex } from 'viem' | ||
import Address from '../Address.vue' | ||
import NumberDisplay from './NumberDisplay.vue' | ||
import ArrayDisplay from './ArrayDisplay.vue' | ||
import StructDisplay from './StructDisplay.vue' | ||
import { replacer } from '~/utils/scaffold-eth/common' | ||
export type DisplayContent = | ||
| string | ||
| number | ||
| bigint | ||
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | ||
| Record<string, any> | ||
| TransactionBase | ||
| TransactionReceipt | ||
| undefined | ||
| unknown | ||
export type ResultFontSize = 'sm' | 'base' | 'xs' | 'lg' | 'xl' | '2xl' | '3xl' | ||
const props = withDefaults( | ||
defineProps<{ | ||
displayContent: DisplayContent | DisplayContent[] | ||
fontSize: ResultFontSize | ||
}>(), | ||
{ | ||
fontSize: 'base', | ||
}, | ||
) | ||
function Display() { | ||
if (props.displayContent == null) { | ||
return '' | ||
} | ||
if (typeof props.displayContent === 'bigint') { | ||
return <NumberDisplay value={props.displayContent} /> | ||
} | ||
if (typeof props.displayContent === 'string') { | ||
if (isAddress(props.displayContent)) { | ||
return <Address address={props.displayContent} size={props.fontSize} /> | ||
} | ||
if (isHex(props.displayContent)) { | ||
return props.displayContent | ||
} | ||
} | ||
if (Array.isArray(props.displayContent)) { | ||
return <ArrayDisplay values={props.displayContent} size={props.fontSize} /> | ||
} | ||
if (typeof props.displayContent === 'object') { | ||
return <StructDisplay struct={props.displayContent} size={props.fontSize} /> | ||
} | ||
return JSON.stringify(props.displayContent, replacer, 2) | ||
} | ||
</script> | ||
|
||
<template> | ||
<Display /> | ||
</template> |
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,71 @@ | ||
<script setup lang="ts"> | ||
import type { Abi, AbiFunction, Address } from 'viem' | ||
// TODO autoimport https://github.com/wevm/wagmi/issues/3977 | ||
import { useReadContract } from '@wagmi/vue' | ||
import { useToast } from 'vue-toastification' | ||
import { notification } from './nitification' | ||
import { getParsedError } from '~/utils/scaffold-eth/getParseError' | ||
interface DisplayVariableProps { | ||
contractAddress: Address | ||
abiFunction: AbiFunction | ||
refreshDisplayVariables: boolean | ||
inheritedForm?: string | ||
abi: Abi | ||
} | ||
const props = defineProps<DisplayVariableProps>() | ||
const { targetNetwork } = useTargetNetwork() | ||
const { data: result, isFetching, refetch, error } = useReadContract({ | ||
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | ||
address: props.contractAddress as any, | ||
functionName: props.abiFunction.name, | ||
abi: props.abi, | ||
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | ||
chainId: targetNetwork.value.id as any, | ||
query: { | ||
retry: false, | ||
}, | ||
}) | ||
const { showAnimation } = useAnimationConfig(result) | ||
watch(() => props.refreshDisplayVariables, () => { | ||
refetch() | ||
}) | ||
watch(error, () => { | ||
if (error.value) { | ||
const parsedError = getParsedError(error) | ||
notification.error(parsedError) | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<!-- <Toast /> --> | ||
<div class="space-y-1 pb-2"> | ||
<div class="flex items-center"> | ||
<h3 class="font-medium text-lg mb-0 break-all"> | ||
{{ abiFunction.name }} | ||
</h3> | ||
<button class="btn btn-ghost btn-xs"> | ||
<span v-if="isFetching" class="loading loading-spinner loading-xs" /> | ||
<Icon v-else name="i-uil-sync" class="h-3 w-3 cursor-pointer" aria-hidden="true" /> | ||
</button> | ||
<InheritanceTooltip :inherited-form /> | ||
</div> | ||
<div class="text-gray-500 font-medium flex flex-col items-start"> | ||
<div> | ||
<div | ||
class=" break-all block transition bg-transparent" | ||
:class="[showAnimation ? 'bg-warning rounded-sm animate-pulse-fast' : '']" | ||
> | ||
<DisplayTxResult :display-content="result" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
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,14 @@ | ||
<script setup lang="ts"> | ||
defineProps<{ | ||
inheritedForm?: string | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<span | ||
class="tooltip tooltip-top tooltip-accent px-2 md:break-normal" | ||
:data-tip="`Inherited from: ${inheritedForm}`" | ||
> | ||
<Icon name="i-uil-exclamation-circle" class="w-4 h-4" /> | ||
</span> | ||
</template> |
Oops, something went wrong.