Skip to content

feat(Protocol-kit): H3Error: SafeProxy was not deployed correctly #505

@franvf

Description

@franvf

Description

I'm trying to deploy a safe wallet, but the function deploySafe() returns the error: SafeProxy was not deployed correctly. But, if I check the tx hash, the SafeProxy is deployed successfully.

I have solved this locally modifying the @safe-global/protocol-kit/src/adapters/web3/contracts/SafeProxyFactory/SafeProxyFactoryWeb3Contract.js file

What I have modified in this file is:
Original file (not works)

const txResponse = this.contract.methods
            .createProxyWithNonce(safeMasterCopyAddress, initializer, saltNonce)
            .send(options);
        if (callback) {
            const txResult = await (0, utils_1.toTxResult)(txResponse);
            callback(txResult.hash);
        }
        const txResult = await new Promise((resolve, reject) => txResponse.once('receipt', (receipt) => resolve(receipt)).catch(reject));
        const proxyAddress = (_c = (_b = (_a = txResult.events) === null || _a === void 0 ? void 0 : _a.ProxyCreation) === null || _b === void 0 ? void 0 : _b.returnValues) === null || _c === void 0 ? void 0 : _c.proxy;
        if (!proxyAddress) {
            throw new Error('SafeProxy was not deployed correctly');
        }
        return proxyAddress;
    }

My modified file (work)

 const txResponse = this.contract.methods
            .createProxyWithNonce(safeMasterCopyAddress, initializer, saltNonce)
            .send(options);
        if (callback) {
            const txResult = await (0, utils_1.toTxResult)(txResponse);
            callback(txResult.hash);
        }
        const txResult = await new Promise((resolve, reject) => txResponse.once('receipt', (receipt) => resolve(receipt)).catch(reject));
        
        //MY CODE START HERE
        const events = await this.contract.getPastEvents("ProxyCreation")
        const proxyAddress = events[0]['returnValues']['0'] //Get the deployed safe proxy address
        
        if (proxyAddress == "0x0000000000000000000000000000000000000000") {
            throw new Error('SafeProxy was not deployed correctly');
        }
        return proxyAddress;
    }
    //MY CODE FINISH HERE

Environment

@safe-global/protocol-kit version: "^1.2.0",
@safe-global/safe-core-sdk-types version: "^2.2.0",

  • Safe contract version: SafeL2 (goerli)
  • Environment:
    • Postman
    • non-browser

Steps to reproduce

My Code

const safeFactory = await SafeFactory.create({ethAdapter})
    
    const owners = [userAddress, adminAddress] //Safe wallet will be managed by two owners, the user and us
    const threshold = 1 //Just one signature is required to carry out a tx

    const safeAccountConfig: SafeAccountConfig = {
        owners, 
        threshold
    }

    const callback = (txHash: any) => {
        console.log({txHash}) //Show the tx hash
    }

    const safeSdk = await safeFactory.deploySafe({safeAccountConfig, callback}) //Here is when I get the error

Expected result

The error should not be thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions