warp-contracts / warp-wasm-templates

Templates for WASM smart contracts (AS, Rust, Go) compatible with SmartWeave Protocol
41 stars 6 forks source link

Migrate to AssemblyScript 0.20.0 #8

Open ppedziwiatr opened 2 years ago

ppedziwiatr commented 2 years ago

https://github.com/AssemblyScript/assemblyscript/releases/tag/v0.20.0 Some significant changes (e.g. new --bindings flag, that replaces the features of the assemblyscript/loader) have been introduced. This will probably require changes in the SDK.

ppedziwiatr commented 2 years ago

Few notes: flag --exportRuntime should be removed flag --bindings esm should be added. This should result (from my understanding) in creating an additional js file with the "glue code" (sth similar to how wasm-bindgen works for Rust).

Trying to compile our template with the latest compiler currently ends with:

FAILURE Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/node_modules/assemblyscript/package.json
    at __node_internal_captureLargerStackTrace (node:internal/errors:464:5)
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:645:7)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.<anonymous> (/Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/node_modules/@serial-as/transform/node_modules/visitor-as/as/index.js:18:32)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/node_modules/@serial-as/transform/node_modules/visitor-as/src/base.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/node_modules/@serial-as/transform/node_modules/visitor-as/src/index.ts:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/node_modules/@serial-as/transform/src/index.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/ContractTransform.js:1:29)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at Module.Ue (/Users/ppe/Projects/redstone-smartcontracts-wasm-templates/assemblyscript/node_modules/assemblyscript/cli/index.js:408:23)
✨  Done in 1.35s.