Commit Graph

346 Commits

Author SHA1 Message Date
James Wilson 9d5c1d5a24 WIP integrating new frame-decode and working out new storage APIS 2025-09-24 16:38:48 +01:00
zhoujiaweii 9080b0b2ae chore: remove redundant word in comment (#2090)
Signed-off-by: zhoujiaweii <zjwustc@outlook.com>
2025-09-17 10:01:39 +01:00
Bastian Köcher 07ed8bad33 backend::Rpc: Export RpcParams and rpc_params! (#2077)
* backend::Rpc: Export `RpcParams` and `rpc_params!`

These are required to for example call `request` on the client and thus, should also be re-exported.

* Move exports together

---------

Co-authored-by: James Wilson <james@jsdw.me>
2025-09-02 17:19:22 +01:00
James Wilson 42f1a62a05 Fix 1.89 clippy warnings (#2055)
* Fix 1.89 clippy warnings

* WASM lightclient clippy fixes too
2025-08-11 15:33:55 +01:00
Bastian Köcher 8e162036a1 Block: Implement clone (#2047) 2025-07-31 10:59:12 +01:00
Donn Pawelek 02eda40bba docs: fix typos in docs (#2045)
* docs: fix typos in docs

* up

* up
2025-07-29 16:01:22 +01:00
puzzle-rusher 17b98d0d9e Refactor: improve nonce and block injection in extrinsic params (#2032)
* Refactor: improve nonce and block injection in extrinsic params

* remove excess import

---------

Co-authored-by: James Wilson <james@jsdw.me>
2025-07-04 22:54:04 +01:00
Bastian Köcher 05c9eafe79 Improve docs for at_latest (#2035)
Tell the user that these functions operate with the last finalized block.

Co-authored-by: James Wilson <james@jsdw.me>
2025-07-04 22:06:41 +01:00
puzzle-rusher e892802baf Clippy fixes (#2033)
* clippy fixed

* wasm clippy

* clippy fixes

* post clippy fmt

* last clippy fix
2025-07-04 21:21:31 +01:00
Donn Pawelek 1f57e8fd1a docs: fix minor comment typos (#2027) 2025-06-30 10:20:07 +01:00
gcmutator 3078729271 chore: remove redundant backtick in comment (#2020)
Signed-off-by: gcmutator <329964069@qq.com>
2025-06-18 10:32:58 +01:00
James Wilson ed25a3ac26 Remove codec::Encode and codec::Decode derives from generated APIs by default (#2008)
* Remove codec::Encode and codec::Decode from generated APIs by default

* clippy fixes

* clippy

* More fixes, and CompactAs only if Encode/Decode

* revert println in example

* fix lightclient test

* fix docs

* Fix another rust doc comment

* Fix failing storage test

* Remove now-unnecessary test

* clippy

* clippy

* Remove pointless clone
2025-05-29 14:43:42 +01:00
James Wilson 7de8d36806 Prep to release v0.42.0 (#2003)
* Prep to release v0.42.0

* Remove test_context reference from example

* standalone_crate for doc tests because codegen is expensive

* fmt
2025-05-12 10:32:38 +01:00
James Wilson 23c62f3d5d Update to 2024 edition (#2001)
* Update to 2024 edition

* Update to 2024 edition; fmt, use<> and remove refs

* async functions
2025-05-09 16:12:18 +01:00
James Wilson 9ba89e3ed7 Support v16 metadata and use it by default if it's available (#1999)
* Support v16 metadata and use it by default if it's available

* lockfile

* fix blocks test; new transaction extension in kitchensink runtime

* Bump scale-typegen to 0.11.1 to cater for Duration prelude type

* fmt

* Fix no-std test building

* Cargo update and bump substrate deps

* Update test and no-std deps

* fmt

* fix test
2025-05-08 14:44:44 +01:00
James Wilson 4524590821 Metadata V16: Implement support for Pallet View Functions (#1981)
* Support Pallet View Functions in Subxt

* fmt

* clippy

* Move a little view function logic to subxt_core

* clippy

* Add back check that prob isnt needed

* avoid vec macro in core

* Add view funciton test and apply various fixes to get it working

* Add test for dynamic view fn call and fix issues

* clippy

* fix test-runtime

* fmt

* remove export

* avoid vec for nostd core

* use const instead of fn for view fn call name

* Update to support latest unstable metadata

* Update metadata stripping tests for new v16 version
2025-04-24 14:42:07 +01:00
James Wilson 21b3f52191 Metadata V16: Be more dynamic over which hasher is used. (#1974)
* Use DynamicHasher256 to support Blake2 or Keccack depending on chain

* remove Config::Hash associated type, replace with HashFor<Config> alias

* Fix doc links

* fix wasm tests

* Don't strip system pallet associated types. check System.Hashing, not Hash. Rename BlockHash trait to Hash

* Tweak comment

* fmt

* fix merge

* Fix typo
2025-04-23 10:12:48 +01:00
James Wilson b3317c5b77 Add DefaultParams to allow more transaction extensions to be used when calling _default() methods (#1979)
* Add DefaultParams to allow more transaction extensions to be used when calling _default() methods

* More imple for AnyOf/DefaultParams

* Prevent T param being used twice in macro

* clippy
2025-04-04 10:08:26 +01:00
James Wilson 06e658cd4b Allow submitting transactions ignoring follow events (#1962) 2025-03-14 16:08:38 +00:00
James Wilson 16c50846c1 Map finality timeout to Dropped instead of Invalid (#1953) 2025-03-11 15:49:52 +01:00
James Wilson b6b9ac65c7 Support constructing and submitting V5 transactions (#1931)
* TransactionExtensions basic support for V5 VerifySignature and renames

* WIP: subxt-core v5 transaction support

* Subxt to support V5 extrinsics

* WIP tests failing with wsm trap error

* Actually encode mortality to fix tx encode issue

* fmt

* rename to sign_with_account_and_signature

* Add explicit methods for v4 and v5 ext construction

* clippy

* fix wasm example and no mut self where not needed

* fix doc example

* another doc fix

* Add tests for tx encoding and fix v5 encode issue

* add copyright and todo

* refactor APIs to have clear v4/v5 split in core and slightly nicer split in subxt proper

* rename Partial/SubmittableExtrinsic to *Transaction

* Remove SignerT::address since it's not needed

* doc fixes

* fmt

* doc fixes

* Fix comment number

* Clarify panic behaviour of inject_signature

* fmt
2025-03-11 11:14:27 +00:00
James Wilson 49c66a0fd5 Wrap the subxt::events::Events type to avoid exposing subxt_core errors and types unnecessarily (#1948)
* Wrap the subxt::events::Events type to avoid exposing subxt_core errors and types unnecessarily (#1947)

* Actually import module and fix issues

* Remove a couple of unnecessary conversions now

* Test
2025-03-06 16:30:47 +00:00
James Wilson e59eef21b4 Allow transaction timeout in ChainheadBackend to be configured (#1943)
* Add configurable transaction timeout to ChainheadBackend

* u64, not usize

* Actually, stick with usize
2025-03-05 10:43:54 +00:00
James Wilson 037d5178b8 Document generating interface from Runtime WASM and change feature to runtime-wasm-path (#1936)
* runtime_metadata_path => runtime_wasm_path and document this feature

* fix doc
2025-03-03 12:07:48 +00:00
Alex Bean 72f8e0372e refactor: make ExtrinsicEvents::new public for external access (#1933) 2025-02-25 14:28:01 +00:00
wgyt 396762510a update copyright year (#1924)
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
2025-02-24 16:07:29 +00:00
Niklas Adolfsson 69ce6d726f deps: remove polkadot-sdk umbrella crate (#1926)
* deps: get rid of polkadot-sdk umbrella crate

* fix nits

* Update subxt/src/backend/mod.rs

* Update subxt/src/events/events_client.rs

* Update metadata/src/utils/validation.rs

* cargo clippy fix

* fix ui tests
2025-02-24 12:38:21 +01:00
James Wilson 816a86423b Split RPCs into a separate crate (#1910)
* WIP extract RPCs into separate crate

* fmt

* Fix test

* Remove unused deps

* fix import

* WIP: Fix up errors and most tests. Start extracintg some tests/code to rpc crate

* MockRpcClient sync or async

* MockRpcClient only async but better type inference

* WIP MockRpcClient FnMuts and some test updates to use it

* Get all but one test working with new MockRpcClient

* WIP trying to debug failure

* WIP, Tests mostly fixed, need to add back oen more

* Get mock RPC tests working

* fmt

* fmt

* Clippy and comment tweak

* update CI to explicitly check subxt-rpc features

* clippy

* small tweaks after pass over

* feature flag rename

* update some docs

* Fix some examples

* fmt

* Fix features flags to work with web/wasm32

* Fix unused dep warning

* explicit targets in wasm CI

* Add better crate level docs

* fmt

* Address review comments

* Comment out flaky test for now and make more obvious how similar POlkadot and Substrate configs are

* Not a doc comment

* Remove unused imports
2025-02-18 12:07:00 +00:00
James Wilson d924ece39a Don't double hash: use the same hash in ExtrinsicDetails and ExtrinsicDetails (#1917)
* Don't double hash: use the same hash in ExtrinsicDetails and ExtrinsicEvents

* clippy
2025-02-03 17:47:31 +00:00
Niklas Adolfsson 39507c7eb4 fix: don't wrap rpc error in DisconnectedWillReconnect in reconnecting rpc client (#1904)
* fix: don't wrap rpc err in DisconnectedWillRecon

* add clarifying comment

* fix no-std-test build

* fix no-std-test build v2
2025-01-24 14:18:12 +01:00
Niklas Adolfsson f363f77a60 chore: fix clippy lints (#1882) 2024-12-10 13:08:40 +01:00
Niklas Adolfsson f5e9ce0d2c remove substrate compat (#1850)
* remove substrate compat

* add hacky example

* simplify substrate-compat example

* simplify substrate-compat example

* cargo fmt

* fix build

* add more examples

* fix nit

* fix test build

* Update subxt/examples/substrate_compat_signer.rs

Co-authored-by: James Wilson <james@jsdw.me>

* keep only polkadot signer example

* remove more substrate compat related stuff

* fix example

* link to substrate signer example in book

* Update subxt/src/book/usage/transactions.rs

* Update subxt/src/book/usage/transactions.rs

* address grumbles

* fix nits

---------

Co-authored-by: James Wilson <james@jsdw.me>
2024-11-27 16:46:38 +01:00
James Wilson 057c847474 Fix unstable-light-client + ChainHeadBackend tx events (#1865)
* Fix unstable-light-client + ChainHeadBackend tx events

* Add note that Broadcasted event should no longer be returned at all

* fmt
2024-11-13 15:26:11 +01:00
James Wilson f861adf5f0 When native feature is enabled, we need polkadot-sdk/std for eg examples to work (#1864) 2024-11-13 10:59:01 +00:00
paritytech-subxt-pr-maker[bot] cb9571d7a6 Update Artifacts (auto-generated) (#1860)
* Update Artifacts (auto-generated)

* fix assethub example

* update Cargo.lock for wasm tests

* cargo fmt

* fix subxt cli tests

* disable failing wasm tests

* add issue link for disabled test

---------

Co-authored-by: niklasad1 <14157425+niklasad1@users.noreply.github.com>
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
2024-11-11 18:34:02 +01:00
PG Herveou 251a925da2 fix (#1843) 2024-10-26 02:26:43 +02:00
Niklas Adolfsson dc0795b3b9 move fetch metadata to a separate crate subxt_utils_fetchmetadata (#1829)
* macros: feature-gate jsonrpsee/fetch metadata url

* make CI happy

* Update codegen/src/error.rs

* extract `fetch-metdata` to separate crate

* add missing license headers

* introduce subxt-utils crate

* add missing files

* codegen: remove unused hex crate

* fix test build

* move subxt_utils -> subxt_utils_fetchmetadata

* cargo fmt

* runtime-path -> runtime-metadata-path

* Update utils/fetch-metadata/src/lib.rs
2024-10-24 14:45:39 +01:00
James Wilson 15cf58f723 Make it clearer which extrinsic failed to decode (#1835)
* Add an extrinsic index to decode errors so that we know which extrinsic failed

* Fix subxt::BlockError to align with subxt_core::BlockError

---------

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
2024-10-23 18:03:32 +02:00
Niklas Adolfsson 9b5523e4b0 chore(deps): bump scale family crates, primitive-types and impl-serde (#1832)
* chore(deps): bump scale-encode and scale-decode

* Update Cargo.toml

* Update Cargo.toml

* Update Cargo.toml

* update Cargo.lock

* bump scale-typegen

* use primitive_types::H256

* cargo fmt

* remove old darling hack
2024-10-22 19:23:38 +02:00
Niklas Adolfsson 418bd88e62 chore(deps): replace instant with web-time (#1830)
* chore(deps): replace `instant` with `web-time`

Close https://github.com/paritytech/subxt/issues/1597

* fix build

* fix build v2

* cargo fmt
2024-10-22 15:54:54 +02:00
Niklas Adolfsson 0e86993cd7 deps: use polkadot-sdk umbrella crate (#1786)
* deps: unify usage of polkadot-sdk crates

* cargo fmt

* fix macro crate

* make tests compile

* fix more nits

* fix doc tests

* fix more nits

* more nits

* core: remove polkadot-sdk/std

* cargo fmt

* remove polkadot-sdk/std by default

* Update metadata/Cargo.toml

* remove more std

* Update Cargo.toml
2024-10-11 14:19:11 +02:00
Niklas Adolfsson 5bf1756394 chainhead backend: notify subscribers when the backend is closed (#1817)
* FollowEvent::stop include backend closed or not

* simplify code: enum variant BackendClosed

* check both stopped and backend closed

* simplify hacky code

* remove old test

* Update subxt/src/backend/chain_head/follow_stream_driver.rs

* Update subxt/src/backend/chain_head/mod.rs

* Update subxt/src/backend/chain_head/mod.rs

* Update subxt/src/backend/chain_head/follow_stream_driver.rs
2024-10-11 11:14:50 +02:00
Niklas Adolfsson 8f3c0b44fb stabilize reconnecting-rpc-client (#1803)
* stabilize reconnecting-rpc-client

* fix build

* remove missed unstable stuff
2024-10-03 20:03:16 +02:00
Niklas Adolfsson 3807b29f36 rpc: stabilize chainhead backend (#1802)
* rpc: stabilize ChainHeadBackend

* remove noise from example

* add missing features

* make tests compile

* make tests compile v2

* revert stop event

* feature-gate runtime

* Update subxt/Cargo.toml

* add docsrs feature stuff

* Update subxt/src/backend/chain_head/mod.rs

* Update subxt/src/backend/chain_head/mod.rs

* Update subxt/src/backend/chain_head/mod.rs
2024-10-03 18:14:38 +02:00
Pavlo Khrystenko 7f9a1a17c0 derive serialize on more types (#1797)
* derive serialize on more types

---------

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
2024-10-03 11:15:09 +02:00
Niklas Adolfsson cbf05d1999 fix: error message on rpc errors (#1804) 2024-10-01 20:01:07 +02:00
James Wilson b5209a162e Use frame-decode for core extrinsic decode logic (#1785)
* WIP using frame-decode for core extrinsic decode logic

* fmt

* Fix dependabot config

* clippy

* tidy some imports

* Fix a couple of tests

* Update to frame-decode 0.0.7

* fix docs

* Decode exts earlier to avoid doing it every iter/find step

* frame-decode to 0.1.0

* fmt

* clippy

* fix wasm example

* doc test fixes

* Fix test

* Fix a couple of subxt_core tests
2024-10-01 11:21:51 +01:00
Niklas Adolfsson 72db833def reconn-rpc-client: parse URL before connecting (#1789)
* reconn-rpc-client: parse URL before connecting

It was hard to figure whether one simply entered a faulty URL
and it tried to reconnect according to the retry policy.

With this change we first parse url and then try to reconnect.
This will detect invalid directly instead of waiting for the retry
to complete.

* clippy fix

* wasm: &str -> Url
2024-09-30 16:40:20 +02:00
Pavlo Khrystenko 8f2c92f0ef add reconnecting tests for unstable_backend (#1765)
* add tests for unstable_backend

---------

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
2024-09-30 00:03:11 +02:00
Alexandru Vasile 2471aefe3b clippy: Remove unneeded ?Sized bound and replace never type with () (#1758)
* storage: Remove ?Sized bound

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* backend: Use () instead of !

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* backend: Return directly

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
2024-09-06 17:14:40 +02:00