Questions tagged [assemblyscript]

AssemblyScript compiles a strict variant of TypeScript (basically JavaScript with types) to WebAssembly.

101 questions
1
vote
0 answers

Integration of KonvaJS with webassembly

I am working on a project where I have a requirement to render millions of shapes. The file which has information on all coordinates can have a size of ~500MB. I am planning to use web assembly in this so that I can use system memory for my complex…
Vikram Jain
  • 376
  • 2
  • 12
1
vote
0 answers

Allocation too large< ~lib/rt/itcms.ts<$Index out of range,~lib/rt.ts when execute AssemblyScript code

I'm stuck on this when learing web assembly. basically I have this index.ts file written in assembly script // The entry file of your WebAssembly module. class Animal { constructor() {} name: i32; age: i32; } export function newAnimal(): i32…
Anh Thi
  • 51
  • 1
  • 5
1
vote
1 answer

Handling exception for invalid json format for `assemblyscript-json` in `JSON.parse`

The following works: let jsonObj: JSON.Obj = (JSON.parse('{"hello": "world", "value": 24}')); but if jsonString has an invalid json format, it breaks my subgraph. Using: "@graphprotocol/graph-cli": "0.35.0", "@graphprotocol/graph-ts":…
Sami
  • 45
  • 4
1
vote
0 answers

AssemblyScript Node.js RuntimeError: memory access out of bounds

I wrote a trivial AssemblyScript function: export function F(s: string): i32 { return s.length; } Loading and using the resulting F.wasm in the browser WORKS WELL while I got RuntimeError: memory access out of bounds using Node.js (on Windows,…
1
vote
0 answers

Passing Javascript references to AssemblyScript

Is it possible to pass a Javascript ref type to assemblyScript solely for the purposes of being retrieved again later? To be clear, I do not want to access the JS object from the WASM side in any way. So no typing should be necessary, I literally…
spike
  • 11
  • 3
1
vote
1 answer

Obtaining a random Integer in AssemblyScript

In the AsemblyScript book it mentions that Math.random() takes a seed and returns an value. I just need a random value. How do I achive that? I tried (Math.random() * 0xffffffffffffffff) as u64 (Math.random() *…
Redu
  • 25,060
  • 6
  • 56
  • 76
1
vote
1 answer

Calling list elements by index in assembly script map function causing compilation error

I'm using nodeJS along with assemblyscript to test out webassembly. I tried writing a simple python style zip function hoping it would work as intended. But for some reason every time I hit compile, it throws an error with basically no description…
1
vote
2 answers

Why number 10_000_000_000 in JS becomes 1410065408 in webassembly?

I made a very simple wasm with the following text format. The function just return the i32 parameter. (module (type $i32_=>_i32 (func (param i32) (result i32))) (memory $0 0) (export "sum" (func $assembly/index/sum)) (export "memory" (memory…
KKKKim
  • 11
  • 1
1
vote
1 answer

Type script array push doesn't do anything

I'd like to lead off with, this isn't the async issues that other people have posted about where their pushes aren't doing anything. Here is my code function createHolderPosition(holder: Holder, position: Position): void { if(holder.positions ==…
Steve
  • 4,457
  • 12
  • 48
  • 89
1
vote
1 answer

Is it possible to use string literal types in AssemblyScript?

Is it possible to create a string literal type in AssemblyScript that resembles the type keyword used in TypeScript? TypeScript example: export type MyType = 'foo' | 'bar';
John
  • 10,165
  • 5
  • 55
  • 71
1
vote
1 answer

Assemblyscript Class Inheritance - Type Casting

Is there a way to cast from a base class into a derived one? class A{} class B extends A{} const b = new B() const a:A = b //casts to base class ok const b2:B = a //Error: Type 'A' is not assignable to type 'B'
chantey
  • 4,252
  • 1
  • 35
  • 40
1
vote
0 answers

Near: AssemblyScript NEP141 is not showed in wallet

I was trying to build a NEP141 token with assemblyscript and to deploy it on the Near Network, but, after the deployment, I'm not able to see it on the wallet. I checked my work with the one in this video from the Near YouTube channel and our…
Doc_failure
  • 94
  • 1
  • 8
1
vote
0 answers

Assemblyscript operator overloading with syntax highlighting

I have written a simple Vector3 class in assemblyscript. The code compiles just fine but the typescript syntax highlighter naturally doesn't understand the operator overloads. Is there a way for typescript to resolve the type from assemblyscript…
chantey
  • 4,252
  • 1
  • 35
  • 40
1
vote
0 answers

Cannot use u128 to represent money/price in smart contract model

import { context, u128, storage, logging, PersistentUnorderedMap } from "near-sdk-as"; @nearBindgen export class MyItem{ id: u64; type: u32; price: u128; // This is causing the deserialization error } When including this fragment of code in…
sgraphics
  • 61
  • 4
1
vote
2 answers

Issues adding NEAR tokens in assemblyscript smart contract using u128.add() function

I have been facing issues with the use of u128.add(a, b) function. The two u128 values do not get added and I am afraid I am doing something wrong. I have checked LEARN-NEAR github page for sample projects and even changed my code to follow the…