From 50f13e6735575cf428988df15e2bce9efddbfe5d Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Thu, 14 Nov 2024 10:41:20 +1300 Subject: [PATCH 1/4] feat(package/rollups-wagmi): Add rollups-v2 contract dependency and added config to generate contracts with prefix. --- packages/rollups-wagmi/package.json | 2 + packages/rollups-wagmi/wagmi.config.ts | 31 ++++- yarn.lock | 179 +++++++++++++++++++++++++ 3 files changed, 211 insertions(+), 1 deletion(-) diff --git a/packages/rollups-wagmi/package.json b/packages/rollups-wagmi/package.json index ea128d442..da70756f6 100644 --- a/packages/rollups-wagmi/package.json +++ b/packages/rollups-wagmi/package.json @@ -30,6 +30,7 @@ }, "devDependencies": { "@cartesi/rollups": "^1.2.0", + "@cartesi/rollups-v2": "npm:@cartesi/rollups@2.0.0-rc.10", "@cartesi/tsconfig": "*", "@sunodo/wagmi-plugin-hardhat-deploy": "^0.3", "@types/react": "^18", @@ -39,6 +40,7 @@ "eslint-config-cartesi": "*", "react": "^18", "tsup": "^7", + "tsx": "^4.19.2", "typescript": "^5" }, "publishConfig": { diff --git a/packages/rollups-wagmi/wagmi.config.ts b/packages/rollups-wagmi/wagmi.config.ts index fc4bbe81f..b936a0390 100644 --- a/packages/rollups-wagmi/wagmi.config.ts +++ b/packages/rollups-wagmi/wagmi.config.ts @@ -1,11 +1,33 @@ import hardhatDeploy from "@sunodo/wagmi-plugin-hardhat-deploy"; -import { defineConfig } from "@wagmi/cli"; +import { ContractConfig, defineConfig } from "@wagmi/cli"; import { react } from "@wagmi/cli/plugins"; import type { Abi } from "abitype"; import { erc20Abi, erc721Abi } from "viem"; +import CartesiApplicationContract from "../../node_modules/@cartesi/rollups-v2/export/artifacts/contracts/dapp/Application.sol/Application.json"; import CartesiDAppContract from "../../node_modules/@cartesi/rollups/export/artifacts/contracts/dapp/CartesiDApp.sol/CartesiDApp.json"; import { erc1155Abi } from "./abi/ERC1155"; +/** + * Uses the sunodo/hardhatDeploy plugin to generate the wagmi config + * and add a prefix 'v2' to the contract's name making it easy to distinguish between v1 and v2 contracts + * while also avoiding collisions and making intellisense useful (e.g. useSimulateV2...) + * @returns + */ +const generateV2ContractsConfig = (): ContractConfig[] => { + const result = hardhatDeploy({ + directory: "../../node_modules/@cartesi/rollups-v2/export/abi", + }); + + const contracts = (result.contracts?.() ?? []) as ContractConfig[]; + + return contracts.map((contract) => ({ + ...contract, + name: `V2${contract.name}`, + })); +}; + +generateV2ContractsConfig(); + export default defineConfig({ out: "src/index.tsx", contracts: [ @@ -25,6 +47,13 @@ export default defineConfig({ abi: erc1155Abi, name: "ERC1155", }, + + { + name: "V2CartesiApplication", + abi: CartesiApplicationContract.abi as Abi, + }, + + ...generateV2ContractsConfig(), ], plugins: [ hardhatDeploy({ diff --git a/yarn.lock b/yarn.lock index 8e8f415e9..0b5e3934e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1444,6 +1444,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@cartesi/rollups-v2@npm:@cartesi/rollups@2.0.0-rc.10": + version "2.0.0-rc.10" + resolved "https://registry.yarnpkg.com/@cartesi/rollups/-/rollups-2.0.0-rc.10.tgz#cad12f24dccf9799a90f8468a5ad45bb614e1d88" + integrity sha512-lh9ZKpUmxiKbVHMAXkKyiN3F9MR6pV62lt9STq1QNBzgyodPuJM6wfYzCruU+dOW9XbB3q5u7fYJuY8nvuKjHQ== + dependencies: + "@openzeppelin/contracts" "5.0.2" + "@cartesi/rollups@^1.2.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@cartesi/rollups/-/rollups-1.4.0.tgz#a044782ab109b081b54741bdaa2a32707c050e62" @@ -1814,6 +1821,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== +"@esbuild/aix-ppc64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz#51299374de171dbd80bb7d838e1cfce9af36f353" + integrity sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ== + "@esbuild/android-arm64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz#984b4f9c8d0377443cc2dfcef266d02244593622" @@ -1834,6 +1846,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== +"@esbuild/android-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz#58565291a1fe548638adb9c584237449e5e14018" + integrity sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw== + "@esbuild/android-arm@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.18.20.tgz#fedb265bc3a589c84cc11f810804f234947c3682" @@ -1854,6 +1871,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== +"@esbuild/android-arm@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.23.1.tgz#5eb8c652d4c82a2421e3395b808e6d9c42c862ee" + integrity sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ== + "@esbuild/android-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.18.20.tgz#35cf419c4cfc8babe8893d296cd990e9e9f756f2" @@ -1874,6 +1896,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== +"@esbuild/android-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.23.1.tgz#ae19d665d2f06f0f48a6ac9a224b3f672e65d517" + integrity sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg== + "@esbuild/darwin-arm64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz#08172cbeccf95fbc383399a7f39cfbddaeb0d7c1" @@ -1894,6 +1921,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== +"@esbuild/darwin-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz#05b17f91a87e557b468a9c75e9d85ab10c121b16" + integrity sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q== + "@esbuild/darwin-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz#d70d5790d8bf475556b67d0f8b7c5bdff053d85d" @@ -1914,6 +1946,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== +"@esbuild/darwin-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz#c58353b982f4e04f0d022284b8ba2733f5ff0931" + integrity sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw== + "@esbuild/freebsd-arm64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz#98755cd12707f93f210e2494d6a4b51b96977f54" @@ -1934,6 +1971,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== +"@esbuild/freebsd-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz#f9220dc65f80f03635e1ef96cfad5da1f446f3bc" + integrity sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA== + "@esbuild/freebsd-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz#c1eb2bff03915f87c29cece4c1a7fa1f423b066e" @@ -1954,6 +1996,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== +"@esbuild/freebsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz#69bd8511fa013b59f0226d1609ac43f7ce489730" + integrity sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g== + "@esbuild/linux-arm64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz#bad4238bd8f4fc25b5a021280c770ab5fc3a02a0" @@ -1974,6 +2021,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== +"@esbuild/linux-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz#8050af6d51ddb388c75653ef9871f5ccd8f12383" + integrity sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g== + "@esbuild/linux-arm@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz#3e617c61f33508a27150ee417543c8ab5acc73b0" @@ -1994,6 +2046,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== +"@esbuild/linux-arm@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz#ecaabd1c23b701070484990db9a82f382f99e771" + integrity sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ== + "@esbuild/linux-ia32@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz#699391cccba9aee6019b7f9892eb99219f1570a7" @@ -2014,6 +2071,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== +"@esbuild/linux-ia32@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz#3ed2273214178109741c09bd0687098a0243b333" + integrity sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ== + "@esbuild/linux-loong64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz#e6fccb7aac178dd2ffb9860465ac89d7f23b977d" @@ -2034,6 +2096,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== +"@esbuild/linux-loong64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz#a0fdf440b5485c81b0fbb316b08933d217f5d3ac" + integrity sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw== + "@esbuild/linux-mips64el@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz#eeff3a937de9c2310de30622a957ad1bd9183231" @@ -2054,6 +2121,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== +"@esbuild/linux-mips64el@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz#e11a2806346db8375b18f5e104c5a9d4e81807f6" + integrity sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q== + "@esbuild/linux-ppc64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz#2f7156bde20b01527993e6881435ad79ba9599fb" @@ -2074,6 +2146,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== +"@esbuild/linux-ppc64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz#06a2744c5eaf562b1a90937855b4d6cf7c75ec96" + integrity sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw== + "@esbuild/linux-riscv64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz#6628389f210123d8b4743045af8caa7d4ddfc7a6" @@ -2094,6 +2171,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== +"@esbuild/linux-riscv64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz#65b46a2892fc0d1af4ba342af3fe0fa4a8fe08e7" + integrity sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA== + "@esbuild/linux-s390x@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz#255e81fb289b101026131858ab99fba63dcf0071" @@ -2114,6 +2196,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== +"@esbuild/linux-s390x@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz#e71ea18c70c3f604e241d16e4e5ab193a9785d6f" + integrity sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw== + "@esbuild/linux-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz#c7690b3417af318a9b6f96df3031a8865176d338" @@ -2134,6 +2221,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0" integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== +"@esbuild/linux-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz#d47f97391e80690d4dfe811a2e7d6927ad9eed24" + integrity sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ== + "@esbuild/netbsd-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz#30e8cd8a3dded63975e2df2438ca109601ebe0d1" @@ -2154,6 +2246,16 @@ resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== +"@esbuild/netbsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz#44e743c9778d57a8ace4b72f3c6b839a3b74a653" + integrity sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA== + +"@esbuild/openbsd-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz#05c5a1faf67b9881834758c69f3e51b7dee015d7" + integrity sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q== + "@esbuild/openbsd-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz#7812af31b205055874c8082ea9cf9ab0da6217ae" @@ -2174,6 +2276,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== +"@esbuild/openbsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz#2e58ae511bacf67d19f9f2dcd9e8c5a93f00c273" + integrity sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA== + "@esbuild/sunos-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz#d5c275c3b4e73c9b0ecd38d1ca62c020f887ab9d" @@ -2194,6 +2301,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== +"@esbuild/sunos-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz#adb022b959d18d3389ac70769cef5a03d3abd403" + integrity sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA== + "@esbuild/win32-arm64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz#73bc7f5a9f8a77805f357fab97f290d0e4820ac9" @@ -2214,6 +2326,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== +"@esbuild/win32-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz#84906f50c212b72ec360f48461d43202f4c8b9a2" + integrity sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A== + "@esbuild/win32-ia32@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz#ec93cbf0ef1085cc12e71e0d661d20569ff42102" @@ -2234,6 +2351,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== +"@esbuild/win32-ia32@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz#5e3eacc515820ff729e90d0cb463183128e82fac" + integrity sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ== + "@esbuild/win32-x64@0.18.20": version "0.18.20" resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz#786c5f41f043b07afb1af37683d7c33668858f6d" @@ -2254,6 +2376,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== +"@esbuild/win32-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz#81fd50d11e2c32b2d6241470e3185b70c7b30699" + integrity sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg== + "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -3613,6 +3740,11 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.2.tgz#1cb2d5e4d3360141a17dbc45094a8cad6aac16c1" integrity sha512-mO+y6JaqXjWeMh9glYVzVu8HYPGknAAnWyxTRhGeckOruyXQMNnlcW6w/Dx9ftLeIQk6N+ZJFuVmTwF7lEIFrg== +"@openzeppelin/contracts@5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.2.tgz#b1d03075e49290d06570b2fd42154d76c2a5d210" + integrity sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA== + "@parcel/watcher-android-arm64@2.4.1": version "2.4.1" resolved "https://registry.yarnpkg.com/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.1.tgz#c2c19a3c442313ff007d2d7a9c2c1dd3e1c9ca84" @@ -9377,6 +9509,36 @@ esbuild@^0.21.3: "@esbuild/win32-ia32" "0.21.5" "@esbuild/win32-x64" "0.21.5" +esbuild@~0.23.0: + version "0.23.1" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.23.1.tgz#40fdc3f9265ec0beae6f59824ade1bd3d3d2dab8" + integrity sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg== + optionalDependencies: + "@esbuild/aix-ppc64" "0.23.1" + "@esbuild/android-arm" "0.23.1" + "@esbuild/android-arm64" "0.23.1" + "@esbuild/android-x64" "0.23.1" + "@esbuild/darwin-arm64" "0.23.1" + "@esbuild/darwin-x64" "0.23.1" + "@esbuild/freebsd-arm64" "0.23.1" + "@esbuild/freebsd-x64" "0.23.1" + "@esbuild/linux-arm" "0.23.1" + "@esbuild/linux-arm64" "0.23.1" + "@esbuild/linux-ia32" "0.23.1" + "@esbuild/linux-loong64" "0.23.1" + "@esbuild/linux-mips64el" "0.23.1" + "@esbuild/linux-ppc64" "0.23.1" + "@esbuild/linux-riscv64" "0.23.1" + "@esbuild/linux-s390x" "0.23.1" + "@esbuild/linux-x64" "0.23.1" + "@esbuild/netbsd-x64" "0.23.1" + "@esbuild/openbsd-arm64" "0.23.1" + "@esbuild/openbsd-x64" "0.23.1" + "@esbuild/sunos-x64" "0.23.1" + "@esbuild/win32-arm64" "0.23.1" + "@esbuild/win32-ia32" "0.23.1" + "@esbuild/win32-x64" "0.23.1" + escalade@^3.1.1: version "3.1.2" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" @@ -10566,6 +10728,13 @@ get-tsconfig@^4.5.0: dependencies: resolve-pkg-maps "^1.0.0" +get-tsconfig@^4.7.5: + version "4.8.1" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.8.1.tgz#8995eb391ae6e1638d251118c7b56de7eb425471" + integrity sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg== + dependencies: + resolve-pkg-maps "^1.0.0" + getos@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5" @@ -17200,6 +17369,16 @@ tsup@^7: sucrase "^3.20.3" tree-kill "^1.2.2" +tsx@^4.19.2: + version "4.19.2" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.19.2.tgz#2d7814783440e0ae42354d0417d9c2989a2ae92c" + integrity sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g== + dependencies: + esbuild "~0.23.0" + get-tsconfig "^4.7.5" + optionalDependencies: + fsevents "~2.3.3" + tty-table@^4.1.5: version "4.2.3" resolved "https://registry.yarnpkg.com/tty-table/-/tty-table-4.2.3.tgz#e33eb4007a0a9c976c97c37fa13ba66329a5c515" From 334ec8107b8acf6ec84cb9838182d0db00705a73 Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Thu, 14 Nov 2024 11:16:08 +1300 Subject: [PATCH 2/4] feat: Add new graphQL schema / queries / codegen for v2. Update Scan API queries to include the App rollup version prop. --- apps/web/codegen.ts | 12 +- apps/web/graphql/queries.graphql | 17 +- apps/web/graphql/rollups/v2/queries.graphql | 110 +++++++ apps/web/graphql/rollups/v2/schema.graphql | 312 ++++++++++++++++++++ 4 files changed, 442 insertions(+), 9 deletions(-) create mode 100644 apps/web/graphql/rollups/v2/queries.graphql create mode 100644 apps/web/graphql/rollups/v2/schema.graphql diff --git a/apps/web/codegen.ts b/apps/web/codegen.ts index 9b3196751..c36ecdc8a 100644 --- a/apps/web/codegen.ts +++ b/apps/web/codegen.ts @@ -3,11 +3,14 @@ import type { Types } from "@graphql-codegen/plugin-helpers"; import { join, sep } from "path"; const basePath = join("src", "graphql"); +const rollupsBasePath = join("graphql", "rollups"); // FIXUP: to be replaced with new deployed API. const explorerSchema = "https://api.cartesiscan.io/graphql"; const explorerAPIQueries = join(".", "graphql", "queries.graphql"); -const rollupsSchema = join(".", "graphql", "rollups", "schema.graphql"); -const rollupsDocuments = join(".", "graphql", "rollups", "queries.graphql"); +const rollupsSchema = join(".", rollupsBasePath, "schema.graphql"); +const rollupsDocuments = join(".", rollupsBasePath, "queries.graphql"); +const rollupsV2Schema = join(".", rollupsBasePath, "v2", "schema.graphql"); +const rollupsV2Documents = join(".", rollupsBasePath, "v2", "queries.graphql"); console.info(`Codegen will use schema URL: ${explorerSchema}`); @@ -18,6 +21,11 @@ interface CommonConfig extends Pick { type Generates = Partial>; const setup: CommonConfig[] = [ + { + dirname: "rollups/v2", + schema: rollupsV2Schema, + documents: rollupsV2Documents, + }, { dirname: "rollups", schema: rollupsSchema, diff --git a/apps/web/graphql/queries.graphql b/apps/web/graphql/queries.graphql index 911b81a9c..41f6cb9da 100644 --- a/apps/web/graphql/queries.graphql +++ b/apps/web/graphql/queries.graphql @@ -1,8 +1,13 @@ +fragment ApplicationRequiredFields on Application { + id + address + rollupVersion +} + fragment InputItem on Input { id application { - id - address + ...ApplicationRequiredFields } chain { id @@ -88,8 +93,7 @@ query statsApplicationsOwner($ownerAddress: String, $chainId: String) { query applications($limit: Int, $where: ApplicationWhereInput) { applications(where: $where, limit: $limit) { - id - address + ...ApplicationRequiredFields } } @@ -110,10 +114,9 @@ query multiTokens($limit: Int, $where: MultiTokenWhereInput) { } fragment ApplicationItem on Application { - id + ...ApplicationRequiredFields owner - timestamp - address + timestamp factory { id address diff --git a/apps/web/graphql/rollups/v2/queries.graphql b/apps/web/graphql/rollups/v2/queries.graphql new file mode 100644 index 000000000..c35118ea1 --- /dev/null +++ b/apps/web/graphql/rollups/v2/queries.graphql @@ -0,0 +1,110 @@ +# FRAGMENTS + +fragment pageInfoFields on PageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage +} + +fragment vouchersFields on Input { + vouchers(first: $firstVouchers, after: $vouchersNextPage, before: $vouchersPrevPage, last: $lastVouchers) { + totalCount + edges { + node { + index + input { + index + } + destination + payload + proof { + outputIndex + outputHashesSiblings + } + } + cursor + } + pageInfo { + ...pageInfoFields + } + } +} + +fragment noticesFields on Input { + notices(first: $firstNotices, after: $noticesNextPage, before: $noticesPrevPage, last: $lastNotices){ + totalCount + edges { + node { + index + payload + } + cursor + } + pageInfo { + ...pageInfoFields + } + } +} + +fragment reportsFields on Input { + reports(first: $firstReports, after: $reportsNextPage, before: $reportsPrevPage, last: $lastReports) { + totalCount + edges { + node { + index + payload + } + cursor + } + pageInfo { + ...pageInfoFields + } + } +} + + + # QUERIES + +query inputDetails ( + $inputId: String! + $firstNotices: Int + $lastNotices: Int + $noticesNextPage: String + $noticesPrevPage: String + $firstReports: Int + $lastReports: Int + $reportsNextPage: String + $reportsPrevPage: String + $firstVouchers: Int + $lastVouchers: Int + $vouchersNextPage: String + $vouchersPrevPage: String +) { + input(id: $inputId){ + ...vouchersFields + ...noticesFields + ...reportsFields + } +} + +query checkStatus { + inputs { + totalCount + } + vouchers { + totalCount + } + reports { + totalCount + } + notices { + totalCount + } +} + +query inputStatus($id: String!) { + input(id: $id) { + status + } +} diff --git a/apps/web/graphql/rollups/v2/schema.graphql b/apps/web/graphql/rollups/v2/schema.graphql new file mode 100644 index 000000000..cae7790f0 --- /dev/null +++ b/apps/web/graphql/rollups/v2/schema.graphql @@ -0,0 +1,312 @@ +""" +The @defer directive may be specified on a fragment spread to imply +de-prioritization, that causes the fragment to be omitted in the initial +response, and delivered as a subsequent response afterward. A query with @defer +directive will cause the request to potentially return multiple responses, where +non-deferred data is delivered in the initial response and data deferred +delivered in a subsequent response. @include and @skip take precedence over @defer. +""" +directive @defer(if: Boolean = true, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT + +""" +The @specifiedBy built-in directive is used within the type system definition +language to provide a scalar specification URL for specifying the behavior of +custom scalar types. +""" +directive @specifiedBy(url: String!) on SCALAR + +input AddressFilterInput { + eq: String + ne: String + in: [String] + nin: [String] + and: [ConvenientFilter] + or: [ConvenientFilter] +} + +scalar BigInt + +input BooleanFilterInput { + eq: Boolean + ne: Boolean + and: [ConvenientFilter] + or: [ConvenientFilter] +} + +enum CompletionStatus { + UNPROCESSED + ACCEPTED + REJECTED + EXCEPTION + MACHINE_HALTED + CYCLE_LIMIT_EXCEEDED + TIME_LIMIT_EXCEEDED + PAYLOAD_LENGTH_LIMIT_EXCEEDED +} + +input ConvenientFilter { + destination: AddressFilterInput + executed: BooleanFilterInput + and: [ConvenientFilter] + or: [ConvenientFilter] +} + +"""Request submitted to the application to advance its state""" +type Input { + """id of the input""" + id: String! + + """Input index starting from genesis""" + index: Int! + + """Status of the input""" + status: CompletionStatus! + + """Address responsible for submitting the input""" + msgSender: String! + + """ + Timestamp associated with the input submission, as defined by the base layer's block in which it was recorded + """ + timestamp: BigInt! @deprecated(reason: "Use `blockTimestamp` instead") + + """Number of the base layer block in which the input was recorded""" + blockNumber: BigInt! + + """Input payload in Ethereum hex binary format, starting with '0x'""" + payload: String! + + """Get vouchers from this particular input with support for pagination""" + vouchers(first: Int, last: Int, after: String, before: String): VoucherConnection! + + """Get notices from this particular input with support for pagination""" + notices(first: Int, last: Int, after: String, before: String): NoticeConnection! + + """Get reports from this particular input with support for pagination""" + reports(first: Int, last: Int, after: String, before: String): ReportConnection! + + """Timestamp associated with the Espresso input submission""" + espressoTimestamp: String @deprecated(reason: "Will be removed") + + """Number of the Espresso block in which the input was recorded""" + espressoBlockNumber: String @deprecated(reason: "Will be removed") + + """Input index in the Input Box""" + inputBoxIndex: String + blockTimestamp: BigInt + prevRandao: String +} + +"""Pagination result""" +type InputConnection { + """Total number of entries that match the query""" + totalCount: Int! + + """Pagination entries returned for the current page""" + edges: [InputEdge!]! + + """Pagination metadata""" + pageInfo: PageInfo! +} + +"""Pagination entry""" +type InputEdge { + """Node instance""" + node: Input! + + """Pagination cursor""" + cursor: String! +} + +"""Filter object to restrict results depending on input properties""" +input InputFilter { + """Filter only inputs with index lower than a given value""" + indexLowerThan: Int + + """Filter only inputs with index greater than a given value""" + indexGreaterThan: Int + + """Filter only inputs with the message sender""" + msgSender: String + + """Filter only inputs from 'inputbox' or 'espresso'""" + type: String +} + +""" +Informational statement that can be validated in the base layer blockchain +""" +type Notice { + """Notice index within the context of the input that produced it""" + index: Int! + + """Input whose processing produced the notice""" + input: Input! + + """ + Notice data as a payload in Ethereum hex binary format, starting with '0x' + """ + payload: String! + + """ + Proof object that allows this notice to be validated by the base layer blockchain + """ + proof: Proof +} + +"""Pagination result""" +type NoticeConnection { + """Total number of entries that match the query""" + totalCount: Int! + + """Pagination entries returned for the current page""" + edges: [NoticeEdge!]! + + """Pagination metadata""" + pageInfo: PageInfo! +} + +"""Pagination entry""" +type NoticeEdge { + """Node instance""" + node: Notice! + + """Pagination cursor""" + cursor: String! +} + +"""Page metadata for the cursor-based Connection pagination pattern""" +type PageInfo { + """Cursor pointing to the first entry of the page""" + startCursor: String + + """Cursor pointing to the last entry of the page""" + endCursor: String + + """Indicates if there are additional entries after the end curs""" + hasNextPage: Boolean! + + """Indicates if there are additional entries before the start curs""" + hasPreviousPage: Boolean! +} + +""" +Data that can be used as proof to validate notices and execute vouchers on the base layer blockchain +""" +type Proof { + outputIndex: BigInt! + outputHashesSiblings: [String]! +} + +"""Top level queries""" +type Query { + """Get input based on its identifier""" + input(id: String!): Input! + + """Get a voucher based on its index""" + voucher(outputIndex: Int!): Voucher! + + """Get a notice based on its index""" + notice(outputIndex: Int!): Notice! + + """Get a report based on its index""" + report(reportIndex: Int!): Report! + + """Get inputs with support for pagination""" + inputs(first: Int, last: Int, after: String, before: String, where: InputFilter): InputConnection! + + """Get vouchers with support for pagination""" + vouchers(first: Int, last: Int, after: String, before: String, filter: [ConvenientFilter]): VoucherConnection! + + """Get notices with support for pagination""" + notices(first: Int, last: Int, after: String, before: String): NoticeConnection! + + """Get reports with support for pagination""" + reports(first: Int, last: Int, after: String, before: String): ReportConnection! +} + +"""Application log or diagnostic information""" +type Report { + """Report index within the context of the input that produced it""" + index: Int! + + """Input whose processing produced the report""" + input: Input! + + """ + Report data as a payload in Ethereum hex binary format, starting with '0x' + """ + payload: String! +} + +"""Pagination result""" +type ReportConnection { + """Total number of entries that match the query""" + totalCount: Int! + + """Pagination entries returned for the current page""" + edges: [ReportEdge!]! + + """Pagination metadata""" + pageInfo: PageInfo! +} + +"""Pagination entry""" +type ReportEdge { + """Node instance""" + node: Report! + + """Pagination cursor""" + cursor: String! +} + +""" +Representation of a transaction that can be carried out on the base layer blockchain, such as a transfer of assets +""" +type Voucher { + """Voucher index within the context of the input that produced it""" + index: Int! + + """Input whose processing produced the voucher""" + input: Input! + + """ + Transaction destination address in Ethereum hex binary format (20 bytes), starting with '0x' + """ + destination: String! + + """Transaction payload in Ethereum hex binary format, starting with '0x'""" + payload: String! + + """ + Proof object that allows this voucher to be validated and executed on the base layer blockchain + """ + proof: Proof + value: BigInt + + """ + Indicates whether the voucher has been executed on the base layer blockchain + """ + executed: Boolean +} + +"""Pagination result""" +type VoucherConnection { + """Total number of entries that match the query""" + totalCount: Int! + + """Pagination entries returned for the current page""" + edges: [VoucherEdge!]! + + """Pagination metadata""" + pageInfo: PageInfo! +} + +"""Pagination entry""" +type VoucherEdge { + """Node instance""" + node: Voucher! + + """Pagination cursor""" + cursor: String! +} \ No newline at end of file From 3a6bb27100b9ed11c5fce74ced4c3b2d64c04096 Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Thu, 14 Nov 2024 13:58:11 +1300 Subject: [PATCH 3/4] fix: Point to the correct branch for generated coverage badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53c17c5ec..8dc194ac6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Rollups Explorer -[![Coverage Status](https://coveralls.io/repos/github/cartesi/rollups-explorer/badge.svg?branch=feature/97-upload-test-coverage-to-coveralls)](https://coveralls.io/github/cartesi/rollups-explorer?branch=feature/97-upload-test-coverage-to-coveralls) +[![Coverage Status](https://coveralls.io/repos/github/cartesi/rollups-explorer/badge.svg?branch=main)](https://coveralls.io/github/cartesi/rollups-explorer?branch=main) This is a monorepo managed by [turborepo](https://turbo.build/repo) using [Yarn v1](https://classic.yarnpkg.com/) as the package manager. It holds two web apps and a few packages. A nextJS app called [web](./apps//web/) that is the rollups-explorer UI. The second is a Storybook app called [workshop](./apps/workshop/) to support showcase and quick development of components. The backend for the rollups-explorer can be found [here](https://github.com/cartesi/rollups-explorer-api) From 3806b3294a47669f684c231925da86dea186da51 Mon Sep 17 00:00:00 2001 From: Bruno Menezes Date: Thu, 14 Nov 2024 13:59:03 +1300 Subject: [PATCH 4/4] feat: Add new system specifications for v2. Add new test cases + data and update a failing one. --- .../components/specification/systemSpecs.ts | 142 ++++++++++++++++++ .../SpecificationListView.test.tsx | 2 +- .../components/specification/decoder.test.ts | 78 ++++++++++ .../specification/encodedData.stubs.ts | 20 +++ 4 files changed, 241 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/specification/systemSpecs.ts b/apps/web/src/components/specification/systemSpecs.ts index 2d4f8fc07..30e8379a2 100644 --- a/apps/web/src/components/specification/systemSpecs.ts +++ b/apps/web/src/components/specification/systemSpecs.ts @@ -9,6 +9,11 @@ import { erc20PortalConfig, erc721PortalConfig, etherPortalConfig, + v2Erc1155BatchPortalConfig, + v2Erc1155SinglePortalConfig, + v2Erc20PortalConfig, + v2Erc721PortalConfig, + v2EtherPortalConfig, } from "@cartesi/rollups-wagmi"; import { Specification } from "./types"; @@ -174,6 +179,138 @@ const DAppAddressRelaySpec: Specification = { ], }; +const V2EtherPortalSpec: Specification = { + id: "52a35267-7c06-4f0b-b329-0f567eab5ed4", + version: 1, + mode: "abi_params", + name: "Ether Portal @cartesi/rollups@2.x", + sliceInstructions: EtherPortalSpec.sliceInstructions, + abiParams: [], + conditionals: [ + { + logicalOperator: "or", + conditions: [ + { + field: "msgSender", + operator: "equals", + value: v2EtherPortalConfig.address.toLowerCase(), + }, + ], + }, + ], +} as const; + +const V2ERC1155SinglePortalSpec: Specification = { + id: "68ae9335-2494-437b-87c7-ac0c8dc7058b", + mode: "abi_params", + name: `ERC-1155 Single Portal @cartesi/rollups@2.x`, + sliceInstructions: ERC1155SinglePortalSpec.sliceInstructions, + conditionals: [ + { + logicalOperator: "or", + conditions: [ + { + field: "msgSender", + operator: "equals", + value: v2Erc1155SinglePortalConfig.address.toLowerCase(), + }, + ], + }, + ], + abiParams: [], + version: 1, +} as const; + +const V2ERC1155BatchPortalSpec: Specification = { + id: "54ee4a79-f725-4078-98ac-d2fa5fd287f9", + mode: "abi_params", + name: "ERC-1155 Batch Portal @cartesi/rollups@2.x", + abiParams: [ + "uint[] tokenIds, uint[] amounts, bytes baseLayer, bytes execLayer", + ], + sliceInstructions: [ + { + from: 0, + to: 20, + name: "tokenAddress", + }, + { + from: 20, + to: 40, + name: "from", + }, + { + from: 40, + name: "data", + }, + ], + sliceTarget: "data", + conditionals: [ + { + logicalOperator: "or", + conditions: [ + { + field: "msgSender", + operator: "equals", + value: v2Erc1155BatchPortalConfig.address.toLowerCase(), + }, + ], + }, + ], + version: 1, +} as const; + +const V2ERC20PortalSpec: Specification = { + id: "451150d0-6936-4e4a-882d-44b264bf5f30", + mode: "abi_params", + name: "ERC-20 Portal @cartesi/rollups@2.x", + sliceInstructions: [ + { from: 0, to: 20, name: "tokenAddress" }, + { from: 20, to: 40, name: "from" }, + { from: 40, to: 72, name: "amount", type: "uint" }, + { from: 72, name: "execLayerData", optional: true }, + ], + abiParams: [], + conditionals: [ + { + logicalOperator: "or", + conditions: [ + { + field: "msgSender", + operator: "equals", + value: v2Erc20PortalConfig.address.toLowerCase(), + }, + ], + }, + ], + version: 1, +} as const; + +const V2ERC721PortalSpec: Specification = { + id: "12fa0cd4-aaa2-4ec9-b38d-0cb0cb19a919", + version: 1, + mode: "abi_params", + name: "ERC-721 Portal @cartesi/rollups@2.x", + sliceInstructions: [ + { from: 0, to: 20, name: "tokenAddress" }, + { from: 20, to: 40, name: "from" }, + { from: 40, to: 72, name: "tokenIndex", type: "uint" }, + ], + abiParams: [], + conditionals: [ + { + logicalOperator: "or", + conditions: [ + { + field: "msgSender", + operator: "equals", + value: v2Erc721PortalConfig.address.toLowerCase(), + }, + ], + }, + ], +} as const; + export const systemSpecification = { ERC1155SinglePortalSpec, ERC1155BatchPortalSpec, @@ -181,6 +318,11 @@ export const systemSpecification = { ERC721PortalSpec, EtherPortalSpec, DAppAddressRelaySpec, + V2EtherPortalSpec, + V2ERC1155BatchPortalSpec, + V2ERC1155SinglePortalSpec, + V2ERC20PortalSpec, + V2ERC721PortalSpec, } as const; export const systemSpecificationAsList = Object.values(systemSpecification); diff --git a/apps/web/test/components/specification/SpecificationListView.test.tsx b/apps/web/test/components/specification/SpecificationListView.test.tsx index 04b29bcf4..f77588818 100644 --- a/apps/web/test/components/specification/SpecificationListView.test.tsx +++ b/apps/web/test/components/specification/SpecificationListView.test.tsx @@ -210,7 +210,7 @@ describe("Specification Listing View", () => { expect( getByText( elem, - "You have 6 specifications, but none of them are the type", + "You have 11 specifications, but none of them are the type", ), ).toBeInTheDocument(); expect(getByText(elem, "JSON ABI")).toBeInTheDocument(); diff --git a/apps/web/test/components/specification/decoder.test.ts b/apps/web/test/components/specification/decoder.test.ts index 5dc9c4d69..fe90bef48 100644 --- a/apps/web/test/components/specification/decoder.test.ts +++ b/apps/web/test/components/specification/decoder.test.ts @@ -267,6 +267,84 @@ Slice name: "from" (Is it the right one?)`, expect(envelope.result).toEqual({}); }); + + describe("Decoding portal data ( Rollups v2 )", () => { + it("should decode ether-portal data", () => { + const envelope = decodePayload( + systemSpecification.V2EtherPortalSpec, + encodedDataSamples.v2EtherPortalSample, + ); + + expect(envelope.result).toEqual({ + amount: 111000000000000000n, + sender: "0xa074683b5be015f053b5dceb064c41fc9d11b6e5", + execLayerData: + "0x7b22616374696f6e223a226d61696e3a616363227d", + }); + }); + + it("should decode erc-721-portal data", () => { + const envelope = decodePayload( + systemSpecification.V2ERC721PortalSpec, + encodedDataSamples.v2Erc721PortalSample, + ); + + expect(envelope.result).toEqual({ + tokenAddress: + "0x7a3cc9c0408887a030a0354330c36a9cd681aa7e", + tokenIndex: 1n, + from: "0xa074683b5be015f053b5dceb064c41fc9d11b6e5", + }); + }); + + it("should decode erc-20-portal data", () => { + const envelope = decodePayload( + systemSpecification.V2ERC20PortalSpec, + encodedDataSamples.v2Erc20PortalSample, + ); + + expect(envelope.result).toEqual({ + amount: 111000000000000000n, + execLayerData: + "0x7b22616374696f6e223a226372656174653a616363227d", + from: "0xa074683b5be015f053b5dceb064c41fc9d11b6e5", + tokenAddress: + "0x813ae0539daf858599a1b2a7083380542a7b1bb5", + }); + }); + + it("should decode erc-1155_single-portal data", () => { + const envelope = decodePayload( + systemSpecification.V2ERC1155SinglePortalSpec, + encodedDataSamples.v2Erc1155SinglePortalSample, + ); + + expect(envelope.result).toEqual({ + amount: 100n, + from: "0xa074683b5be015f053b5dceb064c41fc9d11b6e5", + tokenAddress: + "0x2960f4db2b0993ae5b59bc4a0f5ec7a1767e905e", + tokenId: 0n, + }); + }); + + it("should decode erc-1155_batch-portal data", () => { + const envelope = decodePayload( + systemSpecification.V2ERC1155BatchPortalSpec, + encodedDataSamples.v2Erc1155BatchPortalSample, + ); + + expect(envelope.result).toEqual({ + amounts: [100n, 200n], + baseLayer: "0x636f64653a3139", + execLayer: "0x616374696f6e3a33", + from: "0xa074683b5be015f053b5dceb064c41fc9d11b6e5", + tokenAddress: + "0x2960f4db2b0993ae5b59bc4a0f5ec7a1767e905e", + tokenIds: [1n, 2n], + }); + }); + }); }); describe("Struct definition example cases", () => { diff --git a/apps/web/test/components/specification/encodedData.stubs.ts b/apps/web/test/components/specification/encodedData.stubs.ts index 2dfb437a0..081aef93a 100644 --- a/apps/web/test/components/specification/encodedData.stubs.ts +++ b/apps/web/test/components/specification/encodedData.stubs.ts @@ -27,9 +27,29 @@ const etherPortalSampleWithExecLayer: Hex = const etherPortalSampleWithoutExecLayer: Hex = "0x0c70e9a737aa92055c8c1217bf887a65cb2292f4000000000000000000000000000000000000000000000000002386f26fc10000"; +const v2EtherPortalSample: Hex = + "0xa074683b5be015f053b5dceb064c41fc9d11b6e5000000000000000000000000000000000000000000000000018a59e9721180007b22616374696f6e223a226d61696e3a616363227d"; + +const v2Erc721PortalSample: Hex = + "0x7a3cc9c0408887a030a0354330c36a9cd681aa7ea074683b5be015f053b5dceb064c41fc9d11b6e500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000046f703a32000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006636f643a31300000000000000000000000000000000000000000000000000000"; + +const v2Erc20PortalSample: Hex = + "0x813ae0539daf858599a1b2a7083380542a7b1bb5a074683b5be015f053b5dceb064c41fc9d11b6e5000000000000000000000000000000000000000000000000018a59e9721180007b22616374696f6e223a226372656174653a616363227d"; + +const v2Erc1155SinglePortalSample: Hex = + "0x2960f4db2b0993ae5b59bc4a0f5ec7a1767e905ea074683b5be015f053b5dceb064c41fc9d11b6e50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000f7b22636f64223a226d61783230227d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096f703a3435363738340000000000000000000000000000000000000000000000"; + +const v2Erc1155BatchPortalSample: Hex = + "0x2960f4db2b0993ae5b59bc4a0f5ec7a1767e905ea074683b5be015f053b5dceb064c41fc9d11b6e5000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000c80000000000000000000000000000000000000000000000000000000000000007636f64653a3139000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008616374696f6e3a33000000000000000000000000000000000000000000000000"; + export const encodedDataSamples = { wagmiSample, encodedDataSampleWithStruct, etherPortalSampleWithExecLayer, etherPortalSampleWithoutExecLayer, + v2Erc1155BatchPortalSample, + v2Erc1155SinglePortalSample, + v2Erc20PortalSample, + v2Erc721PortalSample, + v2EtherPortalSample, };