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

cosmic-proto toProtoMsg relying on Decimal fail #10072

Closed
Tracked by #10016
turadg opened this issue Sep 11, 2024 · 0 comments · Fixed by #10080
Closed
Tracked by #10016

cosmic-proto toProtoMsg relying on Decimal fail #10072

turadg opened this issue Sep 11, 2024 · 0 comments · Fixed by #10080
Assignees
Labels
bug Something isn't working

Comments

@turadg
Copy link
Member

turadg commented Sep 11, 2024

Describe the bug

We have a patch for @cosmjs/math to eschew bn.js, which is huge and doesn't play well with SES.

It has multiple problems.

To Reproduce

Use ibc-mocks.ts to make a call like,

buildQueryResponseString(
        QueryDelegatorDelegationsResponse,
        {
          delegationResponses: [
            {
              delegation: {
                delegatorAddress: 'cosmos1test',
                validatorAddress: mockValidator.value,
                shares: '1000000',
              },
              balance: { denom: 'uatom', amount: '1000000' },
            },
          ],
        },
      )

shares is parsed as a Decimal but that's currently broken. It errors with 'Fewer than two elements in split result. This must not happen here.'. That's because the patch does .search(/./') when it should be.search(/\./') (lost in the .patch creation).

After fixing that is a deeper error at this line in staking.ts,

.string(Decimal.fromUserInput(message.sharesDst, 18).atomics)

Our version of the Decimal object doesn't have atomics so that fails. In the real one atomics is a BN.js object, which we're trying to avoid.

Expected behavior

Constructing a QueryDelegatorDelegationsResponse works.

Platform Environment

@endo/init@1.1.4
ses@1.8.0

Additional context

We've run into hurdles before,

Ideally we could use cosmjs without bn.js,

@turadg turadg added the bug Something isn't working label Sep 11, 2024
@turadg turadg self-assigned this Sep 11, 2024
@mergify mergify bot closed this as completed in #10080 Sep 16, 2024
@mergify mergify bot closed this as completed in 67a57a4 Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant