-
Notifications
You must be signed in to change notification settings - Fork 244
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
Extend Contract class to enable view function calls without Account #1325
Extend Contract class to enable view function calls without Account #1325
Conversation
🦋 Changeset detectedLatest commit: 24a01dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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.
Looks very good, only one comment and I belive the biggest change I request is with the changeset, as there are quire a few breaking changes. Please adjust the changeset file accordingly(should be a major version increment most probably). If you're not sure about how semantic versioning works, you can check the rules out here
const result = await connection.provider.query<CodeResult>({ | ||
request_type: 'call_function', | ||
...blockQuery, | ||
account_id: jsContract ? connection.jsvmAccountId : contractId, |
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.
Everything connected to jsvmAccountId
is obsolete and will be removed very soon from near-api-js. Let's not add it to new functionality.
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.
The PR solves another issue and doesn't know anything about jsvmAccountId
, this particular change has taken away function from the Account
class and moved into another place
I wouldn't remove jsvmAccountId
right here as it's a breaking change that may cause issues if you don't mind (and I assume you're preparing another PR out there that does remove it)
These changes were made to be backward compatible, so releasing them to users shouldn't cause any issues (and it's not a breaking change from that perspective of view) |
Pre-flight checklist
pnpm changeset
to create achangeset
JSON document appropriate for this change.Motivation
Many developers complained about the confusing implementation of the Contract class, which requires an Account parameter in the constructor even for view function calls
This PullRequest solves the issue by extending the interface of the first parameter in the constructor and additionally enables full backward compatibility with older versions
Old implementation
New implementation
Test Plan
Related issues/PRs
#1066
#1064