Code Monkey home page Code Monkey logo

Comments (5)

hnord-vdx avatar hnord-vdx commented on June 25, 2024 1

The code you linked to is generated by emscripten. I guess for dart you have to do it manually. The only problem is I have no idea what the functions in the wasm module are as the names are obfuscated. Thanks for the pointers tho!

from wasm.

liamappelbe avatar liamappelbe commented on June 25, 2024

a::a(int32, int32, int32, int32) is a function import, so you need to bind a Dart function to it in the WasmInstanceBuilder (the thing that the builder() function returns).

When you run it in JS, where is emscripten getting that function from?

from wasm.

hnord-vdx avatar hnord-vdx commented on June 25, 2024

I am not very familiar with wasm and emscripten.. The project (trust wallet core) that im compiling to wasm exposes functions through a C interface and has a set of .proto files. Is there a way to automatically bind generated dart protobuf code with the wasm module? It seems the javascript project does that.

"use strict";
// Copyright © 2017-2022 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletCore = exports.TW = void 0;
var core_proto_1 = require("./generated/core_proto");
Object.defineProperty(exports, "TW", { enumerable: true, get: function () { return core_proto_1.TW; } });
var WalletCore = require("./lib/wallet-core"); //! .wasm file and js glue code
exports.WalletCore = WalletCore;

Edit: React JS example that uses the javascript project

from wasm.

liamappelbe avatar liamappelbe commented on June 25, 2024

I'm guessing it binds those function imports somewhere in this file. You need to provide those function imports, like this:

walletCoreWasm = mod.builder()
      ..addFunction('a', 'a', (int arg1, int arg2, int arg3, int arg4) {
        // Call your functions, eg the generated dart protobuf code.
      }))
    .build();

There's no way of automatically binding those functions.

from wasm.

iampawan avatar iampawan commented on June 25, 2024

@hnord-vdx Did you find a way to use Wallet core in Flutter web?

from wasm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.