Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe("CompoundUniswapLeverageDebtIssuance", () => {
compoundSetup.comptroller.address,
cEther.address,
setup.weth.address,
"Compound",
"contracts/protocol/integration/lib/Compound.sol:Compound",
compoundLibrary.address,
);
await setup.controller.addModule(compoundLeverageModule.address);
Expand Down
5 changes: 4 additions & 1 deletion test/protocol/integration/lib/compound.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ describe("Compound", () => {
await setup.initialize();

compoundLib = await deployer.libraries.deployCompound();
compoundLibMock = await deployer.mocks.deployCompoundMock("Compound", compoundLib.address);
compoundLibMock = await deployer.mocks.deployCompoundMock(
"contracts/protocol/integration/lib/Compound.sol:Compound",
compoundLib.address
);
invokeLibMock = await deployer.mocks.deployInvokeMock();
await setup.controller.addModule(compoundLibMock.address);
await setup.controller.addModule(invokeLibMock.address);
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/modules/compoundLeverageModule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe("CompoundLeverageModule", () => {
compoundSetup.comptroller.address,
cEther.address,
setup.weth.address,
"Compound",
"contracts/protocol/integration/lib/Compound.sol:Compound",
compoundLibrary.address,
);
await setup.controller.addModule(compoundLeverageModule.address);
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/modules/compoundLeverageModule2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe("CompoundLeverageModule TestSuite 2", () => {
compoundSetup.comptroller.address,
cEther.address,
setup.weth.address,
"Compound",
"contracts/protocol/integration/lib/Compound.sol:Compound",
compoundLibrary.address,
);
await setup.controller.addModule(compoundLeverageModule.address);
Expand Down
3 changes: 3 additions & 0 deletions utils/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ export {
calculateTokensInReserve,
getReservesSafe
} from "./uniswapUtils";
export {
convertLibraryNameToLinkId
} from "./libraryUtils";
16 changes: 16 additions & 0 deletions utils/common/libraryUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { utils } from "ethers";
import path from "path";

// Converts a fully qualified contract name in a bytecode link id.
// (A fully qualified name looks like: `contracts/mocks/LibraryMock.sol:LibraryMock`)
export function convertLibraryNameToLinkId(libraryName: string): string {
if (!(libraryName.includes(path.sep) && libraryName.includes(":"))) {
throw new Error(
"Converting library name to link id requires a fully qualified " +
"contract name. Example: `contracts/mocks/LibraryMock.sol:LibraryMock`"
);
}

const hashedName = utils.keccak256(utils.toUtf8Bytes(libraryName));
return `__$${hashedName.slice(2).slice(0, 34)}$__`;
}
3 changes: 1 addition & 2 deletions utils/deploys/deployMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ import {
ZeroExMock,
} from "../contracts";

import { ether } from "../common";
import { convertLibraryNameToLinkId } from "../test";
import { convertLibraryNameToLinkId, ether } from "../common";

import { AaveLendingPoolCoreMock__factory } from "../../typechain/factories/AaveLendingPoolCoreMock__factory";
import { AaveLendingPoolMock__factory } from "../../typechain/factories/AaveLendingPoolMock__factory";
Expand Down
2 changes: 1 addition & 1 deletion utils/deploys/deployModules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Signer } from "ethers";
import { convertLibraryNameToLinkId } from "../test";
import { convertLibraryNameToLinkId } from "../common";

import {
AirdropModule,
Expand Down
3 changes: 0 additions & 3 deletions utils/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,3 @@ export {
mineBlockAsync,
cacheBeforeEach
} from "./testingUtils";
export {
convertLibraryNameToLinkId
} from "./libraryUtils";
22 changes: 0 additions & 22 deletions utils/test/libraryUtils.ts

This file was deleted.