import { utils } from "ethers" ; import path from "path" ; export function convertLibraryNameToLinkId ( libraryName ) { 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 ) }$__` ; }