Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Invalid FunctionCall Arguments Type Declaration #1432

@bh2smith

Description

@bh2smith

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    NEW❗

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions