Skip to content

Commit

Permalink
Updated erc1271 and TributeUI .env docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fforbeck committed Aug 5, 2021
1 parent 3855860 commit 92e888f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 43 deletions.
17 changes: 10 additions & 7 deletions contracts/extensions/erc1271/ERC1271.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ contract ERC1271Extension is DaoConstants, AdapterGuard, IExtension, IERC1271 {
mapping(bytes32 => DAOSignature) public signatures; // msgHash => Signature

/// @notice Clonable contract must have an empty constructor
// constructor() {
// }
constructor() {}

modifier hasExtensionAccess(AclFlag flag) {
require(
Expand Down Expand Up @@ -88,8 +87,10 @@ contract ERC1271Extension is DaoConstants, AdapterGuard, IExtension, IERC1271 {
}

/**
* @dev exposes standard ERC1271 isValidSignature interface
*
* @notice Verifies if exists a signature based on the permissionHash, and checks if the provided signature matches the expected signatureHash.
* @param permissionHash The digest of the data to be signed.
* @param signature The signature in bytes to be encoded, hashed and verified.
* @return The magic number in bytes4 in case the signature is valid, otherwise it reverts.
*/
function isValidSignature(bytes32 permissionHash, bytes memory signature)
public
Expand All @@ -108,9 +109,11 @@ contract ERC1271Extension is DaoConstants, AdapterGuard, IExtension, IERC1271 {
}

/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
* @notice Registers a valid signature in the extension.
* @dev Only adapters/extensions with `SIGN` ACL can call this function.
* @param permissionHash The digest of the data to be signed.
* @param signatureHash The hash of the signature.
* @param magicValue The value to be returned by the ERC1271 interface upon success.
*/
function sign(
bytes32 permissionHash,
Expand Down
81 changes: 46 additions & 35 deletions website/docs/contracts/extensions/ERC1271.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
---
id: erc1271-extension
title: ERC1271 Signatures
title: ERC1271
---

## Extension description and scope

The ERC1271 extension allows DAOs to collectively sign messages and typed data through signatures. ERC1271 is a contract signature standard that enables smart contract wallets to behave like EOAs (externally owned accounts). Signatures are critical when interacting with various types of decentralized applications. Developers use signatures for authentication, meta-transactions, order books, and anything that requires delegated permission or proof of ownership of an address. ERC1271 has widespread adoption and is used in applications like Argent and Snapshot.

## Extension workflow

In order to register a signature with the DAO, a member must submit a proposal in which they specify the signature message digest, the signature, and the magic value to return on success.

The message digest must be the hash of the message to sign. This can be a simple message hash, a personal signature (message with special prefix), or a typed data signature (message created using structured data).
Expand All @@ -17,65 +13,82 @@ The proposal enters the voting process.

If the vote passes, the extension returns the magic value when queried via the ERC1271 interface.

## Extension state

### DaoRegistry public dao;
## Access Flags

The DAO address that this extension belongs to
- `SIGN`: right to store a signature into the contract _signatures_ storage.

### bool public initialized = false;
## Structs

Internally tracks deployment under ERC-1167 proxy pattern

### DAOSignature struct
### DAOSignature

- `signatureProposals`: all signature proposals handled by each DAO.
- `SignatureDetails`:
- `signature`: the signature associated with this proposal. May be used to encode other attributes for efficiency, since it is not a real signature and would just be wasted storage space
- `msgHash`: the digest of the data to sign
- `magicValue`: the value to return if a signature proposal has passed
- `signature`: the signature associated with this proposal. May be used to encode other attributes for efficiency, since it is not a real signature and would just be wasted storage space.
- `msgHash`: the digest of the data to sign.
- `magicValue`: the value to return if a signature proposal has passed.

## Storage

### public dao

The DAO address that this extension belongs to.

### public initialized

Internally tracks deployment under ERC-1167 proxy pattern.

## Dependencies and interactions (internal / external)
### public signatures

- Voting
Keeps track of all signatures provided through `sign` function, so they can be verified.

- starts new voting for the signature proposal.
- checks the voting results.
## Dependencies

## Functions description and assumptions / checks
### DaoRegistry

## Functions

### function initialize

```solidity
/**
* @notice Initializes the extension with the DAO that it belongs to,
* and checks if the parameters were set.
* @param _dao The address of the DAO that owns the extension.
* @param creator The owner of the DAO and Extension that is also a member of the DAO.
* @notice Initialises the ERC1271 extension to be associated with a DAO
* @dev Can only be called once
* @param creator The DAO's creator, who will be an initial member
*/
function initialize(DaoRegistry _dao, address creator) external override
function initialize(DaoRegistry _dao, address creator) external
```

### function sign

```solidity
/**
* @notice Registers a valid signature in the extension
* @dev Only DAOs with this extension registered can call this function
* @param signatureHash The hash of the signature
* @param permissionHash The digest of the data to be signed
* @param magicValue The value to be returned by the ERC1271 interface upon success
* @notice Registers a valid signature in the extension.
* @dev Only adapters/extensions with `SIGN` ACL can call this function.
* @param permissionHash The digest of the data to be signed.
* @param signatureHash The hash of the signature.
* @param magicValue The value to be returned by the ERC1271 interface upon success.
*/
function sign(
bytes32 permissionHash,
bytes32 signatureHash,
bytes4 magicValue
) internal virtual hasExtensionAccess(AclFlag.SIGN)
) public hasExtensionAccess(AclFlag.SIGN)
```

### function isValidSignature

```solidity
/**
* @notice Verifies if exists a signature based on the permissionHash, and checks if the provided signature matches the expected signatureHash.
* @param permissionHash The digest of the data to be signed.
* @param signature The signature in bytes to be encoded, hashed and verified.
* @return The magic number in bytes4 in case the signature is valid, otherwise it reverts.
*/
function isValidSignature(bytes32 permissionHash, bytes memory signature)
public
view
override
returns (bytes4)
function isValidSignature(bytes32 permissionHash, bytes memory signature)
public
view
Expand All @@ -85,6 +98,4 @@ function initialize(DaoRegistry _dao, address creator) external override

## Events

List all the events that are emitted by the function in this Extension implementation.

`event Signed(bytes32 PermissionHash)`
- No events are emitted.
2 changes: 1 addition & 1 deletion website/docs/tutorial/dao/TributeUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can find the **REACT_APP_DAO_REGISTRY_CONTRACT_ADDRESS** and **REACT_APP_MUL

```bash
# It can be the same value you used for the Tribute DAO deployment.
REACT_APP_INFURA_PROJECT_ID_LOCAL=...
REACT_APP_INFURA_PROJECT_ID_DEV=...

# The address of the DaoRegistry smart contract deployed to the Rinkeby network.
REACT_APP_DAO_REGISTRY_CONTRACT_ADDRESS=...
Expand Down

0 comments on commit 92e888f

Please sign in to comment.