safe-global / safe-deployments

A collection of Safe singleton deployments
MIT License
123 stars 230 forks source link

Different proxy factory for Optimism Goerli #163

Closed 0xslipk closed 1 year ago

0xslipk commented 1 year ago

Hello guys,

I am trying to predict the safe address with create2 for a cross-chain Safe for goerli, mumbai, optimism-goerli, aurora-testnet, arbitrum-goerli, avalanche-fuji and binance-testnet. The problem is that I am using the proxy factory address as first parameter for getCreate2Address, but optimism-goerli on proxy_factory.json has different address that for example goerli. is this an error or correct?.

I am asking, because I can found the goerli address on optimism-goerli.

Thank you in advance.

moisses89 commented 1 year ago

It is not an error, they used different deterministic deployment proxy ( singleton-factory ) to create them. that's the reason for have two different addresses.

moisses89 commented 1 year ago

@0xslipk related your question https://github.com/safe-global/safe-contracts/issues/460 If no more concerns about this, the issue should be closed. :sweat_smile:

sunliang711 commented 1 year ago

If I want to use the same safe address on all networks, this can't be done, that's so bad ):

0xslipk commented 1 year ago

@0xslipk related your question https://github.com/safe-global/safe-contracts/issues/460

If no more concerns about this, the issue should be closed. :sweat_smile:

Awesome thank you 🙏

0xslipk commented 1 year ago

If I want to use the same safe address on all networks, this can't be done, that's so bad ):

I actually did, so It can be done. 😬

sunliang711 commented 1 year ago

If I want to use the same safe address on all networks, this can't be done, that's so bad ):

I actually did, so It can be done. 😬

How did you do that ? I have used the safe sdk to predict safe address with same owners same threshold and same salt, but the address of optimistic chain is different with others (ethereum polygon bsc arbitrum are the same). This is my code:

export async function deploySafe(rpc: string, privateKey: string, owners: Array<string>, threshold: number, nonce: string, dryRun: boolean,isL1SafeMasterCopy: boolean) {
    // check owners duplicate
    if (new Set(owners).size != owners.length) {
        throw new Error("duplicate owners")
    }

    if (threshold > owners.length) {
        throw new Error("threshold greater than owners count")
    }

    owners.forEach(owner => {
        checkAddress(owner, `owner: ${owner} is not an valid address`)
    })

    const ethAdapter = createAdapter(rpc, privateKey)
    const sender = await ethAdapter.getSigner()?.getAddress()
    console.log("deployer:", sender)
    const safeFactory = await SafeFactory.create({ ethAdapter,isL1SafeMasterCopy })

    const saltNonce = nonce.length > 0 ? nonce : Date.now().toString()
    console.log("nonce:", saltNonce)

    const safeDeploymentConfig: SafeDeploymentConfig = {
        saltNonce
    }

    const safeAccountConfig: SafeAccountConfig = {
        owners,
        threshold
    }

    // predict deployed address
    console.log("predict deploy address..")
    const predictedDeployAddress = await safeFactory.predictSafeAddress({
        safeAccountConfig,
        safeDeploymentConfig
    })
    console.log('Predicted deployed address:', predictedDeployAddress)
    if (dryRun) {
        return
    }

    function callback(txHash: string) {
        console.log('Transaction hash:', txHash)
    }

    console.log("deploy..")
    const safe: Safe = await safeFactory.deploySafe({
        safeAccountConfig,
        safeDeploymentConfig,
        callback
    })
    const newSafeAddress = safe.getAddress()

    console.log('Deployed Safe:', newSafeAddress)
}

I found the proxy factory address on optimistic is different