-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add abi json for verified contracts (#320)
# What ❔ Display the contract's ABI JSON if it's verified ## Why ❔ This addresses #242 and allows users to easily copy/paste the ABI for easier development ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. ## Evidence Verified contract with a small ABI: ![image](https://github.com/user-attachments/assets/cb69aeaf-b905-4ec1-bd73-4c9642288ef4) Verified contract with a large ABI (Closed & Expanded): ![image](https://github.com/user-attachments/assets/694824b3-3c59-4df7-9e38-9d0af0067676) ![image](https://github.com/user-attachments/assets/7b161062-1c45-45f4-8ab9-def76b312b46) Unverified contract: ![image](https://github.com/user-attachments/assets/dba0dfa2-46fa-47cb-84ba-8e6cc0f0418b) --------- Co-authored-by: Roman Petriv <[email protected]>
- Loading branch information
1 parent
517ffd8
commit 9dca4b2
Showing
6 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
packages/app/src/components/common/table/fields/AbiData.vue
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,63 @@ | ||
<template> | ||
<div class="info-field-abi-data"> | ||
<Disclosure v-slot="{ open }"> | ||
<DisclosureButton | ||
class="abi-data-disclosure-btn" | ||
:class="open ? 'rounded-tl-lg rounded-tr-lg' : 'rounded-lg'" | ||
:data-testid="$testId.abiDataDropDown" | ||
> | ||
{{ truncatedAbi }} | ||
|
||
<div class="abi-data-disclosure-icons"> | ||
<CopyButton class="mr-1" tooltipPosition="left" :value="value" /> | ||
<ChevronDownIcon | ||
:class="open ? 'rotate-180 transform' : ''" | ||
class="h-5 w-5 text-gray-500 transition-transform" | ||
/> | ||
</div> | ||
</DisclosureButton> | ||
<DisclosurePanel class="abi-data-disclosure-panel"> | ||
<div class="abi-data-full-value">{{ value }}</div> | ||
</DisclosurePanel> | ||
</Disclosure> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed } from "vue"; | ||
import { Disclosure, DisclosureButton, DisclosurePanel } from "@headlessui/vue"; | ||
import { ChevronDownIcon } from "@heroicons/vue/solid"; | ||
import CopyButton from "@/components/common/CopyButton.vue"; | ||
const props = defineProps({ | ||
value: { | ||
type: String, | ||
default: "", | ||
required: true, | ||
}, | ||
}); | ||
const truncatedAbi = computed<string>(() => { | ||
return props.value.replace(/(.{600})..+/, "$1..."); | ||
}); | ||
</script> | ||
|
||
<style lang="scss"> | ||
.info-field-abi-data { | ||
.abi-data-disclosure-btn { | ||
@apply flex w-full items-center justify-between bg-gray-200 px-4 py-2 text-left text-sm font-medium text-gray-900 hover:bg-gray-200 focus:outline-none; | ||
} | ||
.abi-data-disclosure-icons { | ||
@apply flex items-center; | ||
} | ||
.abi-data-disclosure-panel { | ||
@apply rounded-bl-lg rounded-br-lg border border-t-0 border-dashed border-gray-300 px-4 py-4; | ||
.abi-data-full-value { | ||
@apply overflow-hidden whitespace-pre-line break-words break-all text-sm text-gray-700; | ||
} | ||
} | ||
} | ||
</style> |
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