Skip to content
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

Amino code generator for MsgSoftwareUpgrade Plan is wrong #729

Open
fmorency opened this issue Feb 6, 2025 · 1 comment
Open

Amino code generator for MsgSoftwareUpgrade Plan is wrong #729

fmorency opened this issue Feb 6, 2025 · 1 comment

Comments

@fmorency
Copy link
Contributor

fmorency commented Feb 6, 2025

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.

@fmorency
Copy link
Contributor Author

fmorency commented Feb 6, 2025

cc @pyramation @Zetazzz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant