Closed Pet3ris closed 2 years ago
I will look into this. It's pretty cool how your effort to bind this library to Rescript is uncovering a lot of issues.
Have some additional information: this error does not occur when issuing calls before ArgentX is connected. It only occurs once the wallet is connected => then there are a couple of failed requests.
Version mismatch 🤦♂️. Had to write my own hook to nail down underlying issue (contract.connectedTo got changed to contract.address in starknet.js) but all good now.
Problem
I ran into the following situation:
I have some code that invokes the
useStarknetCall
hook right after theuseContract
hook.There's no real magic in this code as it translates to the following JS:
I noticed an issue where if the contract is not yet loaded when the
useCallback
is called inside of theuseStarknetCall
hook, then the hook never refreshes it's call to StarkNet.I had to add the following hook to the code to make it work and make the address compose:
Shortcut fix
Which translates to the following JS:
Possible fix
I wonder if it's important enough given
useContract
anduseStarknetCall
would typically be called in this sequence, to bake this logic or some form of it into the hook itself.I can see that this issue does not arise during in the demo program despite the hooks being called in short succession.
NOTE When I use the trick above, there are still some wasted requests that get created without a
contract_address
being specified (this may be astarknet.js
issue also).