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,37 @@
1
+ import React from "react";
2
+ import { useTheme } from "next-themes";
3
+
4
+ export const BackGround = () => {
5
+ const { resolvedTheme } = useTheme();
6
+ const isDarkMode = resolvedTheme === "dark";
7
+
8
+ if (!isDarkMode) {
9
+ return <></>;
10
+ }
11
+
12
+ return (
13
+ <>
14
+ <div
15
+ className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-[70vh] w-[70vh] rounded-full -z-50"
16
+ style={{
17
+ backgroundColor: "rgba(230, 15, 119, 0.33)",
18
+ filter: "blur(254.85px)",
19
+ }}
20
+ />
21
+ <div
22
+ className="absolute top-0 -right-2 -translate-y-1/2 w-[630px] h-[630px] rounded-full -z-50"
23
+ style={{
24
+ backgroundColor: "#224457",
25
+ filter: "blur(164.85px)",
26
+ }}
27
+ />
28
+ <div
29
+ className="absolute top-0 left-0 translate-x-2 -translate-y-1/2 w-[630px] h-[630px] rounded-full -z-50"
30
+ style={{
31
+ backgroundColor: "#252525",
32
+ filter: "blur(274.85px)",
33
+ }}
34
+ />
35
+ </>
36
+ );
37
+ };
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import Link from "next/link";
3
+
4
+ interface CardProps {
5
+ icon: React.ReactNode;
6
+ description: React.ReactNode;
7
+ linkHref: string;
8
+ linkText: string;
9
+ isDarkMode: boolean;
10
+ }
11
+
12
+ export const Card: React.FC<CardProps> = ({ icon, description, linkHref, linkText, isDarkMode }) => {
13
+ return (
14
+ <div
15
+ className={`relative h-full rounded-3xl border-2 border-transparent p-4 text-center flex flex-col items-center justify-evenly max-w-md ${
16
+ isDarkMode ? "gradient-border-red" : "gradient-border-light"
17
+ }`}
18
+ style={{
19
+ boxShadow: "0 0 0 3px transparent",
20
+ }}
21
+ >
22
+ <div className="absolute top-0 left-1/2 -translate-x-1/2">
23
+ <svg xmlns="http://www.w3.org/2000/svg" width="84" height="6" viewBox="0 0 84 6" fill="none">
24
+ <path d="M41.3071 6L15.6728 6L0 0L84 0L69.02 6L41.3071 6Z" fill="#E3066E" />
25
+ </svg>
26
+ </div>
27
+ <div>{icon}</div>
28
+ <p className="text-sm">
29
+ {description}
30
+ <br />
31
+ <Link href={linkHref} passHref className="underline underline-offset-4 font-semibold">
32
+ {linkText}
33
+ </Link>{" "}
34
+ tab.
35
+ </p>
36
+ </div>
37
+ );
38
+ };
39
+
40
+ export default Card;
@@ -0,0 +1,93 @@
1
+ import React, { useMemo } from "react";
2
+ import Link from "next/link";
3
+ import { useTheme } from "next-themes";
4
+ import { CurrencyDollarIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline";
5
+ //import { HeartIcon } from "@heroicons/react/24/outline";
6
+ //import { BuidlGuidlLogo } from "~~/components/assets/BuidlGuidlLogo";
7
+ import { Faucet } from "~~/components/scaffold-eth";
8
+ import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
9
+ import { useGlobalState } from "~~/services/store/store";
10
+ import { arbitrumNitro } from "~~/utils/scaffold-stylus/chain";
11
+
12
+ /**
13
+ * Site footer
14
+ */
15
+ export const Footer = () => {
16
+ const nativeCurrencyPrice = useGlobalState(state => state.nativeCurrency.price);
17
+ const { targetNetwork } = useTargetNetwork();
18
+ const { resolvedTheme } = useTheme();
19
+ const isLocalNetwork = targetNetwork.id === arbitrumNitro.id;
20
+
21
+ const isDarkMode = useMemo(() => {
22
+ return resolvedTheme === "dark";
23
+ }, [resolvedTheme]);
24
+
25
+ return (
26
+ <div
27
+ className="min-h-0 py-5 px-1 mb-11 lg:mb-0"
28
+ style={{
29
+ backgroundColor: isDarkMode ? "black" : "white",
30
+ }}
31
+ >
32
+ <div>
33
+ <div className="fixed flex justify-between items-center w-full z-10 p-4 bottom-0 left-0 pointer-events-none">
34
+ <div className="flex flex-col md:flex-row gap-2 pointer-events-auto">
35
+ {nativeCurrencyPrice > 0 && (
36
+ <div>
37
+ <div className="btn btn-sm font-normal gap-1 cursor-auto border-round-color bg-base-100">
38
+ <CurrencyDollarIcon className="h-4 w-4 stroke-[#E3066E]" />
39
+ <span>{nativeCurrencyPrice.toFixed(2)}</span>
40
+ </div>
41
+ </div>
42
+ )}
43
+ {isLocalNetwork && (
44
+ <>
45
+ <Faucet />
46
+ <Link
47
+ href="/blockexplorer"
48
+ passHref
49
+ className="btn btn-sm font-normal gap-1 border-round-color bg-base-100"
50
+ >
51
+ <MagnifyingGlassIcon className="h-4 w-4 stroke-[#E3066E]" />
52
+ <span>Block Explorer</span>
53
+ </Link>
54
+ </>
55
+ )}
56
+ </div>
57
+ </div>
58
+ </div>
59
+ <div className="w-full">
60
+ <ul className="menu menu-horizontal w-full">
61
+ <div className="flex justify-center items-center gap-2 text-sm w-full">
62
+ <div className="text-center">
63
+ <a href="https://github.com/Arb-Stylus/scaffold-stylus" target="_blank" rel="noreferrer" className="link">
64
+ Fork me
65
+ </a>
66
+ </div>
67
+ <span>·</span>
68
+ {/*<div className="flex justify-center items-center gap-2">
69
+ <p className="m-0 text-center">
70
+ Built with <HeartIcon className="inline-block h-4 w-4" /> at
71
+ </p>
72
+ <a
73
+ className="flex justify-center items-center gap-1"
74
+ href="https://buidlguidl.com/"
75
+ target="_blank"
76
+ rel="noreferrer"
77
+ >
78
+ <BuidlGuidlLogo className="w-3 h-5 pb-1" />
79
+ <span className="link">BuidlGuidl</span>
80
+ </a>
81
+ </div>
82
+ <span>·</span>*/}
83
+ <div className="text-center">
84
+ <a href="https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA" target="_blank" rel="noreferrer" className="link">
85
+ Support
86
+ </a>
87
+ </div>
88
+ </div>
89
+ </ul>
90
+ </div>
91
+ </div>
92
+ );
93
+ };
@@ -0,0 +1,114 @@
1
+ "use client";
2
+
3
+ import React, { useCallback, useRef, useState } from "react";
4
+ import Image from "next/image";
5
+ import Link from "next/link";
6
+ import { usePathname } from "next/navigation";
7
+ import { SwitchTheme } from "./SwitchTheme";
8
+ import { Bars3Icon, BugAntIcon } from "@heroicons/react/24/outline";
9
+ import { RainbowKitCustomConnectButton } from "~~/components/scaffold-eth";
10
+ import { useOutsideClick, useTargetNetwork } from "~~/hooks/scaffold-eth";
11
+ import { arbitrumNitro } from "~~/utils/scaffold-stylus/chain";
12
+
13
+ type HeaderMenuLink = {
14
+ label: string;
15
+ href: string;
16
+ icon?: React.ReactNode;
17
+ };
18
+
19
+ export const menuLinks: HeaderMenuLink[] = [
20
+ {
21
+ label: "Home",
22
+ href: "/",
23
+ },
24
+ {
25
+ label: "Debug Contracts",
26
+ href: "/debug",
27
+ icon: <BugAntIcon className="h-4 w-4" />,
28
+ },
29
+ ];
30
+
31
+ export const HeaderMenuLinks = () => {
32
+ const pathname = usePathname();
33
+
34
+ return (
35
+ <>
36
+ {menuLinks.map(({ label, href, icon }) => {
37
+ const isActive = pathname === href;
38
+ return (
39
+ <li key={href}>
40
+ <Link
41
+ href={href}
42
+ passHref
43
+ className={`${
44
+ isActive ? "bg-secondary shadow-md" : ""
45
+ } hover:bg-secondary hover:shadow-md focus:!bg-secondary active:!text-neutral py-1.5 px-3 text-sm rounded-full gap-2 grid grid-flow-col`}
46
+ >
47
+ {icon}
48
+ <span>{label}</span>
49
+ </Link>
50
+ </li>
51
+ );
52
+ })}
53
+ </>
54
+ );
55
+ };
56
+
57
+ /**
58
+ * Site header
59
+ */
60
+ export const Header = () => {
61
+ const [isDrawerOpen, setIsDrawerOpen] = useState(false);
62
+ const burgerMenuRef = useRef<HTMLDivElement>(null);
63
+ const { targetNetwork } = useTargetNetwork();
64
+ const isLocalNetwork = targetNetwork?.id === arbitrumNitro.id;
65
+ useOutsideClick(
66
+ burgerMenuRef,
67
+ useCallback(() => setIsDrawerOpen(false), []),
68
+ );
69
+
70
+ return (
71
+ <div className="sticky lg:static top-0 navbar min-h-0 flex-shrink-0 justify-between z-20 px-0 sm:px-2">
72
+ <div className="navbar-start w-auto lg:w-1/2">
73
+ <div className="lg:hidden dropdown" ref={burgerMenuRef}>
74
+ <label
75
+ tabIndex={0}
76
+ className={`ml-1 btn btn-ghost ${isDrawerOpen ? "hover:bg-secondary" : "hover:bg-transparent"}`}
77
+ onClick={() => {
78
+ setIsDrawerOpen(prevIsOpenState => !prevIsOpenState);
79
+ }}
80
+ >
81
+ <Bars3Icon className="h-1/2" />
82
+ </label>
83
+ {isDrawerOpen && (
84
+ <ul
85
+ tabIndex={0}
86
+ className="menu menu-compact dropdown-content mt-3 p-2 shadow bg-base-100 rounded-box w-52"
87
+ onClick={() => {
88
+ setIsDrawerOpen(false);
89
+ }}
90
+ >
91
+ <HeaderMenuLinks />
92
+ </ul>
93
+ )}
94
+ </div>
95
+ <Link href="/" passHref className="hidden lg:flex items-center gap-2 ml-4 mr-6 shrink-0">
96
+ <div className="flex relative w-10 h-10">
97
+ <Image alt="SE2 logo" className="cursor-pointer" fill src="/logo.svg" />
98
+ </div>
99
+ <div className="flex flex-col">
100
+ <span className="font-bold leading-tight">Scaffold Stylus</span>
101
+ <span className="text-xs">Arbitrum dev stack</span>
102
+ </div>
103
+ </Link>
104
+ <ul className="hidden lg:flex lg:flex-nowrap menu menu-horizontal px-1 gap-2">
105
+ <HeaderMenuLinks />
106
+ </ul>
107
+ </div>
108
+ <div className="flex gap-4 navbar-end flex-grow mr-4">
109
+ <RainbowKitCustomConnectButton />
110
+ <SwitchTheme className={`pointer-events-auto ${isLocalNetwork ? "self-end md:self-auto" : ""}`} />
111
+ </div>
112
+ </div>
113
+ );
114
+ };
@@ -0,0 +1,77 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { BackGround } from "./Background";
5
+ import { RainbowKitProvider, darkTheme, lightTheme } from "@rainbow-me/rainbowkit";
6
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
7
+ import { AppProgressBar as ProgressBar } from "next-nprogress-bar";
8
+ import { useTheme } from "next-themes";
9
+ import { Toaster } from "react-hot-toast";
10
+ import { WagmiProvider } from "wagmi";
11
+ import { Footer } from "~~/components/Footer";
12
+ import { Header } from "~~/components/Header";
13
+ import { BlockieAvatar } from "~~/components/scaffold-eth";
14
+ import { useInitializeNativeCurrencyPrice, useTargetNetwork } from "~~/hooks/scaffold-eth";
15
+ import { wagmiConfig } from "~~/services/web3/wagmiConfig";
16
+ import { arbitrumNitro, initBurnerPK } from "~~/utils/scaffold-stylus";
17
+
18
+ const ScaffoldEthApp = ({ children }: { children: React.ReactNode }) => {
19
+ useInitializeNativeCurrencyPrice();
20
+ const { targetNetwork } = useTargetNetwork();
21
+
22
+ useEffect(() => {
23
+ if (targetNetwork.id === arbitrumNitro.id) {
24
+ initBurnerPK();
25
+ }
26
+ }, [targetNetwork]);
27
+
28
+ return (
29
+ <>
30
+ <div className="flex flex-col min-h-screen">
31
+ <Header />
32
+ <main className="relative flex flex-col flex-1">
33
+ <BackGround />
34
+ {children}
35
+ </main>
36
+ <Footer />
37
+ </div>
38
+ <Toaster />
39
+ </>
40
+ );
41
+ };
42
+
43
+ export const queryClient = new QueryClient({
44
+ defaultOptions: {
45
+ queries: {
46
+ refetchOnWindowFocus: false,
47
+ },
48
+ },
49
+ });
50
+
51
+ export const ScaffoldEthAppWithProviders = ({ children }: { children: React.ReactNode }) => {
52
+ const { resolvedTheme } = useTheme();
53
+ const isDarkMode = resolvedTheme === "dark";
54
+ const [mounted, setMounted] = useState(false);
55
+
56
+ useEffect(() => {
57
+ setMounted(true);
58
+ }, []);
59
+
60
+ if (!mounted) {
61
+ return null;
62
+ }
63
+
64
+ return (
65
+ <WagmiProvider config={wagmiConfig}>
66
+ <QueryClientProvider client={queryClient}>
67
+ <ProgressBar height="3px" color="#2299dd" />
68
+ <RainbowKitProvider
69
+ avatar={BlockieAvatar}
70
+ theme={mounted ? (isDarkMode ? darkTheme() : lightTheme()) : lightTheme()}
71
+ >
72
+ <ScaffoldEthApp>{children}</ScaffoldEthApp>
73
+ </RainbowKitProvider>
74
+ </QueryClientProvider>
75
+ </WagmiProvider>
76
+ );
77
+ };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { useTheme } from "next-themes";
5
+ import { MoonIcon, SunIcon } from "@heroicons/react/24/outline";
6
+
7
+ export const SwitchTheme = ({ className }: { className?: string }) => {
8
+ const { setTheme, resolvedTheme } = useTheme();
9
+ const [mounted, setMounted] = useState(false);
10
+
11
+ const isDarkMode = resolvedTheme === "dark";
12
+
13
+ const handleToggle = () => {
14
+ if (isDarkMode) {
15
+ setTheme("light");
16
+ return;
17
+ }
18
+ setTheme("dark");
19
+ };
20
+
21
+ useEffect(() => {
22
+ setMounted(true);
23
+ }, []);
24
+
25
+ if (!mounted) return null;
26
+
27
+ return (
28
+ <div className={`flex space-x-2 h-5 items-center justify-center text-sm border-l border-neutral px-4 ${className}`}>
29
+ {
30
+ <label
31
+ htmlFor="theme-toggle"
32
+ className={`swap swap-rotate ${!isDarkMode ? "swap-active" : ""}`}
33
+ onClick={handleToggle}
34
+ >
35
+ <SunIcon className="swap-on h-5 w-5" />
36
+ <MoonIcon className="swap-off h-5 w-5" />
37
+ </label>
38
+ }
39
+ </div>
40
+ );
41
+ };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ThemeProvider as NextThemesProvider } from "next-themes";
5
+ import { type ThemeProviderProps } from "next-themes/dist/types";
6
+
7
+ export const ThemeProvider = ({ children, ...props }: ThemeProviderProps) => {
8
+ return (
9
+ <NextThemesProvider attribute="data-theme" defaultTheme="dark" enableSystem disableTransitionOnChange {...props}>
10
+ {children}
11
+ </NextThemesProvider>
12
+ );
13
+ };
@@ -0,0 +1,18 @@
1
+ export const BuidlGuidlLogo = ({ className }: { className: string }) => {
2
+ return (
3
+ <svg
4
+ className={className}
5
+ width="53"
6
+ height="72"
7
+ viewBox="0 0 53 72"
8
+ fill="currentColor"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ >
11
+ <path
12
+ fillRule="evenodd"
13
+ d="M25.9 17.434v15.638h3.927v9.04h9.718v-9.04h6.745v18.08l-10.607 19.88-12.11-.182-12.11.183L.856 51.152v-18.08h6.713v9.04h9.75v-9.04h4.329V2.46a2.126 2.126 0 0 1 4.047-.914c1.074.412 2.157 1.5 3.276 2.626 1.33 1.337 2.711 2.726 4.193 3.095 1.496.373 2.605-.026 3.855-.475 1.31-.47 2.776-.997 5.005-.747 1.67.197 2.557 1.289 3.548 2.509 1.317 1.623 2.82 3.473 6.599 3.752l-.024.017c-2.42 1.709-5.726 4.043-10.86 3.587-1.605-.139-2.736-.656-3.82-1.153-1.546-.707-2.997-1.37-5.59-.832-2.809.563-4.227 1.892-5.306 2.903-.236.221-.456.427-.67.606Z"
14
+ clipRule="evenodd"
15
+ />
16
+ </svg>
17
+ );
18
+ };
@@ -0,0 +1,187 @@
1
+ "use client";
2
+
3
+ import { AddressCopyIcon } from "./AddressCopyIcon";
4
+ import { AddressLinkWrapper } from "./AddressLinkWrapper";
5
+ import { Address as AddressType, getAddress, isAddress } from "viem";
6
+ import { normalize } from "viem/ens";
7
+ import { useEnsAvatar, useEnsName } from "wagmi";
8
+ import { BlockieAvatar } from "~~/components/scaffold-eth";
9
+ import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
10
+ import { getBlockExplorerAddressLink } from "~~/utils/scaffold-stylus";
11
+
12
+ const textSizeMap = {
13
+ "3xs": "text-[10px]",
14
+ "2xs": "text-[11px]",
15
+ xs: "text-xs",
16
+ sm: "text-sm",
17
+ base: "text-base",
18
+ lg: "text-lg",
19
+ xl: "text-xl",
20
+ "2xl": "text-2xl",
21
+ "3xl": "text-3xl",
22
+ "4xl": "text-4xl",
23
+ } as const;
24
+
25
+ const blockieSizeMap = {
26
+ "3xs": 4,
27
+ "2xs": 5,
28
+ xs: 6,
29
+ sm: 7,
30
+ base: 8,
31
+ lg: 9,
32
+ xl: 10,
33
+ "2xl": 12,
34
+ "3xl": 15,
35
+ "4xl": 17,
36
+ "5xl": 19,
37
+ "6xl": 21,
38
+ "7xl": 23,
39
+ } as const;
40
+
41
+ const copyIconSizeMap = {
42
+ "3xs": "h-2.5 w-2.5",
43
+ "2xs": "h-3 w-3",
44
+ xs: "h-3.5 w-3.5",
45
+ sm: "h-4 w-4",
46
+ base: "h-[18px] w-[18px]",
47
+ lg: "h-5 w-5",
48
+ xl: "h-[22px] w-[22px]",
49
+ "2xl": "h-6 w-6",
50
+ "3xl": "h-[26px] w-[26px]",
51
+ "4xl": "h-7 w-7",
52
+ } as const;
53
+
54
+ type SizeMap = typeof textSizeMap | typeof blockieSizeMap;
55
+
56
+ const getNextSize = <T extends SizeMap>(sizeMap: T, currentSize: keyof T, step = 1): keyof T => {
57
+ const sizes = Object.keys(sizeMap) as Array<keyof T>;
58
+ const currentIndex = sizes.indexOf(currentSize);
59
+ const nextIndex = Math.min(currentIndex + step, sizes.length - 1);
60
+ return sizes[nextIndex];
61
+ };
62
+
63
+ const getPrevSize = <T extends SizeMap>(sizeMap: T, currentSize: keyof T, step = 1): keyof T => {
64
+ const sizes = Object.keys(sizeMap) as Array<keyof T>;
65
+ const currentIndex = sizes.indexOf(currentSize);
66
+ const prevIndex = Math.max(currentIndex - step, 0);
67
+ return sizes[prevIndex];
68
+ };
69
+
70
+ type AddressProps = {
71
+ address?: AddressType;
72
+ disableAddressLink?: boolean;
73
+ format?: "short" | "long";
74
+ size?: "xs" | "sm" | "base" | "lg" | "xl" | "2xl" | "3xl";
75
+ onlyEnsOrAddress?: boolean;
76
+ };
77
+
78
+ export const Address = ({
79
+ address,
80
+ disableAddressLink,
81
+ format,
82
+ size = "base",
83
+ onlyEnsOrAddress = false,
84
+ }: AddressProps) => {
85
+ const checkSumAddress = address ? getAddress(address) : undefined;
86
+
87
+ const { targetNetwork } = useTargetNetwork();
88
+
89
+ const { data: ens, isLoading: isEnsNameLoading } = useEnsName({
90
+ address: checkSumAddress,
91
+ chainId: 1,
92
+ query: {
93
+ enabled: isAddress(checkSumAddress ?? ""),
94
+ },
95
+ });
96
+ const { data: ensAvatar } = useEnsAvatar({
97
+ name: ens ? normalize(ens) : undefined,
98
+ chainId: 1,
99
+ query: {
100
+ enabled: Boolean(ens),
101
+ gcTime: 30_000,
102
+ },
103
+ });
104
+
105
+ const shortAddress = checkSumAddress?.slice(0, 6) + "..." + checkSumAddress?.slice(-4);
106
+ const displayAddress = format === "long" ? checkSumAddress : shortAddress;
107
+ const displayEnsOrAddress = ens || displayAddress;
108
+
109
+ const showSkeleton = !checkSumAddress || (!onlyEnsOrAddress && (ens || isEnsNameLoading));
110
+
111
+ const addressSize = showSkeleton && !onlyEnsOrAddress ? getPrevSize(textSizeMap, size, 2) : size;
112
+ const ensSize = getNextSize(textSizeMap, addressSize);
113
+ const blockieSize = showSkeleton && !onlyEnsOrAddress ? getNextSize(blockieSizeMap, addressSize, 4) : addressSize;
114
+
115
+ if (!checkSumAddress) {
116
+ return (
117
+ <div className="flex items-center">
118
+ <div
119
+ className="shrink-0 skeleton rounded-full"
120
+ style={{
121
+ width: (blockieSizeMap[blockieSize] * 24) / blockieSizeMap["base"],
122
+ height: (blockieSizeMap[blockieSize] * 24) / blockieSizeMap["base"],
123
+ }}
124
+ ></div>
125
+ <div className="flex flex-col space-y-1">
126
+ {!onlyEnsOrAddress && (
127
+ <div className={`ml-1.5 skeleton rounded-lg font-bold ${textSizeMap[ensSize]}`}>
128
+ <span className="invisible">0x1234...56789</span>
129
+ </div>
130
+ )}
131
+ <div className={`ml-1.5 skeleton rounded-lg ${textSizeMap[addressSize]}`}>
132
+ <span className="invisible">0x1234...56789</span>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ );
137
+ }
138
+
139
+ if (!isAddress(checkSumAddress)) {
140
+ return <span className="text-error">Wrong address</span>;
141
+ }
142
+
143
+ const blockExplorerAddressLink = getBlockExplorerAddressLink(targetNetwork, checkSumAddress);
144
+
145
+ return (
146
+ <div className="flex items-center shrink-0">
147
+ <div className="shrink-0">
148
+ <BlockieAvatar
149
+ address={checkSumAddress}
150
+ ensImage={ensAvatar}
151
+ size={(blockieSizeMap[blockieSize] * 24) / blockieSizeMap["base"]}
152
+ />
153
+ </div>
154
+ <div className="flex flex-col">
155
+ {showSkeleton &&
156
+ (isEnsNameLoading ? (
157
+ <div className={`ml-1.5 skeleton rounded-lg font-bold ${textSizeMap[ensSize]}`}>
158
+ <span className="invisible">{shortAddress}</span>
159
+ </div>
160
+ ) : (
161
+ <span className={`ml-1.5 ${textSizeMap[ensSize]} font-bold`}>
162
+ <AddressLinkWrapper
163
+ disableAddressLink={disableAddressLink}
164
+ blockExplorerAddressLink={blockExplorerAddressLink}
165
+ >
166
+ {ens}
167
+ </AddressLinkWrapper>
168
+ </span>
169
+ ))}
170
+ <div className="flex">
171
+ <span className={`ml-1.5 ${textSizeMap[addressSize]} font-normal`}>
172
+ <AddressLinkWrapper
173
+ disableAddressLink={disableAddressLink}
174
+ blockExplorerAddressLink={blockExplorerAddressLink}
175
+ >
176
+ {onlyEnsOrAddress ? displayEnsOrAddress : displayAddress}
177
+ </AddressLinkWrapper>
178
+ </span>
179
+ <AddressCopyIcon
180
+ className={`ml-1 ${copyIconSizeMap[addressSize]} cursor-pointer`}
181
+ address={checkSumAddress}
182
+ />
183
+ </div>
184
+ </div>
185
+ </div>
186
+ );
187
+ };
@@ -0,0 +1,23 @@
1
+ import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
2
+ import { useCopyToClipboard } from "~~/hooks/scaffold-eth/useCopyToClipboard";
3
+
4
+ export const AddressCopyIcon = ({ className, address }: { className?: string; address: string }) => {
5
+ const { copyToClipboard: copyAddressToClipboard, isCopiedToClipboard: isAddressCopiedToClipboard } =
6
+ useCopyToClipboard();
7
+
8
+ return (
9
+ <button
10
+ onClick={e => {
11
+ e.stopPropagation();
12
+ copyAddressToClipboard(address);
13
+ }}
14
+ type="button"
15
+ >
16
+ {isAddressCopiedToClipboard ? (
17
+ <CheckCircleIcon className={className} aria-hidden="true" />
18
+ ) : (
19
+ <DocumentDuplicateIcon className={className} aria-hidden="true" />
20
+ )}
21
+ </button>
22
+ );
23
+ };
@@ -0,0 +1,29 @@
1
+ import Link from "next/link";
2
+ import { useTargetNetwork } from "~~/hooks/scaffold-eth";
3
+ import { arbitrumNitro } from "~~/utils/scaffold-stylus/chain";
4
+
5
+ type AddressLinkWrapperProps = {
6
+ children: React.ReactNode;
7
+ disableAddressLink?: boolean;
8
+ blockExplorerAddressLink: string;
9
+ };
10
+
11
+ export const AddressLinkWrapper = ({
12
+ children,
13
+ disableAddressLink,
14
+ blockExplorerAddressLink,
15
+ }: AddressLinkWrapperProps) => {
16
+ const { targetNetwork } = useTargetNetwork();
17
+
18
+ return disableAddressLink ? (
19
+ <>{children}</>
20
+ ) : (
21
+ <Link
22
+ href={blockExplorerAddressLink}
23
+ target={targetNetwork.id === arbitrumNitro.id ? undefined : "_blank"}
24
+ rel={targetNetwork.id === arbitrumNitro.id ? undefined : "noopener noreferrer"}
25
+ >
26
+ {children}
27
+ </Link>
28
+ );
29
+ };