From daa6d8d6c2f6926a9a3d66e03e9c25575ee55668 Mon Sep 17 00:00:00 2001 From: Nadai <112663528+Nadai2010@users.noreply.github.com> Date: Tue, 13 Aug 2024 19:59:36 +0100 Subject: [PATCH] Update Challenge-token-vendor last Version Scaffold Stark (#102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Carlos Ramos <88168831+jrcarlos2000@users.noreply.github.com> Co-authored-by: Gabriela del Pilar Rojas <77763655+GabrielaDelPilarR@users.noreply.github.com> Co-authored-by: 0xquantum3labs Co-authored-by: jrcarlos2000 Co-authored-by: Daniel Calderón Díaz <66186331+danielcdz@users.noreply.github.com> Co-authored-by: gianmalarcon Co-authored-by: Ugonna Paul Dike Co-authored-by: Eduardo <43045722+edulanasca@users.noreply.github.com> Co-authored-by: Eduardo Co-authored-by: github-actions[bot] Co-authored-by: oceanlvr <657531018@qq.com> Co-authored-by: Quantum3Labs <157618676+0xquantum3labs@users.noreply.github.com> Co-authored-by: gianalarcon Co-authored-by: Gabriela del Pilar Rojas Co-authored-by: Richard <53423618+metalboyrick@users.noreply.github.com> Co-authored-by: CarlosR Co-authored-by: Abdulhakeem Abdulazeez Ayodeji <44169294+Ayoazeez26@users.noreply.github.com> Co-authored-by: Ikem <91676649+ikemHood@users.noreply.github.com> Co-authored-by: Wolf <81079370+raizo07@users.noreply.github.com> Co-authored-by: Joseph Chimebuka Co-authored-by: Jemiiah <160767568+Jemiiah@users.noreply.github.com> --- .github/workflows/demo.yaml | 64 +++ .github/workflows/lint.yml | 6 - .github/workflows/release-create-stark.yaml | 114 +++++ README.md | 2 +- package.json | 3 +- .../debug/_components/contract/ContractUI.tsx | 16 +- .../contract/ReadOnlyFunctionForm.tsx | 1 + packages/nextjs/app/debug/page.tsx | 10 + packages/nextjs/app/token-vendor/page.tsx | 2 +- packages/nextjs/components/Footer.tsx | 74 ++- packages/nextjs/components/Header.tsx | 8 +- packages/nextjs/components/SwitchTheme.tsx | 9 +- .../components/scaffold-stark/Balance.tsx | 88 ++-- .../scaffold-stark/BlockExplorer.tsx | 86 ++++ .../scaffold-stark/BlockExplorerSepolia.tsx | 89 ++++ .../components/scaffold-stark/ClassHash.tsx | 85 ++++ .../AddressInfoDropdown.tsx | 2 +- .../CustomConnectButton/index.tsx | 2 + .../components/scaffold-stark/Faucet.tsx | 32 +- .../scaffold-stark/FaucetSepolia.tsx | 144 ++++++ .../nextjs/contracts/deployedContracts.ts | 471 +++-------------- .../nextjs/contracts/predeployedContracts.ts | 474 ++++++++++++++++++ .../scaffold-stark/useNativeCurrencyPrice.ts | 18 +- .../scaffold-stark/useScaffoldStrkBalance.ts | 34 ++ packages/nextjs/public/blast-icon-color.svg | 6 + packages/nextjs/public/debug-image.png | Bin 0 -> 2693584 bytes packages/nextjs/public/logo_alchemy.png | Bin 0 -> 10131 bytes packages/nextjs/public/sn-symbol-gradient.png | Bin 0 -> 26524 bytes packages/nextjs/public/starkcompass-icon.svg | 28 ++ packages/nextjs/public/voyager-icon.svg | 1 + packages/nextjs/services/store/store.ts | 5 + packages/nextjs/services/web3/faucet.ts | 32 +- .../nextjs/utils/scaffold-stark/contract.ts | 5 +- .../scaffold-stark/fetchPriceFromCoingecko.ts | 21 +- .../nextjs/utils/scaffold-stark/networks.ts | 20 + packages/snfoundry/package.json | 1 + .../snfoundry/scripts-ts/deploy-contract.ts | 219 +++++--- packages/snfoundry/scripts-ts/deploy.ts | 76 +-- .../scripts-ts/helpers/colorize-log.ts | 16 + .../scripts-ts/helpers/deploy-wrapper.ts | 10 +- .../scripts-ts/helpers/parse-deployments.ts | 5 +- packages/snfoundry/scripts-ts/types.ts | 9 +- 42 files changed, 1654 insertions(+), 634 deletions(-) create mode 100644 .github/workflows/release-create-stark.yaml create mode 100644 packages/nextjs/components/scaffold-stark/BlockExplorer.tsx create mode 100644 packages/nextjs/components/scaffold-stark/BlockExplorerSepolia.tsx create mode 100644 packages/nextjs/components/scaffold-stark/ClassHash.tsx create mode 100644 packages/nextjs/components/scaffold-stark/FaucetSepolia.tsx create mode 100644 packages/nextjs/hooks/scaffold-stark/useScaffoldStrkBalance.ts create mode 100644 packages/nextjs/public/blast-icon-color.svg create mode 100644 packages/nextjs/public/debug-image.png create mode 100644 packages/nextjs/public/logo_alchemy.png create mode 100644 packages/nextjs/public/sn-symbol-gradient.png create mode 100644 packages/nextjs/public/starkcompass-icon.svg create mode 100644 packages/nextjs/public/voyager-icon.svg create mode 100644 packages/snfoundry/scripts-ts/helpers/colorize-log.ts diff --git a/.github/workflows/demo.yaml b/.github/workflows/demo.yaml index e69de29b..98f41b2c 100644 --- a/.github/workflows/demo.yaml +++ b/.github/workflows/demo.yaml @@ -0,0 +1,64 @@ +name: scaffold-stark-demo workflow + +on: + pull_request: + types: [closed] + branches: [main] + paths: + - 'packages/nextjs/**' + +jobs: + version-bump-nextjs: + runs-on: ubuntu-22.04 + steps: + + - name: Checkout Source Repository + uses: actions/checkout@v4 + with: + repository: Quantum3-Labs/scaffold-stark-2 + token: ${{ secrets.ORG_GITHUB_TOKEN }} + path: source_repo + + - name: Modify scaffoldConfig in Source Repository + run: | + cd source_repo + sed -i 's/targetNetworks: \[chains.devnet\]/targetNetworks: \[chains.sepolia\]/' packages/nextjs/scaffold.config.ts + cat packages/nextjs/scaffold.config.ts + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: 'https://registry.yarnpkg.com' + + - name: Deploy to vercel + if: success() + id: deploy + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + run: | + cd source_repo + yarn install + vercel link --yes --project $VERCEL_PROJECT_ID --token $VERCEL_TOKEN --scope $VERCEL_ORG_ID + vercel --build-env NEXT_PUBLIC_IGNORE_BUILD_ERROR=true --prod --token $VERCEL_TOKEN --scope $VERCEL_ORG_ID + + - name: Notify Slack on Success + if: success() + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: ${{ secrets.SLACK_CHANNEL_ID }} + slack-message: "GitHub deployed to vercel result: ${{ job.status }}\nRepository Name: ${{ github.repository }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + - name: Notify Slack on Failure + if: failure() + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: ${{ secrets.SLACK_CHANNEL_ID }} + slack-message: "GitHub deployed to vercel result: ${{ job.status }}\nRepository Name: ${{ github.repository }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4c4ea6e0..748006d3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,12 +34,6 @@ jobs: run: yarn install --immutable working-directory: ./packages/nextjs - - name: Install scarb - run: curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.5.4 - - - name: Check Code Format - run: npm run format:check - - name: Run Next.js lint run: yarn next:lint --max-warnings=0 working-directory: ./packages/nextjs diff --git a/.github/workflows/release-create-stark.yaml b/.github/workflows/release-create-stark.yaml new file mode 100644 index 00000000..47c698cc --- /dev/null +++ b/.github/workflows/release-create-stark.yaml @@ -0,0 +1,114 @@ +name: Version Bump and Notify + +on: + pull_request: + types: [closed] + branches: [main] + +jobs: + version-bump: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout Source Repository + uses: actions/checkout@v4 + with: + repository: Quantum3-Labs/scaffold-stark-2 + token: ${{ secrets.ORG_GITHUB_TOKEN }} + path: source_repo + + - name: Checkout Destination Repository + uses: actions/checkout@v4 + with: + repository: Quantum3-Labs/create-stark + token: ${{ secrets.ORG_GITHUB_TOKEN }} + path: destination_repo + + - name: Determine version bump type + id: version + run: | + cd source_repo + commit_message=$(git log -1 --pretty=%B) + if [[ "$commit_message" == *"[major]"* ]]; then + echo "type=major" >> "$GITHUB_ENV" + elif [[ "$commit_message" == *"[minor]"* ]]; then + echo "type=minor" >> "$GITHUB_ENV" + else + echo "type=patch" >> "$GITHUB_ENV" + fi + + - name: Bump version in Source Repository + id: bump-version-source + run: | + cd source_repo + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + new_version=$(npm version ${{ env.type }} -m "chore(release): %s [skip ci]") + echo "NEW_VERSION=${new_version}" >> "$GITHUB_ENV" + git push origin main --follow-tags + + - name: Copy Files to Destination Repository + run: | + rsync -av --delete --exclude='.git' source_repo/ destination_repo/templates/base + cd destination_repo + git add . + git commit -m "chore: sync files from scaffold-stark-2 [skip ci]" + + - name: Format .gitignore files + run: | + find destination_repo/templates/base -type f -name ".gitignore" | while read -r gitignore_file; do + mjs_file="${gitignore_file%/*}/.gitignore.template.mjs" + gitignore_content=$(cat "$gitignore_file") + cat > "$mjs_file" <<-EOF + const contents = () => + \`${gitignore_content}\` + + export default contents; + EOF + rm "$gitignore_file" + done + cd destination_repo + git add . + git commit -m "Processed $gitignore_file into $mjs_file" + + - name: Bump version in Destination Repository + id: bump-version-destination + run: | + cd destination_repo + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + new_version=$(npm version ${{ env.type }} -m "chore(release): %s [skip ci]") + git push origin main --follow-tags + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + registry-url: 'https://registry.npmjs.org/' + + - name: Publish release + if: success() + id: publish-release + run: | + cd destination_repo + npm install && npm run build && npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Notify Slack on Success + if: success() + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: ${{ secrets.SLACK_CHANNEL_ID }} + slack-message: "GitHub Action succeeded for version bump to ${{ env.NEW_VERSION }}." + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + - name: Notify Slack on Failure + if: failure() + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: ${{ secrets.SLACK_CHANNEL_ID }} + slack-message: "GitHub Action failed for version bump." + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/README.md b/README.md index 26b2fca8..3debe5e0 100644 --- a/README.md +++ b/README.md @@ -277,4 +277,4 @@ For production-grade applications, it's recommended to obtain your own API keys --- > 🏃 Head to your next challenge [here](https://github.com/Quantum3-Labs/speedrunstark/tree/dice-game). -> � Problems, questions, comments on the stack? Post them to the [🏗 Scaffold-Stark developers chat](https://t.me/+wO3PtlRAreo4MDI9) +> � Problems, questions, comments on the stack? Post them to the [🏗 Scaffold-Stark developers chat](https://t.me/+wO3PtlRAreo4MDI9) \ No newline at end of file diff --git a/package.json b/package.json index e21e893e..bfc7b50a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ss-2", - "version": "0.2.3", + "version": "0.2.6", "author": "Q3 Labs", "license": "MIT", "private": true, @@ -13,6 +13,7 @@ "scripts": { "chain": "yarn workspace @ss-2/snfoundry chain", "deploy": "yarn workspace @ss-2/snfoundry deploy", + "deploy:reset": "yarn workspace @ss-2/snfoundry deploy:reset", "test": "yarn workspace @ss-2/snfoundry test", "compile": "yarn workspace @ss-2/snfoundry compile", "start": "yarn workspace @ss-2/nextjs dev", diff --git a/packages/nextjs/app/debug/_components/contract/ContractUI.tsx b/packages/nextjs/app/debug/_components/contract/ContractUI.tsx index 3d6d1010..e7d749fc 100644 --- a/packages/nextjs/app/debug/_components/contract/ContractUI.tsx +++ b/packages/nextjs/app/debug/_components/contract/ContractUI.tsx @@ -5,11 +5,15 @@ import { useReducer } from "react"; import { ContractReadMethods } from "./ContractReadMethods"; // import { ContractWriteMethods } from "./ContractWriteMethods"; import { Address, Balance } from "~~/components/scaffold-stark"; -import { useDeployedContractInfo } from "~~/hooks/scaffold-stark"; +import { + useDeployedContractInfo, + useNetworkColor, +} from "~~/hooks/scaffold-stark"; import { useTargetNetwork } from "~~/hooks/scaffold-stark/useTargetNetwork"; import { ContractName } from "~~/utils/scaffold-stark/contract"; import { ContractVariables } from "./ContractVariables"; import { ContractWriteMethods } from "./ContractWriteMethods"; +import { ClassHash } from "~~/components/scaffold-stark/ClassHash"; type ContractUIProps = { contractName: ContractName; @@ -51,13 +55,17 @@ export const ContractUI = ({
-
+
- {contractName} + {contractName}
+
Balance:
); -}; +}; \ No newline at end of file diff --git a/packages/nextjs/app/debug/_components/contract/ReadOnlyFunctionForm.tsx b/packages/nextjs/app/debug/_components/contract/ReadOnlyFunctionForm.tsx index 53d4bb23..c2c013f5 100644 --- a/packages/nextjs/app/debug/_components/contract/ReadOnlyFunctionForm.tsx +++ b/packages/nextjs/app/debug/_components/contract/ReadOnlyFunctionForm.tsx @@ -85,6 +85,7 @@ export const ReadOnlyFunctionForm = ({
)}
+
{ return ( <> + {/*
+

Debug Contracts

+

+ You can debug & interact with your deployed contracts here. +
Check{" "} + + packages / nextjs / app / debug / page.tsx + {" "} +

+
*/} ); }; diff --git a/packages/nextjs/app/token-vendor/page.tsx b/packages/nextjs/app/token-vendor/page.tsx index 3a41a327..43651df8 100644 --- a/packages/nextjs/app/token-vendor/page.tsx +++ b/packages/nextjs/app/token-vendor/page.tsx @@ -228,4 +228,4 @@ const TokenVendor: NextPage = () => { ); }; -export default TokenVendor; +export default TokenVendor; \ No newline at end of file diff --git a/packages/nextjs/components/Footer.tsx b/packages/nextjs/components/Footer.tsx index 31f75fea..6eab928e 100644 --- a/packages/nextjs/components/Footer.tsx +++ b/packages/nextjs/components/Footer.tsx @@ -1,15 +1,13 @@ import React from "react"; -import Link from "next/link"; -import { - CurrencyDollarIcon, - MagnifyingGlassIcon, -} from "@heroicons/react/24/outline"; +import { CurrencyDollarIcon } from "@heroicons/react/24/outline"; import { useTargetNetwork } from "~~/hooks/scaffold-stark/useTargetNetwork"; import { useGlobalState } from "~~/services/store/store"; -import { devnet } from "@starknet-react/chains"; -import { Faucet } from "./scaffold-stark"; -import { getBlockExplorerLink } from "~~/utils/scaffold-stark"; +import { devnet, sepolia, mainnet } from "@starknet-react/chains"; +import { Faucet } from "~~/components/scaffold-stark/Faucet"; +import { FaucetSepolia } from "~~/components/scaffold-stark/FaucetSepolia"; +import { BlockExplorerSepolia } from "./scaffold-stark/BlockExplorerSepolia"; +import { BlockExplorer } from "./scaffold-stark/BlockExplorer"; /** * Site footer @@ -20,12 +18,14 @@ export const Footer = () => { ); const { targetNetwork } = useTargetNetwork(); const isLocalNetwork = targetNetwork.id === devnet.id; + const isSepoliaNetwork = targetNetwork.id === sepolia.id; + const isMainnetNetwork = targetNetwork.id === mainnet.id; return (
-
-
+
+
{nativeCurrencyPrice > 0 && (
@@ -34,27 +34,28 @@ export const Footer = () => {
)} + {isSepoliaNetwork && ( + <> + + + + )} {isLocalNetwork && ( <> - - - Block Explorer - + + )} + {isMainnetNetwork && ( + <> + )}
-
-