-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: exclude eligible intersections
- Loading branch information
Showing
9 changed files
with
213 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './lido.module'; | ||
export * from './lido.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { LidoService } from './lido.service'; | ||
|
||
@Module({ | ||
providers: [LidoService], | ||
exports: [LidoService], | ||
}) | ||
export class LidoModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Test } from '@nestjs/testing'; | ||
import { ConfigModule } from 'common/config'; | ||
import { LoggerModule } from 'common/logger'; | ||
import { MockProviderModule, ProviderService } from 'provider'; | ||
import { LidoAbi__factory } from 'generated'; | ||
import { RepositoryModule } from 'contracts/repository'; | ||
import { Interface } from '@ethersproject/abi'; | ||
import { LidoService } from './lido.service'; | ||
import { LidoModule } from './lido.module'; | ||
|
||
describe('SecurityService', () => { | ||
let lidoService: LidoService; | ||
let providerService: ProviderService; | ||
|
||
beforeEach(async () => { | ||
const moduleRef = await Test.createTestingModule({ | ||
imports: [ | ||
ConfigModule.forRoot(), | ||
MockProviderModule.forRoot(), | ||
LoggerModule, | ||
LidoModule, | ||
RepositoryModule, | ||
], | ||
}).compile(); | ||
|
||
lidoService = moduleRef.get(LidoService); | ||
providerService = moduleRef.get(ProviderService); | ||
}); | ||
|
||
describe('getWithdrawalCredentials', () => { | ||
it('should return withdrawal credentials', async () => { | ||
const expected = '0x' + '1'.repeat(64); | ||
|
||
const mockProviderCall = jest | ||
.spyOn(providerService.provider, 'call') | ||
.mockImplementation(async () => { | ||
const iface = new Interface(LidoAbi__factory.abi); | ||
const result = [expected]; | ||
return iface.encodeFunctionResult('getWithdrawalCredentials', result); | ||
}); | ||
|
||
const wc = await lidoService.getWithdrawalCredentials(); | ||
expect(wc).toBe(expected); | ||
expect(mockProviderCall).toBeCalledTimes(1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { RepositoryService } from 'contracts/repository'; | ||
import { BlockTag } from 'provider'; | ||
|
||
@Injectable() | ||
export class LidoService { | ||
constructor(private repositoryService: RepositoryService) {} | ||
|
||
/** | ||
* Returns withdrawal credentials from the contract | ||
*/ | ||
public async getWithdrawalCredentials(blockTag?: BlockTag): Promise<string> { | ||
const contract = await this.repositoryService.getCachedLidoContract(); | ||
|
||
return await contract.getWithdrawalCredentials({ | ||
blockTag: blockTag as any, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.