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

[Bug] Wrong type for PromiseResult #379

Closed
4 tasks done
gagdiez opened this issue Jan 29, 2024 · 1 comment
Closed
4 tasks done

[Bug] Wrong type for PromiseResult #379

gagdiez opened this issue Jan 29, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@gagdiez
Copy link
Collaborator

gagdiez commented Jan 29, 2024

Prerequisites

  • I'm using the latest version of near-sdk-js.
  • I have tried to start with a fresh project and reproduce the defect with minimal code changes.
  • I have read the console error messages carefully (if applicable).

Description

While working on auditing the docs near/docs#1545 we found an error in the cross-contract calls written in typescript.

Currently there is an error in the type PromiseIndex. It is defined as (number | bigint) & PromiseIndexBrand. Since & is the intersection operator, and PromiseIndexBrand == -1, then the only valid value is -1.

This is a bug, since a PromiseIndex of 1, 2... etc should be valid

Reproducible demo

No response

Steps to reproduce

Create a ts contract, try to use near.promiseResult(0), you will get an error since 0 is not PromiseIndexBrand === -1

Expected behavior

near.promiseResult(0) should work.

Actual behavior

Gives a type error

Your environment

  • NEAR JavaScript SDK version used: 1.0.0

Self-service

  • I'd be willing to fix this bug myself.
@gagdiez gagdiez added the bug Something isn't working label Jan 29, 2024
@gagdiez gagdiez mentioned this issue Jan 29, 2024
4 tasks
@gagdiez
Copy link
Collaborator Author

gagdiez commented Feb 25, 2024

closed by #378

@gagdiez gagdiez closed this as completed Feb 25, 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

No branches or pull requests

1 participant