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

Misbehavior With Amino Types #12

Closed
Tracked by #278
DavideSegullo opened this issue Oct 1, 2022 · 7 comments
Closed
Tracked by #278

Misbehavior With Amino Types #12

DavideSegullo opened this issue Oct 1, 2022 · 7 comments

Comments

@DavideSegullo
Copy link

Hello, I'm using osmojs for sinfonia-ui, but I found two errors inside the AminoConverter:

  1. The amino converter related to /osmosis.lockup.MsgLockTokens should produce as a return for the "toAmino" function an object with the following structure:
{
  owner: string;
  duration: string;
  coins: Coin[];
}

Although, it returns an object with the following structure:

{
    owner: string;
    duration: {
        seconds: string;
        nanos: number;
    };
    coins: {
        denom: string;
        amount: string;
    }[];
}

As it's possible to see, here the duration field is returned as an object with seconds and nanos attributes, instead of a single string.

That's how I implemented it on sinfonia:
https://github.com/bitsongofficial/sinfonia-ui/blob/9aaa13947b971d220ae64600704645faf2133efb/src/signing/amino-types.ts#L89

  1. The amino type related to the message /osmosis.lockup.MsgBeginUnlocking seems to be wrong, it isn't osmosis/lockup/begin-unlocking as in line 24, since on osmosis it's defined such as osmosis/lockup/begin-unlock-period-lock as in line 14. You could get another reference directly from the osmosis frontend
@pyramation
Copy link
Collaborator

thanks! great info. I'm also curious, how are you creating the lockTokens message? In many ways I'm happy to see this issue because I'm trying to get more information about it myself.

related:

@DavideSegullo
Copy link
Author

Ye, ofc that's how I create lockTokens message on line 43

@pyramation
Copy link
Collaborator

ok so @DavideSegullo as an interface, you're essentially passing in durations as objects. This does make sense.

For context, we used strings because I had originally reverse engineered the code from osmosis-frontend which used strings.

I'll be updating this after HackWasm! Thanks for the details :)

@DavideSegullo
Copy link
Author

I add that also the message MsgCreateGauge presents the problem of duration

@pyramation
Copy link
Collaborator

Thanks! Will be able to sort this out soon, it's on my todo list!

@JoseRFelix
Copy link

Running into this same issue. I'm working around it by sending a plain number instead of a string:

const duration: 126000
{
      /**
       * Marking as 'any' because Duration type definition in telescope is wrong.
       * @see https://github.com/osmosis-labs/osmojs/issues/12
       * @see https://github.com/osmosis-labs/telescope/issues/211
       */
      duration: duration as any,
}

@pyramation
Copy link
Collaborator

please try the new release candidate @JoseRFelix @DavideSegullo

osmojs@15.1.0-rc.1

example here https://github.com/cosmology-tech/cosmology/blob/main/packages/cli/src/commands/lock.ts#L113-L116

  const msg = lockTokens({
    owner: account.address,
    coins,
    duration: Duration.fromPartial({
      seconds: Long.fromString(duration),
      nanos: 0
    })
  });

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

3 participants