diff --git a/contracts/CPKFactory.sol b/contracts/CPKFactory.sol index b6cfc143..a566b6d6 100644 --- a/contracts/CPKFactory.sol +++ b/contracts/CPKFactory.sol @@ -11,6 +11,14 @@ contract CPKFactory { return type(Proxy).creationCode; } + function proxyRuntimeCode() external pure returns (bytes memory) { + return type(Proxy).runtimeCode; + } + + function proxyRuntimeCodeHash() external pure returns (bytes32 digest) { + return keccak256(type(Proxy).runtimeCode); + } + function createProxyAndExecTransaction( address masterCopy, uint256 saltNonce, diff --git a/test/ethers/shouldWorkWithEthers.ts b/test/ethers/shouldWorkWithEthers.ts index c6a054cb..3bd4c222 100644 --- a/test/ethers/shouldWorkWithEthers.ts +++ b/test/ethers/shouldWorkWithEthers.ts @@ -65,6 +65,8 @@ export function shouldWorkWithEthers({ signer.provider.getTransactionCount(address) ), getBalance: (address: Address): Promise => signer.provider.getBalance(address), + getCode: (address: Address): Promise => signer.provider.getCode(address), + keccak256: (hex: string): string => ethers.utils.keccak256(hex), testedTxObjProps: 'the TransactionResponse and the hash', checkTxObj: ({ transactionResponse, hash }: { transactionResponse: any; hash: string }): void => { diff --git a/test/transactions/shouldSupportDifferentTransactions.ts b/test/transactions/shouldSupportDifferentTransactions.ts index 12068e5d..436ae6a5 100644 --- a/test/transactions/shouldSupportDifferentTransactions.ts +++ b/test/transactions/shouldSupportDifferentTransactions.ts @@ -12,6 +12,8 @@ interface ShouldSupportDifferentTransactionsProps { fromWei: any; getTransactionCount: any; getBalance: any; + getCode: any; + keccak256: any; testedTxObjProps: any; checkTxObj: any; waitTxReceipt: any; @@ -28,6 +30,8 @@ export function shouldSupportDifferentTransactions({ fromWei, getTransactionCount, getBalance, + getCode, + keccak256, testedTxObjProps, checkTxObj, waitTxReceipt, @@ -290,5 +294,23 @@ export function shouldSupportDifferentTransactions({ gasCosts.should.be.equal(gasPrice * gasUsed); }); + + if (!ownerIsRecognizedContract) { + it('deploys proxy which matches factory specs', async () => { + const cpkFactory = await getContracts().CPKFactory.deployed(); + const idPrecompile = `0x${'0'.repeat(39)}4`; + await cpk.execTransactions([{ + operation: CPK.Call, + to: idPrecompile, + value: 0, + data: '0x', + }]); + const proxyRuntimeCode = await getCode(cpk.address); + await cpkFactory.proxyRuntimeCode() + .should.eventually.equal(proxyRuntimeCode); + await cpkFactory.proxyRuntimeCodeHash() + .should.eventually.equal(keccak256(proxyRuntimeCode)); + }); + } }); } diff --git a/test/web3/shouldWorkWithWeb3.ts b/test/web3/shouldWorkWithWeb3.ts index fcb28def..61dc9938 100644 --- a/test/web3/shouldWorkWithWeb3.ts +++ b/test/web3/shouldWorkWithWeb3.ts @@ -43,6 +43,8 @@ export function shouldWorkWithWeb3({ testedTxObjProps: 'the PromiEvent for the transaction and the hash', getBalance: (address: Address): number => web3Box[0].eth.getBalance(address) .then((balance: number) => web3Box[0].utils.toBN(balance)), + getCode: (address: Address): Promise => web3Box[0].eth.getCode(address), + keccak256: (hex: string): string => web3Box[0].utils.keccak256(hex), checkTxObj: ({ promiEvent, hash }: { promiEvent: any; hash: string }): void => { should.exist(promiEvent); should.exist(hash);