Skip to content
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

reporting error in AssemblyScript build #89

Closed
jlwaugh opened this issue Mar 2, 2021 · 0 comments · Fixed by #91
Closed

reporting error in AssemblyScript build #89

jlwaugh opened this issue Mar 2, 2021 · 0 comments · Fixed by #91

Comments

@jlwaugh
Copy link

jlwaugh commented Mar 2, 2021

via km1tz on Discord:

"Error is thrown in build time inside near-sdk-core package."

Error Message

ERROR TS2304: Cannot find name 'encode'.
       this.setBytes(key, encode<T>(value));
 in ~lib/near-sdk-core/storage.ts(158,26)

ERROR TS2304: Cannot find name 'decode'.
     return decode<T>(bytes);
 in ~lib/near-sdk-core/util.ts(46,12)

"While inspecting further, I can see that encode and decode functions are defined inside near-sdk-core\assembly\as_types.d.ts and cannot figure out where is the problem. I've tried updating near-sdk-core and typescript compiler to latest version to latest version but it did not make any difference."

Replicated Locally

yarn build:as
yarn run v1.22.5
$ ./contracts/assemblyscript/build.js

compiling contract [ nep21-basic/main.ts ] to [ out/nep21-basic-as.wasm ]
 asconfig.js is deprecated use `asb`to build files.  NOTE: output now in ./build/release/ 
asc /Users/jlwaugh/Desktop/FT/contracts/assemblyscript/nep21-basic/main.ts -O3z --debug --measure --runPasses inlining-optimizing,dce --optimizeLevel 3 --shrinkLevel 3 --target release --binaryFile build/release/main.wasm
ERROR TS2304: Cannot find name 'encode'.

       this.setBytes(key, encode<T>(value));
                          ~~~~~~
 in ~lib/near-sdk-core/storage.ts(158,26)

ERROR TS2304: Cannot find name 'decode'.

     return decode<T>(bytes);
            ~~~~~~
 in ~lib/near-sdk-core/util.ts(46,12)

/Users/jlwaugh/Desktop/FT/node_modules/near-sdk-bindgen/compiler.js:19
        throw new Error(err);
        ^

Error: Error: 2 compile error(s)
    at cb (/Users/jlwaugh/Desktop/FT/node_modules/near-sdk-bindgen/compiler.js:19:15)
    at Object.main (/Users/jlwaugh/Desktop/FT/node_modules/assemblyscript/cli/asc.js:717:12)
    at compileProject (/Users/jlwaugh/Desktop/FT/node_modules/asbuild/dist/cli.js:191:9)
    at main (/Users/jlwaugh/Desktop/FT/node_modules/asbuild/dist/cli.js:92:9)
    at module.exports.compile (/Users/jlwaugh/Desktop/FT/node_modules/near-sdk-bindgen/compiler.js:42:3)
    at compileContract (/Users/jlwaugh/Desktop/FT/contracts/assemblyscript/build.js:23:3)
    at Array.map (<anonymous>)
    at Object.<anonymous> (/Users/jlwaugh/Desktop/FT/contracts/assemblyscript/build.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant