From db7a55854a3043b1cc38a89b39c22d31cf1b1583 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Dec 2021 21:35:39 +0000 Subject: [PATCH 1/7] Bump chart.js from 3.6.0 to 3.6.2 (#135) --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4e34a5..f73fd32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "@types/react-dom": "^17.0.11", "@types/react-highlight": "^0.12.5", "@types/react-syntax-highlighter": "^13.5.2", - "chart.js": "^3.6.0", + "chart.js": "^3.6.2", "ethers": "^5.5.1", "highlightjs-solidity": "^2.0.2", "react": "^17.0.2", @@ -5558,9 +5558,9 @@ } }, "node_modules/chart.js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.0.tgz", - "integrity": "sha512-iOzzDKePL+bj+ccIsVAgWQehCXv8xOKGbaU2fO/myivH736zcx535PGJzQGanvcSGVOqX6yuLZsN3ygcQ35UgQ==" + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.2.tgz", + "integrity": "sha512-Xz7f/fgtVltfQYWq0zL1Xbv7N2inpG+B54p3D5FSvpCdy3sM+oZhbqa42eNuYXltaVvajgX5UpKCU2GeeJIgxg==" }, "node_modules/check-types": { "version": "11.1.2", @@ -23135,9 +23135,9 @@ "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==" }, "chart.js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.0.tgz", - "integrity": "sha512-iOzzDKePL+bj+ccIsVAgWQehCXv8xOKGbaU2fO/myivH736zcx535PGJzQGanvcSGVOqX6yuLZsN3ygcQ35UgQ==" + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.2.tgz", + "integrity": "sha512-Xz7f/fgtVltfQYWq0zL1Xbv7N2inpG+B54p3D5FSvpCdy3sM+oZhbqa42eNuYXltaVvajgX5UpKCU2GeeJIgxg==" }, "check-types": { "version": "11.1.2" diff --git a/package.json b/package.json index 5bce984..34aacfd 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@types/react-dom": "^17.0.11", "@types/react-highlight": "^0.12.5", "@types/react-syntax-highlighter": "^13.5.2", - "chart.js": "^3.6.0", + "chart.js": "^3.6.2", "ethers": "^5.5.1", "highlightjs-solidity": "^2.0.2", "react": "^17.0.2", From 59fe3476c29f2e025c18ffdd0e7844cb01b59600 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Dec 2021 21:36:57 +0000 Subject: [PATCH 2/7] Bump @testing-library/jest-dom from 5.15.1 to 5.16.1 (#134) --- package-lock.json | 31 ++++++++++++++++++++++--------- package.json | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index f73fd32..5babcb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@fortawesome/free-solid-svg-icons": "^5.15.4", "@fortawesome/react-fontawesome": "^0.1.16", "@headlessui/react": "^1.4.2", - "@testing-library/jest-dom": "^5.15.1", + "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.24", @@ -2867,13 +2867,13 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "5.15.1", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.15.1.tgz", - "integrity": "sha512-kmj8opVDRE1E4GXyLlESsQthCXK7An28dFWxhiMwD7ZUI7ZxA6sjdJRxLerD9Jd8cHX4BDc1jzXaaZKqzlUkvg==", + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.16.1.tgz", + "integrity": "sha512-ajUJdfDIuTCadB79ukO+0l8O+QwN0LiSxDaYUTI4LndbbUsGi6rWU1SCexXzBA2NSjlVB9/vbkasQIL3tmPBjw==", "dependencies": { "@babel/runtime": "^7.9.2", "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^4.2.2", + "aria-query": "^5.0.0", "chalk": "^3.0.0", "css": "^3.0.0", "css.escape": "^1.5.1", @@ -2897,6 +2897,14 @@ "node": ">=6.9.0" } }, + "node_modules/@testing-library/jest-dom/node_modules/aria-query": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz", + "integrity": "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==", + "engines": { + "node": ">=6.0" + } + }, "node_modules/@testing-library/jest-dom/node_modules/chalk": { "version": "3.0.0", "license": "MIT", @@ -21248,13 +21256,13 @@ } }, "@testing-library/jest-dom": { - "version": "5.15.1", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.15.1.tgz", - "integrity": "sha512-kmj8opVDRE1E4GXyLlESsQthCXK7An28dFWxhiMwD7ZUI7ZxA6sjdJRxLerD9Jd8cHX4BDc1jzXaaZKqzlUkvg==", + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.16.1.tgz", + "integrity": "sha512-ajUJdfDIuTCadB79ukO+0l8O+QwN0LiSxDaYUTI4LndbbUsGi6rWU1SCexXzBA2NSjlVB9/vbkasQIL3tmPBjw==", "requires": { "@babel/runtime": "^7.9.2", "@types/testing-library__jest-dom": "^5.9.1", - "aria-query": "^4.2.2", + "aria-query": "^5.0.0", "chalk": "^3.0.0", "css": "^3.0.0", "css.escape": "^1.5.1", @@ -21269,6 +21277,11 @@ "regenerator-runtime": "^0.13.4" } }, + "aria-query": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz", + "integrity": "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==" + }, "chalk": { "version": "3.0.0", "requires": { diff --git a/package.json b/package.json index 34aacfd..105bb11 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@fortawesome/free-solid-svg-icons": "^5.15.4", "@fortawesome/react-fontawesome": "^0.1.16", "@headlessui/react": "^1.4.2", - "@testing-library/jest-dom": "^5.15.1", + "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.24", From 8b33337e4974a89faab245edb82c8c20e192f6c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Dec 2021 21:39:36 +0000 Subject: [PATCH 3/7] Bump ethers from 5.5.1 to 5.5.2 (#131) --- package-lock.json | 62 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5babcb8..d24cbe1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "@types/react-highlight": "^0.12.5", "@types/react-syntax-highlighter": "^13.5.2", "chart.js": "^3.6.2", - "ethers": "^5.5.1", + "ethers": "^5.5.2", "highlightjs-solidity": "^2.0.2", "react": "^17.0.2", "react-blockies": "^1.4.1", @@ -1672,9 +1672,9 @@ ] }, "node_modules/@ethersproject/networks": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.5.0.tgz", - "integrity": "sha512-KWfP3xOnJeF89Uf/FCJdV1a2aDJe5XTN2N52p4fcQ34QhDqQFkgQKZ39VGtiqUgHcLI8DfT0l9azC3KFTunqtA==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.5.1.tgz", + "integrity": "sha512-tYRDM4zZtSUcKnD4UMuAlj7SeXH/k5WC4SP2u1Pn57++JdXHkRu2zwNkgNogZoxHzhm9Q6qqurDBVptHOsW49Q==", "funding": [ { "type": "individual", @@ -1727,9 +1727,9 @@ } }, "node_modules/@ethersproject/providers": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.5.0.tgz", - "integrity": "sha512-xqMbDnS/FPy+J/9mBLKddzyLLAQFjrVff5g00efqxPzcAwXiR+SiCGVy6eJ5iAIirBOATjx7QLhDNPGV+AEQsw==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.5.1.tgz", + "integrity": "sha512-2zdD5sltACDWhjUE12Kucg2PcgM6V2q9JMyVvObtVGnzJu+QSmibbP+BHQyLWZUBfLApx2942+7DC5D+n4wBQQ==", "funding": [ { "type": "individual", @@ -1985,9 +1985,9 @@ } }, "node_modules/@ethersproject/web": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.5.0.tgz", - "integrity": "sha512-BEgY0eL5oH4mAo37TNYVrFeHsIXLRxggCRG/ksRIxI2X5uj5IsjGmcNiRN/VirQOlBxcUhCgHhaDLG4m6XAVoA==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.5.1.tgz", + "integrity": "sha512-olvLvc1CB12sREc1ROPSHTdFCdvMh0J5GSJYiQg2D0hdD4QmJDy8QYDb1CvoqD/bF1c++aeKv2sR5uduuG9dQg==", "funding": [ { "type": "individual", @@ -8082,9 +8082,9 @@ } }, "node_modules/ethers": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.5.1.tgz", - "integrity": "sha512-RodEvUFZI+EmFcE6bwkuJqpCYHazdzeR1nMzg+YWQSmQEsNtfl1KHGfp/FWZYl48bI/g7cgBeP2IlPthjiVngw==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.5.2.tgz", + "integrity": "sha512-EF5W+6Wwcu6BqVwpgmyR5U2+L4c1FQzlM/02dkZOugN3KF0cG9bzHZP+TDJglmPm2/IzCEJDT7KBxzayk7SAHw==", "funding": [ { "type": "individual", @@ -8111,10 +8111,10 @@ "@ethersproject/json-wallets": "5.5.0", "@ethersproject/keccak256": "5.5.0", "@ethersproject/logger": "5.5.0", - "@ethersproject/networks": "5.5.0", + "@ethersproject/networks": "5.5.1", "@ethersproject/pbkdf2": "5.5.0", "@ethersproject/properties": "5.5.0", - "@ethersproject/providers": "5.5.0", + "@ethersproject/providers": "5.5.1", "@ethersproject/random": "5.5.0", "@ethersproject/rlp": "5.5.0", "@ethersproject/sha2": "5.5.0", @@ -8124,7 +8124,7 @@ "@ethersproject/transactions": "5.5.0", "@ethersproject/units": "5.5.0", "@ethersproject/wallet": "5.5.0", - "@ethersproject/web": "5.5.0", + "@ethersproject/web": "5.5.1", "@ethersproject/wordlists": "5.5.0" } }, @@ -20541,9 +20541,9 @@ "integrity": "sha512-rIY/6WPm7T8n3qS2vuHTUBPdXHl+rGxWxW5okDfo9J4Z0+gRRZT0msvUdIJkE4/HS29GUMziwGaaKO2bWONBrg==" }, "@ethersproject/networks": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.5.0.tgz", - "integrity": "sha512-KWfP3xOnJeF89Uf/FCJdV1a2aDJe5XTN2N52p4fcQ34QhDqQFkgQKZ39VGtiqUgHcLI8DfT0l9azC3KFTunqtA==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.5.1.tgz", + "integrity": "sha512-tYRDM4zZtSUcKnD4UMuAlj7SeXH/k5WC4SP2u1Pn57++JdXHkRu2zwNkgNogZoxHzhm9Q6qqurDBVptHOsW49Q==", "requires": { "@ethersproject/logger": "^5.5.0" } @@ -20566,9 +20566,9 @@ } }, "@ethersproject/providers": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.5.0.tgz", - "integrity": "sha512-xqMbDnS/FPy+J/9mBLKddzyLLAQFjrVff5g00efqxPzcAwXiR+SiCGVy6eJ5iAIirBOATjx7QLhDNPGV+AEQsw==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.5.1.tgz", + "integrity": "sha512-2zdD5sltACDWhjUE12Kucg2PcgM6V2q9JMyVvObtVGnzJu+QSmibbP+BHQyLWZUBfLApx2942+7DC5D+n4wBQQ==", "requires": { "@ethersproject/abstract-provider": "^5.5.0", "@ethersproject/abstract-signer": "^5.5.0", @@ -20712,9 +20712,9 @@ } }, "@ethersproject/web": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.5.0.tgz", - "integrity": "sha512-BEgY0eL5oH4mAo37TNYVrFeHsIXLRxggCRG/ksRIxI2X5uj5IsjGmcNiRN/VirQOlBxcUhCgHhaDLG4m6XAVoA==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.5.1.tgz", + "integrity": "sha512-olvLvc1CB12sREc1ROPSHTdFCdvMh0J5GSJYiQg2D0hdD4QmJDy8QYDb1CvoqD/bF1c++aeKv2sR5uduuG9dQg==", "requires": { "@ethersproject/base64": "^5.5.0", "@ethersproject/bytes": "^5.5.0", @@ -24808,9 +24808,9 @@ "version": "1.8.1" }, "ethers": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.5.1.tgz", - "integrity": "sha512-RodEvUFZI+EmFcE6bwkuJqpCYHazdzeR1nMzg+YWQSmQEsNtfl1KHGfp/FWZYl48bI/g7cgBeP2IlPthjiVngw==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.5.2.tgz", + "integrity": "sha512-EF5W+6Wwcu6BqVwpgmyR5U2+L4c1FQzlM/02dkZOugN3KF0cG9bzHZP+TDJglmPm2/IzCEJDT7KBxzayk7SAHw==", "requires": { "@ethersproject/abi": "5.5.0", "@ethersproject/abstract-provider": "5.5.1", @@ -24827,10 +24827,10 @@ "@ethersproject/json-wallets": "5.5.0", "@ethersproject/keccak256": "5.5.0", "@ethersproject/logger": "5.5.0", - "@ethersproject/networks": "5.5.0", + "@ethersproject/networks": "5.5.1", "@ethersproject/pbkdf2": "5.5.0", "@ethersproject/properties": "5.5.0", - "@ethersproject/providers": "5.5.0", + "@ethersproject/providers": "5.5.1", "@ethersproject/random": "5.5.0", "@ethersproject/rlp": "5.5.0", "@ethersproject/sha2": "5.5.0", @@ -24840,7 +24840,7 @@ "@ethersproject/transactions": "5.5.0", "@ethersproject/units": "5.5.0", "@ethersproject/wallet": "5.5.0", - "@ethersproject/web": "5.5.0", + "@ethersproject/web": "5.5.1", "@ethersproject/wordlists": "5.5.0" } }, diff --git a/package.json b/package.json index 105bb11..e9e3b77 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@types/react-highlight": "^0.12.5", "@types/react-syntax-highlighter": "^13.5.2", "chart.js": "^3.6.2", - "ethers": "^5.5.1", + "ethers": "^5.5.2", "highlightjs-solidity": "^2.0.2", "react": "^17.0.2", "react-blockies": "^1.4.1", From 0754c4f4bfbe1086b405f004659e9a3666942aea Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sun, 12 Dec 2021 23:32:30 -0300 Subject: [PATCH 4/7] Add failed tx error msg support; depends on ots_getTransactionError custom API --- src/params.ts | 2 +- src/transaction/Details.tsx | 17 ++++++++++++++--- src/useErigonHooks.ts | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/params.ts b/src/params.ts index 7ac916a..d1464c6 100644 --- a/src/params.ts +++ b/src/params.ts @@ -1,3 +1,3 @@ -export const MIN_API_LEVEL = 4; +export const MIN_API_LEVEL = 5; export const PAGE_SIZE = 25; diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index e4daf2f..36141ca 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -41,6 +41,7 @@ import { DevDoc, UserDoc } from "../sourcify/useSourcify"; import { ResolvedAddresses } from "../api/address-resolver"; import { RuntimeContext } from "../useRuntime"; import { useContractsMetadata } from "../hooks"; +import { useTransactionError } from "../useErigonHooks"; type DetailsProps = { txData: TransactionData; @@ -96,6 +97,7 @@ const Details: React.FC = ({ return _addresses; }, [txData]); const metadatas = useContractsMetadata(addresses, provider); + const errorMsg = useTransactionError(provider, txData.transactionHash); return ( @@ -114,10 +116,19 @@ const Details: React.FC = ({ Success ) : ( - +
- Fail - + + Fail + {errorMsg && ( + <> + {" "} + with revert message: ' + {errorMsg}' + + )} + +
)} {txData.confirmedData && ( diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 30effa2..324adc7 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -3,6 +3,7 @@ import { Block, BlockWithTransactions } from "@ethersproject/abstract-provider"; import { JsonRpcProvider } from "@ethersproject/providers"; import { getAddress } from "@ethersproject/address"; import { Contract } from "@ethersproject/contracts"; +import { defaultAbiCoder } from "@ethersproject/abi"; import { BigNumber } from "@ethersproject/bignumber"; import { arrayify, hexDataSlice, isHexString } from "@ethersproject/bytes"; import { extract4Bytes } from "./use4Bytes"; @@ -484,3 +485,37 @@ export const useAddressesWithCode = ( return results; }; + +export const useTransactionError = ( + provider: JsonRpcProvider | undefined, + txHash: string +): string | undefined => { + const [errorMsg, setErrorMsg] = useState(); + + useEffect(() => { + // Reset + setErrorMsg(undefined); + + if (provider === undefined) { + return; + } + + const readCodes = async () => { + const result = (await provider.send("ots_getTransactionError", [ + txHash, + ])) as string; + + // Filter hardcoded Error(string) selector because ethers don't let us + // construct it + if (result.substr(0, 10) !== "0x08c379a0") { + return; + } + + const msg = defaultAbiCoder.decode(["string"], "0x" + result.substr(10)); + setErrorMsg(msg[0]); + }; + readCodes(); + }, [provider, txHash]); + + return errorMsg; +}; From d5fa5dda36e4410d10dcea12b489180141a8a1bb Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 13 Dec 2021 15:11:34 -0300 Subject: [PATCH 5/7] Small refactorings; no semantic changes --- src/useErigonHooks.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 324adc7..ff70e38 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -486,6 +486,9 @@ export const useAddressesWithCode = ( return results; }; +// Error(string) +const ERROR_MESSAGE_SELECTOR = "0x08c379a0"; + export const useTransactionError = ( provider: JsonRpcProvider | undefined, txHash: string @@ -505,14 +508,22 @@ export const useTransactionError = ( txHash, ])) as string; - // Filter hardcoded Error(string) selector because ethers don't let us - // construct it - if (result.substr(0, 10) !== "0x08c379a0") { + // Empty or success + if (result === "0x") { return; } - const msg = defaultAbiCoder.decode(["string"], "0x" + result.substr(10)); - setErrorMsg(msg[0]); + // Filter hardcoded Error(string) selector because ethers don't let us + // construct it + const selector = result.substr(0, 10); + if (selector === ERROR_MESSAGE_SELECTOR) { + const msg = defaultAbiCoder.decode( + ["string"], + "0x" + result.substr(10) + ); + setErrorMsg(msg[0]); + return; + } }; readCodes(); }, [provider, txHash]); From f22199d7d5d39b6982e2ed33aef0c6c851640c7f Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 13 Dec 2021 15:41:37 -0300 Subject: [PATCH 6/7] Add basic structure for custom errors --- src/components/ExpanderSwitch.tsx | 22 ++++++++ src/transaction/Details.tsx | 90 +++++++++++++++++++++++++------ src/transaction/TraceInput.tsx | 17 ++---- src/useErigonHooks.ts | 17 +++++- 4 files changed, 116 insertions(+), 30 deletions(-) create mode 100644 src/components/ExpanderSwitch.tsx diff --git a/src/components/ExpanderSwitch.tsx b/src/components/ExpanderSwitch.tsx new file mode 100644 index 0000000..71292db --- /dev/null +++ b/src/components/ExpanderSwitch.tsx @@ -0,0 +1,22 @@ +import React from "react"; +import { Switch } from "@headlessui/react"; + +type ExpanderSwitchProps = { + expanded: boolean; + setExpanded: React.Dispatch>; +}; + +const ExpanderSwitch: React.FC = ({ + expanded, + setExpanded, +}) => ( + + {expanded ? [-] : <>[...]} + +); + +export default ExpanderSwitch; diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 36141ca..ca21ea4 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -1,4 +1,5 @@ -import React, { useContext, useMemo } from "react"; +import React, { useContext, useMemo, useState } from "react"; +import { Tab } from "@headlessui/react"; import { TransactionDescription } from "@ethersproject/abi"; import { BigNumber } from "@ethersproject/bignumber"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -8,6 +9,8 @@ import { faTimesCircle } from "@fortawesome/free-solid-svg-icons/faTimesCircle"; import ContentFrame from "../ContentFrame"; import InfoRow from "../components/InfoRow"; import BlockLink from "../components/BlockLink"; +import ModeTab from "../components/ModeTab"; +import ExpanderSwitch from "../components/ExpanderSwitch"; import BlockConfirmations from "../components/BlockConfirmations"; import TransactionAddress from "../components/TransactionAddress"; import Copy from "../components/Copy"; @@ -97,7 +100,11 @@ const Details: React.FC = ({ return _addresses; }, [txData]); const metadatas = useContractsMetadata(addresses, provider); - const errorMsg = useTransactionError(provider, txData.transactionHash); + const [errorMsg, outputData, isCustomError] = useTransactionError( + provider, + txData.transactionHash + ); + const [expanded, setExpanded] = useState(false); return ( @@ -111,24 +118,75 @@ const Details: React.FC = ({ {txData.confirmedData === undefined ? ( Pending ) : txData.confirmedData.status ? ( - - + + Success ) : ( -
- - - Fail - {errorMsg && ( - <> - {" "} - with revert message: ' - {errorMsg}' - + <> +
+
+ + + Fail + {errorMsg && ( + <> + {" "} + with revert message: ' + {errorMsg}' + + )} + {isCustomError && <> with custom error} + +
+ {isCustomError && ( + )} - -
+
+ {expanded && ( + + + Decoded + Raw + + + + {/* {fourBytes === "0x" ? ( + <>No parameters + ) : resolvedTxDesc === undefined ? ( + <>Waiting for data... + ) : resolvedTxDesc === null ? ( + <>Can't decode data + ) : ( + + )} */} + + +