From dc3c81f45f90377a3d3f45441ce43883abffcf0a Mon Sep 17 00:00:00 2001 From: John Feras Date: Thu, 27 Jun 2024 17:00:10 -0400 Subject: [PATCH] Remove all reference to INFURA_ID --- .github/workflows/ci.yaml | 1 - contracts-core/.env.example | 1 - frontend/.env.example | 1 - umbra-js/.env.example | 1 - umbra-js/hardhat.config.ts | 11 +++++----- umbra-js/test/cns.test.ts | 8 +++---- umbra-js/test/utils.test.ts | 44 +++++++++++++++++++++---------------- 7 files changed, 34 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 375b1173b..630cdb469 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,6 @@ env: GNOSIS_CHAIN_RPC_URL: ${{ secrets.GNOSIS_CHAIN_RPC_URL }} BASE_RPC_URL: $${{ secrets.BASE_RPC_URL }} FOUNDRY_PROFILE: ci - INFURA_ID: ${{ secrets.INFURA_ID }} WALLET_CONNECT_PROJECT_ID: ${{ secrets.WALLET_CONNECT_PROJECT_ID }} jobs: diff --git a/contracts-core/.env.example b/contracts-core/.env.example index 4777fb8b0..b7951bc4b 100644 --- a/contracts-core/.env.example +++ b/contracts-core/.env.example @@ -1,4 +1,3 @@ -INFURA_ID=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz MNEMONIC=here is where your twelve words mnemonic should be put my friend DEPLOY_GSN=false ETHERSCAN_VERIFICATION_API_KEY="YOUR_API_KEY" diff --git a/frontend/.env.example b/frontend/.env.example index ee9dccc1b..3062ba0bd 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -3,7 +3,6 @@ OPTIMISTIC_ETHERSCAN_API_KEY=yourOptimisticEtherscanApiKey POLYGONSCAN_API_KEY=yourPolygonscanApiKey ARBISCAN_API_KEY=yourArbiscanApiKey -INFURA_ID=yourKeyHere BLOCKNATIVE_API_KEY=yourKeyHere FORTMATIC_API_KEY=yourKeyHere PORTIS_API_KEY=yourKeyHere diff --git a/umbra-js/.env.example b/umbra-js/.env.example index 0317f16b1..0b36f09e2 100644 --- a/umbra-js/.env.example +++ b/umbra-js/.env.example @@ -3,7 +3,6 @@ OPTIMISTIC_ETHERSCAN_API_KEY=yourOptimisticEtherscanApiKey POLYGONSCAN_API_KEY=yourPolygonscanApiKey ARBISCAN_API_KEY=yourArbiscanApiKey GNOSISSCAN_API_KEY=yourGnosisSafeScanApiKey -INFURA_ID=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz MAINNET_RPC_URL=yourMainnetRpcUrl OPTIMISM_RPC_URL=yourOptimismRpcUrl GNOSIS_CHAIN_RPC_URL=yourGnosisChainRpcUrl diff --git a/umbra-js/hardhat.config.ts b/umbra-js/hardhat.config.ts index cf6fe252f..1d97311dc 100644 --- a/umbra-js/hardhat.config.ts +++ b/umbra-js/hardhat.config.ts @@ -19,11 +19,10 @@ const chainIds = { // Ensure that we have all the environment variables we need. const mnemonic = 'test test test test test test test test test test test junk'; -const infuraApiKey = process.env.INFURA_ID; -if (!infuraApiKey) throw new Error('Please set your INFURA_ID in a .env file'); - function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig { - const url = `https://${network}.infura.io/v3/${infuraApiKey as string}`; + const rpcUrlString = `${network.toUpperCase()}_RPC_URL`; + const url = process.env[rpcUrlString]; + if (!url) throw new Error(`Please set the ${url} in a .env file`); return { accounts: { count: 10, @@ -36,12 +35,14 @@ function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig }; } +const rpcUrlString = process.env.SEPOLIA_RPC_URL; +if (!rpcUrlString) throw new Error('Please set the SEPOLIA_RPC_URL in a .env file'); const config: HardhatUserConfig = { defaultNetwork: 'hardhat', networks: { hardhat: { forking: { - url: `https://sepolia.infura.io/v3/${infuraApiKey}`, + url: rpcUrlString, }, chainId: chainIds.hardhat, accounts: { diff --git a/umbra-js/test/cns.test.ts b/umbra-js/test/cns.test.ts index 9f6933161..20f1dad15 100644 --- a/umbra-js/test/cns.test.ts +++ b/umbra-js/test/cns.test.ts @@ -11,11 +11,11 @@ const resolution = new Resolution({ uns: { locations: { Layer1: { - url: `https://mainnet.infura.io/v3/${String(process.env.INFURA_ID)}`, + url: `${String(process.env.MAINNET_RPC_URL)}`, network: 'mainnet', }, Layer2: { - url: `https://polygon-mainnet.infura.io/v3/${String(process.env.INFURA_ID)}`, + url: `${String(process.env.POLYGON_RPC_URL)}`, network: 'polygon-mainnet', }, }, @@ -43,9 +43,7 @@ describe('СNS functions', () => { it('gets the public keys associated with a CNS address', async () => { const address = await resolution.addr(name, 'ETH'); - const ethersProvider = new StaticJsonRpcProvider( - `https://polygon-mainnet.infura.io/v3/${String(process.env.INFURA_ID)}` - ); + const ethersProvider = new StaticJsonRpcProvider(`${String(process.env.POLYGON_RPC_URL)}`); const keys = await utils.lookupRecipient(address, ethersProvider); expect(keys.spendingPublicKey).to.equal(nameSpendingPublicKey); expect(keys.viewingPublicKey).to.equal(nameViewingPublicKey); diff --git a/umbra-js/test/utils.test.ts b/umbra-js/test/utils.test.ts index 86c42b244..37ae2afa5 100644 --- a/umbra-js/test/utils.test.ts +++ b/umbra-js/test/utils.test.ts @@ -8,8 +8,20 @@ import { Event } from '../src/ethers'; const ethersProvider = ethers.provider; -const INFURA_ID = process.env.INFURA_ID; -if (!INFURA_ID) throw new Error('Please set your INFURA_ID in a .env file'); +const MAINNET_RPC_URL = process.env.MAINNET_RPC_URL; +if (!MAINNET_RPC_URL) throw new Error('Please set your MAINNET_RPC_URL in a .env file'); + +const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL; +if (!SEPOLIA_RPC_URL) throw new Error('Please set your SEPOLIA_RPC_URL in a .env file'); + +const POLYGON_RPC_URL = process.env.POLYGON_RPC_URL; +if (!POLYGON_RPC_URL) throw new Error('Please set your POLYGON_RPC_URL in a .env file'); + +const OPTIMISM_RPC_URL = process.env.OPTIMISM_RPC_URL; +if (!OPTIMISM_RPC_URL) throw new Error('Please set your OPTIMISM_RPC_URL in a .env file'); + +const ARBITRUM_ONE_RPC_URL = process.env.ARBITRUM_ONE_RPC_URL; +if (!ARBITRUM_ONE_RPC_URL) throw new Error('Please set your ARBITRUM_ONE_RPC_URL in a .env file'); // Public key and address corresponding to stratus4.eth const publicKey = '0x04458465db23fe07d148c8c9078d8b67497998a66f4f2aa479973a9cbaaf8b5a96e6ba166a389b8f794b68010849b64b91343e72c7fa4cfcc178607c4b1d4870ed'; // prettier-ignore @@ -109,21 +121,21 @@ describe('Utilities', () => { // --- Address, advanced mode on (i.e. don't use the StealthKeyRegistry) --- it('looks up recipients by address, advanced mode on', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${String(process.env.INFURA_ID)}`); + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); const keys = await utils.lookupRecipient(address, ethersProvider, { advanced: true }); expect(keys.spendingPublicKey).to.equal(pubKeysWallet.spendingPublicKey); expect(keys.viewingPublicKey).to.equal(pubKeysWallet.viewingPublicKey); }); it('looks up recipients by ENS, advanced mode on', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${String(process.env.INFURA_ID)}`); + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); const keys = await utils.lookupRecipient('stratus4.eth', ethersProvider, { advanced: true }); expect(keys.spendingPublicKey).to.equal(pubKeysWallet.spendingPublicKey); expect(keys.viewingPublicKey).to.equal(pubKeysWallet.viewingPublicKey); }); it.skip('looks up recipients by CNS, advanced mode on', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${INFURA_ID}`); + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); const keys = await utils.lookupRecipient('udtestdev-msolomon.crypto', ethersProvider, { advanced: true }); expect(keys.spendingPublicKey).to.equal(pubKeysWallet.spendingPublicKey); expect(keys.viewingPublicKey).to.equal(pubKeysWallet.viewingPublicKey); @@ -131,7 +143,7 @@ describe('Utilities', () => { // --- Address, advanced mode off (i.e. use the StealthKeyRegistry) --- it('looks up recipients by address, advanced mode off', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${INFURA_ID}`); // otherwise throws with unsupported network since we're on localhost + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); // otherwise throws with unsupported network since we're on localhost const keys = await utils.lookupRecipient(address, ethersProvider); expect(keys.spendingPublicKey).to.equal(pubKeysUmbra.spendingPublicKey); expect(keys.viewingPublicKey).to.equal(pubKeysUmbra.viewingPublicKey); @@ -143,7 +155,7 @@ describe('Utilities', () => { }); it('looks up recipients by ENS, advanced mode off', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${INFURA_ID}`); + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); const keys = await utils.lookupRecipient('stratus4.eth', ethersProvider); // These values are set on the Sepolia resolver expect(keys.spendingPublicKey).to.equal(pubKeysUmbra.spendingPublicKey); @@ -181,37 +193,31 @@ describe('Utilities', () => { // --- Address history by network --- it('looks up transaction history on mainnet', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://mainnet.infura.io/v3/${INFURA_ID}`); + const ethersProvider = new StaticJsonRpcProvider(MAINNET_RPC_URL); const txHash = await utils.getSentTransaction(address, ethersProvider); expect(txHash).to.have.lengthOf(66); }); it('looks up transaction history on sepolia', async () => { - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${INFURA_ID}`); + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); const txHash = await utils.getSentTransaction(address, ethersProvider); expect(txHash).to.have.lengthOf(66); }); it('looks up transaction history on polygon', async () => { - const ethersProvider = new ethers.providers.StaticJsonRpcProvider( - `https://polygon-mainnet.infura.io/v3/${INFURA_ID}` - ) as EthersProvider; + const ethersProvider = new ethers.providers.StaticJsonRpcProvider(POLYGON_RPC_URL) as EthersProvider; const txHash = await utils.getSentTransaction(address, ethersProvider); expect(txHash).to.have.lengthOf(66); }); it('looks up transaction history on optimism', async () => { - const ethersProvider = new ethers.providers.StaticJsonRpcProvider( - `https://optimism-mainnet.infura.io/v3/${INFURA_ID}` - ) as EthersProvider; + const ethersProvider = new ethers.providers.StaticJsonRpcProvider(OPTIMISM_RPC_URL) as EthersProvider; const txHash = await utils.getSentTransaction(address, ethersProvider); expect(txHash).to.have.lengthOf(66); }); it('looks up transaction history on arbitrum one', async () => { - const ethersProvider = new ethers.providers.StaticJsonRpcProvider( - `https://arbitrum-mainnet.infura.io/v3/${INFURA_ID}` - ) as EthersProvider; + const ethersProvider = new ethers.providers.StaticJsonRpcProvider(ARBITRUM_ONE_RPC_URL) as EthersProvider; const txHash = await utils.getSentTransaction(address, ethersProvider); expect(txHash).to.have.lengthOf(66); }); @@ -238,7 +244,7 @@ describe('Utilities', () => { it('throws when looking up an address that has not sent a transaction', async () => { const address = '0x0000000000000000000000000000000000000002'; - const ethersProvider = new StaticJsonRpcProvider(`https://sepolia.infura.io/v3/${INFURA_ID}`); // otherwise throws with unsupported network since we're on localhost + const ethersProvider = new StaticJsonRpcProvider(SEPOLIA_RPC_URL); // otherwise throws with unsupported network since we're on localhost const errorMsg = `Address ${address} has not registered stealth keys. Please ask them to setup their Umbra account`; await expectRejection(utils.lookupRecipient(address, ethersProvider), errorMsg); });