hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
18 lines (15 loc) • 472 B
text/typescript
export function applyRemappings(
remappings: Record<string, string>,
sourceName: string
): string {
const selectedRemapping = { from: "", to: "" };
for (const [from, to] of Object.entries(remappings)) {
if (
sourceName.startsWith(from) &&
from.length >= selectedRemapping.from.length
) {
[ ] = [from, to];
}
}
return sourceName.replace(selectedRemapping.from, selectedRemapping.to);
}