Skip to content

Commit

Permalink
Updated and modified files for the project
Browse files Browse the repository at this point in the history
- Updated files:
  - src/ape_utils/_cli.py
  • Loading branch information
avik committed Jul 10, 2024
1 parent e268110 commit d647a0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ pip install -e .

## Quick Usage

Once installed, you can use the ape_call command to call view functions on Ethereum smart contracts. Here is how you can use it:
Once installed, you can use the ape_utils command to call view functions on Ethereum smart contracts. Here is how you can use it:

![help](media/help.png)

```sh
ape_call call --function-sig "function_signature" --address "contract_address" --args argument
ape_utils call --function-sig "function_signature" --address "contract_address" --args argument
```

### Example

To call a view function with the signature `call_this_view_function(uint256)(string)` on a contract at address `0x80E097a70cacA11EB71B6401FB12D48A1A61Ef54` with an argument `6147190`, you can use:

```bash
ape_call call --function-sig "call_this_view_function(uint256)(string)" --address "0x80E097a70cacA11EB71B6401FB12D48A1A61Ef54" --args 6147190
ape_utils call --function-sig "call_this_view_function(uint256)(string)" --address "0x80E097a70cacA11EB71B6401FB12D48A1A61Ef54" --args 6147190
```

![working](media/working.png)
Expand Down
4 changes: 2 additions & 2 deletions demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Set WindowBar Colorful
Set Framerate 60


Type "ape_call --help"
Type "ape_utils --help"
Enter 1
Sleep 2s
Type "ape_call call --function-sig 'call_this_view_function(uint256)(string)' --address '0x80E097a70cacA11EB71B6401FB12D48A1A61Ef54' --args 6147190"
Type "ape_utils call --function-sig 'call_this_view_function(uint256)(string)' --address '0x80E097a70cacA11EB71B6401FB12D48A1A61Ef54' --args 6147190"
Enter 1
Sleep 10s
5 changes: 5 additions & 0 deletions src/ape_utils/_cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import click
import rich_click as rclick
from rich.console import Console
from rich.traceback import install

from ape_utils.__about__ import __version__
from ape_utils.utils import call_view_function, encode_calldata_using_ape

install()
console = Console()

rclick.OPTION_GROUPS = {
Expand Down Expand Up @@ -84,10 +86,13 @@ def encode(signature: str, args: list) -> None:
console.print(f"[blue bold]Encoded Calldata: [green]{calldata.hex()}")
except Exception as e:
console.print(f"Error: [red]{e!s}")
# TODO: Raise if debug mode is enabled
# raise e


# Add commands to the CLI group
cli.add_command(call_view_function_from_cli, name="call")
cli.add_command(encode, name="encode")
cli.add_command(version, name="version")

if __name__ == "__main__":
Expand Down

0 comments on commit d647a0a

Please sign in to comment.