From 031773560a38d232f9282c5c93ccc689b31c192c Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Thu, 6 Oct 2022 14:46:25 +0200 Subject: [PATCH 1/3] feat: remove invoke command and update README.md --- README.md | 50 +++++++++++++++++++++---------------------------- src/nile/cli.py | 19 +------------------ src/nile/nre.py | 6 ------ 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 527107f1..f135e06d 100644 --- a/README.md +++ b/README.md @@ -154,17 +154,16 @@ You can find an example `.env` file in `example.env`. These are private keys onl nile setup 🚀 Deploying Account -🌕 artifacts/Account.json successfully deployed to 0x07db6b52c8ab888183277bc6411c400136fe566c0eebfb96fffa559b2e60e794 +⏳ ️Deployment of Account successfully sent at 0x07db6b52c8ab888183277bc6411c400136fe566c0eebfb96fffa559b2e60e794 +🧾 Transaction hash: 0x17 📦 Registering deployment as account-0 in localhost.deployments.txt -Invoke transaction was sent. -Contract address: 0x07db6b52c8ab888183277bc6411c400136fe566c0eebfb96fffa559b2e60e794 -Transaction hash: 0x17 ``` A few things to notice here: 1. `nile setup ` looks for an environment variable with the name of the private key alias -2. This creates a `localhost.accounts.json` file storing all data related to accounts management +2. This creates or updates `localhost.accounts.json` file storing all data related to accounts management +3. The creates or updates `localhost.deployments.txt` file storing all data related to deployments ### `send` @@ -189,23 +188,15 @@ Some things to note: - `max_fee` defaults to `0`. Add `--max_fee ` to set the maximum fee for the transaction - `network` defaults to the `localhost`. Add `--network ` to change the network for the transaction -### `call` and `invoke` +### `call` -Using `call` and `invoke`, we can perform read and write operations against our local node (or public one using the `--network mainnet` parameter). The syntax is: +Using `call`, we can perform read operations against our local node (or public one using the `--network mainnet` parameter). The syntax is: ```sh -nile [PARAM_1, PARAM2...] +nile call [PARAM_1, PARAM2...] ``` -Where `` is either `call` or `invoke` and `` is either our contract address or alias, as defined on `deploy`. - -```sh -nile invoke my_contract increase_balance 1 - -Invoke transaction was sent. -Contract address: 0x07ec10eb0758f7b1bc5aed0d5b4d30db0ab3c087eba85d60858be46c1a5e4680 -Transaction hash: 0x1 -``` +Where `` is either our contract address or alias, as defined on `deploy`. ```sh nile call my_contract get_balance @@ -239,17 +230,6 @@ Please note: - `localhost` is the default network. Add `--network ` to change the network for the script -### `get_declaration` (NRE only) - -Return the hash of a declared class. This can be useful in scenarios where a contract class is already declared with an alias prior to running a script. - -```python -def run(nre): - predeclared_class = nre.get_declaration("alias") -``` - -> Note that this command is only available in the context of scripting in the Nile Runtime Environment. - ### `clean` Deletes the `artifacts/` directory for a fresh start ❄️ @@ -391,7 +371,7 @@ def run(nre): > Please note that the list of accounts includes only those that exist in the local `.accounts.json` file. In a recent release we added a flag to the command, to get predeployed accounts if the network you are connected to is a [starknet-devnet](https://github.com/Shard-Labs/starknet-devnet) instance. -### `get-accounts --predeployed` +### `get-accounts --predeployed (only starknet-devnet)` This flag retrieves the predeployed accounts if the network you are connecting to is a [starknet-devnet](https://github.com/Shard-Labs/starknet-devnet) instance. @@ -426,6 +406,18 @@ Retrieves the nonce for the given contract address (usually an account). nile get-nonce ``` +### `get_declaration` (NRE only) + +Return the hash of a declared class. This can be useful in scenarios where a contract class is already declared with an alias prior to running a script. + +```python +def run(nre): + predeclared_class = nre.get_declaration("alias") +``` + +> Note that this command is only available in the context of scripting in the Nile Runtime Environment. + + ## Short string literals From [cairo-lang docs](https://www.cairo-lang.org/docs/how_cairo_works/consts.html#short-string-literals): A short string is a string whose length is at most 31 characters, and therefore can fit into a single field element. diff --git a/src/nile/cli.py b/src/nile/cli.py index fee65e06..5f231516 100755 --- a/src/nile/cli.py +++ b/src/nile/cli.py @@ -119,7 +119,7 @@ def setup(signer, network): @click.option("--max_fee", nargs=1) @network_option def send(signer, address_or_alias, method, params, network, max_fee=None): - """Invoke a contract's method through an Account. Same usage as nile invoke.""" + """Invoke a contract's method through an Account.""" account = Account(signer, network) print( "Calling {} on {} with params: {}".format( @@ -131,23 +131,6 @@ def send(signer, address_or_alias, method, params, network, max_fee=None): print(out) -@cli.command() -@click.argument("address_or_alias", nargs=1) -@click.argument("method", nargs=1) -@click.argument("params", nargs=-1) -@click.option("--max_fee", nargs=1) -@network_option -def invoke(address_or_alias, method, params, network, max_fee=None): - """Invoke functions of StarkNet smart contracts.""" - if not is_alias(address_or_alias): - address_or_alias = normalize_number(address_or_alias) - - out = call_or_invoke_command( - address_or_alias, "invoke", method, params, network, max_fee=max_fee - ) - print(out) - - @cli.command() @click.argument("address_or_alias", nargs=1) @click.argument("method", nargs=1) diff --git a/src/nile/nre.py b/src/nile/nre.py index a85f0bfa..1ba72e98 100644 --- a/src/nile/nre.py +++ b/src/nile/nre.py @@ -45,12 +45,6 @@ def call(self, address_or_alias, method, params=None): call_or_invoke(address_or_alias, "call", method, params, self.network) ).split() - def invoke(self, address_or_alias, method, params=None): - """Invoke a mutable function in a smart contract.""" - if not is_alias(address_or_alias): - address_or_alias = normalize_number(address_or_alias) - return call_or_invoke(address_or_alias, "invoke", method, params, self.network) - def get_deployment(self, address_or_alias): """Get a deployment by its identifier (address or alias).""" if not is_alias(address_or_alias): From 18b96c8d481091483668d3702c1350c1ee3556e6 Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Fri, 7 Oct 2022 15:59:54 +0200 Subject: [PATCH 2/3] Update README.md Co-authored-by: Andrew Fleming --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f135e06d..5187b2f1 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ Some things to note: ### `call` -Using `call`, we can perform read operations against our local node (or public one using the `--network mainnet` parameter). The syntax is: +Using `call`, we can perform read operations against our local node or the specified public network. The syntax is: ```sh nile call [PARAM_1, PARAM2...] From d8a2d8b6efb162d006193799ab3fd4d1d6742989 Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Fri, 21 Oct 2022 14:05:51 +0200 Subject: [PATCH 3/3] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martín Triay --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5187b2f1..c08ce00b 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ nile setup 📦 Registering deployment as account-0 in localhost.deployments.txt ``` -A few things to notice here: +A few things to note here: 1. `nile setup ` looks for an environment variable with the name of the private key alias 2. This creates or updates `localhost.accounts.json` file storing all data related to accounts management