create-stylus 0.0.5

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 (220) 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/.github/workflows/release-manual.yml +26 -0
  5. package/.yarnrc.yml +1 -0
  6. package/CONTRIBUTING.md +42 -0
  7. package/README.md +66 -0
  8. package/bin/create-dapp-ss.js +4 -0
  9. package/package.json +46 -0
  10. package/rollup.config.js +22 -0
  11. package/src/cli.ts +14 -0
  12. package/src/extensions.json +14 -0
  13. package/src/main.ts +72 -0
  14. package/src/tasks/copy-extension-file.ts +227 -0
  15. package/src/tasks/copy-template-files.ts +252 -0
  16. package/src/tasks/create-first-git-commit.ts +35 -0
  17. package/src/tasks/create-project-directory.ts +34 -0
  18. package/src/tasks/index.ts +5 -0
  19. package/src/tasks/install-packages.ts +15 -0
  20. package/src/tasks/prettier-format.ts +17 -0
  21. package/src/types.ts +31 -0
  22. package/src/utils/consts.ts +1 -0
  23. package/src/utils/find-files-recursively.ts +19 -0
  24. package/src/utils/link.ts +44 -0
  25. package/src/utils/load-extensions.ts +10 -0
  26. package/src/utils/merge-package-json.ts +33 -0
  27. package/src/utils/parse-arguments-into-options.ts +38 -0
  28. package/src/utils/prompt-for-missing-options.ts +53 -0
  29. package/src/utils/render-intro-message.ts +11 -0
  30. package/src/utils/render-outro-message.ts +34 -0
  31. package/templates/base/.github/ISSUE_TEMPLATE/bug_report.yml +58 -0
  32. package/templates/base/.github/ISSUE_TEMPLATE/config.yml +8 -0
  33. package/templates/base/.github/pull_request_template.md +16 -0
  34. package/templates/base/.github/workflows/lint.yaml +300 -0
  35. package/templates/base/.gitignore.template.mjs +19 -0
  36. package/templates/base/.gitmodules +0 -0
  37. package/templates/base/.husky/pre-commit +4 -0
  38. package/templates/base/.lintstagedrc.js +21 -0
  39. package/templates/base/.vscode/settings.json +7 -0
  40. package/templates/base/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
  41. package/templates/base/.yarn/releases/yarn-3.2.3.cjs +783 -0
  42. package/templates/base/.yarnrc.yml +11 -0
  43. package/templates/base/CONTRIBUTING.md +86 -0
  44. package/templates/base/LICENCE +21 -0
  45. package/templates/base/dist/cli.js +683 -0
  46. package/templates/base/dist/cli.js.map +1 -0
  47. package/templates/base/nitro-devnode/LICENSE +201 -0
  48. package/templates/base/nitro-devnode/README.md +70 -0
  49. package/templates/base/nitro-devnode/run-dev-node.sh +132 -0
  50. package/templates/base/nitro-devnode/start-chain-with-cors.sh +150 -0
  51. package/templates/base/nitro-devnode/stylus-deployer-bytecode.txt +1 -0
  52. package/templates/base/nitro-devnode/stylus-dev/Dockerfile +10 -0
  53. package/templates/base/package.json +44 -0
  54. package/templates/base/packages/nextjs/.env.example +13 -0
  55. package/templates/base/packages/nextjs/.eslintignore +11 -0
  56. package/templates/base/packages/nextjs/.eslintrc.json +15 -0
  57. package/templates/base/packages/nextjs/.gitignore.template.mjs +42 -0
  58. package/templates/base/packages/nextjs/.prettierrc.js +9 -0
  59. package/templates/base/packages/nextjs/.prettierrc.json +8 -0
  60. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressCodeTab.tsx +27 -0
  61. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressComponent.tsx +36 -0
  62. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressLogsTab.tsx +21 -0
  63. package/templates/base/packages/nextjs/app/blockexplorer/_components/AddressStorageTab.tsx +61 -0
  64. package/templates/base/packages/nextjs/app/blockexplorer/_components/BackButton.tsx +12 -0
  65. package/templates/base/packages/nextjs/app/blockexplorer/_components/ContractTabs.tsx +102 -0
  66. package/templates/base/packages/nextjs/app/blockexplorer/_components/PaginationButton.tsx +39 -0
  67. package/templates/base/packages/nextjs/app/blockexplorer/_components/SearchBar.tsx +49 -0
  68. package/templates/base/packages/nextjs/app/blockexplorer/_components/TransactionHash.tsx +28 -0
  69. package/templates/base/packages/nextjs/app/blockexplorer/_components/TransactionsTable.tsx +71 -0
  70. package/templates/base/packages/nextjs/app/blockexplorer/_components/index.tsx +7 -0
  71. package/templates/base/packages/nextjs/app/blockexplorer/address/[address]/page.tsx +101 -0
  72. package/templates/base/packages/nextjs/app/blockexplorer/layout.tsx +12 -0
  73. package/templates/base/packages/nextjs/app/blockexplorer/page.tsx +83 -0
  74. package/templates/base/packages/nextjs/app/blockexplorer/transaction/[txHash]/page.tsx +23 -0
  75. package/templates/base/packages/nextjs/app/blockexplorer/transaction/_components/TransactionComp.tsx +152 -0
  76. package/templates/base/packages/nextjs/app/debug/_components/DebugContracts.tsx +73 -0
  77. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractInput.tsx +84 -0
  78. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractReadMethods.tsx +43 -0
  79. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractUI.tsx +164 -0
  80. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractVariables.tsx +50 -0
  81. package/templates/base/packages/nextjs/app/debug/_components/contract/ContractWriteMethods.tsx +49 -0
  82. package/templates/base/packages/nextjs/app/debug/_components/contract/DisplayVariable.tsx +85 -0
  83. package/templates/base/packages/nextjs/app/debug/_components/contract/InheritanceTooltip.tsx +14 -0
  84. package/templates/base/packages/nextjs/app/debug/_components/contract/ReadOnlyFunctionForm.tsx +102 -0
  85. package/templates/base/packages/nextjs/app/debug/_components/contract/Tuple.tsx +44 -0
  86. package/templates/base/packages/nextjs/app/debug/_components/contract/TupleArray.tsx +142 -0
  87. package/templates/base/packages/nextjs/app/debug/_components/contract/TxReceipt.tsx +42 -0
  88. package/templates/base/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx +144 -0
  89. package/templates/base/packages/nextjs/app/debug/_components/contract/index.tsx +8 -0
  90. package/templates/base/packages/nextjs/app/debug/_components/contract/utilsContract.tsx +166 -0
  91. package/templates/base/packages/nextjs/app/debug/_components/contract/utilsDisplay.tsx +114 -0
  92. package/templates/base/packages/nextjs/app/debug/page.tsx +14 -0
  93. package/templates/base/packages/nextjs/app/layout.tsx +67 -0
  94. package/templates/base/packages/nextjs/app/not-found.tsx +16 -0
  95. package/templates/base/packages/nextjs/app/page.tsx +94 -0
  96. package/templates/base/packages/nextjs/components/Background.tsx +37 -0
  97. package/templates/base/packages/nextjs/components/Card.tsx +40 -0
  98. package/templates/base/packages/nextjs/components/Footer.tsx +93 -0
  99. package/templates/base/packages/nextjs/components/Header.tsx +114 -0
  100. package/templates/base/packages/nextjs/components/ScaffoldEthAppWithProviders.tsx +77 -0
  101. package/templates/base/packages/nextjs/components/SwitchTheme.tsx +41 -0
  102. package/templates/base/packages/nextjs/components/ThemeProvider.tsx +13 -0
  103. package/templates/base/packages/nextjs/components/assets/BuidlGuidlLogo.tsx +18 -0
  104. package/templates/base/packages/nextjs/components/scaffold-eth/Address/Address.tsx +187 -0
  105. package/templates/base/packages/nextjs/components/scaffold-eth/Address/AddressCopyIcon.tsx +23 -0
  106. package/templates/base/packages/nextjs/components/scaffold-eth/Address/AddressLinkWrapper.tsx +29 -0
  107. package/templates/base/packages/nextjs/components/scaffold-eth/Balance.tsx +75 -0
  108. package/templates/base/packages/nextjs/components/scaffold-eth/BlockieAvatar.tsx +17 -0
  109. package/templates/base/packages/nextjs/components/scaffold-eth/Faucet.tsx +131 -0
  110. package/templates/base/packages/nextjs/components/scaffold-eth/FaucetButton.tsx +75 -0
  111. package/templates/base/packages/nextjs/components/scaffold-eth/Input/AddressInput.tsx +120 -0
  112. package/templates/base/packages/nextjs/components/scaffold-eth/Input/Bytes32Input.tsx +31 -0
  113. package/templates/base/packages/nextjs/components/scaffold-eth/Input/BytesInput.tsx +28 -0
  114. package/templates/base/packages/nextjs/components/scaffold-eth/Input/EtherInput.tsx +128 -0
  115. package/templates/base/packages/nextjs/components/scaffold-eth/Input/InputBase.tsx +66 -0
  116. package/templates/base/packages/nextjs/components/scaffold-eth/Input/IntegerInput.tsx +63 -0
  117. package/templates/base/packages/nextjs/components/scaffold-eth/Input/index.ts +9 -0
  118. package/templates/base/packages/nextjs/components/scaffold-eth/Input/utils.ts +109 -0
  119. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/AddressInfoDropdown.tsx +121 -0
  120. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/AddressQRCodeModal.tsx +33 -0
  121. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/BurnerWalletModal.tsx +63 -0
  122. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx +48 -0
  123. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/WrongNetworkDropdown.tsx +32 -0
  124. package/templates/base/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx +89 -0
  125. package/templates/base/packages/nextjs/components/scaffold-eth/index.tsx +7 -0
  126. package/templates/base/packages/nextjs/contracts/deployedContracts.ts +9 -0
  127. package/templates/base/packages/nextjs/contracts/externalContracts.ts +16 -0
  128. package/templates/base/packages/nextjs/eslint.config.mjs +32 -0
  129. package/templates/base/packages/nextjs/hooks/scaffold-eth/index.ts +17 -0
  130. package/templates/base/packages/nextjs/hooks/scaffold-eth/useAnimationConfig.ts +20 -0
  131. package/templates/base/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts +40 -0
  132. package/templates/base/packages/nextjs/hooks/scaffold-eth/useCopyToClipboard.ts +19 -0
  133. package/templates/base/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts +86 -0
  134. package/templates/base/packages/nextjs/hooks/scaffold-eth/useDisplayUsdMode.ts +21 -0
  135. package/templates/base/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts +133 -0
  136. package/templates/base/packages/nextjs/hooks/scaffold-eth/useInitializeNativeCurrencyPrice.ts +32 -0
  137. package/templates/base/packages/nextjs/hooks/scaffold-eth/useNativeCurrencyPrice.ts +34 -0
  138. package/templates/base/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts +22 -0
  139. package/templates/base/packages/nextjs/hooks/scaffold-eth/useOutsideClick.ts +23 -0
  140. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts +65 -0
  141. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts +213 -0
  142. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts +80 -0
  143. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts +40 -0
  144. package/templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts +191 -0
  145. package/templates/base/packages/nextjs/hooks/scaffold-eth/useSelectedNetwork.ts +18 -0
  146. package/templates/base/packages/nextjs/hooks/scaffold-eth/useTargetNetwork.ts +23 -0
  147. package/templates/base/packages/nextjs/hooks/scaffold-eth/useTransactor.tsx +114 -0
  148. package/templates/base/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts +21 -0
  149. package/templates/base/packages/nextjs/icons/CompassIcon.tsx +39 -0
  150. package/templates/base/packages/nextjs/icons/DarkBugAntIcon.tsx +30 -0
  151. package/templates/base/packages/nextjs/icons/LightBugAntIcon.tsx +52 -0
  152. package/templates/base/packages/nextjs/next-env.d.ts +5 -0
  153. package/templates/base/packages/nextjs/next.config.js +19 -0
  154. package/templates/base/packages/nextjs/package.json +58 -0
  155. package/templates/base/packages/nextjs/postcss.config.js +6 -0
  156. package/templates/base/packages/nextjs/public/debug-image.png +0 -0
  157. package/templates/base/packages/nextjs/public/favicon.png +0 -0
  158. package/templates/base/packages/nextjs/public/logo.svg +8 -0
  159. package/templates/base/packages/nextjs/public/manifest.json +5 -0
  160. package/templates/base/packages/nextjs/public/thumbnail.jpg +0 -0
  161. package/templates/base/packages/nextjs/react-copy-to-clipboard.d.ts +44 -0
  162. package/templates/base/packages/nextjs/scaffold.config.ts +56 -0
  163. package/templates/base/packages/nextjs/services/store/store.ts +39 -0
  164. package/templates/base/packages/nextjs/services/web3/wagmiConfig.tsx +44 -0
  165. package/templates/base/packages/nextjs/services/web3/wagmiConnectors.tsx +51 -0
  166. package/templates/base/packages/nextjs/styles/globals.css +80 -0
  167. package/templates/base/packages/nextjs/tailwind.config.js +97 -0
  168. package/templates/base/packages/nextjs/tsconfig.json +28 -0
  169. package/templates/base/packages/nextjs/types/abitype/abi.d.ts +16 -0
  170. package/templates/base/packages/nextjs/types/utils.ts +3 -0
  171. package/templates/base/packages/nextjs/utils/scaffold-eth/block.ts +17 -0
  172. package/templates/base/packages/nextjs/utils/scaffold-eth/common.ts +8 -0
  173. package/templates/base/packages/nextjs/utils/scaffold-eth/contract.ts +352 -0
  174. package/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts +11 -0
  175. package/templates/base/packages/nextjs/utils/scaffold-eth/decodeTxData.ts +65 -0
  176. package/templates/base/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts +72 -0
  177. package/templates/base/packages/nextjs/utils/scaffold-eth/getMetadata.ts +50 -0
  178. package/templates/base/packages/nextjs/utils/scaffold-eth/getParsedError.ts +35 -0
  179. package/templates/base/packages/nextjs/utils/scaffold-eth/index.ts +6 -0
  180. package/templates/base/packages/nextjs/utils/scaffold-eth/notification.tsx +90 -0
  181. package/templates/base/packages/nextjs/utils/scaffold-stylus/burner.ts +59 -0
  182. package/templates/base/packages/nextjs/utils/scaffold-stylus/chain.ts +42 -0
  183. package/templates/base/packages/nextjs/utils/scaffold-stylus/index.ts +3 -0
  184. package/templates/base/packages/nextjs/utils/scaffold-stylus/networks.ts +94 -0
  185. package/templates/base/packages/nextjs/vercel.json +3 -0
  186. package/templates/base/packages/stylus/.env.example +16 -0
  187. package/templates/base/packages/stylus/.eslintrc.js +23 -0
  188. package/templates/base/packages/stylus/.gitignore.template.mjs +7 -0
  189. package/templates/base/packages/stylus/jest.config.js +15 -0
  190. package/templates/base/packages/stylus/package.json +48 -0
  191. package/templates/base/packages/stylus/scripts/deploy.ts +46 -0
  192. package/templates/base/packages/stylus/scripts/deploy_contract.ts +84 -0
  193. package/templates/base/packages/stylus/scripts/deploy_wrapper.ts +39 -0
  194. package/templates/base/packages/stylus/scripts/export_abi.ts +87 -0
  195. package/templates/base/packages/stylus/scripts/index.ts +0 -0
  196. package/templates/base/packages/stylus/scripts/new_module.sh +35 -0
  197. package/templates/base/packages/stylus/scripts/test_network.ts +31 -0
  198. package/templates/base/packages/stylus/scripts/utils/command.ts +152 -0
  199. package/templates/base/packages/stylus/scripts/utils/contract.ts +228 -0
  200. package/templates/base/packages/stylus/scripts/utils/deployment.ts +260 -0
  201. package/templates/base/packages/stylus/scripts/utils/index.ts +6 -0
  202. package/templates/base/packages/stylus/scripts/utils/network.ts +132 -0
  203. package/templates/base/packages/stylus/scripts/utils/type.ts +51 -0
  204. package/templates/base/packages/stylus/scripts/utils.ts +3 -0
  205. package/templates/base/packages/stylus/tsconfig.json +41 -0
  206. package/templates/base/packages/stylus/your-contract/.cargo/config.toml +18 -0
  207. package/templates/base/packages/stylus/your-contract/Cargo.lock +5761 -0
  208. package/templates/base/packages/stylus/your-contract/Cargo.toml +48 -0
  209. package/templates/base/packages/stylus/your-contract/examples/counter.rs +78 -0
  210. package/templates/base/packages/stylus/your-contract/header.png +0 -0
  211. package/templates/base/packages/stylus/your-contract/licenses/Apache-2.0 +201 -0
  212. package/templates/base/packages/stylus/your-contract/licenses/COPYRIGHT.md +5 -0
  213. package/templates/base/packages/stylus/your-contract/licenses/DCO.txt +34 -0
  214. package/templates/base/packages/stylus/your-contract/licenses/MIT +21 -0
  215. package/templates/base/packages/stylus/your-contract/rust-toolchain.toml +2 -0
  216. package/templates/base/packages/stylus/your-contract/src/lib.rs +241 -0
  217. package/templates/base/packages/stylus/your-contract/src/main.rs +10 -0
  218. package/templates/base/readme.md +352 -0
  219. package/templates/base/yarn.lock +17859 -0
  220. package/tsconfig.json +13 -0
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "ss",
3
+ "version": "0.0.5",
4
+ "private": true,
5
+ "workspaces": {
6
+ "packages": [
7
+ "packages/stylus",
8
+ "packages/nextjs"
9
+ ]
10
+ },
11
+ "scripts": {
12
+ "account": "yarn workspace @ss/stylus account",
13
+ "chain": "./nitro-devnode/start-chain-with-cors.sh",
14
+ "fork": "yarn workspace @ss/stylus fork",
15
+ "deploy": "yarn workspace @ss/stylus deploy",
16
+ "export-abi": "yarn workspace @ss/stylus export-abi",
17
+ "verify": "yarn workspace @ss/stylus verify",
18
+ "stylus-verify": "yarn workspace @ss/stylus stylus-verify",
19
+ "compile": "yarn workspace @ss/stylus compile",
20
+ "generate": "yarn workspace @ss/stylus generate",
21
+ "flatten": "yarn workspace @ss/stylus flatten",
22
+ "stylus:lint": "yarn workspace @ss/stylus lint",
23
+ "stylus:format": "yarn workspace @ss/stylus format",
24
+ "stylus:test": "yarn workspace @ss/stylus test",
25
+ "test": "yarn stylus:test",
26
+ "test:networks": "yarn workspace @ss/stylus test:networks",
27
+ "format": "yarn next:format",
28
+ "start": "yarn workspace @ss/nextjs dev",
29
+ "next:lint": "yarn workspace @ss/nextjs lint",
30
+ "next:format": "yarn workspace @ss/nextjs format",
31
+ "next:check-types": "yarn workspace @ss/nextjs check-types",
32
+ "next:build": "yarn workspace @ss/nextjs build",
33
+ "postinstall": "husky install",
34
+ "precommit": "lint-staged",
35
+ "vercel": "yarn workspace @ss/nextjs vercel",
36
+ "vercel:yolo": "yarn workspace @ss/nextjs vercel:yolo",
37
+ "new-module": "yarn workspace @ss/stylus new-module"
38
+ },
39
+ "packageManager": "yarn@3.2.3",
40
+ "devDependencies": {
41
+ "husky": "^8.0.1",
42
+ "lint-staged": "^13.0.3"
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ # Template for NextJS environment variables.
2
+
3
+ # For local development, copy this file, rename it to .env.local, and fill in the values.
4
+ # When deploying live, you'll need to store the vars in Vercel/System config.
5
+
6
+ # If not set, we provide default values (check `scaffold.config.ts`) so developers can start prototyping out of the box,
7
+ # but we recommend getting your own API Keys for Production Apps.
8
+
9
+ # To access the values stored in this env file you can use: process.env.VARIABLENAME
10
+ # You'll need to prefix the variables names with NEXT_PUBLIC_ if you want to access them on the client side.
11
+ # More info: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
12
+ NEXT_PUBLIC_ALCHEMY_API_KEY=
13
+ NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
@@ -0,0 +1,11 @@
1
+ # folders
2
+ .next
3
+ node_modules/
4
+ # files
5
+ **/*.less
6
+ **/*.css
7
+ **/*.scss
8
+ **/*.json
9
+ **/*.png
10
+ **/*.svg
11
+ **/generated/**/*
@@ -0,0 +1,15 @@
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "extends": ["next/core-web-vitals", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended"],
4
+ "rules": {
5
+ "@typescript-eslint/no-unused-vars": ["error"],
6
+ "@typescript-eslint/no-explicit-any": ["off"],
7
+ "@typescript-eslint/ban-ts-comment": ["off"],
8
+ "prettier/prettier": [
9
+ "warn",
10
+ {
11
+ "endOfLine": "auto"
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,42 @@
1
+ const contents = () =>
2
+ `# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3
+
4
+ # dependencies
5
+ /node_modules
6
+ /.pnp
7
+ .pnp.js
8
+
9
+ # testing
10
+ /coverage
11
+
12
+ # next.js
13
+ /.next/
14
+ /out/
15
+ .vercel
16
+
17
+ # production
18
+ /build
19
+
20
+ # misc
21
+ .DS_Store
22
+ *.pem
23
+
24
+ # debug
25
+ npm-debug.log*
26
+ yarn-debug.log*
27
+ yarn-error.log*
28
+ .pnpm-debug.log*
29
+
30
+ # local env files
31
+ .env
32
+ .env.local
33
+ .env.development.local
34
+ .env.test.local
35
+ .env.production.local
36
+
37
+ # typescript
38
+ *.tsbuildinfo
39
+
40
+ ipfs-upload.config.json`
41
+
42
+ export default contents;
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ arrowParens: "avoid",
3
+ printWidth: 120,
4
+ tabWidth: 2,
5
+ trailingComma: "all",
6
+ importOrder: ["^react$", "^next/(.*)$", "<THIRD_PARTY_MODULES>", "^@heroicons/(.*)$", "^~~/(.*)$"],
7
+ importOrderSortSpecifiers: true,
8
+ plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")],
9
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "printWidth": 120,
4
+ "tabWidth": 2,
5
+ "trailingComma": "all",
6
+ "importOrder": ["^react$", "^next/(.*)$", "<THIRD_PARTY_MODULES>", "^@heroicons/(.*)$", "^~~/(.*)$"],
7
+ "importOrderSortSpecifiers": true
8
+ }
@@ -0,0 +1,27 @@
1
+ type AddressCodeTabProps = {
2
+ bytecode: string;
3
+ assembly: string;
4
+ };
5
+
6
+ export const AddressCodeTab = ({ bytecode, assembly }: AddressCodeTabProps) => {
7
+ const formattedAssembly = Array.from(assembly.matchAll(/\w+( 0x[a-fA-F0-9]+)?/g))
8
+ .map(it => it[0])
9
+ .join("\n");
10
+
11
+ return (
12
+ <div className="flex flex-col gap-3 p-4">
13
+ Bytecode
14
+ <div className="mockup-code -indent-5 overflow-y-auto max-h-[500px]">
15
+ <pre className="px-5">
16
+ <code className="whitespace-pre-wrap overflow-auto break-words">{bytecode}</code>
17
+ </pre>
18
+ </div>
19
+ Opcodes
20
+ <div className="mockup-code -indent-5 overflow-y-auto max-h-[500px]">
21
+ <pre className="px-5">
22
+ <code>{formattedAssembly}</code>
23
+ </pre>
24
+ </div>
25
+ </div>
26
+ );
27
+ };
@@ -0,0 +1,36 @@
1
+ import { BackButton } from "./BackButton";
2
+ import { ContractTabs } from "./ContractTabs";
3
+ import { Address as AddressType } from "viem";
4
+ import { Address, Balance } from "~~/components/scaffold-eth";
5
+
6
+ export const AddressComponent = ({
7
+ address,
8
+ contractData,
9
+ }: {
10
+ address: AddressType;
11
+ contractData: { bytecode: string; assembly: string } | null;
12
+ }) => {
13
+ return (
14
+ <div className="m-10 mb-20">
15
+ <div className="flex justify-start mb-5">
16
+ <BackButton />
17
+ </div>
18
+ <div className="col-span-5 grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-10">
19
+ <div className="col-span-1 flex flex-col">
20
+ <div className="bg-base-100 border-base-300 border shadow-md shadow-secondary rounded-3xl px-6 lg:px-8 mb-6 space-y-1 py-4 overflow-x-auto">
21
+ <div className="flex">
22
+ <div className="flex flex-col gap-1">
23
+ <Address address={address} format="long" onlyEnsOrAddress />
24
+ <div className="flex gap-1 items-center">
25
+ <span className="font-bold text-sm">Balance:</span>
26
+ <Balance address={address} className="text" />
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ <ContractTabs address={address} contractData={contractData} />
34
+ </div>
35
+ );
36
+ };
@@ -0,0 +1,21 @@
1
+ import { Address } from "viem";
2
+ import { useContractLogs } from "~~/hooks/scaffold-eth";
3
+ import { replacer } from "~~/utils/scaffold-eth/common";
4
+
5
+ export const AddressLogsTab = ({ address }: { address: Address }) => {
6
+ const contractLogs = useContractLogs(address);
7
+
8
+ return (
9
+ <div className="flex flex-col gap-3 p-4">
10
+ <div className="mockup-code overflow-auto max-h-[500px]">
11
+ <pre className="px-5 whitespace-pre-wrap break-words">
12
+ {contractLogs.map((log, i) => (
13
+ <div key={i}>
14
+ <strong>Log:</strong> {JSON.stringify(log, replacer, 2)}
15
+ </div>
16
+ ))}
17
+ </pre>
18
+ </div>
19
+ </div>
20
+ );
21
+ };
@@ -0,0 +1,61 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { Address, createPublicClient, http, toHex } from "viem";
5
+ import { arbitrumNitro } from "~~/utils/scaffold-stylus/chain";
6
+
7
+ const publicClient = createPublicClient({
8
+ chain: arbitrumNitro,
9
+ transport: http(),
10
+ });
11
+
12
+ export const AddressStorageTab = ({ address }: { address: Address }) => {
13
+ const [storage, setStorage] = useState<string[]>([]);
14
+
15
+ useEffect(() => {
16
+ const fetchStorage = async () => {
17
+ try {
18
+ const storageData = [];
19
+ let idx = 0;
20
+
21
+ while (true) {
22
+ const storageAtPosition = await publicClient.getStorageAt({
23
+ address: address,
24
+ slot: toHex(idx),
25
+ });
26
+
27
+ if (storageAtPosition === "0x" + "0".repeat(64)) break;
28
+
29
+ if (storageAtPosition) {
30
+ storageData.push(storageAtPosition);
31
+ }
32
+
33
+ idx++;
34
+ }
35
+ setStorage(storageData);
36
+ } catch (error) {
37
+ console.error("Failed to fetch storage:", error);
38
+ }
39
+ };
40
+
41
+ fetchStorage();
42
+ }, [address]);
43
+
44
+ return (
45
+ <div className="flex flex-col gap-3 p-4">
46
+ {storage.length > 0 ? (
47
+ <div className="mockup-code overflow-auto max-h-[500px]">
48
+ <pre className="px-5 whitespace-pre-wrap break-words">
49
+ {storage.map((data, i) => (
50
+ <div key={i}>
51
+ <strong>Storage Slot {i}:</strong> {data}
52
+ </div>
53
+ ))}
54
+ </pre>
55
+ </div>
56
+ ) : (
57
+ <div className="text-lg">This contract does not have any variables.</div>
58
+ )}
59
+ </div>
60
+ );
61
+ };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+
5
+ export const BackButton = () => {
6
+ const router = useRouter();
7
+ return (
8
+ <button className="btn btn-sm btn-primary" onClick={() => router.back()}>
9
+ Back
10
+ </button>
11
+ );
12
+ };
@@ -0,0 +1,102 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { AddressCodeTab } from "./AddressCodeTab";
5
+ import { AddressLogsTab } from "./AddressLogsTab";
6
+ import { AddressStorageTab } from "./AddressStorageTab";
7
+ import { PaginationButton } from "./PaginationButton";
8
+ import { TransactionsTable } from "./TransactionsTable";
9
+ import { Address, createPublicClient, http } from "viem";
10
+ import { useFetchBlocks } from "~~/hooks/scaffold-eth";
11
+ import { arbitrumNitro } from "~~/utils/scaffold-stylus/chain";
12
+
13
+ type AddressCodeTabProps = {
14
+ bytecode: string;
15
+ assembly: string;
16
+ };
17
+
18
+ type PageProps = {
19
+ address: Address;
20
+ contractData: AddressCodeTabProps | null;
21
+ };
22
+
23
+ const publicClient = createPublicClient({
24
+ chain: arbitrumNitro,
25
+ transport: http(),
26
+ });
27
+
28
+ export const ContractTabs = ({ address, contractData }: PageProps) => {
29
+ const { blocks, transactionReceipts, currentPage, totalBlocks, setCurrentPage } = useFetchBlocks();
30
+ const [activeTab, setActiveTab] = useState("transactions");
31
+ const [isContract, setIsContract] = useState(false);
32
+
33
+ useEffect(() => {
34
+ const checkIsContract = async () => {
35
+ const contractCode = await publicClient.getBytecode({ address: address });
36
+ setIsContract(contractCode !== undefined && contractCode !== "0x");
37
+ };
38
+
39
+ checkIsContract();
40
+ }, [address]);
41
+
42
+ const filteredBlocks = blocks.filter(block =>
43
+ block.transactions.some(tx => {
44
+ if (typeof tx === "string") {
45
+ return false;
46
+ }
47
+ return tx.from.toLowerCase() === address.toLowerCase() || tx.to?.toLowerCase() === address.toLowerCase();
48
+ }),
49
+ );
50
+
51
+ return (
52
+ <>
53
+ {isContract && (
54
+ <div role="tablist" className="tabs tabs-lift">
55
+ <button
56
+ role="tab"
57
+ className={`tab ${activeTab === "transactions" ? "tab-active" : ""}`}
58
+ onClick={() => setActiveTab("transactions")}
59
+ >
60
+ Transactions
61
+ </button>
62
+ <button
63
+ role="tab"
64
+ className={`tab ${activeTab === "code" ? "tab-active" : ""}`}
65
+ onClick={() => setActiveTab("code")}
66
+ >
67
+ Code
68
+ </button>
69
+ <button
70
+ role="tab"
71
+ className={`tab ${activeTab === "storage" ? "tab-active" : ""}`}
72
+ onClick={() => setActiveTab("storage")}
73
+ >
74
+ Storage
75
+ </button>
76
+ <button
77
+ role="tab"
78
+ className={`tab ${activeTab === "logs" ? "tab-active" : ""}`}
79
+ onClick={() => setActiveTab("logs")}
80
+ >
81
+ Logs
82
+ </button>
83
+ </div>
84
+ )}
85
+ {activeTab === "transactions" && (
86
+ <div className="pt-4">
87
+ <TransactionsTable blocks={filteredBlocks} transactionReceipts={transactionReceipts} />
88
+ <PaginationButton
89
+ currentPage={currentPage}
90
+ totalItems={Number(totalBlocks)}
91
+ setCurrentPage={setCurrentPage}
92
+ />
93
+ </div>
94
+ )}
95
+ {activeTab === "code" && contractData && (
96
+ <AddressCodeTab bytecode={contractData.bytecode} assembly={contractData.assembly} />
97
+ )}
98
+ {activeTab === "storage" && <AddressStorageTab address={address} />}
99
+ {activeTab === "logs" && <AddressLogsTab address={address} />}
100
+ </>
101
+ );
102
+ };
@@ -0,0 +1,39 @@
1
+ import { ArrowLeftIcon, ArrowRightIcon } from "@heroicons/react/24/outline";
2
+
3
+ type PaginationButtonProps = {
4
+ currentPage: number;
5
+ totalItems: number;
6
+ setCurrentPage: (page: number) => void;
7
+ };
8
+
9
+ const ITEMS_PER_PAGE = 20;
10
+
11
+ export const PaginationButton = ({ currentPage, totalItems, setCurrentPage }: PaginationButtonProps) => {
12
+ const isPrevButtonDisabled = currentPage === 0;
13
+ const isNextButtonDisabled = currentPage + 1 >= Math.ceil(totalItems / ITEMS_PER_PAGE);
14
+
15
+ const prevButtonClass = isPrevButtonDisabled ? "btn-disabled cursor-default" : "btn-primary";
16
+ const nextButtonClass = isNextButtonDisabled ? "btn-disabled cursor-default" : "btn-primary";
17
+
18
+ if (isNextButtonDisabled && isPrevButtonDisabled) return null;
19
+
20
+ return (
21
+ <div className="mt-5 justify-end flex gap-3 mx-5">
22
+ <button
23
+ className={`btn btn-sm ${prevButtonClass}`}
24
+ disabled={isPrevButtonDisabled}
25
+ onClick={() => setCurrentPage(currentPage - 1)}
26
+ >
27
+ <ArrowLeftIcon className="h-4 w-4" />
28
+ </button>
29
+ <span className="self-center text-primary-content font-medium">Page {currentPage + 1}</span>
30
+ <button
31
+ className={`btn btn-sm ${nextButtonClass}`}
32
+ disabled={isNextButtonDisabled}
33
+ onClick={() => setCurrentPage(currentPage + 1)}
34
+ >
35
+ <ArrowRightIcon className="h-4 w-4" />
36
+ </button>
37
+ </div>
38
+ );
39
+ };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import { useRouter } from "next/navigation";
5
+ import { isAddress, isHex } from "viem";
6
+ import { usePublicClient } from "wagmi";
7
+ import { arbitrumNitro } from "~~/utils/scaffold-stylus/chain";
8
+
9
+ export const SearchBar = () => {
10
+ const [searchInput, setSearchInput] = useState("");
11
+ const router = useRouter();
12
+
13
+ const client = usePublicClient({ chainId: arbitrumNitro.id });
14
+
15
+ const handleSearch = async (event: React.FormEvent) => {
16
+ event.preventDefault();
17
+ if (isHex(searchInput)) {
18
+ try {
19
+ const tx = await client?.getTransaction({ hash: searchInput });
20
+ if (tx) {
21
+ router.push(`/blockexplorer/transaction/${searchInput}`);
22
+ return;
23
+ }
24
+ } catch (error) {
25
+ console.error("Failed to fetch transaction:", error);
26
+ }
27
+ }
28
+
29
+ if (isAddress(searchInput)) {
30
+ router.push(`/blockexplorer/address/${searchInput}`);
31
+ return;
32
+ }
33
+ };
34
+
35
+ return (
36
+ <form onSubmit={handleSearch} className="flex items-center justify-end mb-5 space-x-3 mx-5">
37
+ <input
38
+ className="border-primary bg-base-100 text-base-content placeholder:text-base-content/50 p-2 mr-2 w-full md:w-1/2 lg:w-1/3 rounded-md shadow-md focus:outline-hidden focus:ring-2 focus:ring-accent"
39
+ type="text"
40
+ value={searchInput}
41
+ placeholder="Search by hash or address"
42
+ onChange={e => setSearchInput(e.target.value)}
43
+ />
44
+ <button className="btn btn-sm btn-primary" type="submit">
45
+ Search
46
+ </button>
47
+ </form>
48
+ );
49
+ };
@@ -0,0 +1,28 @@
1
+ import Link from "next/link";
2
+ import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
3
+ import { useCopyToClipboard } from "~~/hooks/scaffold-eth/useCopyToClipboard";
4
+
5
+ export const TransactionHash = ({ hash }: { hash: string }) => {
6
+ const { copyToClipboard: copyAddressToClipboard, isCopiedToClipboard: isAddressCopiedToClipboard } =
7
+ useCopyToClipboard();
8
+
9
+ return (
10
+ <div className="flex items-center">
11
+ <Link href={`/blockexplorer/transaction/${hash}`}>
12
+ {hash?.substring(0, 6)}...{hash?.substring(hash.length - 4)}
13
+ </Link>
14
+ {isAddressCopiedToClipboard ? (
15
+ <CheckCircleIcon
16
+ className="ml-1.5 text-xl font-normal text-base-content h-5 w-5 cursor-pointer"
17
+ aria-hidden="true"
18
+ />
19
+ ) : (
20
+ <DocumentDuplicateIcon
21
+ className="ml-1.5 text-xl font-normal h-5 w-5 cursor-pointer"
22
+ aria-hidden="true"
23
+ onClick={() => copyAddressToClipboard(hash)}
24
+ />
25
+ )}
26
+ </div>
27
+ );
28
+ };
@@ -0,0 +1,71 @@
1
+ import { TransactionHash } from "./TransactionHash";
2
+ import { formatEther } from "viem";
3
+ import { Address } from "~~/components/scaffold-eth";
4
+ import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
5
+ import { TransactionWithFunction } from "~~/utils/scaffold-eth";
6
+ import { TransactionsTableProps } from "~~/utils/scaffold-eth/";
7
+
8
+ export const TransactionsTable = ({ blocks, transactionReceipts }: TransactionsTableProps) => {
9
+ const { targetNetwork } = useTargetNetwork();
10
+
11
+ return (
12
+ <div className="flex justify-center px-4 md:px-0">
13
+ <div className="overflow-x-auto w-full shadow-2xl rounded-xl">
14
+ <table className="table text-xl bg-base-100 table-zebra w-full md:table-md table-sm">
15
+ <thead>
16
+ <tr className="rounded-xl text-sm text-base-content">
17
+ <th className="bg-primary">Transaction Hash</th>
18
+ <th className="bg-primary">Function Called</th>
19
+ <th className="bg-primary">Block Number</th>
20
+ <th className="bg-primary">Time Mined</th>
21
+ <th className="bg-primary">From</th>
22
+ <th className="bg-primary">To</th>
23
+ <th className="bg-primary text-end">Value ({targetNetwork.nativeCurrency.symbol})</th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ {blocks.map(block =>
28
+ (block.transactions as TransactionWithFunction[]).map(tx => {
29
+ const receipt = transactionReceipts[tx.hash];
30
+ const timeMined = new Date(Number(block.timestamp) * 1000).toLocaleString();
31
+ const functionCalled = tx.input.substring(0, 10);
32
+
33
+ return (
34
+ <tr key={tx.hash} className="hover text-sm">
35
+ <td className="w-1/12 md:py-4">
36
+ <TransactionHash hash={tx.hash} />
37
+ </td>
38
+ <td className="w-2/12 md:py-4">
39
+ {tx.functionName === "0x" ? "" : <span className="mr-1">{tx.functionName}</span>}
40
+ {functionCalled !== "0x" && (
41
+ <span className="badge badge-primary font-bold text-xs">{functionCalled}</span>
42
+ )}
43
+ </td>
44
+ <td className="w-1/12 md:py-4">{block.number?.toString()}</td>
45
+ <td className="w-2/12 md:py-4">{timeMined}</td>
46
+ <td className="w-2/12 md:py-4">
47
+ <Address address={tx.from} size="sm" onlyEnsOrAddress />
48
+ </td>
49
+ <td className="w-2/12 md:py-4">
50
+ {!receipt?.contractAddress ? (
51
+ tx.to && <Address address={tx.to} size="sm" onlyEnsOrAddress />
52
+ ) : (
53
+ <div className="relative">
54
+ <Address address={receipt.contractAddress} size="sm" onlyEnsOrAddress />
55
+ <small className="absolute top-4 left-4">(Contract Creation)</small>
56
+ </div>
57
+ )}
58
+ </td>
59
+ <td className="text-right md:py-4">
60
+ {formatEther(tx.value)} {targetNetwork.nativeCurrency.symbol}
61
+ </td>
62
+ </tr>
63
+ );
64
+ }),
65
+ )}
66
+ </tbody>
67
+ </table>
68
+ </div>
69
+ </div>
70
+ );
71
+ };
@@ -0,0 +1,7 @@
1
+ export * from "./SearchBar";
2
+ export * from "./BackButton";
3
+ export * from "./AddressCodeTab";
4
+ export * from "./TransactionHash";
5
+ export * from "./ContractTabs";
6
+ export * from "./PaginationButton";
7
+ export * from "./TransactionsTable";