-
Notifications
You must be signed in to change notification settings - Fork 251
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
Update viewFunction with only accepting single object as argument #935
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one comment
packages/near-api-js/src/account.ts
Outdated
@@ -483,40 +483,17 @@ export class Account { | |||
* @param contractId NEAR account where the contract is deployed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This JSDoc is configured for separate arguments, now that viewFunction
expects a single object argument I believe we need something similar to the previous options
- https://jsdoc.app/tags-param.html
🦋 Changeset detectedLatest commit: c2f93a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple comments around the included Changeset.
Also, because this is a major bump, let's hold off on merging this. It might be better to publish the minor/patch changes first so that they aren't lumped in to the major change. That would give devs more granularity in terms of upgrading.
.changeset/great-jobs-destroy.md
Outdated
@@ -0,0 +1,6 @@ | |||
--- | |||
"@near-js/cookbook": minor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔪
.changeset/great-jobs-destroy.md
Outdated
"near-api-js": major | ||
--- | ||
|
||
Update `viewFunction` on account model to only accept single object as argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is a breaking change it would pay to add more detail here, including migration info. What do you think of the following:
account.viewFunction
now takes a single object argument rather than individual args. Callsites will now need to be updated like so:
-await account.viewFunction(
- 'wrap.near',
- 'storage_balance_of',
- { account_id: 'example.near' }
-);
+await account.viewFunction({
+ contractId: 'wrap.near',
+ methodName: 'storage_balance_of',
+ args: { account_id: 'example.near' },
+});
Motivation
This PR is removing old syntax that is expected to be deprecated. Since this PR contains BREAKING CHANGE, prior to merge, please follow up with team to confirm correct schedule.
Description
This PR will update
viewFunction
inaccount.ts
to only support single object as argument. (Deprecating on supporting old convention of accepting array of arguments)Also updates existing tests
Checklist