-
Notifications
You must be signed in to change notification settings - Fork 61
Convert Hardhat tasks to Commander.js commands (using the Call example) #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@hernan-clich lmk what you think of this general direction. |
hernan-clich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall direction is fine, this should definitely be the new standard. A comment below on type safety.
|
|
||
| import { createCommand, createRevertOptions, getAbi } from "../common"; | ||
|
|
||
| const main = async (options: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ensure we don't use any, these commands would benefit from zod argument validation, this function is an excellent example of why this is necessary because it uses types and values, and since we're not using any validation or refinements, they could differ in length. We could use a commander preAction hook if we think zod is overkill for this small project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples is a different sort of code base where we can't have extra code laying around. I agree with you about additional validation and I think we can accomplish this by exporting required validation rules/functions from the toolkit and just importing them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we can add zod directly here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unresolved Merge Conflicts in `yarn.lock`
The yarn.lock file contains unresolved Git merge conflict markers (<<<<<<< HEAD, =======, >>>>>>> update-cli) at multiple locations. This prevents yarn install from completing successfully and causes project build failures.
examples/call/yarn.lock#L135-L283
example-contracts/examples/call/yarn.lock
Lines 135 to 283 in 0d647e4
| <<<<<<< HEAD | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz#4e0f91776c2b340e75558f60552195f6fad09f18" | |
| integrity sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.5.tgz#bc766407f1718923f6b8079c8c61bf86ac3a6a4f" | |
| integrity sha512-VGzGhj4lJO+TVGV1v8ntCZWJktV7SGCs3Pn1GRWI1SBFtRALoomm8k5E9Pmwg3HOAal2VDc2F9+PM/rEY6oIDg== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.5.tgz#4290d6d3407bae3883ad2cded1081a234473ce26" | |
| integrity sha512-AdJKSPeEHgi7/ZhuIPtcQKr5RQdo6OO2IL87JkianiMYMPbCtot9fxPbrMiBADOWWm3T2si9stAiVsGbTQFkbA== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.5.tgz#40c11d9cbca4f2406548c8a9895d321bc3b35eff" | |
| integrity sha512-D2GyJT1kjvO//drbRT3Hib9XPwQeWd9vZoBJn+bu/lVsOZ13cqNdDeqIF/xQ5/VmWvMduP6AmXvylO/PIc2isw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz#49d8bf8b1df95f759ac81eb1d0736018006d7e34" | |
| integrity sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.5.tgz#e27a5d92a14886ef1d492fd50fc61a2d4d87e418" | |
| integrity sha512-1iT4FVL0dJ76/q1wd7XDsXrSW+oLoquptvh4CLR4kITDtqi2e/xwXwdCVH8hVHU43wgJdsq7Gxuzcs6Iq/7bxQ== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.5.tgz#97cede59d638840ca104e605cdb9f1b118ba0b1c" | |
| integrity sha512-nk4tGP3JThz4La38Uy/gzyXtpkPW8zSAmoUhK9xKKXdBCzKODMc2adkB2+8om9BDYugz+uGV7sLmpTYzvmz6Sw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.5.tgz#71c77812042a1a8190c3d581e140d15b876b9c6f" | |
| integrity sha512-PrikaNjiXdR2laW6OIjlbeuCPrPaAl0IwPIaRv+SMV8CiM8i2LqVUHFC1+8eORgWyY7yhQY+2U2fA55mBzReaw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.5.tgz#f7b7c8f97eff8ffd2e47f6c67eb5c9765f2181b8" | |
| integrity sha512-Z9kfb1v6ZlGbWj8EJk9T6czVEjjq2ntSYLY2cw6pAZl4oKtfgQuS4HOq41M/BcoLPzrUbNd+R4BXFyH//nHxVg== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.5.tgz#2a0be71b6cd8201fa559aea45598dffabc05d911" | |
| integrity sha512-cPzojwW2okgh7ZlRpcBEtsX7WBuqbLrNXqLU89GxWbNt6uIg78ET82qifUy3W6OVww6ZWobWub5oqZOVtwolfw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.5.tgz#763414463cd9ea6fa1f96555d2762f9f84c61783" | |
| integrity sha512-sQ7l00M8bSv36GLV95BVAdhJ2QsIbCuCjh/uYrWiMQSUuV+LpXwIqhgJDcvMTj+VsQmqAHL2yYaasENvJ7CDKA== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.5.tgz#428cf2213ff786a502a52c96cf29d1fcf1eb8506" | |
| integrity sha512-0ur7ae16hDUC4OL5iEnDb0tZHDxYmuQyhKhsPBV8f99f6Z9KQM02g33f93rNH5A30agMS46u2HP6qTdEt6Q1kg== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.5.tgz#5cbcc7fd841b4cd53358afd33527cd394e325d96" | |
| integrity sha512-kB/66P1OsHO5zLz0i6X0RxlQ+3cu0mkxS3TKFvkb5lin6uwZ/ttOkP3Z8lfR9mJOBk14ZwZ9182SIIWFGNmqmg== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.5.tgz#0d954ab39ce4f5e50f00c4f8c4fd38f976c13ad9" | |
| integrity sha512-UZCmJ7r9X2fe2D6jBmkLBMQetXPXIsZjQJCjgwpVDz+YMcS6oFR27alkgGv3Oqkv07bxdvw7fyB71/olceJhkQ== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.5.tgz#0e7dd30730505abd8088321e8497e94b547bfb1e" | |
| integrity sha512-kTxwu4mLyeOlsVIFPfQo+fQJAV9mh24xL+y+Bm6ej067sYANjyEw1dNHmvoqxJUCMnkBdKpvOn0Ahql6+4VyeA== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.5.tgz#5669af81327a398a336d7e40e320b5bbd6e6e72d" | |
| integrity sha512-K2dSKTKfmdh78uJ3NcWFiqyRrimfdinS5ErLSn3vluHNeHVnBAFWC8a4X5N+7FgVE1EjXS1QDZbpqZBjfrqMTQ== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.5.tgz#b2357dd153aa49038967ddc1ffd90c68a9d2a0d4" | |
| integrity sha512-uhj8N2obKTE6pSZ+aMUbqq+1nXxNjZIIjCjGLfsWvVpy7gKCOL6rsY1MhRh9zLtUtAI7vpgLMK6DxjO8Qm9lJw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.5.tgz#53b4dfb8fe1cee93777c9e366893bd3daa6ba63d" | |
| integrity sha512-pwHtMP9viAy1oHPvgxtOv+OkduK5ugofNTVDilIzBLpoWAM16r7b/mxBvfpuQDpRQFMfuVr5aLcn4yveGvBZvw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.5.tgz#a0206f6314ce7dc8713b7732703d0f58de1d1e79" | |
| integrity sha512-WOb5fKrvVTRMfWFNCroYWWklbnXH0Q5rZppjq0vQIdlsQKuw6mdSihwSo4RV/YdQ5UCKKvBy7/0ZZYLBZKIbwQ== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.5.tgz#2a796c87c44e8de78001d808c77d948a21ec22fd" | |
| integrity sha512-7A208+uQKgTxHd0G0uqZO8UjK2R0DDb4fDmERtARjSHWxqMTye4Erz4zZafx7Di9Cv+lNHYuncAkiGFySoD+Mw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.5.tgz#28d0cd8909b7fa3953af998f2b2ed34f576728f0" | |
| integrity sha512-G4hE405ErTWraiZ8UiSoesH8DaCsMm0Cay4fsFWOOUcz8b8rC6uCvnagr+gnioEjWn0wC+o1/TAHt+It+MpIMg== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.5.tgz#a28164f5b997e8247d407e36c90d3fd5ddbe0dc5" | |
| integrity sha512-l+azKShMy7FxzY0Rj4RCt5VD/q8mG/e+mDivgspo+yL8zW7qEwctQ6YqKX34DTEleFAvCIUviCFX1SDZRSyMQA== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.5.tgz#6eadbead38e8bd12f633a5190e45eff80e24007e" | |
| integrity sha512-O2S7SNZzdcFG7eFKgvwUEZ2VG9D/sn/eIiz8XRZ1Q/DO5a3s76Xv0mdBzVM5j5R639lXQmPmSo0iRpHqUUrsxw== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.5.tgz#bab6288005482f9ed2adb9ded7e88eba9a62cc0d" | |
| integrity sha512-onOJ02pqs9h1iMJ1PQphR+VZv8qBMQ77Klcsqv9CNW2w6yLqoURLcgERAIurY6QE63bbLuqgP9ATqajFLK5AMQ== | |
| "@esbuild/[email protected]": | |
| version "0.25.5" | |
| resolved "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.5.tgz#7fc114af5f6563f19f73324b5d5ff36ece0803d1" | |
| integrity sha512-TXv6YnJ8ZMVdX+SXWVBo/0p8LTcrUYngpWjvm91TMjjBQii7Oz11Lw5lbDV5Y0TzuhSJHwiH4hEtC1I42mMS0g== | |
| ======= | |
| "@emnapi/core@^1.4.3": | |
| version "1.4.4" | |
| resolved "https://registry.npmjs.org/@emnapi/core/-/core-1.4.4.tgz#76620673f3033626c6d79b1420d69f06a6bb153c" | |
| integrity sha512-A9CnAbC6ARNMKcIcrQwq6HeHCjpcBZ5wSx4U01WXCqEKlrzB9F9315WDNHkrs2xbx7YjjSxbUYxuN6EQzpcY2g== | |
| dependencies: | |
| "@emnapi/wasi-threads" "1.0.3" | |
| tslib "^2.4.0" | |
| "@emnapi/runtime@^1.4.3": | |
| version "1.4.4" | |
| resolved "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.4.4.tgz#19a8f00719c51124e2d0fbf4aaad3fa7b0c92524" | |
| integrity sha512-hHyapA4A3gPaDCNfiqyZUStTMqIkKRshqPIuDOXv1hcBnD4U3l8cP0T1HMCfGRxQ6V64TGCcoswChANyOAwbQg== | |
| dependencies: | |
| tslib "^2.4.0" | |
| "@emnapi/[email protected]": | |
| version "1.0.3" | |
| resolved "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.0.3.tgz#83fa228bde0e71668aad6db1af4937473d1d3ab1" | |
| integrity sha512-8K5IFFsQqF9wQNJptGbS6FNKgUTsSRYnTqNCG1vPP8jFdjSv18n2mQfJpkt2Oibo9iBEzcDnDxNwKTzC7svlJw== | |
| dependencies: | |
| tslib "^2.4.0" | |
| >>>>>>> update-cli |
examples/call/yarn.lock#L5837-L5848
example-contracts/examples/call/yarn.lock
Lines 5837 to 5848 in 0d647e4
| <<<<<<< HEAD | |
| ethers@^6.14.4: | |
| version "6.14.4" | |
| resolved "https://registry.npmjs.org/ethers/-/ethers-6.14.4.tgz#0f6fbc562a8425c7c888da307fa71ef796be0c04" | |
| integrity sha512-Jm/dzRs2Z9iBrT6e9TvGxyb5YVKAPLlpna7hjxH7KH/++DSh2T/JVmQUv7iHI5E55hDbp/gEVvstWYXVxXFzsA== | |
| ======= | |
| ethers@^6.13.2: | |
| version "6.15.0" | |
| resolved "https://registry.npmjs.org/ethers/-/ethers-6.15.0.tgz#2980f2a3baf0509749b7e21f8692fa8a8349c0e3" | |
| integrity sha512-Kf/3ZW54L4UT0pZtsY/rf+EkBU7Qi5nnhonjUb8yTXcxH3cdcWrV2cRyk0Xk/4jK6OoHhxxZHriyhje20If2hQ== | |
| >>>>>>> update-cli |
Bug: Command Options Type and Requirement Errors
The universal-call and universal-withdraw-and-call commands have two issues:
- The
--functionoption is defined as optional but is directly used inethers.id(). If not provided,ethers.id(undefined)will throw an error, as the function signature is essential for creating the payload. This option should be required. - The
--call-options-gas-limitoption is defined without a type, defaulting to a string. It is then used as agasLimitparameter, which expects a number, potentially causing runtime errors.
examples/call/commands/universal/withdrawAndCall.ts#L56-L61
example-contracts/examples/call/commands/universal/withdrawAndCall.ts
Lines 56 to 61 in 0d647e4
| .option("--call-options-is-arbitrary-call", "Call any function", false) | |
| .option("--call-options-gas-limit", "The gas limit for the call", "500000") | |
| .option( | |
| "--function <function>", | |
| `Function to call (example: "hello(string)")` | |
| ) |
examples/call/commands/universal/call.ts#L14-L15
example-contracts/examples/call/commands/universal/call.ts
Lines 14 to 15 in 0d647e4
| const functionSignature = ethers.id(options.function).slice(0, 10); |
examples/call/commands/universal/withdrawAndCall.ts#L18-L19
example-contracts/examples/call/commands/universal/withdrawAndCall.ts
Lines 18 to 19 in 0d647e4
| const functionSignature = ethers.id(options.function).slice(0, 10); |
Bug: Function Option Required, Gas Limit Type Mismatch
The --function option is defined as optional but its value is directly used by ethers.id(), causing an error if undefined. It should be a required option. Additionally, the --call-options-gas-limit option is defined as a string but is used as a number for gasLimit, which can cause runtime errors.
examples/call/commands/universal/call.ts#L49-L54
example-contracts/examples/call/commands/universal/call.ts
Lines 49 to 54 in 0d647e4
| .option("--call-options-is-arbitrary-call", "Call any function", false) | |
| .option("--call-options-gas-limit", "The gas limit for the call", "500000") | |
| .option( | |
| "--function <function>", | |
| `Function to call (example: "hello(string)")` | |
| ) |
Comment bugbot run to trigger another review on this PR
Was this report helpful? Give feedback by reacting with 👍 or 👎
✅ Transaction sent: 0x7534ce013e1f5fae9972713600a4f7867e1e7a8656092aca2e831c8e73da8e05
✅ Transaction sent: 0xc81efd489f2d8a635ffc84e7cc46cef06de32d3aa826145698ae138d7419ff9c
✅ Transaction sent: 0xbab9478835229a29f02d88b23774ed3123b407f3a8075bdcec1443d988832476
✅ Transaction sent: 0xe9868c5128a9f466eb1898d4ba46232265c1410da8f09c5d14faa90aa8f67c81
✅ Transaction sent: 0xa9e1040a3c60ebc8f8d46671a5d0477f1882984cab73a70fd9e1c8ad2c2ec5e2
Updated to Ethers v6.
Should work with zeta-chain/cli#23
Not implemented yet: