Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/equilibriumco/xrpl-hooks-ide/4mwCRoJYBMsRM9Ur2CJD84ujUud1 |
|
So, could it also include the Language Server ( https://github.com/typescript-language-server/typescript-language-server )? That still doesn't have quite the right syntax, but I think tsserver could be modified, at least not to show errors on common type names... |
|
Added import support to files |
Hmm, which version of |
|
Thanks @WietseWind. I also found/got this gist made by you https://gist.github.com/WietseWind/0a0d07e7df8e44efa9c8befa55d97b7d. Seems like that with both examples, at least the WAT output is similar when using same compile settings, which is nice! In our investigation we're using the latest AssemblyScript compiler. Have you been able to deploy any of the hooks built with AssemblyScript? We bumped into this error: |
Seems like Wietse's example is using this version Version 0.20.0 (24 days ago) introduced quite a bit of changes, for example they started to use ESM modules and while doing that they removed the old browser SDK, also a lots of other changes were done (check release notes for v0.20.0). That release (and issues posted around it) kind of triggered me to investigate the changes in the first place and find out how it might affect us if we want to proceed with the AssemblyScript support. So I guess this is the release where they changed the cli options as well. Weird that there isn't any big mention about it. |
|
BTW the hook binary from the example above does deploy on hooks v1 testnet - so the |
Aah, good point, I tested only against v2 |
|
I figured it out. Got it working on the latest version of AssemblyScript (v0.20.4). The problem occurs if there are Works: export function OK (text: string = 'OK'): void {
ACCEPT(text, text.length * 2, 0)
}Does not work: export const OK = (text: string = 'OK'): void => {
ACCEPT(text, text.length * 2, 0)
}Super simple working example: import {GUARD, LOG, OK} from './HooksLib'
export function cbak(reserved: i32 = 0): i64 {
return 0
}
export function hook(reserved: i32 = 0): i64 {
GUARD(1, 1)
for (let i = 0; GUARD(10, 10), i < 3; i++) {
LOG('-- :D --')
}
OK('-- :) --')
return 0
}
@external("env", "_g")
export declare function GUARD(id: i32, maxiter: i32): i64
@external("env", "accept")
export declare function ACCEPT(read_ptr: string, read_len: i32, err: i64): i64
@external("env", "trace")
export declare function TRACE(mread_ptr: string, mread_len: i32, dread_ptr: string, dread_len: i32, as_hex: i32): i64
////////////////////////
export function LOG (text: string): void {
TRACE(text, text.length * 2, text, text.length * 2, 0)
}
export function OK (text: string = 'OK'): void {
ACCEPT(text, text.length * 2, 0)
}Compile: asc -O3 --noAssert --runtime minimal \
--textFile ./module.wat \
--outFile ./module.wasm \
./src/module.ts |
|
Nice one @
So no more 'import {...} from 'our-hooks-lib' 🎉 -- I'm only focussing at V2 now, it's working on V1 but V2 shows a couple of issues. This sample above:
It's actually not working after that:
@RichardAH is looking into this :) |
|
Oh nice! 🥳 @WietseWind your update to your latest comment was the solution, we actually used only function statements while investigating this topic, so our problem wasn't that we used const exports. It was the return type on guard that was the issue all along. |
|
@valstu Great. Meanwhile @RichardAH found a bug in the Hooks source so: getting there :) |
|
@valstu @vbar Bug fixed, deployed to Testnet V2 and confirmed it's working. So: lib: Guard returns i32: 🎉 |
|
Oh wow! And we were only supposed to investigate the topic but it kind of works already 😅 Well there is of course the language server stuff which is completely separate topic but cool that we can actually create working hooks with AssemblyScript 🎉 |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Socket Security Report👍 No new dependency issues detected in pull request Socket.dev scan summary
Powered by socket.dev |
388427c to
775ae3d
Compare
|
This is now up to date against main branch |

This PR contains inital investigation around AssemblyScript support. So far this repo adds following findings:
asc.At the moment this supports compiling single files, haven't tested if this works when there are other files imported on a single fileShould support now also imports inside filesHopefully this helps testing and investigation around this topic. You can now add .ts files and write some example hooks in AssemblyScript and compile them. Deploy should work, at least it sends the SetHook request in correct way but haven't been able successfully deploy a hook yet. We're getting this error: