.. _smart-contracts: Smart Contracts =============== .. contents:: :local: .. _sc-registry-shop: Shop Registry -------------- The Shop Registry is an extension of `EIP721 `_. Therefore each registered shop is an NFT and the contract comes with the associated functions, like ``mint``, ``ownerOf``, ``transferFrom`` and ``approve``. The ``shopId`` is chosen by the caller. Minting already taken IDs will lead to a revert. User Invitation ^^^^^^^^^^^^^^^ The user-facing way to add :term:`Clerks` to a shop is through the use of an invitation (See :ref:`adding-clerks`). The contract offers these functions: - :sol:func:`publishInviteVerifier` - :sol:func:`redeemInvite` .. _sc-shop-config: Shop Configuration ^^^^^^^^^^^^^^^^^^ To add and remove :term:`Relays` from your :term:`Shop` the contract offers these functions: - :sol:func:`getAllRelays` - :sol:func:`addRelay` - :sol:func:`replaceRelay` - :sol:func:`removeRelay` Manual User Management ^^^^^^^^^^^^^^^^^^^^^^ To manually add or remove a :term:`Clerk` (a type of :term:`User`), an :term:`Admin` can call these functions: - :sol:func:`registerUser` - :sol:func:`removeUser` Full Contract Listing ^^^^^^^^^^^^^^^^^^^^^ .. autosolcontract:: ShopReg :members: mint, publishInviteVerifier, redeemInvite, getAllRelays, addRelay, replaceRelay, removeRelay, updateRootHash, registerUser, removeUser :exclude-members: xxxxxxxxx .. TODO: this is handwritten because there is a bug in the sphinx-solidity domain to recognize abstract contracts .. sol:contract:: AccessControl is ERC721 Abstract contract to manage access control to a Shop. .. TODO no formatter for errors? .. error NotAuthorized(uint8 permission); .. sol:event:: UserAdded(uint256 indexed shopId, address user, uint256 permissions) .. sol:event:: UserRemoved(uint256 indexed shopId, address users) .. sol:event:: PermissionAdded(uint256 indexed shopId, address user, uint8 permission) .. sol:event:: PermissionRemoved(uint256 indexed shopId, address user, uint8 permission) .. sol:function:: hasPermission(uint256 id, address user, uint8 perm) public view returns (bool) Checks if a user has a single permission .. sol:function:: getAllPermissions(uint256 id, address user) public view returns (uint256) Returns a user's perimsion bitmap .. sol:function:: permsToBitmap(uint8[] memory perms) public pure returns (uint256) Converts an array of permissions to a bitmap .. _sc-registry-relay: Relay Registry -------------- Just like the Shop Registry, the Relay Registry is an extension of `EIP721 `_. .. autosolcontract:: RelayReg :members: :exclude-members: __init__ Payments *v2* ------------- Next iteration, using a single contract for all payments. Will support attestations and refunds. .. autosolcontract:: Payments :members: :exclude-members: xxxxxxx .. TODO: this is handwritten because there is no autosolstruct for some reason .. sol:struct:: PaymentRequest Holds the Payment details :member uint256 chainId: The network the payment is supposed to be made on :member uint256 ttl: The deadline for the payment (block.timestamp) :member bytes32 order: The hash of the order details :member address currency: The address of the ERC20 token to be transferred :member uint256 amount: The amount of tokens to be transferred :member address payeeAddress: The address that will receive the payment :member bool isPaymentEndpoint: Whether the payment should be forwarded with another contract call. See IPaymentEndpoint. :member uint256 shopId: The token id of the shop :member bytes shopSignature: The signature of a merchant's relay or signer .. _sc-payment-factory: PaymentsByAddress ----------------- For wallets that don't support direct function calls to `pay`, we support the creation of counterfactual instantiation via ``CREATE2``. .. autosolcontract:: PaymentsByAddress :members: getPaymentId, getPaymentAddress :exclude-members: xxxxxx