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

JS bindings for entropy client #897

Closed
wants to merge 29 commits into from
Closed

Conversation

ameba23
Copy link
Contributor

@ameba23 ameba23 commented Jun 18, 2024

This adds JS bindings to entropy-client.

The idea is to make it easier to migrate the SDK to a newer version of entropy-core - as this binds to client code which is all tested in CI in entropy-core. And also to avoid issues with inconsistencies between subxt and polkadot JS - by relying less on polkadot JS.

There is a very basic nodejs test CLI for trying this out

For some reason when using docker-compose i have to specify the chain endpoint as ws://127.0.0.1:9944 - it does not like localhost (gives a connection refused error).

Register is a bit complicated because to poll for registration we need to a way to 'sleep' - rusts std::thread::sleep doesn't work. The web-sys crate does gives us access to window.setTimeout() but i think i prefer to keep this out of our bindings.

So i split registration into 2 functions. One which submits the transaction and one which checks for a confirmation with a given account id and returns the verifying key if successful. Running the loop and adding a delay is done externally in JS.

I am occasionally seeing this issue: #542 - which does not effect things working, but means an annoying error message pops up.

Tested manually with nodejs 18.15.0.

I am not planning to add tests for this because of the issues we had with the JS tests for entropy-protocol. If it this gets used in the SDK it should be tested there, and if it does not get used in the SDK then we probably dont need these bindings.

@ameba23 ameba23 marked this pull request as draft June 18, 2024 09:48
@@ -103,3 +103,10 @@ pub enum ClientError {
#[error("Verifying key has incorrect length")]
BadVerifyingKeyLength,
}

#[cfg(feature = "full-client")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason when compiling for wasm it doesn't like me deriving this trait with thiserror for this particular error type.

@ameba23 ameba23 marked this pull request as ready for review June 20, 2024 20:52
* Minor grammatical and spelling updates.

* Fixed SDK NPM link.
Copy link

github-actions bot commented Jul 30, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ameba23
Copy link
Contributor Author

ameba23 commented Jul 30, 2024

I have read the CLA Document and I hereby sign the CLA

Entropy-Machine-CI added a commit to entropyxyz/.github that referenced this pull request Jul 30, 2024
@johnnymatthews
Copy link
Contributor

I have read the CLA Document and I hereby sign the CLA

Entropy-Machine-CI added a commit to entropyxyz/.github that referenced this pull request Jul 30, 2024
@frankiebee frankiebee requested a review from mixmix July 30, 2024 17:59
@ameba23
Copy link
Contributor Author

ameba23 commented Aug 7, 2024

Closing this as it seems no-one wants it. Can re-open if that changes.

@ameba23 ameba23 closed this Aug 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
@HCastano HCastano deleted the peg/bindings-entropy-client branch August 7, 2024 17:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants