@@ -8,8 +8,20 @@ import { Event } from '../src/ethers';
8
8
9
9
const ethersProvider = ethers . provider ;
10
10
11
- const INFURA_ID = < string > process . env . INFURA_ID ;
12
- if ( ! INFURA_ID ) throw new Error ( 'Please set your INFURA_ID in a .env file' ) ;
11
+ const MAINNET_RPC_URL = < string > process . env . MAINNET_RPC_URL ;
12
+ if ( ! MAINNET_RPC_URL ) throw new Error ( 'Please set your MAINNET_RPC_URL in a .env file' ) ;
13
+
14
+ const SEPOLIA_RPC_URL = < string > process . env . SEPOLIA_RPC_URL ;
15
+ if ( ! SEPOLIA_RPC_URL ) throw new Error ( 'Please set your SEPOLIA_RPC_URL in a .env file' ) ;
16
+
17
+ const POLYGON_RPC_URL = < string > process . env . POLYGON_RPC_URL ;
18
+ if ( ! POLYGON_RPC_URL ) throw new Error ( 'Please set your POLYGON_RPC_URL in a .env file' ) ;
19
+
20
+ const OPTIMISM_RPC_URL = < string > process . env . OPTIMISM_RPC_URL ;
21
+ if ( ! OPTIMISM_RPC_URL ) throw new Error ( 'Please set your OPTIMISM_RPC_URL in a .env file' ) ;
22
+
23
+ const ARBITRUM_ONE_RPC_URL = < string > process . env . ARBITRUM_ONE_RPC_URL ;
24
+ if ( ! ARBITRUM_ONE_RPC_URL ) throw new Error ( 'Please set your ARBITRUM_ONE_RPC_URL in a .env file' ) ;
13
25
14
26
// Public key and address corresponding to stratus4.eth
15
27
const publicKey = '0x04458465db23fe07d148c8c9078d8b67497998a66f4f2aa479973a9cbaaf8b5a96e6ba166a389b8f794b68010849b64b91343e72c7fa4cfcc178607c4b1d4870ed' ; // prettier-ignore
@@ -109,29 +121,29 @@ describe('Utilities', () => {
109
121
110
122
// --- Address, advanced mode on (i.e. don't use the StealthKeyRegistry) ---
111
123
it ( 'looks up recipients by address, advanced mode on' , async ( ) => {
112
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ String ( process . env . INFURA_ID ) } ` ) ;
124
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ;
113
125
const keys = await utils . lookupRecipient ( address , ethersProvider , { advanced : true } ) ;
114
126
expect ( keys . spendingPublicKey ) . to . equal ( pubKeysWallet . spendingPublicKey ) ;
115
127
expect ( keys . viewingPublicKey ) . to . equal ( pubKeysWallet . viewingPublicKey ) ;
116
128
} ) ;
117
129
118
130
it ( 'looks up recipients by ENS, advanced mode on' , async ( ) => {
119
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ String ( process . env . INFURA_ID ) } ` ) ;
131
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ;
120
132
const keys = await utils . lookupRecipient ( 'stratus4.eth' , ethersProvider , { advanced : true } ) ;
121
133
expect ( keys . spendingPublicKey ) . to . equal ( pubKeysWallet . spendingPublicKey ) ;
122
134
expect ( keys . viewingPublicKey ) . to . equal ( pubKeysWallet . viewingPublicKey ) ;
123
135
} ) ;
124
136
125
137
it . skip ( 'looks up recipients by CNS, advanced mode on' , async ( ) => {
126
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ INFURA_ID } ` ) ;
138
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ;
127
139
const keys = await utils . lookupRecipient ( 'udtestdev-msolomon.crypto' , ethersProvider , { advanced : true } ) ;
128
140
expect ( keys . spendingPublicKey ) . to . equal ( pubKeysWallet . spendingPublicKey ) ;
129
141
expect ( keys . viewingPublicKey ) . to . equal ( pubKeysWallet . viewingPublicKey ) ;
130
142
} ) ;
131
143
132
144
// --- Address, advanced mode off (i.e. use the StealthKeyRegistry) ---
133
145
it ( 'looks up recipients by address, advanced mode off' , async ( ) => {
134
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ INFURA_ID } ` ) ; // otherwise throws with unsupported network since we're on localhost
146
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ; // otherwise throws with unsupported network since we're on localhost
135
147
const keys = await utils . lookupRecipient ( address , ethersProvider ) ;
136
148
expect ( keys . spendingPublicKey ) . to . equal ( pubKeysUmbra . spendingPublicKey ) ;
137
149
expect ( keys . viewingPublicKey ) . to . equal ( pubKeysUmbra . viewingPublicKey ) ;
@@ -143,7 +155,7 @@ describe('Utilities', () => {
143
155
} ) ;
144
156
145
157
it ( 'looks up recipients by ENS, advanced mode off' , async ( ) => {
146
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ INFURA_ID } ` ) ;
158
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ;
147
159
const keys = await utils . lookupRecipient ( 'stratus4.eth' , ethersProvider ) ;
148
160
// These values are set on the Sepolia resolver
149
161
expect ( keys . spendingPublicKey ) . to . equal ( pubKeysUmbra . spendingPublicKey ) ;
@@ -181,37 +193,31 @@ describe('Utilities', () => {
181
193
182
194
// --- Address history by network ---
183
195
it ( 'looks up transaction history on mainnet' , async ( ) => {
184
- const ethersProvider = new StaticJsonRpcProvider ( `https://mainnet.infura.io/v3/ ${ INFURA_ID } ` ) ;
196
+ const ethersProvider = new StaticJsonRpcProvider ( MAINNET_RPC_URL ) ;
185
197
const txHash = await utils . getSentTransaction ( address , ethersProvider ) ;
186
198
expect ( txHash ) . to . have . lengthOf ( 66 ) ;
187
199
} ) ;
188
200
189
201
it ( 'looks up transaction history on sepolia' , async ( ) => {
190
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ INFURA_ID } ` ) ;
202
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ;
191
203
const txHash = await utils . getSentTransaction ( address , ethersProvider ) ;
192
204
expect ( txHash ) . to . have . lengthOf ( 66 ) ;
193
205
} ) ;
194
206
195
207
it ( 'looks up transaction history on polygon' , async ( ) => {
196
- const ethersProvider = new ethers . providers . StaticJsonRpcProvider (
197
- `https://polygon-mainnet.infura.io/v3/${ INFURA_ID } `
198
- ) as EthersProvider ;
208
+ const ethersProvider = new ethers . providers . StaticJsonRpcProvider ( POLYGON_RPC_URL ) as EthersProvider ;
199
209
const txHash = await utils . getSentTransaction ( address , ethersProvider ) ;
200
210
expect ( txHash ) . to . have . lengthOf ( 66 ) ;
201
211
} ) ;
202
212
203
213
it ( 'looks up transaction history on optimism' , async ( ) => {
204
- const ethersProvider = new ethers . providers . StaticJsonRpcProvider (
205
- `https://optimism-mainnet.infura.io/v3/${ INFURA_ID } `
206
- ) as EthersProvider ;
214
+ const ethersProvider = new ethers . providers . StaticJsonRpcProvider ( OPTIMISM_RPC_URL ) as EthersProvider ;
207
215
const txHash = await utils . getSentTransaction ( address , ethersProvider ) ;
208
216
expect ( txHash ) . to . have . lengthOf ( 66 ) ;
209
217
} ) ;
210
218
211
219
it ( 'looks up transaction history on arbitrum one' , async ( ) => {
212
- const ethersProvider = new ethers . providers . StaticJsonRpcProvider (
213
- `https://arbitrum-mainnet.infura.io/v3/${ INFURA_ID } `
214
- ) as EthersProvider ;
220
+ const ethersProvider = new ethers . providers . StaticJsonRpcProvider ( ARBITRUM_ONE_RPC_URL ) as EthersProvider ;
215
221
const txHash = await utils . getSentTransaction ( address , ethersProvider ) ;
216
222
expect ( txHash ) . to . have . lengthOf ( 66 ) ;
217
223
} ) ;
@@ -238,7 +244,7 @@ describe('Utilities', () => {
238
244
239
245
it ( 'throws when looking up an address that has not sent a transaction' , async ( ) => {
240
246
const address = '0x0000000000000000000000000000000000000002' ;
241
- const ethersProvider = new StaticJsonRpcProvider ( `https://sepolia.infura.io/v3/ ${ INFURA_ID } ` ) ; // otherwise throws with unsupported network since we're on localhost
247
+ const ethersProvider = new StaticJsonRpcProvider ( SEPOLIA_RPC_URL ) ; // otherwise throws with unsupported network since we're on localhost
242
248
const errorMsg = `Address ${ address } has not registered stealth keys. Please ask them to setup their Umbra account` ;
243
249
await expectRejection ( utils . lookupRecipient ( address , ethersProvider ) , errorMsg ) ;
244
250
} ) ;
0 commit comments