generated from ApeWorX/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: code refactored & working on fixing the cli
- Loading branch information
avik
committed
Jul 9, 2024
1 parent
aaa72ad
commit 1bb2c5b
Showing
8 changed files
with
135 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "0.0.1" | ||
version = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# Add module top-level imports here | ||
from ape_utils.utils import call_view_function | ||
|
||
__all__ = ["call_view_function"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import click | ||
|
||
from ape_utils.utils import call_view_function | ||
|
||
|
||
@click.command() | ||
@click.option('--function-sig', prompt='Function signature', help='The function signature (e.g., gsr_query(uint256)(string)).') | ||
@click.option('--address', prompt='Contract address', help='The address of the smart contract.') | ||
@click.option('--args', prompt='Arguments', help='The arguments for the function call.', type=int) | ||
def main(function_sig, address, args): | ||
@click.option( | ||
"--function-sig", prompt="Function signature", help="The function signature (e.g., function_name(uint256)(string))." | ||
) | ||
@click.option("--address", prompt="Contract address", help="The address of the smart contract.") | ||
@click.option("--args", prompt="Arguments", help="The arguments for the function call.", type=int) | ||
def main(function_sig: str, address: str, args: int) -> None: | ||
try: | ||
output = call_view_function(function_sig, address, args) | ||
click.echo(f"Output: {output}") | ||
except Exception as e: | ||
click.echo(f"Error: {str(e)}") | ||
click.echo(f"Error: {e!s}") | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
from multicall import Call # type: ignore | ||
from web3 import Web3 | ||
import os | ||
from typing import Any | ||
|
||
from multicall import Call | ||
from rich.console import Console | ||
from rich.traceback import install | ||
|
||
|
||
from web3 import Web3 | ||
|
||
# install rich traceback | ||
install() | ||
console = Console() | ||
|
||
|
||
|
||
def call_view_function(function_sig: str, address: str, args: int) -> None: | ||
|
||
def call_view_function(function_sig: str, address: str, args: int) -> Any: | ||
w3 = Web3(Web3.HTTPProvider(os.environ["sepoliafork"])) | ||
|
||
# get_sitnature(address, function_sig) | ||
|
||
output = Call(address, [function_sig, args])(_w3=w3) | ||
|
||
console.print(f"[blue]Output: [green bold]{output}") | ||
# console.print(f"[blue]Output: [green bold]{output}") | ||
return output | ||
|
||
|
||
if __name__ == "__main__": | ||
function_sig: str = "gsr_query(uint256)(string)" | ||
address: str = "0x9b7FD6FF5e427F8470E1da652f21A79Bed318f38" | ||
args = 6147190 | ||
|
||
call_view_function(function_sig, address, args) | ||
|