TeamSmartWalletPermitHelper

A smart contract for managing permit calls on behalf of a TeamSmartWallet.

It follows EIP-712 standard to allow permit access.

DEFAULT_ADMIN_ROLE

bytes32 DEFAULT_ADMIN_ROLE

Role that allows a user to execute trading functions

TRADING_ROLE

bytes32 TRADING_ROLE

Role that allows a user to execute trading functions

FINANCIAL_ROLE

bytes32 FINANCIAL_ROLE

Role that allows a user to execute financial functions

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

Role that allows a user to upgrade the smart contract

teamSmartWallet

initialize

Initialize function used instead of constructor to properly support proxy contracts.

Parameters

Name
Type
Description

_teamSmartWallet

address

The TeamSmartWallet associated with this helper.

isSignerAndSignatureValid

Modifier to check if signer has a given role.

Parameters

Name
Type
Description

_role

bytes32

The role to check.

_signature

struct Signature

The signer struct containing the signature, signer and deadline.

_permitHash

bytes32

The EIP-712 hash to validate.

unregister

Function to permanently renounce this helper from a team.

permitGrantRole

This function is used to grant a role to a user using a permit mechanism.

The permit must be signed by a user with the DEFAULT_ADMIN_ROLE.

Parameters

Name
Type
Description

_role

bytes32

The role to grant.

_user

address

The address of the user to grant the role to.

_signature

struct Signature

The signers signature, address and deadline.

permitRevokeRole

This function is used to revoke a role from a user using a permit mechanism.

The permit must be signed by a user with the DEFAULT_ADMIN_ROLE.

Parameters

Name
Type
Description

_role

bytes32

The role to revoke.

_user

address

The address of the user from whom to revoke the role.

_signature

struct Signature

The signers signature, address and deadline.

permitTransferNative

This function allows a signed permit to perform a native transfer.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_recipient

address payable

The address of the recipient.

_amount

uint256

The amount to transfer.

_signature

struct Signature

The signers signature, address and deadline.

permitApproveERC20

This function allows a signed permit to approve a ERC20 transfer.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_token

contract IERC20

The ERC20 token to approve.

_spender

address

The address of the spender.

_amount

uint256

The amount to approve.

_signature

struct Signature

The signers signature, address and deadline.

permitTransferERC20

This function allows a signed permit to perform a ERC20 transfer.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_token

address

The ERC20 token to transfer.

_recipient

address

The address of the recipient.

_amount

uint256

The amount to transfer.

_signature

struct Signature

The signers signature, address and deadline.

permitApproveERC721

This function allows a signed permit to approve a ERC721 transfer.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_token

address

The ERC721 token to approve.

_to

address

The address to approve.

_tokenId

uint256

The ID of the token to approve.

_signature

struct Signature

The signers signature, address and deadline.

permitSetApprovalForAllERC721

This function allows a signed permit to approve or revoke approval of an operator to transfer any NFT by the owner.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_erc721

address

The ERC721 contract to approve.

_operator

address

The address to approve.

_approved

bool

The approval status.

_signature

struct Signature

The signers signature, address and deadline.

permitTransferERC721

This function allows a signed permit to perform a ERC721 transfer.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_token

address

The ERC721 token to transfer.

_recipient

address

The address of the recipient.

_tokenId

uint256

The ID of the token to transfer.

_signature

struct Signature

The signers signature, address and deadline.

permitSetApprovalForAllERC1155

This function allows a signed permit to set approval for all ERC1155 tokens.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_erc1155

address

The ERC1155 token contract.

_operator

address

The operator to be approved or disapproved.

_approved

bool

Approval status to set for the operator.

_signature

struct Signature

The signers signature, address and deadline.

permitTransferFromERC1155

This function allows a signed permit to perform a ERC1155 transfer.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_erc1155

address

The ERC1155 token contract.

_from

address

The address to transfer from.

_to

address

The address to transfer to.

_id

uint256

The ID of the token to transfer.

_amount

uint256

The amount of the token to transfer.

_signature

struct Signature

The signers signature, address and deadline.

permitList

This function allows a signed permit to list an NFT for sale.

The permit must be signed by a user with the FINANCIAL_ROLE.

Parameters

Name
Type
Description

_collection

address

The NFT collection contract.

_tokenId

uint256

The ID of the NFT to list.

_erc20

address

The ERC20 token in which the NFT will be priced.

_price

uint256

The listing price of the NFT.

_signature

struct Signature

The signers signature, address and deadline.

permitDelist

This function allows a signed permit to delist an NFT from sale.

The permit must be signed by a user with the TRADING_ROLE.

Parameters

Name
Type
Description

_collection

address

The NFT collection contract.

_tokenId

uint256

The ID of the NFT to delist.

_erc20

address

The ERC20 token in which the NFT is priced.

_signature

struct Signature

The signers signature, address and deadline.

permitBuy

This function allows a signed permit to buy an NFT.

The permit must be signed by a user with the TRADING_ROLE.

Parameters

Name
Type
Description

_collection

address

The NFT collection contract.

_tokenId

uint256

The ID of the NFT to buy.

_erc20

address

The ERC20 token in which the NFT is priced.

_signature

struct Signature

Signature from the user invoking the buy.

permitOffer

This function allows a signed permit to make an offer for an NFT.

The permit must be signed by a user with the TRADING_ROLE.

Parameters

Name
Type
Description

_collection

address

The NFT collection contract.

_tokenId

uint256

The ID of the NFT to make an offer for.

_erc20

address

The ERC20 token in which the offer is priced.

_price

uint256

The offering price.

_signature

struct Signature

The signers signature, address and deadline.

permitRevokeOffer

This function allows a signed permit to revoke an offer for an NFT.

The permit must be signed by a user with the TRADING_ROLE.

Parameters

Name
Type
Description

_collection

address

The NFT collection contract.

_tokenId

uint256

The ID of the NFT for which to revoke the offer.

_erc20

address

The ERC20 token in which the offer is priced.

_signature

struct Signature

The signers signature, address and deadline.

permitAcceptOffer

This function allows a signed permit to accept an offer for an NFT.

The permit must be signed by a user with the TRADING_ROLE.

Parameters

Name
Type
Description

_buyer

address

The address of the user who made the offer.

_erc20

address

The ERC20 token in which the offer is priced.

_collection

address

The NFT collection contract.

_tokenId

uint256

The ID of the NFT for which to accept the offer.

_signature

struct Signature

The signers signature, address and deadline.

permitUpdateSale

This function allows a signed permit to update the state of a sale.

The permit must be signed by a user with the TRADING_ROLE.

Parameters

Name
Type
Description

_saleId

uint256

The ID of the sale to update.

_newState

enum IEscrow.State

The new state of the sale.

_signature

struct Signature

The signers signature, address and deadline.

permitSetOffchainPayout

Turns on or off the offchain payout behaviour, via a EIP-712 signature

When on, payouts will be redirected to Colle, and emit a event stating Colle owes the user the amount

Parameters

Name
Type
Description

_offchainPayout

bool

Whether to turn on or off offchain payouts.

_signature

struct Signature

_getPermitGrantRoleHash

Generates a unique hash to be signed for granting a role to a user.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_role

bytes32

The role identifier to grant.

_user

address

The address of the user to grant the role to.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitRevokeRoleHash

Generates a unique hash to be signed for revoking a role from a user.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_role

bytes32

The role identifier to revoke.

_user

address

The address of the user from whom to revoke the role.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitTransferHash

Generates a unique hash to be signed for transferring native token (such as ETH) from the owner to the recipient.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_recipient

address

The address of the user to whom the token will be transferred.

_amount

uint256

The amount of token to transfer.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitApproveERC20Hash

Generates a unique hash to be signed for approving an ERC20 token allowance.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_token

contract IERC20

The ERC20 token to approve.

_spender

address

The address of the user to grant the allowance to.

_amount

uint256

The amount of tokens to approve.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitTransferERC20Hash

Generates a unique hash to be signed for transferring ERC20 tokens.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_token

address

