-
Notifications
You must be signed in to change notification settings - Fork 103
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
update all GetSignBytes
functions with correct codec
#1481
Comments
The short-term workaround we had anticipated for this problem (by forking CosmJS) will not actually work, since the serialization of a signDoc happens inside of the Keplr wallet extension. As a result, we'll need to go back to our original plan to do a network upgrade & software governance proposal to get hardware wallet support working w/ the upcoming marketplace launch. I spent some time today doing manually testing against #1480 and #1481. Unfortunately neither of them seem to work as expected. I added a println to the bottom of $ regen version
main-00829dac260fa304760e399561f89eed15350a11
$ regen tx ecocredit send 500 C01-001-20200101-20210101-001 regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46 --from cory_ledger --output json
Default sign-mode 'direct' not supported by Ledger, using sign-mode 'amino-json'.
# this is the normal proto-json output displayed to the user
{"body":{"messages":[{"@type":"/regen.ecocredit.v1.MsgSend","sender":"regen10sc6nxu0uc4ss5m4cxdzhwcahc9zte9allwrsh","recipient":"regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46","credits":[{"batch_denom":"C01-001-20200101-20210101-001","tradable_amount":"500","retired_amount":"0","retirement_jurisdiction":""}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""},"tip":null},"signatures":[]}
confirm transaction before signing and broadcasting [y/N]: y
# this is the amino GetSignBytes() output from `x/auth/tx/legacy_amino_json.go`
Serialized SignDoc: {"account_number":"103","chain_id":"regen-redwood-1","fee":{"amount":[],"gas":"200000"},"memo":"","msgs":[{"credits":[{"batch_denom":"C01-001-20200101-20210101-001","retired_amount":"0","tradable_amount":"500"}],"recipient":"regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46","sender":"regen10sc6nxu0uc4ss5m4cxdzhwcahc9zte9allwrsh"}],"sequence":"4"} @AmauryM @technicallyty do either of you have any idea what may be missing here? I know Amaury had written a unit test to verify that the serialization was working correct... Are there different codecs being wired up at some other point that don't make use of the ones from #1480 ? |
For reference, here's what sending a normal $ regen tx bank send $(regen keys show -a cory_ledger) regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46 5000uregen --from cory_ledger --output json
Default sign-mode 'direct' not supported by Ledger, using sign-mode 'amino-json'.
# this is the normal proto-json output displayed to the user
{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"regen10sc6nxu0uc4ss5m4cxdzhwcahc9zte9allwrsh","to_address":"regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46","amount":[{"denom":"uregen","amount":"5000"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""},"tip":null},"signatures":[]}
confirm transaction before signing and broadcasting [y/N]: y
# this is the amino GetSignBytes() output from `x/auth/tx/legacy_amino_json.go`
Serialized SignDoc: {"account_number":"103","chain_id":"regen-redwood-1","fee":{"amount":[],"gas":"200000"},"memo":"","msgs":[{"type":"cosmos-sdk/MsgSend","value":{"amount":[{"amount":"5000","denom":"uregen"}],"from_address":"regen10sc6nxu0uc4ss5m4cxdzhwcahc9zte9allwrsh","to_address":"regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46"}}],"sequence":"4"} |
i'm getting bz, err := legacy.Cdc.MarshalJSON(StdSignDoc{
AccountNumber: accnum,
ChainID: chainID,
Fee: json.RawMessage(fee.Bytes()),
Memo: memo,
Msgs: msgsBytes,
Sequence: sequence,
TimeoutHeight: timeout,
Tip: stdTip,
})
if err != nil {
panic(err)
} resulting in {
"account_number": "0",
"sequence": "9",
"chain_id": "chain-ysrrFL",
"memo": "",
"fee": {
"amount": [
{
"denom": "stake",
"amount": "10"
}
],
"gas": "200000"
},
"msgs": [
{
"type": "regen/MsgCreateClass",
"value": {
"admin": "regen1znmkg3qgvvz3f3qxnfw628kd5e7ueseschfsc3",
"credit_type_abbrev": "C",
"fee": {
"amount": "20000000",
"denom": "stake"
},
"issuers": [
"regen1znmkg3qgvvz3f3qxnfw628kd5e7ueseschfsc3"
],
"metadata": "metadata"
}
}
]
} |
Turns out this was correctly fixed on main branch, and the only issue on @technicallyty's PR was that there was no replace directive in the go.mod for As long as we ensure #1500 is taken care of after merging #1483, then we should be good to go. Closing this issue in favor of #1500 now. |
…) (#1483) * fix(x/ecocredit): amino registration * chore: changelog entry Co-authored-by: tyler <{ID}+{username}@users.noreply.github.com>
Summary of Bug
our
GetSignBytes
methods on all messages are currently producing incorrect sign bytes. The fix for MsgSend is in this PRVersion
main
Steps to Reproduce
GetSignBytes
of any regen ledger messagetype
andvalue
fields, but currently does notFor Admin Use
The text was updated successfully, but these errors were encountered: