-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(svm): include solana artifacts in package build output (#806)
* feat(svm): add types to dist Signed-off-by: Pablo Maldonado <[email protected]> * feat(svm): types Signed-off-by: Pablo Maldonado <[email protected]> * fix: ci Signed-off-by: Pablo Maldonado <[email protected]> * feat: add getters Signed-off-by: Pablo Maldonado <[email protected]> * feat: export only assets Signed-off-by: Pablo Maldonado <[email protected]> * fix: missing old import Signed-off-by: Pablo Maldonado <[email protected]> * fix: export svm Signed-off-by: Pablo Maldonado <[email protected]> * feat: read program id from deployed addresses or pass it as arg Signed-off-by: Pablo Maldonado <[email protected]> * refactor: rename generate-evm-assets Signed-off-by: Pablo Maldonado <[email protected]> * refactor: dif readme Signed-off-by: Pablo Maldonado <[email protected]> * refactor: remove diff readme Signed-off-by: Pablo Maldonado <[email protected]> * fix: imports Signed-off-by: Pablo Maldonado <[email protected]> --------- Signed-off-by: Pablo Maldonado <[email protected]>
- Loading branch information
Showing
29 changed files
with
273 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ target | |
**/*.rs.bk | ||
test-ledger | ||
idls | ||
src/svm/assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,4 +112,4 @@ | |
"storage": [], | ||
"types": null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
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" | ||
echo "export {${camelCaseName} as ${newName}} from \"./${name}\";" >> "$TYPES_OUTPUT_FILE" | ||
done | ||
|
||
echo "svm-types index.ts generated successfully at $TYPES_OUTPUT_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.