The ERC20 token to transfer.

_recipient

address

The address of the user to whom the tokens will be transferred.

_amount

uint256

The amount of tokens to transfer.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitApproveERC721Hash

Generates a unique hash to be signed for approving an ERC721 token transfer.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_token

address

The ERC721 token to approve.

_to

address

The address of the user to whom the token transfer will be approved.

_tokenId

uint256

The ID of the token to approve.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitSetApprovalForAllERC721Hash

Generates a unique hash to be signed for approving a operator to transfer all NFTs by the owner.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_erc721

address

The ERC721 contract to approve.

_operator

address

The address of the user to whom the token transfer will be approved.

_approved

bool

The approval status of the operator.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitTransferERC721Hash

Generates a unique hash to be signed for transferring an ERC721 token.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_token

address

The ERC721 token to transfer.

_recipient

address

The address of the user to whom the token will be transferred.

_tokenId

uint256

The ID of the token to transfer.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitListHash

Generates a unique hash to be signed for listing a token on a marketplace.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_collection

address

The address of the token's collection.

_tokenId

uint256

The ID of the token to list.

_erc20

address

The address of the ERC20 token to accept as payment.

_price

uint256

The price at which the token will be listed.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitDelistHash

Generates a unique hash to be signed for delisting a token from the marketplace.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_collection

address

The address of the token's collection.

_tokenId

uint256

The ID of the token to delist.

_erc20

address

The address of the ERC20 token used in the original listing.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitBuyHash

Generates a unique hash to be signed for buying a token from the marketplace.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The buyers signature, address and deadline.

_collection

address

The address of the token's collection.

_tokenId

uint256

The ID of the token to buy.

_erc20

address

The address of the ERC20 token used to pay.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitOfferHash

Generates a unique hash to be signed for offering to buy a token from the marketplace.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_collection

address

The address of the token's collection.

_tokenId

uint256

The ID of the token to buy.

_erc20

address

The address of the ERC20 token used to pay.

_price

uint256

The price at which the offer is made.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitRevokeOfferHash

Generates a unique hash to be signed for revoking an offer from the marketplace.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_collection

address

The address of the token's collection.

_tokenId

uint256

The ID of the token involved in the offer.

_erc20

address

The address of the ERC20 token used in the offer.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitAcceptOfferHash

Generates a unique hash to be signed for accepting an offer from the marketplace.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_buyer

address

The address of the user who made the offer.

_erc20

address

The address of the ERC20 token used in the offer.

_collection

address

The address of the token's collection.

_tokenId

uint256

The ID of the token involved in the offer.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitUpdateSaleHash

Generates a unique hash to be signed for updating the state of a sale.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_saleId

uint256

The ID of the sale to update.

_newState

enum IEscrow.State

The new state of the sale.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitSetOffchainPayoutHash

Computes the EIP-712 hash that should be signed by the buyer to buy a token.

Parameters

Name
Type
Description

_offchainPayout

bool

Whether to turn on or off offchain payouts.

_signature

struct Signature

The address of the buyer and the deadline

Return Values

Name
Type
Description

[0]

bytes32

Returns the EIP-712 hash.

_getPermitSetApprovalForAllERC1155Hash

Generates a unique hash to be signed for setting an operator's approval status on all tokens of a certain ERC1155 contract for a user.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_erc1155

address

The address of the ERC1155 contract.

_operator

address

The address of the operator.

_approved

bool

Whether the operator is approved or not.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

_getPermitTransferFromERC1155Hash

Generates a unique hash to be signed for transferring a certain amount of a specific ERC1155 token from one address to another.

This method is compliant with the EIP712 standard.

Parameters

Name
Type
Description

_signature

struct Signature

The signers signature, address and deadline.

_erc1155

address

The address of the ERC1155 contract.

_from

address

The address from which the tokens will be transferred.

_to

address

The address to which the tokens will be transferred.

_id

uint256

The ID of the token to transfer.

_value

uint256

The amount of the token to transfer.

Return Values

Name
Type
Description

[0]

bytes32

A unique hash that represents the requested operation.

Last updated