@0x:contracts-staking Addressed review feedback by removing simplyProxyCallWithData
				
					
				
			This commit is contained in:
		@@ -104,14 +104,22 @@ contract StakingProxy is
 | 
			
		||||
        public
 | 
			
		||||
        returns (bytes[] memory batchReturnData)
 | 
			
		||||
    {
 | 
			
		||||
        // Initialize commonly used variables.
 | 
			
		||||
        bool success;
 | 
			
		||||
        bytes memory returnData;
 | 
			
		||||
        batchReturnData = new bytes[](data.length);
 | 
			
		||||
 | 
			
		||||
        // Ensure that a staking contract has been attached to the proxy.
 | 
			
		||||
        if (stakingContract == address(0)) {
 | 
			
		||||
            LibRichErrors.rrevert(
 | 
			
		||||
                LibStakingRichErrors.ProxyDestinationCannotBeNilError()
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Execute all of the calls encoded in the provided calldata.
 | 
			
		||||
        for (uint256 i = 0; i < data.length; i++) {
 | 
			
		||||
            // Call the staking contract with the provided calldata.
 | 
			
		||||
            (success, returnData) = stakingContract.simpleProxyCallWithData(data[i]);
 | 
			
		||||
            (success, returnData) = stakingContract.delegatecall(data[i]);
 | 
			
		||||
 | 
			
		||||
            // Revert on failure.
 | 
			
		||||
            if (!success) {
 | 
			
		||||
 
 | 
			
		||||
@@ -109,24 +109,4 @@ library LibProxy {
 | 
			
		||||
            return(0, returndatasize())
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Proxies incoming call to destination contract with specified calldata.
 | 
			
		||||
    /// @param destination Address to call.
 | 
			
		||||
    /// @param data The calldata that will be sent to the destination.
 | 
			
		||||
    function simpleProxyCallWithData(
 | 
			
		||||
        address destination,
 | 
			
		||||
        bytes memory data
 | 
			
		||||
    )
 | 
			
		||||
        internal
 | 
			
		||||
        returns (bool, bytes memory)
 | 
			
		||||
    {
 | 
			
		||||
        if (destination == address(0)) {
 | 
			
		||||
            LibRichErrors.rrevert(
 | 
			
		||||
                LibStakingRichErrors.ProxyDestinationCannotBeNilError()
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // delegatecall into the destination address, and return the result.
 | 
			
		||||
        return destination.delegatecall(data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -71,14 +71,4 @@ contract TestLibProxy {
 | 
			
		||||
        proxyCallArgs = args;
 | 
			
		||||
        (success, returnData) = address(this).call(data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Calls the destination with the provided calldata.
 | 
			
		||||
    /// @param destination The contract that should be called by the proxy call.
 | 
			
		||||
    /// @param data The bytes that should be used to call into the destination contract.
 | 
			
		||||
    function publicSimpleProxyCallWithData(address destination, bytes memory data)
 | 
			
		||||
        public
 | 
			
		||||
        returns (bool success, bytes memory returnData)
 | 
			
		||||
    {
 | 
			
		||||
        return destination.simpleProxyCallWithData(data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -271,33 +271,4 @@ blockchainTests.resets('LibProxy', env => {
 | 
			
		||||
            ]);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    describe('simpleProxyCallWithData', () => {
 | 
			
		||||
        it('should revert if address zero is the destination', async () => {
 | 
			
		||||
            const expectedError = new StakingRevertErrors.ProxyDestinationCannotBeNilError();
 | 
			
		||||
            const tx = proxy.publicSimpleProxyCallWithData.awaitTransactionSuccessAsync(
 | 
			
		||||
                constants.NULL_ADDRESS,
 | 
			
		||||
                constants.NULL_BYTES,
 | 
			
		||||
            );
 | 
			
		||||
            return expect(tx).to.revertWith(expectedError);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        it('should call the receiver with the correct calldata and report a success when the receiver succeeds', async () => {
 | 
			
		||||
            const calldata = constructRandomSuccessCalldata();
 | 
			
		||||
            verifyPostConditions(
 | 
			
		||||
                await proxy.publicSimpleProxyCallWithData.callAsync(receiver.address, calldata),
 | 
			
		||||
                true,
 | 
			
		||||
                calldata,
 | 
			
		||||
            );
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        it('should call the receiver with the correct calldata and report a success when the receiver succeeds', async () => {
 | 
			
		||||
            const calldata = constructRandomFailureCalldata();
 | 
			
		||||
            verifyPostConditions(
 | 
			
		||||
                await proxy.publicSimpleProxyCallWithData.callAsync(receiver.address, calldata),
 | 
			
		||||
                false,
 | 
			
		||||
                calldata,
 | 
			
		||||
            );
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user