Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Challenge-base v2 #94

Merged
merged 39 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d3b75e7
Add postinstall (#187)
jrcarlos2000 Jul 11, 2024
bf86a2e
feat: Add cyberpunk style (#181)
GabrielaDelPilarR Jul 12, 2024
0954e0a
Fix correctly display wallet connectors (#189)
danielcdz Jul 14, 2024
8659c38
Changes in styles (#191)
GabrielaDelPilarR Jul 16, 2024
cfa44b6
feat: update cyberpunk theme
GabrielaDelPilarR Jul 17, 2024
1c9aa03
Add correctly display wallet connectors in new style (#192)
Nadai2010 Jul 17, 2024
a252e2c
update latest changes
GabrielaDelPilarR Jul 17, 2024
0cf5904
feat: update Readme.md
GabrielaDelPilarR Jul 17, 2024
fe7eaae
Removed all mention of Goerli and all associated packages (#193)
Ugo-X Jul 17, 2024
914d5d4
fix page.tsx
GabrielaDelPilarR Jul 17, 2024
df5f867
Update README.md
GabrielaDelPilarR Jul 17, 2024
947bb6c
fix: remove unused imports
GabrielaDelPilarR Jul 17, 2024
bb0c32e
workflow to update create-stark in every PR (#195)
edulanasca Jul 18, 2024
dcf1e5c
chore(release): 0.0.3 [skip ci]
github-actions[bot] Jul 18, 2024
56ca519
chore: remove unused images and comments
GabrielaDelPilarR Jul 18, 2024
0a87ab6
delete example view page
GabrielaDelPilarR Jul 18, 2024
f3f0f82
delete debug-contracts.png
GabrielaDelPilarR Jul 18, 2024
051bec6
update: wallet not deployed in ui & deploy.ts (#196) [minor]
edulanasca Jul 19, 2024
0525ed0
chore(release): 0.1.0 [skip ci]
github-actions[bot] Jul 19, 2024
5c1b40e
devops(demo): support scaffol-stark-demo workflow (#199)
oceanlvr Jul 20, 2024
b51c207
Update CONTRIBUTING.md (#201)
0xquantum3labs Jul 21, 2024
ffeb461
chore(release): 0.1.1 [skip ci]
github-actions[bot] Jul 21, 2024
d1097a2
Fix botton Wallet Not Deployed (#203)
Nadai2010 Jul 23, 2024
cba6bc4
Update package.json (#204)
jrcarlos2000 Jul 23, 2024
5621fa2
chore(release): 0.1.2 [skip ci]
github-actions[bot] Jul 23, 2024
2ad3b6a
lint to validate deployContract (#198)
edulanasca Jul 23, 2024
ed0b2ba
chore(release): 0.1.3 [skip ci]
github-actions[bot] Jul 23, 2024
783a64e
Support for latest versions : v2 Release (#165) [minor]
0xquantum3labs Jul 28, 2024
f3b9656
chore(release): 0.2.0 [skip ci]
github-actions[bot] Jul 28, 2024
4a8d170
Update rpc (#206)
0xquantum3labs Jul 28, 2024
b12b6e9
chore(release): 0.2.1 [skip ci]
github-actions[bot] Jul 28, 2024
8ba39e2
chore : remove submodule (#207)
0xquantum3labs Jul 28, 2024
5fee13e
chore(release): 0.2.2 [skip ci]
github-actions[bot] Jul 28, 2024
63ccf8f
Update readme (#208)
0xquantum3labs Jul 28, 2024
7149cb4
chore(release): 0.2.3 [skip ci]
github-actions[bot] Jul 28, 2024
42477da
update challenge-base v2
GabrielaDelPilarR Jul 30, 2024
b4eec71
Merge branch 'challenge-base' into gabi/challenge-base
Nadai2010 Jul 30, 2024
c79e21d
Update prettier
Nadai2010 Jul 30, 2024
07f6349
fix error
GabrielaDelPilarR Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/demo.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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 }}

114 changes: 114 additions & 0 deletions .github/workflows/release-create-stark.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: "GitHub Action failed for version bump."
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/test_contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
uses: actions/checkout@master

- name: Install scarb
run: curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.5.4
run: curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- -v 2.6.5

- name: Install snfoundryup
run: curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | sh

- name: Install snforge
run: snfoundryup -v 0.25.0
run: snfoundryup -v 0.27.0

- name: Run snforge tests
run: snforge test
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "packages/snfoundry/local-devnet"]
path = packages/snfoundry/local-devnet
url = https://github.com/0xSpaceShard/starknet-devnet-rs
branch = json-rpc-v0.5.1
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ If your changes involve updates to how users interact with Scaffold-Stark or Spe

## Need Help?

Reach out via our community channels if you encounter issues or need clarification on contributing.
Reach out via our community channels if you encounter issues or need clarification on contributing [here](https://t.me/+wO3PtlRAreo4MDI9).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Make sure you have the compatible versions otherwise refer to [Scaffold-Stark Re
Then download the challenge to your computer and install dependencies by running:

```sh
git clone https://github.com/Quantum3-Labs/speedrunstark.git --recurse-submodules {challengeName}
git clone https://github.com/Quantum3-Labs/speedrunstark.git {challengeName}
cd {challengeName}
git checkout {challengeName}
yarn install
Expand Down
Binary file removed assests/debug-contracts.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ss-2",
"version": "0.0.2",
"version": "0.2.3",
"author": "Q3 Labs",
"license": "MIT",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NEXT_PUBLIC_PROVIDER_URL=https://starknet-sepolia.infura.io/v3/c45bd0ce3e584ba4a5e6a5928c9c0b0f
NEXT_PUBLIC_PROVIDER_URL=https://starknet-sepolia.public.blastapi.io/rpc/v0_7
4 changes: 2 additions & 2 deletions packages/nextjs/app/debug/_components/DebugContracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export function DebugContracts() {
<button
className={`btn btn-secondary btn-sm font-light hover:border-transparent ${
contractName === selectedContract
? "bg-base-300 hover:bg-base-300 no-animation text-base-100 "
: "bg-base-100 hover:bg-secondary hover:text-neutral-content text-primary"
? "bg-secondary hover:bg-secondary no-animation text-white"
: "bg-transparent text-neutral hover:text-white"
}`}
key={contractName}
onClick={() => setSelectedContract(contractName)}
Expand Down
129 changes: 129 additions & 0 deletions packages/nextjs/app/debug/_components/contract/Array.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";
import { getFunctionInputKey, getInitialTupleFormState } from "./utilsContract";
import {
AbiEnum,
AbiParameter,
AbiStruct,
} from "~~/utils/scaffold-stark/contract";
import { replacer } from "~~/utils/scaffold-stark/common";
import { ContractInput } from "./ContractInput";
import { Abi } from "abi-wan-kanabi";
import { parseGenericType } from "~~/utils/scaffold-stark";

type ArrayProps = {
abi: Abi;
abiParameter: AbiParameter;
parentForm: Record<string, any> | undefined;
setParentForm: (form: Record<string, any>) => void;
parentStateObjectKey: string;
setFormErrorMessage: Dispatch<SetStateAction<string | null>>;
};

export const ArrayInput = ({
abi,
parentForm,
setParentForm,
parentStateObjectKey,
abiParameter,
setFormErrorMessage,
}: ArrayProps) => {
// array in object representation
const [inputArr, setInputArr] = useState<any>({});
const [arrLength, setArrLength] = useState<number>(-1);

const elementType = useMemo(() => {
const parsed = parseGenericType(abiParameter.type);
return Array.isArray(parsed) ? parsed[0] : parsed;
}, [abiParameter.type]);

// side effect to transform data before setState
useEffect(() => {
// non empty objects only
setParentForm({
...parentForm,
[parentStateObjectKey]: Object.values(inputArr).filter(
(item) => item !== null,
),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(inputArr, replacer)]);

return (
<div>
<div className="collapse bg-base-200 pl-4 pt-1.5 pb-2 border-2 border-secondary custom-after">
<input type="checkbox" className="min-h-fit peer" />
<div className="collapse-title p-0 min-h-fit peer-checked:mb-2 text-primary-content/50">
<p className="m-0 p-0 text-[1rem]">array (length: {arrLength + 1})</p>
</div>
<div className="ml-3 flex-col space-y-4 border-secondary/80 border-l-2 pl-4 collapse-content">
{/* do note here that the "index" are basically array keys */}
{Object.keys(inputArr).map((index) => {
return (
<ContractInput
abi={abi}
key={index}
setForm={(
nextInputRecipe:
| Record<string, any>
| ((arg: Record<string, any>) => void),
) => {
let nextInputObject: Record<string, any> = nextInputRecipe;

// set state recipe function, handle
if (typeof nextInputRecipe === "function") {
nextInputObject = nextInputRecipe(parentForm!);
}

const currentInputArray = { ...inputArr };

// we do some nasty workaround
currentInputArray[index] =
nextInputObject?.[`input_${index}`] || null;

setInputArr(currentInputArray);
}}
form={inputArr[index]}
stateObjectKey={`input_${index}`}
paramType={
{
name: `${abiParameter.name}[${index}]`,
type: elementType,
} as AbiParameter
}
setFormErrorMessage={setFormErrorMessage}
/>
);
})}
<div className="flex gap-3">
<button
onClick={() => {
const nextLength = arrLength + 1;
setInputArr((prev: any) => ({
...prev,
[nextLength]: null,
}));
setArrLength(nextLength);
}}
className="btn btn-sm shadow-none border border-success text-white"
>
+ Add (push)
</button>
<button
className="btn btn-sm shadow-none border border-error text-white"
onClick={() => {
if (arrLength > -1) {
const nextInputArr = { ...inputArr };
delete nextInputArr[arrLength];
setInputArr(nextInputArr);
setArrLength((prev) => prev - 1);
}
}}
>
- Remove (pop)
</button>
</div>
</div>
</div>
</div>
);
};
Loading
Loading