fix: ensure account gets funded even if identity already exists - #106
Conversation
|
I noticed when changing the fund to within the contract upload error check that the after_deploy script was in the wrong place. It should be within the else statement (if no contract ID is supplied) because it should only be run after actually deploying the contract. You can see in the latest change this was moved to after the deploy call. This fixes after_deploy being run for contracts that have already been deployed and it fixes a potential issue of an account not being funded when it doesn't exist if you have the contract ID already set (all remaining actions are just generating typescript bindings / npm installing none of which require an account). |
There was a problem hiding this comment.
I like this retry path better, but I'll defer to @willemneal for the final call/what direction this should go.
Also a flag to check out that the after_deploy movement is right -- sounds like it to me.
|
I tried installing this and testing it end to end. Steps:
|
|
The issue is that the friendbot service gets initialized after the rpc server is ready, so there is a race condition with friendbot being ready and the network fund. I fixed it by adding a friendbot status check before continuing after starting the network container. Here is the output after the fix: |
willemneal
left a comment
There was a problem hiding this comment.
LGTM. Just one question and suggestion
Currently if you have an identity saved for an account created locally, whenever your network container resets this account will no longer exist. When we go to generate the account, the
generate --fundcall tostellar-clifails withidentity already exists. Currently we dont exist on this error because it shouldn't cause the remainder of the code execution to fail. However, if the underlying account no longer exists on-chain, any later commands using that account will fail. So to fix it, I added akeys fundcall if we find the identity exists. This ensures the key actually does exist on-chain and is funded. This is only done when the network is not mainnet, and the environment isdevelopmentortesting.