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

#219 auth wrapper #222

Merged
merged 23 commits into from
May 24, 2022
Merged

#219 auth wrapper #222

merged 23 commits into from
May 24, 2022

Conversation

llbartekll
Copy link
Contributor

@llbartekll llbartekll commented May 20, 2022

  • Supports client's delegate with Combine API
  • Adds Singleton Auth wrapper around AuthClient
  • updates sample apps to consume new interface

close #219
close #55

@llbartekll llbartekll marked this pull request as draft May 20, 2022 09:00
@llbartekll llbartekll marked this pull request as ready for review May 20, 2022 10:37
@llbartekll llbartekll marked this pull request as draft May 20, 2022 11:48
@llbartekll llbartekll requested a review from flypaper0 May 23, 2022 08:26
@llbartekll llbartekll marked this pull request as ready for review May 23, 2022 13:44
@llbartekll llbartekll self-assigned this May 23, 2022
import Combine

public class Auth {
static public let instance = Auth()
Copy link
Contributor

Choose a reason for hiding this comment

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

public static ?

private let relayClient: RelayClient

private init() {
guard let config = Auth.config else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Factory?
static public let instance = AuthFactory.create()

static public let instance = Auth()
private let client: AuthClient
private static var config: Config?
public let logger: ConsoleLogging
Copy link
Contributor

Choose a reason for hiding this comment

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

What you think about this codestyle?

    public static let instance = Auth()
    public let logger: ConsoleLogging
    
    private static var config: Config?
    private let client: AuthClient
    private let relayClient: RelayClient

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌

static public let instance = Auth()
private let client: AuthClient
private static var config: Config?
public let logger: ConsoleLogging
Copy link
Contributor

@flypaper0 flypaper0 May 23, 2022

Choose a reason for hiding this comment

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

Why logger is public here? Why we need this here? Sorry didn't find

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that during sdk integration it may be sometimes convenient to set logging level to debug.
make sense?

}
relayClient = RelayClient(relayHost: "relay.walletconnect.com", projectId: config.projectId, socketConnectionType: config.socketConnectionType)
client = AuthClient(metadata: config.metadata, relayClient: relayClient)
self.logger = client.logger
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we avoid this inverted proxy somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean AuthClient in Auth?

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.

some codestyle / architecture suggestions, otherwise lgtm

@llbartekll llbartekll merged commit bb010be into develop May 24, 2022
@llbartekll llbartekll deleted the #219-Auth-wrapper branch May 24, 2022 08:01
llbartekll added a commit that referenced this pull request May 25, 2022
* add update methods tests

* add updateEvents to ControllerSessionStateMachine

* add handleUpdateEventsResponse

* Add expiry date concept test case

* Add inactive pairing expiry tests

* Change pairing creation pattern

* Add pairing extension tests

* Add pairing activation test

* Activate pairing created from URI

* Update Tests/WalletConnectTests/Helpers/Error+Extension.swift

Co-authored-by: André Vants <MisterVants@users.noreply.github.com>

* build fix

* refactor ControllerSessionStateMachine

* add onSessionUpdateEventsRequest handling

* add session update events integration test

* add NonControllerSessionStateMachine unit tests

* Add ControllerSessionStateMachineTests events tests

* Change test case name

* Fix build

* Renamed PairingSequence to WCPairing

* Renamed SessionSequence to WCSession

* Adds Commons and Toolbox packages

* update session proposal data model

* update public proposal data model

* update methods with protocol requirements

* update account params

* remove comment

* Removing sequence name from storage variables names

* Dropping sequence term from storage protocols signature

* Renamed sequence params in storage mocks

* Fixes Bad access when trying to modify subscriptions #156

* migrate update methods to state machines

* rename notifications to events

* move update accounts to state machines

* savepoint

* update client delegate

* Add integration test for expiry

* simplify method

* Fix example wallet build

* Fix example dapp build

* Renamed responder VC to wallet VC

* Revert "Adds Commons and Toolbox packages"

This reverts commit 8b9ce2b.

* Update swift.yml

* Update swift.yml

* refactor pairing model

* refactor session model

* update gitignore

* savepoint

* add session to pairing topic storage

* Update gitignore

* Update Gemfile.lock

* Update fix gitignore

* Workaround a double precision bug in AnyCodable tests

* Fix AnyCodable double test w/ workaround

* Re-enable app build actions

* Disable app actions test

* Re-enable test wallet build step

* Test build example with xcodebuild

* Fix Xcode version

* Change action command place

* Change xcodebuild params

* Try running with destination param

* Test without specifying the platform

* Try using custom simulator

* Fix Xcode version in path

* Try adding 13.1 runtime

* Test with device type param

* Try listing device types

* Revert version workaround, running generic build

* update session delete params, change propose response body

* Update swift.yml

* remove update pairing metadata method from pairing engine

* Fixed conflict in CI file

* remove subscriber from pairing engine

* fix pairing engine tests

* remove subscriber from session engine

* build session engine tests

* remove wcsubscriber implementation

* Fixes blurry QR code when running on device

* rename notify to emit

* remove duplicated subscriber from walletconnect relayer

* add methods and events params to client's approve method

* Update docs

* fix build

* fix build

* fix crash

* savepoint

* Updated project structure

* Renamed session proposal view & controller

* Formatted some code

* savepoint - namespaces check

* build auth package after protocol change

* savepoint

* remove blockchains from proposal, refactor tests

* compile test target

* fix integration tests

* disable automatic sample apps builds

* Add empty namespace test cases

* Add remaining request authorization tests

* Fixed implementation to comply with test cases

* Refactored request stubbing on tests

* Declared namespace members as public

* Fixed example wallet build

* Fixed dapp build

* Re-enable app build workflows

* Fixed integration tests

* savepoint

* savepoint

* Approve with proposal id

* fix wallet build

* remove duplicated client delegate extension method

* Add SwiftUI previews extension for UIKit views

* Add previews for session proposal and details

* Add preview to request view

* SwiftUI experiment with proposal view

* Redesigned view to show namespaces data

* Moved Proposal type to another file

* Using async image to load icon

* Refactored proposal view controller

* Refactor proposal view code

* savepoint

* add new publish method to relayer

* Adds Relayer async publish method

* savepoint

* fix fing integration tests

* distinguish three separate wc relaying reguest methods:
-request
-requestNetworkAck
-requestPeerResponse

* Rename WalletConnectRelay to NetworkingInteractor

* refactor networking interactor async method

* refactor client's disconnect method to be async

* turn off dispatching retry
fix example apps after client interface changes

* fix tests

* Small tweaks to example wallet

* fix wallet to not operate on mocked data

* build package with starscream
delete urlsession

* fix relay client tests
remove unused classes

* add logs, integration tests wait clients connected

* fix example apps

* add socket connection status

* add diddisconnect delegate method

* fix unit tsts

* Fix integration tests issue

* fix delete session issue when no internet connection

* Fix tests

* Update project structure

* Removed optional from event chainId

* Removed optional from request chainId

* Fixed integration test case

* remove unused code

* savepoint

* add pair method engine actor

* update client's connect to async

* Added validation checks for empty namespaces

* Fixed build

* savepoint

* fix client's connect method, uncomment integration tests

* restructure project

* add Concurrency to emit method

* savepoint

* fix dapp build

* fix deeplinking

* remove commented code

* clean up

* Add split namespaces

* Changed proposal schema with required namespaces

* Change client API to use namespace dict for approval

* Remove update accounts method

* Updated wc methods signatures

* Fixed test build

* Removed update accounts commented code

* Changed update call to new specs

* Disable CI app build

* rename WalletConnectClient to AuthClient

* Rename Relayer to Relay Client

* rename auth and relay packages

* Fix package issues after renaming

* Add validation test cases

* Implemented namespace validation

* Removed previous namespace code

* Removed previous namespace code

* Added peer validation matching test cases

* Implemented namespace peer validation

* Added approver side namespace checks

* Added proposer side namespace checks on approval

* Removed leftover unnecessary check

* remove code examples

* add Concurrency to extend and update functions

* fix tests, add XCTAssertNoThrowAsync

* Moved namespace validation when proposal is received

* Remove unnecessary todo

* Merge callbacks on proposal response

* map proposed namespaces to session namespaces

* fix wallet build

* remove  session state validating and namespace type

* fix dapp build

* reenable app builds

* fix swift.yml

* fix tests

* Setting proposal to nil after using it on settlement

* tvOS support

* #219 auth wrapper (#222)

* Add Auth singleton

* savepoint

* Add combine publishers

* savepoint

* change build number

* add socket connection status publisher

* fix sample apps builds

* savepoiint

* savepoint

* add Auth to sample dapp

* remove client delegate

* fix dapp with Auth consumption

* subscribe main scheduler

* add all delegate methods to Auth

* Add missing Auth publishers

* restructure project

* Add Auth to the sample wallet

* add connect and disconnect methods to Auth

* fix tests

* adjust style

* remove logger from Auth

* fix build

* #220 Permission validation for requests and events (#221)

* Add permission checks for requests

* Add permission checks for event emissions

* Add tests for basic permission validation

* Fixed permission validation with test cases

* Improve session permission tests

Co-authored-by: André Vants

* remove getAcknowledgedSessions (#228)

* remove getAcknowledgedSessions

* rename method

* fix Auth connect method (#229)

* remove getAcknowledgedSessions

* rename method

* fix connect() bug

* Update namespaces (#230)

* remove getAcknowledgedSessions

* rename method

* fix connect() bug

* update namespaces on controller request

* turn off logger

* [Wallet] Edit session namespaces (#231)

* Edit session namespaces UI

* Update namespace error handling

* Pending requests

* Show SessionRequest Screen

* Reload SessionDetails on request respond

* Unused import removed

* Hot fix dapp personal sign (#234)

use session account for personal_sign request

* #226 Rename Auth package to Sign (#232)

* Renamed package and base directories

* Renamed imports to WalletConnectSign

* Renamed client and delegate

* Renamed Auth type to Sign

* Fixed a log typo

* Removed auth reference from build scheme

Co-authored-by: André Vants

* rename update expiry to extend on Sign publishers (#237)

rename update expiry to extend

Co-authored-by: André Vants <andrevants@icloud.com>
Co-authored-by: André Vants <MisterVants@users.noreply.github.com>
Co-authored-by: Krypto Pank <krypto.pank@gmail.com>
Co-authored-by: Artur Guseinov <arthur.guseinov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants