@pasosdejesus/m 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. package/dist/blockchain/deployments.d.ts +40 -0
  2. package/dist/blockchain/deployments.d.ts.map +1 -0
  3. package/dist/blockchain/deployments.js +64 -0
  4. package/dist/debug/DebugConsole.d.ts +22 -0
  5. package/dist/debug/DebugConsole.d.ts.map +1 -0
  6. package/dist/debug/DebugConsole.js +79 -0
  7. package/dist/debug/Logger.d.ts +38 -0
  8. package/dist/debug/Logger.d.ts.map +1 -0
  9. package/dist/debug/Logger.js +94 -0
  10. package/dist/debug/index.d.ts +6 -0
  11. package/dist/debug/index.d.ts.map +1 -0
  12. package/dist/debug/index.js +4 -0
  13. package/dist/debug/useLogger.d.ts +14 -0
  14. package/dist/debug/useLogger.d.ts.map +1 -0
  15. package/dist/debug/useLogger.js +23 -0
  16. package/dist/debug/utils.d.ts +10 -0
  17. package/dist/debug/utils.d.ts.map +1 -0
  18. package/dist/debug/utils.js +53 -0
  19. package/dist/e2e/assertions.d.ts +5 -0
  20. package/dist/e2e/assertions.d.ts.map +1 -0
  21. package/dist/e2e/assertions.js +18 -0
  22. package/dist/e2e/browser.d.ts +37 -0
  23. package/dist/e2e/browser.d.ts.map +1 -0
  24. package/dist/e2e/browser.js +97 -0
  25. package/dist/e2e/env.d.ts +18 -0
  26. package/dist/e2e/env.d.ts.map +1 -0
  27. package/dist/e2e/env.js +57 -0
  28. package/dist/e2e/index.d.ts +11 -0
  29. package/dist/e2e/index.d.ts.map +1 -0
  30. package/dist/e2e/index.js +8 -0
  31. package/dist/e2e/navigation.d.ts +4 -0
  32. package/dist/e2e/navigation.d.ts.map +1 -0
  33. package/dist/e2e/navigation.js +32 -0
  34. package/dist/e2e/siwe-mock.d.ts +11 -0
  35. package/dist/e2e/siwe-mock.d.ts.map +1 -0
  36. package/dist/e2e/siwe-mock.js +112 -0
  37. package/dist/e2e/siwe.d.ts +15 -0
  38. package/dist/e2e/siwe.d.ts.map +1 -0
  39. package/dist/e2e/siwe.js +85 -0
  40. package/dist/e2e/wallet-mock.d.ts +13 -0
  41. package/dist/e2e/wallet-mock.d.ts.map +1 -0
  42. package/dist/e2e/wallet-mock.js +91 -0
  43. package/dist/i18n/common-cli.d.ts +11 -0
  44. package/dist/i18n/common-cli.d.ts.map +1 -0
  45. package/dist/i18n/common-cli.js +22 -0
  46. package/dist/i18n/createTranslator.d.ts +28 -0
  47. package/dist/i18n/createTranslator.d.ts.map +1 -0
  48. package/dist/i18n/createTranslator.js +48 -0
  49. package/dist/i18n/index.d.ts +4 -0
  50. package/dist/i18n/index.d.ts.map +1 -0
  51. package/dist/i18n/index.js +2 -0
  52. package/dist/i18n/locales/cli.d.ts +3 -0
  53. package/dist/i18n/locales/cli.d.ts.map +1 -0
  54. package/dist/i18n/locales/cli.js +180 -0
  55. package/dist/i18n/types.d.ts +3 -0
  56. package/dist/i18n/types.d.ts.map +1 -0
  57. package/dist/i18n/types.js +1 -0
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +15 -0
  61. package/dist/index.test.d.ts +2 -0
  62. package/dist/index.test.d.ts.map +1 -0
  63. package/dist/index.test.js +10 -0
  64. package/dist/m.d.ts +2 -0
  65. package/dist/m.d.ts.map +1 -0
  66. package/dist/m.js +334 -0
  67. package/dist/plugin.d.ts +10 -0
  68. package/dist/plugin.d.ts.map +1 -0
  69. package/dist/plugin.js +7 -0
  70. package/dist/shadcn_components/cn.d.ts +13 -0
  71. package/dist/shadcn_components/cn.d.ts.map +1 -0
  72. package/dist/shadcn_components/cn.js +15 -0
  73. package/dist/shadcn_components/ui/accordion.d.ts +8 -0
  74. package/dist/shadcn_components/ui/accordion.d.ts.map +1 -0
  75. package/dist/shadcn_components/ui/accordion.js +14 -0
  76. package/dist/shadcn_components/ui/alert-dialog.d.ts +21 -0
  77. package/dist/shadcn_components/ui/alert-dialog.d.ts.map +1 -0
  78. package/dist/shadcn_components/ui/alert-dialog.js +27 -0
  79. package/dist/shadcn_components/ui/alert.d.ts +9 -0
  80. package/dist/shadcn_components/ui/alert.d.ts.map +1 -0
  81. package/dist/shadcn_components/ui/alert.js +22 -0
  82. package/dist/shadcn_components/ui/avatar.d.ts +7 -0
  83. package/dist/shadcn_components/ui/avatar.d.ts.map +1 -0
  84. package/dist/shadcn_components/ui/avatar.js +12 -0
  85. package/dist/shadcn_components/ui/badge.d.ts +10 -0
  86. package/dist/shadcn_components/ui/badge.d.ts.map +1 -0
  87. package/dist/shadcn_components/ui/badge.js +22 -0
  88. package/dist/shadcn_components/ui/button.d.ts +11 -0
  89. package/dist/shadcn_components/ui/button.d.ts.map +1 -0
  90. package/dist/shadcn_components/ui/button.js +31 -0
  91. package/dist/shadcn_components/ui/card.d.ts +10 -0
  92. package/dist/shadcn_components/ui/card.d.ts.map +1 -0
  93. package/dist/shadcn_components/ui/card.js +24 -0
  94. package/dist/shadcn_components/ui/checkbox.d.ts +5 -0
  95. package/dist/shadcn_components/ui/checkbox.d.ts.map +1 -0
  96. package/dist/shadcn_components/ui/checkbox.js +9 -0
  97. package/dist/shadcn_components/ui/dialog.d.ts +20 -0
  98. package/dist/shadcn_components/ui/dialog.d.ts.map +1 -0
  99. package/dist/shadcn_components/ui/dialog.js +23 -0
  100. package/dist/shadcn_components/ui/dropdown-menu.d.ts +28 -0
  101. package/dist/shadcn_components/ui/dropdown-menu.d.ts.map +1 -0
  102. package/dist/shadcn_components/ui/dropdown-menu.js +36 -0
  103. package/dist/shadcn_components/ui/form.d.ts +24 -0
  104. package/dist/shadcn_components/ui/form.d.ts.map +1 -0
  105. package/dist/shadcn_components/ui/form.js +63 -0
  106. package/dist/shadcn_components/ui/input.d.ts +4 -0
  107. package/dist/shadcn_components/ui/input.d.ts.map +1 -0
  108. package/dist/shadcn_components/ui/input.js +6 -0
  109. package/dist/shadcn_components/ui/label.d.ts +6 -0
  110. package/dist/shadcn_components/ui/label.d.ts.map +1 -0
  111. package/dist/shadcn_components/ui/label.js +10 -0
  112. package/dist/shadcn_components/ui/menubar.d.ts +29 -0
  113. package/dist/shadcn_components/ui/menubar.d.ts.map +1 -0
  114. package/dist/shadcn_components/ui/menubar.js +46 -0
  115. package/dist/shadcn_components/ui/popover.d.ts +7 -0
  116. package/dist/shadcn_components/ui/popover.d.ts.map +1 -0
  117. package/dist/shadcn_components/ui/popover.js +10 -0
  118. package/dist/shadcn_components/ui/progress.d.ts +5 -0
  119. package/dist/shadcn_components/ui/progress.d.ts.map +1 -0
  120. package/dist/shadcn_components/ui/progress.js +8 -0
  121. package/dist/shadcn_components/ui/radio-group.d.ts +6 -0
  122. package/dist/shadcn_components/ui/radio-group.d.ts.map +1 -0
  123. package/dist/shadcn_components/ui/radio-group.js +15 -0
  124. package/dist/shadcn_components/ui/scroll-area.d.ts +6 -0
  125. package/dist/shadcn_components/ui/scroll-area.d.ts.map +1 -0
  126. package/dist/shadcn_components/ui/scroll-area.js +12 -0
  127. package/dist/shadcn_components/ui/select.d.ts +14 -0
  128. package/dist/shadcn_components/ui/select.d.ts.map +1 -0
  129. package/dist/shadcn_components/ui/select.js +27 -0
  130. package/dist/shadcn_components/ui/separator.d.ts +5 -0
  131. package/dist/shadcn_components/ui/separator.d.ts.map +1 -0
  132. package/dist/shadcn_components/ui/separator.js +8 -0
  133. package/dist/shadcn_components/ui/sheet.d.ts +26 -0
  134. package/dist/shadcn_components/ui/sheet.d.ts.map +1 -0
  135. package/dist/shadcn_components/ui/sheet.js +37 -0
  136. package/dist/shadcn_components/ui/skeleton.d.ts +3 -0
  137. package/dist/shadcn_components/ui/skeleton.d.ts.map +1 -0
  138. package/dist/shadcn_components/ui/skeleton.js +6 -0
  139. package/dist/shadcn_components/ui/slider.d.ts +5 -0
  140. package/dist/shadcn_components/ui/slider.d.ts.map +1 -0
  141. package/dist/shadcn_components/ui/slider.js +8 -0
  142. package/dist/shadcn_components/ui/switch.d.ts +5 -0
  143. package/dist/shadcn_components/ui/switch.d.ts.map +1 -0
  144. package/dist/shadcn_components/ui/switch.js +8 -0
  145. package/dist/shadcn_components/ui/table.d.ts +11 -0
  146. package/dist/shadcn_components/ui/table.d.ts.map +1 -0
  147. package/dist/shadcn_components/ui/table.js +20 -0
  148. package/dist/shadcn_components/ui/tabs.d.ts +8 -0
  149. package/dist/shadcn_components/ui/tabs.d.ts.map +1 -0
  150. package/dist/shadcn_components/ui/tabs.js +13 -0
  151. package/dist/shadcn_components/ui/textarea.d.ts +4 -0
  152. package/dist/shadcn_components/ui/textarea.d.ts.map +1 -0
  153. package/dist/shadcn_components/ui/textarea.js +8 -0
  154. package/dist/shadcn_components/ui/toast.d.ts +16 -0
  155. package/dist/shadcn_components/ui/toast.d.ts.map +1 -0
  156. package/dist/shadcn_components/ui/toast.js +34 -0
  157. package/dist/shadcn_components/ui/toaster.d.ts +2 -0
  158. package/dist/shadcn_components/ui/toaster.d.ts.map +1 -0
  159. package/dist/shadcn_components/ui/toaster.js +10 -0
  160. package/dist/shadcn_components/ui/tooltip.d.ts +8 -0
  161. package/dist/shadcn_components/ui/tooltip.d.ts.map +1 -0
  162. package/dist/shadcn_components/ui/tooltip.js +11 -0
  163. package/dist/shadcn_components/ui/use-toast.d.ts +45 -0
  164. package/dist/shadcn_components/ui/use-toast.d.ts.map +1 -0
  165. package/dist/shadcn_components/ui/use-toast.js +126 -0
  166. package/dist/tasks/context.d.ts +13 -0
  167. package/dist/tasks/context.d.ts.map +1 -0
  168. package/dist/tasks/context.js +310 -0
  169. package/dist/tasks/create.d.ts +2 -0
  170. package/dist/tasks/create.d.ts.map +1 -0
  171. package/dist/tasks/create.js +91 -0
  172. package/dist/tasks/db.d.ts +19 -0
  173. package/dist/tasks/db.d.ts.map +1 -0
  174. package/dist/tasks/db.js +791 -0
  175. package/dist/tasks/e2e.d.ts +2 -0
  176. package/dist/tasks/e2e.d.ts.map +1 -0
  177. package/dist/tasks/e2e.js +124 -0
  178. package/dist/tasks/edit.d.ts +7 -0
  179. package/dist/tasks/edit.d.ts.map +1 -0
  180. package/dist/tasks/edit.js +471 -0
  181. package/dist/tasks/engine.d.ts +2 -0
  182. package/dist/tasks/engine.d.ts.map +1 -0
  183. package/dist/tasks/engine.js +149 -0
  184. package/dist/tasks/env-diff.d.ts +2 -0
  185. package/dist/tasks/env-diff.d.ts.map +1 -0
  186. package/dist/tasks/env-diff.js +140 -0
  187. package/dist/tasks/fuzzy.d.ts +9 -0
  188. package/dist/tasks/fuzzy.d.ts.map +1 -0
  189. package/dist/tasks/fuzzy.js +153 -0
  190. package/dist/tasks/glob.d.ts +5 -0
  191. package/dist/tasks/glob.d.ts.map +1 -0
  192. package/dist/tasks/glob.js +57 -0
  193. package/dist/tasks/grep.d.ts +9 -0
  194. package/dist/tasks/grep.d.ts.map +1 -0
  195. package/dist/tasks/grep.js +93 -0
  196. package/dist/tasks/readfile.d.ts +2 -0
  197. package/dist/tasks/readfile.d.ts.map +1 -0
  198. package/dist/tasks/readfile.js +177 -0
  199. package/dist/tasks/update.d.ts +5 -0
  200. package/dist/tasks/update.d.ts.map +1 -0
  201. package/dist/tasks/update.js +200 -0
  202. package/dist/tasks/util.d.ts +12 -0
  203. package/dist/tasks/util.d.ts.map +1 -0
  204. package/dist/tasks/util.js +42 -0
  205. package/dist/tasks/wallet.d.ts +2 -0
  206. package/dist/tasks/wallet.d.ts.map +1 -0
  207. package/dist/tasks/wallet.js +697 -0
  208. package/dist/tasks/writefile.d.ts +2 -0
  209. package/dist/tasks/writefile.d.ts.map +1 -0
  210. package/dist/tasks/writefile.js +66 -0
  211. package/dist/templates/AGENTS.md.hbs +81 -0
  212. package/dist/templates/ARCHITECTURE.md.hbs +146 -0
  213. package/dist/templates/CONTRIBUTING.md.hbs +83 -0
  214. package/dist/templates/LICENCIA.md +21 -0
  215. package/dist/templates/LICENSE.md +15 -0
  216. package/dist/templates/Makefile +16 -0
  217. package/dist/templates/README.md.hbs +111 -0
  218. package/dist/templates/apps/.env.example.hbs +75 -0
  219. package/dist/templates/apps/hardhat/.prettierrc +16 -0
  220. package/dist/templates/apps/hardhat/MOCK_USDT_README.md +20 -0
  221. package/dist/templates/apps/hardhat/Makefile +13 -0
  222. package/dist/templates/apps/hardhat/README.md +129 -0
  223. package/dist/templates/apps/hardhat/bin/MusdtVerification +4 -0
  224. package/dist/templates/apps/hardhat/bin/approveDepositOwner +7 -0
  225. package/dist/templates/apps/hardhat/bin/contractVerification +9 -0
  226. package/dist/templates/apps/hardhat/bin/deployMockUSDT +7 -0
  227. package/dist/templates/apps/hardhat/bin/prepadJ.sh +14 -0
  228. package/dist/templates/apps/hardhat/bin/verifyMockUSDT +7 -0
  229. package/dist/templates/apps/hardhat/contracts/MockUSDT.sol +47 -0
  230. package/dist/templates/apps/hardhat/hardhat.config.ts +102 -0
  231. package/dist/templates/apps/hardhat/package.json +55 -0
  232. package/dist/templates/apps/hardhat/scripts/approveDepositOwner.ts +22 -0
  233. package/dist/templates/apps/hardhat/scripts/deployMockUSDT.ts +49 -0
  234. package/dist/templates/apps/hardhat/scripts/verifyDeployment.ts +93 -0
  235. package/dist/templates/apps/hardhat/scripts/verifyMockUSDT.ts +52 -0
  236. package/dist/templates/apps/hardhat/sync-abis.mjs +58 -0
  237. package/dist/templates/apps/hardhat/test/MockUSDT.test.ts +40 -0
  238. package/dist/templates/apps/hardhat/tsconfig.json +27 -0
  239. package/dist/templates/apps/nextjs/.config/kysely.config.ts +36 -0
  240. package/dist/templates/apps/nextjs/Makefile +24 -0
  241. package/dist/templates/apps/nextjs/README.md.hbs +76 -0
  242. package/dist/templates/apps/nextjs/abis/IERC20.json +74 -0
  243. package/dist/templates/apps/nextjs/abis/MockUSDT.json +242 -0
  244. package/dist/templates/apps/nextjs/abis/ReentrancyGuard.json +1 -0
  245. package/dist/templates/apps/nextjs/app/globals.css +3 -0
  246. package/dist/templates/apps/nextjs/app/layout.tsx.hbs +26 -0
  247. package/dist/templates/apps/nextjs/app/page.tsx.hbs +225 -0
  248. package/dist/templates/apps/nextjs/app/testui/page.tsx +371 -0
  249. package/dist/templates/apps/nextjs/bin/m +8 -0
  250. package/dist/templates/apps/nextjs/components.json +21 -0
  251. package/dist/templates/apps/nextjs/next-env.d.ts +5 -0
  252. package/dist/templates/apps/nextjs/next.config.ts +10 -0
  253. package/dist/templates/apps/nextjs/package.json.hbs +48 -0
  254. package/dist/templates/apps/nextjs/pnpm-workspace.yaml +13 -0
  255. package/dist/templates/apps/nextjs/postcss.config.mjs +6 -0
  256. package/dist/templates/apps/nextjs/tailwind.config.js +11 -0
  257. package/dist/templates/apps/nextjs/tests/helpers.ts +31 -0
  258. package/dist/templates/apps/nextjs/tests/index.test.ts +7 -0
  259. package/dist/templates/apps/nextjs/tests/setup-env.ts.hbs +8 -0
  260. package/dist/templates/apps/nextjs/tests/test-utils.example.test.ts +168 -0
  261. package/dist/templates/apps/nextjs/tsconfig.json +44 -0
  262. package/dist/templates/apps/nextjs/tsconfig.test.json +38 -0
  263. package/dist/templates/apps/nextjs/vitest.config.ts +13 -0
  264. package/dist/test-utils/fs-mocks.d.ts +32 -0
  265. package/dist/test-utils/fs-mocks.d.ts.map +1 -0
  266. package/dist/test-utils/fs-mocks.js +63 -0
  267. package/dist/test-utils/i18n-mock.d.ts +21 -0
  268. package/dist/test-utils/i18n-mock.d.ts.map +1 -0
  269. package/dist/test-utils/i18n-mock.js +29 -0
  270. package/dist/test-utils/index.d.ts +12 -0
  271. package/dist/test-utils/index.d.ts.map +1 -0
  272. package/dist/test-utils/index.js +11 -0
  273. package/dist/test-utils/kysely-mocks.d.ts +298 -0
  274. package/dist/test-utils/kysely-mocks.d.ts.map +1 -0
  275. package/dist/test-utils/kysely-mocks.js +173 -0
  276. package/dist/test-utils/radix-mocks.d.ts +134 -0
  277. package/dist/test-utils/radix-mocks.d.ts.map +1 -0
  278. package/dist/test-utils/radix-mocks.js +175 -0
  279. package/dist/test-utils/rainbowkit-mocks.d.ts +80 -0
  280. package/dist/test-utils/rainbowkit-mocks.d.ts.map +1 -0
  281. package/dist/test-utils/rainbowkit-mocks.js +247 -0
  282. package/dist/test-utils/viem-mocks.d.ts +86 -0
  283. package/dist/test-utils/viem-mocks.d.ts.map +1 -0
  284. package/dist/test-utils/viem-mocks.js +54 -0
  285. package/dist/util/cli-parser.d.ts +20 -0
  286. package/dist/util/cli-parser.d.ts.map +1 -0
  287. package/dist/util/cli-parser.js +38 -0
  288. package/dist/util/colors.d.ts +5 -0
  289. package/dist/util/colors.d.ts.map +1 -0
  290. package/dist/util/colors.js +5 -0
  291. package/dist/util/locale.d.ts +3 -0
  292. package/dist/util/locale.d.ts.map +1 -0
  293. package/dist/util/locale.js +10 -0
  294. package/dist/wba/client.d.ts +19 -0
  295. package/dist/wba/client.d.ts.map +1 -0
  296. package/dist/wba/client.js +31 -0
  297. package/dist/wba/index.d.ts +4 -0
  298. package/dist/wba/index.d.ts.map +1 -0
  299. package/dist/wba/index.js +2 -0
  300. package/dist/wba/routes/event.d.ts +32 -0
  301. package/dist/wba/routes/event.d.ts.map +1 -0
  302. package/dist/wba/routes/event.js +42 -0
  303. package/dist/wba/routes/index.d.ts +3 -0
  304. package/dist/wba/routes/index.d.ts.map +1 -0
  305. package/dist/wba/routes/index.js +2 -0
  306. package/dist/wba/routes/summary.d.ts +44 -0
  307. package/dist/wba/routes/summary.d.ts.map +1 -0
  308. package/dist/wba/routes/summary.js +146 -0
  309. package/dist/wba/server.d.ts +18 -0
  310. package/dist/wba/server.d.ts.map +1 -0
  311. package/dist/wba/server.js +29 -0
  312. package/dist/wba/types.d.ts +68 -0
  313. package/dist/wba/types.d.ts.map +1 -0
  314. package/dist/wba/types.js +6 -0
  315. package/package.json +223 -0
  316. package/src/blockchain/README.md +80 -0
  317. package/src/debug/README.md +94 -0
  318. package/src/e2e/README.md +105 -0
  319. package/src/i18n/README.md +143 -0
  320. package/src/shadcn_components/README.md +125 -0
  321. package/src/tasks/README.md +69 -0
  322. package/src/test-utils/README.md +638 -0
  323. package/src/util/README.md +18 -0
  324. package/src/wba/README.md +175 -0
@@ -0,0 +1,129 @@
1
+ # Learn.tg - Smart Contracts
2
+
3
+ This directory contains the Solidity smart contracts for the
4
+ platform, managed with Hardhat. These contracts handle ...
5
+
6
+ ## Overview
7
+
8
+ - **`MockUSDT.sol`**: A mock USDT contract for testing purposes in a
9
+ local or testnet environment.
10
+
11
+ ## Prerequisites
12
+
13
+ - [Node.js](https://nodejs.org/) (>= 18)
14
+ - [Yarn](https://yarnpkg.com/)
15
+ - A Celo-compatible wallet with test funds. You can get Sepolia Celo
16
+ tokens from the [Celo Faucet](https://faucet.celo.org/celo-sepolia).
17
+ To get test cCop use https://app.mento.org/
18
+
19
+ ## 1. Environment Configuration
20
+
21
+ First, create your environment file by copying the template:
22
+
23
+ ```sh
24
+ cp .env.example .env
25
+ ```
26
+
27
+ Next, edit the `.env` file with the following information:
28
+
29
+ - `NETWORK`: The network to deploy to. Use `celoSepolia` for the testnet
30
+ or `celo` for mainnet.
31
+ - `PRIVATE_KEY`: The private key of the wallet you will use for deployment.
32
+ - `BLOCKSCOUT_API_KEY`: Your API key from Blockscout for contract
33
+ verification. You can generate one in your account settings on the
34
+ [Celo Blockscout explorer](https://explorer.celo.org/).
35
+ - `DEPLOYED_AT`: This will hold the contract address after deployment.
36
+ Leave it blank for now.
37
+
38
+ **โš ๏ธ Security Warning:** Never use a wallet containing real funds for
39
+ development. Always generate and use a separate, dedicated wallet
40
+ for testing.
41
+
42
+ ## 2. Platform-Specific Setup (adJ / OpenBSD)
43
+
44
+ Due to compatibility issues, Hardhat v3 does not work on adJ/OpenBSD
45
+ as of 2025. This project is configured to use Hardhat v2. If you are on
46
+ this platform, you must first run the following script to prepare the
47
+ environment:
48
+
49
+ ```sh
50
+ bin/prepadJ.sh
51
+ ```
52
+
53
+ ## 3. Development Workflow
54
+
55
+ Follow these steps to compile, deploy, and verify your contracts.
56
+
57
+ ### Step 3.1: Install Dependencies
58
+
59
+ ```sh
60
+ yarn install
61
+ ```
62
+
63
+ ### Step 3.2: Compile Contracts
64
+
65
+ This command compiles the Solidity contracts and automatically syncs the
66
+ ABIs with the Next.js frontend.
67
+
68
+ ```sh
69
+ yarn build
70
+ ```
71
+
72
+ ### Step 3.3: Deploy the Contract
73
+
74
+ Make sure your deployment wallet is funded. Then, run the deployment
75
+ script:
76
+
77
+ ```sh
78
+ bin/deploy*
79
+ ```
80
+
81
+ The script will output the contract address to the console. **Copy
82
+ this address.**
83
+
84
+ ### Step 3.4: Update Environment File
85
+
86
+ Paste the copied contract address into the `DEPLOYED_AT` variable in
87
+ your `.env` file.
88
+
89
+ ### Step 3.5: Verify Contract on Blockscout
90
+
91
+ This step publishes and verifies the contract's source code on the
92
+ blockchain explorer, which is a crucial trust and security signal.
93
+
94
+ ```sh
95
+ bin/contractVerification
96
+ ```
97
+
98
+ ## 4. Testing
99
+
100
+ The project uses Hardhat's built-in testing framework with Chai matchers.
101
+ The tests are located in the `test/` directory.
102
+
103
+ To run the entire test suite, execute the following command:
104
+
105
+ ```sh
106
+ yarn test
107
+ ```
108
+
109
+ This will compile your contracts, run the tests in an in-memory Hardhat
110
+ Network, and report the results in the console.
111
+
112
+ ## ABI Synchronization
113
+
114
+ The contract ABIs (Application Binary Interfaces) are essential for the
115
+ frontend to interact with the smart contracts. This project is configured
116
+ to sync them automatically.
117
+
118
+ - **Automatic Sync:** ABIs are synced to `../nextjs/abis/` every time you
119
+ run `yarn build` (or `yarn compile`).
120
+ - **Manual Sync:** To sync the ABIs without recompiling, run
121
+ `yarn sync:abis`.
122
+
123
+
124
+ ## 5. Practices
125
+
126
+ * Prefer a multisig
127
+ * For a project with only one owner prefer a contract with transferOwner
128
+ https://metaschool.so/articles/account-ownership-in-solidity
129
+ and setBackendAddress
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ . .env
4
+ npx hardhat verify --network celoSepolia $MOCK_USDT_ADDRESS
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ # Load environment variables from the root .env file
4
+ . ../.env
5
+
6
+ # Run the script to approve the deposit owner
7
+ npx hardhat run scripts/approveDepositOwner.ts --network $NEXT_PUBLIC_NETWORK
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+
3
+ # Load environment variables from the root .env file
4
+ . ../.env
5
+
6
+ # Run the verification script, which will read the necessary variables
7
+ # from the environment.
8
+ # The network is specified via the NETWORK variable in the .env file.
9
+ npx hardhat run scripts/verifyDeployment.ts --network $NEXT_PUBLIC_NETWORK
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ # Load environment variables from the root .env file
4
+ . ../.env
5
+
6
+ # Run the deployment script for MockUSDT
7
+ npx hardhat run scripts/deployMockUSDT.ts --network $NEXT_PUBLIC_NETWORK
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+
3
+ yarn install
4
+ mkdir -p tmpart
5
+ sed -e "s/freebsd/openbsd/g" node_modules/@nomicfoundation/solidity-analyzer/index.js > tmpart/index-sa.js
6
+ cp tmpart/index-sa.js node_modules/@nomicfoundation/solidity-analyzer/index.js
7
+ cd node_modules/@nomicfoundation/solidity-analyzer/
8
+ doas corepack enable
9
+ yarn
10
+ yarn build
11
+ cd ../../..
12
+ yarn
13
+ cp tmpart/index-sa.js node_modules/@nomicfoundation/solidity-analyzer/index.js
14
+ yarn build
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ # Load environment variables from the root .env file
4
+ . ../.env
5
+
6
+ # Run the verification script for MockUSDT
7
+ npx hardhat run scripts/verifyMockUSDT.ts --network $NEXT_PUBLIC_NETWORK
@@ -0,0 +1,47 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.24;
3
+
4
+ contract MockUSDT {
5
+ string public constant name = "Mock USDT";
6
+ string public constant symbol = "MUSDT";
7
+ uint8 public constant decimals = 6;
8
+ uint256 public totalSupply;
9
+
10
+ mapping(address => uint256) public balanceOf;
11
+ mapping(address => mapping(address => uint256)) public allowance;
12
+
13
+ event Transfer(address indexed from, address indexed to, uint256 value);
14
+ event Approval(address indexed owner, address indexed spender, uint256 value);
15
+
16
+ function mint(address to, uint256 amount) external {
17
+ totalSupply += amount;
18
+ balanceOf[to] += amount;
19
+ emit Transfer(address(0), to, amount);
20
+ }
21
+
22
+ function transfer(address to, uint256 amount) external returns (bool) {
23
+ require(balanceOf[msg.sender] >= amount, "Insufficient balance");
24
+ balanceOf[msg.sender] -= amount;
25
+ balanceOf[to] += amount;
26
+ emit Transfer(msg.sender, to, amount);
27
+ return true;
28
+ }
29
+
30
+ function transferFrom(address from, address to, uint256 amount) external returns (bool) {
31
+ require(balanceOf[from] >= amount, "Insufficient balance");
32
+ require(allowance[from][msg.sender] >= amount, "Insufficient allowance");
33
+
34
+ balanceOf[from] -= amount;
35
+ balanceOf[to] += amount;
36
+ allowance[from][msg.sender] -= amount;
37
+
38
+ emit Transfer(from, to, amount);
39
+ return true;
40
+ }
41
+
42
+ function approve(address spender, uint256 amount) external returns (bool) {
43
+ allowance[msg.sender][spender] = amount;
44
+ emit Approval(msg.sender, spender, amount);
45
+ return true;
46
+ }
47
+ }
@@ -0,0 +1,102 @@
1
+ import '@nomicfoundation/hardhat-toolbox';
2
+ import '@nomicfoundation/hardhat-verify';
3
+ import { config as dotEnvConfig } from 'dotenv';
4
+ import { HardhatUserConfig } from 'hardhat/config';
5
+ import { task } from "hardhat/config";
6
+ import { task } from "hardhat/config";
7
+
8
+
9
+ dotEnvConfig({ path: '../.env' });
10
+
11
+
12
+ task("check-transfer", "Check token transfer from tx hash")
13
+ .addParam("tx", "Transaction hash")
14
+ .addParam("token", "Token contract address")
15
+ .setAction(async (taskArgs, hre) => {
16
+ const { ethers } = hre;
17
+ const { tx, token } = taskArgs;
18
+
19
+ const receipt = await ethers.provider.getTransactionReceipt(tx);
20
+ if (!receipt) {
21
+ console.log("Transaction not found");
22
+ return;
23
+ }
24
+
25
+ const TokenABI = [
26
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
27
+ "function decimals() view returns (uint8)"
28
+ ];
29
+
30
+ const tokenContract = new ethers.Contract(token, TokenABI, ethers.provider);
31
+ const decimals = await tokenContract.decimals();
32
+
33
+ const transferEventTopic = ethers.id("Transfer(address,address,uint256)");
34
+ const transferLogs = receipt.logs.filter(log => log.topics[0] === transferEventTopic);
35
+
36
+ if (transferLogs.length === 0) {
37
+ console.log("No Transfer event found");
38
+ return;
39
+ }
40
+
41
+ for (const log of transferLogs) {
42
+ const parsedLog = tokenContract.interface.parseLog(log);
43
+ console.log("Amount:", ethers.formatUnits(parsedLog.args.value, decimals));
44
+ }
45
+ });
46
+
47
+ const config: HardhatUserConfig = {
48
+ networks: {
49
+ celo: {
50
+ accounts: [process.env.PRIVATE_KEY ?? '0x0'],
51
+ url: 'https://forno.celo.org',
52
+ },
53
+ celoSepolia: {
54
+ accounts: [process.env.PRIVATE_KEY ?? '0x0'],
55
+ url: 'https://forno.celo-sepolia.celo-testnet.org/',
56
+ },
57
+
58
+ 'base-sepolia': {
59
+ accounts: [process.env.PRIVATE_KEY ?? '0x0'],
60
+ url: 'https://sepolia.base.org',
61
+ },
62
+ },
63
+ etherscan: {
64
+ apiKey: {
65
+ celoSepolia: process.env.BLOCKSCOUT_API_KEY ?? '',
66
+ celo: process.env.BLOCKSCOUT_API_KEY ?? '',
67
+ 'base-sepolia': process.env.BASESCAN_API_KEY ?? '',
68
+ },
69
+ customChains: [
70
+ {
71
+ network: 'celoSepolia',
72
+ chainId: 11_142_220,
73
+ urls: {
74
+ apiURL: 'https://celo-sepolia.blockscout.com/api',
75
+ browserURL: 'https://celo-sepolia.blockscout.com/',
76
+ },
77
+ },
78
+ {
79
+ chainId: 42_220,
80
+ network: 'celo',
81
+ urls: {
82
+ apiURL: 'https://celo.blockscout.com/api',
83
+ browserURL: 'https://celo.blockscout.com/',
84
+ },
85
+ },
86
+ {
87
+ chainId: 84532,
88
+ network: 'base-sepolia',
89
+ urls: {
90
+ apiURL: 'https://api-sepolia.basescan.org/api',
91
+ browserURL: 'https://sepolia.basescan.org/',
92
+ },
93
+ },
94
+ ],
95
+ },
96
+ sourcify: {
97
+ enabled: false,
98
+ },
99
+ solidity: '0.8.24',
100
+ };
101
+
102
+ export default config;
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@stable-sl/hardhat",
3
+ "license": "MIT",
4
+ "version": "1.0.0",
5
+ "devDependencies": {
6
+ "@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
7
+ "@nomicfoundation/hardhat-ethers": "^3.0.0",
8
+ "@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
9
+ "@nomicfoundation/hardhat-network-helpers": "^1.0.11",
10
+ "@nomicfoundation/hardhat-toolbox": "^5.0.0",
11
+ "@nomicfoundation/hardhat-verify": "^2.0.11",
12
+ "@nomiclabs/hardhat-ethers": "^2.2.3",
13
+ "@typechain/ethers-v6": "^0.5.0",
14
+ "@typechain/hardhat": "^9.1.0",
15
+ "@types/chai": "^5.2.3",
16
+ "@types/mocha": "^10.0.7",
17
+ "chai": "^4.2.0",
18
+ "ethers": "^6.15.0",
19
+ "hardhat": ">=2.27.0 <3.0.0",
20
+ "hardhat-gas-reporter": "^2.3.0",
21
+ "minimatch": "^10.1.1",
22
+ "solidity-coverage": "^0.8.1",
23
+ "ts-node": "^10.9.2",
24
+ "typechain": "^8.3.2",
25
+ "tsx": "^4.21.0",
26
+ "typescript": "^5.5.3"
27
+ },
28
+ "dependencies": {
29
+ "@nomicfoundation/hardhat-ignition": "0.15.0",
30
+ "@openzeppelin/contracts": "^5.4.0",
31
+ "dotenv": "^17.2.3",
32
+ "viem": "^2.40.0"
33
+ },
34
+ "scripts": {
35
+ "postinstall": "chmod +x sync-abis.mjs",
36
+ "compile": "hardhat clean && hardhat compile && node sync-abis.mjs",
37
+ "tsc": "node_modules/.bin/tsc -p . && mkdir -p dist/typechain-types/ && cp typechain-types/*.d.ts dist/typechain-types/",
38
+ "build": "pnpm compile && pnpm tsc",
39
+ "clean": "hardhat clean",
40
+ "run:node": "hardhat node",
41
+ "test": "hardhat test",
42
+ "deploy": "bin/deployLearnTGVaults",
43
+ "verify": "bin/verifyLearnTGVaults",
44
+ "contract-verification": "bin/contractVerification",
45
+ "deploy-mock-usdt": "bin/deployMockUsdt",
46
+ "verify-mock-usdt": "bin/verifyMockUSDT",
47
+ "deploy-celoubi": "bin/deployCeloUbi",
48
+ "verify-celoubi": "bin/verifyCeloUbi",
49
+ "contract-verification-celoubi": "bin/contractVerificationCeloUbi",
50
+ "prettier": "prettier --write 'contracts/**/*.sol' '**/*.ts'",
51
+ "sync:abis": "node sync-abis.mjs"
52
+ },
53
+ "author": "pasosdeJesus",
54
+ "packageManager": "pnpm@10.34.5"
55
+ }
@@ -0,0 +1,22 @@
1
+ import { ethers } from "hardhat";
2
+
3
+ async function main() {
4
+ // Get signers
5
+ const [deployer] = await ethers.getSigners();
6
+
7
+ // Attach to existing ERC-20 token contract
8
+ const tokenAddress = process.env.USDT_ADDRES;
9
+ const TokenABI = ["function approve(address spender, uint256 amount) returns (bool)"];
10
+ const token = new ethers.Contract(tokenAddress, TokenABI, deployer);
11
+
12
+ const spenderAddress = process.env.DEPLOYED_ADDRESS;
13
+
14
+ // Approve 1 token (adjust decimals as needed)
15
+ const amount = ethers.parseUnits("1000", 18);
16
+
17
+ console.log("Approving...");
18
+ const tx = await token.approve(spenderAddress, amount);
19
+ await tx.wait();
20
+
21
+ console.log("Approved! Transaction hash:", tx.hash);
22
+ }
@@ -0,0 +1,49 @@
1
+ import { ethers } from "hardhat";
2
+
3
+ async function main() {
4
+ // Get the contract factory for MockUSDT
5
+ const MockUSDT = await ethers.getContractFactory("MockUSDT");
6
+
7
+ console.log("Deploying MockUSDT token...");
8
+
9
+ // Deploy the contract
10
+ const mockUSDT = await MockUSDT.deploy();
11
+
12
+ // Wait for the deployment transaction to be mined
13
+ await mockUSDT.waitForDeployment();
14
+
15
+ const mockUSDTAddress = await mockUSDT.getAddress();
16
+ console.log("MockUSDT deployed to:", mockUSDTAddress);
17
+
18
+ // Mint 1,000,000 tokens to the deployer (owner)
19
+ // USDT has 6 decimals, so we need to multiply by 10^6
20
+ const deployer = (await ethers.getSigners())[0];
21
+ const deployerAddress = await deployer.getAddress();
22
+ const amount = ethers.parseUnits("10000000000", 6); // 10,000,000,000 tokens with 6 decimals
23
+
24
+ console.log("Minting 10,000,000,000 tokens to:", deployerAddress);
25
+ const tx = await mockUSDT.mint(deployerAddress, amount);
26
+ await tx.wait();
27
+
28
+ console.log("Minted 10,000,000,000 tokens to the owner's account");
29
+
30
+ // Verify the balance
31
+ const balance = await mockUSDT.balanceOf(deployerAddress);
32
+ console.log("Owner's balance:", ethers.formatUnits(balance, 6), "MUSDT");
33
+
34
+ // Also check the total supply
35
+ const totalSupply = await mockUSDT.totalSupply();
36
+ console.log("Total supply:", ethers.formatUnits(totalSupply, 6), "MUSDT");
37
+
38
+ // Save the deployment address to .env file
39
+ console.log("Deployment completed successfully!");
40
+ console.log("Add this line to your .env file:");
41
+ console.log(`MOCK_USDT_ADDRESS="${mockUSDTAddress}"`);
42
+ }
43
+
44
+ // We recommend this pattern to be able to use async/await everywhere
45
+ // and properly handle errors.
46
+ main().catch((error) => {
47
+ console.error(error);
48
+ process.exitCode = 1;
49
+ });
@@ -0,0 +1,93 @@
1
+ import { ethers } from "hardhat";
2
+ import dotenv from "dotenv"
3
+ dotenv.config({ path: '../.env' })
4
+
5
+ async function main() {
6
+ // Get the deployed contract
7
+ const learnTGVaults = await ethers.getContractAt(
8
+ "LearnTGVaults",
9
+ process.env.NEXT_PUBLIC_DEPLOYED_AT // The deployed address
10
+ );
11
+ console.log("๐Ÿ“œ LearnTGVaults Verification");
12
+ console.log("=============================");
13
+ console.log("Contract address:", process.env.NEXT_PUBLIC_DEPLOYED_AT);
14
+
15
+ // Get the owner of the contract
16
+ const owner = await learnTGVaults.owner();
17
+ console.log("\n๐Ÿ‘ค Contract owner:", owner);
18
+
19
+ // Get the USDT token address that the contract was initialized with
20
+ const usdtToken = await learnTGVaults.usdtToken();
21
+ console.log("๐Ÿ’ฐ Contract USDT token address:", usdtToken);
22
+
23
+ // Get the cCop token address that the contract was initialized with
24
+ const cCopToken = await learnTGVaults.cCopToken();
25
+ console.log("๐Ÿ”ถ Contract cCop token address:", cCopToken);
26
+
27
+ // Get the gooddollar token address that the contract was initialized with
28
+ const gooddollarToken = await learnTGVaults.gooddollarToken();
29
+ console.log("๐Ÿ’Ž Contract gooddollar token address:", gooddollarToken);
30
+
31
+ // Get provider
32
+ const provider = ethers.provider;
33
+
34
+ // Get USDT contract instance
35
+ const usdtContract = await ethers.getContractAt("IERC20", usdtToken);
36
+ const usdtDecimals = process.env.NEXT_PUBLIC_USDT_DECIMALS ? parseInt(process.env.NEXT_PUBLIC_USDT_DECIMALS) : 6;
37
+
38
+ console.log("\n๐Ÿ“Š Balance Verification");
39
+ console.log("=====================");
40
+
41
+ // 1. Check contract USDT balance
42
+ const contractUSDTBalance = await usdtContract.balanceOf(learnTGVaults.target);
43
+ const formattedContractUSDT = ethers.formatUnits(contractUSDTBalance, usdtDecimals);
44
+ console.log(`1. LearnTGVaults USDT balance: ${formattedContractUSDT} USDT`);
45
+
46
+ // 2. Check contract CELO balance
47
+ const contractCELOBalance = await provider.getBalance(learnTGVaults.target);
48
+ const formattedContractCELO = ethers.formatEther(contractCELOBalance);
49
+ console.log(`2. LearnTGVaults CELO balance: ${formattedContractCELO} CELO`);
50
+
51
+ // 3. Check owner USDT balance
52
+ const ownerUSDTBalance = await usdtContract.balanceOf(owner);
53
+ const formattedOwnerUSDT = ethers.formatUnits(ownerUSDTBalance, usdtDecimals);
54
+ console.log(`3. Owner USDT balance: ${formattedOwnerUSDT} USDT`);
55
+
56
+ // 4. Check owner CELO balance
57
+ const ownerCELOBalance = await provider.getBalance(owner);
58
+ const formattedOwnerCELO = ethers.formatEther(ownerCELOBalance);
59
+ console.log(`4. Owner CELO balance: ${formattedOwnerCELO} CELO`);
60
+
61
+ // 5. Check deployer account (from private key) balances if available
62
+ if (process.env.PRIVATE_KEY) {
63
+ const deployerWallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
64
+ const deployerAddress = deployerWallet.address;
65
+ const deployerUSDTBalance = await usdtContract.balanceOf(deployerAddress);
66
+ const deployerCELOBalance = await provider.getBalance(deployerAddress);
67
+ console.log(`\n๐Ÿ”‘ Deployer account (from PRIVATE_KEY):`);
68
+ console.log(` Address: ${deployerAddress}`);
69
+ console.log(` USDT: ${ethers.formatUnits(deployerUSDTBalance, usdtDecimals)} USDT`);
70
+ console.log(` CELO: ${ethers.formatEther(deployerCELOBalance)} CELO`);
71
+ }
72
+
73
+ // 6. Check old Hardhat account #0 (common test account)
74
+ const hardhatAccount0 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
75
+ const hardhatUSDTBalance = await usdtContract.balanceOf(hardhatAccount0);
76
+ const hardhatCELOBalance = await provider.getBalance(hardhatAccount0);
77
+ console.log(`\n๐Ÿงช Hardhat account #0 (common test):`);
78
+ console.log(` Address: ${hardhatAccount0}`);
79
+ console.log(` USDT: ${ethers.formatUnits(hardhatUSDTBalance, usdtDecimals)} USDT`);
80
+ console.log(` CELO: ${ethers.formatEther(hardhatCELOBalance)} CELO`);
81
+
82
+ console.log("\nโœ… Contract deployed and verified successfully!");
83
+ console.log("\n๐Ÿ“‹ Summary:");
84
+ console.log(" โ€ข LearnTGVaults contract is deployed and accessible");
85
+ console.log(" โ€ข Verify contract has sufficient USDT for rewards");
86
+ console.log(" โ€ข Verify contract has CELO for gas (if needed)");
87
+ console.log(" โ€ข Owner and deployer accounts should have CELO for operations");
88
+ }
89
+
90
+ main().catch((error) => {
91
+ console.error(error);
92
+ process.exitCode = 1;
93
+ });
@@ -0,0 +1,52 @@
1
+ import { ethers } from "hardhat";
2
+
3
+ async function main() {
4
+ // Get the MockUSDT address from environment variables
5
+ const mockUSDTAddress = process.env.MOCK_USDT_ADDRESS;
6
+
7
+ if (!mockUSDTAddress) {
8
+ throw new Error("MOCK_USDT_ADDRESS not found in environment variables");
9
+ }
10
+
11
+ // Get the contract factory for MockUSDT
12
+ const MockUSDT = await ethers.getContractFactory("MockUSDT");
13
+
14
+ // Connect to the deployed contract
15
+ const mockUSDT = MockUSDT.attach(mockUSDTAddress);
16
+
17
+ console.log("Verifying MockUSDT deployment at:", mockUSDTAddress);
18
+
19
+ // Check token details
20
+ const name = await mockUSDT.name();
21
+ const symbol = await mockUSDT.symbol();
22
+ const decimals = await mockUSDT.decimals();
23
+ const totalSupply = await mockUSDT.totalSupply();
24
+
25
+ console.log("Token Name:", name);
26
+ console.log("Token Symbol:", symbol);
27
+ console.log("Decimals:", decimals);
28
+ console.log("Total Supply:", ethers.formatUnits(totalSupply, decimals), symbol);
29
+
30
+ // Check owner's balance
31
+ const deployer = (await ethers.getSigners())[0];
32
+ const deployerAddress = await deployer.getAddress();
33
+ const balance = await mockUSDT.balanceOf(deployerAddress);
34
+
35
+ console.log("Owner Address:", deployerAddress);
36
+ console.log("Owner Balance:", ethers.formatUnits(balance, decimals), symbol);
37
+
38
+ // Verify that the owner has tokens
39
+ const expectedBalance = ethers.parseUnits("10000000000", decimals);
40
+ if (balance > 0) {
41
+ console.log("โœ“ Verification successful: Owner has tokens");
42
+ } else {
43
+ console.log("โœ— Verification failed: Owner does not have the expected balance");
44
+ }
45
+ }
46
+
47
+ // We recommend this pattern to be able to use async/await everywhere
48
+ // and properly handle errors.
49
+ main().catch((error) => {
50
+ console.error(error);
51
+ process.exitCode = 1;
52
+ });
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'fs'
4
+ import path from 'path'
5
+
6
+ // Configuration - directory files
7
+ const HARDHAT_ARTIFACTS_PATH = './artifacts/contracts'
8
+ const NEXTJS_ABI_PATH = '../nextjs/abis'
9
+
10
+ // Create the React ABI directory if it doesn't exist
11
+ if (!fs.existsSync(NEXTJS_ABI_PATH)) {
12
+ fs.mkdirSync(NEXTJS_ABI_PATH, { recursive: true })
13
+ }
14
+
15
+ // Function to walk through directories recursively
16
+ function walkDir(dir) {
17
+ let results = []
18
+ const list = fs.readdirSync(dir)
19
+ list.forEach(file => {
20
+ const filePath = path.join(dir, file)
21
+ const stat = fs.statSync(filePath)
22
+ if (stat && stat.isDirectory()) {
23
+ results = results.concat(walkDir(filePath))
24
+ } else {
25
+ // Ensure we only grab the main contract JSON, not the debug files
26
+ if (file.endsWith('.json') && !file.includes('.dbg.')) {
27
+ results.push(filePath)
28
+ }
29
+ }
30
+ })
31
+ return results
32
+ }
33
+
34
+ // Main script
35
+ console.log("๐Ÿ”„ Syncing ABIs to the frontend app...")
36
+
37
+ try {
38
+ // Find all artifact JSON files from Hardhat compilation
39
+ const artifactFiles = walkDir(HARDHAT_ARTIFACTS_PATH)
40
+
41
+ artifactFiles.forEach(filepath => {
42
+ // Read and parse the artifact file
43
+ const artifact = JSON.parse(fs.readFileSync(filepath, 'utf8'))
44
+ const filename = path.basename(filepath)
45
+ const contractName = filename.replace('.json', '')
46
+
47
+ // Extract just the ABI and save it to the Next.js directory
48
+ const abiPath = path.join(NEXTJS_ABI_PATH, `${contractName}.json`)
49
+ fs.writeFileSync(abiPath, JSON.stringify(artifact.abi, null, 2))
50
+ console.log(`Copied ABI for ${contractName}`)
51
+ })
52
+
53
+ console.log("โœ… ABI sync complete!")
54
+
55
+ } catch (error) {
56
+ console.error("โŒ Error syncing ABIs:", error)
57
+ process.exit(1)
58
+ }