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

Invalid FunctionCall Arguments Type Declaration #1432

Open
1 of 4 tasks
bh2smith opened this issue Nov 20, 2024 · 0 comments
Open
1 of 4 tasks

Invalid FunctionCall Arguments Type Declaration #1432

bh2smith opened this issue Nov 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@bh2smith
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

This cast in the constructor is misleading and wrong:

function functionCall(
methodName: string,
args: Uint8Array | object,
gas = 0n,
deposit = 0n,
stringify = stringifyJsonOrBytes,
jsContract = false
): Action {
if (jsContract) {
return new Action({
functionCall: new FunctionCall({ methodName, args: args as Uint8Array, gas, deposit }),
});
}
return new Action({
functionCall: new FunctionCall({
methodName,
args: stringify(args),
gas,
deposit,
}),
});
}

The unit tests call this constructor with arguments defined via Buffer.from which is an "object"

The constructor takes object OR Unit8Array and casts to Uint8Array while the actual contents are never Uint8Array.

Reproducible demo

No response

Steps to reproduce

Try and construct an example in the tests that are actually Uint8Array to demonstrate to end users how its expected to look.

Expected behavior

Expect that the Type declaration for these arguments is actually something people use.

Actual behavior

This form is dumb.

Your environment

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

Self-service

  • I'd be willing to fix this bug myself.
@bh2smith bh2smith added the bug Something isn't working label Nov 20, 2024
@github-project-automation github-project-automation bot moved this to NEW❗ in DevTools Nov 20, 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
Status: NEW❗
Development

No branches or pull requests

1 participant