feat(channels): wasm, coin balance and socket impl#1978
Merged
Conversation
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
…sh-only-streaming-channels
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
shamardy
reviewed
Oct 9, 2023
Collaborator
shamardy
left a comment
There was a problem hiding this comment.
Thank you for the fixes! Next review iteration!
Collaborator
Opened an issue for the above #1986 |
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Collaborator
|
@KomodoPlatform/qa how to test wasm event streaming and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


New Event: COIN_BALANCE:
It's now implemented for Tendermint Protocol(will cause panics with
todofor any other coins).The way it works:
1- Subscribe to the account address using websocket
2- On any message(this means our address either sent tx or recieved tx), get the current balance
3- If the balance is changed(different than the previously broadcasted event) then broadcast it to mm2 clients.
Sample configuration:
Native:
Same as #1945, for triggering COIN_BALANCE event, enable any tendermint based coin and send/recieve some funds on that address.
WASM:
Event streaming on WASM can be tested easily with https://github.com/KomodoPlatform/react-komodefi-wasm.
Build:
Build mm2 with
wasm-pack build --release mm2src/mm2_bin_lib --target web --out-dir ../../target/target-wasm-releasesoft-linking(or file/dir replacement directly):
atomicDEX-API/target/target-wasm-release/mm2lib.js to react-komodefi-wasm/src/js/mm2.js
atomicDEX-API/target/target-wasm-release/snippets to react-komodefi-wasm/src/js/snippets
atomicDEX-API/target/target-wasm-release/mm2lib_bg.wasm to react-komodefi-wasm/public/mm2_bg.wasm
Add ATOM-TEST coin:
Append the following json value to the coins file:
{ "coin": "ATOM-TEST", "avg_blocktime": 5, "protocol": { "type": "TENDERMINT", "protocol_data": { "decimals": 6, "denom": "uatom", "account_prefix": "cosmos", "chain_id": "theta-testnet-001" } }, "derivation_path": "m/44'/118'" }Worker file:
Create
react-komodefi-wasm/worker.jsfile with the following content:Test the network and balance events:
Network events should start being logged on console right away when mm2 is started, for the balance events, you have to enable tendermint based coins, an example ATOM-TEST which we added to coins file. For that, execute the following RPC:
{ "userpass": "testpsw", "method":"enable_tendermint_with_assets", "mmrpc":"2.0", "params": { "ticker": "ATOM-TEST", "tokens_params": [], "rpc_urls": [ "https://rpc.sentry-02.theta-testnet.polypore.xyz" ], "tx_history": false }, "id": 0 }After the activation, when your address gets/sends TX, you should be able to see COIN_BALANCE event on the console logs.
KomodoPlatform/tokio-tungstenite-wasm
There is no socket library that supports Native + WASM platforms with async/await & Send+Sync(without those supports, handling events(specially COIN_BALANCE) will cause i/o blocking and resource-intensive situations on the runtime). I had to fork a few of the existing ones and do some changes. This fork should be super easy to maintain for us, as it's just a wrapper around tokio-tungstenite and web-sys. Most of the effort on this fork will be bumping the dependencies when needed.