create-stylus 1.1.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 (222) hide show
  1. package/.github/issue_template.md +7 -0
  2. package/.github/pull_request_template.md +11 -0
  3. package/.github/workflows/release-alpha.yml +32 -0
  4. package/.yarnrc.yml +1 -0
  5. package/CONTRIBUTING.md +42 -0
  6. package/README.md +66 -0
  7. package/bin/create-dapp-ss.js +4 -0
  8. package/dist/cli.js +656 -0
  9. package/dist/cli.js.map +1 -0
  10. package/package.json +46 -0
  11. package/rollup.config.js +22 -0
  12. package/src/cli.ts +14 -0
  13. package/src/extensions.json +14 -0
  14. package/src/main.ts +70 -0
  15. package/src/tasks/copy-extension-file.ts +227 -0
  16. package/src/tasks/copy-template-files.ts +252 -0
  17. package/src/tasks/create-first-git-commit.ts +35 -0
  18. package/src/tasks/create-project-directory.ts +34 -0
  19. package/src/tasks/index.ts +5 -0
  20. package/src/tasks/install-packages.ts +15 -0
  21. package/src/tasks/prettier-format.ts +17 -0
  22. package/src/types.ts +31 -0
  23. package/src/utils/consts.ts +1 -0
  24. package/src/utils/find-files-recursively.ts +19 -0
  25. package/src/utils/link.ts +44 -0
  26. package/src/utils/load-extensions.ts +10 -0
  27. package/src/utils/merge-package-json.ts +33 -0
  28. package/src/utils/parse-arguments-into-options.ts +38 -0
  29. package/src/utils/prompt-for-missing-options.ts +53 -0
  30. package/src/utils/render-intro-message.ts +11 -0
  31. package/src/utils/render-outro-message.ts +34 -0
  32. package/templates/base/.github/ISSUE_TEMPLATE/bug_report.yml +58 -0
  33. package/templates/base/.github/ISSUE_TEMPLATE/config.yml +8 -0
  34. package/templates/base/.github/pull_request_template.md +16 -0
  35. package/templates/base/.github/workflows/lint.yaml +300 -0
  36. package/templates/base/.gitignore.template.mjs +19 -0
  37. package/templates/base/.gitmodules +0 -0
  38. package/templates/base/.husky/pre-commit +4 -0
  39. package/templates/base/.lintstagedrc.js +21 -0
  40. package/templates/base/.vscode/settings.json +7 -0
  41. package/templates/base/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
  42. package/templates/base/.yarn/releases/yarn-3.2.3.cjs +783 -0
  43. package/templates/base/.yarnrc.yml +11 -0
  44. package/templates/base/CONTRIBUTING.md +86 -0
  45. package/templates/base/LICENCE +21 -0
  46. package/templates/base/nitro-devnode/LICENSE +201 -0
  47. package/templates/base/nitro-devnode/README.md +70 -0
  48. package/templates/base/nitro-devnode/run-dev-node.sh +132 -0
  49. package/templates/base/nitro-devnode/start-chain-with-cors.sh +150 -0
  50. package/templates/base/nitro-devnode/stylus-deployer-bytecode.txt +1 -0
  51. package/templates/base/nitro-devnode/stylus-dev/Dockerfile +10 -0
  52. package/templates/base/package.json +43 -0
  53. package/templates/base/packages/nextjs/.env.example +13 -0
  54. package/templates/base/packages/nextjs/.eslintignore +11 -0
  55. package/templates/base/packages/nextjs/.eslintrc.json +15 -0
  56. package/templates/base/packages/nextjs/.gitignore.template.mjs +42 -0
  57. package/templates/base/packages/nextjs/.prettierrc.js +9 -0
  58. package/templates/base/packages/nextjs/.prettierrc.json +8 -0
  59. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressCodeTab.tsx +27 -0
  60. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressComponent.tsx +36 -0
  61. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressLogsTab.tsx +21 -0
  62. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressStorageTab.tsx +61 -0
  63. package/templates/base/packages/nextjs/app/blockexplorer/_components/BackButton.tsx +12 -0
  64. package/templates/base/packages/nextjs/app/blockexplorer/_components/ContractTabs.tsx +102 -0
  65. package/templates/base/packages/nextjs/app/blockexplorer/_components/PaginationButton.tsx +39 -0
  66. package/templates/base/packages/nextjs/app/blockexplorer/_components/SearchBar.tsx +49 -0
  67. package/templates/base/packages/nextjs/app/blockexplorer/_components/TransactionHash.tsx +28 -0
  68. package/templates/base/packages/nextjs/app/blockexplorer/_components/TransactionsTable.tsx +71 -0
  69. package/templates/base/packages/nextjs/app/blockexplorer/_components/index.tsx +7 -0
  70. package/templates/base/packages/nextjs/app/blockexplorer/address/[address]/page.tsx +101 -0
  71. package/templates/base/packages/nextjs/app/blockexplorer/layout.tsx +12 -0
  72. package/templates/base/packages/nextjs/app/blockexplorer/page.tsx +83 -0
  73. package/templates/base/packages/nextjs/app/blockexplorer/transaction/[txHash]/page.tsx +23 -0
  74. package/templates/base/packages/nextjs/app/blockexplorer/transaction/_components/TransactionComp.tsx +152 -0
  75. package/templates/base/packages/nextjs/app/debug/_components/DebugContracts.tsx +73 -0
  76. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractInput.tsx +84 -0
  77. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractReadMethods.tsx +43 -0
  78. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractUI.tsx +164 -0
  79. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractVariables.tsx +50 -0
  80. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractWriteMethods.tsx +49 -0
  81. package/templates/base/packages/nextjs/app/debug/_components/contract/DisplayVariable.tsx +85 -0
  82. package/templates/base/packages/nextjs/app/debug/_components/contract/InheritanceTooltip.tsx +14 -0
  83. package/templates/base/packages/nextjs/app/debug/_components/contract/ReadOnlyFunctionForm.tsx +102 -0
  84. package/templates/base/packages/nextjs/app/debug/_components/contract/Tuple.tsx +44 -0
  85. package/templates/base/packages/nextjs/app/debug/_components/contract/TupleArray.tsx +142 -0
  86. package/templates/base/packages/nextjs/app/debug/_components/contract/TxReceipt.tsx +42 -0
  87. package/templates/base/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx +144 -0
  88. package/templates/base/packages/nextjs/app/debug/_components/contract/index.tsx +8 -0
  89. package/templates/base/packages/nextjs/app/debug/_components/contract/utilsContract.tsx +166 -0
  90. package/templates/base/packages/nextjs/app/debug/_components/contract/utilsDisplay.tsx +114 -0
  91. package/templates/base/packages/nextjs/app/debug/page.tsx +14 -0
  92. package/templates/base/packages/nextjs/app/layout.tsx +67 -0
  93. package/templates/base/packages/nextjs/app/not-found.tsx +16 -0
  94. package/templates/base/packages/nextjs/app/page.tsx +94 -0
  95. package/templates/base/packages/nextjs/components/Background.tsx +37 -0
  96. package/templates/base/packages/nextjs/components/Card.tsx +40 -0
  97. package/templates/base/packages/nextjs/components/Footer.tsx +93 -0
  98. package/templates/base/packages/nextjs/components/Header.tsx +114 -0
  99. package/templates/base/packages/nextjs/components/ScaffoldEthAppWithProviders.tsx +77 -0
  100. package/templates/base/packages/nextjs/components/SwitchTheme.tsx +41 -0
  101. package/templates/base/packages/nextjs/components/ThemeProvider.tsx +13 -0
  102. package/templates/base/packages/nextjs/components/assets/BuidlGuidlLogo.tsx +18 -0
  103. package/templates/base/packages/nextjs/components/scaffold-eth/Address/Address.tsx +187 -0
  104. package/templates/base/packages/nextjs/components/scaffold-eth/Address/AddressCopyIcon.tsx +23 -0
  105. package/templates/base/packages/nextjs/components/scaffold-eth/Address/AddressLinkWrapper.tsx +29 -0
  106. package/templates/base/packages/nextjs/components/scaffold-eth/Balance.tsx +75 -0
  107. package/templates/base/packages/nextjs/components/scaffold-eth/BlockieAvatar.tsx +17 -0
  108. package/templates/base/packages/nextjs/components/scaffold-eth/Faucet.tsx +131 -0
  109. package/templates/base/packages/nextjs/components/scaffold-eth/FaucetButton.tsx +75 -0
  110. package/templates/base/packages/nextjs/components/scaffold-eth/Input/AddressInput.tsx +120 -0
  111. package/templates/base/packages/nextjs/components/scaffold-eth/Input/Bytes32Input.tsx +31 -0
  112. package/templates/base/packages/nextjs/components/scaffold-eth/Input/BytesInput.tsx +28 -0
  113. package/templates/base/packages/nextjs/components/scaffold-eth/Input/EtherInput.tsx +128 -0
  114. package/templates/base/packages/nextjs/components/scaffold-eth/Input/InputBase.tsx +66 -0
  115. package/templates/base/packages/nextjs/components/scaffold-eth/Input/IntegerInput.tsx +63 -0
  116. package/templates/base/packages/nextjs/components/scaffold-eth/Input/index.ts +9 -0
  117. package/templates/base/packages/nextjs/components/scaffold-eth/Input/utils.ts +109 -0
  118. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/AddressInfoDropdown.tsx +121 -0
  119. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/AddressQRCodeModal.tsx +33 -0
  120. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/BurnerWalletModal.tsx +63 -0
  121. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx +48 -0
  122. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/WrongNetworkDropdown.tsx +32 -0
  123. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx +89 -0
  124. package/templates/base/packages/nextjs/components/scaffold-eth/index.tsx +7 -0
  125. package/templates/base/packages/nextjs/contracts/deployedContracts.ts +9 -0
  126. package/templates/base/packages/nextjs/contracts/externalContracts.ts +16 -0
  127. package/templates/base/packages/nextjs/eslint.config.mjs +32 -0
  128. package/templates/base/packages/nextjs/hooks/scaffold-eth/index.ts +17 -0
  129. package/templates/base/packages/nextjs/hooks/scaffold-eth/useAnimationConfig.ts +20 -0
  130. package/templates/base/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts +40 -0
  131. package/templates/base/packages/nextjs/hooks/scaffold-eth/useCopyToClipboard.ts +19 -0
  132. package/templates/base/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts +86 -0
  133. package/templates/base/packages/nextjs/hooks/scaffold-eth/useDisplayUsdMode.ts +21 -0
  134. package/templates/base/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts +133 -0
  135. package/templates/base/packages/nextjs/hooks/scaffold-eth/useInitializeNativeCurrencyPrice.ts +32 -0
  136. package/templates/base/packages/nextjs/hooks/scaffold-eth/useNativeCurrencyPrice.ts +34 -0
  137. package/templates/base/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts +22 -0
  138. package/templates/base/packages/nextjs/hooks/scaffold-eth/useOutsideClick.ts +23 -0
  139. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts +65 -0
  140. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts +213 -0
  141. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts +80 -0
  142. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts +40 -0
  143. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts +191 -0
  144. package/templates/base/packages/nextjs/hooks/scaffold-eth/useSelectedNetwork.ts +18 -0
  145. package/templates/base/packages/nextjs/hooks/scaffold-eth/useTargetNetwork.ts +23 -0
  146. package/templates/base/packages/nextjs/hooks/scaffold-eth/useTransactor.tsx +114 -0
  147. package/templates/base/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts +21 -0
  148. package/templates/base/packages/nextjs/icons/CompassIcon.tsx +39 -0
  149. package/templates/base/packages/nextjs/icons/DarkBugAntIcon.tsx +30 -0
  150. package/templates/base/packages/nextjs/icons/LightBugAntIcon.tsx +52 -0
  151. package/templates/base/packages/nextjs/next-env.d.ts +5 -0
  152. package/templates/base/packages/nextjs/next.config.js +19 -0
  153. package/templates/base/packages/nextjs/package.json +58 -0
  154. package/templates/base/packages/nextjs/postcss.config.js +6 -0
  155. package/templates/base/packages/nextjs/public/debug-image.png +0 -0
  156. package/templates/base/packages/nextjs/public/favicon.png +0 -0
  157. package/templates/base/packages/nextjs/public/logo.svg +8 -0
  158. package/templates/base/packages/nextjs/public/manifest.json +5 -0
  159. package/templates/base/packages/nextjs/public/thumbnail.jpg +0 -0
  160. package/templates/base/packages/nextjs/react-copy-to-clipboard.d.ts +44 -0
  161. package/templates/base/packages/nextjs/scaffold.config.ts +56 -0
  162. package/templates/base/packages/nextjs/services/store/store.ts +39 -0
  163. package/templates/base/packages/nextjs/services/web3/wagmiConfig.tsx +44 -0
  164. package/templates/base/packages/nextjs/services/web3/wagmiConnectors.tsx +51 -0
  165. package/templates/base/packages/nextjs/styles/globals.css +80 -0
  166. package/templates/base/packages/nextjs/tailwind.config.js +97 -0
  167. package/templates/base/packages/nextjs/tsconfig.json +28 -0
  168. package/templates/base/packages/nextjs/types/abitype/abi.d.ts +16 -0
  169. package/templates/base/packages/nextjs/types/utils.ts +3 -0
  170. package/templates/base/packages/nextjs/utils/scaffold-eth/block.ts +17 -0
  171. package/templates/base/packages/nextjs/utils/scaffold-eth/common.ts +8 -0
  172. package/templates/base/packages/nextjs/utils/scaffold-eth/contract.ts +352 -0
  173. package/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts +11 -0
  174. package/templates/base/packages/nextjs/utils/scaffold-eth/decodeTxData.ts +65 -0
  175. package/templates/base/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts +72 -0
  176. package/templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts +50 -0
  177. package/templates/base/packages/nextjs/utils/scaffold-eth/getParsedError.ts +35 -0
  178. package/templates/base/packages/nextjs/utils/scaffold-eth/index.ts +6 -0
  179. package/templates/base/packages/nextjs/utils/scaffold-eth/notification.tsx +90 -0
  180. package/templates/base/packages/nextjs/utils/scaffold-stylus/burner.ts +59 -0
  181. package/templates/base/packages/nextjs/utils/scaffold-stylus/chain.ts +42 -0
  182. package/templates/base/packages/nextjs/utils/scaffold-stylus/index.ts +3 -0
  183. package/templates/base/packages/nextjs/utils/scaffold-stylus/networks.ts +94 -0
  184. package/templates/base/packages/nextjs/vercel.json +3 -0
  185. package/templates/base/packages/stylus/.env.example +13 -0
  186. package/templates/base/packages/stylus/.eslintrc.js +23 -0
  187. package/templates/base/packages/stylus/.gitignore.template.mjs +7 -0
  188. package/templates/base/packages/stylus/README.md +263 -0
  189. package/templates/base/packages/stylus/header.png +0 -0
  190. package/templates/base/packages/stylus/jest.config.js +15 -0
  191. package/templates/base/packages/stylus/package.json +49 -0
  192. package/templates/base/packages/stylus/scripts/deploy.ts +29 -0
  193. package/templates/base/packages/stylus/scripts/deploy_all_contracts.ts +59 -0
  194. package/templates/base/packages/stylus/scripts/deploy_contract.ts +93 -0
  195. package/templates/base/packages/stylus/scripts/deploy_wrapper.ts +79 -0
  196. package/templates/base/packages/stylus/scripts/export_abi.ts +87 -0
  197. package/templates/base/packages/stylus/scripts/index.ts +0 -0
  198. package/templates/base/packages/stylus/scripts/new_module.sh +35 -0
  199. package/templates/base/packages/stylus/scripts/test_network.ts +31 -0
  200. package/templates/base/packages/stylus/scripts/utils/command.ts +165 -0
  201. package/templates/base/packages/stylus/scripts/utils/contract.ts +219 -0
  202. package/templates/base/packages/stylus/scripts/utils/deployment.ts +136 -0
  203. package/templates/base/packages/stylus/scripts/utils/index.ts +6 -0
  204. package/templates/base/packages/stylus/scripts/utils/network.ts +112 -0
  205. package/templates/base/packages/stylus/scripts/utils/type.ts +48 -0
  206. package/templates/base/packages/stylus/scripts/utils.ts +3 -0
  207. package/templates/base/packages/stylus/tsconfig.json +41 -0
  208. package/templates/base/packages/stylus/your-contract/.cargo/config.toml +18 -0
  209. package/templates/base/packages/stylus/your-contract/Cargo.lock +5744 -0
  210. package/templates/base/packages/stylus/your-contract/Cargo.toml +46 -0
  211. package/templates/base/packages/stylus/your-contract/examples/counter.rs +78 -0
  212. package/templates/base/packages/stylus/your-contract/header.png +0 -0
  213. package/templates/base/packages/stylus/your-contract/licenses/Apache-2.0 +201 -0
  214. package/templates/base/packages/stylus/your-contract/licenses/COPYRIGHT.md +5 -0
  215. package/templates/base/packages/stylus/your-contract/licenses/DCO.txt +34 -0
  216. package/templates/base/packages/stylus/your-contract/licenses/MIT +21 -0
  217. package/templates/base/packages/stylus/your-contract/rust-toolchain.toml +2 -0
  218. package/templates/base/packages/stylus/your-contract/src/lib.rs +211 -0
  219. package/templates/base/packages/stylus/your-contract/src/main.rs +10 -0
  220. package/templates/base/readme.md +187 -0
  221. package/templates/base/yarn.lock +17860 -0
  222. package/tsconfig.json +13 -0
