implement combination of withdraw and delegation messages on auto-del…#6
implement combination of withdraw and delegation messages on auto-del…#6leopoldjoy wants to merge 5 commits into
Conversation
| if [[($remaining_stake_left_from_last_delegation -gt 10000000)]] | ||
| then | ||
| # Since it was photinos, set equal to zero since there were no STAKE left following the last transaction | ||
| remaining_stake_left_from_last_delegation=0 |
There was a problem hiding this comment.
Nice. I thought it was variable overflow when I set up to be at least > 10000000.
But you are saying that when no stake then it retrieves the photinos.
There was a problem hiding this comment.
Correct. .value.coins is an array containing the STAKE (first) and photinos (second) balances. If the STAKE balance is zero than only the photinos balance is returned—hence the much higher number.
There was a problem hiding this comment.
Cosmos team should learn about good programming practices...
A variable can't return a different type / scope on different scenarios.
There was a problem hiding this comment.
Haha :) Yes, they could use an object/dictionary for each of the coin balance names. However my guess is that they used an array since they may want to ultimately allow any number of different coin types/balances in an account
There was a problem hiding this comment.
Maybe but a variable should always return the same type.
| # which will generate the above file (at /etc/systemd/system/myservice.service.d/myenv.conf) | ||
|
|
||
| echo "Setting (fake) initial historical interval stake earnings..." | ||
| last_10_interval_earnings[0]=100 |
There was a problem hiding this comment.
It should retrieve history from the blockchain directly.
- It allows restart of the script
- it starts from averaging previous attacks and strange behaviors.
There was a problem hiding this comment.
Yes, 100% agree, let's add this as a ticket
| echo "About to withdraw (all STAKE) and delegate: $total_to_delegate STAKE" | ||
|
|
||
| # Create withdrawal transaction | ||
| withdrawal_txn=$(sudo /opt/go/bin/gaiacli --home=/opt/gaiacli tx dist withdraw-rewards --async --is-validator --from=game-of-stake-key-validator4 --chain-id=game_of_stakes_3 --fee=1000photinos --trust-node --generate-only) |
There was a problem hiding this comment.
No, absolutely not, since this is a --generate-only command. Good call! Removed in the most recent commit 👍
| delegation_msg=$(echo $delegation_txn | jq -r '.value.msg[0]') | ||
|
|
||
| # Combine the delegation message with the withdrawal transaction to create the final transaction (with both messages) | ||
| withdrawal_and_delegation_txn=$(echo $withdrawal_txn | jq ".value.msg[1] |= . + $delegation_msg") |
| # Combine the delegation message with the withdrawal transaction to create the final transaction (with both messages) | ||
| withdrawal_and_delegation_txn=$(echo $withdrawal_txn | jq ".value.msg[1] |= . + $delegation_msg") | ||
|
|
||
| echo "Saving generated withdrawal/delegation transaction to $filePath..." |
There was a problem hiding this comment.
name filePath is not good.
Maybe: ComboTX or WithdrawDelegateTX
There was a problem hiding this comment.
Yes, true! Fixed in the most recent commit 👍
…tps://github.com/stake-capital/cosmos into feature/implement-withdraw-and-delegate-together
…egate.sh script