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

Deprecation warning using view methods on the Contract object #1023

Open
fadeevab opened this issue Oct 31, 2022 · 3 comments
Open

Deprecation warning using view methods on the Contract object #1023

fadeevab opened this issue Oct 31, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@fadeevab
Copy link

Describe the bug

Deprecation warning using any view method:

Account.viewFunction(contractId, methodName, args, options) deprecated use `Account.viewFunction(ViewFunctionCallOptions)` instead <anonymous>:null:null

To Reproduce
package.json

"devDependencies": {
    "near-api-js": "1.1.0",
}

Code example:

const methods = {
  viewMethods: ['version'],
};

const account = new nearAPI.Account(near.connection, "alice.test.near");
const contract = new nearAPI.Contract(account, "contract.test.near", methods);

# Call the view method.
const version = await contract.version();

Expected behavior
No warning.

Actual behavior:
image

Additional context
I found this commit: 956e81f#diff-16fe34cedcd9d6d94a8c147bcbd8eb4ca48d46d5de7263373b83f2bbe437e773

And I think the problem is that the Contract constructor defines view methods in a deprecated way:

image

@fadeevab fadeevab added the bug Something isn't working label Oct 31, 2022
@fadeevab fadeevab changed the title Deprecation warning using _view_ methods on the Contract object Deprecation warning using view methods on the Contract object Oct 31, 2022
@fadeevab
Copy link
Author

fadeevab commented Nov 2, 2022

@andy-haynes @marcinbodnar @hcho112 FYI

@fadeevab
Copy link
Author

fadeevab commented Nov 18, 2022

@andy-haynes @marcinbodnar @hcho112 Seems like the near-api-js 1.1.0, published 1 month ago, doesn't actually contain the changes of 3 months old (https://github.com/near/near-api-js/blob/master/packages/near-api-js/src/contract.ts#L102): the changes in contract.ts are not reflected in the actual node_modules/near-api-js/lib/contract.js downloaded by npm install (at the same time, package.js shows 1.1.0 there).

@andy-haynes
Copy link
Collaborator

@fadeevab thank you for catching this, I missed that this was an outstanding feature to be released with v2. I will put together a plan for publishing this along with any other breaking changes we have in the works.

@github-project-automation github-project-automation bot moved this to Backlog 🥶 in DevRel Jun 10, 2024
@thisisjoshford thisisjoshford removed this from DevRel Oct 31, 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
None yet
Development

No branches or pull requests

2 participants