-
Notifications
You must be signed in to change notification settings - Fork 260
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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:
near-api-js/packages/transactions/src/action_creators.ts
Lines 98 to 120 in 480fe81
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
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
NEW❗