-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gaiacli sign --offline should require additional flags #3893
Comments
|
We should implement a conditional logic in the CLIContext that populates account number, sequence, and all the rest according to the offline flag, i.e. if offline is false then populate values automatically (provides that they are not overridden by their respective cli flags and the node is reachable); else leave them blank and leave error handling with the caller. |
Maybe we can add new command for sign offline with sequence and account-number as argument. |
Don't we already do this @alessio during the @yangyanqing I think we should really avoid new commands if possible. The default value can just be -1 in this case. |
These two flag's type was Uint64, so -1 can not be set as the default value. Function func populateAccountFromState(txBldr authtxb.TxBuilder, cliCtx context.CLIContext,
addr sdk.AccAddress) (authtxb.TxBuilder, error) {
if txBldr.AccountNumber() == 0 {
accNum, err := cliCtx.GetAccountNumber(addr)
if err != nil {
return txBldr, err
}
txBldr = txBldr.WithAccountNumber(accNum)
}
if txBldr.Sequence() == 0 {
accSeq, err := cliCtx.GetAccountSequence(addr)
if err != nil {
return txBldr, err
}
txBldr = txBldr.WithSequence(accSeq)
}
return txBldr, nil
} But we can't make that assumptions, except:
➜ cosmos-sdk git:(frank/3893-gaiacli-sign-offline) ✗ gaiacli query account cosmos1h7urjzmuejtu6h96t744r2euvqekar6ujupegm( {
"type": "auth/Account",
"value": {
"address": "cosmos1h7urjzmuejtu6h96t744r2euvqekar6ujupegm",
"coins": [
{
"denom": "apple",
"amount": "99999"
},
{
"denom": "stake",
"amount": "199999900"
}
],
"public_key": {
"type": "tendermint/PubKeySecp256k1",
"value": "AzpJconKtox/Pf774JosZhASDDkRS5E+j4yKcPJXb0jn"
},
"account_number": "0",
"sequence": "2"
}
} |
Sure, so we can make the type |
No no, I mean the CLI flags and TxBuilder can use ints. The account must use unsigned ints! |
Choosing int sequence means reducing the number of available tx by half. |
Ahh I suppose you're right. The reason was collective. No reason they should be signed integers. For offline mode we can perhaps check via Viper if the flag was set/changed. |
Great idea! I'll try it. |
Or we can turn the CLI flag into a string, and parse it as Uint later on. |
As a side note, these flags should be |
I agree @jackzampolin, shorthands for common and important flags should always be provided. |
- Add shorthand flags `-a` and `-s` for the account and sequence numbers respectively - Mark the account and sequence numbers required during "offline" mode - Always do an RPC query for account and sequence number during "online" mode - If clients wish to provide such values, they must use `--offline`. This makes the whole flow/UX easier to reason about. closes: #3893
The
--account-number
,--sequence
and--chain-id
flags should be required.The text was updated successfully, but these errors were encountered: