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 8 commits
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
112 changes: 68 additions & 44 deletions bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const rm = promisify(fs.rm);
// Initialize readline interface
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
});

// Function to ask questions in the terminal
Expand All @@ -28,19 +28,29 @@ let projectPath;
const installPackage = async () => {
try {
// Ask for package name
const packageName = await askQuestion('Enter your package name: ');
const packageName = await askQuestion("Enter your package name: ");

// Ask for package type
const packageTypeChoices = ['contract_only', 'fullstack', 'dojo', 'debugger'];
console.log('Available package types:');
packageTypeChoices.forEach((type, index) => console.log(`${index + 1}. ${type}`));
const packageTypeChoices = [
"contract_only",
"fullstack",
"dojo",
"debugger",
"kakarot",
Darlington02 marked this conversation as resolved.
Show resolved Hide resolved
];
console.log("Available package types:");
packageTypeChoices.forEach((type, index) =>
console.log(`${index + 1}. ${type}`)
);

let packageType;
while (!packageType) {
const packageTypeChoice = await askQuestion('Select the package type (1-3): ');
const packageTypeChoice = await askQuestion(
"Select the package type (1-4): "
);
packageType = packageTypeChoices[parseInt(packageTypeChoice) - 1];
if (!packageType) {
console.log('Invalid choice. Please select a valid package type.');
console.log("Invalid choice. Please select a valid package type.");
}
}

Expand All @@ -49,11 +59,12 @@ const installPackage = async () => {
projectPath = path.join(currentPath, packageName);

if (fs.existsSync(projectPath)) {
console.log(`The file ${projectName} already exist in the current directory, please give it another name.`);
process.exit(1);
}
else {
fs.mkdirSync(projectPath);
console.log(
`The file ${projectName} already exist in the current directory, please give it another name.`
);
process.exit(1);
} else {
fs.mkdirSync(projectPath);
}

// Clone the repository
Expand All @@ -63,11 +74,24 @@ const installPackage = async () => {
gitSpinner.succeed();

let cleanupTasks = [];
let excluded_files = [".git", ".github", "CONTRIBUTING.md", "bin", "burner", "website", "docs", "CNAME"];

if (packageType === "fullstack" || packageType === "dojo") {
const FRONTEND_BASE_PATH = "frontend/src/app";
const componentsToRemove = [
let excluded_files = [
".git",
".github",
"CONTRIBUTING.md",
"bin",
"burner",
"website",
"docs",
"CNAME",
];

if (
packageType === "fullstack" ||
packageType === "dojo" ||
packageType === "kakarot"
) {
const FRONTEND_BASE_PATH = "frontend/src/app";
const componentsToRemove = [
`${FRONTEND_BASE_PATH}/burner`,
`${FRONTEND_BASE_PATH}/wikipedia`,
`${FRONTEND_BASE_PATH}/scaffold-deployer`,
Expand All @@ -78,49 +102,45 @@ const installPackage = async () => {
`${FRONTEND_BASE_PATH}/components/AssetTransferModal.tsx`,
`${FRONTEND_BASE_PATH}/components/ConnectionModal.tsx`,
`${FRONTEND_BASE_PATH}/components/ContractExecutionModal.tsx`,
];
cleanupTasks.push(
];
cleanupTasks.push(
...componentsToRemove.map((comp) =>
rm(path.join(projectPath, comp), {
rm(path.join(projectPath, comp), {
recursive: true,
force: true,
}),
})
),
...excluded_files.map((comp) =>
rm(path.join(projectPath, comp), {
rm(path.join(projectPath, comp), {
recursive: true,
force: true,
}),
),
})
)
);
}
else if (packageType == "contract_only") {
} else if (packageType == "contract_only") {
let componentsToRemove = [...excluded_files, "frontend", ".editorconfig"];
cleanupTasks.push(
...componentsToRemove.map((comp) =>
rm(path.join(projectPath, comp), {
recursive: true,
force: true,
}),
),
)
}
else {
recursive: true,
force: true,
})
)
);
} else {
cleanupTasks.push(
...excluded_files.map((comp) =>
rm(path.join(projectPath, comp), {
rm(path.join(projectPath, comp), {
recursive: true,
force: true,
}),
),
})
)
);
}

// remove useless files
const cleanSpinner = ora("Removing useless files").start();
await Promise.all([
...cleanupTasks,
]);
await Promise.all([...cleanupTasks]);

process.chdir(projectPath);
// remove the packages needed for cli
Expand All @@ -129,10 +149,15 @@ const installPackage = async () => {

// install dependencies
const npmSpinner = ora("Installing dependencies...").start();
if(packageType == "dojo") {
await exec("npm run install --legacy-peer-deps && npm run initialize-dojo");
}
else if(packageType !== "contract_only") {
if (packageType == "dojo") {
await exec(
"npm run install --legacy-peer-deps && npm run initialize-dojo"
);
} else if (packageType !== "kakarot") {
Copy link
Member

Choose a reason for hiding this comment

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

remove the negation. you meant:

else if (packageType == "kakarot")

await exec(
"npm run install --legacy-peer-deps && npm run initialize-kakarot"
);
} else if (packageType !== "contract_only") {
await exec("npm run install --legacy-peer-deps");
}
npmSpinner.succeed();
Expand All @@ -141,7 +166,6 @@ const installPackage = async () => {
console.log("You can now run the scaffold with:");
console.log(` cd ${packageName}`);
console.log(` npm run start`);

} catch (err) {
// clean up in case of error, so the user does not have to do it manually
fs.rmSync(projectPath, { recursive: true, force: true });
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
"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",
"build-ui": "cd frontend && npm run build"
"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",
Copy link
Member

Choose a reason for hiding this comment

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

include a command to initialize git too within the initialize-kakarot. ie && git init.

Not doing this, makes the next command setup-kakarot fail with error: not a git repository

"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 solidity_contracts/src/${npm_contract_path} --private-key $PRIVATE_KEY"
},
"repository": {
"type": "git",
Expand Down
12 changes: 12 additions & 0 deletions scripts/install_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ install_starknet_foundry() {

}

# 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
Expand Down
Loading