|
7 | 7 | IdentityTypes, |
8 | 8 | RequestLogicTypes, |
9 | 9 | } from '@requestnetwork/types'; |
10 | | -import { providers, Wallet } from 'ethers'; |
| 10 | +import { providers, Wallet, utils } from 'ethers'; |
11 | 11 | import { |
12 | 12 | deploySingleRequestProxy, |
13 | 13 | payRequestWithSingleRequestProxy, |
@@ -168,55 +168,56 @@ describe('deploySingleRequestProxy', () => { |
168 | 168 | it('should deploy EthereumSingleRequestProxy and emit event', async () => { |
169 | 169 | const singleRequestProxyFactory = singleRequestProxyFactoryArtifact.connect('private', wallet); |
170 | 170 |
|
171 | | - // Get the initial event count |
172 | 171 | const initialEventCount = await provider.getBlockNumber(); |
173 | 172 |
|
| 173 | + const walletAddress = await wallet.getAddress(); |
| 174 | + |
174 | 175 | const proxyAddress = await deploySingleRequestProxy(ethRequest, wallet); |
175 | 176 |
|
176 | 177 | expect(proxyAddress).toBeDefined(); |
177 | 178 | expect(typeof proxyAddress).toBe('string'); |
178 | 179 | expect(proxyAddress).toMatch(/^0x[a-fA-F0-9]{40}$/); |
179 | 180 |
|
180 | | - // Get the latest events |
181 | 181 | const latestBlock = await provider.getBlockNumber(); |
182 | 182 | const events = await singleRequestProxyFactory.queryFilter( |
183 | 183 | singleRequestProxyFactory.filters.EthereumSingleRequestProxyCreated(), |
184 | 184 | initialEventCount, |
185 | 185 | latestBlock, |
186 | 186 | ); |
187 | 187 |
|
188 | | - // Check if the event was emitted with the correct parameters |
189 | | - const event = events.find((e) => e.args?.proxyAddress === proxyAddress); |
190 | | - expect(event).toBeDefined(); |
191 | | - expect(event?.args?.payee).toBe(paymentAddress); |
192 | | - expect(event?.args?.paymentReference).toBeDefined(); |
| 188 | + expect(events.length).toBeGreaterThan(0); |
| 189 | + |
| 190 | + const eventData = utils.defaultAbiCoder.decode(['address', 'address'], events[0].data); |
| 191 | + |
| 192 | + expect(eventData[0]).toBe(proxyAddress); |
| 193 | + expect(eventData[1]).toBe(walletAddress); |
193 | 194 | }); |
194 | 195 |
|
195 | 196 | it('should deploy ERC20SingleRequestProxy and emit event', async () => { |
196 | 197 | const singleRequestProxyFactory = singleRequestProxyFactoryArtifact.connect('private', wallet); |
197 | 198 |
|
198 | | - // Get the initial event count |
199 | 199 | const initialEventCount = await provider.getBlockNumber(); |
200 | 200 |
|
| 201 | + const walletAddress = await wallet.getAddress(); |
| 202 | + |
201 | 203 | const proxyAddress = await deploySingleRequestProxy(erc20Request, wallet); |
202 | 204 |
|
203 | 205 | expect(proxyAddress).toBeDefined(); |
204 | 206 | expect(typeof proxyAddress).toBe('string'); |
205 | 207 | expect(proxyAddress).toMatch(/^0x[a-fA-F0-9]{40}$/); |
206 | 208 |
|
207 | | - // Get the latest events |
208 | 209 | const latestBlock = await provider.getBlockNumber(); |
209 | 210 | const events = await singleRequestProxyFactory.queryFilter( |
210 | 211 | singleRequestProxyFactory.filters.ERC20SingleRequestProxyCreated(), |
211 | 212 | initialEventCount, |
212 | 213 | latestBlock, |
213 | 214 | ); |
214 | 215 |
|
215 | | - // Check if the event was emitted with the correct parameters |
216 | | - const event = events.find((e) => e.args?.proxyAddress === proxyAddress); |
217 | | - expect(event).toBeDefined(); |
218 | | - expect(event?.args?.payee).toBe(paymentAddress); |
219 | | - expect(event?.args?.paymentReference).toBeDefined(); |
| 216 | + expect(events.length).toBeGreaterThan(0); |
| 217 | + |
| 218 | + const eventData = utils.defaultAbiCoder.decode(['address', 'address'], events[0].data); |
| 219 | + |
| 220 | + expect(eventData[0]).toBe(proxyAddress); |
220 | 221 | }); |
221 | 222 |
|
222 | 223 | it('should throw error when trying to pay with invalid single request proxy', async () => { |
|
0 commit comments