Skip to content
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
63 changes: 32 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,53 +48,57 @@ docker build . -t toncli-local \
```



## Use

It's also useful to copy `toncli-docker` binary to your path (or copy it to /usr/local/bin) so you can access it from anywhere.

``` console
cp ./toncli-docker /usr/local/bin/toncli-docker
```

You're going to need to pass your workdir as a volume to make things happen
Now go to the path, where you are going to create your project (e.g. ~/your/path/dev/)

### Creating project
Run
Run

``` console
docker run --rm -it \
-v ~/Dev:/code \
toncli-local start --name test_project wallet
toncli-docker start --name test_project wallet
```

You're going to see the toncli project structure in *~/Dev/test_project*
You're going to see the toncli project structure in *~/your/path/dev/test_project*
`README.md build fift func project.yaml tests`

### Building

Go to your project path by `cd ~/your/path/dev/test_project` and

Run

``` console
docker run --rm -it \
-v ~/Dev/test_project:/code \
toncli-local build
toncli-docker build
```

### Running tests

``` console
docker run --rm -it \
-v ~/Dev/test_project:/code \
toncli-local run_tests
```

``` console
toncli-docker run_tests
```

### Deploying contract
Now here is the tricky part.
**Toncli** stores deployment info in it's config directory instead of your project directory.
So we're going to have to create another volume for that to persist.

Run

``` console
toncli-docker update_libs
```

The deployment info is stored in the `~/.toncli-deploy` dir by default.
If you want to change this path, you can run this command:
``` console
docker run --rm -it \
-v ~/Dev/test_project:/code \
-v /path/to/toncli_conf_dir/:/root/.config \
toncli-local update_libs
toncli-docker --set-deployment-path /your/custom/path
```

After that you should go through standard toncli initialization dialog and pass absolute paths to the binaries
- /usr/local/bin/func
- /usr/local/bin/fift
Expand All @@ -113,17 +117,14 @@ docker build . -t toncli-local \

Now you can use it in the deploy or any other process like so.

Run
Run

``` console
docker run --rm -it \
-v /path/to/project:/code \
-v /path/to/toncli_conf_dir/:/root/.config \
toncli-local deploy --net testnet
toncli-docker deploy --net testnet
```

**wallet** directory would be created inside your local config dir with all the usefull deployment information
### General usage
### General usage without toncli-docker wrapper
``` console
docker run --rm -it \
-v <code_volume> \
Expand Down
74 changes: 74 additions & 0 deletions toncli-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# where permanent variables are stored
CONFIG_VAR_PATH="$HOME/.toncli-config"

# Usage: kv_validate_key <key>
kv_validate_key() {
[[ "$1" =~ ^[0-9a-zA-Z._:-]+$ ]]
}

# Usage: kvget <key>
kvget() {
key="$1"
kv_validate_key "$key" || {
kv_echo_err_box 'invalid param "key"' 'kvget()'
return 1
}
kv_user_dir=${KV_USER_DIR:-$CONFIG_VAR_PATH}
VALUE="$([ -f "$CONFIG_VAR_PATH/$key" ] && cat "$CONFIG_VAR_PATH/$key")"
echo "$VALUE"

[ "$VALUE" != "" ]
}

# Usage: kvset <key> [value]
kvset() {
key="$1"
value="$2"
kv_validate_key "$key" || {
kv_echo_err_box 'invalid param "key"' 'kvset()'
return 1
}
kv_user_dir=${KV_USER_DIR:-$CONFIG_VAR_PATH}
test -d "$kv_user_dir" || mkdir "$kv_user_dir"
echo "$value" > "$kv_user_dir/$key"
}

# Usage: kvdel <key>
kvdel() {
key="$1"
kv_validate_key "$key" || {
kv_echo_err_box 'invalid param "key"' 'kvdel()'
return 1
}
kv_user_dir=${KV_USER_DIR:-$CONFIG_VAR_PATH}
test -f "$kv_user_dir/$key" && rm -f "$kv_user_dir/$key"
}


TONCLI_CMD="toncli-local"
# where toncli stores deployment info
DEPLOY_PATH=$(kvget DEPLOY_PATH) || "$HOME/.toncli-deploy"

# ./toncli-docker update_libs /path/to/toncli_conf_dir/
if [[ $1 == "update_libs" ]]; then
docker run --rm -it \
-v "$(pwd)":/code \
-v "$DEPLOY_PATH":/root/.config \
$TONCLI_CMD update_libs
# ./toncli-docker deploy /path/to/toncli_conf_dir/
elif [[ $1 == "deploy" ]]; then
docker run --rm -it \
-v "$(pwd)":/code \
-v "$DEPLOY_PATH":/root/.config \
$TONCLI_CMD deploy $@
elif [[ $1 == "--set-deployment-path" ]]; then
kvset DEPLOY_PATH "$2"
else
docker run --rm -it \
-v "$(pwd)":/code \
$TONCLI_CMD $@
fi

# all commands w/ toncli: https://github.com/disintar/toncli/blob/master/docs/advanced/commands.md