Skip to content

Commit

Permalink
Merge pull request #519 from WalletConnect/feature/project-id-secrets…
Browse files Browse the repository at this point in the history
…-#145

[CI] Project ID from secrets
  • Loading branch information
flypaper0 authored Sep 29, 2022
2 parents 365e223 + 524aecf commit 8af0d03
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
description: 'The endpoint of the relay e.g. relay.walletconnect.com'
required: false
default: 'relay.walletconnect.com'
project-id:
description: 'WalletConnect project id'
required: true

runs:
using: "composite"
Expand All @@ -29,12 +32,14 @@ runs:
shell: bash
env:
RELAY_ENDPOINT: ${{ inputs.relay-endpoint }}
PROJECT_ID: ${{ inputs.project-id }}
run: "xcodebuild \
-project Example/ExampleApp.xcodeproj \
-scheme IntegrationTests \
-clonedSourcePackagesDirPath SourcePackagesCache \
-destination 'platform=iOS Simulator,name=iPhone 13' \
RELAY_HOST='$RELAY_ENDPOINT' \
PROJECT_ID='$PROJECT_ID' \
test"

# Wallet build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- uses: ./.github/actions/ci
with:
type: ${{ matrix.test-type }}
project-id: ${{ secrets.PROJECT_ID }}

test-ui:
if: github.ref == 'refs/heads/main'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ Package.resolved
*/fastlane/test_output
*/fastlane/README.md

# Configuration
Configuration.xcconfig

2 changes: 2 additions & 0 deletions Configuration.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Uncomment next line and paste your project id. Get this on: https://cloud.walletconnect.com/sign-in
// PROJECT_ID = YOUR_PROJECT_ID
12 changes: 12 additions & 0 deletions Example/DApp/Common/InputConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

struct InputConfig {

static var projectId: String {
return config(for: "PROJECT_ID")!
}

private static func config(for key: String) -> String? {
return Bundle.main.object(forInfoDictionaryKey: key) as? String
}
}
2 changes: 2 additions & 0 deletions Example/DApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PROJECT_ID</key>
<string>$(PROJECT_ID)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UIApplicationSceneManifest</key>
Expand Down
2 changes: 1 addition & 1 deletion Example/DApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
private let authCoordinator = AuthCoordinator()

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
Relay.configure(projectId: "3ca2919724fbfa5456a25194e369a8b4", socketFactory: SocketFactory())
Relay.configure(projectId: InputConfig.projectId, socketFactory: SocketFactory())

