Commit Graph

40 Commits

Author SHA1 Message Date
bwty 216b5614dd Raw payload return SignedPayload struct (#92)
* create SignedPayload struct

* align with generic extra updates

Co-authored-by: bwty <whalelephant@users.noreply.github.com>
2020-04-20 07:25:37 +01:00
Andrew Jones dc2a73dc4a Wrap and export BlockNumber (#87)
* Add fetch example and wrap BlockNumber impl

* Fmt
2020-04-15 08:45:58 +01:00
David Craven 8cf652605f Custom extra (#89)
* Run rustfmt.

* Make extra customizable.

* Update to alpha 6.
2020-04-15 08:21:19 +01:00
bwty bb465782dc raw_payload w/test (#83)
Co-authored-by: bwty <whalelephant@users.noreply.github.com>
2020-04-03 09:47:00 +01:00
Black3HDF f4ef19edc9 Remove unused things (#76)
* remove unused imports

* remove unused type alias

* remove unused imports
2020-03-19 16:07:08 +00:00
Andrew Jones 8ea264d7b0 Upgrade to substrate alpha.3 crates.io dependencies (#73)
* Use substrate dependencies from crates.io

* Remove test that depends on node_runtime.

Because node_runtime is not on crates.io and was downloading duplicate substrate dependencies. The integration tests will test whether the serialization of keys and calls works.

* Fix updated jsonrpsee compilation errors

* Add missing frame-metadata dependency
2020-03-06 11:58:23 +00:00
Andrew Jones dcc6b91d10 Use new AccountInfo struct for "System Account" storage data (#71)
* Add AccountInfo struct for "System Account" data

* Fmt

* Simplify AccountInfo struct constraints
2020-02-25 17:18:10 +00:00
Andrew Jones b7565ff435 Latest substrate updates (#70)
* Fix compilation errors with latest substrate

* System::Account replaces FreeBalance and Nonce

* System::Account replaces FreeBalance and Nonce

* Remove Balances FreeBalance, replaced with System Account

* Update system event, fix instantiate

* reorder deps
2020-02-20 13:09:11 +00:00
Andrew Jones 399ac68cb1 Allow irrefutable let pattern for subscriptions, remove legacy lint 2020-01-31 11:52:30 +00:00
Yuanchao Sun 3618b03dee Add methods to get header and storage change set (#65) 2020-01-21 09:43:10 +00:00
Andrew Jones 253a7d8b0b Convert to std futures (#58)
* WIP

* Begin converting rpc layer to use std futures and jsonrpsee

* Convert metadata to async/await

* Convert block_hash to async/await

* Convert more methods to async/await

* Remove sp_rpc

* Fix more compilation errors

* Remove connect

* Starting to convert subscription functions

* Use jsonrpsee branch from PR for public client types

* Implement subscribe events with jsonrpsee subscription

* Converting subscriptions and wait_for_block_events

* WIP converting lib methods to async

* Use shared client reference directly for rpc call

`rpc_api!` macro currently only supports RawClient (which cannot be shared).
Also supports named params only which is not currently compatible with substrate rpd which accepts only positional params.

* Use &self instead of &mut self for shared Client

* Convert submit_and_watch to async/await

* Convert more Client fns to async

* Pin some trait futures

* Add serde error

* Fix client creation

* Fix client request compiler errors

* Unify metadata errors

* Add WS handshake error variant

* Fix some more compiler errors

* Fix more compiler errors

* Convert submit_extrinsic to async

* Convert submit and submit_and_watch

* Add Send + Sync constraints

* Clone clients

* Fix EventArg conversion error

* Fix remaining warnings/errors

* Replace deny warnings with specific lints

* Infallable subscription loops

* Use jsonrpsee wss branch

* Fix example

* Start to fix up tests

* Make contracts tests compile

* Make some more tests pass

* Fix up remaining tests

* Fmt

* Use correct event storage key type

* Fix finding events

* Use master jsonrpsee
2020-01-20 12:00:08 +00:00
Maciej Hirsz 691244fef2 feat: generic Extrinsic on System; Client::storage taking Option<T::Hash>; (#63) 2020-01-14 15:09:01 +00:00
Andrew Jones f998444619 Remove unwrap and format code (#62)
* Remove unwrap from metadata fetch

* Format code
2020-01-09 17:26:50 +00:00
Andrew Jones b159d0dae1 Improve dynamic events type sizes API (#61)
* Do not error if type sizes missing: log warn

* Split out EventsSubscriber, allow updating events decoder

* Format code

* Check missing type sizes after registration

* Add example which for submit and watching events
2020-01-07 15:14:30 +00:00
Maciej Hirsz 923013628b Add a method to fetch current finalized head hash (#57)
* chore: Update to latest substrate master renames

* feat: Introduce Client::finalized_head
2019-12-19 16:58:08 +00:00
Andrew Jones 6561535467 Remove pallet crates to improve compilation time (#55) 2019-12-17 11:41:40 +00:00
Andrew Jones daa1415297 Fix contracts instantiation (#51)
* Move contracts tests to contracts module

* Add test for instantiating a contract

* Fix InstantiateArgs encoding

* Ignore PhantomData primitives, they are 0

* Increase endowment and log code hash

* Update SystemEvent

* Fix codec import

* Oops

* Write buffer directly to output to avoid encoding vec

* Debug with StorageChanges encoded as hex

* Logging and format code
2019-12-17 09:39:56 +00:00
Andrew Jones f1926f55cf Update substrate and codec crate aliases (#54)
* Replace substrate crate aliases with actual crate names

* Alias parity-scale-codec to just codec, like in substrate

* Format code
2019-12-16 15:57:48 +00:00
Andrew Jones 625621e6ab New substrate crate renames (#50) 2019-12-02 13:41:20 +00:00
Yuanchao Sun 5108bce467 Fix the module index used to create a encoded func (#47)
* Fix the module index used to create a encoded func

Same as Events, modules with no calls should be ignored when calculating
the module index.

* Update substrate
2019-11-28 12:46:39 +00:00
Qinxuan Chen 4769b4b016 Use thiserror instead of derive_more (#44)
- Use thiserror instead of derive_more
- Format code
- Fix clippy warnings
- Add LICENSE_TEMPLATE

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2019-11-26 12:09:17 +00:00
Andrew Jones 55e067a294 Rename palette -> frame (#41) 2019-11-22 18:35:36 +00:00
Andrew Jones 17abfb49b2 Refactor: simplify module call definitions (#24)
* Refactor: simplify module call definitions

* Fix compilation errors after merge

* Add missing comments and remove unused imports

* Now it compiles
2019-11-21 17:53:45 +00:00
Andrew Jones 5242939f4d Rename paint -> palette with pallets (#38) 2019-11-21 10:08:54 +00:00
Andrew Jones 593646c2bc Update default runtime types to match substrate, format code (#34)
* Update default runtime types to match latest substrate

* Format code
2019-11-15 17:57:38 +00:00
Andrew Jones b39ff1771a New substrate signing API, srml -> paint rename (#33)
* Update jsonrpc to align with substrate

* Update to new substrate signing

* Default to MultiSignature

* Add missing event type sizes

* Rename TakeFees check to ChargeTransactionPayment

* Fix extrinsic Signature

* Ignore AuthorityList type size

* Rename srml to paint (#32)
2019-11-15 15:04:06 +00:00
Andrew Jones 58959db9d4 Define node_runtime compatible Runtime types (#23)
* Define default `node_runtime` compatible Runtime

* rustfmt
2019-10-04 17:54:16 +01:00
Andrew Jones 90cb9fc4cc Remove runtime dependency (#21)
* Remove System::Event type

* WIP: removing requirement for concrete Runtime impl for extras

* Use built in substrate types for constructing/signing the extrinsic

* Implement SignedExtension for copied types

* Fix remaining compilation errors

* Allow plugging in of predefined runtime types with blanket impls

* rustfmt

* Add CheckBlockGasLimit

* Construct DefaultExtrinsic in XtBuilder

* Derive Debug for extras

* Replace SignedExtension macro with explicit implementations

* Replace Lookup associated type with Address

* Move balances and contracts to main deps
2019-10-03 18:17:28 +01:00
Andrew Jones ee6db12917 Runtime agnostic Events (#20)
* Introduce OpaqueEvent

* Look up event by module and variant

* Index events by module

* Get events by module

* Dynamically decode events

* Decode System events and EventRecord topics

* Use type sizes to decode raw events

* Remove unused imports

* rustfmt

* Unify error types, fix some compiler errors

* Make dynamic event decoding work

- fix compilation errors
- skip modules with no events when indexing
- preallocate vec for raw event data

* Remove printlns, replace where required with log

* Remove unused import

* Check missing type sizes

* Ignore unknown event arg type sizes

* Decode concrete System events, assumes every Runtime has the module

* Reorganise usings

* pub use some types

* Code docs

* Export Error

* Error Display impls

* Format code
2019-09-26 17:48:25 +01:00
Andrew Plaza e9070e2786 Insipx/add block method (#18)
* Fix compile errors

* Fix tests, close #13 BTW

* add block method

* add block_hash method

* add tests for block and block_hash
2019-09-12 20:34:24 +01:00
Yuanchao Sun 650c6d3bb0 Fix compile errors (#17)
* Fix compile errors

* Fix tests, close #13 BTW
2019-09-12 20:31:05 +01:00
Andrew Jones 25c3e81811 Fetch runtime version and add to extrinsic payload (#12)
* Update extrinsic extra data to include CheckVersion

* Fetch version via rpc and add to raw extrinsic payload

* Add missing sr-version dependency
2019-08-23 18:24:34 +01:00
Daogang Tang 8a338f6c3f adding srml_system::CheckVersion to SignedExtra in tests in lib.rs. (#11)
Signed-off-by: daogangtang <daogangtang@gmail.com>
2019-08-23 16:32:44 +01:00
Andrew Jones d46b6a975e Allow either submit or submit_and_watch on the builder. (#9)
* Refactor: allow submit and submit_and_watch, separate module builders

* Convert Balances, and use generic ModuleCalls

* Convert System, and use generic ModuleCalls

* Extract common calls to set_call

* rustfmt

* Test contract put_code with valid contract

* Patch jsonrpc client dependency for bugfix

* Handle result from call builder inside submit

* Use patched version of jsonrpc

* Lift module calls to Error

* jsonrpc 13.0

* Remove unused static constraints
2019-08-20 16:57:06 +01:00
David Craven 151c7f7e0a Refactor (#7)
* Increment nonce when submitting transaction.

* Refactor.

* use default values from metadata
* use functions from metadata

* Nonce fixup

* Add docs.

* Add contracts module.

* Add set_code.

* Add events to metadata.

* Support pretty printing metadata.

* Add subscriptions.

* Add submit_and_watch to XtBuilder.

* nits from review
2019-08-12 17:07:28 +02:00
David Craven be5ccc1d11 Get it to work. (#6) 2019-08-08 16:01:07 +01:00
David Craven 19604e8f2e Use substrate metadata, introduce builder for client (#4)
* Export Error type

* Fix license headers

* Remove unnecessary fully qualified associated types

* Update to parity-scale-codec, handles decoding errors

* rustfmt

* Add metadata.

* Use metadata for calls.

* Refactor generics.

* Storage metadata.

* Use builders.

* Finish making generic.

* Fix merge.

* Run rustfmt.

* Fix merge.
2019-08-08 15:04:50 +01:00
David Craven 6522bb08d0 Misc changes (#2)
* Remove dependency on tokio, submit returns a future
* Enable logging in tests
* Add fetch, fetch_or, fetch_or_default
2019-08-06 15:26:11 +01:00
Andrew Jones 5a046d043e Make generic, removing dependency on node_runtime (#1)
* Extract error to file

* Update readme

* Extract Rpc to separate file

* Make Rpc generic over Runtime

* Editor config etc.

* rustfmt

* Remove node-runtime dependency, generic soup

* Move generic trait bounds to impl

* rustfmt

* Remove unused stuff

* Add test for balance transfer call
2019-08-06 13:12:12 +01:00
Andrew Jones 766e47d709 First commit (extracted from ink! cli) 2019-08-05 11:37:29 +01:00