-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
…V2 into #376-auth-request-service
- Loading branch information
Showing
21 changed files
with
637 additions
and
276 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
# This workflow moves issues to the Swift board | ||
# when they receive the "accepted" label | ||
# When WalletConnect Org members create issues they | ||
# are automatically "accepted". | ||
# Else they need to manually receive that label during intake. | ||
name: intake | ||
|
||
on: | ||
issues: | ||
types: [opened, labeled] | ||
pull_request: | ||
types: [opened, labeled] | ||
|
||
jobs: | ||
add-to-project: | ||
name: Add issue to board | ||
if: github.event.action == 'labeled' && github.event.label.name == 'accepted' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
project-url: https://github.com/orgs/WalletConnect/projects/5 | ||
github-token: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }} | ||
labeled: accepted | ||
label-operator: OR | ||
auto-promote: | ||
name: auto-promote | ||
if: github.event.action == 'opened' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if organization member | ||
id: is_organization_member | ||
if: github.event.action == 'opened' | ||
uses: JamesSingleton/[email protected] | ||
with: | ||
organization: WalletConnect | ||
username: ${{ github.event_name != 'pull_request' && github.event.issue.user.login || github.event.sender.login }} | ||
token: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }} | ||
- name: Label issues | ||
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 | ||
with: | ||
add-labels: "accepted" | ||
repo-token: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }} |
This file contains 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 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 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 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 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,65 @@ | ||
struct Subscribe: RelayRPC { | ||
|
||
struct Params: Codable { | ||
let topic: String | ||
} | ||
|
||
let params: Params | ||
|
||
var method: String { | ||
"subscribe" | ||
} | ||
} | ||
|
||
struct Unsubscribe: RelayRPC { | ||
|
||
struct Params: Codable { | ||
let id: String | ||
let topic: String | ||
} | ||
|
||
let params: Params | ||
|
||
var method: String { | ||
"unsubscribe" | ||
} | ||
} | ||
|
||
struct Publish: RelayRPC { | ||
|
||
struct Params: Codable { | ||
let topic: String | ||
let message: String | ||
let ttl: Int | ||
let prompt: Bool? | ||
let tag: Int? | ||
} | ||
|
||
let params: Params | ||
|
||
var method: String { | ||
"publish" | ||
} | ||
} | ||
|
||
struct Subscription: RelayRPC { | ||
|
||
struct Params: Codable { | ||
struct Contents: Codable { | ||
let topic: String | ||
let message: String | ||
} | ||
let id: String | ||
let data: Contents | ||
} | ||
|
||
let params: Params | ||
|
||
var method: String { | ||
"subscription" | ||
} | ||
|
||
init(id: String, topic: String, message: String) { | ||
self.params = Params(id: id, data: Params.Contents(topic: topic, message: message)) | ||
} | ||
} |
This file contains 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,5 @@ | ||
protocol RPCMethod { | ||
associatedtype Parameters | ||
var method: String { get } | ||
var params: Parameters { get } | ||
} |
This file contains 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,38 @@ | ||
import JSONRPC | ||
|
||
protocol RelayRPC: RPCMethod {} | ||
|
||
extension RelayRPC where Parameters: Codable { | ||
|
||
var idGenerator: IdentifierGenerator { | ||
return WalletConnectRPCID() | ||
} | ||
|
||
func wrapToIridium() -> PrefixDecorator<Self> { | ||
return PrefixDecorator(rpcMethod: self, prefix: "iridium") | ||
} | ||
|
||
func wrapToIRN() -> PrefixDecorator<Self> { | ||
return PrefixDecorator(rpcMethod: self, prefix: "irn") | ||
} | ||
|
||
func asRPCRequest() -> RPCRequest { | ||
RPCRequest(method: self.method, params: self.params, idGenerator: self.idGenerator) | ||
} | ||
} | ||
|
||
struct PrefixDecorator<T>: RelayRPC where T: RelayRPC { | ||
|
||
typealias Parameters = T.Parameters | ||
|
||
let rpcMethod: T | ||
let prefix: String | ||
|
||
var method: String { | ||
"\(prefix)_\(rpcMethod.method)" | ||
} | ||
|
||
var params: Parameters { | ||
rpcMethod.params | ||
} | ||
} |
This file contains 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,11 @@ | ||
import Foundation | ||
import JSONRPC | ||
|
||
struct WalletConnectRPCID: IdentifierGenerator { | ||
|
||
func next() -> RPCID { | ||
let timestamp = Int64(Date().timeIntervalSince1970 * 1000) * 1000 | ||
let random = Int64.random(in: 0..<1000) | ||
return .right(Int(timestamp + random)) | ||
} | ||
} |
Oops, something went wrong.