-
Notifications
You must be signed in to change notification settings - Fork 166
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
Strange Behavior when using sc.ContractParam
#850
Comments
Which version of neon-js are you experiencing this on? We use and identical pattern to the one you reference in the props sdk for all test invokes and I have not encountered the problem.
|
@melanke is this still an issue or can it be closed? |
@snowypowers I need some expert help here to solve this one. The following works succesfully const { sc, rpc } = require("@cityofzion/neon-js");
// const { rpc } = require("@cityofzion/neon-js");
// const { sc } = require("@cityofzion/neon-core");
async function f() {
const params = [
sc.ContractParam.hash160("NcLx6gjoLCYF6VkBhQ25SQxGFd5o3YHs5s"),
];
const res = await new rpc.RPCClient(
"http://seed1t5.neo.org:20332"
).invokeFunction(
"0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"balanceOf",
params
);
return res;
}
f()
.then((r) => console.log(r))
.catch((r) => console.log(r)); now comment the top line and uncomment line 2 + 3 such that In the working case the contract param inside the query looks as follows in the failing case at the same point it looks like this -edit- to fix screenshot |
-update- In the failing case inside neon-js/packages/neon-core/src/rpc/Query.ts Line 576 in ad3af74
it does not seem to think that the param is an instance of Again, working screenshot at Objects both seem to indicate to be a |
Looks like we have encountered one of the more annoying parts of JS which is how the code is packaged and imported. So if you import both What's the use case here that you will require to import these 2 together? |
I'll let @melanke answer that one. As a side note, it's not the first time I've heard people question the package structure. Not in the sense of "it's bad" but in the sense of "I don't understand why it's like that or needed like this". I'm personally not a |
@snowypowers after we could identify how to reproduce the error and how to workaround I was imagining the error was caused exactly by what you are describing, indeed, very annoying. I don't have an use case where I NEED to import they as you asked. It was a mistake, and since we have a workaround it is not a problem for me anymore. But I am afraid this might lead to problems and confusion for other developers, don't you agree? |
As I'd like todo a release this week I want to keep this conversation going.
Some ideas on this
Draft note:
@snowypowers is this import issue file based or project based? Please fix the above note with your insights :-) |
its project-based (but by that definition, file-based too since project is a superset). Ideally, a project just needs to install either 1 dependency and use it throughout. Maybe its easier to just recommend neon-js? For most of the developers, I would imagine neon-js fits 80% of the use cases. neon-core is made for certain niche development scenarios (e.g. extending it into a full node or a website that only wants readonly access to the network, etc). |
completed in v5.2.0 release |
Hello, I notice a problem with some methods of
sc.ContractParam
, they can't be directly used with `invokeFunction.How to Reproduce
Making a simple request like the following:
Result
Results in a request body like the following:
(This result was retrieved by monitoring the Chrome Dev Tools, Network tab)
The value is an empty object.
Workaround
I can workaround this problem by using
toJson
method:Result
Resulting in a working request body:
I had to use
toJson
with the following methods:Is this expected? Is it happening to you too?
The text was updated successfully, but these errors were encountered: