ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
873 stars 133 forks source link

Sign: [y/N]: shows every tx #668

Closed SwapOperator closed 2 years ago

SwapOperator commented 2 years ago

Environment information

$ ape --version
# ...copy and paste result of above command here...

$ ape plugins list
# ...copy and paste result of above command here...
$ cat ape-config.yaml
# contracts_folder: contracts

What went wrong?

I decided to test my smart contracts with APE. For that I needed to install hardhat plugin. I did it through pycharm Python Interpreter. However, I needed to do a few more tests on Rinkeby before I ran "ape test". At this moment I found out a bug that ask me to sign tx on each transaction. I deleted hardhat plugin late, but it didn't help.

my first tx:

Sign:  [y/N]: y
Enter passphrase to unlock 'trader03' []: 
Leave 'trader03' unlocked? [y/N]: y

The message below after first tx:

Sign:  [y/N]:

reacts only positive only on Enter, y, n, N. But if I type n or N, the tx will continue to process.

If I type some random symbols:

Sign:  [y/N]: sfgsf
Error: invalid input

I don't remember the exact version of APE i has before. But I'm sure it was older 2.0.

I tested on a new created env, but I still get with message again and again.

Please include information like:

How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed.

antazoey commented 2 years ago

Hello! In general, we use test accounts that do not require y/N for signing transactions, but you said you are running tests on the Rinkeby network so that is why you are probably using key-file accounts.

Thankfully, there is a solution for this! We have a method for enabling auto sign()...

account.set_autosign(True)

It will prompt you for a passphrase, but you can also pass it on to bypass that:

accounts.set_autosign(True, passphrase="123")

Please let me know if this resolves your issue! And thank you for using ape and reporting :)

SwapOperator commented 2 years ago

Hello! In general, we use test accounts that do not require y/N for signing transactions, but you said you are running tests on the Rinkeby network so that is why you are probably using key-file accounts.

Thankfully, there is a solution for this! We have a method for enabling auto sign()...

account.set_autosign(True)

It will prompt you for a passphrase, but you can also pass it on to bypass that:

accounts.set_autosign(True, passphrase="123")

Please let me know if this resolves your issue! And thank you for using ape and reporting :)

AttributeError: 'AccountManager' object has no attribute 'set_autosign'

It's interesting but I got error. I checked def auto_sign() recently, and it is definitely was in accounts.py

SwapOperator commented 2 years ago

Thanks @fubuloubu and @unparalleled-js . The problem was solved

    owner = accounts.load("trader03")
    owner.set_autosign(True)