-
Notifications
You must be signed in to change notification settings - Fork 3
Added a read example with smoldot #94
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
Open
x3c41a
wants to merge
14
commits into
main
Choose a base branch
from
smoldot_read
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0a2f7be
added read example with smalldot
x3c41a f59f66c
removed log callback
x3c41a a88087d
Merge branch 'main' into smoldot_read
x3c41a bbf24b1
Merge branch 'main' into smoldot_read
x3c41a 4eee061
added smoldot + read to live chain
x3c41a 630c196
Merge branch 'main' into smoldot_read
x3c41a d70d0ba
added newline
x3c41a 3fc5af2
Update examples/smoldot_read.js
bkontur 7feb404
fixed formatting
x3c41a 54898f6
Merge branch 'main' into smoldot_read
x3c41a cf2a357
Merge branch 'main' into smoldot_read
x3c41a 91ef137
Merge branch 'main' into smoldot_read
x3c41a 6f0d444
Merge branch 'main' into smoldot_read
x3c41a 21668d3
Merge branch 'main' into smoldot_read
x3c41a File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import * as smoldot from 'smoldot'; | ||
| import { cryptoWaitReady } from '@polkadot/util-crypto'; | ||
| import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
|
||
|
|
||
| async function main() { | ||
| await cryptoWaitReady(); | ||
|
|
||
| // Download the raw chain spec from an RPC node. | ||
| // Note: The dApps or the actual application should not connect to any external RPC node, | ||
| // but should instead use chain specs provided directly. | ||
| // 12346 is Bob's validator rpc port, because Alice does not have `bootNodes`. | ||
| const ws = new WsProvider('ws://localhost:12346'); | ||
| const api = await ApiPromise.create({ provider: ws }); | ||
| await api.isReady; | ||
| const chainSpec = await api.rpc.syncstate.genSyncSpec(true); | ||
|
|
||
| const client = smoldot.start(); | ||
|
|
||
| await client | ||
| .addChain({ chainSpec: chainSpec.toString() }) | ||
x3c41a marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .then((chain) => { | ||
| chain.sendJsonRpc(`{"jsonrpc":"2.0","id":12,"method":"chain_getFinalizedHead","params":[]}`); | ||
| return chain; | ||
| }) | ||
| .then(async (chain) => { | ||
| const response = await chain.nextJsonRpcResponse(); | ||
| console.log("✅ JSON-RPC response:", response); | ||
| return chain; | ||
| }) | ||
| .then(() => client.terminate()); | ||
| } | ||
|
|
||
| await main(); | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkontur I think it's a good practice to keep one
package.json. I addedpackage.jsonto one ofahm-dryrunsubfolders and @seadanda suggested to stick to onepackage.jsonbecause:package.jsonfiles may easily go out of sync and cause a "dependency drift",package.jsoncan lead to configs not being picked up correctly, working in one folder but not another.Let's maybe revert back to a single
package.json?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea a single top level file was preferable for ahm-dryrun because we wanted to keep packages in sync and used the same frameworks etc everywhere, but sometimes you don't actually want that, and multiple
package.jsons are fine (there are even some tools to manage that flow like npm workspaces/turborepo).There are legit usecases for each, but I think that the simplest is best unless you need multiple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we have just one
examples/package.json.Point of these examples is to use the same versions as simply as possible and run them as a part of CI. I don't see any reason to have multiple package.json and versions.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an old comment, it concerned the state of this PR (or related) when we had two
package.json, now we have only one so it's already obsolete, I believe.