Skip to content

Amino code generator for MsgSoftwareUpgrade Plan is wrong #729

@fmorency

Description

@fmorency

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.,

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

  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

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions