erasureprotocol / erasure-protocol

Information wants to be expensive
https://erasure.world/
MIT License
163 stars 27 forks source link

[Wrapper] Linking posts and agreements #46

Open thegostep opened 5 years ago

thegostep commented 5 years ago

@jgeary This would require modifying the post and agreement contracts to allow it to be operated on behalf of the owner by a different address.

Here is an example:

// Sealed

    // Call with signed message
    function sign(bytes memory signature) public {
        address party = ECDSA.recover(
            ECDSA.toEthSignedMessageHash(
                getSignSig()
            ),
            signature
        );
        require(party != address(0), 'check signature validity');

        _sign(party);
        // tokens are transfered from the party
        require(IERC20(params.token).transferFrom(party, address(this), parties[party].stake), "token transfer failed");
    }

    // Call from trusted operator
    function sign(address party) public {
        require(msg.sender == params.operator, "only operator");
        require(params.trustedOperator, "only trusted operator");

        _sign(party);
        // tokens are transfered from the operator
        require(IERC20(params.token).transferFrom(params.operator, address(this), parties[party].stake), "token transfer failed");
    }

    // Call from party address
    function sign() public {
        address party = msg.sender;

        _sign(party);
        // tokens are transfered from the party
        require(IERC20(params.token).transferFrom(party, address(this), parties[party].stake), "token transfer failed");
    }

    function _sign(address party) internal {
        doSomething()
    }

I am not a big fan of this pattern because it adds a lot of complexity to the underlying contract.

@0age @kenchangh do you have any thoughts on how we can solve this?

thegostep commented 5 years ago

Decision is to use inherited operator contract to perform access control for now