-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add contract concern dependency (#3424)
* Add contract concern dependency
- Loading branch information
Showing
21 changed files
with
114 additions
and
39 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,30 @@ | ||
import { | ||
// eslint-disable-next-line no-restricted-imports | ||
ContractConcern, | ||
SendTransactionOpts, | ||
} from '@/services/web3/transactions/concerns/contract.concern'; | ||
import { initContractConcern } from './contract.concern'; | ||
import { aSigner } from '@tests/unit/builders/signer'; | ||
import { TransactionResponse } from '@ethersproject/abstract-provider'; | ||
import { mock } from 'vitest-mock-extended'; | ||
|
||
export const defaultContractTransactionResponse = mock<TransactionResponse>(); | ||
defaultContractTransactionResponse.chainId = 5; | ||
|
||
export const sendTransactionMock = vi.fn( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
(opts: SendTransactionOpts) => | ||
Promise.resolve(defaultContractTransactionResponse) | ||
); | ||
|
||
export class MockedContractConcern extends ContractConcern { | ||
constructor() { | ||
super(aSigner()); | ||
} | ||
|
||
sendTransaction = (opts: SendTransactionOpts) => sendTransactionMock(opts); | ||
} | ||
|
||
export function initContractConcernWithDefaultMocks() { | ||
initContractConcern(MockedContractConcern); | ||
} |
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,23 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
import { ContractConcern } from '@/services/web3/transactions/concerns/contract.concern'; | ||
import { handleDependencyError } from '.'; | ||
|
||
let contractConcern: typeof ContractConcern | undefined; | ||
|
||
/** | ||
* initContractConcern uses the real Contract Concern instance by default but allows injecting Contract Concern mocks from tests | ||
*/ | ||
export function initContractConcern( | ||
contractConcernInstance: typeof ContractConcern = ContractConcern | ||
) { | ||
contractConcern = contractConcernInstance; | ||
} | ||
|
||
export function getContractConcern() { | ||
if (!contractConcern) { | ||
handleDependencyError('Contract Concern'); | ||
} | ||
return contractConcern; | ||
} | ||
|
||
export type ContractConcernType = ContractConcern; |
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
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
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
6 changes: 5 additions & 1 deletion
6
src/services/balancer/pools/exits/handlers/swap-exit.handler.spec.ts
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
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
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.