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

Near api call contract missing type enforcement #1192

Open
1 of 4 tasks
cold-briu opened this issue Oct 13, 2023 · 0 comments
Open
1 of 4 tasks

Near api call contract missing type enforcement #1192

cold-briu opened this issue Oct 13, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@cold-briu
Copy link

Prerequisites

  • I'm using the latest version of near-api-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

Take this snippet as an example
https://docs.near.org/tools/near-api-js/contract#call-contract

In this example, the attached amount should be a string, however, if I send a number instead (by using a parseInt) the explorer will tell that attached amount is zero.

I would expect that near-api-js tells me something like

method_name attachedDeposit type error expecting string

Reproducible demo

No response

Steps to reproduce

Run this snippet
https://docs.near.org/tools/near-api-js/contract#call-contract

await contract.method_name(
  {
    arg_name: "value", // argument name and value - pass empty object if no args required
  },
  "300000000000000", // attached GAS (optional)
  parseInt("1000000000000000000000000") // attached deposit in yoctoNEAR (optional)
);

Expected behavior

Error: method_name attachedDeposit type error expecting string

Actual behavior

Transaction runs a successfultx but the explorer shows attached amount as zero.

Your environment

  • NEAR JavaScript API version used: 1.0
  • Frontend framework (if applicable):
  • Relevant dependencies (if applicable):

Self-service

  • I'd be willing to fix this bug myself.
@cold-briu cold-briu added the bug Something isn't working label Oct 13, 2023
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
Status: Backlog 🥶
Development

No branches or pull requests

1 participant