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

#256 JSON-RPC Package (& Commons) #261

Merged
merged 30 commits into from
Jun 8, 2022
Merged

#256 JSON-RPC Package (& Commons) #261

merged 30 commits into from
Jun 8, 2022

Conversation

sekimondre
Copy link

Overview

This PR introduces a full compliant JSON-RPC 2.0 interface for request and responses. Specs can be found at jsonrpc.org

What changed

  • Introduces the Commons and JSONRPC packages.
  • Adds RPCRequest and RPCResponse compliant with JSON-RPC 2.0 specifications.
  • Adds RPCRequestConvertible to facilitate decouple of protocol methods from RPC requests.
  • AnyCodable type moved to Commons package.
  • Reintroduces Either type.
  • Also enables the code coverage report for the project. (Was previously missing in SPM)

Notes

Types were introduced in a way to interfere as little as possible with current SDK code. Current request objects can be migrated over time, and ID generation logic can be wrapped over the RPC models.

The JSONRPC types can be considered foundational code and are build with the intention to be flexible, solid, and allow use in other types of application. Feedback over the API and its usage is appreciated.

@sekimondre sekimondre added the enhancement New feature or request label Jun 6, 2022
@sekimondre sekimondre self-assigned this Jun 6, 2022
throw DecodingError.dataCorruptedError(
forKey: .params,
in: container,
debugDescription: "")
Copy link
Author

Choose a reason for hiding this comment

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

I forgot this description

@llbartekll
Copy link
Contributor

Looks, very clean and thoroughly tested, I just wonder if it is not too complex fro our needs but looking forward how it will work consumed by SDKs.

Comment on lines 37 to +39
.target(
name: "WalletConnectUtils",
dependencies: ["Commons"]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we define a difference between WalletConnectUtils and a Commons ?

Copy link
Author

Choose a reason for hiding this comment

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

WalletConnectUtils should have types related to WalletConnect domain rules, Commons should be always agnostic of any WalletConnect implementation. I think we could even rename WalletConnectUtils to WalletConnectCore and, over time, extract the components (storage, logging) to their own packages.

@sekimondre sekimondre linked an issue Jun 6, 2022 that may be closed by this pull request
Copy link
Contributor

@flypaper0 flypaper0 left a comment

Choose a reason for hiding this comment

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

Looks grate to me! Could you please commit a little example of integration JSON-RPC Package in out codebase?

@flypaper0
Copy link
Contributor

We could close #155 after that changes?

@sekimondre
Copy link
Author

We could close #155 after that changes?

Absolutely

@sekimondre
Copy link
Author

Looks grate to me! Could you please commit a little example of integration JSON-RPC Package in out codebase?

Sure, I'll try doing something on a next PR

@sekimondre sekimondre merged commit 9e94672 into develop Jun 8, 2022
@sekimondre sekimondre deleted the #256-jsonrpc-package branch June 8, 2022 13:25
@flypaper0 flypaper0 mentioned this pull request Jun 9, 2022
flypaper0 added a commit that referenced this pull request Jun 9, 2022
* Cleanup Service + SequenceStore refactor (#241)

* Cleanup service

* Clean sessionToPairingTopic

* SequenceStore refactor

* Rename KeyValueStore -> CodableStore

* Deliver an invite (#254)

* Add Chat target, split packages

* savepoint

* Update networking interactor  to decode unencrypted messages

* pass on invite test

* restructure chat's project folder

* Add engine storages

* extract storage domain identifiers

* update logging

* fix schemas

* Update style

* Add publishers to Chat

* rename kv store to codable strore

* UI tests (#242)

* Pairing testcase

* Ping testcase

* ApproveSessionExistingPairing test case

* Unused extensions deleted

* Renamed to RegressionTests

* UITests step on CI

* CleanLaunch instead of deleting app

* Fix test on Real device

* Launch App fix

* Approve engine refactor (#260)

* Approve method moved ApproveEngine

* Reject and wcSessionSubscriptions for ApproveEngine

* Private methods moved in extension

* ApproveEngine errors handlers

* Try on reject

* ApproveEngine moved to callbacks

* Session Settle moved to approve Engine

* onProposeResponse subscription removed

* Reject by proposalId

* Settle moved to approve

* ApproveEngine moved to Controller folder

* typealias removed

* TODO for SettleEngine

* #256 JSON-RPC Package (& Commons) (#261)

* Add Chat target, split packages

* savepoint

* restructure chat's project folder

* fix schemas

* Add JSONRPC and Commons packages

* Moved AnyCodable to Commons

* Fixed test import

* Reintroduces either type

* Add request and response types

* Add simple response decode tests

* Add response ID parsing tests

* Fixed tests typo

* Improved response round trip coding test

* Error response decoding tests

* Invalid response decode tests

* Enabled code coverage for library

* Response decoding tests for structured result values

* Add flexible initializers with tests

* Add descriptions to errors thrown in response decoding

* Renamed response internalResult to outcome

* Basic RPC request decoding tests

* Tests for request empty cases and corner cases

* Add flexible inits for requests

* Add identifier generation inits

* Joined request notification extensions

* Renamed files

* Implemented default JSONRPC error cases

* Declared RPCRequestConvertible as public

* Remove rebase artifacts

* Added debug description to request param primitives error

Co-authored-by: Bartosz Rozwarski <bartus000@gmail.com>
Co-authored-by: André Vants <MisterVants@users.noreply.github.com>
@flypaper0 flypaper0 mentioned this pull request Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Unify JSON-RPC request & response API
3 participants