@@ -0,0 +1,11 @@
1
+ enableColors: true
2
+
3
+ nmHoistingLimits: workspaces
4
+
5
+ nodeLinker: node-modules
6
+
7
+ plugins:
8
+ - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
9
+ spec: "@yarnpkg/plugin-typescript"
10
+
11
+ yarnPath: .yarn/releases/yarn-3.2.3.cjs
@@ -0,0 +1,86 @@
1
+ # Welcome to Scaffold-Stylus Contributing Guide
2
+
3
+ Thank you for investing your time in contributing to Scaffold-Stylus!
4
+
5
+ This guide aims to provide an overview of the contribution workflow to help us make the contribution process effective for everyone involved.
6
+
7
+ ## About the Project
8
+
9
+ Scaffold-Stylus is a minimal and forkable repo providing builders with a starter kit to build decentralized applications on Ethereum.
10
+
11
+ Read the [README](README.md) to get an overview of the project.
12
+
13
+ ### Vision
14
+
15
+ The goal of Scaffold-Stylus is to provide the primary building blocks for a decentralized application.
16
+
17
+ The repo can be forked to include integrations and more features, but we want to keep the master branch simple and minimal.
18
+
19
+ ### Project Status
20
+
21
+ The project is under active development.
22
+
23
+ You can view the open Issues, follow the development process and contribute to the project.
24
+
25
+ ## Getting started
26
+
27
+ You can contribute to this repo in many ways:
28
+
29
+ - Solve open issues
30
+ - Report bugs or feature requests
31
+ - Improve the documentation
32
+
33
+ Contributions are made via Issues and Pull Requests (PRs). A few general guidelines for contributions:
34
+
35
+ - Search for existing Issues and PRs before creating your own.
36
+ - Contributions should only fix/add the functionality in the issue OR address style issues, not both.
37
+ - If you're running into an error, please give context. Explain what you're trying to do and how to reproduce the error.
38
+ - Please use the same formatting in the code repository. You can configure your IDE to do it by using the prettier / linting config files included in each package.
39
+ - If applicable, please edit the README.md file to reflect the changes.
40
+
41
+ ### Issues
42
+
43
+ Issues should be used to report problems, request a new feature, or discuss potential changes before a PR is created.
44
+
45
+ #### Solve an issue
46
+
47
+ Scan through our [existing issues](https://github.com/Arb-Stylus/scaffold-stylus/issues) to find one that interests you.
48
+
49
+ If a contributor is working on the issue, they will be assigned to the individual. If you find an issue to work on, you are welcome to assign it to yourself and open a PR with a fix for it.
50
+
51
+ #### Create a new issue
52
+
53
+ If a related issue doesn't exist, you can open a new issue.
54
+
55
+ Some tips to follow when you are creating an issue:
56
+
57
+ - Provide as much context as possible. Over-communicate to give the most details to the reader.
58
+ - Include the steps to reproduce the issue or the reason for adding the feature.
59
+ - Screenshots, videos etc., are highly appreciated.
60
+
61
+ ### Pull Requests
62
+
63
+ #### Pull Request Process
64
+
65
+ We follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr)
66
+
67
+ 1. Fork the repo
68
+ 2. Clone the project
69
+ 3. Create a new branch with a descriptive name
70
+ 4. Commit your changes to the new branch
71
+ 5. Push changes to your fork
72
+ 6. Open a PR in our repository and tag one of the maintainers to review your PR
73
+
74
+ Here are some tips for a high-quality pull request:
75
+
76
+ - Create a title for the PR that accurately defines the work done.
77
+ - Structure the description neatly to make it easy to consume by the readers. For example, you can include bullet points and screenshots instead of having one large paragraph.
78
+ - Add the link to the issue if applicable.
79
+ - Have a good commit message that summarises the work done.
80
+
81
+ Once you submit your PR:
82
+
83
+ - We may ask questions, request additional information or ask for changes to be made before a PR can be merged. Please note that these are to make the PR clear for everyone involved and aims to create a frictionless interaction process.
84
+ - As you update your PR and apply changes, mark each conversation resolved.
85
+
86
+ Once the PR is approved, we'll "squash-and-merge" to keep the git commit history clean.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 BuidlGuidl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,70 @@
1
+ # Nitro dev node
2
+
3
+ This repository contains a simple script to start a Nitro dev node and deploy the Stylus `Cache Manager` contract for testing purposes.
4
+
5
+ ## Prerequisites
6
+
7
+ Before beginning, ensure the following is installed and running on your machine:
8
+
9
+ - Docker: Required to run the Nitro dev node in a container. Install Docker by following [the official installation guide](https://docs.docker.com/get-started/get-docker/) for your operating system.
10
+ - cast: A command-line tool from Foundry for interacting with Ethereum smart contracts. You can install it via Foundry by following [the installation instructions](https://book.getfoundry.sh/getting-started/installation).
11
+ - jq: A lightweight JSON parsing tool used to extract contract addresses from the script output. Install jq by following [the official installation guide](https://jqlang.github.io/jq/download/) for your operating system.
12
+
13
+ ## Development account (used by default)
14
+
15
+ In `--dev` mode, the script uses a pre-funded development account by default. This account is pre-funded with ETH in all networks and is used to deploy contracts, interact with the chain, and assume chain ownership.
16
+
17
+ - Address: 0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E
18
+ - Private key: 0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
19
+
20
+ You don’t need to set up a private key manually unless you prefer using your own key.
21
+
22
+
23
+ ## Chain ownership in `--dev` mode
24
+
25
+ In Nitro `--dev` mode, the default chain owner is set to `0x0000000000000000000000000000000000000000`. However, you can use the `ArbDebug` precompile to set the chain owner. This precompile includes the `becomeChainOwner()` function, which can be called to assume ownership of the chain.
26
+
27
+ Chain ownership is important because it allows the owner to perform certain critical functions within the Arbitrum environment, such as:
28
+
29
+ - Adding or removing other chain owners
30
+ - Setting the L1 and L2 base fees directly
31
+ - Adjusting the gas pricing inertia and backlog tolerance
32
+ - Modifying the computational speed limit and transaction gas limits
33
+ - Managing network and infrastructure fee accounts
34
+
35
+ The script automatically sets the chain owner to the pre-funded dev account before registering the `Cache Manager` contract. Here’s how the `becomeChainOwner()` function is called within the script:
36
+
37
+ ```bash
38
+ cast send 0x00000000000000000000000000000000000000FF "becomeChainOwner()" --private-key 0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 --rpc-url http://127.0.0.1:8547
39
+ ```
40
+
41
+ This step ensures that the dev account has ownership of the chain, which is necessary to register the `Cache Manager` as a WASM cache manager.
42
+
43
+
44
+ ## Usage
45
+
46
+ To use the script, follow these steps:
47
+
48
+ 1. Clone the repository:
49
+
50
+ ```bash
51
+ git clone https://github.com/OffchainLabs/nitro-devnode.git
52
+ cd nitro-devnode
53
+ ```
54
+
55
+ 2. Run the dev node script:
56
+ Run the script to start the Nitro dev node, deploy the Stylus `Cache Manager` contract, and register it as a WASM cache manager using the default development account:
57
+
58
+ ```bash
59
+ ./run-dev-node.sh
60
+ ```
61
+
62
+ The script will:
63
+
64
+ - Start the Nitro dev node in the background using Docker.
65
+ - Deploy the Stylus `Cache Manager` contract on the local Nitro network.
66
+ - Register the `Cache Manager` contract as a WASM cache manager.
67
+
68
+ ## Note on `--dev` mode
69
+
70
+ The script starts the Nitro node in `--dev` mode, which does not persist chain data. Each time you restart the node, the chain state resets. This is suitable for testing and development purposes, but for persistent chain data, consider using a full node setup instead of `--dev`.
@@ -0,0 +1,132 @@
1
+ #!/bin/bash
2
+
3
+ NITRO_NODE_VERSION="v3.5.5-90ee45c" # <-- only update this when you need a new version
4
+ TARGET_IMAGE="offchainlabs/nitro-node:${NITRO_NODE_VERSION}"
5
+
6
+ RPC=http://127.0.0.1:8547
7
+ PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
8
+ CREATE2_FACTORY=0x4e59b44847b379578588920ca78fbf26c0b4956c
9
+ SALT=0x0000000000000000000000000000000000000000000000000000000000000000
10
+
11
+ # By default, use nitro docker image. If "--stylus" is passed, build the image with stylus dev dependencies
12
+ STYLUS_MODE="false"
13
+
14
+ # Parse arguments
15
+ while [[ $# -gt 0 ]]; do
16
+ case "$1" in
17
+ --stylus)
18
+ STYLUS_MODE="true"
19
+ shift
20
+ ;;
21
+ *)
22
+ echo "Unknown option: $1"
23
+ exit 1
24
+ ;;
25
+ esac
26
+ done
27
+
28
+ if [[ "$STYLUS_MODE" == "true" ]]; then
29
+ echo "Building Nitro node with Stylus dev dependencies..."
30
+ # Build using the specific version
31
+ docker build . --target nitro-node-stylus-dev \
32
+ --tag nitro-node-stylus-dev -f stylus-dev/Dockerfile \
33
+ --build-arg NITRO_NODE_VERSION="${NITRO_NODE_VERSION}"
34
+
35
+ TARGET_IMAGE="nitro-node-stylus-dev"
36
+ fi
37
+
38
+ # Start Nitro dev node in the background
39
+ echo "Starting Nitro dev node..."
40
+ docker run --rm --name nitro-dev -p 8547:8547 "${TARGET_IMAGE}" --dev --http.addr 0.0.0.0 --http.api=net,web3,eth,debug &
41
+
42
+ # Kill background processes when exiting
43
+ trap 'kill $(jobs -p) 2>/dev/null' EXIT
44
+
45
+ # Wait for the node to initialize
46
+ echo "Waiting for the Nitro node to initialize..."
47
+
48
+ until [[ "$(curl -s -X POST -H "Content-Type: application/json" \
49
+ --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' \
50
+ $RPC)" == *"result"* ]]; do
51
+ sleep 0.1
52
+ done
53
+
54
+
55
+ # Check if node is running
56
+ curl_output=$(curl -s -X POST -H "Content-Type: application/json" \
57
+ --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' \
58
+ $RPC)
59
+
60
+ if [[ "$curl_output" == *"result"* ]]; then
61
+ echo "Nitro node is running!"
62
+ else
63
+ echo "Failed to start Nitro node."
64
+ exit 1
65
+ fi
66
+
67
+ # Make the caller a chain owner
68
+ echo "Setting chain owner to pre-funded dev account..."
69
+ cast send 0x00000000000000000000000000000000000000FF "becomeChainOwner()" \
70
+ --private-key $PRIVATE_KEY \
71
+ --rpc-url $RPC
72
+
73
+ # Set the L1 data fee to 0 so it doesn't impact the L2 Gas limit.
74
+ # This makes the gas estimates closer to Ethereum and allows the deployment of the CREATE2 factory
75
+ cast send -r $RPC --private-key $PRIVATE_KEY 0x0000000000000000000000000000000000000070 'setL1PricePerUnit(uint256)' 0x0
76
+
77
+ # Deploy CREATE2 factory
78
+ echo "Deploying the CREATE2 factory"
79
+ cast send --rpc-url $RPC --private-key $PRIVATE_KEY --value "1 ether" 0x3fab184622dc19b6109349b94811493bf2a45362
80
+ cast publish --rpc-url $RPC 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222
81
+ if [ "$(cast code -r $RPC $CREATE2_FACTORY)" == "0x" ]; then
82
+ echo "Failed to deploy CREATE2 factory"
83
+ exit 1
84
+ fi
85
+
86
+ # Deploy Cache Manager Contract
87
+ echo "Deploying Cache Manager contract..."
88
+ deploy_output=$(cast send --private-key $PRIVATE_KEY \
89
+ --rpc-url $RPC \
90
+ --create 0x60a06040523060805234801561001457600080fd5b50608051611d1c61003060003960006105260152611d1c6000f3fe)
91
+
92
+ # Extract contract address using awk from plain text output
93
+ contract_address=$(echo "$deploy_output" | awk '/contractAddress/ {print $2}')
94
+
95
+ # Check if contract deployment was successful
96
+ if [[ -z "$contract_address" ]]; then
97
+ echo "Error: Failed to extract contract address. Full output:"
98
+ echo "$deploy_output"
99
+ exit 1
100
+ fi
101
+
102
+ echo "Cache Manager contract deployed at address: $contract_address"
103
+
104
+ # Register the deployed Cache Manager contract
105
+ echo "Registering Cache Manager contract as a WASM cache manager..."
106
+ registration_output=$(cast send --private-key $PRIVATE_KEY \
107
+ --rpc-url $RPC \
108
+ 0x0000000000000000000000000000000000000070 \
109
+ "addWasmCacheManager(address)" "$contract_address")
110
+
111
+ # Check if registration was successful
112
+ if [[ "$registration_output" == *"error"* ]]; then
113
+ echo "Failed to register Cache Manager contract. Registration output:"
114
+ echo "$registration_output"
115
+ exit 1
116
+ fi
117
+ echo "Cache Manager deployed and registered successfully"
118
+
119
+ # Deploy StylusDeployer
120
+ deployer_code=$(cat ./stylus-deployer-bytecode.txt)
121
+ deployer_address=$(cast create2 --salt $SALT --init-code $deployer_code)
122
+ cast send --private-key $PRIVATE_KEY --rpc-url $RPC \
123
+ $CREATE2_FACTORY "$SALT$deployer_code"
124
+ if [ "$(cast code -r $RPC $deployer_address)" == "0x" ]; then
125
+ echo "Failed to deploy StylusDeployer"
126
+ exit 1
127
+ fi
128
+ echo "StylusDeployer deployed at address: $deployer_address"
129
+
130
+ # If no errors, print success message
131
+ echo "Nitro node is running..."
132
+ wait # Keep the script alive and the node running
@@ -0,0 +1,150 @@
1
+ #!/bin/bash
2
+
3
+ NITRO_NODE_VERSION="v3.5.5-90ee45c"
4
+ TARGET_IMAGE="offchainlabs/nitro-node:${NITRO_NODE_VERSION}"
5
+
6
+ RPC=http://127.0.0.1:8547
7
+ PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
8
+ CREATE2_FACTORY=0x4e59b44847b379578588920ca78fbf26c0b4956c
9
+ SALT=0x0000000000000000000000000000000000000000000000000000000000000000
10
+
11
+ # By default, use nitro docker image. If "--stylus" is passed, build the image with stylus dev dependencies
12
+ STYLUS_MODE="false"
13
+
14
+ # Parse arguments
15
+ while [[ $# -gt 0 ]]; do
16
+ case "$1" in
17
+ --stylus)
18
+ STYLUS_MODE="true"
19
+ shift
20
+ ;;
21
+ *)
22
+ echo "Unknown option: $1"
23
+ exit 1
24
+ ;;
25
+ esac
26
+ done
27
+
28
+ # Check if nitro-devnode exists, if not initialize the submodule
29
+ if [ ! -d "./nitro-devnode" ]; then
30
+ echo "nitro-devnode directory not found. Initializing nitro-devnode submodule..."
31
+ # Run git submodule from the root directory where .gitmodules is located
32
+ cd "$(git rev-parse --show-toplevel)" && git submodule update --init nitro-devnode && cd packages/stylus
33
+ fi
34
+
35
+ if [[ "$STYLUS_MODE" == "true" ]]; then
36
+ echo "Building Nitro node with Stylus dev dependencies..."
37
+ # Build using the specific version
38
+ docker build . --target nitro-node-stylus-dev \
39
+ --tag nitro-node-stylus-dev -f nitro-devnode/stylus-dev/Dockerfile \
40
+ --build-arg NITRO_NODE_VERSION="${NITRO_NODE_VERSION}"
41
+
42
+ TARGET_IMAGE="nitro-node-stylus-dev"
43
+ fi
44
+
45
+ # Start Nitro dev node in the background with CORS settings and WebSocket enabled
46
+ echo "Starting Nitro dev node with CORS and WebSocket enabled..."
47
+ docker run --rm --name nitro-dev -p 8547:8547 "${TARGET_IMAGE}" --dev --http.addr 0.0.0.0 --http.api=net,web3,eth,debug --http.corsdomain="*" --http.vhosts="*" --ws.addr 0.0.0.0 --ws.port 8547 --ws.api=net,web3,eth,debug --ws.origins="*" &
48
+
49
+ # Kill background processes when exiting
50
+ trap 'kill $(jobs -p) 2>/dev/null' EXIT
51
+
52
+ # Wait for the node to initialize
53
+ echo "Waiting for the Nitro node to initialize..."
54
+
55
+ until [[ "$(curl -s -X POST -H "Content-Type: application/json" \
56
+ --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' \
57
+ $RPC)" == *"result"* ]]; do
58
+ sleep 0.1
59
+ done
60
+
61
+ # Check if node is running
62
+ curl_output=$(curl -s -X POST -H "Content-Type: application/json" \
63
+ --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' \
64
+ $RPC)
65
+
66
+ if [[ "$curl_output" == *"result"* ]]; then
67
+ echo "Nitro node is running with CORS and WebSocket enabled!"
68
+ echo "HTTP RPC: http://127.0.0.1:8547"
69
+ echo "WebSocket: ws://127.0.0.1:8547"
70
+ else
71
+ echo "Failed to start Nitro node."
72
+ exit 1
73
+ fi
74
+
75
+ # Make the caller a chain owner
76
+ echo "Setting chain owner to pre-funded dev account..."
77
+ cast send 0x00000000000000000000000000000000000000FF "becomeChainOwner()" \
78
+ --private-key $PRIVATE_KEY \
79
+ --rpc-url $RPC
80
+
81
+ # Set the L1 data fee to 0 so it doesn't impact the L2 Gas limit.
82
+ # This makes the gas estimates closer to Ethereum and allows the deployment of the CREATE2 factory
83
+ cast send -r $RPC --private-key $PRIVATE_KEY 0x0000000000000000000000000000000000000070 'setL1PricePerUnit(uint256)' 0x0
84
+
85
+ # Deploy CREATE2 factory
86
+ echo "Deploying the CREATE2 factory"
87
+ cast send --rpc-url $RPC --private-key $PRIVATE_KEY --value "1 ether" 0x3fab184622dc19b6109349b94811493bf2a45362
88
+ cast publish --rpc-url $RPC 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222
89
+ if [ "$(cast code -r $RPC $CREATE2_FACTORY 2>/dev/null)" == "0x" ]; then
90
+ echo "Failed to deploy CREATE2 factory"
91
+ exit 1
92
+ fi
93
+
94
+ # Deploy Cache Manager Contract
95
+ echo "Deploying Cache Manager contract..."
96
+ deploy_output=$(cast send --private-key $PRIVATE_KEY \
97
+ --rpc-url $RPC \
98
+ --create 0x60a06040523060805234801561001457600080fd5b50608051611d1c61003060003960006105260152611d1c6000f3fe)
99
+
100
+ # Extract contract address using awk from plain text output
101
+ contract_address=$(echo "$deploy_output" | awk '/contractAddress/ {print $2}')
102
+
103
+ # Check if contract deployment was successful
104
+ if [[ -z "$contract_address" ]]; then
105
+ echo "Error: Failed to extract contract address. Full output:"
106
+ echo "$deploy_output"
107
+ exit 1
108
+ fi
109
+
110
+ echo "Cache Manager contract deployed at address: $contract_address"
111
+
112
+ # Register the deployed Cache Manager contract
113
+ echo "Registering Cache Manager contract as a WASM cache manager..."
114
+ registration_output=$(cast send --private-key $PRIVATE_KEY \
115
+ --rpc-url $RPC \
116
+ 0x0000000000000000000000000000000000000070 \
117
+ "addWasmCacheManager(address)" "$contract_address")
118
+
119
+ # Check if registration was successful
120
+ if [[ "$registration_output" == *"error"* ]]; then
121
+ echo "Failed to register Cache Manager contract. Registration output:"
122
+ echo "$registration_output"
123
+ exit 1
124
+ fi
125
+ echo "Cache Manager deployed and registered successfully"
126
+
127
+ # Deploy StylusDeployer
128
+ deployer_code=$(cat ./nitro-devnode/stylus-deployer-bytecode.txt)
129
+ deployer_address=$(cast create2 --init-code $deployer_code 2>/dev/null)
130
+ cast send --private-key $PRIVATE_KEY --rpc-url $RPC \
131
+ $CREATE2_FACTORY "$SALT$deployer_code"
132
+ if [ "$(cast code -r $RPC $deployer_address 2>/dev/null)" == "0x" ]; then
133
+ echo "Failed to deploy StylusDeployer"
134
+ exit 1
135
+ fi
136
+ echo "StylusDeployer deployed at address: $deployer_address"
137
+
138
+ # Fund accounts with 1 ETH each
139
+ echo "Funding accounts with 1 ETH each..."
140
+ cast send --private-key $PRIVATE_KEY --rpc-url $RPC --value "1 ether" 0xDD09b55496EaA3cFAe23137ABDeA52a9a979B70e
141
+ cast send --private-key $PRIVATE_KEY --rpc-url $RPC --value "1 ether" 0xE9cB1563bE49002383D08386ee287aF7BAD08c3b
142
+ cast send --private-key $PRIVATE_KEY --rpc-url $RPC --value "1 ether" 0x838d568Ffb16BC74083e88fd769df85E8d3afcE6
143
+ cast send --private-key $PRIVATE_KEY --rpc-url $RPC --value "1 ether" 0xA491d1134388c78AeEDf6b1Ca3F21657015Ff8E1
144
+ echo "All accounts funded with 1 ETH each"
145
+
146
+ # If no errors, print success message
147
+ echo "Nitro node is running with CORS and WebSocket enabled..."
148
+ echo "HTTP RPC: http://127.0.0.1:8547"
149
+ echo "WebSocket: ws://127.0.0.1:8547"
150
+ wait # Keep the script alive and the node running