-
Notifications
You must be signed in to change notification settings - Fork 55
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(svm): include solana artifacts in package build output #806
base: master
Are you sure you want to change the base?
Changes from 7 commits
dd4969f
0bca3a8
a09be49
6de6d5e
c647999
916449e
97973eb
804fa7a
8ec0fe4
907b7d7
9d0c7a5
3ec7934
5b33a4a
2be0052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ target | |
**/*.rs.bk | ||
test-ledger | ||
idls | ||
src/svm/assets |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./typechain"; | ||
export * from "./src/DeploymentUtils"; | ||
export * from "./utils"; | ||
export * from "./src/svm"; | ||
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -26,10 +26,11 @@ | |||
"lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly fmt --all && cargo clippy", | ||||
"clean-fast": "for dir in node_modules cache cache-zk artifacts artifacts-zk dist typechain; do mv \"${dir}\" \"_${dir}\"; rm -rf \"_${dir}\" &; done", | ||||
"clean": "rm -rf node_modules cache cache-zk artifacts artifacts-zk dist typechain", | ||||
"generate-svm-assets": "sh ./scripts/generate-svm-assets.sh", | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should think about making this file easier to reason about with this new command you've added. the equivalent evm command is also, I think that given this command is not yet within the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated ✅
I think it is, its part of the build as we need to run Line 33 in 907b7d7
Let's wait for @mrice32 & @nicholaspai to see what they think the proposed changes. |
||||
"build-evm": "hardhat compile", | ||||
"build-svm": "echo 'Generating IDLs...' && anchor build > /dev/null 2>&1 || true && anchor run generateExternalTypes && anchor build", | ||||
"build-ts": "tsc && rsync -a --include '*/' --include '*.d.ts' --exclude '*' ./typechain ./dist/", | ||||
"build": "yarn build-evm && yarn build-svm && yarn build-ts", | ||||
"build": "yarn build-evm && yarn build-svm && yarn generate-svm-assets && yarn build-ts", | ||||
"test-evm": "IS_TEST=true hardhat test", | ||||
"test-svm": "anchor test -- --features test", | ||||
"test": "yarn test-evm && yarn test-svm", | ||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,89 @@ | ||||
#!/bin/bash | ||||
|
||||
# Set paths for source and destination | ||||
TARGET_IDL="./target/idl" | ||||
TARGET_TYPES="./target/types" | ||||
SVM_ASSETS="./src/svm/assets" | ||||
SVM_IDL="$SVM_ASSETS/idl" | ||||
SVM_TYPES="$SVM_ASSETS" | ||||
IDL_OUTPUT_FILE="$SVM_IDL/index.ts" | ||||
TYPES_OUTPUT_FILE="$SVM_TYPES/index.ts" | ||||
|
||||
# Ensure the destination directories exist | ||||
mkdir -p "$SVM_IDL" | ||||
mkdir -p "$SVM_TYPES" | ||||
|
||||
# --- Copy Files --- | ||||
echo "Copying IDL files..." | ||||
cp -r "$TARGET_IDL/"* "$SVM_IDL/" | ||||
|
||||
echo "Copying Types files..." | ||||
cp -r "$TARGET_TYPES/"* "$SVM_TYPES/" | ||||
|
||||
# --- Generate IDL index.ts --- | ||||
echo "Generating IDL index.ts..." | ||||
> "$IDL_OUTPUT_FILE" | ||||
|
||||
# Add autogenerated file note | ||||
{ | ||||
echo "// This file has been autogenerated. Do not edit manually." | ||||
echo "// Generated by a script." | ||||
echo | ||||
} >> "$IDL_OUTPUT_FILE" | ||||
|
||||
IMPORTS="" | ||||
EXPORTS="" | ||||
|
||||
for file in "$SVM_IDL"/*.json; do | ||||
filename=$(basename -- "$file") | ||||
name="${filename%.json}" | ||||
camelCaseName=$(echo "$name" | awk -F'_' '{ | ||||
for (i=1; i<=NF; i++) { | ||||
printf toupper(substr($i,1,1)) tolower(substr($i,2)); | ||||
} | ||||
}') | ||||
IMPORTS="${IMPORTS}const ${camelCaseName}Idl = require(\"./${filename}\");\n" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use
|
||||
EXPORTS="${EXPORTS} ${camelCaseName}Idl,\n" | ||||
done | ||||
|
||||
# Write the imports to the file | ||||
printf "$IMPORTS" >> "$IDL_OUTPUT_FILE" | ||||
|
||||
# Write the exports block | ||||
{ | ||||
echo "export {" | ||||
printf "$EXPORTS" | sed '$ s/,$//' | ||||
echo "};" | ||||
} >> "$IDL_OUTPUT_FILE" | ||||
|
||||
echo "IDL index.ts generated successfully at $IDL_OUTPUT_FILE" | ||||
|
||||
# --- Generate svm-types index.ts --- | ||||
echo "Generating svm-types index.ts..." | ||||
> "$TYPES_OUTPUT_FILE" | ||||
|
||||
# Add autogenerated file note | ||||
{ | ||||
echo "// This file has been autogenerated. Do not edit manually." | ||||
echo "// Generated by a script." | ||||
echo | ||||
} >> "$TYPES_OUTPUT_FILE" | ||||
|
||||
# Export * from ./idl | ||||
echo "export * from \"./idl\";" >> "$TYPES_OUTPUT_FILE" | ||||
|
||||
# Export * from each .ts file in ./svm-types, removing underscores and capitalizing names | ||||
for file in "$SVM_TYPES"/*.ts; do | ||||
[ "$(basename -- "$file")" = "index.ts" ] && continue | ||||
filename=$(basename -- "$file") | ||||
name="${filename%.ts}" | ||||
camelCaseName=$(echo "$name" | awk -F'_' '{ | ||||
for (i=1; i<=NF; i++) { | ||||
printf toupper(substr($i,1,1)) tolower(substr($i,2)); | ||||
} | ||||
}') | ||||
newName="${camelCaseName}Anchor" | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prepend "Anchor" to the types to prevent conflicts with evm types |
||||
echo "export {${camelCaseName} as ${newName}} from \"./${name}\";" >> "$TYPES_OUTPUT_FILE" | ||||
done | ||||
|
||||
echo "svm-types index.ts generated successfully at $TYPES_OUTPUT_FILE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The program getters, types, and IDLs can be imported directly from
@across-protocol/contracts
, as well as utility functions (we should move the latter to the SDK next).