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

overlay environment to support folder as transaction name with pragmatic central testnet.env #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ This repository contains Flow transaction scripts that the Dapper wallet will su
```shell
$ bash render.sh [TEMPLATE_NAME] [NETWORK]
```
or
```shell
$ bash all.sh [NETWORK] // loops directories
```

## Rendering Transaction Environment

Check out the templates and find the one that fits your use case best. Let's say it's `create-listing`, and you'd like to render a transaction template for use on `testnet`.
Overlay environment with each folder `<tx-name>/<network>.env` and shared `./<network>.env` both optional

1. Open `create-listing/testnet.env` and fill in the missing template variables.
2. Run the folowing command to render the template using the variables you set in `testnet.env`
Example
1. Open `create-listing/testnet.env` or `./testnet.env` and fill in the missing template variables.
2. Run the folowing command to render `testnet.env`
```shell
$ bash render.sh create-listing testnet
```
Expand Down
12 changes: 12 additions & 0 deletions all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# Make sure the arguments look valid
if [ -z $1 ] || ([ $1 != "testnet" ] && [ $1 != "mainnet" ])
then
echo "Usage: bash all.sh [NETWORK]"
exit 1
fi
for dir in */; do
DIRNAME=${dir%/}
/bin/bash render.sh $DIRNAME $1
done
10 changes: 7 additions & 3 deletions render.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ then
fi

# Compute paths to the .env file and the template file
env_file="$1/$2.env"
template_file="$1/$1.cdc.tmpl"
output_file="$1/$1-$2.cdc"

# Populate environment with values from the .env file
export $(cat $env_file | xargs)
# overlay model
if test -f "$2.env"; then
export $(cat "$2.env" | xargs)
fi
if test -f "$1/$2.env"; then
export $(cat "$1/$2.env" | xargs)
fi

# Render the template
envsubst < $template_file > $output_file
Expand Down
11 changes: 11 additions & 0 deletions testnet.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FungibleTokenContractAddress=0x9a0766d93b6608b7
NonFungibleTokenContractAddress=0x631e88ae7f1d7c20
DapperUtilityCoinContractAddress=0x82ec283f88a62e65
NFTStorefrontContractAddress=0x94b06cfca1d8a476
PackNFTContractAddress=0x4dfd62c88d1b6462
IPackNFTContractAddress=0x5e3c1eb7f25e3c99
NFTContractName=
NFTContractAddress=
RoyaltyReceiverAddress=