hyperweb-io / hyperweb-io/telescope

Amino code generator for `MsgSoftwareUpgrade` `Plan` is wrong

Open
#729 2 comments 0 reactions 1 assignee Claimed by @NorOldBurden View on GitHub
Dominant language
TypeScript
Stars
154
Forks
53
PR merge metrics
No merged PRs in 30d

Description

The `time` field of `Plan` was deprecated. It is specified that

> If this field is not empty, an error will be thrown.

as described in [1].

The current `Plan` interface generated by Telescope **requires** the `time` field to be set. The `time` field is of type `Date`. One cannot use the `softwareUpgrade`, i.e.,

```typescript
const { softwareUpgrade } = cosmos.upgrade.v1beta1.MessageComposer.withTypeUrl;
```

without setting the `time` field.

As a workaround, one can use

```
const msgUpgrade = MsgSoftwareUpgrade.fromPartial({
plan: {
name: values.name,
height: BigInt(values.height),
info: JSON.stringify(infoObject),
},
authority: admin,
});
```

but the `toAmino()` code generated by Telescope does

```typescript
toAmino(message: Plan): PlanAmino {
const obj: any = {};
obj.name = message.name === "" ? undefined : message.name;
obj.time = message.time ? Timestamp.toAmino(toTimestamp(message.time)) : new Date();
obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined;
obj.info = message.info === "" ? undefined : message.info;
obj.upgraded_client_state = message.upgradedClientState ? Any.toAmino(message.upgradedClientState) : undefined;
return obj;
},
```

The line

```typescript
obj.time = message.time ? Timestamp.toAmino(toTimestamp(message.time)) : new Date();
```

sets the `time` field to the current `Date` if not set.

This is wrong. The `time` field, as specified in [1], should be empty.

[1]: https://github.com/cosmos/cosmos-sdk/blob/c64d1010800d60677cc25e2fca5b3d8c37b683cc/proto/cosmos/upgrade/v1beta1/upgrade.proto#L27-L31

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.