hyperweb-io / hyperweb-io/telescope
(Nested) `Any` from/toAmino not symmetrical
- Dominant language
- TypeScript
- Stars
- 154
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
The call to `fromAmino` removes the nested message type indicator in a group proposal, causing an issue when multiple message types contain the same fields.
## Context
[Telescope configuration](https://github.com/fmorency/manifestjs/blob/7873535b4801c95e96264bb7f58ad7ef27f33e7f/scripts/codegen.js#L10-L140)
The [POA](https://github.com/strangelove-ventures/poa) module contains [MsgRemovePending](https://github.com/strangelove-ventures/poa/blob/6922e22a617a892501b9150662c597ab06bfb805/proto/strangelove_ventures/poa/v1/tx.proto#L70-L80) and [MsgRemoveValidator](https://github.com/strangelove-ventures/poa/blob/6922e22a617a892501b9150662c597ab06bfb805/proto/strangelove_ventures/poa/v1/tx.proto#L54-L64) differing only by message name, i.e., the message fields are the same in both messages.
The [remove pending validator test](https://github.com/fmorency/manifestjs/blob/7873535b4801c95e96264bb7f58ad7ef27f33e7f/starship/__tests__/poa.group.test.ts#L147-L197) creates a `Group Proposal` containing a `Remove Pending Validator` message, submits the proposal, vote on it and execute the proposal.
Encoding and signing the message using AMINO works fine
```json
{
"chain_id": "manifest-ledger-beta",
"account_number": "2",
"sequence": "8",
"fee": {
"amount": [
{
"denom": "umfx",
"amount": "100000"
}
],
"gas": "550000"
},
"msgs": [
{
"type": "cosmos-sdk/group/MsgSubmitProposal",
"value": {
"group_policy_address": "manifest1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsfmy9qj",
"proposers": [
"manifest1pss7nxeh3f9md2vuxku8q99femnwdjtcwhpj7f"
],
"messages": [
{
"type": "poa/MsgRemovePending",
"value": {
"sender": "manifest1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsfmy9qj",
"validator_address": "manifestvaloper1pss7nxeh3f9md2vuxku8q99femnwdjtcjhuxjm"
}
}
],
"title": "remove pending",
"summary": "some remove pending"
}
}
],
"memo": ""
}
```
The nested message is of the right type. However, the `signedTxBodyEncodedObject` created in the `signAmino` method and broadcasted to the server is
```json
{
"typeUrl": "/cosmos.tx.v1beta1.TxBody",
"value": {
"messages": [
{
"typeUrl": "/cosmos.group.v1.MsgSubmitProposal",
"value": {
"groupPolicyAddress": "manifest1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsfmy9qj",
"proposers": [
"manifest1pss7nxeh3f9md2vuxku8q99femnwdjtcwhpj7f"
],
"metadata": "",
"messages": [
{
"sender": "manifest1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsfmy9qj",
"validatorAddress": "manifestvaloper1pss7nxeh3f9md2vuxku8q99femnwdjtcjhuxjm"
}
],
"exec": 0,
"title": "remove pending",
"summary": "some remove pending"
}
}
],
"memo": ""
}
}
```
Notice that the nested `message` field has no type indicator. This field is created by the call to `fromAmino`
```typescript
const signedTxBody = {
messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
memo: signed.memo,
timeoutHeight: timeoutHeight,
};
```
The message decoded by the server is of type `poa/RemoveValidator` instead of `poa/RemovePending` causing the signature check to fail. I suspect the lack of type indication in the nested message causes the issue. One is unable to match the type only from the instance.
Everything works fine when using the `DIRECT` signer. Everything also works fine using the AMINO signer from the `manifestd` CLI.
## Running the test
```shell
yarn starship start
yarn starship:test starship/__tests__/poa.group.test.ts
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.