Skip to content

Commit

Permalink
New Taquito plugin task called transfer to enable interaction with …
Browse files Browse the repository at this point in the history
…deployed contracts (#1245)

* Prep for transfer task impl

* Implemented transfer task

* Better messages

* Improved err messaging

* Improved err messaging

* Add doc for new task called transfer and restructure the doc a little to follow DRY

* Update help menu content for e2e tests

* Update test for help menu

* Update test for help menu

* Delete unused help menu content file
  • Loading branch information
jchenche authored Sep 15, 2022
1 parent 820539e commit 8ee18c8
Show file tree
Hide file tree
Showing 17 changed files with 394 additions and 600 deletions.
63 changes: 31 additions & 32 deletions deno-lock.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
{
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/deno/ts-pattern.js": "139329135ba186e1f4d171fb5f8c4412f634b516cd86d9eebd144c818c8b4690",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/guards.d.ts": "23d3ac26c35d4ea250f4f6fa07b659bd29c927a9b2820538566b6cb4430b28c3",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/index.d.ts": "9be090eb63ebe134cd5016ce8619bec07146219443604c34232a548303f262d8",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/symbols.d.ts": "98319b603cf3f3a8b5b2c41de042cde79d84b690f26c0b4685e4e672df8ca404",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/BuildMany.d.ts": "3674e53f36e6e41ba02338325facde0d9a955de5d7fd688498f587782db88093",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/DeepExclude.d.ts": "5c60171c7dd994fe164c8bbf3fc8ea24c38e59b28d591f5aabeff38ec88c6412",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/DistributeUnions.d.ts": "ea6d9a52a1dcafa3e3b00638585ab474f1ee12742047df8650f2dafda2e7b23e",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/ExtractPreciseValue.d.ts": "9e1e400b20494dfc0b76dbb958fbeb4d1ab1d466ede399d68cf0f48f0fb8c739",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/FindSelected.d.ts": "566c9855f7664544a79da7c90fa5f7d9d56410984e7fed1692860df71c121ebb",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/InvertPattern.d.ts": "02923619121da147c587d07cf4fe44cff411ff30f1f73c73e75d7649ff680407",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/IsMatching.d.ts": "cec8189326776ce185aaec51fca5e7614febfd698371250fe5f05ce839ace71e",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/Match.d.ts": "63e07e40910e6e8d4c4f08027aca1e7397aa31673a9dbfed50c9442b0800995b",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/Pattern.d.ts": "f30e3728c2943012603e55ab32cf3553ecf62a4cb90702169bddd8028aee7a35",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/helpers.d.ts": "93e97f7a2715e8391e59ffd02e23773fdd9184c041719cb4e52821501b3995d0",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/wildcards.d.ts": "c1bfcc56d4e49285e3254b407a36325dd2f099dba94fe7dee68d992d1fc35429",
"https://cdn.jsdelivr.net/gh/fluture-js/Fluture@14.0.0/dist/module.js": "c11481f8a52a4ceabe6fb971abd0783b79ed7eb8a3eb2e2c4f3a3c8a1afa3303",
"https://cdn.jsdelivr.net/gh/fluture-js/Fluture@14.0.0/index.d.ts": "7f0d5888ab9f39515ee8f83df99377f63428ae65aa5e4daf3034035c773ea211",
"https://cdn.skypack.dev/-/batching-toposort@v1.2.0-dHlz5M75ZjMJ8fm1NtwH/dist=es2019,mode=imports/optimized/batching-toposort.js": "9508ff2861e25b728b4015df6a75aae993195da7279ec92a59294ba825751d6e",
Expand Down Expand Up @@ -40,22 +55,21 @@
"https://deno.land/std@0.128.0/io/buffer.ts": "bd0c4bf53db4b4be916ca5963e454bddfd3fcd45039041ea161dbf826817822b",
"https://deno.land/std@0.128.0/io/types.d.ts": "01f60ae7ec02675b5dbed150d258fc184a78dfe5c209ef53ba4422b46b58822c",
"https://deno.land/std@0.128.0/streams/conversion.ts": "712585bfa0172a97fb68dd46e784ae8ad59d11b88079d6a4ab098ff42e697d21",
"https://deno.land/std@0.149.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.149.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49",
"https://deno.land/std@0.149.0/fmt/colors.ts": "6f9340b7fb8cc25a993a99e5efc56fe81bb5af284ff412129dd06df06f53c0b4",
"https://deno.land/std@0.149.0/fmt/printf.ts": "e2c0f72146aed1efecf0c39ab928b26ae493a2278f670a871a0fbdcf36ff3379",
"https://deno.land/std@0.149.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
"https://deno.land/std@0.149.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
"https://deno.land/std@0.149.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b",
"https://deno.land/std@0.149.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
"https://deno.land/std@0.149.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
"https://deno.land/std@0.149.0/path/mod.ts": "4945b430b759b0b3d98f2a278542cbcf95e0ad2bd8eaaed3c67322b306b2b346",
"https://deno.land/std@0.149.0/path/posix.ts": "c1f7afe274290ea0b51da07ee205653b2964bd74909a82deb07b69a6cc383aaa",
"https://deno.land/std@0.149.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
"https://deno.land/std@0.149.0/path/win32.ts": "bd7549042e37879c68ff2f8576a25950abbfca1d696d41d82c7bca0b7e6f452c",
"https://deno.land/std@0.149.0/testing/_diff.ts": "029a00560b0d534bc0046f1bce4bd36b3b41ada3f2a3178c85686eb2ff5f1413",
"https://deno.land/std@0.149.0/testing/_format.ts": "0d8dc79eab15b67cdc532826213bbe05bccfd276ca473a50a3fc7bbfb7260642",
"https://deno.land/std@0.149.0/testing/asserts.ts": "0ee58a557ac764e762c62bb21f00e7d897e3919e71be38b2d574fb441d721005",
"https://deno.land/std@0.133.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.133.0/_util/os.ts": "49b92edea1e82ba295ec946de8ffd956ed123e2948d9bd1d3e901b04e4307617",
"https://deno.land/std@0.133.0/fmt/colors.ts": "30455035d6d728394781c10755351742dd731e3db6771b1843f9b9e490104d37",
"https://deno.land/std@0.133.0/fmt/printf.ts": "e2c0f72146aed1efecf0c39ab928b26ae493a2278f670a871a0fbdcf36ff3379",
"https://deno.land/std@0.133.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
"https://deno.land/std@0.133.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
"https://deno.land/std@0.133.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b",
"https://deno.land/std@0.133.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
"https://deno.land/std@0.133.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
"https://deno.land/std@0.133.0/path/mod.ts": "4275129bb766f0e475ecc5246aa35689eeade419d72a48355203f31802640be7",
"https://deno.land/std@0.133.0/path/posix.ts": "663e4a6fe30a145f56aa41a22d95114c4c5582d8b57d2d7c9ed27ad2c47636bb",
"https://deno.land/std@0.133.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
"https://deno.land/std@0.133.0/path/win32.ts": "e7bdf63e8d9982b4d8a01ef5689425c93310ece950e517476e22af10f41a136e",
"https://deno.land/std@0.133.0/testing/_diff.ts": "9d849cd6877694152e01775b2d93f9d6b7aef7e24bfe3bfafc4d7a1ac8e9f392",
"https://deno.land/std@0.133.0/testing/asserts.ts": "b0ef969032882b1f7eb1c7571e313214baa1485f7b61cf35807b2434e254365c",
"https://deno.land/std@0.85.0/async/deferred.ts": "f89ed49ba5e1dd0227c6bd5b23f017be46c3f92e4f0338dda08ff5aa54b9f6c9",
"https://deno.land/std@0.85.0/async/delay.ts": "9de1d8d07d1927767ab7f82434b883f3d8294fb19cad819691a2ad81a728cf3d",
"https://deno.land/std@0.85.0/async/mod.ts": "253b41c658d768613eacfb11caa0a9ca7148442f932018a45576f7f27554c853",
Expand Down Expand Up @@ -532,21 +546,6 @@
"https://deno.land/x/zod@v3.14.4/index.ts": "035a7422d9f2be54daa0fe464254b69225b443000673e4794095d672471e8792",
"https://deno.land/x/zod@v3.14.4/mod.ts": "64e55237cb4410e17d968cd08975566059f27638ebb0b86048031b987ba251c4",
"https://deno.land/x/zod@v3.14.4/types.ts": "7829a9fe28910b928e13de4b1b7ae72798ab09934daf69f3ef9d7ce52d0d5663",
"https://esm.sh/ts-pattern@3.3.5": "b3cf92da318a7dfcfc986523bb4cdf1e4e1626e5dd3fb34d7e8988ff5927f32e",
"https://esm.sh/v92/ts-pattern@3.3.5/deno/ts-pattern.js": "297f804772ed7ebf6a913dc3c462e8ce473ebf8ef315d715b29750a47e0a6459",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/guards.d.ts": "23d3ac26c35d4ea250f4f6fa07b659bd29c927a9b2820538566b6cb4430b28c3",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/index.d.ts": "9be090eb63ebe134cd5016ce8619bec07146219443604c34232a548303f262d8",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/symbols.d.ts": "98319b603cf3f3a8b5b2c41de042cde79d84b690f26c0b4685e4e672df8ca404",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/BuildMany.d.ts": "3674e53f36e6e41ba02338325facde0d9a955de5d7fd688498f587782db88093",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/DeepExclude.d.ts": "5c60171c7dd994fe164c8bbf3fc8ea24c38e59b28d591f5aabeff38ec88c6412",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/DistributeUnions.d.ts": "ea6d9a52a1dcafa3e3b00638585ab474f1ee12742047df8650f2dafda2e7b23e",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/ExtractPreciseValue.d.ts": "9e1e400b20494dfc0b76dbb958fbeb4d1ab1d466ede399d68cf0f48f0fb8c739",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/FindSelected.d.ts": "566c9855f7664544a79da7c90fa5f7d9d56410984e7fed1692860df71c121ebb",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/InvertPattern.d.ts": "02923619121da147c587d07cf4fe44cff411ff30f1f73c73e75d7649ff680407",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/IsMatching.d.ts": "cec8189326776ce185aaec51fca5e7614febfd698371250fe5f05ce839ace71e",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/Match.d.ts": "63e07e40910e6e8d4c4f08027aca1e7397aa31673a9dbfed50c9442b0800995b",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/Pattern.d.ts": "f30e3728c2943012603e55ab32cf3553ecf62a4cb90702169bddd8028aee7a35",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/types/helpers.d.ts": "93e97f7a2715e8391e59ffd02e23773fdd9184c041719cb4e52821501b3995d0",
"https://esm.sh/v92/ts-pattern@3.3.5/lib/wildcards.d.ts": "c1bfcc56d4e49285e3254b407a36325dd2f099dba94fe7dee68d992d1fc35429",
"https://esm.sh/ts-pattern@3.3.5": "13920cf5529bab1debc7df1be8bc57d914bf2d80cd81c452df8045af0da67f2d",
"https://raw.githubusercontent.com/mweichert/clipboard/master/mod.ts": "6368780ee65d9f034a23b7d525229947e02f141a16f1678f2b25735f391a2c6e"
}
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 35 additions & 2 deletions taqueria-plugin-taquito/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Taqueria Taquito Plugin

The Taquito plugin provides a stateful task to originate a smart contract to a Tezos sandbox or testnet
The Taquito plugin provides stateful tasks to originate and interact with smart contracts in Tezos sandboxes or testnets

## Installation

Expand All @@ -23,7 +23,7 @@ taq originate <filename>

### Basic description

The Taquito plugin exposes an `taq originate` task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.
The Taquito plugin exposes a `taq originate` (or `taq deploy`) task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.

This will originate a Michelson `.tz` file in the `/artifacts` directory to the default environment (the sandbox named `local`).

Expand All @@ -39,6 +39,39 @@ After origination, an alias will be created to refer to the originated contract'

- To provide an alias for the originated contract explicitly, use the `--alias` flag and supply a name.

## The `taq transfer` task

Basic usage is:

```shell
taq transfer <contract alias or address>
```

### Basic description

The Taquito plugin exposes a `taq transfer` (or `taq call`) task in Taqueria which will call the specified Michelson contract deployed to a Taqueria environment (default environment is one with sandbox named `local`).

This allows interactions from implicit accounts to implicit or smart contract accounts.

### Options

- To target a different environment, use the `--env` flag with the named Taqueria environment you want to target.

- By default, the amount of tez sent is `0`. Use the `--tez` flag to specify an amount you want.

- By default, the parameter is `Unit`. Use the `--param` flag to specify a filename, in `/artifacts`, that contains the content of the parameter for the transfer/call.

- By default, the entrypoint is `default`, which points to no specific annotated entrypoint. Use `--entrypoint` to specify an annotated entrypoint to call. E.g. if the parameter type of a Michelson contract is `(or (or (int %decrement) (int %increment)) (unit %reset))`, then there are two ways to call the `increment` entrypoint, with parameter `(Left (Right 14))` or with parameter `14` if your command contains `--entrypoint increment`.

### Examples

`taq call counter --param counter.parameter.param1.tz` will call a smart contract aliased as `counter` in the default environment with the parameter contained in that `.tz` file, transferring `0` tez.

`taq transfer tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb --tez 20` will transfer `20` tez to that address, which is some implicit account.

> ### :page_with_curl: Note
> `transfer` and `call` are exactly the same task. They are synonyms.
## Plugin Architecture

This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
38 changes: 36 additions & 2 deletions taqueria-plugin-taquito/_readme.eta
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Taqueria Taquito Plugin
<% } %>

The Taquito plugin provides a stateful task to originate a smart contract to a Tezos sandbox or testnet
The Taquito plugin provides stateful tasks to originate and interact with smart contracts in Tezos sandboxes or testnets

## Installation

Expand All @@ -25,7 +25,7 @@ taq originate <filename>

### Basic description

The Taquito plugin exposes an `taq originate` task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.
The Taquito plugin exposes a `taq originate` (or `taq deploy`) task in Taqueria which will originate the specified Michelson contract to a Taqueria environment.

This will originate a Michelson `.tz` file in the `/artifacts` directory to the default environment (the sandbox named `local`).

Expand All @@ -41,6 +41,40 @@ After origination, an alias will be created to refer to the originated contract'

- To provide an alias for the originated contract explicitly, use the `--alias` flag and supply a name.

## The `taq transfer` task

Basic usage is:

```shell
taq transfer <contract alias or address>
```

### Basic description

The Taquito plugin exposes a `taq transfer` (or `taq call`) task in Taqueria which will call the specified Michelson contract deployed to a Taqueria environment (default environment is one with sandbox named `local`).

This allows interactions from implicit accounts to implicit or smart contract accounts.

### Options

- To target a different environment, use the `--env` flag with the named Taqueria environment you want to target.

- By default, the amount of tez sent is `0`. Use the `--tez` flag to specify an amount you want.

- By default, the parameter is `Unit`. Use the `--param` flag to specify a filename, in `/artifacts`, that contains the content of the parameter for the transfer/call.

- By default, the entrypoint is `default`, which points to no specific annotated entrypoint. Use `--entrypoint` to specify an annotated entrypoint to call. E.g. if the parameter type of a Michelson contract is `(or (or (int %decrement) (int %increment)) (unit %reset))`, then there are two ways to call the `increment` entrypoint, with parameter `(Left (Right 14))` or with parameter `14` if your command contains `--entrypoint increment`.

### Examples

`taq call counter --param counter.parameter.param1.tz` will call a smart contract aliased as `counter` in the default environment with the parameter contained in that `.tz` file, transferring `0` tez.

`taq transfer tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb --tez 20` will transfer `20` tez to that address, which is some implicit account.

<%~ it.noteOpenAdmonition %>
`transfer` and `call` are exactly the same task. They are synonyms.
<%= it.closeAdmonition %>

## Plugin Architecture

This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
31 changes: 29 additions & 2 deletions taqueria-plugin-taquito/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Option, Plugin, Task } from '@taqueria/node-sdk';
import originate from './originate';
import taquito from './taquito';

Plugin.create(_i18n => ({
alias: 'taquito',
Expand Down Expand Up @@ -27,6 +27,33 @@ Plugin.create(_i18n => ({
handler: 'proxy',
encoding: 'application/json',
}),
Task.create({
task: 'transfer',
command: 'transfer <contract>',
description:
'Transfer/call an implicit account or a smart contract (specified via its alias or address) deployed to a particular environment',
options: [
Option.create({
flag: 'tez',
description: 'Amount of Tez to transfer',
required: false,
}),
Option.create({
flag: 'param',
description: 'Parameter to invoke the smart contract',
required: false,
}),
Option.create({
flag: 'entrypoint',
description:
'You may explicitly specify an entrypoint to make the parameter value shorter, without having to specify a chain of (Left (Right ... 14 ...))',
required: false,
}),
],
aliases: ['call'],
handler: 'proxy',
encoding: 'application/json',
}),
],
proxy: originate,
proxy: taquito,
}), process.argv);
Loading

0 comments on commit 8ee18c8

Please sign in to comment.