From 8d5bfe4754d8cdddf467939ee442adbdeea7161b Mon Sep 17 00:00:00 2001
From: Miguel Angel Quinones <miguel@miqu.me>
Date: Tue, 14 Feb 2023 14:48:57 +0100
Subject: [PATCH] [CHANGE] Remove test key from repository

---
 .github/workflows/CI.yml    | 4 ++++
 .gitignore                  | 1 +
 scripts/setupKey.sh         | 4 ++++
 web3sTests/TestConfig.swift | 6 +++---
 4 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100755 scripts/setupKey.sh

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index fdd34813..99c27691 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -14,8 +14,12 @@ jobs:
   macos:
     needs: lint
     runs-on: macos-latest
+    env:
+      TESTS_PRIVATEKEY: ${{ secrets.TESTS_PRIVATEKEY }}
     steps:
     - uses: actions/checkout@v3
+    - name: SetupKey
+      run: ./scripts/setupKey.sh "${{ secrets.TESTS_PRIVATEKEY }}"
     - name: Build
       run: swift build -v
     - name: Tests
diff --git a/.gitignore b/.gitignore
index 38dc9aff..08235dd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,3 +66,4 @@ fastlane/screenshots
 fastlane/test_output
 
 scripts/bin/*
+TestConfig_private.swift
diff --git a/scripts/setupKey.sh b/scripts/setupKey.sh
new file mode 100755
index 00000000..68e38b70
--- /dev/null
+++ b/scripts/setupKey.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# write first argument to a Test
+echo "extension TestConfig {\nstatic let privateKey = \"$1\"\n}" > web3sTests/TestConfig_private.swift
\ No newline at end of file
diff --git a/web3sTests/TestConfig.swift b/web3sTests/TestConfig.swift
index f81ce600..1a7b7a68 100644
--- a/web3sTests/TestConfig.swift
+++ b/web3sTests/TestConfig.swift
@@ -13,11 +13,11 @@ struct TestConfig {
     // This is the proxy wss URL for connecting to the Blockchain. For testing we usually use the Goerli network on Infura. Using free tier, so might hit rate limits
     static let wssUrl = "wss://goerli.infura.io/ws/v3/b2f4b3f635d8425c96854c3d28ba6bb0"
 
-    // An EOA with some Ether, so that we can test sending transactions (pay for gas)
-    static let privateKey = "0xef4e182ae2cf32192d2a62c1159c8c4f7f2d658c303d0dfca5791a205456a132"
+    // An EOA with some Ether, so that we can test sending transactions (pay for gas). Set by CI
+//    static let privateKey = "SET_YOUR_KEY_HERE"
 
     // This is the expected public key (address) from the above private key
-    static let publicKey = "0x719561fee351F7aC6560D0302aE415FfBEEc0B51"
+    static let publicKey = "0xE78e5ecb061fE3DD1672dDDA7b5116213B23B99A"
 
     // A test ERC20 token contract (UNI)
     static let erc20Contract = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"