-
Notifications
You must be signed in to change notification settings - Fork 344
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
Add authz and feegrant messages to default types #1026
Comments
This should make https://github.com/cosmos/composer/blob/master/react/src/redux/action-creator/wallet.ts#L59-L60 unnecessary. |
Reopening because this part is missing:
We should add an implementation to https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/aminotypes.ts#L67-L511 for the new message types where both |
I added the error in #1039 , but wonder how I should do the |
I have a question around the not implemented aminoTypes. That also means, that signing those kind of messages won't work with a ledger device, since it seems that when using a ledger it requires the amino signer? |
Just FYI, discussing right now if we should add Amino signing for Authz and will ping here if there's an issue on the SDK. Imo there's quite a few use cases for it. |
Amino for |
All right, I've tested some things and it seems possible to do it, as long as CosmJS allows for truly custom encoding/decoding when using Amino. ContextCurrently Instead of having something like this: {
"type": "cosmos/MsgGrant",
"value": {
"grant":{
"authorization":{},
"expiration":"2023-02-17T15:37:29Z"
},
"grantee":"desmos1gedewhj0qpm55yc359e6qd36wkl9jvnp3zk90h",
"granter":"desmos1vxe0qadrgpg52zk03k5r29wd9jt59ej664t2yl"
}
} We have something like this: {
"grant":{
"authorization":{},
"expiration":"2023-02-17T15:37:29Z"
},
"grantee":"desmos1gedewhj0qpm55yc359e6qd36wkl9jvnp3zk90h",
"granter":"desmos1vxe0qadrgpg52zk03k5r29wd9jt59ej664t2yl"
} Possible solutionOnce possible solution is to define the following converter: export const cosmosTypes: Record<string, AminoConverter> = {
// Authz types
"/cosmos.authz.v1beta1.MsgGrant": {
aminoType: "",
toAmino: (value: MsgGrant): AminoMsgGrant => {
return {
grant: value.grant ? convertGrant(value.grant) : undefined,
granter: value.granter,
grantee: value.grantee,
};
},
fromAmino: (msg: AminoMsgGrant): MsgGrant => {
return MsgGrant.fromPartial({
grant: msg.grant ? convertAminoGrant(msg.grant) : undefined,
granter: msg.granter,
grantee: msg.grantee,
});
},
},
}; The problem with this is that (after testing it), I've found out that CosmJS automatically puts everything that is returned by the I think that by applying the following changes to CosmJS everything could be implemented properly:
|
Urg, that sounds like the same bug that Stargaze had in their airdrop claim message. The |
If I'm not mistaken, the reason we have weird amino encoding for authz/feegrant is because we forgot to add the We can definitely add RegisterLegacyAminoCodec for authz/feegrant in v0.46. But CosmJS must detect the SDK version, and throw an error for <0.46. |
I spoke with @aaronc about this yesterday, and looks like it wasn't implemented properly in the SDK yeah. I'll confirm with him and create an issue on the SDK if that's the case. |
Ah, there you go. Great timing. Are you okay to create an issue on the SDK @AmauryM ? |
I would appreciate a solution that is consistent with the current Amino JSON framework. The lack of a type identifier makes it impossibe to do the reverse conversion (Amino JSON -> proto), would requires us to change a lot of architecture and probably break caller code. |
We can track this issue on the SDK here: cosmos/cosmos-sdk#11190. There's also a PR cosmos/cosmos-sdk#11224. Note that this will be only available starting on v0.46. |
That's fine with me. CosmJS users can change the configuration of the For now we'll just change the term "not implemented on chain" to "not supported on chain" in #1039 and consider a non-compliant implementation "not supported". |
By the way, @AmauryM, thank you for implementing Amino JSON sign mode for the new types. I have the impression this will make many people very happy and help the adotion of the new functionality. |
This discussion has been summarized in https://medium.com/confio/authz-and-ledger-signing-an-executive-summary-8754a0dc2a88 in order to educate the various stakeholder. The follow-up ticket is #1092. |
authz and feegrant were added to the code generator already. They add the new message types:
They should be added to the Stargate registry.
For the AminoTypes it seems like no Amino JSON signing is implemented on-chain. So we should create a specific error message for that, explaining why it does not work.
The text was updated successfully, but these errors were encountered: