AssemblyScript compiles a strict variant of TypeScript (basically JavaScript with types) to WebAssembly.
Questions tagged [assemblyscript]
101 questions
0
votes
2 answers
does AssemblyScript supports array of functions?
here is my js code that I would like to convert to AssemblyScript
function make_func_array(size){
function f1(w){
w.val+=1
}
function f2(w){
w.val+=10
}
var ans=[]
for (let i=0;i

yigal
- 3,923
- 8
- 37
- 59
0
votes
1 answer
AssemblyScript: Dynamic local array size
Trying to create an array with a size that is a variable imported from the JS doesn't seem to work.
For example:
AssemblyScript:
export declare arrSize: u32
const arr = new Uint32Array(arrSize)
export function init (): void {
…

Auh
- 145
- 11
0
votes
1 answer
AssemblyScript export name with space in its label
I need to export a label pointing to a function like
(func $can_sayhello (export "can sayhello") (type $t3)
The closest I can get is:
(export "can_sayhello" (func $assembly/index/can_sayhello))
using this AssemblyScript
@external("can…

user3006981
- 177
- 8
0
votes
0 answers
AssemblyScript array access causing Memory Out of Bounds
I am trying to access elements of an Array in AssemblyScript.
I initialize and fill my arrays as follows:
let totalSize: u32 = 512;
let leaderPtsX: u32[];
let leaderPtsY: u32[];
let leaderPtsType: u32[];
export function createPoints(): void…

psychnaut
- 64
- 1
- 3
0
votes
1 answer
Transfer byte array (Uint8Array) between WebAssembly and JavaScript
I have a u8[] array in WebAssembly code, how can I read it in regular JS? Calls to it just return me a i32.
// Load module WebAssembly.Instance
const instance = await getInstance("./build/embed.wasm");
// Try to get the array of bytes from the…

simbolo
- 7,279
- 6
- 56
- 96
0
votes
1 answer
Read embedded file as Uint8Array in WebAssembly instance
I'm embedding a binary file within a WebAssembly wasm file.
Consider this source:
embed.ts (gets built to embed.wasm using AssemblyScript):
export const text: u8[] = [83,65,77,80,76,69,10]; // The text "SAMPLE" in UTF-8 encoding
export const…

simbolo
- 7,279
- 6
- 56
- 96
0
votes
1 answer
Concatenate or merge TypedArrays in AssemblyScript
I have two Uint8Arrays of length 32 bytes each and I want to merge them to one Uint8Array of length 64.
So my question is:
Is there a way to merge two TypedArrays to a new TypedArray of the same type in AssemblyScript.
I guess I'm looking for the…

Stefanie Doll
- 63
- 1
- 6
0
votes
1 answer
In typescirpt,Is there a way to check the type of a value in wasm which has been loaded by typescirpt, example:i32?
In WebAssembly,we have i32 A 32-bit signed integer,if we load this wasm ,so we can check the type of i32?If cannot check i32 by javascirpt/typescirpt ,is there another way to check the value of wasm ?
So I try to build the wasm,the typeof return a…

Aya Choo
- 11
- 2
0
votes
1 answer
Access global variable from an anonymous function assemblyscript
I'm trying to process assemblyscript arrays using the functional syntax.
However, when I try to access variable outside the scope of the functions I get an error:
Example
ts.values.filter(t => t.someField == ts.someField)
I get an error Cannot find…

Amxx
- 3,020
- 2
- 24
- 45
-1
votes
1 answer
Simulation test of public method taking integers arguments fails with errorcode "WasmUnknownError"
The problem occurs when using the command "near-vm" to execute a simulation test of an assemblyscript smart contract method that takes inputs of type numbers like i32, u32, i64, u64. The following error is returned…

Jimmy Nsenga
- 156
- 2
- 7
-1
votes
1 answer
TypeError: Cannot read properties of undefined (reading 'format')
I am building a web app on NEAR Protocol using React and AssemblyScript (for smart contracts), which send NEAR to any Near wallet. I am constantly getting an error:-
Money.jsx:35 Uncaught (in promise) TypeError: Cannot read properties of undefined…

Moksh Singh Dangi
- 65
- 4