Skip to content

Instantly share code, notes, and snippets.

@toonsevrin
Last active May 21, 2018 09:57
Show Gist options
  • Select an option

  • Save toonsevrin/077b5ce2ef67c6abfc5b44508b403342 to your computer and use it in GitHub Desktop.

Select an option

Save toonsevrin/077b5ce2ef67c6abfc5b44508b403342 to your computer and use it in GitHub Desktop.
npm run build
> helloas@1.0.0 build /root/eos/contracts/helloas
> npm run build:untouched && npm run build:optimized
> helloas@1.0.0 build:untouched /root/eos/contracts/helloas
> asc assembly/module.ts -t build/untouched.wat -b build/untouched.wasm --validate --sourceMap --measure --noAssert
I/O Read : 0.354 ms
I/O Write : 18.782 ms
Parse : 745.488 ms
Compile : 562.162 ms
Emit : 598.019 ms
Validate : 122.809 ms
Optimize : N/A
> helloas@1.0.0 build:optimized /root/eos/contracts/helloas
> asc assembly/module.ts -t build/optimized.wat -b build/optimized.wasm --validate --sourceMap --measure --optimize --noAssert
I/O Read : 0.404 ms
I/O Write : 22.563 ms
Parse : 756.900 ms
Compile : 592.225 ms
Emit : 590.446 ms
Validate : 122.068 ms
Optimize : 2793.203 ms
root@dawn4:~/eos/contracts/helloas/build# cleos set contract testera ./ untouched.wasm hello.abi
Reading WAST/WASM from untouched.wasm...
Using already assembled WASM...
Publishing contract...
3315173ms thread-0 main.cpp:2493 main ] Failed with error: Assert Exception (10)
!"unresolvable": env.abort
import "allocator/tlsf";
import { HEADER_SIZE } from "internal/arraybuffer";
const QUESTION_MARK: u8 = 63;
export namespace env {
/**
* Eos environment function to print a utf-8 encoded string, identified by its pointer, to the console.
* AssemblyScript strings are encoded in utf-16le so we first convert these to latin.
*
*/
declare function prints(pointer: usize): void;
}
/**
* Entrypoint for the eos contract
*
*/
export function apply(account: u64, code: u64, action: u64): void {
env.prints(UTF16LEtoLatin1Ptr("Hello, World!"));
}
/**
* Converts an UTF16 string to latin1.
* All unicode characters up to code U+00FF (end of latin1 extension) are allowed, if the string contains a character out of this range, it is replaced with a question mark.
*
*/
export function UTF16LEtoLatin1Ptr(str: string): usize {
var output = new Array<u8>(str.length + 1);
for (let i : i32 = 0, len: i32 = str.length; i < len; i++) {
let code = str.codePointAt(i);
output[i] = code >= 0xFF ? QUESTION_MARK : <u8>code;
}
output[str.length] = 0;
return changetype<usize>(output.buffer_) + HEADER_SIZE;
}
{
"name": "helloas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "asc assembly/module.ts -t build/untouched.wat -b build/untouched.wasm --validate --sourceMap --measure --noAssert",
"build:optimized": "asc assembly/module.ts -t build/optimized.wat -b build/optimized.wasm --validate --sourceMap --measure --optimize --noAssert"
},
"author": "",
"license": "ISC",
"devDependencies": {
"assemblyscript": "github:AssemblyScript/assemblyscript"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment