Skip to content

Commit

Permalink
fix: add lookbehind
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Feb 15, 2024
1 parent 80dc44f commit bae7c9c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion generator/features/__snapshots__/rateUpdates.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 3 additions & 2 deletions generator/utils/importsResolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';`
);
Expand Down
2 changes: 1 addition & 1 deletion generator/utils/importsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(/(?<!I)(AaveV[2..3][A-Za-z]+)\./);
if (addressBookMatch) {
imports.push(addressBookMatch[1]);
root = addressBookMatch[1];
Expand Down

0 comments on commit bae7c9c

Please sign in to comment.