Skip to content

Commit

Permalink
Merge pull request #304 from CoinbaseStablecoin/v2-oz-L02
Browse files Browse the repository at this point in the history
Update NatSpec comments [L02]
  • Loading branch information
petejkim committed Jul 17, 2020
2 parents 9de45f0 + 50a7b33 commit 3290919
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 98 deletions.
38 changes: 20 additions & 18 deletions @types/generated/FiatTokenV2.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 39 additions & 37 deletions contracts/v2/FiatTokenV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Permit } from "./Permit.sol";

/**
* @title FiatToken V2
* @notice ERC20 Token backed by fiat reserves, version 2
*/
contract FiatTokenV2 is
FiatTokenV1_1,
Expand All @@ -47,7 +48,8 @@ contract FiatTokenV2 is
/**
* @notice Initialize V2 contract
* @dev When upgrading to V2, this function must also be invoked
* simultaneously by using upgradeAndCall instead of upgradeTo.
* simultaneously by using upgradeToAndCall instead of upgradeTo.
* @param newName New token name
*/
function initializeV2(string calldata newName) external {
require(
Expand Down Expand Up @@ -95,15 +97,15 @@ contract FiatTokenV2 is

/**
* @notice Execute a transfer with a signed authorization
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function transferWithAuthorization(
address from,
Expand Down Expand Up @@ -131,15 +133,15 @@ contract FiatTokenV2 is

/**
* @notice Update allowance with a signed authorization
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param value Amount of allowance
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param value Amount of allowance
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function approveWithAuthorization(
address owner,
Expand Down Expand Up @@ -167,15 +169,15 @@ contract FiatTokenV2 is

/**
* @notice Increase allowance with a signed authorization
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param increment Amount of increase in allowance
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param increment Amount of increase in allowance
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function increaseAllowanceWithAuthorization(
address owner,
Expand Down Expand Up @@ -203,15 +205,15 @@ contract FiatTokenV2 is

/**
* @notice Decrease allowance with a signed authorization
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param decrement Amount of decrease in allowance
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param decrement Amount of decrease in allowance
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function decreaseAllowanceWithAuthorization(
address owner,
Expand Down
82 changes: 43 additions & 39 deletions contracts/v2/GasAbstraction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import { EIP712 } from "../util/EIP712.sol";

/**
* @title Gas Abstraction
* @notice Provide internal implementation for gas-abstracted transfers and
* approvals
* @dev Contracts that inherit from this must wrap these with publicly
* accessible functions, optionally adding modifiers where necessary
*/
abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {
bytes32 public constant TRANSFER_WITH_AUTHORIZATION_TYPEHASH = 0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267;
Expand Down Expand Up @@ -61,7 +65,7 @@ abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {
* @notice Returns the state of an authorization
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
* @return Nonce state
* @return Authorization state
*/
function authorizationState(address authorizer, bytes32 nonce)
external
Expand All @@ -73,15 +77,15 @@ abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {

/**
* @notice Verify a signed transfer authorization and execute if valid
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param from Payer's address (Authorizer)
* @param to Payee's address
* @param value Amount to be transferred
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function _transferWithAuthorization(
address from,
Expand Down Expand Up @@ -114,15 +118,15 @@ abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {
/**
* @notice Verify a signed authorization for an increase in the allowance
* granted to the spender and execute if valid
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param increment Amount of increase in allowance
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param increment Amount of increase in allowance
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function _increaseAllowanceWithAuthorization(
address owner,
Expand Down Expand Up @@ -155,15 +159,15 @@ abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {
/**
* @notice Verify a signed authorization for a decrease in the allowance
* granted to the spender and execute if valid
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param decrement Amount of decrease in allowance
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param decrement Amount of decrease in allowance
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function _decreaseAllowanceWithAuthorization(
address owner,
Expand Down Expand Up @@ -195,15 +199,15 @@ abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {

/**
* @notice Verify a signed approval authorization and execute if valid
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param value Amount of allowance
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param value Amount of allowance
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
* @param nonce Unique nonce
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
*/
function _approveWithAuthorization(
address owner,
Expand Down Expand Up @@ -281,8 +285,8 @@ abstract contract GasAbstraction is AbstractFiatTokenV2, EIP712Domain {
* @notice Check that authorization is valid
* @param authorizer Authorizer's address
* @param nonce Nonce of the authorization
* @param validAfter Earliest time this is valid, seconds since the epoch
* @param validBefore Expiration time, seconds since the epoch
* @param validAfter The time after which this is valid (unix time)
* @param validBefore The time before which this is valid (unix time)
*/
function _requireValidAuthorization(
address authorizer,
Expand Down
9 changes: 5 additions & 4 deletions contracts/v2/Permit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import { EIP712 } from "../util/EIP712.sol";

/**
* @title Permit
* @dev An alternative to approveWithAuthorization, provided for compatibility
* with the draft EIP2612 proposed by Uniswap.
* Differences:
* @notice An alternative to approveWithAuthorization, provided for
* compatibility with the draft EIP2612 proposed by Uniswap.
* @dev Differences:
* - Uses sequential nonce, which restricts transaction submission to one at a
* time, or else it will revert
* - Has deadline (= validBefore - 1) but does not have validAfter
Expand All @@ -49,6 +49,7 @@ abstract contract Permit is AbstractFiatTokenV2, EIP712Domain {
/**
* @notice Nonces for permit
* @param permitter Permitter's address
* @return Next nonce
*/
function nonces(address permitter) external view returns (uint256) {
return _permitNonces[permitter];
Expand All @@ -59,7 +60,7 @@ abstract contract Permit is AbstractFiatTokenV2, EIP712Domain {
* @param owner Token owner's address (Authorizer)
* @param spender Spender's address
* @param value Amount of allowance
* @param deadline Time after which it will expire, seconds since the epoch
* @param deadline The time at which this expires (unix time)
* @param v v of the signature
* @param r r of the signature
* @param s s of the signature
Expand Down

0 comments on commit 3290919

Please sign in to comment.