Skip to content

Commit

Permalink
[change] README to include steps of running generate_wasm.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Asem-Abdelhady <[email protected]>
  • Loading branch information
Asem-Abdelhady committed Jan 19, 2024
1 parent ef8760b commit 337bed1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ bash ./scripts/test_env.sh setup
bash ./scripts/tests/register_mint_quantity.sh
bash ./scripts/test_env.sh cleanup
```
To generate WASM files for smart contracts, use the provided script `generate_wasm.sh`. If you are in the root directory of iroha run the following command:

```bash
bash ./scripts/generate_wasm.sh [path/to/smartcontracts]
```

The generated WASM files will be saved in a generated directory `test-smartcontracts`, relative to your current working directory. The default path for smart contracts in this project is `client/tests/integration/smartcontracts`.

</details>

Expand Down
22 changes: 9 additions & 13 deletions scripts/generate_wasm.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <source-dir>"
exit 1
# Default source directory
DEFAULT_SOURCE_DIR="client/tests/integration/smartcontracts"

# If no arguments are provided, use the default source directory
if [ "$#" -eq 0 ]; then
SOURCE_DIR="$DEFAULT_SOURCE_DIR"
else
SOURCE_DIR="$1"
fi

# First argument is the source directory
SOURCE_DIR="$1"

TARGET_DIR="test-smartcontracts"

mkdir -p "$TARGET_DIR"

for folder in "$SOURCE_DIR"/**; do
for folder in "$SOURCE_DIR"/*; do
if [ -d "$folder" ] && [ "$(basename "$folder")" != ".cargo" ]; then

folder_name=$(basename "$folder")
Expand All @@ -24,9 +26,3 @@ for folder in "$SOURCE_DIR"/**; do
done

echo "Smart contracts build complete."

# How to run:
# make sure you root from the root directrory if iroha or
# any iroha directory that is not a package in the working space
# run the following command:
# ./path/to/script/generate_wasm.sh /path/to/smart_contracts

0 comments on commit 337bed1

Please sign in to comment.