-
Notifications
You must be signed in to change notification settings - Fork 91
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
nodejs WebAssembly native work is well,but webassemblyjs throw these error #472
Comments
i want test a wasm moudle and pass a i64 param to a function |
Could you please send me the Wasm module, if you can?
This is not possible yet, there's ongoing work to support that in JS. But you can pass two i32 instead. |
http://votetracker.eosmedi.com/code.wast this wasm module is a smart contract running on eos platform https://github.com/eosio/eos my goal is execute this module in javascript,but the 'apply' function only accept the 3 i64 parameters , but i found a article write by you,use bigint as i64 type, also i found this project ,i saw you used long.js, so i think maybe i can pass 3 'long' type values as the function input |
Thanks, I'll investigate that during the holidays. The article I wrote is about the native support which is not yet deployed widely. I know that we have a hack to pass i64 as Long.js objects, i'll send an example here. |
With #473 merged I'm down to two errors:
|
thanks a lot, merry christmas! |
Thanks, you too and see in at D2 😃 |
Now with #474 the module validates. I'm hitting an unimplemented operation now ( For the i64 instructions case, we have Long.js that implements many operations already. Also, to pass an i64 from JavaScript you can use: const { readFileSync } = require("fs");
const WebAssemblyjs = require("./packages/webassemblyjs");
const Long = require("@xtuc/long").default;
const makeLogFn = msg => () => console.log(msg);
const _internalInstanceOptions = {
checkForI64InSignature: false
};
const imports = {
_internalInstanceOptions,
env: {
abort: makeLogFn("abort"),
action_data_size: makeLogFn("action_data_size"),
current_time: makeLogFn("current_time"),
db_get_i64: makeLogFn("db_get_i64"),
db_lowerbound_i64: makeLogFn("db_lowerbound_i64"),
eosio_assert: makeLogFn("eosio_assert"),
is_account: makeLogFn("is_account"),
memcpy: makeLogFn("memcpy"),
read_action_data: makeLogFn("read_action_data"),
require_auth: makeLogFn("require_auth"),
require_auth2: makeLogFn("require_auth2"),
send_inline: makeLogFn("send_inline")
}
};
const i64 = n => new Long.fromString(n);
WebAssemblyjs.instantiate(readFileSync("./code.wasm", null), imports)
.then(i => {
const { apply } = i.instance.exports;
apply(i64("1"), i64("2"), i64("3"));
})
.catch(err => {
throw err;
}); |
wow, it's really helpful for me. |
webassembly in blockchain project are very popular. |
RETURN_OPCODE(Compare, I64GtU); |
I have an ongoing patch for the i64 operations https://github.com/xtuc/webassemblyjs/pull/475/files. I encounter another error in the interpreter:
|
thanks for your job! |
The text was updated successfully, but these errors were encountered: