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

[BUG] - Cannot call a @method that returns a value directly from a transaction. #429

Closed
MartinMinkov opened this issue Sep 20, 2022 · 0 comments · Fixed by #461
Closed
Assignees
Labels
bug Something isn't working

Comments

@MartinMinkov
Copy link
Contributor

Description

If we define a method that returns a value (like in the composability example), we cannot call such method directly from a transaction() call.

This is currently happening on SnarkyJS 0.6.0

Reproduce

Given the following method:

@method callAddAndEmit(_x: Field, _y: Field): Field {
   ...
   return Field.one;
}

An error will occur when we attempt to directly call it in a transaction block

tx = await Mina.transaction(feePayer, () => {
  zkapp.callAddAndEmit(Field(5), Field(6));
});

The following stack trace is reported:

/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:7565
         throw err;
         ^

Error: Type "undefined" cannot be converted to a field element
    at raise_error (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:419334:44)
    at value$6 (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:419400:43)
    at caml_call_gen (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:2081:17)
    at /home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:3643:18
    at new eval (eval at caml_js_eval_string (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:3630:44), <anonymous>:4:26)
    at to_field_obj (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:419416:35)
    at /home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:419708:44
    at caml_call_gen (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:2081:17)
    at Function.<anonymous> (/home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/_node_bindings/snarky_js_node.bc.cjs:3643:18)
    at Function.Class.<computed> [as toFields] (file:///home/martin/Code/o1/mina/src/lib/snarky_js_bindings/snarkyjs/dist/node/snarky/proxy.js:21:62)
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

Successfully merging a pull request may close this issue.

2 participants