Skip to content

Commit

Permalink
Update GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Dec 3, 2024
1 parent e46f278 commit 147138d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/cadence_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ jobs:
echo "Starting Flow emulator in the background..."
nohup flow emulator start > emulator.log 2>&1 &
sleep 5 # Wait for the emulator to start
flow project deploy --network=emulator # Deploy the recipe contracts indicated in flow.json
- name: Run Transaction
run: |
echo "Running recipe transaction with Flow emulator..."
flow transactions send cadence/transaction.cdc --signer emulator-account
TRANSACTION_OUTPUT=$(flow transactions send cadence/transaction.cdc --signer emulator-account)
echo "$TRANSACTION_OUTPUT"
if echo "$TRANSACTION_OUTPUT" | grep -q "Transaction Error"; then
echo "Transaction Error detected, failing the action..."
exit 1
fi
- name: Run Cadence Lint
run: |
Expand Down
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Once you have a set created and some plays, you can use this to add a play to a
- [Description](#description)
- [What is included in this repository?](#what-is-included-in-this-repository)
- [Supported Recipe Data](#recipe-data)
-[Deploying Recipe Contracts and Running Transactions Locally (Flow Emulator)](#deploying-recipe-contracts-and-running-transactions-locally-flow-emulator)
- [License](#license)

## Description
Expand All @@ -19,7 +20,6 @@ The Cadence Cookbook is a collection of code examples, recipes, and tutorials de

Each recipe in the Cadence Cookbook is a practical coding example that showcases a specific aspect of Cadence or use-case on Flow, including smart contract development, interaction, and best practices. By following these recipes, you can gain hands-on experience and learn how to leverage Cadence for your blockchain projects.


### Contributing to the Cadence Cookbook

Learn more about the contribution process [here](https://github.com/onflow/cadence-cookbook/blob/main/contribute.md).
Expand Down Expand Up @@ -95,6 +95,42 @@ export const sampleRecipe= {
transactionExplanation: transactionExplanationPath,
};
```
## Deploying Recipe Contracts and Running Transactions Locally (Flow Emulator)

This section explains how to deploy the recipe's contracts to the Flow emulator, run the associated transaction with sample arguments, and verify the results.

### Prerequisites

Before deploying and running the recipe:

1. Install the Flow CLI. You can find installation instructions [here](https://docs.onflow.org/flow-cli/install/).
2. Ensure the Flow emulator is installed and ready to use with `flow version`.

### Step 1: Start the Flow Emulator

Start the Flow emulator to simulate the blockchain environment locally:

```bash
flow emulator start
```

### Step 2: Deploy Project Contracts

Deploy the recipe's contracts to the emulator. The `Recipe` contract is located at `./contract.cdc`. Other contracts on which the recipe is dependent can be found in the `./contracts/` directory.

```bash
flow project deploy --network=emulator
```

### Step 3: Run the Transaction

The transaction file is located in `./cadence/transaction.cdc`. To run the transaction, execute the following command:

```bash
flow transactions send cadence/transaction.cdc --signer emulator-account
```

To verify the transaction's execution, check the emulator logs printed during the transaction for confirmation messages. You can add the `--log-level debug` flag to your Flow CLI command for more detailed output during contract deployment or transaction execution.

## License

Expand Down

0 comments on commit 147138d

Please sign in to comment.