From bae7c9c5269c48abe9a59929f5e2e3142e6eec1c Mon Sep 17 00:00:00 2001 From: sakulstra Date: Thu, 15 Feb 2024 16:22:54 +0100 Subject: [PATCH] fix: add lookbehind --- .../features/__snapshots__/priceFeedsUpdate.spec.ts.snap | 2 +- generator/features/__snapshots__/rateUpdates.spec.ts.snap | 2 +- generator/utils/importsResolver.spec.ts | 5 +++-- generator/utils/importsResolver.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/generator/features/__snapshots__/priceFeedsUpdate.spec.ts.snap b/generator/features/__snapshots__/priceFeedsUpdate.spec.ts.snap index b9a3489dc..ef008b88c 100644 --- a/generator/features/__snapshots__/priceFeedsUpdate.spec.ts.snap +++ b/generator/features/__snapshots__/priceFeedsUpdate.spec.ts.snap @@ -55,7 +55,7 @@ export const config: ConfigFile = { "payload": "// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {AaveV3ConfigEngine, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveV3EthereumAssets, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {AaveV3PayloadEthereum} from 'aave-helpers/v3-config-engine/AaveV3PayloadEthereum.sol'; import {IAaveV3ConfigEngine} from 'aave-helpers/v3-config-engine/IAaveV3ConfigEngine.sol'; diff --git a/generator/features/__snapshots__/rateUpdates.spec.ts.snap b/generator/features/__snapshots__/rateUpdates.spec.ts.snap index 62e3e6afe..662698aef 100644 --- a/generator/features/__snapshots__/rateUpdates.spec.ts.snap +++ b/generator/features/__snapshots__/rateUpdates.spec.ts.snap @@ -109,7 +109,7 @@ export const config: ConfigFile = { "payload": "// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {AaveV2ConfigEngine, AaveV2EthereumAMMAssets} from 'aave-address-book/AaveV2EthereumAMM.sol'; +import {AaveV2EthereumAMMAssets, AaveV2EthereumAMMAssets} from 'aave-address-book/AaveV2EthereumAMM.sol'; import {AaveV3PayloadEthereum} from 'aave-helpers/v3-config-engine/AaveV3PayloadEthereum.sol'; import {EngineFlags} from 'aave-helpers/v3-config-engine/EngineFlags.sol'; import {IAaveV2ConfigEngine} from 'aave-helpers/v2-config-engine/IAaveV2ConfigEngine.sol'; diff --git a/generator/utils/importsResolver.spec.ts b/generator/utils/importsResolver.spec.ts index 400ba34e8..e038802e5 100644 --- a/generator/utils/importsResolver.spec.ts +++ b/generator/utils/importsResolver.spec.ts @@ -26,13 +26,14 @@ describe('prefixWithImports', () => { }); it('should detect v2 Engine imports', () => { - expect(prefixWithImports('IAaveV2ConfigEngine.RateStrategyUpdate')).toContain( + const result = prefixWithImports('IAaveV2ConfigEngine.RateStrategyUpdate'); + console.log(result); + expect(result).toContain( `import {IAaveV2ConfigEngine} from 'aave-helpers/v2-config-engine/IAaveV2ConfigEngine.sol';` ); }); it('should detect addressbook imports', () => { - console.log(prefixWithImports('AaveV2Ethereum.POOL AaveV2EthereumAssets.DAI')); expect(prefixWithImports('AaveV2Ethereum.POOL AaveV2EthereumAssets.DAI')).toContain( `import {AaveV2Ethereum,AaveV2EthereumAssets} from 'aave-address-book/AaveV2Ethereum.sol';` ); diff --git a/generator/utils/importsResolver.ts b/generator/utils/importsResolver.ts index 3542c470e..b14124f1e 100644 --- a/generator/utils/importsResolver.ts +++ b/generator/utils/importsResolver.ts @@ -17,7 +17,7 @@ const GovernanceImports = [ function generateAddressBookImports(code: string) { const imports: string[] = []; let root = ''; - const addressBookMatch = code.match(/(AaveV[2..3][A-Za-z]+)\./); + const addressBookMatch = code.match(/(?