diff --git a/src/contracts/IntentSource.contract.ts b/src/contracts/IntentSource.contract.ts index 4f299c8..808126a 100644 --- a/src/contracts/IntentSource.contract.ts +++ b/src/contracts/IntentSource.contract.ts @@ -103,7 +103,7 @@ export const IntentSourceAbi = [ type: 'uint256[]', }, { - indexed: false, + indexed: true, internalType: 'uint256', name: '_expiryTime', type: 'uint256', @@ -115,7 +115,7 @@ export const IntentSourceAbi = [ type: 'bytes32', }, { - indexed: true, + indexed: false, internalType: 'address', name: '_prover', type: 'address', diff --git a/src/intent/tests/watch-intent.service.spec.ts b/src/intent/tests/watch-intent.service.spec.ts index 0559344..389a379 100644 --- a/src/intent/tests/watch-intent.service.spec.ts +++ b/src/intent/tests/watch-intent.service.spec.ts @@ -68,7 +68,7 @@ describe('WatchIntentService', () => { it('should subscribe to all source intents', async () => { const mockWatch = jest.fn() publicClientService.getClient.mockResolvedValue({ - watchContractEvent: mockWatch + watchContractEvent: mockWatch, } as any) ecoConfigService.getSourceIntents.mockReturnValue(sources) ecoConfigService.getSolvers.mockReturnValue(sources) @@ -78,9 +78,11 @@ describe('WatchIntentService', () => { for (const [index, s] of sources.entries()) { const { address, eventName, args } = mockWatch.mock.calls[index][0] const partial = { address, eventName, args } - expect(partial).toEqual( - { address: s.sourceAddress, eventName: 'IntentCreated', args: { _destinationChain: supportedChains, _prover: s.provers } } - ) + expect(partial).toEqual({ + address: s.sourceAddress, + eventName: 'IntentCreated', + args: { _destinationChain: supportedChains}// TODO include in next release of contracts , _prover: s.provers }, + }) } }) }) @@ -95,7 +97,7 @@ describe('WatchIntentService', () => { it('should unsubscribe to all source intents', async () => { const mockUnwatch = jest.fn() publicClientService.getClient.mockResolvedValue({ - watchContractEvent: () => mockUnwatch + watchContractEvent: () => mockUnwatch, } as any) ecoConfigService.getSourceIntents.mockReturnValue(sources) ecoConfigService.getSolvers.mockReturnValue(sources) @@ -119,23 +121,27 @@ describe('WatchIntentService', () => { it('should convert all bigints to strings', async () => { expect(mockLogDebug.mock.calls[0][0].createIntent).toEqual( expect.objectContaining({ - args: { _hash: '1', logIndex: '2' } - }) + args: { _hash: '1', logIndex: '2' }, + }), ) - }) it('should should attach source chainID and network', async () => { expect(mockLogDebug.mock.calls[0][0].createIntent).toEqual( expect.objectContaining({ - sourceChainID: s.chainID, sourceNetwork: s.network - }) + sourceChainID: s.chainID, + sourceNetwork: s.network, + }), ) }) it('should should enque a job for every intent', async () => { expect(mockQueueAdd).toHaveBeenCalledTimes(1) - expect(mockQueueAdd).toHaveBeenCalledWith(QUEUES.SOURCE_INTENT.jobs.create_intent, expect.any(Object), { "jobId": "watch-1-0" }) + expect(mockQueueAdd).toHaveBeenCalledWith( + QUEUES.SOURCE_INTENT.jobs.create_intent, + expect.any(Object), + { jobId: 'watch-1-0' }, + ) }) }) }) diff --git a/src/intent/watch-intent.service.ts b/src/intent/watch-intent.service.ts index 26645d4..74e49f7 100644 --- a/src/intent/watch-intent.service.ts +++ b/src/intent/watch-intent.service.ts @@ -70,8 +70,8 @@ export class WatchIntentService implements OnApplicationBootstrap, OnModuleDestr args: { // restrict by acceptable chains, chain ids must be bigints _destinationChain: solverSupportedChains, - // restrict by acceptable prover - _prover: source.provers, + // TODO redeploy once we are using the new contract addressess with the new abi restrict by acceptable prover + // _prover: source.provers, }, onLogs: this.addJob(source), }) diff --git a/src/solver/filters/tests/valid-smart-wallet.service.spec.ts b/src/solver/filters/tests/valid-smart-wallet.service.spec.ts index 6972fea..30221aa 100644 --- a/src/solver/filters/tests/valid-smart-wallet.service.spec.ts +++ b/src/solver/filters/tests/valid-smart-wallet.service.spec.ts @@ -61,9 +61,7 @@ describe('ValidSmartWalletService Tests', () => { } }) const result = await validWalletService.validateSmartWallet('0x789', 1n) - //todo restore this - // expect(result).toEqual(false) - expect(result).toEqual(true) + expect(result).toEqual(false) }) it('should return false if the SA address is from another factory', async () => { @@ -73,9 +71,7 @@ describe('ValidSmartWalletService Tests', () => { } }) const result = await validWalletService.validateSmartWallet('0x789', 1n) - //todo restore this - // expect(result).toEqual(false) - expect(result).toEqual(true) + expect(result).toEqual(false) }) it('should return true if the SA is from our factory', async () => { diff --git a/src/solver/filters/valid-smart-wallet.service.ts b/src/solver/filters/valid-smart-wallet.service.ts index b94a22c..9424a58 100644 --- a/src/solver/filters/valid-smart-wallet.service.ts +++ b/src/solver/filters/valid-smart-wallet.service.ts @@ -1,11 +1,14 @@ -import { Injectable, OnModuleInit } from '@nestjs/common' +import { Injectable, Logger, OnModuleInit } from '@nestjs/common' import { MultichainPublicClientService } from '../../transaction/multichain-public-client.service' import { EcoConfigService } from '../../eco-configs/eco-config.service' import { Hex } from 'viem' import { EntryPointAbi_v6 } from '../../contracts/EntryPoint.V6.contract' +import { EcoLogMessage } from '../../common/logging/eco-log-message' @Injectable() export class ValidSmartWalletService implements OnModuleInit { + private logger = new Logger(ValidSmartWalletService.name) + private entryPointAddress: Hex private factoryAddress: Hex constructor( @@ -27,19 +30,31 @@ export class ValidSmartWalletService implements OnModuleInit { */ async validateSmartWallet(smartWalletAddress: Hex, chainID: bigint): Promise { //TODO fix this - return true - // const client = await this.publicClient.getClient(chainID) - // const deployedEvents = await client.getContractEvents({ - // address: this.entryPointAddress, - // abi: EntryPointAbi_v6, - // eventName: 'AccountDeployed', - // args: { sender: smartWalletAddress }, - // fromBlock: 0n, - // toBlock: 'latest', - // }) - // //should be only one event, but comes as an array - // return ( - // deployedEvents && deployedEvents.some((event) => event.args.factory === this.factoryAddress) - // ) + // return true + const client = await this.publicClient.getClient(Number(chainID)) + try { + const deployedEvents = await client.getContractEvents({ + address: this.entryPointAddress, + abi: EntryPointAbi_v6, + eventName: 'AccountDeployed', + args: { sender: smartWalletAddress }, + fromBlock: 0n, + toBlock: 'latest', + }) + //should be only one event, but comes as an array + return ( + deployedEvents && deployedEvents.some((event) => event.args.factory === this.factoryAddress) + ) + } catch (error) { + this.logger.error( + EcoLogMessage.fromDefault({ + message: `RPC: getContractEvents error`, + properties: { + error, + }, + }), + ) + return false + } } }