import MinimumViableMultisig from "@counterfactual/cf-funding-protocol-contracts/expected-build-artifacts/MinimumViableMultisig.json" ; import Proxy from "@counterfactual/cf-funding-protocol-contracts/expected-build-artifacts/Proxy.json" ; import { getAddress , Interface , keccak256 , solidityKeccak256 } from "ethers/utils" ; import { xkeysToSortedKthAddresses } from "../engine/xkeys" ; export param { string [ ] } owners param { string } proxyFactoryAddress param { string } minimumViableMultisigAddress returns { string } const cache = { } as any ; export function getCreate2MultisigAddress ( owners , proxyFactoryAddress , minimumViableMultisigAddress ) { const cacheKey = owners + proxyFactoryAddress + minimumViableMultisigAddress ; cache [ cacheKey ] = cache [ cacheKey ] || getAddress ( solidityKeccak256 ( [ "bytes1" , "address" , "uint256" , "bytes32" ] , [ "0xff" , proxyFactoryAddress , solidityKeccak256 ( [ "bytes32" , "uint256" ] , [ keccak256 ( new Interface ( MinimumViableMultisig . abi ) . functions . setup . encode ( [ xkeysToSortedKthAddresses ( owners , 0 ) ] ) ) , 0 ] ) , solidityKeccak256 ( [ "bytes" , "uint256" ] , [ `0x${ Proxy . evm . bytecode . object }` , minimumViableMultisigAddress ] ) ] ) . slice ( - 40 ) ) ; return cache [ cacheKey ] ; }