setupWindow(scene: scene)
}
Expand Down
26 changes: 24 additions & 2 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
A50C036528AAD32200FE72D3 /* ClientDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50C036428AAD32200FE72D3 /* ClientDelegate.swift */; };
A50F3946288005B200064555 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50F3945288005B200064555 /* Types.swift */; };
A518B31428E33A6500A2CE93 /* InputConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A518B31328E33A6500A2CE93 /* InputConfig.swift */; };
A51AC0D928E436A3001BACF9 /* InputConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51AC0D828E436A3001BACF9 /* InputConfig.swift */; };
A51AC0DD28E43727001BACF9 /* InputConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51AC0DB28E436E6001BACF9 /* InputConfig.swift */; };
A51AC0DF28E4379F001BACF9 /* InputConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51AC0DE28E4379F001BACF9 /* InputConfig.swift */; };
A55CAAB028B92AFF00844382 /* ScanModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55CAAAB28B92AFF00844382 /* ScanModule.swift */; };
A55CAAB128B92AFF00844382 /* ScanPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55CAAAC28B92AFF00844382 /* ScanPresenter.swift */; };
A55CAAB228B92AFF00844382 /* ScanRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55CAAAD28B92AFF00844382 /* ScanRouter.swift */; };
Expand Down Expand Up @@ -244,6 +247,9 @@
A50C036428AAD32200FE72D3 /* ClientDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientDelegate.swift; sourceTree = "<group>"; };
A50F3945288005B200064555 /* Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = "<group>"; };
A518B31328E33A6500A2CE93 /* InputConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputConfig.swift; sourceTree = "<group>"; };
A51AC0D828E436A3001BACF9 /* InputConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputConfig.swift; sourceTree = "<group>"; };
A51AC0DB28E436E6001BACF9 /* InputConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputConfig.swift; sourceTree = "<group>"; };
A51AC0DE28E4379F001BACF9 /* InputConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputConfig.swift; sourceTree = "<group>"; };
A55CAAAB28B92AFF00844382 /* ScanModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanModule.swift; sourceTree = "<group>"; };
A55CAAAC28B92AFF00844382 /* ScanPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanPresenter.swift; sourceTree = "<group>"; };
A55CAAAD28B92AFF00844382 /* ScanRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanRouter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -356,6 +362,7 @@
A5E22D212840C8D300E36487 /* WalletEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletEngine.swift; sourceTree = "<group>"; };
A5E22D232840C8DB00E36487 /* SafariEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariEngine.swift; sourceTree = "<group>"; };
A5E22D2B2840EAC300E36487 /* XCUIElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCUIElement.swift; sourceTree = "<group>"; };
A5F48A0528E43D3F0034CBFB /* Configuration.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Configuration.xcconfig; path = ../Configuration.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -452,6 +459,7 @@
764E1D3326F8D3FC00A1FB15 = {
isa = PBXGroup;
children = (
A5F48A0528E43D3F0034CBFB /* Configuration.xcconfig */,
84CE6453279FFE1100142511 /* Wallet.entitlements */,
764E1D3E26F8D3FC00A1FB15 /* ExampleApp */,
84CE641D27981DED00142511 /* DApp */,
Expand Down Expand Up @@ -481,6 +489,7 @@
children = (
764E1D3F26F8D3FC00A1FB15 /* AppDelegate.swift */,
764E1D4126F8D3FC00A1FB15 /* SceneDelegate.swift */,
A51AC0DA28E436DE001BACF9 /* Common */,
761248152819F9A800CB6D48 /* Wallet */,
761C64A426FCB08B004239D1 /* SessionProposal */,
8460DCFE2750D6DF0081F94C /* SessionDetails */,
Expand Down Expand Up @@ -607,6 +616,14 @@
path = Types;
sourceTree = "<group>";
};
A51AC0DA28E436DE001BACF9 /* Common */ = {
isa = PBXGroup;
children = (
A51AC0DB28E436E6001BACF9 /* InputConfig.swift */,
);
path = Common;
sourceTree = "<group>";
};
A55CAAAA28B92AF200844382 /* Scan */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -762,6 +779,7 @@
A58E7CFD2872A0F80082D443 /* Common */ = {
isa = PBXGroup;
children = (
A51AC0DE28E4379F001BACF9 /* InputConfig.swift */,
A50F3944288005A700064555 /* Types */,
A5C2021F287EA5AF007E3188 /* Components */,
A578FA332873049400AA7720 /* Style */,
Expand Down Expand Up @@ -979,6 +997,7 @@
A5BB7FAB28B6AA7100707FC6 /* Common */ = {
isa = PBXGroup;
children = (
A51AC0D828E436A3001BACF9 /* InputConfig.swift */,
A5BB7FAC28B6AA7D00707FC6 /* QRCodeGenerator.swift */,
);
path = Common;
Expand Down Expand Up @@ -1307,6 +1326,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A51AC0DD28E43727001BACF9 /* InputConfig.swift in Sources */,
76235E892820198B004ED0AA /* UIKit+Previews.swift in Sources */,
76B149F02821C03B00F05F91 /* Proposal.swift in Sources */,
765056272821989600F9AE79 /* Color+Extension.swift in Sources */,
Expand Down Expand Up @@ -1344,6 +1364,7 @@
84CE645527A29D4D00142511 /* ResponseViewController.swift in Sources */,
84CE641F27981DED00142511 /* AppDelegate.swift in Sources */,
A5BB7FAD28B6AA7D00707FC6 /* QRCodeGenerator.swift in Sources */,
A51AC0D928E436A3001BACF9 /* InputConfig.swift in Sources */,
A5BB7FA928B6A5FD00707FC6 /* AuthViewModel.swift in Sources */,
84CE6452279ED42B00142511 /* ConnectView.swift in Sources */,
84CE6448279AE68600142511 /* AccountRequestViewController.swift in Sources */,
Expand All @@ -1363,6 +1384,7 @@
files = (
A58E7D3B2872D55F0082D443 /* ChatInteractor.swift in Sources */,
A58E7D1F2872A57B0082D443 /* ApplicationConfigurator.swift in Sources */,
A51AC0DF28E4379F001BACF9 /* InputConfig.swift in Sources */,
A58E7D452872EE570082D443 /* ContentMessageView.swift in Sources */,
A5C20223287EA7E2007E3188 /* BrandButton.swift in Sources */,
A5629ADF2876CC6E00094373 /* InviteListPresenter.swift in Sources */,
Expand Down Expand Up @@ -1528,6 +1550,7 @@
/* Begin XCBuildConfiguration section */
764E1D4E26F8D3FE00A1FB15 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A5F48A0528E43D3F0034CBFB /* Configuration.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -1589,6 +1612,7 @@
};
764E1D4F26F8D3FE00A1FB15 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A5F48A0528E43D3F0034CBFB /* Configuration.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -1876,7 +1900,6 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IntegrationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
RELAY_HOST = relay.walletconnect.com;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -1895,7 +1918,6 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.IntegrationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
RELAY_HOST = relay.walletconnect.com;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
value = "$(RELAY_HOST)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "PROJECT_ID"
value = "$(PROJECT_ID)"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<Testables>
<TestableReference
Expand Down
12 changes: 12 additions & 0 deletions Example/ExampleApp/Common/InputConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

struct InputConfig {

static var projectId: String {
return config(for: "PROJECT_ID")!
}

private static func config(for key: String) -> String? {
return Bundle.main.object(forInfoDictionaryKey: key) as? String
}
}
2 changes: 2 additions & 0 deletions Example/ExampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PROJECT_ID</key>
<string>$(PROJECT_ID)</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
2 changes: 1 addition & 1 deletion Example/ExampleApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
url: "example.wallet",
icons: ["https://avatars.githubusercontent.com/u/37784886"])

Relay.configure(projectId: "3ca2919724fbfa5456a25194e369a8b4", socketFactory: SocketFactory())
Relay.configure(projectId: InputConfig.projectId, socketFactory: SocketFactory())
Sign.configure(metadata: metadata)
#if DEBUG
if CommandLine.arguments.contains("-cleanInstall") {
Expand Down
3 changes: 1 addition & 2 deletions Example/IntegrationTests/Auth/AuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ final class AuthTests: XCTestCase {

func makeClient(prefix: String, account: Account? = nil) -> AuthClient {
let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug)
let projectId = "3ca2919724fbfa5456a25194e369a8b4"
let keychain = KeychainStorageMock()
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: projectId, keychainStorage: keychain, socketFactory: SocketFactory(), logger: logger)
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: InputConfig.projectId, keychainStorage: keychain, socketFactory: SocketFactory(), logger: logger)

return AuthClientFactory.create(
metadata: AppMetadata(name: name, description: "", url: "", icons: [""]),
Expand Down
3 changes: 1 addition & 2 deletions Example/IntegrationTests/Chat/ChatTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ final class ChatTests: XCTestCase {

func makeClient(prefix: String) -> ChatClient {
let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug)
let projectId = "3ca2919724fbfa5456a25194e369a8b4"
let keychain = KeychainStorageMock()
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: projectId, keychainStorage: keychain, socketFactory: SocketFactory(), logger: logger)
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: InputConfig.projectId, keychainStorage: keychain, socketFactory: SocketFactory(), logger: logger)
return ChatClientFactory.create(registry: registry, relayClient: relayClient, kms: KeyManagementService(keychain: keychain), logger: logger, keyValueStorage: RuntimeKeyValueStorage())
}

Expand Down
3 changes: 1 addition & 2 deletions Example/IntegrationTests/Pairing/PairingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ final class PairingTests: XCTestCase {
func makeClients(prefix: String) -> (PairingClient, PushClient) {
let keychain = KeychainStorageMock()
let logger = ConsoleLogger(suffix: prefix, loggingLevel: .debug)
let projectId = "3ca2919724fbfa5456a25194e369a8b4"
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: projectId, keychainStorage: keychain, socketFactory: SocketFactory(), logger: logger)
let relayClient = RelayClient(relayHost: InputConfig.relayHost, projectId: InputConfig.projectId, keychainStorage: keychain, socketFactory: SocketFactory(), logger: logger)

let pairingClient = PairingClientFactory.create(logger: logger, keyValueStorage: RuntimeKeyValueStorage(), keychainStorage: keychain, relayClient: relayClient)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Starscream

final class RelayClientEndToEndTests: XCTestCase {

let projectId = "3ca2919724fbfa5456a25194e369a8b4"
private var publishers = Set<AnyCancellable>()

func makeRelayClient() -> RelayClient {
Expand All @@ -18,7 +17,7 @@ final class RelayClientEndToEndTests: XCTestCase {
relayHost: InputConfig.relayHost
)
let urlFactory = RelayUrlFactory(socketAuthenticator: socketAuthenticator)
let socket = WebSocket(url: urlFactory.create(host: InputConfig.relayHost, projectId: projectId))
let socket = WebSocket(url: urlFactory.create(host: InputConfig.relayHost, projectId: InputConfig.projectId))

let logger = ConsoleLogger()
let dispatcher = Dispatcher(socket: socket, socketConnectionHandler: ManualSocketConnectionHandler(socket: socket), logger: logger)
Expand Down
7 changes: 2 additions & 5 deletions Example/IntegrationTests/Sign/SignClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ final class SignClientTests: XCTestCase {
var dapp: ClientDelegate!
var wallet: ClientDelegate!

static private func makeClientDelegate(
name: String,
projectId: String = "3ca2919724fbfa5456a25194e369a8b4"
) -> ClientDelegate {
static private func makeClientDelegate(name: String) -> ClientDelegate {
let logger = ConsoleLogger(suffix: name, loggingLevel: .debug)
let keychain = KeychainStorageMock()
let relayClient = RelayClient(
relayHost: InputConfig.relayHost,
projectId: projectId,
projectId: InputConfig.projectId,
keyValueStorage: RuntimeKeyValueStorage(),
keychainStorage: keychain,
socketFactory: SocketFactory(),
Expand Down
10 changes: 9 additions & 1 deletion Example/IntegrationTests/Stubs/InputConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ import Foundation
struct InputConfig {

static var relayHost: String {
return ProcessInfo.processInfo.environment["RELAY_HOST"]!
return config(for: "RELAY_HOST")!
}

static var projectId: String {
return config(for: "PROJECT_ID")!
}

static var defaultTimeout: TimeInterval {
return 30
}

private static func config(for key: String) -> String? {
return ProcessInfo.processInfo.environment[key]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Auth
struct ThirdPartyConfigurator: Configurator {

func configure() {
Relay.configure(projectId: "relay.walletconnect.com", socketFactory: SocketFactory())
Relay.configure(projectId: InputConfig.projectId, socketFactory: SocketFactory())

Auth.configure(
metadata: AppMetadata(
Expand Down
12 changes: 12 additions & 0 deletions Example/Showcase/Common/InputConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

struct InputConfig {

static var projectId: String {
return config(for: "PROJECT_ID")!
}

private static func config(for key: String) -> String? {
return Bundle.main.object(forInfoDictionaryKey: key) as? String
}
}
2 changes: 2 additions & 0 deletions Example/Showcase/Other/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PROJECT_ID</key>
<string>$(PROJECT_ID)</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>CFBundleURLTypes</key>
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ dependencies: [
.package(url: "https://github.com/WalletConnect/WalletConnectSwiftV2", .branch("main")),
],
```
## Setting Project ID
Follow instructions from *Configuration.xcconfig* and configure PROJECT_ID with your ID from WalletConnect Dashboard
```
// Uncomment next line and paste your project id. Get this on: https://cloud.walletconnect.com/sign-in
// PROJECT_ID = YOUR_PROJECT_ID
```
## Example App
open `Example/ExampleApp.xcodeproj`

Expand Down

0 comments on commit 8af0d03

Please sign in to comment.