snet-cli
snet-cli copied to clipboard
Add informative messages when transaction fails
If user tries to withdraw an amount that he doesn't have in MPE:
$ snet account withdraw 1000000000000000000000
# gas_price = 1.000000 GWei
Error: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'}
If you want to see full Traceback then run:
snet --print-traceback [parameters]
If user tries to deposit an amount that he doesn't have in his wallet:
$ snet account deposit 10000000000
# gas_price = 1.000000 GWei
transaction:
chainId: 3
...
Proceed? (y/n): y
Submitting transaction...
event_summaries:
- args:
owner: '0xA6E06cF37110930D2906e6Ae70bA6224eDED917B'
spender: '0x7E6366Fbe3bdfCE3C906667911FC5237Cc96BD08'
value: 1000000000000000000
event: Approval
...
# gas_price = 1.000000 GWei
Error: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'}
If you want to see full Traceback then run:
snet --print-traceback [parameters]
(in this case we must avoid the Approval transaction too, not only adding a message...)
If user tries to publish an already published service:
$ snet service publish snet example-service
# gas_price = 1.000000 GWei
Error: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'}
If you want to see full Traceback then run:
snet --print-traceback [parameters]
If user tries to delete a service from other user:
$ snet service delete snet example-service
# gas_price = 1.000000 GWei
Error: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'}
If you want to see full Traceback then run:
snet --print-traceback [parameters]
Will check all commands but first we need to agree on how to deliver this to the users...
I did this, in a friendly way, in the snet organization
commands, like:
$ snet organization add-members snet 0xA6E06cF37110930D2906e6Ae70bA6224eDED917B
Creating transaction to add 1 members into organization snet...
# gas_price = 1.000000 GWei
Transaction error!
HINT: Check if you are the owner of snet
Error: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'}
If you want to see full Traceback then run:
snet --print-traceback [parameters]
What do you guys think about how we should warn/inform/show messages to the users?
@arturgontijo I would propose slightly different approach.
We should check for possible errors before making transaction.
For example: In snet organization add-members
we should check that current identity is the owner of the given organization and we should fail with clear message ("you are not the owner of ...."). I think it is better then the current "HINT" behavior because it might be misleading (if the real reason of the failure is different).
The same for all examples @arturgontijo has mentioned.
Agree!