arc.js_legacy icon indicating copy to clipboard operation
arc.js_legacy copied to clipboard

`genesisProtocolWrapper.stake(..)` should check result and throw an exception if not succesful

Open tsuberim opened this issue 7 years ago • 5 comments

GenesisProtocol.stake(..) returns false if unsuccessful. This should be checked in Arc.js and thrown as an exception. Eg. this happens if staking once for YES and again with NO (according to this line).

Also, make sure cases like this are checked throughout the library.

Edit: in this case, the best way to check for this is to check if the Stake event was emitted since false may be returned in cases other than a failed stake

tsuberim avatar May 14 '18 14:05 tsuberim

I am not aware of a means of checking return values when transactions are generated. The right way to do this, I believe, would be to check whether the expected events were emitted.

dkent600 avatar May 14 '18 14:05 dkent600

@dkent600 Correct. Edited.

tsuberim avatar May 14 '18 14:05 tsuberim

Arc.js could perhaps incorporate such a check on functions where it would make sense and be commonly needed.

dkent600 avatar May 14 '18 14:05 dkent600

I think it should be on a case by case basis, according to the logic defined in Arc for each method.

tsuberim avatar May 14 '18 14:05 tsuberim

Definitely potentially a useful feature.

dkent600 avatar May 14 '18 14:05 dkent600