-
Notifications
You must be signed in to change notification settings - Fork 329
typescript sdk #2853
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
UnArbosSix
wants to merge
77
commits into
main
Choose a base branch
from
bittensor-core-typescript-sdk
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
typescript sdk #2853
Changes from 3 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
1815ec2
typescript sdk
UnArbosSix dc041b1
fix mnemonics
UnArbosSix d5bf752
fix formatting
UnArbosSix ebe31a7
ts e2es use ts sdk
UnArbosSix 69a636a
Update basic.test.cjs
UnArbosSix 9943d40
Merge branch 'bittensor-core-exploration' into bittensor-core-typescr…
UnArbosSix 90e4198
fix review
UnArbosSix 89cd213
clippy
UnArbosSix d1ef788
fix warnings
UnArbosSix fa59bcb
Merge branch 'bittensor-core-exploration' into bittensor-core-typescr…
UnArbosSix 8890ace
fix sdk build
UnArbosSix 4b6e0ed
fix build post-merge
UnArbosSix a630667
Move key derivation into Rust & finish names
UnArbosSix 8b9f190
fix keys
UnArbosSix 4b40b22
add browser support
UnArbosSix 586a460
add features from old bittensor
UnArbosSix 3a38161
fix ts sdk job
UnArbosSix d80e20e
fix keys
UnArbosSix 8d34eff
try fix typescript sdk again
UnArbosSix 86af620
fix browser gap
UnArbosSix 1979344
Update typescript-e2e.yml
UnArbosSix f0183d8
fix parity check
UnArbosSix 17fe74e
fix
UnArbosSix 3ce5325
fix ledger
UnArbosSix 437b717
fix ts e2e
UnArbosSix 800a45e
fix runtime metadata
UnArbosSix d7153bc
fix
UnArbosSix 423b73b
try fix e2e ts again
UnArbosSix cca254e
fix nonce
UnArbosSix d5fbc3b
fix e2e
UnArbosSix 0351315
Keep sp-core/std out of the portable WASM
UnArbosSix a8fa5a7
fix leak
UnArbosSix e32ad17
fmt
UnArbosSix 3a174b0
fix js version
UnArbosSix 112a89d
Restore parity validation for the browser wrapper
UnArbosSix 6291648
rename to bittensor-ts
UnArbosSix 766dbe0
fix for review
UnArbosSix 8cd9033
fix ci
UnArbosSix cb54cb3
another round of improvments
UnArbosSix 1b0a474
Update generate-esm.cjs
UnArbosSix d1c9ae8
another round of fixes
UnArbosSix f7166e7
use get_subnet_hyperparams_v3
UnArbosSix 7fb7777
finish impl
UnArbosSix c8bf57c
more fixes
UnArbosSix 8aede23
fixes
UnArbosSix 3f288d6
Merge branch 'bittensor-core-exploration' into bittensor-core-typescr…
UnArbosSix 4eeb1b6
Fix CI
UnArbosSix 0e9679b
fix rpc stuff
UnArbosSix 3557d6b
fix typecheck
UnArbosSix 1ae69cc
cleanup
UnArbosSix 5a285e1
fix CI again
UnArbosSix d713c32
address auditor review
UnArbosSix dc718f7
fix inaccurate job names
UnArbosSix 6bfcd61
another round of fixes
UnArbosSix b430828
fix e2e
UnArbosSix 7ab5ca4
another review round
UnArbosSix 4625c5c
another review round
UnArbosSix 1c55023
clippy
UnArbosSix 3d50eb0
Merge branch 'main' into bittensor-core-typescript-sdk
UnArbosSix 47dceba
use new rust from merge
UnArbosSix 1f4e856
fixes
UnArbosSix 7b21070
fmt
UnArbosSix e05308f
fixes
UnArbosSix cb479d5
fis TS checks
UnArbosSix 252c684
try fix ci
UnArbosSix 10c3b09
fix CI
UnArbosSix ce5f46c
cover all old ts e2e in new
UnArbosSix 46ac117
more fixes
UnArbosSix d4a5748
Merge main
UnArbosSix 05b51b2
Use bittensor SDK helpers in ts-tests
UnArbosSix ae80118
Update test-bittensor-ts.ts
UnArbosSix 715d6db
fixes
UnArbosSix fb8e11c
fix browser smoke
UnArbosSix 4d9633e
use hyperparams v3
UnArbosSix ca6453e
fix CI
UnArbosSix d3afb99
Fix TS SDK test and clippy allow
UnArbosSix 547179f
clippy
UnArbosSix 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,7 @@ | ||
| node_modules/ | ||
| dist/ | ||
| native.cjs | ||
| native.generated.d.ts | ||
| *.node | ||
| *.node.map | ||
| npm-debug.log* |
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,71 @@ | ||
| # `@bittensor/sdk` | ||
|
|
||
| The monorepo's TypeScript SDK. It lives in its own `sdk/typescript-sdk` | ||
| package and is a deliberately thin Node-API wrapper around the sibling | ||
| `bittensor-core` Rust crate. | ||
|
|
||
| All chain-defined work runs in Rust: | ||
|
|
||
| - sr25519/ed25519 keys, signatures, SS58, and wallet keyfiles; | ||
| - SCALE encoding and decoding, runtime metadata, storage keys, calls, and | ||
| signed extrinsics; | ||
| - RFC-0078 metadata digests and Ledger proofs; | ||
| - drand timelock encryption and epoch-schedule simulation; | ||
| - ML-KEM/XChaCha20 MEV-shield envelopes; and | ||
| - Ledger HID signing. | ||
|
|
||
| The TypeScript layer is limited to JavaScript-friendly names and defaults, | ||
| lossless `Buffer`/`bigint`/`Map` boundary conversion, error classes, and | ||
| compatibility adapters for the signer objects expected by Polkadot.js, | ||
| Polkadot API, and Moonwall. | ||
|
|
||
| The package exposes both CommonJS and ESM entrypoints. It also exports the | ||
| raw generated Node-API module as `@bittensor/sdk/native`, so every native | ||
| entry point is callable even when an ergonomic wrapper has not yet been | ||
| added. | ||
|
|
||
| ## Build locally | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```sh | ||
| cargo test -p bittensor-typescript-sdk-native --all-features | ||
| npm --prefix sdk/typescript-sdk ci | ||
| npm --prefix sdk/typescript-sdk run check | ||
| ``` | ||
|
|
||
| The native crate is isolated under `sdk/typescript-sdk/native`; it links | ||
| `sdk/bittensor-core` directly and contains binding glue only. No chain | ||
| algorithm is reimplemented in TypeScript. | ||
|
|
||
| Node.js 20.17 or newer is required. | ||
|
|
||
| ## Example | ||
|
|
||
| ```ts | ||
| import { | ||
| Keypair, | ||
| Runtime, | ||
| createKeyringPairFromUri, | ||
| sealMevShieldTransaction, | ||
| } from '@bittensor/sdk' | ||
|
|
||
| const alice = Keypair.fromUri('//Alice') | ||
| const signature = alice.sign(Buffer.from('hello')) | ||
| console.log(alice.verify(Buffer.from('hello'), signature)) | ||
|
|
||
| // Compatible with tx.signAsync(...) and Moonwall helpers, while the secret | ||
| // key and signing operation remain in Rust. | ||
| const signer = createKeyringPairFromUri('//Alice') | ||
|
|
||
| const runtime = new Runtime(metadataBytes, specVersion, transactionVersion) | ||
| const call = runtime.composeCall('System', 'remark', { | ||
| remark: Buffer.from('hello'), | ||
| }) | ||
|
|
||
| const ciphertext = sealMevShieldTransaction(mlKemPublicKey, call) | ||
| ``` | ||
|
|
||
| Large SCALE integers are returned as `bigint`; byte carriers are returned as | ||
| `Buffer`. A decoded SCALE dictionary with non-string keys is returned as a | ||
| `Map`, so no key information is lost. |
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,29 @@ | ||
| [package] | ||
| name = "bittensor-typescript-sdk-native" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| publish = false | ||
| description = "Native Node-API bridge used by the Bittensor TypeScript SDK" | ||
| license = "Apache-2.0" | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib"] | ||
|
|
||
| [features] | ||
| default = ["ledger"] | ||
| ledger = ["bittensor-core/ledger"] | ||
|
|
||
| [dependencies] | ||
| bittensor-core = { path = "../../bittensor-core" } | ||
| codec = { workspace = true } | ||
| hex = "0.4.3" | ||
| napi = { version = "3.10.3", default-features = false, features = ["napi8", "serde-json", "dyn-symbols"] } | ||
| napi-derive = "3.5.9" | ||
| scale-info = { workspace = true, features = ["std", "serde"] } | ||
| serde_json = { version = "1.0.132", features = ["arbitrary_precision"] } | ||
|
|
||
| [build-dependencies] | ||
| napi-build = "2.3.2" | ||
|
|
||
| [lints] | ||
| workspace = true |
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,3 @@ | ||
| fn main() { | ||
| napi_build::setup(); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.