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

[Flutter-SDK-related] Can I call ALEO SDK from Flutter? [Possible Bug][Bug] #867

Open
folarinxe opened this issue Mar 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@folarinxe
Copy link

🐛 Bug Report

  • The goal is to call ALEO SDK from js.
  • 1st, Compile ALEO to wasm.
  • js call wasm
  • flutter call js.

When I call @aleoHq/sdk, I results in error

Steps to Reproduce

Code snippet to reproduce

const { initThreadPool: wasmInitThreadPool, Address, Execution, ExecutionResponse, Field, OfflineQuery, Private, PrivateKey, PrivateKeyCiphertext, Program, ProvingKey, RecordCiphertext, RecordPlaintext, ProgramManager, Signature, Transaction, ViewKey, VerifyingKey, verifyFunctionExecution, } = await Cargo({
                                                                                                                                                                                                                                                                                                       ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1175:20)
    at Module._compile (node:internal/modules/cjs/loader:1219:27)
    at Module.m._compile (/Users/weixuefeng/.nvm/versions/node/v20.3.0/lib/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
    at Object.require.extensions.<computed> [as .js] (/Users/weixuefeng/.nvm/versions/node/v20.3.0/lib/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1113:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1137:19)
    at require (node:internal/modules/helpers:121:18)

Stack trace & error message

// Paste the output here

Expected Behavior

(Write what you expected to happen here)

Your Environment

@folarinxe folarinxe added the bug Something isn't working label Mar 8, 2024
@weixuefeng
Copy link

do you have some progress about this issue? @folandarian

@Pauan
Copy link
Collaborator

Pauan commented Apr 29, 2024

Based on that error, it seems that Flutter doesn't support top level await, which is a standard JS feature.

I wasn't able to find an existing bug report on the Flutter repo, so I recommend making a new issue there, since it's a bug within Flutter, it's not a bug with Aleo.

As a possible workaround, you can pre-compile your code using Webpack (which does support top level await).

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

3 participants