From 8b4b930570cb95956e76104cf7da9254a2a55ab7 Mon Sep 17 00:00:00 2001 From: "Miquel A. Cabot" Date: Tue, 31 Jan 2023 13:49:16 +0100 Subject: [PATCH] remove deployments to test --- deployments/alfajores/.chainId | 1 - deployments/alfajores/Soulbound2FA.json | 1923 ---------------- .../ba20b0945b3d8227cd3974f83be2ddaf.json | 178 -- deployments/bsctest/.chainId | 1 - deployments/bsctest/Soulbound2FA.json | 1923 ---------------- .../ba20b0945b3d8227cd3974f83be2ddaf.json | 178 -- deployments/mumbai/.chainId | 1 - deployments/mumbai/Soulbound2FA.json | 1938 ----------------- .../ba20b0945b3d8227cd3974f83be2ddaf.json | 178 -- 9 files changed, 6321 deletions(-) delete mode 100644 deployments/alfajores/.chainId delete mode 100644 deployments/alfajores/Soulbound2FA.json delete mode 100644 deployments/alfajores/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json delete mode 100644 deployments/bsctest/.chainId delete mode 100644 deployments/bsctest/Soulbound2FA.json delete mode 100644 deployments/bsctest/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json delete mode 100644 deployments/mumbai/.chainId delete mode 100644 deployments/mumbai/Soulbound2FA.json delete mode 100644 deployments/mumbai/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json diff --git a/deployments/alfajores/.chainId b/deployments/alfajores/.chainId deleted file mode 100644 index 38448fe1c..000000000 --- a/deployments/alfajores/.chainId +++ /dev/null @@ -1 +0,0 @@ -44787 \ No newline at end of file diff --git a/deployments/alfajores/Soulbound2FA.json b/deployments/alfajores/Soulbound2FA.json deleted file mode 100644 index a53c29fe1..000000000 --- a/deployments/alfajores/Soulbound2FA.json +++ /dev/null @@ -1,1923 +0,0 @@ -{ - "address": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "admin", - "type": "address" - }, - { - "internalType": "string", - "name": "baseTokenURI", - "type": "string" - }, - { - "internalType": "contract ISoulboundIdentity", - "name": "soulboundIdentity", - "type": "address" - }, - { - "components": [ - { - "internalType": "address", - "name": "swapRouter", - "type": "address" - }, - { - "internalType": "address", - "name": "wrappedNativeToken", - "type": "address" - }, - { - "internalType": "address", - "name": "stableCoin", - "type": "address" - }, - { - "internalType": "address", - "name": "masaToken", - "type": "address" - }, - { - "internalType": "address", - "name": "reserveWallet", - "type": "address" - } - ], - "internalType": "struct PaymentGateway.PaymentParams", - "name": "paymentParams", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "AlreadyAdded", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "AuthorityNotExists", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "caller", - "type": "address" - } - ], - "name": "CallerNotOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InsufficientEthAmount", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - } - ], - "name": "InvalidPaymentMethod", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidSignature", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - } - ], - "name": "InvalidToken", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "erc20token", - "type": "address" - } - ], - "name": "NonExistingErc20Token", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "signer", - "type": "address" - } - ], - "name": "NotAuthorized", - "type": "error" - }, - { - "inputs": [], - "name": "NotLinkedToAnIdentitySBT", - "type": "error" - }, - { - "inputs": [], - "name": "RefundFailed", - "type": "error" - }, - { - "inputs": [], - "name": "SameValue", - "type": "error" - }, - { - "inputs": [], - "name": "TransferFailed", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "Burn", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - } - ], - "name": "Soulbound2FAMintedToAddress", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "identityId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - } - ], - "name": "Soulbound2FAMintedToIdentity", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_authority", - "type": "address" - } - ], - "name": "addAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "addLinkPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "addLinkPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "authorities", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_paymentMethod", - "type": "address" - } - ], - "name": "disablePaymentMethod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_paymentMethod", - "type": "address" - } - ], - "name": "enablePaymentMethod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "enabledPaymentMethod", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "enabledPaymentMethods", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "exists", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEnabledPaymentMethods", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getIdentityId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - } - ], - "name": "getMintPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "masaToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "internalType": "uint256", - "name": "identityId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "mintPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "mintPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "queryLinkPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "queryLinkPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_authority", - "type": "address" - } - ], - "name": "removeAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "reserveWallet", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_addLinkPrice", - "type": "uint256" - } - ], - "name": "setAddLinkPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_addLinkPriceMASA", - "type": "uint256" - } - ], - "name": "setAddLinkPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_masaToken", - "type": "address" - } - ], - "name": "setMasaToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintPrice", - "type": "uint256" - } - ], - "name": "setMintPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintPriceMASA", - "type": "uint256" - } - ], - "name": "setMintPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_queryLinkPrice", - "type": "uint256" - } - ], - "name": "setQueryLinkPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_queryLinkPriceMASA", - "type": "uint256" - } - ], - "name": "setQueryLinkPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_reserveWallet", - "type": "address" - } - ], - "name": "setReserveWallet", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ISoulboundIdentity", - "name": "_soulboundIdentity", - "type": "address" - } - ], - "name": "setSoulboundIdentity", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_stableCoin", - "type": "address" - } - ], - "name": "setStableCoin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_swapRouter", - "type": "address" - } - ], - "name": "setSwapRouter", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_wrappedNativeToken", - "type": "address" - } - ], - "name": "setWrappedNativeToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "soulboundIdentity", - "outputs": [ - { - "internalType": "contract ISoulboundIdentity", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "stableCoin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "swapRouter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenOfOwnerByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "wrappedNativeToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0x94c3a54acd2224e1239cd50d5242e5403407c22278d70bce2ba9b83ac28f4112", - "receipt": { - "to": null, - "from": "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28", - "contractAddress": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "transactionIndex": 0, - "gasUsed": "3587918", - "logsBloom": "0x00000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000020000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000020000080000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000400000000000000000000000000000000000000000100000000000024000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xba12e7d94a175c44aa72b53d2f79896014fe3bf38b0d92f6466f7b0e4636b63d", - "transactionHash": "0x94c3a54acd2224e1239cd50d5242e5403407c22278d70bce2ba9b83ac28f4112", - "logs": [ - { - "transactionIndex": 0, - "blockNumber": 15960635, - "transactionHash": "0x94c3a54acd2224e1239cd50d5242e5403407c22278d70bce2ba9b83ac28f4112", - "address": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28" - ], - "data": "0x", - "logIndex": 0, - "blockHash": "0xba12e7d94a175c44aa72b53d2f79896014fe3bf38b0d92f6466f7b0e4636b63d" - } - ], - "blockNumber": 15960635, - "cumulativeGasUsed": "3587918", - "status": 1, - "byzantium": true - }, - "args": [ - "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28", - "https://beta.metadata.masa.finance/v1.0/2fa/", - "0x0000000000000000000000000000000000000000", - [ - "0xE3D8bd6Aed4F159bc8000a9cD47CffDb95F96121", - "0x524d97A67f50F4A062C28c74F60703Aec9028a94", - "0x37f39aD164cBBf0Cc03Dd638472F3FbeC7aE426C", - "0x7d91E51C8F218f7140188A155f5C75388630B6a8", - "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28" - ] - ], - "numDeployments": 1, - "solcInputHash": "ba20b0945b3d8227cd3974f83be2ddaf", - "metadata": "{\"compiler\":{\"version\":\"0.8.7+commit.e28d00a7\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"baseTokenURI\",\"type\":\"string\"},{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"soulboundIdentity\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"swapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wrappedNativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stableCoin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"masaToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"reserveWallet\",\"type\":\"address\"}],\"internalType\":\"struct PaymentGateway.PaymentParams\",\"name\":\"paymentParams\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"authority\",\"type\":\"address\"}],\"name\":\"AuthorityNotExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"}],\"name\":\"CallerNotOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"}],\"name\":\"InvalidPaymentMethod\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSignature\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"InvalidToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"erc20token\",\"type\":\"address\"}],\"name\":\"NonExistingErc20Token\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"}],\"name\":\"NotAuthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotLinkedToAnIdentitySBT\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RefundFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SameValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TransferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"}],\"name\":\"Soulbound2FAMintedToAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"identityId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"}],\"name\":\"Soulbound2FAMintedToIdentity\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authority\",\"type\":\"address\"}],\"name\":\"addAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addLinkPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addLinkPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"authorities\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_paymentMethod\",\"type\":\"address\"}],\"name\":\"disablePaymentMethod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_paymentMethod\",\"type\":\"address\"}],\"name\":\"enablePaymentMethod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"enabledPaymentMethod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"enabledPaymentMethods\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEnabledPaymentMethods\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getIdentityId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"}],\"name\":\"getMintPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"masaToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"identityId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"queryLinkPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"queryLinkPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authority\",\"type\":\"address\"}],\"name\":\"removeAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveWallet\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_addLinkPrice\",\"type\":\"uint256\"}],\"name\":\"setAddLinkPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_addLinkPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setAddLinkPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_masaToken\",\"type\":\"address\"}],\"name\":\"setMasaToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintPrice\",\"type\":\"uint256\"}],\"name\":\"setMintPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setMintPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_queryLinkPrice\",\"type\":\"uint256\"}],\"name\":\"setQueryLinkPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_queryLinkPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setQueryLinkPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_reserveWallet\",\"type\":\"address\"}],\"name\":\"setReserveWallet\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"_soulboundIdentity\",\"type\":\"address\"}],\"name\":\"setSoulboundIdentity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_stableCoin\",\"type\":\"address\"}],\"name\":\"setStableCoin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_swapRouter\",\"type\":\"address\"}],\"name\":\"setSwapRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wrappedNativeToken\",\"type\":\"address\"}],\"name\":\"setWrappedNativeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"soulboundIdentity\",\"outputs\":[{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stableCoin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedNativeToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Masa Finance\",\"details\":\"Soulbound 2FA, that inherits from the SBT contract.\",\"kind\":\"dev\",\"methods\":{\"addAuthority(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_authority\":\"New authority to add\"}},\"balanceOf(address)\":{\"details\":\"See {ISBT-balanceOf}.\"},\"burn(uint256)\":{\"details\":\"Burns `tokenId`. See {SBT-_burn}. Requirements: - The caller must own `tokenId` or be an approved operator.\"},\"constructor\":{\"details\":\"Creates a new soulbound 2FA, inheriting from the SBT contract.\",\"params\":{\"admin\":\"Administrator of the smart contract\",\"baseTokenURI\":\"Base URI of the token\",\"paymentParams\":\"Payment gateway params\",\"soulboundIdentity\":\"Address of the SoulboundIdentity contract\"}},\"disablePaymentMethod(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_paymentMethod\":\"Token to remove\"}},\"enablePaymentMethod(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_paymentMethod\":\"New token to add\"}},\"exists(uint256)\":{\"details\":\"Returns true if the token has been minted\",\"params\":{\"tokenId\":\"Token to check\"},\"returns\":{\"_0\":\"True if the token exists\"}},\"getEnabledPaymentMethods()\":{\"details\":\"Returns the address of all available payment methods\",\"returns\":{\"_0\":\"Array of all enabled payment methods\"}},\"getIdentityId(uint256)\":{\"params\":{\"tokenId\":\"Id of the token\"},\"returns\":{\"_0\":\"Id of the identity\"}},\"getMintPrice(address)\":{\"details\":\"Returns current pricing for minting\",\"params\":{\"paymentMethod\":\"Address of token that user want to pay\"},\"returns\":{\"_0\":\"Current price for minting in the given payment method\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"mint(address,address,address,uint256,bytes)\":{\"details\":\"The caller must have the MINTER role\",\"params\":{\"authorityAddress\":\"Address of the authority that signed the message\",\"paymentMethod\":\"Address of token that user want to pay\",\"signature\":\"Signature of the message\",\"signatureDate\":\"Date of the signature\",\"to\":\"The address to mint the SBT to\"},\"returns\":{\"_0\":\"The SBT ID of the newly minted SBT\"}},\"mint(address,uint256,address,uint256,bytes)\":{\"details\":\"The caller must have the MINTER role\",\"params\":{\"authorityAddress\":\"Address of the authority that signed the message\",\"identityId\":\"TokenId of the identity to mint the NFT to\",\"paymentMethod\":\"Address of token that user want to pay\",\"signature\":\"Signature of the message\",\"signatureDate\":\"Date of the signature\"},\"returns\":{\"_0\":\"The NFT ID of the newly minted SBT\"}},\"name()\":{\"details\":\"See {ISBTMetadata-name}.\"},\"ownerOf(uint256)\":{\"details\":\"See {ISBT-ownerOf}.\"},\"removeAuthority(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_authority\":\"Authority to remove\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setAddLinkPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_addLinkPrice\":\"New price for adding the link in SoulLinker in stable coin\"}},\"setAddLinkPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_addLinkPriceMASA\":\"New price for adding the link in SoulLinker in MASA\"}},\"setMasaToken(address)\":{\"details\":\"The caller must have the admin role to call this function It can be set to address(0) to disable paying in MASA\",\"params\":{\"_masaToken\":\"New utility token to pay the fee in\"}},\"setMintPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_mintPrice\":\"New price of minting in stable coin\"}},\"setMintPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_mintPriceMASA\":\"New price of minting in MASA\"}},\"setQueryLinkPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_queryLinkPrice\":\"New price for reading data in SoulLinker in stable coin\"}},\"setQueryLinkPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_queryLinkPriceMASA\":\"New price for reading data in SoulLinker in MASA\"}},\"setReserveWallet(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_reserveWallet\":\"New reserve wallet\"}},\"setSoulboundIdentity(address)\":{\"details\":\"The caller must be the admin to call this function\",\"params\":{\"_soulboundIdentity\":\"Address of the SoulboundIdentity contract\"}},\"setStableCoin(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_stableCoin\":\"New stable coin to pay the fee in\"}},\"setSwapRouter(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_swapRouter\":\"New swap router address\"}},\"setWrappedNativeToken(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_wrappedNativeToken\":\"New wrapped native token address\"}},\"supportsInterface(bytes4)\":{\"details\":\"Interface identification is specified in ERC-165.\",\"params\":{\"interfaceId\":\"The interface identifier, as specified in ERC-165\"},\"returns\":{\"_0\":\"`true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise\"}},\"symbol()\":{\"details\":\"See {ISBTMetadata-symbol}.\"},\"tokenByIndex(uint256)\":{\"details\":\"See {ISBTEnumerable-tokenByIndex}.\"},\"tokenOfOwnerByIndex(address,uint256)\":{\"details\":\"See {ISBTEnumerable-tokenOfOwnerByIndex}.\"},\"tokenURI(uint256)\":{\"details\":\"Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the \\\"ERC721 Metadata JSON Schema\\\".\",\"params\":{\"tokenId\":\"SBT to get the URI of\"},\"returns\":{\"_0\":\"URI of the SBT\"}},\"totalSupply()\":{\"details\":\"See {ISBTEnumerable-totalSupply}.\"}},\"title\":\"Soulbound Two-factor authentication (2FA)\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addAuthority(address)\":{\"notice\":\"Adds a new authority to the list of authorities\"},\"constructor\":{\"notice\":\"Creates a new soulbound Two-factor authentication (2FA)\"},\"disablePaymentMethod(address)\":{\"notice\":\"Removes a token as a valid payment method\"},\"enablePaymentMethod(address)\":{\"notice\":\"Adds a new token as a valid payment method\"},\"exists(uint256)\":{\"notice\":\"Returns true if the token exists\"},\"getEnabledPaymentMethods()\":{\"notice\":\"Returns all available payment methods\"},\"getIdentityId(uint256)\":{\"notice\":\"Returns the identityId owned by the given token\"},\"getMintPrice(address)\":{\"notice\":\"Returns the price for minting\"},\"mint(address,address,address,uint256,bytes)\":{\"notice\":\"Mints a new SBT\"},\"mint(address,uint256,address,uint256,bytes)\":{\"notice\":\"Mints a new SBT\"},\"removeAuthority(address)\":{\"notice\":\"Removes an authority from the list of authorities\"},\"setAddLinkPrice(uint256)\":{\"notice\":\"Sets the price for adding the link in SoulLinker in stable coin\"},\"setAddLinkPriceMASA(uint256)\":{\"notice\":\"Sets the price for adding the link in SoulLinker in MASA\"},\"setMasaToken(address)\":{\"notice\":\"Sets the utility token to pay the fee in (MASA)\"},\"setMintPrice(uint256)\":{\"notice\":\"Sets the price of minting in stable coin\"},\"setMintPriceMASA(uint256)\":{\"notice\":\"Sets the price of minting in MASA\"},\"setQueryLinkPrice(uint256)\":{\"notice\":\"Sets the price for reading data in SoulLinker in stable coin\"},\"setQueryLinkPriceMASA(uint256)\":{\"notice\":\"Sets the price for reading data in SoulLinker in MASA\"},\"setReserveWallet(address)\":{\"notice\":\"Set the reserve wallet\"},\"setSoulboundIdentity(address)\":{\"notice\":\"Sets the SoulboundIdentity contract address linked to this SBT\"},\"setStableCoin(address)\":{\"notice\":\"Sets the stable coin to pay the fee in (USDC)\"},\"setSwapRouter(address)\":{\"notice\":\"Sets the swap router address\"},\"setWrappedNativeToken(address)\":{\"notice\":\"Sets the wrapped native token address\"},\"supportsInterface(bytes4)\":{\"notice\":\"Query if a contract implements an interface\"},\"tokenURI(uint256)\":{\"notice\":\"A distinct Uniform Resource Identifier (URI) for a given asset.\"}},\"notice\":\"Soulbound token that represents a Two-factor authentication (2FA)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Soulbound2FA.sol\":\"Soulbound2FA\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"details\":{\"constantOptimizer\":true,\"cse\":true,\"deduplicate\":true,\"inliner\":true,\"jumpdestRemover\":true,\"orderLiterals\":true,\"peephole\":true,\"yul\":false},\"runs\":1},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(uint160(account), 20),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5b35d8e68aeaccc685239bd9dd79b9ba01a0357930f8a3307ab85511733d9724\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Counters.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Counters\\n * @author Matt Condon (@shrugs)\\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\\n *\\n * Include with `using Counters for Counters.Counter;`\\n */\\nlibrary Counters {\\n struct Counter {\\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\\n // this feature: see https://github.com/ethereum/solidity/issues/4637\\n uint256 _value; // default: 0\\n }\\n\\n function current(Counter storage counter) internal view returns (uint256) {\\n return counter._value;\\n }\\n\\n function increment(Counter storage counter) internal {\\n unchecked {\\n counter._value += 1;\\n }\\n }\\n\\n function decrement(Counter storage counter) internal {\\n uint256 value = counter._value;\\n require(value > 0, \\\"Counter: decrement overflow\\\");\\n unchecked {\\n counter._value = value - 1;\\n }\\n }\\n\\n function reset(Counter storage counter) internal {\\n counter._value = 0;\\n }\\n}\\n\",\"keccak256\":\"0xf0018c2440fbe238dd3a8732fa8e17a0f9dce84d31451dc8a32f6d62b349c9f1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xdb7f5c28fc61cda0bd8ab60ce288e206b791643bcd3ba464a70cbec18895a2f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./ECDSA.sol\\\";\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\\n *\\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\\n *\\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\\n * ({_hashTypedDataV4}).\\n *\\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\\n * the chain id to protect against replay attacks on an eventual fork of the chain.\\n *\\n * NOTE: This contract implements the version of the encoding known as \\\"v4\\\", as implemented by the JSON RPC method\\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\\n *\\n * _Available since v3.4._\\n */\\nabstract contract EIP712 {\\n /* solhint-disable var-name-mixedcase */\\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\\n // invalidate the cached domain separator if the chain id changes.\\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\\n uint256 private immutable _CACHED_CHAIN_ID;\\n address private immutable _CACHED_THIS;\\n\\n bytes32 private immutable _HASHED_NAME;\\n bytes32 private immutable _HASHED_VERSION;\\n bytes32 private immutable _TYPE_HASH;\\n\\n /* solhint-enable var-name-mixedcase */\\n\\n /**\\n * @dev Initializes the domain separator and parameter caches.\\n *\\n * The meaning of `name` and `version` is specified in\\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\\n *\\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\\n * - `version`: the current major version of the signing domain.\\n *\\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\\n * contract upgrade].\\n */\\n constructor(string memory name, string memory version) {\\n bytes32 hashedName = keccak256(bytes(name));\\n bytes32 hashedVersion = keccak256(bytes(version));\\n bytes32 typeHash = keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n );\\n _HASHED_NAME = hashedName;\\n _HASHED_VERSION = hashedVersion;\\n _CACHED_CHAIN_ID = block.chainid;\\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\\n _CACHED_THIS = address(this);\\n _TYPE_HASH = typeHash;\\n }\\n\\n /**\\n * @dev Returns the domain separator for the current chain.\\n */\\n function _domainSeparatorV4() internal view returns (bytes32) {\\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\\n return _CACHED_DOMAIN_SEPARATOR;\\n } else {\\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\\n }\\n }\\n\\n function _buildDomainSeparator(\\n bytes32 typeHash,\\n bytes32 nameHash,\\n bytes32 versionHash\\n ) private view returns (bytes32) {\\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\\n }\\n\\n /**\\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\\n * function returns the hash of the fully encoded EIP712 message for this domain.\\n *\\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\\n *\\n * ```solidity\\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\\n * keccak256(\\\"Mail(address to,string contents)\\\"),\\n * mailTo,\\n * keccak256(bytes(mailContents))\\n * )));\\n * address signer = ECDSA.recover(digest, signature);\\n * ```\\n */\\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\\n }\\n}\\n\",\"keccak256\":\"0x6688fad58b9ec0286d40fa957152e575d5d8bd4c3aa80985efdb11b44f776ae7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a * b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"contracts/Soulbound2FA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\nimport \\\"./libraries/Errors.sol\\\";\\nimport \\\"./tokens/MasaSBTSelfSovereign.sol\\\";\\n\\n/// @title Soulbound Two-factor authentication (2FA)\\n/// @author Masa Finance\\n/// @notice Soulbound token that represents a Two-factor authentication (2FA)\\n/// @dev Soulbound 2FA, that inherits from the SBT contract.\\ncontract Soulbound2FA is MasaSBTSelfSovereign, ReentrancyGuard {\\n /* ========== STATE VARIABLES =========================================== */\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound Two-factor authentication (2FA)\\n /// @dev Creates a new soulbound 2FA, inheriting from the SBT contract.\\n /// @param admin Administrator of the smart contract\\n /// @param baseTokenURI Base URI of the token\\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\\n /// @param paymentParams Payment gateway params\\n constructor(\\n address admin,\\n string memory baseTokenURI,\\n ISoulboundIdentity soulboundIdentity,\\n PaymentParams memory paymentParams\\n )\\n MasaSBTSelfSovereign(\\n admin,\\n \\\"Masa 2FA\\\",\\n \\\"M2F\\\",\\n baseTokenURI,\\n soulboundIdentity,\\n paymentParams\\n )\\n EIP712(\\\"Soulbound2FA\\\", \\\"1.0.0\\\")\\n {}\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /// @notice Mints a new SBT\\n /// @dev The caller must have the MINTER role\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param identityId TokenId of the identity to mint the NFT to\\n /// @param authorityAddress Address of the authority that signed the message\\n /// @param signatureDate Date of the signature\\n /// @param signature Signature of the message\\n /// @return The NFT ID of the newly minted SBT\\n function mint(\\n address paymentMethod,\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate,\\n bytes calldata signature\\n ) public payable virtual nonReentrant returns (uint256) {\\n address to = soulboundIdentity.ownerOf(identityId);\\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\\n\\n _verify(\\n _hash(identityId, authorityAddress, signatureDate),\\n signature,\\n authorityAddress\\n );\\n\\n _pay(paymentMethod, getMintPrice(paymentMethod));\\n\\n uint256 tokenId = _mintWithCounter(to);\\n\\n emit Soulbound2FAMintedToIdentity(\\n tokenId,\\n identityId,\\n authorityAddress,\\n signatureDate,\\n paymentMethod,\\n mintPrice\\n );\\n\\n return tokenId;\\n }\\n\\n /// @notice Mints a new SBT\\n /// @dev The caller must have the MINTER role\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param to The address to mint the SBT to\\n /// @param authorityAddress Address of the authority that signed the message\\n /// @param signatureDate Date of the signature\\n /// @param signature Signature of the message\\n /// @return The SBT ID of the newly minted SBT\\n function mint(\\n address paymentMethod,\\n address to,\\n address authorityAddress,\\n uint256 signatureDate,\\n bytes calldata signature\\n ) external payable virtual returns (uint256) {\\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\\n\\n _verify(\\n _hash(to, authorityAddress, signatureDate),\\n signature,\\n authorityAddress\\n );\\n\\n _pay(paymentMethod, getMintPrice(paymentMethod));\\n\\n uint256 tokenId = _mintWithCounter(to);\\n\\n emit Soulbound2FAMintedToAddress(\\n tokenId,\\n to,\\n authorityAddress,\\n signatureDate,\\n paymentMethod,\\n mintPrice\\n );\\n\\n return tokenId;\\n }\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _hash(\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate\\n ) internal view returns (bytes32) {\\n return\\n _hashTypedDataV4(\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Mint2FA(uint256 identityId,address authorityAddress,uint256 signatureDate)\\\"\\n ),\\n identityId,\\n authorityAddress,\\n signatureDate\\n )\\n )\\n );\\n }\\n\\n function _hash(\\n address to,\\n address authorityAddress,\\n uint256 signatureDate\\n ) internal view returns (bytes32) {\\n return\\n _hashTypedDataV4(\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Mint2FA(address to,address authorityAddress,uint256 signatureDate)\\\"\\n ),\\n to,\\n authorityAddress,\\n signatureDate\\n )\\n )\\n );\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n\\n event Soulbound2FAMintedToIdentity(\\n uint256 tokenId,\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate,\\n address paymentMethod,\\n uint256 mintPrice\\n );\\n\\n event Soulbound2FAMintedToAddress(\\n uint256 tokenId,\\n address to,\\n address authorityAddress,\\n uint256 signatureDate,\\n address paymentMethod,\\n uint256 mintPrice\\n );\\n}\\n\",\"keccak256\":\"0x09363a0ec6d1313b4f3164262b699566875e0738b075c730a58414dfd8afddb6\",\"license\":\"MIT\"},\"contracts/dex/PaymentGateway.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/dex/IUniswapRouter.sol\\\";\\n\\n/// @title Pay using a Decentralized automated market maker (AMM) when needed\\n/// @author Masa Finance\\n/// @notice Smart contract to call a Dex AMM smart contract to pay to a reserve wallet recipient\\n/// @dev This smart contract will call the Uniswap Router interface, based on\\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\\nabstract contract PaymentGateway is AccessControl {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n\\n struct PaymentParams {\\n address swapRouter; // Swap router address\\n address wrappedNativeToken; // Wrapped native token address\\n address stableCoin; // Stable coin to pay the fee in (USDC)\\n address masaToken; // Utility token to pay the fee in (MASA)\\n address reserveWallet; // Wallet that will receive the fee\\n }\\n\\n /* ========== STATE VARIABLES =========================================== */\\n\\n address public swapRouter;\\n address public wrappedNativeToken;\\n\\n address public stableCoin; // USDC. It also needs to be enabled as payment method, if we want to pay in USDC\\n address public masaToken; // MASA. It also needs to be enabled as payment method, if we want to pay in MASA\\n\\n // enabled payment methods: ETH and ERC20 tokens\\n mapping(address => bool) public enabledPaymentMethod;\\n address[] public enabledPaymentMethods;\\n\\n address public reserveWallet;\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new Dex AMM\\n /// @dev Creates a new Decentralized automated market maker (AMM) smart contract,\\n // that will call the Uniswap Router interface\\n /// @param admin Administrator of the smart contract\\n /// @param paymentParams Payment params\\n constructor(address admin, PaymentParams memory paymentParams) {\\n if (paymentParams.swapRouter == address(0)) revert ZeroAddress();\\n if (paymentParams.wrappedNativeToken == address(0))\\n revert ZeroAddress();\\n if (paymentParams.stableCoin == address(0)) revert ZeroAddress();\\n if (paymentParams.reserveWallet == address(0)) revert ZeroAddress();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\\n\\n swapRouter = paymentParams.swapRouter;\\n wrappedNativeToken = paymentParams.wrappedNativeToken;\\n stableCoin = paymentParams.stableCoin;\\n masaToken = paymentParams.masaToken;\\n reserveWallet = paymentParams.reserveWallet;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the swap router address\\n /// @dev The caller must have the admin role to call this function\\n /// @param _swapRouter New swap router address\\n function setSwapRouter(address _swapRouter)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_swapRouter == address(0)) revert ZeroAddress();\\n if (swapRouter == _swapRouter) revert SameValue();\\n swapRouter = _swapRouter;\\n }\\n\\n /// @notice Sets the wrapped native token address\\n /// @dev The caller must have the admin role to call this function\\n /// @param _wrappedNativeToken New wrapped native token address\\n function setWrappedNativeToken(address _wrappedNativeToken)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_wrappedNativeToken == address(0)) revert ZeroAddress();\\n if (wrappedNativeToken == _wrappedNativeToken) revert SameValue();\\n wrappedNativeToken = _wrappedNativeToken;\\n }\\n\\n /// @notice Sets the stable coin to pay the fee in (USDC)\\n /// @dev The caller must have the admin role to call this function\\n /// @param _stableCoin New stable coin to pay the fee in\\n function setStableCoin(address _stableCoin)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_stableCoin == address(0)) revert ZeroAddress();\\n if (stableCoin == _stableCoin) revert SameValue();\\n stableCoin = _stableCoin;\\n }\\n\\n /// @notice Sets the utility token to pay the fee in (MASA)\\n /// @dev The caller must have the admin role to call this function\\n /// It can be set to address(0) to disable paying in MASA\\n /// @param _masaToken New utility token to pay the fee in\\n function setMasaToken(address _masaToken)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (masaToken == _masaToken) revert SameValue();\\n masaToken = _masaToken;\\n }\\n\\n /// @notice Adds a new token as a valid payment method\\n /// @dev The caller must have the admin role to call this function\\n /// @param _paymentMethod New token to add\\n function enablePaymentMethod(address _paymentMethod)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (enabledPaymentMethod[_paymentMethod]) revert AlreadyAdded();\\n\\n enabledPaymentMethod[_paymentMethod] = true;\\n enabledPaymentMethods.push(_paymentMethod);\\n }\\n\\n /// @notice Removes a token as a valid payment method\\n /// @dev The caller must have the admin role to call this function\\n /// @param _paymentMethod Token to remove\\n function disablePaymentMethod(address _paymentMethod)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (!enabledPaymentMethod[_paymentMethod])\\n revert NonExistingErc20Token(_paymentMethod);\\n\\n enabledPaymentMethod[_paymentMethod] = false;\\n for (uint256 i = 0; i < enabledPaymentMethods.length; i++) {\\n if (enabledPaymentMethods[i] == _paymentMethod) {\\n enabledPaymentMethods[i] = enabledPaymentMethods[\\n enabledPaymentMethods.length - 1\\n ];\\n enabledPaymentMethods.pop();\\n break;\\n }\\n }\\n }\\n\\n /// @notice Set the reserve wallet\\n /// @dev The caller must have the admin role to call this function\\n /// @param _reserveWallet New reserve wallet\\n function setReserveWallet(address _reserveWallet)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_reserveWallet == address(0)) revert ZeroAddress();\\n if (_reserveWallet == reserveWallet) revert SameValue();\\n reserveWallet = _reserveWallet;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns all available payment methods\\n /// @dev Returns the address of all available payment methods\\n /// @return Array of all enabled payment methods\\n function getEnabledPaymentMethods()\\n external\\n view\\n returns (address[] memory)\\n {\\n return enabledPaymentMethods;\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n /// @notice Converts an amount from a stable coin to a payment method amount\\n /// @dev This method will perform the swap between the stable coin and the\\n /// payment method, and return the amount of the payment method,\\n /// performing the swap if necessary\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param amount Price to be converted in the specified payment method\\n function _convertFromStableCoin(address paymentMethod, uint256 amount)\\n internal\\n view\\n returns (uint256)\\n {\\n if (!enabledPaymentMethod[paymentMethod] || paymentMethod == stableCoin)\\n revert InvalidToken(paymentMethod);\\n\\n if (paymentMethod == address(0)) {\\n return _estimateSwapAmount(wrappedNativeToken, stableCoin, amount);\\n } else {\\n return _estimateSwapAmount(paymentMethod, stableCoin, amount);\\n }\\n }\\n\\n /// @notice Performs the payment in any payment method\\n /// @dev This method will transfer the funds to the reserve wallet, performing\\n /// the swap if necessary\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param amount Price to be paid in the specified payment method\\n function _pay(address paymentMethod, uint256 amount) internal {\\n if (amount == 0) return;\\n if (!enabledPaymentMethod[paymentMethod])\\n revert InvalidPaymentMethod(paymentMethod);\\n if (paymentMethod == address(0)) {\\n // ETH\\n if (msg.value < amount) revert InsufficientEthAmount(amount);\\n (bool success, ) = payable(reserveWallet).call{value: amount}(\\\"\\\");\\n if (!success) revert TransferFailed();\\n if (msg.value > amount) {\\n // return diff\\n uint256 refund = msg.value.sub(amount);\\n (success, ) = payable(msg.sender).call{value: refund}(\\\"\\\");\\n if (!success) revert RefundFailed();\\n }\\n } else {\\n // ERC20 token, including MASA and USDC\\n IERC20(paymentMethod).safeTransferFrom(\\n msg.sender,\\n reserveWallet,\\n amount\\n );\\n }\\n }\\n\\n function _estimateSwapAmount(\\n address _fromToken,\\n address _toToken,\\n uint256 _amountOut\\n ) private view returns (uint256) {\\n uint256[] memory amounts;\\n address[] memory path;\\n path = _getPathFromTokenToToken(_fromToken, _toToken);\\n amounts = IUniswapRouter(swapRouter).getAmountsIn(_amountOut, path);\\n return amounts[0];\\n }\\n\\n function _getPathFromTokenToToken(address fromToken, address toToken)\\n private\\n view\\n returns (address[] memory)\\n {\\n if (fromToken == wrappedNativeToken || toToken == wrappedNativeToken) {\\n address[] memory path = new address[](2);\\n path[0] = fromToken == wrappedNativeToken\\n ? wrappedNativeToken\\n : fromToken;\\n path[1] = toToken == wrappedNativeToken\\n ? wrappedNativeToken\\n : toToken;\\n return path;\\n } else {\\n address[] memory path = new address[](3);\\n path[0] = fromToken;\\n path[1] = wrappedNativeToken;\\n path[2] = toToken;\\n return path;\\n }\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0xe5262dbf09717fd9c0283f2ec1b519062e525d36edd399f42f8ae9325564d0b1\",\"license\":\"MIT\"},\"contracts/interfaces/ILinkableSBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../tokens/SBT/ISBT.sol\\\";\\n\\ninterface ILinkableSBT is ISBT {\\n function addLinkPrice() external view returns (uint256);\\n\\n function addLinkPriceMASA() external view returns (uint256);\\n\\n function queryLinkPrice() external view returns (uint256);\\n\\n function queryLinkPriceMASA() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x1015d56aa9b3250816385ea78bb865a315d1882313e43381df64b587016bd3c0\",\"license\":\"MIT\"},\"contracts/interfaces/ISoulName.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\ninterface ISoulName {\\n function mint(\\n address to,\\n string memory name,\\n uint256 yearsPeriod,\\n string memory _tokenURI\\n ) external returns (uint256);\\n\\n function getExtension() external view returns (string memory);\\n\\n function isAvailable(string memory name)\\n external\\n view\\n returns (bool available);\\n\\n function getTokenData(string memory name)\\n external\\n view\\n returns (\\n string memory sbtName,\\n bool linked,\\n uint256 identityId,\\n uint256 tokenId,\\n uint256 expirationDate,\\n bool active\\n );\\n\\n function getTokenId(string memory name) external view returns (uint256);\\n\\n function getSoulNames(address owner)\\n external\\n view\\n returns (string[] memory sbtNames);\\n\\n function getSoulNames(uint256 identityId)\\n external\\n view\\n returns (string[] memory sbtNames);\\n}\\n\",\"keccak256\":\"0x8793d235ae8c9d723280f7ef0b35f1fb8a3fd0a706c7d9943c7a68db850e31c7\",\"license\":\"MIT\"},\"contracts/interfaces/ISoulboundIdentity.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../tokens/SBT/ISBT.sol\\\";\\n\\nimport \\\"./ISoulName.sol\\\";\\n\\ninterface ISoulboundIdentity is ISBT {\\n function mint(address to) external returns (uint256);\\n\\n function mintIdentityWithName(\\n address to,\\n string memory name,\\n uint256 yearsPeriod,\\n string memory _tokenURI\\n ) external returns (uint256);\\n\\n function getSoulName() external view returns (ISoulName);\\n\\n function tokenOfOwner(address owner) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x443506c61e4b65b8587c43928ed004d880feb4e272a56f474bb8def5d9090c0a\",\"license\":\"MIT\"},\"contracts/interfaces/dex/IUniswapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\n/// @title Uniswap Router interface\\n/// @author Masa Finance\\n/// @notice Interface of the Uniswap Router contract\\n/// @dev This interface is used to interact with the Uniswap Router contract,\\n/// and gets the most important functions of the contract. It's based on\\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\\ninterface IUniswapRouter {\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function getAmountsOut(uint256 amountIn, address[] calldata path)\\n external\\n view\\n returns (uint256[] memory amounts);\\n\\n function getAmountsIn(uint256 amountOut, address[] calldata path)\\n external\\n view\\n returns (uint256[] memory amounts);\\n}\\n\",\"keccak256\":\"0xc5821fe554ec90d78f9d0fc5a627346e9e0542a9af5722e6707933853c867d4f\",\"license\":\"MIT\"},\"contracts/libraries/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nerror AddressDoesNotHaveIdentity(address to);\\nerror AlreadyAdded();\\nerror AuthorityNotExists(address authority);\\nerror CallerNotOwner(address caller);\\nerror CallerNotReader(address caller);\\nerror CreditScoreAlreadyCreated(address to);\\nerror IdentityAlreadyCreated(address to);\\nerror IdentityOwnerIsReader(uint256 readerIdentityId);\\nerror InsufficientEthAmount(uint256 amount);\\nerror IdentityOwnerNotTokenOwner(uint256 tokenId, uint256 ownerIdentityId);\\nerror InvalidPaymentMethod(address paymentMethod);\\nerror InvalidSignature();\\nerror InvalidSignatureDate(uint256 signatureDate);\\nerror InvalidToken(address token);\\nerror InvalidTokenURI(string tokenURI);\\nerror LinkAlreadyExists(\\n address token,\\n uint256 tokenId,\\n uint256 readerIdentityId,\\n uint256 signatureDate\\n);\\nerror LinkAlreadyRevoked();\\nerror LinkDoesNotExist();\\nerror NameAlreadyExists(string name);\\nerror NameNotFound(string name);\\nerror NameRegisteredByOtherAccount(string name, uint256 tokenId);\\nerror NotAuthorized(address signer);\\nerror NonExistingErc20Token(address erc20token);\\nerror NotLinkedToAnIdentitySBT();\\nerror RefundFailed();\\nerror SameValue();\\nerror SBTAlreadyLinked(address token);\\nerror SoulNameContractNotSet();\\nerror TokenNotFound(uint256 tokenId);\\nerror TransferFailed();\\nerror URIAlreadyExists(string tokenURI);\\nerror ValidPeriodExpired(uint256 expirationDate);\\nerror ZeroAddress();\\nerror ZeroLengthName(string name);\\nerror ZeroYearsPeriod(uint256 yearsPeriod);\\n\",\"keccak256\":\"0x6f844a5a2149390d1ad7113b302b7ae539c27b0e861133554dbe8c2e00fb99e7\",\"license\":\"MIT\"},\"contracts/tokens/MasaSBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/ILinkableSBT.sol\\\";\\nimport \\\"./SBT/SBT.sol\\\";\\nimport \\\"./SBT/extensions/SBTEnumerable.sol\\\";\\nimport \\\"./SBT/extensions/SBTBurnable.sol\\\";\\n\\n/// @title MasaSBT\\n/// @author Masa Finance\\n/// @notice Soulbound token. Non-fungible token that is not transferable.\\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\\nabstract contract MasaSBT is\\n SBT,\\n SBTEnumerable,\\n AccessControl,\\n SBTBurnable,\\n ILinkableSBT\\n{\\n /* ========== STATE VARIABLES =========================================== */\\n\\n using Strings for uint256;\\n\\n string private _baseTokenURI;\\n\\n uint256 public override addLinkPrice; // price in stable coin\\n uint256 public override addLinkPriceMASA; // price in MASA\\n uint256 public override queryLinkPrice; // price in stable coin\\n uint256 public override queryLinkPriceMASA; // price in MASA\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound token\\n /// @dev Creates a new soulbound token\\n /// @param admin Administrator of the smart contract\\n /// @param name Name of the token\\n /// @param symbol Symbol of the token\\n /// @param baseTokenURI Base URI of the token\\n constructor(\\n address admin,\\n string memory name,\\n string memory symbol,\\n string memory baseTokenURI\\n ) SBT(name, symbol) {\\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\\n\\n _baseTokenURI = baseTokenURI;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the price for adding the link in SoulLinker in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _addLinkPrice New price for adding the link in SoulLinker in stable coin\\n function setAddLinkPrice(uint256 _addLinkPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (addLinkPrice == _addLinkPrice) revert SameValue();\\n addLinkPrice = _addLinkPrice;\\n }\\n\\n /// @notice Sets the price for adding the link in SoulLinker in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _addLinkPriceMASA New price for adding the link in SoulLinker in MASA\\n function setAddLinkPriceMASA(uint256 _addLinkPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (addLinkPriceMASA == _addLinkPriceMASA) revert SameValue();\\n addLinkPriceMASA = _addLinkPriceMASA;\\n }\\n\\n /// @notice Sets the price for reading data in SoulLinker in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _queryLinkPrice New price for reading data in SoulLinker in stable coin\\n function setQueryLinkPrice(uint256 _queryLinkPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (queryLinkPrice == _queryLinkPrice) revert SameValue();\\n queryLinkPrice = _queryLinkPrice;\\n }\\n\\n /// @notice Sets the price for reading data in SoulLinker in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _queryLinkPriceMASA New price for reading data in SoulLinker in MASA\\n function setQueryLinkPriceMASA(uint256 _queryLinkPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (queryLinkPriceMASA == _queryLinkPriceMASA) revert SameValue();\\n queryLinkPriceMASA = _queryLinkPriceMASA;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns true if the token exists\\n /// @dev Returns true if the token has been minted\\n /// @param tokenId Token to check\\n /// @return True if the token exists\\n function exists(uint256 tokenId) external view returns (bool) {\\n return _exists(tokenId);\\n }\\n\\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\\n /// @dev Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC\\n /// 3986. The URI may point to a JSON file that conforms to the \\\"ERC721\\n /// Metadata JSON Schema\\\".\\n /// @param tokenId SBT to get the URI of\\n /// @return URI of the SBT\\n function tokenURI(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (string memory)\\n {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return\\n bytes(baseURI).length > 0\\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \\\".json\\\"))\\n : \\\"\\\";\\n }\\n\\n /// @notice Query if a contract implements an interface\\n /// @dev Interface identification is specified in ERC-165.\\n /// @param interfaceId The interface identifier, as specified in ERC-165\\n /// @return `true` if the contract implements `interfaceId` and\\n /// `interfaceId` is not 0xffffffff, `false` otherwise\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(SBT, SBTEnumerable, AccessControl, IERC165)\\n returns (bool)\\n {\\n return super.supportsInterface(interfaceId);\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _baseURI() internal view virtual override returns (string memory) {\\n return _baseTokenURI;\\n }\\n\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual override(SBT, SBTEnumerable) {\\n super._beforeTokenTransfer(from, to, tokenId);\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0x97a3f6aba32056305a1831e553d0557c4d9f4eed7407962ec47902d6699d7e37\",\"license\":\"MIT\"},\"contracts/tokens/MasaSBTSelfSovereign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Counters.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/ISoulboundIdentity.sol\\\";\\nimport \\\"../dex/PaymentGateway.sol\\\";\\nimport \\\"./MasaSBT.sol\\\";\\n\\n/// @title MasaSBTSelfSovereign\\n/// @author Masa Finance\\n/// @notice Soulbound token. Non-fungible token that is not transferable.\\n/// Adds a link to a SoulboundIdentity SC to let minting using the identityId\\n/// Adds a payment gateway to let minting paying a fee\\n/// Adds a self-sovereign protocol to let minting using an authority signature\\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\\nabstract contract MasaSBTSelfSovereign is PaymentGateway, MasaSBT, EIP712 {\\n /* ========== STATE VARIABLES =========================================== */\\n\\n using Counters for Counters.Counter;\\n\\n Counters.Counter private _tokenIdCounter;\\n\\n ISoulboundIdentity public soulboundIdentity;\\n\\n uint256 public mintPrice; // price in stable coin\\n uint256 public mintPriceMASA; // price in MASA\\n\\n mapping(address => bool) public authorities;\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound token\\n /// @dev Creates a new soulbound token\\n /// @param admin Administrator of the smart contract\\n /// @param name Name of the token\\n /// @param symbol Symbol of the token\\n /// @param baseTokenURI Base URI of the token\\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\\n /// @param paymentParams Payment gateway params\\n constructor(\\n address admin,\\n string memory name,\\n string memory symbol,\\n string memory baseTokenURI,\\n ISoulboundIdentity _soulboundIdentity,\\n PaymentParams memory paymentParams\\n )\\n PaymentGateway(admin, paymentParams)\\n MasaSBT(admin, name, symbol, baseTokenURI)\\n {\\n soulboundIdentity = _soulboundIdentity;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the SoulboundIdentity contract address linked to this SBT\\n /// @dev The caller must be the admin to call this function\\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\\n soulboundIdentity = _soulboundIdentity;\\n }\\n\\n /// @notice Sets the price of minting in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _mintPrice New price of minting in stable coin\\n function setMintPrice(uint256 _mintPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (mintPrice == _mintPrice) revert SameValue();\\n mintPrice = _mintPrice;\\n }\\n\\n /// @notice Sets the price of minting in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _mintPriceMASA New price of minting in MASA\\n function setMintPriceMASA(uint256 _mintPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (mintPriceMASA == _mintPriceMASA) revert SameValue();\\n mintPriceMASA = _mintPriceMASA;\\n }\\n\\n /// @notice Adds a new authority to the list of authorities\\n /// @dev The caller must have the admin role to call this function\\n /// @param _authority New authority to add\\n function addAuthority(address _authority)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_authority == address(0)) revert ZeroAddress();\\n if (authorities[_authority]) revert AlreadyAdded();\\n\\n authorities[_authority] = true;\\n }\\n\\n /// @notice Removes an authority from the list of authorities\\n /// @dev The caller must have the admin role to call this function\\n /// @param _authority Authority to remove\\n function removeAuthority(address _authority)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_authority == address(0)) revert ZeroAddress();\\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\\n\\n authorities[_authority] = false;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns the identityId owned by the given token\\n /// @param tokenId Id of the token\\n /// @return Id of the identity\\n function getIdentityId(uint256 tokenId) external view returns (uint256) {\\n if (soulboundIdentity == ISoulboundIdentity(address(0)))\\n revert NotLinkedToAnIdentitySBT();\\n\\n address owner = super.ownerOf(tokenId);\\n return soulboundIdentity.tokenOfOwner(owner);\\n }\\n\\n /// @notice Returns the price for minting\\n /// @dev Returns current pricing for minting\\n /// @param paymentMethod Address of token that user want to pay\\n /// @return Current price for minting in the given payment method\\n function getMintPrice(address paymentMethod) public view returns (uint256) {\\n if (mintPrice == 0 && mintPriceMASA == 0) {\\n return 0;\\n } else if (\\n paymentMethod == masaToken &&\\n enabledPaymentMethod[paymentMethod] &&\\n mintPriceMASA > 0\\n ) {\\n // price in MASA without conversion rate\\n return mintPriceMASA;\\n } else if (\\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\\n ) {\\n // stable coin\\n return mintPrice;\\n } else if (enabledPaymentMethod[paymentMethod]) {\\n // ETH and ERC 20 token\\n return _convertFromStableCoin(paymentMethod, mintPrice);\\n } else {\\n revert InvalidPaymentMethod(paymentMethod);\\n }\\n }\\n\\n /// @notice Query if a contract implements an interface\\n /// @dev Interface identification is specified in ERC-165.\\n /// @param interfaceId The interface identifier, as specified in ERC-165\\n /// @return `true` if the contract implements `interfaceId` and\\n /// `interfaceId` is not 0xffffffff, `false` otherwise\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(AccessControl, MasaSBT)\\n returns (bool)\\n {\\n return super.supportsInterface(interfaceId);\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _verify(\\n bytes32 digest,\\n bytes memory signature,\\n address signer\\n ) internal view {\\n address _signer = ECDSA.recover(digest, signature);\\n if (_signer != signer) revert InvalidSignature();\\n if (!authorities[_signer]) revert NotAuthorized(_signer);\\n }\\n\\n function _mintWithCounter(address to) internal virtual returns (uint256) {\\n uint256 tokenId = _tokenIdCounter.current();\\n _tokenIdCounter.increment();\\n _mint(to, tokenId);\\n\\n return tokenId;\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0xbfdfe31ae30bc6cb5ba35cb273d7acb3f905ca50c9f107e06a4d1bc54ed238d2\",\"license\":\"MIT\"},\"contracts/tokens/SBT/ISBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ninterface ISBT is IERC165 {\\n /// @dev This emits when an SBT is newly minted.\\n /// This event emits when SBTs are created\\n event Mint(address indexed _owner, uint256 indexed _tokenId);\\n\\n /// @dev This emits when an SBT is burned\\n /// This event emits when SBTs are destroyed\\n event Burn(address indexed _owner, uint256 indexed _tokenId);\\n\\n /// @notice Count all SBTs assigned to an owner\\n /// @dev SBTs assigned to the zero address are considered invalid, and this\\n /// function throws for queries about the zero address.\\n /// @param _owner An address for whom to query the balance\\n /// @return The number of SBTs owned by `_owner`, possibly zero\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice Find the owner of an SBT\\n /// @dev SBTs assigned to zero address are considered invalid, and queries\\n /// about them do throw.\\n /// @param _tokenId The identifier for an SBT\\n /// @return The address of the owner of the SBT\\n function ownerOf(uint256 _tokenId) external view returns (address);\\n}\\n\",\"keccak256\":\"0xe3bbe44185c28e82bafd54b2197ea0971af74864dd1e7148ac4bbc673d52d738\",\"license\":\"MIT\"},\"contracts/tokens/SBT/SBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/ERC165.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\n\\nimport \\\"./ISBT.sol\\\";\\nimport \\\"./extensions/ISBTMetadata.sol\\\";\\n\\n/// @title SBT\\n/// @author Masa Finance\\n/// @notice Soulbound token is an NFT token that is not transferable.\\ncontract SBT is Context, ERC165, ISBT, ISBTMetadata {\\n using Strings for uint256;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Mapping from token ID to owner address\\n mapping(uint256 => address) private _owners;\\n\\n // Mapping owner address to token count\\n mapping(address => uint256) private _balances;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(ERC165, IERC165)\\n returns (bool)\\n {\\n return\\n interfaceId == type(ISBT).interfaceId ||\\n interfaceId == type(ISBTMetadata).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {ISBT-balanceOf}.\\n */\\n function balanceOf(address owner)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(owner != address(0), \\\"SBT: address zero is not a valid owner\\\");\\n return _balances[owner];\\n }\\n\\n /**\\n * @dev See {ISBT-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (address)\\n {\\n address owner = _owners[tokenId];\\n require(owner != address(0), \\\"SBT: invalid token ID\\\");\\n return owner;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (string memory)\\n {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return\\n bytes(baseURI).length > 0\\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\\n : \\\"\\\";\\n }\\n\\n /**\\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\\n * by default, can be overridden in child contracts.\\n */\\n function _baseURI() internal view virtual returns (string memory) {\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isOwner(address spender, uint256 tokenId)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n address owner = SBT.ownerOf(tokenId);\\n return (spender == owner);\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _owners[tokenId] != address(0);\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Mint} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"SBT: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"SBT: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId);\\n\\n _balances[to] += 1;\\n _owners[tokenId] = to;\\n\\n emit Mint(to, tokenId);\\n\\n _afterTokenTransfer(address(0), to, tokenId);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n *\\n * Requirements:\\n * - `tokenId` must exist.\\n *\\n * Emits a {Burn} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = SBT.ownerOf(tokenId);\\n\\n _beforeTokenTransfer(owner, address(0), tokenId);\\n\\n _balances[owner] -= 1;\\n delete _owners[tokenId];\\n\\n emit Burn(owner, tokenId);\\n\\n _afterTokenTransfer(owner, address(0), tokenId);\\n }\\n\\n /**\\n * @dev Reverts if the `tokenId` has not been minted yet.\\n */\\n function _requireMinted(uint256 tokenId) internal view virtual {\\n require(_exists(tokenId), \\\"SBT: invalid token ID\\\");\\n }\\n\\n /**\\n * @dev Hook that is called before any token minting/burning\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address,\\n address,\\n uint256\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any minting/burning of tokens\\n *\\n * Calling conditions:\\n * - when `from` and `to` are both non-zero.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address,\\n address,\\n uint256\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x0248d73f3daa5e2fe5d306a0366e56f6f3c85ba461de46a3f0c5235b9d19af0e\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/ISBTEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../ISBT.sol\\\";\\n\\n/**\\n * @title SBT Soulbound Token Standard, optional enumeration extension\\n */\\ninterface ISBTEnumerable is ISBT {\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x3cfc53065d044d199a7af437aa9768d4a777caf702b2634ae65b4f896ba9ef3c\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/ISBTMetadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../ISBT.sol\\\";\\n\\n/**\\n * @title SBT Soulbound Token Standard, optional metadata extension\\n */\\ninterface ISBTMetadata is ISBT {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xfaff9e3f2be62198273767a93c4a82bcbe2909be23ec48fdbf5f1564fb690aee\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/SBTBurnable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\n\\nimport \\\"../SBT.sol\\\";\\n\\n/**\\n * @title SBT Burnable Token\\n * @dev SBT Token that can be burned (destroyed).\\n */\\nabstract contract SBTBurnable is Context, SBT {\\n /**\\n * @dev Burns `tokenId`. See {SBT-_burn}.\\n *\\n * Requirements:\\n *\\n * - The caller must own `tokenId` or be an approved operator.\\n */\\n function burn(uint256 tokenId) public virtual {\\n //solhint-disable-next-line max-line-length\\n require(\\n _isOwner(_msgSender(), tokenId),\\n \\\"SBT: caller is not token owner\\\"\\n );\\n _burn(tokenId);\\n }\\n}\\n\",\"keccak256\":\"0xffdf66fb4023f2aa75bc8bdf4ea2b8d27380f3fb4f1df8a65793f6605de10966\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/SBTEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../SBT.sol\\\";\\nimport \\\"./ISBTEnumerable.sol\\\";\\n\\n/**\\n * @dev This implements an optional extension of {SBT} defined in the EIP that adds\\n * enumerability of all the token ids in the contract as well as all token ids owned by each\\n * account.\\n */\\nabstract contract SBTEnumerable is SBT, ISBTEnumerable {\\n // Mapping from owner to list of owned token IDs\\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\\n\\n // Mapping from token ID to index of the owner tokens list\\n mapping(uint256 => uint256) private _ownedTokensIndex;\\n\\n // Array with all token ids, used for enumeration\\n uint256[] private _allTokens;\\n\\n // Mapping from token id to position in the allTokens array\\n mapping(uint256 => uint256) private _allTokensIndex;\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(IERC165, SBT)\\n returns (bool)\\n {\\n return\\n interfaceId == type(ISBTEnumerable).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-tokenOfOwnerByIndex}.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(\\n index < SBT.balanceOf(owner),\\n \\\"SBTEnumerable: owner index out of bounds\\\"\\n );\\n return _ownedTokens[owner][index];\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _allTokens.length;\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-tokenByIndex}.\\n */\\n function tokenByIndex(uint256 index)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(\\n index < SBTEnumerable.totalSupply(),\\n \\\"SBTEnumerable: global index out of bounds\\\"\\n );\\n return _allTokens[index];\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting\\n * and burning.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual override {\\n super._beforeTokenTransfer(from, to, tokenId);\\n\\n if (from == address(0)) {\\n _addTokenToAllTokensEnumeration(tokenId);\\n } else if (from != to) {\\n _removeTokenFromOwnerEnumeration(from, tokenId);\\n }\\n if (to == address(0)) {\\n _removeTokenFromAllTokensEnumeration(tokenId);\\n } else if (to != from) {\\n _addTokenToOwnerEnumeration(to, tokenId);\\n }\\n }\\n\\n /**\\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\\n * @param to address representing the new owner of the given token ID\\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\\n */\\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\\n uint256 length = SBT.balanceOf(to);\\n _ownedTokens[to][length] = tokenId;\\n _ownedTokensIndex[tokenId] = length;\\n }\\n\\n /**\\n * @dev Private function to add a token to this extension's token tracking data structures.\\n * @param tokenId uint256 ID of the token to be added to the tokens list\\n */\\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\\n _allTokensIndex[tokenId] = _allTokens.length;\\n _allTokens.push(tokenId);\\n }\\n\\n /**\\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\\n * @param from address representing the previous owner of the given token ID\\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\\n */\\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)\\n private\\n {\\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\\n // then delete the last slot (swap and pop).\\n\\n uint256 lastTokenIndex = SBT.balanceOf(from) - 1;\\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\\n\\n // When the token to delete is the last token, the swap operation is unnecessary\\n if (tokenIndex != lastTokenIndex) {\\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\\n\\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\\n }\\n\\n // This also deletes the contents at the last position of the array\\n delete _ownedTokensIndex[tokenId];\\n delete _ownedTokens[from][lastTokenIndex];\\n }\\n\\n /**\\n * @dev Private function to remove a token from this extension's token tracking data structures.\\n * This has O(1) time complexity, but alters the order of the _allTokens array.\\n * @param tokenId uint256 ID of the token to be removed from the tokens list\\n */\\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\\n // then delete the last slot (swap and pop).\\n\\n uint256 lastTokenIndex = _allTokens.length - 1;\\n uint256 tokenIndex = _allTokensIndex[tokenId];\\n\\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\\n uint256 lastTokenId = _allTokens[lastTokenIndex];\\n\\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\\n\\n // This also deletes the contents at the last position of the array\\n delete _allTokensIndex[tokenId];\\n _allTokens.pop();\\n }\\n}\\n\",\"keccak256\":\"0x6d18005011564b08decc293aed48684d29cc6872e1d5ace5514e42b86ea675a5\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x6101406040523480156200001257600080fd5b50604051620042f8380380620042f88339810160408190526200003591620005a4565b83604051806040016040528060088152602001674d6173612032464160c01b8152506040518060400160405280600381526020016226992360e91b8152508585856040518060400160405280600c81526020016b536f756c626f756e6432464160a01b815250604051806040016040528060058152602001640312e302e360dc1b815250878787878b8784848160009080519060200190620000d9929190620003d7565b508051620000ef906001906020840190620003d7565b505081516001600160a01b0316151590506200011e5760405163d92e233d60e01b815260040160405180910390fd5b60208101516001600160a01b03166200014a5760405163d92e233d60e01b815260040160405180910390fd5b60408101516001600160a01b0316620001765760405163d92e233d60e01b815260040160405180910390fd5b60808101516001600160a01b0316620001a25760405163d92e233d60e01b815260040160405180910390fd5b620001af600083620002e3565b8051600980546001600160a01b03199081166001600160a01b03938416179091556020830151600a805483169184169190911790556040830151600b805483169184169190911790556060830151600c80548316918416919091179055608090920151600f80549093169116179055506200022c600085620002e3565b805162000241906010906020840190620003d7565b5050845160208087019190912085519186019190912060e08290526101008190524660a05290935091507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90506200029b8184846200036e565b6080523060601b60c052610120525050601680546001600160a01b0319166001600160a01b03959095169490941790935550506001601a5550620007fc975050505050505050565b620002ef8282620003aa565b6200036a5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620003293390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600083838346306040516020016200038b95949392919062000647565b6040516020818303038152906040528051906020012090509392505050565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b828054620003e5906200073e565b90600052602060002090601f01602090048101928262000409576000855562000454565b82601f106200042457805160ff191683800117855562000454565b8280016001018555821562000454579182015b828111156200045457825182559160200191906001019062000437565b506200046292915062000466565b5090565b5b8082111562000462576000815560010162000467565b6000620004946200048e84620006bc565b6200069d565b905082815260208101848484011115620004b157620004b1600080fd5b620004be8482856200070b565b509392505050565b8051620003d181620007d7565b8051620003d181620007f1565b600082601f830112620004f657620004f6600080fd5b8151620005088482602086016200047d565b949350505050565b600060a08284031215620005275762000527600080fd5b6200053360a06200069d565b90506000620005438484620004c6565b82525060206200055684848301620004c6565b60208301525060406200056c84828501620004c6565b60408301525060606200058284828501620004c6565b60608301525060806200059884828501620004c6565b60808301525092915050565b6000806000806101008587031215620005c057620005c0600080fd5b6000620005ce8787620004c6565b94505060208501516001600160401b03811115620005ef57620005ef600080fd5b620005fd87828801620004e0565b93505060406200061087828801620004d3565b9250506060620006238782880162000510565b91505092959194509250565b6200063a81620006ec565b82525050565b806200063a565b60a0810162000657828862000640565b62000666602083018762000640565b62000675604083018662000640565b62000684606083018562000640565b6200069360808301846200062f565b9695505050505050565b6000620006a960405190565b9050620006b782826200076f565b919050565b60006001600160401b03821115620006d857620006d8620007b7565b620006e382620007cd565b60200192915050565b60006001600160a01b038216620003d1565b6000620003d182620006ec565b60005b83811015620007285781810151838201526020016200070e565b8381111562000738576000848401525b50505050565b6002810460018216806200075357607f821691505b60208210811415620007695762000769620007a1565b50919050565b6200077a82620007cd565b81018181106001600160401b03821117156200079a576200079a620007b7565b6040525050565b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b620007e281620006ec565b8114620007ee57600080fd5b50565b620007e281620006fe565b60805160a05160c05160601c60e0516101005161012051613aa96200084f600039600061220a0152600061224c0152600061222b0152600061218f015260006121b9015260006121e30152613aa96000f3fe60806040526004361061025a5760003560e01c806301ffc9a71461025f5780630513c3e91461029557806306fdde03146102c257806310200519146102e457806313150b481461030657806317fcb39b1461032957806318160ddd146103495780631830e8811461035e5780631f37c1241461037457806320d558aa1461038a57806323af4e171461039d578063248a9ca3146103bf57806326defa73146103df578063289c686b146103ff5780632f2ff15d1461041f5780632f745c591461043f57806336568abe1461045f5780633ad3033e1461047f5780633c72ae701461049f57806341273657146104bf57806342966c68146104df5780634962a158146104ff5780634f558e791461051f5780634f6ccce71461053f5780636352211e1461055f5780636817c76c1461057f57806370a0823114610595578063719d0f2b146105b557806376ad1997146105d5578063776d1a54146105f557806377bed5ed1461060b5780637a0d1646146106385780637ad09dff146106685780637db8cb681461067b57806391223d691461069b57806391d14854146106cb57806394a665e9146106eb57806395d89b411461070b578063992642e514610720578063a217fddf14610740578063b97d6b2314610755578063c1177d191461076b578063c31c9c071461078b578063c86aadb6146107ab578063c87b56dd146107cb578063d544e010146107eb578063d547741f1461080b578063d72b11bd1461082b578063da058ae31461084b578063dda4fa8f1461086b578063ebda43961461088b578063f4a0a528146108ab578063fd48ac83146108cb575b600080fd5b34801561026b57600080fd5b5061027f61027a366004612f33565b6108eb565b60405161028c919061356d565b60405180910390f35b3480156102a157600080fd5b506102b56102b0366004612edf565b6108fc565b60405161028c9190613526565b3480156102ce57600080fd5b506102d7610926565b60405161028c919061365a565b3480156102f057600080fd5b506102f96109b8565b60405161028c919061355c565b34801561031257600080fd5b5061031c60145481565b60405161028c919061357b565b34801561033557600080fd5b50600a546102b5906001600160a01b031681565b34801561035557600080fd5b5060065461031c565b34801561036a57600080fd5b5061031c60185481565b34801561038057600080fd5b5061031c60115481565b61031c610398366004612e4b565b610a19565b3480156103a957600080fd5b506103bd6103b8366004612d37565b610bba565b005b3480156103cb57600080fd5b5061031c6103da366004612edf565b610c3e565b3480156103eb57600080fd5b506103bd6103fa366004612d37565b610c53565b34801561040b57600080fd5b506103bd61041a366004612edf565b610ce4565b34801561042b57600080fd5b506103bd61043a366004612f00565b610d18565b34801561044b57600080fd5b5061031c61045a366004612e0e565b610d39565b34801561046b57600080fd5b506103bd61047a366004612f00565b610d8b565b34801561048b57600080fd5b506103bd61049a366004612f54565b610dc1565b3480156104ab57600080fd5b506103bd6104ba366004612edf565b610e1e565b3480156104cb57600080fd5b506103bd6104da366004612d37565b610e52565b3480156104eb57600080fd5b506103bd6104fa366004612edf565b610ed6565b34801561050b57600080fd5b506103bd61051a366004612edf565b610f08565b34801561052b57600080fd5b5061027f61053a366004612edf565b610f3c565b34801561054b57600080fd5b5061031c61055a366004612edf565b610f47565b34801561056b57600080fd5b506102b561057a366004612edf565b610f95565b34801561058b57600080fd5b5061031c60175481565b3480156105a157600080fd5b5061031c6105b0366004612d37565b610fca565b3480156105c157600080fd5b5061031c6105d0366004612d37565b61100e565b3480156105e157600080fd5b506103bd6105f0366004612d37565b61110e565b34801561060157600080fd5b5061031c60125481565b34801561061757600080fd5b5060165461062b906001600160a01b031681565b60405161028c919061364c565b34801561064457600080fd5b5061027f610653366004612d37565b600d6020526000908152604090205460ff1681565b61031c610676366004612d79565b61116b565b34801561068757600080fd5b506103bd610696366004612edf565b611239565b3480156106a757600080fd5b5061027f6106b6366004612d37565b60196020526000908152604090205460ff1681565b3480156106d757600080fd5b5061027f6106e6366004612f00565b61126d565b3480156106f757600080fd5b506103bd610706366004612d37565b611298565b34801561071757600080fd5b506102d7611405565b34801561072c57600080fd5b50600b546102b5906001600160a01b031681565b34801561074c57600080fd5b5061031c600081565b34801561076157600080fd5b5061031c60135481565b34801561077757600080fd5b5061031c610786366004612edf565b611414565b34801561079757600080fd5b506009546102b5906001600160a01b031681565b3480156107b757600080fd5b506103bd6107c6366004612d37565b6114d3565b3480156107d757600080fd5b506102d76107e6366004612edf565b61157f565b3480156107f757600080fd5b506103bd610806366004612d37565b6115e5565b34801561081757600080fd5b506103bd610826366004612f00565b611674565b34801561083757600080fd5b50600f546102b5906001600160a01b031681565b34801561085757600080fd5b506103bd610866366004612d37565b611690565b34801561087757600080fd5b506103bd610886366004612d37565b611714565b34801561089757600080fd5b50600c546102b5906001600160a01b031681565b3480156108b757600080fd5b506103bd6108c6366004612edf565b611798565b3480156108d757600080fd5b506103bd6108e6366004612edf565b6117cc565b60006108f682611800565b92915050565b600e818154811061090c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600080546109359061390b565b80601f01602080910402602001604051908101604052809291908181526020018280546109619061390b565b80156109ae5780601f10610983576101008083540402835291602001916109ae565b820191906000526020600020905b81548152906001019060200180831161099157829003601f168201915b5050505050905090565b6060600e8054806020026020016040519081016040528092919081815260200182805480156109ae57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f2575050505050905090565b60006002601a541415610a475760405162461bcd60e51b8152600401610a3e9061375b565b60405180910390fd5b6002601a556016546040516331a9108f60e11b81526000916001600160a01b031690636352211e90610a7d908a9060040161357b565b60206040518083038186803b158015610a9557600080fd5b505afa158015610aa9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acd9190612d58565b90506001600160a01b0381163314610afb57335b60405163060296c760e31b8152600401610a3e9190613526565b610b47610b0988888861180b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b925061186a915050565b610b5988610b548a61100e565b6118eb565b6000610b6482611a91565b90507f2acd987f463cc0a2358ed0e6aafd383842212a5d7b82c9fb5e0999a44733c490818989898d601754604051610ba1969594939291906137ea565b60405180910390a16001601a5598975050505050505050565b6000610bc581611ab7565b6001600160a01b038216610bec5760405163d92e233d60e01b815260040160405180910390fd5b600b546001600160a01b0383811691161415610c1b5760405163c23f6ccb60e01b815260040160405180910390fd5b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526008602052604090206001015490565b6000610c5e81611ab7565b6001600160a01b038216610c855760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1615610cbf5760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000908152601960205260409020805460ff19166001179055565b6000610cef81611ab7565b816011541415610d125760405163c23f6ccb60e01b815260040160405180910390fd5b50601155565b610d2182610c3e565b610d2a81611ab7565b610d348383611ac1565b505050565b6000610d4483610fca565b8210610d625760405162461bcd60e51b8152600401610a3e906136ab565b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b0381163314610db35760405162461bcd60e51b8152600401610a3e9061376b565b610dbd8282611b47565b5050565b6000610dcc81611ab7565b6016546001600160a01b0383811691161415610dfb5760405163c23f6ccb60e01b815260040160405180910390fd5b50601680546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e2981611ab7565b816012541415610e4c5760405163c23f6ccb60e01b815260040160405180910390fd5b50601255565b6000610e5d81611ab7565b6001600160a01b038216610e845760405163d92e233d60e01b815260040160405180910390fd5b6009546001600160a01b0383811691161415610eb35760405163c23f6ccb60e01b815260040160405180910390fd5b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b610ee03382611bae565b610efc5760405162461bcd60e51b8152600401610a3e906136eb565b610f0581611bd1565b50565b6000610f1381611ab7565b816018541415610f365760405163c23f6ccb60e01b815260040160405180910390fd5b50601855565b60006108f682611c6b565b6000610f5260065490565b8210610f705760405162461bcd60e51b8152600401610a3e9061374b565b60068281548110610f8357610f83613a02565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108f65760405162461bcd60e51b8152600401610a3e9061371b565b60006001600160a01b038216610ff25760405162461bcd60e51b8152600401610a3e906136db565b506001600160a01b031660009081526003602052604090205490565b600060175460001480156110225750601854155b1561102f57506000919050565b600c546001600160a01b03838116911614801561106457506001600160a01b0382166000908152600d602052604090205460ff165b801561107257506000601854115b1561107f57505060185490565b600b546001600160a01b0383811691161480156110b457506001600160a01b0382166000908152600d602052604090205460ff165b156110c157505060175490565b6001600160a01b0382166000908152600d602052604090205460ff16156110ee576108f682601754611c88565b81604051630ac29ab760e31b8152600401610a3e9190613526565b919050565b600061111981611ab7565b600c546001600160a01b03838116911614156111485760405163c23f6ccb60e01b815260040160405180910390fd5b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03861633146111835733610ae1565b6111cf611191878787611d27565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061186a915050565b6111dc87610b548961100e565b60006111e787611a91565b90507fba3afdf6e7965ed8d31aeefc9ffbaf04262d250621df85cef0ef13a8a4487cba818888888c6017546040516112249695949392919061377b565b60405180910390a190505b9695505050505050565b600061124481611ab7565b8160145414156112675760405163c23f6ccb60e01b815260040160405180910390fd5b50601455565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006112a381611ab7565b6001600160a01b0382166000908152600d602052604090205460ff166112de57816040516318317bd560e01b8152600401610a3e9190613526565b6001600160a01b0382166000908152600d60205260408120805460ff191690555b600e54811015610d3457826001600160a01b0316600e828154811061132657611326613a02565b6000918252602090912001546001600160a01b031614156113f357600e80546113519060019061388a565b8154811061136157611361613a02565b600091825260209091200154600e80546001600160a01b03909216918390811061138d5761138d613a02565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e8054806113cc576113cc6139ec565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b806113fd81613965565b9150506112ff565b6060600180546109359061390b565b6016546000906001600160a01b031661144057604051630d7fe67b60e41b815260040160405180910390fd5b600061144b83610f95565b60165460405163294cdf0d60e01b81529192506001600160a01b03169063294cdf0d9061147c908490600401613526565b60206040518083038186803b15801561149457600080fd5b505afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc9190612f75565b9392505050565b60006114de81611ab7565b6001600160a01b0382166000908152600d602052604090205460ff16156115185760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600e805491820181559091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319169091179055565b606061158a82611d63565b6000611594611d88565b905060008151116115b457604051806020016040528060008152506114cc565b806115be84611d97565b6040516020016115cf92919061346d565b6040516020818303038152906040529392505050565b60006115f081611ab7565b6001600160a01b0382166116175760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1661165257816040516324b1f80560e21b8152600401610a3e9190613526565b506001600160a01b03166000908152601960205260409020805460ff19169055565b61167d82610c3e565b61168681611ab7565b610d348383611b47565b600061169b81611ab7565b6001600160a01b0382166116c25760405163d92e233d60e01b815260040160405180910390fd5b600a546001600160a01b03838116911614156116f15760405163c23f6ccb60e01b815260040160405180910390fd5b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061171f81611ab7565b6001600160a01b0382166117465760405163d92e233d60e01b815260040160405180910390fd5b600f546001600160a01b03838116911614156117755760405163c23f6ccb60e01b815260040160405180910390fd5b50600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006117a381611ab7565b8160175414156117c65760405163c23f6ccb60e01b815260040160405180910390fd5b50601755565b60006117d781611ab7565b8160135414156117fa5760405163c23f6ccb60e01b815260040160405180910390fd5b50601355565b60006108f682611e94565b60006118627f34ec28456d08f4e49693917808b7282a69eadae2824d33b92474bc8bdfdb7be68585856040516020016118479493929190613609565b60405160208183030381529060405280519060200120611eb9565b949350505050565b60006118768484611ecc565b9050816001600160a01b0316816001600160a01b0316146118aa57604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b03811660009081526019602052604090205460ff166118e55780604051634a0bfec160e01b8152600401610a3e9190613526565b50505050565b806118f4575050565b6001600160a01b0382166000908152600d602052604090205460ff1661192f5781604051630ac29ab760e31b8152600401610a3e9190613526565b6001600160a01b038216611a755780341015611960578060405163091a6d0f60e01b8152600401610a3e919061357b565b600f546040516000916001600160a01b031690839061197e906134cc565b60006040518083038185875af1925050503d80600081146119bb576040519150601f19603f3d011682016040523d82523d6000602084013e6119c0565b606091505b50509050806119e2576040516312171d8360e31b815260040160405180910390fd5b81341115610d345760006119f63484611ef0565b9050336001600160a01b031681604051611a0f906134cc565b60006040518083038185875af1925050503d8060008114611a4c576040519150601f19603f3d011682016040523d82523d6000602084013e611a51565b606091505b505080925050816118e557604051633c31275160e21b815260040160405180910390fd5b600f54610dbd906001600160a01b038481169133911684611efc565b600080611a9d60155490565b9050611aad601580546001019055565b6108f68382611f54565b610f058133612030565b611acb828261126d565b610dbd5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611b51828261126d565b15610dbd5760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611bba83610f95565b6001600160a01b0385811691161491505092915050565b6000611bdc82610f95565b9050611bea81600084612094565b6001600160a01b0381166000908152600360205260408120805460019290611c1390849061388a565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6001600160a01b0382166000908152600d602052604081205460ff161580611cbd5750600b546001600160a01b038481169116145b15611cdd578260405163961c9a4f60e01b8152600401610a3e9190613526565b6001600160a01b038316611d0f57600a54600b54611d08916001600160a01b0390811691168461209f565b90506108f6565b600b54611d089084906001600160a01b03168461209f565b60006118627fe84d61ea5268441d87c5a96690bcc830d3d14781947a5181464911a7ff7dcc5d8585856040516020016118479493929190613589565b611d6c81611c6b565b610f055760405162461bcd60e51b8152600401610a3e9061371b565b6060601080546109359061390b565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf81613965565b9150611dde9050600a83613857565b9150611dbf565b6000816001600160401b03811115611dff57611dff613a18565b6040519080825280601f01601f191660200182016040528015611e29576020820181803683370190505b5090505b841561186257611e3e60018361388a565b9150611e4b600a86613980565b611e5690603061383f565b60f81b818381518110611e6b57611e6b613a02565b60200101906001600160f81b031916908160001a905350611e8d600a86613857565b9450611e2d565b60006001600160e01b03198216637965db0b60e01b14806108f657506108f68261215d565b60006108f6611ec6612182565b83612275565b6000806000611edb85856122a8565b91509150611ee8816122ee565b509392505050565b60006114cc828461388a565b6118e5846323b872dd60e01b858585604051602401611f1d93929190613534565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526123d3565b6001600160a01b038216611f7a5760405162461bcd60e51b8152600401610a3e9061369b565b611f8381611c6b565b15611fa05760405162461bcd60e51b8152600401610a3e9061370b565b611fac60008383612094565b6001600160a01b0382166000908152600360205260408120805460019290611fd590849061383f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b61203a828261126d565b610dbd57612052816001600160a01b03166014612462565b61205d836020612462565b60405160200161206e9291906134d4565b60408051601f198184030181529082905262461bcd60e51b8252610a3e9160040161365a565b610d348383836125cd565b60006060806120ae8686612685565b6009546040516307c0329d60e21b81529192506001600160a01b031690631f00ca74906120e190879085906004016137ca565b60006040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121359190810190612e84565b91508160008151811061214a5761214a613a02565b6020026020010151925050509392505050565b60006001600160e01b0319821663780e9d6360e01b14806108f657506108f682612817565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156121db57507f000000000000000000000000000000000000000000000000000000000000000046145b1561220557507f000000000000000000000000000000000000000000000000000000000000000090565b6122707f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612867565b905090565b6000828260405160200161228a92919061349b565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156122df5760208301516040840151606085015160001a6122d3878285856128a1565b945094505050506122e7565b506000905060025b9250929050565b6000816004811115612302576123026139c0565b141561230b5750565b600181600481111561231f5761231f6139c0565b141561233d5760405162461bcd60e51b8152600401610a3e9061366b565b6002816004811115612351576123516139c0565b141561236f5760405162461bcd60e51b8152600401610a3e9061368b565b6003816004811115612383576123836139c0565b14156123a15760405162461bcd60e51b8152600401610a3e906136bb565b60048160048111156123b5576123b56139c0565b1415610f055760405162461bcd60e51b8152600401610a3e906136fb565b6000612428826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129779092919063ffffffff16565b805190915015610d3457808060200190518101906124469190612ebe565b610d345760405162461bcd60e51b8152600401610a3e9061373b565b6060600061247183600261386b565b61247c90600261383f565b6001600160401b0381111561249357612493613a18565b6040519080825280601f01601f1916602001820160405280156124bd576020820181803683370190505b509050600360fc1b816000815181106124d8576124d8613a02565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061250757612507613a02565b60200101906001600160f81b031916908160001a905350600061252b84600261386b565b61253690600161383f565b90505b60018111156125ae576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256a5761256a613a02565b1a60f81b82828151811061258057612580613a02565b60200101906001600160f81b031916908160001a90535060049490941c936125a7816138f4565b9050612539565b5083156114cc5760405162461bcd60e51b8152600401610a3e9061367b565b6001600160a01b0383166126285761262381600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b61264b565b816001600160a01b0316836001600160a01b03161461264b5761264b8382612986565b6001600160a01b03821661266257610d3481612a23565b826001600160a01b0316826001600160a01b031614610d3457610d348282612ad2565b600a546060906001600160a01b03848116911614806126b15750600a546001600160a01b038381169116145b1561277b5760408051600280825260608201835260009260208301908036833701905050600a549091506001600160a01b038581169116146126f35783612700565b600a546001600160a01b03165b8160008151811061271357612713613a02565b6001600160a01b039283166020918202929092010152600a5484821691161461273c5782612749565b600a546001600160a01b03165b8160018151811061275c5761275c613a02565b6001600160a01b039092166020928302919091019091015290506108f6565b604080516003808252608082019092526000916020820160608036833701905050905083816000815181106127b2576127b2613a02565b6001600160a01b039283166020918202929092010152600a548251911690829060019081106127e3576127e3613a02565b60200260200101906001600160a01b031690816001600160a01b031681525050828160028151811061275c5761275c613a02565b60006001600160e01b031982166313f2a32f60e01b148061284857506001600160e01b03198216635b5e139f60e01b145b806108f657506301ffc9a760e01b6001600160e01b03198316146108f6565b600083838346306040516020016128829594939291906135c7565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156128ce575060009050600361296e565b8460ff16601b141580156128e657508460ff16601c14155b156128f7575060009050600461296e565b60006001878787876040516000815260200160405260405161291c9493929190613624565b6020604051602081039080840390855afa15801561293e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129675760006001925092505061296e565b9150600090505b94509492505050565b60606118628484600085612b16565b6000600161299384610fca565b61299d919061388a565b6000838152600560205260409020549091508082146129f0576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b600654600090612a359060019061388a565b60008381526007602052604081205460068054939450909284908110612a5d57612a5d613a02565b906000526020600020015490508060068381548110612a7e57612a7e613a02565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480612ab657612ab66139ec565b6001900381819060005260206000200160009055905550505050565b6000612add83610fca565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b606082471015612b385760405162461bcd60e51b8152600401610a3e906136cb565b6001600160a01b0385163b612b5f5760405162461bcd60e51b8152600401610a3e9061372b565b600080866001600160a01b03168587604051612b7b9190613461565b60006040518083038185875af1925050503d8060008114612bb8576040519150601f19603f3d011682016040523d82523d6000602084013e612bbd565b606091505b5091509150612bcd828286612bd8565b979650505050505050565b60608315612be75750816114cc565b825115612bf75782518084602001fd5b8160405162461bcd60e51b8152600401610a3e919061365a565b6000612c24612c1f8461381c565b613805565b90508083825260208201905082856020860282011115612c4657612c46600080fd5b60005b85811015612c725781612c5c8882612d2c565b8452506020928301929190910190600101612c49565b5050509392505050565b80356108f681613a38565b80516108f681613a38565b600082601f830112612ca657612ca6600080fd5b8151611862848260208601612c11565b80516108f681613a4c565b80356108f681613a54565b80356108f681613a5a565b60008083601f840112612cec57612cec600080fd5b5081356001600160401b03811115612d0657612d06600080fd5b6020830191508360018202830111156122e7576122e7600080fd5b80356108f681613a6a565b80516108f681613a54565b600060208284031215612d4c57612d4c600080fd5b60006118628484612c7c565b600060208284031215612d6d57612d6d600080fd5b60006118628484612c87565b60008060008060008060a08789031215612d9557612d95600080fd5b6000612da18989612c7c565b9650506020612db289828a01612c7c565b9550506040612dc389828a01612c7c565b9450506060612dd489828a01612cc1565b93505060808701356001600160401b03811115612df357612df3600080fd5b612dff89828a01612cd7565b92509250509295509295509295565b60008060408385031215612e2457612e24600080fd5b6000612e308585612c7c565b9250506020612e4185828601612cc1565b9150509250929050565b60008060008060008060a08789031215612e6757612e67600080fd5b6000612e738989612c7c565b9650506020612db289828a01612cc1565b600060208284031215612e9957612e99600080fd5b81516001600160401b03811115612eb257612eb2600080fd5b61186284828501612c92565b600060208284031215612ed357612ed3600080fd5b60006118628484612cb6565b600060208284031215612ef457612ef4600080fd5b60006118628484612cc1565b60008060408385031215612f1657612f16600080fd5b6000612f228585612cc1565b9250506020612e4185828601612c7c565b600060208284031215612f4857612f48600080fd5b60006118628484612ccc565b600060208284031215612f6957612f69600080fd5b60006118628484612d21565b600060208284031215612f8a57612f8a600080fd5b60006118628484612d2c565b6000612fa28383612faa565b505060200190565b612fb3816138a1565b82525050565b6000612fc3825190565b80845260209384019383018060005b83811015612ff7578151612fe68882612f96565b975060208301925050600101612fd2565b509495945050505050565b801515612fb3565b80612fb3565b600061301a825190565b6130288185602086016138c8565b9290920192915050565b612fb3816138bd565b6000613045825190565b80845260208401935061305c8185602086016138c8565b61306581613a2e565b9093019392505050565b601881526000602082017745434453413a20696e76616c6964207369676e617475726560401b815291505b5060200190565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e749101908152600061309a565b601f81526000602082017f45434453413a20696e76616c6964207369676e6174757265206c656e677468008152915061309a565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061309a565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b6020820152915061317c565b602681526000602082017f416464726573733a20696e73756666696369656e742062616c616e636520666f8152651c8818d85b1b60d21b6020820152915061317c565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b6020820152915061317c565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061309a565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b6020820152915061317c565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061309a565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061309a565b601d81526000602082017f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000008152915061309a565b602a81526000602082017f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b6020820152915061317c565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b6020820152915061317c565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c008152915061309a565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b6020820152915061317c565b60ff8116612fb3565b60006114cc8284613010565b60006134798285613010565b91506134858284613010565b64173539b7b760d91b8152915060058201611862565b61190160f01b815260020160006134b2828561300a565b6020820191506134c2828461300a565b5060200192915050565b6000816108f6565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006135008285613010565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110191506118628284613010565b602081016108f68284612faa565b606081016135428286612faa565b61354f6020830185612faa565b611862604083018461300a565b602080825281016114cc8184612fb9565b602081016108f68284613002565b602081016108f6828461300a565b60808101613597828761300a565b6135a46020830186612faa565b6135b16040830185612faa565b6135be606083018461300a565b95945050505050565b60a081016135d5828861300a565b6135e2602083018761300a565b6135ef604083018661300a565b6135fc606083018561300a565b61122f6080830184612faa565b60808101613617828761300a565b6135a4602083018661300a565b60808101613632828761300a565b61363f6020830186613458565b6135b1604083018561300a565b602081016108f68284613032565b602080825281016114cc818461303b565b602080825281016108f68161306f565b602080825281016108f6816130a1565b602080825281016108f6816130d3565b602080825281016108f681613107565b602080825281016108f68161313b565b602080825281016108f681613183565b602080825281016108f6816131c2565b602080825281016108f681613205565b602080825281016108f681613248565b602080825281016108f68161327c565b602080825281016108f6816132bb565b602080825281016108f6816132eb565b602080825281016108f681613317565b602080825281016108f68161334b565b602080825281016108f681613392565b602080825281016108f6816133d8565b602080825281016108f68161340c565b60c08101613789828961300a565b6137966020830188612faa565b6137a36040830187612faa565b6137b0606083018661300a565b6137bd6080830185612faa565b612bcd60a083018461300a565b604081016137d8828561300a565b81810360208301526118628184612fb9565b60c081016137f8828961300a565b613796602083018861300a565b600061381060405190565b90506111098282613938565b60006001600160401b0382111561383557613835613a18565b5060209081020190565b6000821982111561385257613852613994565b500190565b600082613866576138666139aa565b500490565b600081600019048311821515161561388557613885613994565b500290565b60008282101561389c5761389c613994565b500390565b60006001600160a01b0382166108f6565b60006108f6826138a1565b60006108f6826138b2565b60005b838110156138e35781810151838201526020016138cb565b838111156118e55750506000910152565b60008161390357613903613994565b506000190190565b60028104600182168061391f57607f821691505b60208210811415613932576139326139d6565b50919050565b61394182613a2e565b81018181106001600160401b038211171561395e5761395e613a18565b6040525050565b600060001982141561397957613979613994565b5060010190565b60008261398f5761398f6139aa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b613a41816138a1565b8114610f0557600080fd5b801515613a41565b80613a41565b6001600160e01b03198116613a41565b613a41816138b256fea2646970667358221220d10d652bb5f49377047195872f4159a146a1be86a941ac6fb28339769132b85264736f6c63430008070033", - "deployedBytecode": "0x60806040526004361061025a5760003560e01c806301ffc9a71461025f5780630513c3e91461029557806306fdde03146102c257806310200519146102e457806313150b481461030657806317fcb39b1461032957806318160ddd146103495780631830e8811461035e5780631f37c1241461037457806320d558aa1461038a57806323af4e171461039d578063248a9ca3146103bf57806326defa73146103df578063289c686b146103ff5780632f2ff15d1461041f5780632f745c591461043f57806336568abe1461045f5780633ad3033e1461047f5780633c72ae701461049f57806341273657146104bf57806342966c68146104df5780634962a158146104ff5780634f558e791461051f5780634f6ccce71461053f5780636352211e1461055f5780636817c76c1461057f57806370a0823114610595578063719d0f2b146105b557806376ad1997146105d5578063776d1a54146105f557806377bed5ed1461060b5780637a0d1646146106385780637ad09dff146106685780637db8cb681461067b57806391223d691461069b57806391d14854146106cb57806394a665e9146106eb57806395d89b411461070b578063992642e514610720578063a217fddf14610740578063b97d6b2314610755578063c1177d191461076b578063c31c9c071461078b578063c86aadb6146107ab578063c87b56dd146107cb578063d544e010146107eb578063d547741f1461080b578063d72b11bd1461082b578063da058ae31461084b578063dda4fa8f1461086b578063ebda43961461088b578063f4a0a528146108ab578063fd48ac83146108cb575b600080fd5b34801561026b57600080fd5b5061027f61027a366004612f33565b6108eb565b60405161028c919061356d565b60405180910390f35b3480156102a157600080fd5b506102b56102b0366004612edf565b6108fc565b60405161028c9190613526565b3480156102ce57600080fd5b506102d7610926565b60405161028c919061365a565b3480156102f057600080fd5b506102f96109b8565b60405161028c919061355c565b34801561031257600080fd5b5061031c60145481565b60405161028c919061357b565b34801561033557600080fd5b50600a546102b5906001600160a01b031681565b34801561035557600080fd5b5060065461031c565b34801561036a57600080fd5b5061031c60185481565b34801561038057600080fd5b5061031c60115481565b61031c610398366004612e4b565b610a19565b3480156103a957600080fd5b506103bd6103b8366004612d37565b610bba565b005b3480156103cb57600080fd5b5061031c6103da366004612edf565b610c3e565b3480156103eb57600080fd5b506103bd6103fa366004612d37565b610c53565b34801561040b57600080fd5b506103bd61041a366004612edf565b610ce4565b34801561042b57600080fd5b506103bd61043a366004612f00565b610d18565b34801561044b57600080fd5b5061031c61045a366004612e0e565b610d39565b34801561046b57600080fd5b506103bd61047a366004612f00565b610d8b565b34801561048b57600080fd5b506103bd61049a366004612f54565b610dc1565b3480156104ab57600080fd5b506103bd6104ba366004612edf565b610e1e565b3480156104cb57600080fd5b506103bd6104da366004612d37565b610e52565b3480156104eb57600080fd5b506103bd6104fa366004612edf565b610ed6565b34801561050b57600080fd5b506103bd61051a366004612edf565b610f08565b34801561052b57600080fd5b5061027f61053a366004612edf565b610f3c565b34801561054b57600080fd5b5061031c61055a366004612edf565b610f47565b34801561056b57600080fd5b506102b561057a366004612edf565b610f95565b34801561058b57600080fd5b5061031c60175481565b3480156105a157600080fd5b5061031c6105b0366004612d37565b610fca565b3480156105c157600080fd5b5061031c6105d0366004612d37565b61100e565b3480156105e157600080fd5b506103bd6105f0366004612d37565b61110e565b34801561060157600080fd5b5061031c60125481565b34801561061757600080fd5b5060165461062b906001600160a01b031681565b60405161028c919061364c565b34801561064457600080fd5b5061027f610653366004612d37565b600d6020526000908152604090205460ff1681565b61031c610676366004612d79565b61116b565b34801561068757600080fd5b506103bd610696366004612edf565b611239565b3480156106a757600080fd5b5061027f6106b6366004612d37565b60196020526000908152604090205460ff1681565b3480156106d757600080fd5b5061027f6106e6366004612f00565b61126d565b3480156106f757600080fd5b506103bd610706366004612d37565b611298565b34801561071757600080fd5b506102d7611405565b34801561072c57600080fd5b50600b546102b5906001600160a01b031681565b34801561074c57600080fd5b5061031c600081565b34801561076157600080fd5b5061031c60135481565b34801561077757600080fd5b5061031c610786366004612edf565b611414565b34801561079757600080fd5b506009546102b5906001600160a01b031681565b3480156107b757600080fd5b506103bd6107c6366004612d37565b6114d3565b3480156107d757600080fd5b506102d76107e6366004612edf565b61157f565b3480156107f757600080fd5b506103bd610806366004612d37565b6115e5565b34801561081757600080fd5b506103bd610826366004612f00565b611674565b34801561083757600080fd5b50600f546102b5906001600160a01b031681565b34801561085757600080fd5b506103bd610866366004612d37565b611690565b34801561087757600080fd5b506103bd610886366004612d37565b611714565b34801561089757600080fd5b50600c546102b5906001600160a01b031681565b3480156108b757600080fd5b506103bd6108c6366004612edf565b611798565b3480156108d757600080fd5b506103bd6108e6366004612edf565b6117cc565b60006108f682611800565b92915050565b600e818154811061090c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600080546109359061390b565b80601f01602080910402602001604051908101604052809291908181526020018280546109619061390b565b80156109ae5780601f10610983576101008083540402835291602001916109ae565b820191906000526020600020905b81548152906001019060200180831161099157829003601f168201915b5050505050905090565b6060600e8054806020026020016040519081016040528092919081815260200182805480156109ae57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f2575050505050905090565b60006002601a541415610a475760405162461bcd60e51b8152600401610a3e9061375b565b60405180910390fd5b6002601a556016546040516331a9108f60e11b81526000916001600160a01b031690636352211e90610a7d908a9060040161357b565b60206040518083038186803b158015610a9557600080fd5b505afa158015610aa9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acd9190612d58565b90506001600160a01b0381163314610afb57335b60405163060296c760e31b8152600401610a3e9190613526565b610b47610b0988888861180b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b925061186a915050565b610b5988610b548a61100e565b6118eb565b6000610b6482611a91565b90507f2acd987f463cc0a2358ed0e6aafd383842212a5d7b82c9fb5e0999a44733c490818989898d601754604051610ba1969594939291906137ea565b60405180910390a16001601a5598975050505050505050565b6000610bc581611ab7565b6001600160a01b038216610bec5760405163d92e233d60e01b815260040160405180910390fd5b600b546001600160a01b0383811691161415610c1b5760405163c23f6ccb60e01b815260040160405180910390fd5b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526008602052604090206001015490565b6000610c5e81611ab7565b6001600160a01b038216610c855760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1615610cbf5760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000908152601960205260409020805460ff19166001179055565b6000610cef81611ab7565b816011541415610d125760405163c23f6ccb60e01b815260040160405180910390fd5b50601155565b610d2182610c3e565b610d2a81611ab7565b610d348383611ac1565b505050565b6000610d4483610fca565b8210610d625760405162461bcd60e51b8152600401610a3e906136ab565b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b0381163314610db35760405162461bcd60e51b8152600401610a3e9061376b565b610dbd8282611b47565b5050565b6000610dcc81611ab7565b6016546001600160a01b0383811691161415610dfb5760405163c23f6ccb60e01b815260040160405180910390fd5b50601680546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e2981611ab7565b816012541415610e4c5760405163c23f6ccb60e01b815260040160405180910390fd5b50601255565b6000610e5d81611ab7565b6001600160a01b038216610e845760405163d92e233d60e01b815260040160405180910390fd5b6009546001600160a01b0383811691161415610eb35760405163c23f6ccb60e01b815260040160405180910390fd5b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b610ee03382611bae565b610efc5760405162461bcd60e51b8152600401610a3e906136eb565b610f0581611bd1565b50565b6000610f1381611ab7565b816018541415610f365760405163c23f6ccb60e01b815260040160405180910390fd5b50601855565b60006108f682611c6b565b6000610f5260065490565b8210610f705760405162461bcd60e51b8152600401610a3e9061374b565b60068281548110610f8357610f83613a02565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108f65760405162461bcd60e51b8152600401610a3e9061371b565b60006001600160a01b038216610ff25760405162461bcd60e51b8152600401610a3e906136db565b506001600160a01b031660009081526003602052604090205490565b600060175460001480156110225750601854155b1561102f57506000919050565b600c546001600160a01b03838116911614801561106457506001600160a01b0382166000908152600d602052604090205460ff165b801561107257506000601854115b1561107f57505060185490565b600b546001600160a01b0383811691161480156110b457506001600160a01b0382166000908152600d602052604090205460ff165b156110c157505060175490565b6001600160a01b0382166000908152600d602052604090205460ff16156110ee576108f682601754611c88565b81604051630ac29ab760e31b8152600401610a3e9190613526565b919050565b600061111981611ab7565b600c546001600160a01b03838116911614156111485760405163c23f6ccb60e01b815260040160405180910390fd5b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03861633146111835733610ae1565b6111cf611191878787611d27565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061186a915050565b6111dc87610b548961100e565b60006111e787611a91565b90507fba3afdf6e7965ed8d31aeefc9ffbaf04262d250621df85cef0ef13a8a4487cba818888888c6017546040516112249695949392919061377b565b60405180910390a190505b9695505050505050565b600061124481611ab7565b8160145414156112675760405163c23f6ccb60e01b815260040160405180910390fd5b50601455565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006112a381611ab7565b6001600160a01b0382166000908152600d602052604090205460ff166112de57816040516318317bd560e01b8152600401610a3e9190613526565b6001600160a01b0382166000908152600d60205260408120805460ff191690555b600e54811015610d3457826001600160a01b0316600e828154811061132657611326613a02565b6000918252602090912001546001600160a01b031614156113f357600e80546113519060019061388a565b8154811061136157611361613a02565b600091825260209091200154600e80546001600160a01b03909216918390811061138d5761138d613a02565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e8054806113cc576113cc6139ec565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b806113fd81613965565b9150506112ff565b6060600180546109359061390b565b6016546000906001600160a01b031661144057604051630d7fe67b60e41b815260040160405180910390fd5b600061144b83610f95565b60165460405163294cdf0d60e01b81529192506001600160a01b03169063294cdf0d9061147c908490600401613526565b60206040518083038186803b15801561149457600080fd5b505afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc9190612f75565b9392505050565b60006114de81611ab7565b6001600160a01b0382166000908152600d602052604090205460ff16156115185760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600e805491820181559091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319169091179055565b606061158a82611d63565b6000611594611d88565b905060008151116115b457604051806020016040528060008152506114cc565b806115be84611d97565b6040516020016115cf92919061346d565b6040516020818303038152906040529392505050565b60006115f081611ab7565b6001600160a01b0382166116175760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1661165257816040516324b1f80560e21b8152600401610a3e9190613526565b506001600160a01b03166000908152601960205260409020805460ff19169055565b61167d82610c3e565b61168681611ab7565b610d348383611b47565b600061169b81611ab7565b6001600160a01b0382166116c25760405163d92e233d60e01b815260040160405180910390fd5b600a546001600160a01b03838116911614156116f15760405163c23f6ccb60e01b815260040160405180910390fd5b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061171f81611ab7565b6001600160a01b0382166117465760405163d92e233d60e01b815260040160405180910390fd5b600f546001600160a01b03838116911614156117755760405163c23f6ccb60e01b815260040160405180910390fd5b50600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006117a381611ab7565b8160175414156117c65760405163c23f6ccb60e01b815260040160405180910390fd5b50601755565b60006117d781611ab7565b8160135414156117fa5760405163c23f6ccb60e01b815260040160405180910390fd5b50601355565b60006108f682611e94565b60006118627f34ec28456d08f4e49693917808b7282a69eadae2824d33b92474bc8bdfdb7be68585856040516020016118479493929190613609565b60405160208183030381529060405280519060200120611eb9565b949350505050565b60006118768484611ecc565b9050816001600160a01b0316816001600160a01b0316146118aa57604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b03811660009081526019602052604090205460ff166118e55780604051634a0bfec160e01b8152600401610a3e9190613526565b50505050565b806118f4575050565b6001600160a01b0382166000908152600d602052604090205460ff1661192f5781604051630ac29ab760e31b8152600401610a3e9190613526565b6001600160a01b038216611a755780341015611960578060405163091a6d0f60e01b8152600401610a3e919061357b565b600f546040516000916001600160a01b031690839061197e906134cc565b60006040518083038185875af1925050503d80600081146119bb576040519150601f19603f3d011682016040523d82523d6000602084013e6119c0565b606091505b50509050806119e2576040516312171d8360e31b815260040160405180910390fd5b81341115610d345760006119f63484611ef0565b9050336001600160a01b031681604051611a0f906134cc565b60006040518083038185875af1925050503d8060008114611a4c576040519150601f19603f3d011682016040523d82523d6000602084013e611a51565b606091505b505080925050816118e557604051633c31275160e21b815260040160405180910390fd5b600f54610dbd906001600160a01b038481169133911684611efc565b600080611a9d60155490565b9050611aad601580546001019055565b6108f68382611f54565b610f058133612030565b611acb828261126d565b610dbd5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611b51828261126d565b15610dbd5760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611bba83610f95565b6001600160a01b0385811691161491505092915050565b6000611bdc82610f95565b9050611bea81600084612094565b6001600160a01b0381166000908152600360205260408120805460019290611c1390849061388a565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6001600160a01b0382166000908152600d602052604081205460ff161580611cbd5750600b546001600160a01b038481169116145b15611cdd578260405163961c9a4f60e01b8152600401610a3e9190613526565b6001600160a01b038316611d0f57600a54600b54611d08916001600160a01b0390811691168461209f565b90506108f6565b600b54611d089084906001600160a01b03168461209f565b60006118627fe84d61ea5268441d87c5a96690bcc830d3d14781947a5181464911a7ff7dcc5d8585856040516020016118479493929190613589565b611d6c81611c6b565b610f055760405162461bcd60e51b8152600401610a3e9061371b565b6060601080546109359061390b565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf81613965565b9150611dde9050600a83613857565b9150611dbf565b6000816001600160401b03811115611dff57611dff613a18565b6040519080825280601f01601f191660200182016040528015611e29576020820181803683370190505b5090505b841561186257611e3e60018361388a565b9150611e4b600a86613980565b611e5690603061383f565b60f81b818381518110611e6b57611e6b613a02565b60200101906001600160f81b031916908160001a905350611e8d600a86613857565b9450611e2d565b60006001600160e01b03198216637965db0b60e01b14806108f657506108f68261215d565b60006108f6611ec6612182565b83612275565b6000806000611edb85856122a8565b91509150611ee8816122ee565b509392505050565b60006114cc828461388a565b6118e5846323b872dd60e01b858585604051602401611f1d93929190613534565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526123d3565b6001600160a01b038216611f7a5760405162461bcd60e51b8152600401610a3e9061369b565b611f8381611c6b565b15611fa05760405162461bcd60e51b8152600401610a3e9061370b565b611fac60008383612094565b6001600160a01b0382166000908152600360205260408120805460019290611fd590849061383f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b61203a828261126d565b610dbd57612052816001600160a01b03166014612462565b61205d836020612462565b60405160200161206e9291906134d4565b60408051601f198184030181529082905262461bcd60e51b8252610a3e9160040161365a565b610d348383836125cd565b60006060806120ae8686612685565b6009546040516307c0329d60e21b81529192506001600160a01b031690631f00ca74906120e190879085906004016137ca565b60006040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121359190810190612e84565b91508160008151811061214a5761214a613a02565b6020026020010151925050509392505050565b60006001600160e01b0319821663780e9d6360e01b14806108f657506108f682612817565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156121db57507f000000000000000000000000000000000000000000000000000000000000000046145b1561220557507f000000000000000000000000000000000000000000000000000000000000000090565b6122707f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612867565b905090565b6000828260405160200161228a92919061349b565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156122df5760208301516040840151606085015160001a6122d3878285856128a1565b945094505050506122e7565b506000905060025b9250929050565b6000816004811115612302576123026139c0565b141561230b5750565b600181600481111561231f5761231f6139c0565b141561233d5760405162461bcd60e51b8152600401610a3e9061366b565b6002816004811115612351576123516139c0565b141561236f5760405162461bcd60e51b8152600401610a3e9061368b565b6003816004811115612383576123836139c0565b14156123a15760405162461bcd60e51b8152600401610a3e906136bb565b60048160048111156123b5576123b56139c0565b1415610f055760405162461bcd60e51b8152600401610a3e906136fb565b6000612428826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129779092919063ffffffff16565b805190915015610d3457808060200190518101906124469190612ebe565b610d345760405162461bcd60e51b8152600401610a3e9061373b565b6060600061247183600261386b565b61247c90600261383f565b6001600160401b0381111561249357612493613a18565b6040519080825280601f01601f1916602001820160405280156124bd576020820181803683370190505b509050600360fc1b816000815181106124d8576124d8613a02565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061250757612507613a02565b60200101906001600160f81b031916908160001a905350600061252b84600261386b565b61253690600161383f565b90505b60018111156125ae576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256a5761256a613a02565b1a60f81b82828151811061258057612580613a02565b60200101906001600160f81b031916908160001a90535060049490941c936125a7816138f4565b9050612539565b5083156114cc5760405162461bcd60e51b8152600401610a3e9061367b565b6001600160a01b0383166126285761262381600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b61264b565b816001600160a01b0316836001600160a01b03161461264b5761264b8382612986565b6001600160a01b03821661266257610d3481612a23565b826001600160a01b0316826001600160a01b031614610d3457610d348282612ad2565b600a546060906001600160a01b03848116911614806126b15750600a546001600160a01b038381169116145b1561277b5760408051600280825260608201835260009260208301908036833701905050600a549091506001600160a01b038581169116146126f35783612700565b600a546001600160a01b03165b8160008151811061271357612713613a02565b6001600160a01b039283166020918202929092010152600a5484821691161461273c5782612749565b600a546001600160a01b03165b8160018151811061275c5761275c613a02565b6001600160a01b039092166020928302919091019091015290506108f6565b604080516003808252608082019092526000916020820160608036833701905050905083816000815181106127b2576127b2613a02565b6001600160a01b039283166020918202929092010152600a548251911690829060019081106127e3576127e3613a02565b60200260200101906001600160a01b031690816001600160a01b031681525050828160028151811061275c5761275c613a02565b60006001600160e01b031982166313f2a32f60e01b148061284857506001600160e01b03198216635b5e139f60e01b145b806108f657506301ffc9a760e01b6001600160e01b03198316146108f6565b600083838346306040516020016128829594939291906135c7565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156128ce575060009050600361296e565b8460ff16601b141580156128e657508460ff16601c14155b156128f7575060009050600461296e565b60006001878787876040516000815260200160405260405161291c9493929190613624565b6020604051602081039080840390855afa15801561293e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129675760006001925092505061296e565b9150600090505b94509492505050565b60606118628484600085612b16565b6000600161299384610fca565b61299d919061388a565b6000838152600560205260409020549091508082146129f0576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b600654600090612a359060019061388a565b60008381526007602052604081205460068054939450909284908110612a5d57612a5d613a02565b906000526020600020015490508060068381548110612a7e57612a7e613a02565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480612ab657612ab66139ec565b6001900381819060005260206000200160009055905550505050565b6000612add83610fca565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b606082471015612b385760405162461bcd60e51b8152600401610a3e906136cb565b6001600160a01b0385163b612b5f5760405162461bcd60e51b8152600401610a3e9061372b565b600080866001600160a01b03168587604051612b7b9190613461565b60006040518083038185875af1925050503d8060008114612bb8576040519150601f19603f3d011682016040523d82523d6000602084013e612bbd565b606091505b5091509150612bcd828286612bd8565b979650505050505050565b60608315612be75750816114cc565b825115612bf75782518084602001fd5b8160405162461bcd60e51b8152600401610a3e919061365a565b6000612c24612c1f8461381c565b613805565b90508083825260208201905082856020860282011115612c4657612c46600080fd5b60005b85811015612c725781612c5c8882612d2c565b8452506020928301929190910190600101612c49565b5050509392505050565b80356108f681613a38565b80516108f681613a38565b600082601f830112612ca657612ca6600080fd5b8151611862848260208601612c11565b80516108f681613a4c565b80356108f681613a54565b80356108f681613a5a565b60008083601f840112612cec57612cec600080fd5b5081356001600160401b03811115612d0657612d06600080fd5b6020830191508360018202830111156122e7576122e7600080fd5b80356108f681613a6a565b80516108f681613a54565b600060208284031215612d4c57612d4c600080fd5b60006118628484612c7c565b600060208284031215612d6d57612d6d600080fd5b60006118628484612c87565b60008060008060008060a08789031215612d9557612d95600080fd5b6000612da18989612c7c565b9650506020612db289828a01612c7c565b9550506040612dc389828a01612c7c565b9450506060612dd489828a01612cc1565b93505060808701356001600160401b03811115612df357612df3600080fd5b612dff89828a01612cd7565b92509250509295509295509295565b60008060408385031215612e2457612e24600080fd5b6000612e308585612c7c565b9250506020612e4185828601612cc1565b9150509250929050565b60008060008060008060a08789031215612e6757612e67600080fd5b6000612e738989612c7c565b9650506020612db289828a01612cc1565b600060208284031215612e9957612e99600080fd5b81516001600160401b03811115612eb257612eb2600080fd5b61186284828501612c92565b600060208284031215612ed357612ed3600080fd5b60006118628484612cb6565b600060208284031215612ef457612ef4600080fd5b60006118628484612cc1565b60008060408385031215612f1657612f16600080fd5b6000612f228585612cc1565b9250506020612e4185828601612c7c565b600060208284031215612f4857612f48600080fd5b60006118628484612ccc565b600060208284031215612f6957612f69600080fd5b60006118628484612d21565b600060208284031215612f8a57612f8a600080fd5b60006118628484612d2c565b6000612fa28383612faa565b505060200190565b612fb3816138a1565b82525050565b6000612fc3825190565b80845260209384019383018060005b83811015612ff7578151612fe68882612f96565b975060208301925050600101612fd2565b509495945050505050565b801515612fb3565b80612fb3565b600061301a825190565b6130288185602086016138c8565b9290920192915050565b612fb3816138bd565b6000613045825190565b80845260208401935061305c8185602086016138c8565b61306581613a2e565b9093019392505050565b601881526000602082017745434453413a20696e76616c6964207369676e617475726560401b815291505b5060200190565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e749101908152600061309a565b601f81526000602082017f45434453413a20696e76616c6964207369676e6174757265206c656e677468008152915061309a565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061309a565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b6020820152915061317c565b602681526000602082017f416464726573733a20696e73756666696369656e742062616c616e636520666f8152651c8818d85b1b60d21b6020820152915061317c565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b6020820152915061317c565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061309a565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b6020820152915061317c565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061309a565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061309a565b601d81526000602082017f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000008152915061309a565b602a81526000602082017f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b6020820152915061317c565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b6020820152915061317c565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c008152915061309a565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b6020820152915061317c565b60ff8116612fb3565b60006114cc8284613010565b60006134798285613010565b91506134858284613010565b64173539b7b760d91b8152915060058201611862565b61190160f01b815260020160006134b2828561300a565b6020820191506134c2828461300a565b5060200192915050565b6000816108f6565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006135008285613010565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110191506118628284613010565b602081016108f68284612faa565b606081016135428286612faa565b61354f6020830185612faa565b611862604083018461300a565b602080825281016114cc8184612fb9565b602081016108f68284613002565b602081016108f6828461300a565b60808101613597828761300a565b6135a46020830186612faa565b6135b16040830185612faa565b6135be606083018461300a565b95945050505050565b60a081016135d5828861300a565b6135e2602083018761300a565b6135ef604083018661300a565b6135fc606083018561300a565b61122f6080830184612faa565b60808101613617828761300a565b6135a4602083018661300a565b60808101613632828761300a565b61363f6020830186613458565b6135b1604083018561300a565b602081016108f68284613032565b602080825281016114cc818461303b565b602080825281016108f68161306f565b602080825281016108f6816130a1565b602080825281016108f6816130d3565b602080825281016108f681613107565b602080825281016108f68161313b565b602080825281016108f681613183565b602080825281016108f6816131c2565b602080825281016108f681613205565b602080825281016108f681613248565b602080825281016108f68161327c565b602080825281016108f6816132bb565b602080825281016108f6816132eb565b602080825281016108f681613317565b602080825281016108f68161334b565b602080825281016108f681613392565b602080825281016108f6816133d8565b602080825281016108f68161340c565b60c08101613789828961300a565b6137966020830188612faa565b6137a36040830187612faa565b6137b0606083018661300a565b6137bd6080830185612faa565b612bcd60a083018461300a565b604081016137d8828561300a565b81810360208301526118628184612fb9565b60c081016137f8828961300a565b613796602083018861300a565b600061381060405190565b90506111098282613938565b60006001600160401b0382111561383557613835613a18565b5060209081020190565b6000821982111561385257613852613994565b500190565b600082613866576138666139aa565b500490565b600081600019048311821515161561388557613885613994565b500290565b60008282101561389c5761389c613994565b500390565b60006001600160a01b0382166108f6565b60006108f6826138a1565b60006108f6826138b2565b60005b838110156138e35781810151838201526020016138cb565b838111156118e55750506000910152565b60008161390357613903613994565b506000190190565b60028104600182168061391f57607f821691505b60208210811415613932576139326139d6565b50919050565b61394182613a2e565b81018181106001600160401b038211171561395e5761395e613a18565b6040525050565b600060001982141561397957613979613994565b5060010190565b60008261398f5761398f6139aa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b613a41816138a1565b8114610f0557600080fd5b801515613a41565b80613a41565b6001600160e01b03198116613a41565b613a41816138b256fea2646970667358221220d10d652bb5f49377047195872f4159a146a1be86a941ac6fb28339769132b85264736f6c63430008070033", - "devdoc": { - "author": "Masa Finance", - "details": "Soulbound 2FA, that inherits from the SBT contract.", - "kind": "dev", - "methods": { - "addAuthority(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_authority": "New authority to add" - } - }, - "balanceOf(address)": { - "details": "See {ISBT-balanceOf}." - }, - "burn(uint256)": { - "details": "Burns `tokenId`. See {SBT-_burn}. Requirements: - The caller must own `tokenId` or be an approved operator." - }, - "constructor": { - "details": "Creates a new soulbound 2FA, inheriting from the SBT contract.", - "params": { - "admin": "Administrator of the smart contract", - "baseTokenURI": "Base URI of the token", - "paymentParams": "Payment gateway params", - "soulboundIdentity": "Address of the SoulboundIdentity contract" - } - }, - "disablePaymentMethod(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_paymentMethod": "Token to remove" - } - }, - "enablePaymentMethod(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_paymentMethod": "New token to add" - } - }, - "exists(uint256)": { - "details": "Returns true if the token has been minted", - "params": { - "tokenId": "Token to check" - }, - "returns": { - "_0": "True if the token exists" - } - }, - "getEnabledPaymentMethods()": { - "details": "Returns the address of all available payment methods", - "returns": { - "_0": "Array of all enabled payment methods" - } - }, - "getIdentityId(uint256)": { - "params": { - "tokenId": "Id of the token" - }, - "returns": { - "_0": "Id of the identity" - } - }, - "getMintPrice(address)": { - "details": "Returns current pricing for minting", - "params": { - "paymentMethod": "Address of token that user want to pay" - }, - "returns": { - "_0": "Current price for minting in the given payment method" - } - }, - "getRoleAdmin(bytes32)": { - "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." - }, - "grantRole(bytes32,address)": { - "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event." - }, - "hasRole(bytes32,address)": { - "details": "Returns `true` if `account` has been granted `role`." - }, - "mint(address,address,address,uint256,bytes)": { - "details": "The caller must have the MINTER role", - "params": { - "authorityAddress": "Address of the authority that signed the message", - "paymentMethod": "Address of token that user want to pay", - "signature": "Signature of the message", - "signatureDate": "Date of the signature", - "to": "The address to mint the SBT to" - }, - "returns": { - "_0": "The SBT ID of the newly minted SBT" - } - }, - "mint(address,uint256,address,uint256,bytes)": { - "details": "The caller must have the MINTER role", - "params": { - "authorityAddress": "Address of the authority that signed the message", - "identityId": "TokenId of the identity to mint the NFT to", - "paymentMethod": "Address of token that user want to pay", - "signature": "Signature of the message", - "signatureDate": "Date of the signature" - }, - "returns": { - "_0": "The NFT ID of the newly minted SBT" - } - }, - "name()": { - "details": "See {ISBTMetadata-name}." - }, - "ownerOf(uint256)": { - "details": "See {ISBT-ownerOf}." - }, - "removeAuthority(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_authority": "Authority to remove" - } - }, - "renounceRole(bytes32,address)": { - "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event." - }, - "revokeRole(bytes32,address)": { - "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event." - }, - "setAddLinkPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_addLinkPrice": "New price for adding the link in SoulLinker in stable coin" - } - }, - "setAddLinkPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_addLinkPriceMASA": "New price for adding the link in SoulLinker in MASA" - } - }, - "setMasaToken(address)": { - "details": "The caller must have the admin role to call this function It can be set to address(0) to disable paying in MASA", - "params": { - "_masaToken": "New utility token to pay the fee in" - } - }, - "setMintPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_mintPrice": "New price of minting in stable coin" - } - }, - "setMintPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_mintPriceMASA": "New price of minting in MASA" - } - }, - "setQueryLinkPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_queryLinkPrice": "New price for reading data in SoulLinker in stable coin" - } - }, - "setQueryLinkPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_queryLinkPriceMASA": "New price for reading data in SoulLinker in MASA" - } - }, - "setReserveWallet(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_reserveWallet": "New reserve wallet" - } - }, - "setSoulboundIdentity(address)": { - "details": "The caller must be the admin to call this function", - "params": { - "_soulboundIdentity": "Address of the SoulboundIdentity contract" - } - }, - "setStableCoin(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_stableCoin": "New stable coin to pay the fee in" - } - }, - "setSwapRouter(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_swapRouter": "New swap router address" - } - }, - "setWrappedNativeToken(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_wrappedNativeToken": "New wrapped native token address" - } - }, - "supportsInterface(bytes4)": { - "details": "Interface identification is specified in ERC-165.", - "params": { - "interfaceId": "The interface identifier, as specified in ERC-165" - }, - "returns": { - "_0": "`true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise" - } - }, - "symbol()": { - "details": "See {ISBTMetadata-symbol}." - }, - "tokenByIndex(uint256)": { - "details": "See {ISBTEnumerable-tokenByIndex}." - }, - "tokenOfOwnerByIndex(address,uint256)": { - "details": "See {ISBTEnumerable-tokenOfOwnerByIndex}." - }, - "tokenURI(uint256)": { - "details": "Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the \"ERC721 Metadata JSON Schema\".", - "params": { - "tokenId": "SBT to get the URI of" - }, - "returns": { - "_0": "URI of the SBT" - } - }, - "totalSupply()": { - "details": "See {ISBTEnumerable-totalSupply}." - } - }, - "title": "Soulbound Two-factor authentication (2FA)", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "addAuthority(address)": { - "notice": "Adds a new authority to the list of authorities" - }, - "constructor": { - "notice": "Creates a new soulbound Two-factor authentication (2FA)" - }, - "disablePaymentMethod(address)": { - "notice": "Removes a token as a valid payment method" - }, - "enablePaymentMethod(address)": { - "notice": "Adds a new token as a valid payment method" - }, - "exists(uint256)": { - "notice": "Returns true if the token exists" - }, - "getEnabledPaymentMethods()": { - "notice": "Returns all available payment methods" - }, - "getIdentityId(uint256)": { - "notice": "Returns the identityId owned by the given token" - }, - "getMintPrice(address)": { - "notice": "Returns the price for minting" - }, - "mint(address,address,address,uint256,bytes)": { - "notice": "Mints a new SBT" - }, - "mint(address,uint256,address,uint256,bytes)": { - "notice": "Mints a new SBT" - }, - "removeAuthority(address)": { - "notice": "Removes an authority from the list of authorities" - }, - "setAddLinkPrice(uint256)": { - "notice": "Sets the price for adding the link in SoulLinker in stable coin" - }, - "setAddLinkPriceMASA(uint256)": { - "notice": "Sets the price for adding the link in SoulLinker in MASA" - }, - "setMasaToken(address)": { - "notice": "Sets the utility token to pay the fee in (MASA)" - }, - "setMintPrice(uint256)": { - "notice": "Sets the price of minting in stable coin" - }, - "setMintPriceMASA(uint256)": { - "notice": "Sets the price of minting in MASA" - }, - "setQueryLinkPrice(uint256)": { - "notice": "Sets the price for reading data in SoulLinker in stable coin" - }, - "setQueryLinkPriceMASA(uint256)": { - "notice": "Sets the price for reading data in SoulLinker in MASA" - }, - "setReserveWallet(address)": { - "notice": "Set the reserve wallet" - }, - "setSoulboundIdentity(address)": { - "notice": "Sets the SoulboundIdentity contract address linked to this SBT" - }, - "setStableCoin(address)": { - "notice": "Sets the stable coin to pay the fee in (USDC)" - }, - "setSwapRouter(address)": { - "notice": "Sets the swap router address" - }, - "setWrappedNativeToken(address)": { - "notice": "Sets the wrapped native token address" - }, - "supportsInterface(bytes4)": { - "notice": "Query if a contract implements an interface" - }, - "tokenURI(uint256)": { - "notice": "A distinct Uniform Resource Identifier (URI) for a given asset." - } - }, - "notice": "Soulbound token that represents a Two-factor authentication (2FA)", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 9702, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_name", - "offset": 0, - "slot": "0", - "type": "t_string_storage" - }, - { - "astId": 9704, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_symbol", - "offset": 0, - "slot": "1", - "type": "t_string_storage" - }, - { - "astId": 9708, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_owners", - "offset": 0, - "slot": "2", - "type": "t_mapping(t_uint256,t_address)" - }, - { - "astId": 9712, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_balances", - "offset": 0, - "slot": "3", - "type": "t_mapping(t_address,t_uint256)" - }, - { - "astId": 10171, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_ownedTokens", - "offset": 0, - "slot": "4", - "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))" - }, - { - "astId": 10175, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_ownedTokensIndex", - "offset": 0, - "slot": "5", - "type": "t_mapping(t_uint256,t_uint256)" - }, - { - "astId": 10178, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_allTokens", - "offset": 0, - "slot": "6", - "type": "t_array(t_uint256)dyn_storage" - }, - { - "astId": 10182, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_allTokensIndex", - "offset": 0, - "slot": "7", - "type": "t_mapping(t_uint256,t_uint256)" - }, - { - "astId": 24, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_roles", - "offset": 0, - "slot": "8", - "type": "t_mapping(t_bytes32,t_struct(RoleData)19_storage)" - }, - { - "astId": 7619, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "swapRouter", - "offset": 0, - "slot": "9", - "type": "t_address" - }, - { - "astId": 7621, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "wrappedNativeToken", - "offset": 0, - "slot": "10", - "type": "t_address" - }, - { - "astId": 7623, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "stableCoin", - "offset": 0, - "slot": "11", - "type": "t_address" - }, - { - "astId": 7625, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "masaToken", - "offset": 0, - "slot": "12", - "type": "t_address" - }, - { - "astId": 7629, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "enabledPaymentMethod", - "offset": 0, - "slot": "13", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 7632, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "enabledPaymentMethods", - "offset": 0, - "slot": "14", - "type": "t_array(t_address)dyn_storage" - }, - { - "astId": 7634, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "reserveWallet", - "offset": 0, - "slot": "15", - "type": "t_address" - }, - { - "astId": 8976, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_baseTokenURI", - "offset": 0, - "slot": "16", - "type": "t_string_storage" - }, - { - "astId": 8979, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "addLinkPrice", - "offset": 0, - "slot": "17", - "type": "t_uint256" - }, - { - "astId": 8982, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "addLinkPriceMASA", - "offset": 0, - "slot": "18", - "type": "t_uint256" - }, - { - "astId": 8985, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "queryLinkPrice", - "offset": 0, - "slot": "19", - "type": "t_uint256" - }, - { - "astId": 8988, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "queryLinkPriceMASA", - "offset": 0, - "slot": "20", - "type": "t_uint256" - }, - { - "astId": 9297, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_tokenIdCounter", - "offset": 0, - "slot": "21", - "type": "t_struct(Counter)2798_storage" - }, - { - "astId": 9300, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "soulboundIdentity", - "offset": 0, - "slot": "22", - "type": "t_contract(ISoulboundIdentity)8379" - }, - { - "astId": 9302, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "mintPrice", - "offset": 0, - "slot": "23", - "type": "t_uint256" - }, - { - "astId": 9304, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "mintPriceMASA", - "offset": 0, - "slot": "24", - "type": "t_uint256" - }, - { - "astId": 9308, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "authorities", - "offset": 0, - "slot": "25", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 624, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_status", - "offset": 0, - "slot": "26", - "type": "t_uint256" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_address)dyn_storage": { - "base": "t_address", - "encoding": "dynamic_array", - "label": "address[]", - "numberOfBytes": "32" - }, - "t_array(t_uint256)dyn_storage": { - "base": "t_uint256", - "encoding": "dynamic_array", - "label": "uint256[]", - "numberOfBytes": "32" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_contract(ISoulboundIdentity)8379": { - "encoding": "inplace", - "label": "contract ISoulboundIdentity", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_bool)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => mapping(uint256 => uint256))", - "numberOfBytes": "32", - "value": "t_mapping(t_uint256,t_uint256)" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_bytes32,t_struct(RoleData)19_storage)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => struct AccessControl.RoleData)", - "numberOfBytes": "32", - "value": "t_struct(RoleData)19_storage" - }, - "t_mapping(t_uint256,t_address)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => address)", - "numberOfBytes": "32", - "value": "t_address" - }, - "t_mapping(t_uint256,t_uint256)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_string_storage": { - "encoding": "bytes", - "label": "string", - "numberOfBytes": "32" - }, - "t_struct(Counter)2798_storage": { - "encoding": "inplace", - "label": "struct Counters.Counter", - "members": [ - { - "astId": 2797, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_value", - "offset": 0, - "slot": "0", - "type": "t_uint256" - } - ], - "numberOfBytes": "32" - }, - "t_struct(RoleData)19_storage": { - "encoding": "inplace", - "label": "struct AccessControl.RoleData", - "members": [ - { - "astId": 16, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "members", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 18, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "adminRole", - "offset": 0, - "slot": "1", - "type": "t_bytes32" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} \ No newline at end of file diff --git a/deployments/alfajores/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json b/deployments/alfajores/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json deleted file mode 100644 index 456dfd96a..000000000 --- a/deployments/alfajores/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/dex/PaymentGateway.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/dex/IUniswapRouter.sol\";\n\n/// @title Pay using a Decentralized automated market maker (AMM) when needed\n/// @author Masa Finance\n/// @notice Smart contract to call a Dex AMM smart contract to pay to a reserve wallet recipient\n/// @dev This smart contract will call the Uniswap Router interface, based on\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\nabstract contract PaymentGateway is AccessControl {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n\n struct PaymentParams {\n address swapRouter; // Swap router address\n address wrappedNativeToken; // Wrapped native token address\n address stableCoin; // Stable coin to pay the fee in (USDC)\n address masaToken; // Utility token to pay the fee in (MASA)\n address reserveWallet; // Wallet that will receive the fee\n }\n\n /* ========== STATE VARIABLES =========================================== */\n\n address public swapRouter;\n address public wrappedNativeToken;\n\n address public stableCoin; // USDC. It also needs to be enabled as payment method, if we want to pay in USDC\n address public masaToken; // MASA. It also needs to be enabled as payment method, if we want to pay in MASA\n\n // enabled payment methods: ETH and ERC20 tokens\n mapping(address => bool) public enabledPaymentMethod;\n address[] public enabledPaymentMethods;\n\n address public reserveWallet;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new Dex AMM\n /// @dev Creates a new Decentralized automated market maker (AMM) smart contract,\n // that will call the Uniswap Router interface\n /// @param admin Administrator of the smart contract\n /// @param paymentParams Payment params\n constructor(address admin, PaymentParams memory paymentParams) {\n if (paymentParams.swapRouter == address(0)) revert ZeroAddress();\n if (paymentParams.wrappedNativeToken == address(0))\n revert ZeroAddress();\n if (paymentParams.stableCoin == address(0)) revert ZeroAddress();\n if (paymentParams.reserveWallet == address(0)) revert ZeroAddress();\n\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n\n swapRouter = paymentParams.swapRouter;\n wrappedNativeToken = paymentParams.wrappedNativeToken;\n stableCoin = paymentParams.stableCoin;\n masaToken = paymentParams.masaToken;\n reserveWallet = paymentParams.reserveWallet;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the swap router address\n /// @dev The caller must have the admin role to call this function\n /// @param _swapRouter New swap router address\n function setSwapRouter(address _swapRouter)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_swapRouter == address(0)) revert ZeroAddress();\n if (swapRouter == _swapRouter) revert SameValue();\n swapRouter = _swapRouter;\n }\n\n /// @notice Sets the wrapped native token address\n /// @dev The caller must have the admin role to call this function\n /// @param _wrappedNativeToken New wrapped native token address\n function setWrappedNativeToken(address _wrappedNativeToken)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_wrappedNativeToken == address(0)) revert ZeroAddress();\n if (wrappedNativeToken == _wrappedNativeToken) revert SameValue();\n wrappedNativeToken = _wrappedNativeToken;\n }\n\n /// @notice Sets the stable coin to pay the fee in (USDC)\n /// @dev The caller must have the admin role to call this function\n /// @param _stableCoin New stable coin to pay the fee in\n function setStableCoin(address _stableCoin)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_stableCoin == address(0)) revert ZeroAddress();\n if (stableCoin == _stableCoin) revert SameValue();\n stableCoin = _stableCoin;\n }\n\n /// @notice Sets the utility token to pay the fee in (MASA)\n /// @dev The caller must have the admin role to call this function\n /// It can be set to address(0) to disable paying in MASA\n /// @param _masaToken New utility token to pay the fee in\n function setMasaToken(address _masaToken)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (masaToken == _masaToken) revert SameValue();\n masaToken = _masaToken;\n }\n\n /// @notice Adds a new token as a valid payment method\n /// @dev The caller must have the admin role to call this function\n /// @param _paymentMethod New token to add\n function enablePaymentMethod(address _paymentMethod)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (enabledPaymentMethod[_paymentMethod]) revert AlreadyAdded();\n\n enabledPaymentMethod[_paymentMethod] = true;\n enabledPaymentMethods.push(_paymentMethod);\n }\n\n /// @notice Removes a token as a valid payment method\n /// @dev The caller must have the admin role to call this function\n /// @param _paymentMethod Token to remove\n function disablePaymentMethod(address _paymentMethod)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (!enabledPaymentMethod[_paymentMethod])\n revert NonExistingErc20Token(_paymentMethod);\n\n enabledPaymentMethod[_paymentMethod] = false;\n for (uint256 i = 0; i < enabledPaymentMethods.length; i++) {\n if (enabledPaymentMethods[i] == _paymentMethod) {\n enabledPaymentMethods[i] = enabledPaymentMethods[\n enabledPaymentMethods.length - 1\n ];\n enabledPaymentMethods.pop();\n break;\n }\n }\n }\n\n /// @notice Set the reserve wallet\n /// @dev The caller must have the admin role to call this function\n /// @param _reserveWallet New reserve wallet\n function setReserveWallet(address _reserveWallet)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_reserveWallet == address(0)) revert ZeroAddress();\n if (_reserveWallet == reserveWallet) revert SameValue();\n reserveWallet = _reserveWallet;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns all available payment methods\n /// @dev Returns the address of all available payment methods\n /// @return Array of all enabled payment methods\n function getEnabledPaymentMethods()\n external\n view\n returns (address[] memory)\n {\n return enabledPaymentMethods;\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /// @notice Converts an amount from a stable coin to a payment method amount\n /// @dev This method will perform the swap between the stable coin and the\n /// payment method, and return the amount of the payment method,\n /// performing the swap if necessary\n /// @param paymentMethod Address of token that user want to pay\n /// @param amount Price to be converted in the specified payment method\n function _convertFromStableCoin(address paymentMethod, uint256 amount)\n internal\n view\n returns (uint256)\n {\n if (!enabledPaymentMethod[paymentMethod] || paymentMethod == stableCoin)\n revert InvalidToken(paymentMethod);\n\n if (paymentMethod == address(0)) {\n return _estimateSwapAmount(wrappedNativeToken, stableCoin, amount);\n } else {\n return _estimateSwapAmount(paymentMethod, stableCoin, amount);\n }\n }\n\n /// @notice Performs the payment in any payment method\n /// @dev This method will transfer the funds to the reserve wallet, performing\n /// the swap if necessary\n /// @param paymentMethod Address of token that user want to pay\n /// @param amount Price to be paid in the specified payment method\n function _pay(address paymentMethod, uint256 amount) internal {\n if (amount == 0) return;\n if (!enabledPaymentMethod[paymentMethod])\n revert InvalidPaymentMethod(paymentMethod);\n if (paymentMethod == address(0)) {\n // ETH\n if (msg.value < amount) revert InsufficientEthAmount(amount);\n (bool success, ) = payable(reserveWallet).call{value: amount}(\"\");\n if (!success) revert TransferFailed();\n if (msg.value > amount) {\n // return diff\n uint256 refund = msg.value.sub(amount);\n (success, ) = payable(msg.sender).call{value: refund}(\"\");\n if (!success) revert RefundFailed();\n }\n } else {\n // ERC20 token, including MASA and USDC\n IERC20(paymentMethod).safeTransferFrom(\n msg.sender,\n reserveWallet,\n amount\n );\n }\n }\n\n function _estimateSwapAmount(\n address _fromToken,\n address _toToken,\n uint256 _amountOut\n ) private view returns (uint256) {\n uint256[] memory amounts;\n address[] memory path;\n path = _getPathFromTokenToToken(_fromToken, _toToken);\n amounts = IUniswapRouter(swapRouter).getAmountsIn(_amountOut, path);\n return amounts[0];\n }\n\n function _getPathFromTokenToToken(address fromToken, address toToken)\n private\n view\n returns (address[] memory)\n {\n if (fromToken == wrappedNativeToken || toToken == wrappedNativeToken) {\n address[] memory path = new address[](2);\n path[0] = fromToken == wrappedNativeToken\n ? wrappedNativeToken\n : fromToken;\n path[1] = toToken == wrappedNativeToken\n ? wrappedNativeToken\n : toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = fromToken;\n path[1] = wrappedNativeToken;\n path[2] = toToken;\n return path;\n }\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" - }, - "contracts/libraries/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nerror AddressDoesNotHaveIdentity(address to);\nerror AlreadyAdded();\nerror AuthorityNotExists(address authority);\nerror CallerNotOwner(address caller);\nerror CallerNotReader(address caller);\nerror CreditScoreAlreadyCreated(address to);\nerror IdentityAlreadyCreated(address to);\nerror IdentityOwnerIsReader(uint256 readerIdentityId);\nerror InsufficientEthAmount(uint256 amount);\nerror IdentityOwnerNotTokenOwner(uint256 tokenId, uint256 ownerIdentityId);\nerror InvalidPaymentMethod(address paymentMethod);\nerror InvalidSignature();\nerror InvalidSignatureDate(uint256 signatureDate);\nerror InvalidToken(address token);\nerror InvalidTokenURI(string tokenURI);\nerror LinkAlreadyExists(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId,\n uint256 signatureDate\n);\nerror LinkAlreadyRevoked();\nerror LinkDoesNotExist();\nerror NameAlreadyExists(string name);\nerror NameNotFound(string name);\nerror NameRegisteredByOtherAccount(string name, uint256 tokenId);\nerror NotAuthorized(address signer);\nerror NonExistingErc20Token(address erc20token);\nerror NotLinkedToAnIdentitySBT();\nerror RefundFailed();\nerror SameValue();\nerror SBTAlreadyLinked(address token);\nerror SoulNameContractNotSet();\nerror TokenNotFound(uint256 tokenId);\nerror TransferFailed();\nerror URIAlreadyExists(string tokenURI);\nerror ValidPeriodExpired(uint256 expirationDate);\nerror ZeroAddress();\nerror ZeroLengthName(string name);\nerror ZeroYearsPeriod(uint256 yearsPeriod);\n" - }, - "contracts/interfaces/dex/IUniswapRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\n/// @title Uniswap Router interface\n/// @author Masa Finance\n/// @notice Interface of the Uniswap Router contract\n/// @dev This interface is used to interact with the Uniswap Router contract,\n/// and gets the most important functions of the contract. It's based on\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\ninterface IUniswapRouter {\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "contracts/SoulStore.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./dex/PaymentGateway.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\n\n/// @title Soul Store\n/// @author Masa Finance\n/// @notice Soul Store, that can mint new Soulbound Identities and Soul Name NFTs, paying a fee\n/// @dev From this smart contract we can mint new Soulbound Identities and Soul Name NFTs.\n/// This minting can be done paying a fee in ETH, USDC or MASA\ncontract SoulStore is PaymentGateway, Pausable, ReentrancyGuard, EIP712 {\n using SafeMath for uint256;\n\n /* ========== STATE VARIABLES ========== */\n\n ISoulboundIdentity public soulboundIdentity;\n\n mapping(uint256 => uint256) public nameRegistrationPricePerYear; // (length --> price in stable coin per year)\n\n mapping(address => bool) public authorities;\n\n /* ========== INITIALIZE ========== */\n\n /// @notice Creates a new Soul Store\n /// @dev Creates a new Soul Store, that has the role to minting new Soulbound Identities\n /// and Soul Name NFTs, paying a fee\n /// @param admin Administrator of the smart contract\n /// @param _soulBoundIdentity Address of the Soulbound identity contract\n /// @param _nameRegistrationPricePerYear Price of the default name registering in stable coin per year\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n ISoulboundIdentity _soulBoundIdentity,\n uint256 _nameRegistrationPricePerYear,\n PaymentParams memory paymentParams\n ) PaymentGateway(admin, paymentParams) EIP712(\"SoulStore\", \"1.0.0\") {\n if (address(_soulBoundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulBoundIdentity;\n\n nameRegistrationPricePerYear[0] = _nameRegistrationPricePerYear; // name price for default length per year\n }\n\n /* ========== RESTRICTED FUNCTIONS ========== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this store\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity New SoulboundIdentity contract address\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the price of the name registering per one year in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _nameLength Length of the name\n /// @param _nameRegistrationPricePerYear New price of the name registering per one\n /// year in stable coin for that name length per year\n function setNameRegistrationPricePerYear(\n uint256 _nameLength,\n uint256 _nameRegistrationPricePerYear\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\n if (\n nameRegistrationPricePerYear[_nameLength] ==\n _nameRegistrationPricePerYear\n ) revert SameValue();\n nameRegistrationPricePerYear[\n _nameLength\n ] = _nameRegistrationPricePerYear;\n }\n\n /// @notice Adds a new authority to the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority New authority to add\n function addAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (authorities[_authority]) revert AlreadyAdded();\n\n authorities[_authority] = true;\n }\n\n /// @notice Removes an authority from the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority Authority to remove\n function removeAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\n\n authorities[_authority] = false;\n }\n\n /// @notice Pauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function pause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function unpause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /* ========== MUTATIVE FUNCTIONS ========== */\n\n /// @notice Mints a new Soulbound Identity and Name purchasing it\n /// @dev This function allows the purchase of a soulbound identity and name using\n /// stable coin (USDC), native token (ETH) or utility token (MASA)\n /// @param paymentMethod Address of token that user want to pay\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soulbound identity\n function purchaseIdentityAndName(\n address paymentMethod,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant returns (uint256) {\n _pay(\n paymentMethod,\n getPriceForMintingName(paymentMethod, nameLength, yearsPeriod)\n );\n\n // finalize purchase\n return\n _mintSoulboundIdentityAndName(\n _msgSender(),\n name,\n nameLength,\n yearsPeriod,\n tokenURI,\n authorityAddress,\n signature\n );\n }\n\n /// @notice Mints a new Soulbound Identity purchasing it\n /// @dev This function allows the purchase of a soulbound identity for free\n /// @return TokenId of the new soulbound identity\n function purchaseIdentity()\n external\n whenNotPaused\n nonReentrant\n returns (uint256)\n {\n // finalize purchase\n return _mintSoulboundIdentity(_msgSender());\n }\n\n /// @notice Mints a new Soul Name purchasing it\n /// @dev This function allows the purchase of a soul name using\n /// stable coin (USDC), native token (ETH) or utility token (MASA)\n /// @param paymentMethod Address of token that user want to pay\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new sou name\n function purchaseName(\n address paymentMethod,\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant returns (uint256) {\n _pay(\n paymentMethod,\n getPriceForMintingName(paymentMethod, nameLength, yearsPeriod)\n );\n\n // finalize purchase\n return\n _mintSoulName(\n to,\n name,\n nameLength,\n yearsPeriod,\n tokenURI,\n authorityAddress,\n signature\n );\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Returns the price of register a name per year in stable coin for an specific length\n /// @dev Returns the price for registering per year in USD for an specific name length\n /// @param nameLength Length of the name\n /// @return Price in stable coin for that name length\n function getNameRegistrationPricePerYear(uint256 nameLength)\n public\n view\n returns (uint256)\n {\n uint256 price = nameRegistrationPricePerYear[nameLength];\n if (price == 0) {\n // if not found, return the default price\n price = nameRegistrationPricePerYear[0];\n }\n return price;\n }\n\n /// @notice Returns the price of the name minting\n /// @dev Returns current pricing for name minting for a given name length and years period\n /// @param paymentMethod Address of token that user want to pay\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @return Current price of the name minting in the given payment method\n function getPriceForMintingName(\n address paymentMethod,\n uint256 nameLength,\n uint256 yearsPeriod\n ) public view returns (uint256) {\n uint256 mintPrice = getNameRegistrationPricePerYear(nameLength).mul(\n yearsPeriod\n );\n\n if (mintPrice == 0) {\n return 0;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return mintPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, mintPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /* ========== PRIVATE FUNCTIONS ========== */\n\n /// @notice Mints a new Soulbound Identity and Name\n /// @dev The final step of all purchase options. Will mint a\n /// new Soulbound Identity and a Soul Name NFT and emit the purchase event\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soulbound identity\n function _mintSoulboundIdentityAndName(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) internal returns (uint256) {\n _verify(\n _hash(to, name, nameLength, yearsPeriod, tokenURI),\n signature,\n authorityAddress\n );\n\n // mint Soulbound identity token\n uint256 tokenId = soulboundIdentity.mintIdentityWithName(\n to,\n name,\n yearsPeriod,\n tokenURI\n );\n\n emit SoulboundIdentityAndNamePurchased(to, tokenId, name, yearsPeriod);\n\n return tokenId;\n }\n\n /// @notice Mints a new Soulbound Identity\n /// @dev The final step of all purchase options. Will mint a\n /// new Soulbound Identity and emit the purchase event\n /// @param to Address of the owner of the new identity\n /// @return TokenId of the new soulbound identity\n function _mintSoulboundIdentity(address to) internal returns (uint256) {\n // mint Soulbound identity token\n uint256 tokenId = soulboundIdentity.mint(to);\n\n emit SoulboundIdentityPurchased(to, tokenId);\n\n return tokenId;\n }\n\n /// @notice Mints a new Soul Name\n /// @dev The final step of all purchase options. Will mint a\n /// new Soul Name NFT and emit the purchase event\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soul name\n function _mintSoulName(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) internal returns (uint256) {\n _verify(\n _hash(to, name, nameLength, yearsPeriod, tokenURI),\n signature,\n authorityAddress\n );\n\n // mint Soul Name token\n ISoulName soulName = soulboundIdentity.getSoulName();\n\n uint256 tokenId = soulName.mint(to, name, yearsPeriod, tokenURI);\n\n emit SoulNamePurchased(to, tokenId, name, yearsPeriod);\n\n return tokenId;\n }\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address signer\n ) internal view {\n address _signer = ECDSA.recover(digest, signature);\n if (_signer != signer) revert InvalidSignature();\n if (!authorities[_signer]) revert NotAuthorized(_signer);\n }\n\n function _hash(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintSoulName(address to,string name,uint256 nameLength,uint256 yearsPeriod,string tokenURI)\"\n ),\n to,\n keccak256(bytes(name)),\n nameLength,\n yearsPeriod,\n keccak256(bytes(tokenURI))\n )\n )\n );\n }\n\n /* ========== MODIFIERS ========== */\n\n /* ========== EVENTS ========== */\n\n event SoulboundIdentityAndNamePurchased(\n address indexed account,\n uint256 tokenId,\n string indexed name,\n uint256 yearsPeriod\n );\n\n event SoulboundIdentityPurchased(address indexed account, uint256 tokenId);\n\n event SoulNamePurchased(\n address indexed account,\n uint256 tokenId,\n string indexed name,\n uint256 yearsPeriod\n );\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" - }, - "@openzeppelin/contracts/security/ReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "contracts/interfaces/ISoulboundIdentity.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../tokens/SBT/ISBT.sol\";\n\nimport \"./ISoulName.sol\";\n\ninterface ISoulboundIdentity is ISBT {\n function mint(address to) external returns (uint256);\n\n function mintIdentityWithName(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external returns (uint256);\n\n function getSoulName() external view returns (ISoulName);\n\n function tokenOfOwner(address owner) external view returns (uint256);\n}\n" - }, - "contracts/interfaces/ISoulName.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\ninterface ISoulName {\n function mint(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external returns (uint256);\n\n function getExtension() external view returns (string memory);\n\n function isAvailable(string memory name)\n external\n view\n returns (bool available);\n\n function getTokenData(string memory name)\n external\n view\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n );\n\n function getTokenId(string memory name) external view returns (uint256);\n\n function getSoulNames(address owner)\n external\n view\n returns (string[] memory sbtNames);\n\n function getSoulNames(uint256 identityId)\n external\n view\n returns (string[] memory sbtNames);\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "contracts/tokens/SBT/ISBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\ninterface ISBT is IERC165 {\n /// @dev This emits when an SBT is newly minted.\n /// This event emits when SBTs are created\n event Mint(address indexed _owner, uint256 indexed _tokenId);\n\n /// @dev This emits when an SBT is burned\n /// This event emits when SBTs are destroyed\n event Burn(address indexed _owner, uint256 indexed _tokenId);\n\n /// @notice Count all SBTs assigned to an owner\n /// @dev SBTs assigned to the zero address are considered invalid, and this\n /// function throws for queries about the zero address.\n /// @param _owner An address for whom to query the balance\n /// @return The number of SBTs owned by `_owner`, possibly zero\n function balanceOf(address _owner) external view returns (uint256);\n\n /// @notice Find the owner of an SBT\n /// @dev SBTs assigned to zero address are considered invalid, and queries\n /// about them do throw.\n /// @param _tokenId The identifier for an SBT\n /// @return The address of the owner of the SBT\n function ownerOf(uint256 _tokenId) external view returns (address);\n}\n" - }, - "contracts/SoulName.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./libraries/Utils.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\nimport \"./tokens/MasaNFT.sol\";\n\n/// @title SoulName NFT\n/// @author Masa Finance\n/// @notice SoulName NFT that points to a Soulbound identity token\n/// @dev SoulName NFT, that inherits from the NFT contract, and points to a Soulbound identity token.\n/// It has an extension, and stores all the information about the identity names.\ncontract SoulName is MasaNFT, ISoulName, ReentrancyGuard {\n /* ========== STATE VARIABLES ========== */\n using SafeMath for uint256;\n\n uint256 constant YEAR = 31536000; // 60 seconds * 60 minutes * 24 hours * 365 days\n\n ISoulboundIdentity public soulboundIdentity;\n string public extension; // suffix of the names (.sol?)\n\n // contractURI() points to the smart contract metadata\n // see https://docs.opensea.io/docs/contract-level-metadata\n string public contractURI;\n\n // Optional mapping for token URIs\n mapping(uint256 => string) private _tokenURIs;\n mapping(string => bool) private _URIs; // used to check if a uri is already used\n\n mapping(uint256 => TokenData) public tokenData; // used to store the data of the token id\n mapping(string => NameData) public nameData; // stores the token id of the current active soul name\n\n struct TokenData {\n string name; // Name with lowercase and uppercase\n uint256 expirationDate;\n }\n\n struct NameData {\n bool exists;\n uint256 tokenId;\n }\n\n /* ========== INITIALIZE ========== */\n\n /// @notice Creates a new SoulName NFT\n /// @dev Creates a new SoulName NFT, that points to a Soulbound identity, inheriting from the NFT contract.\n /// @param admin Administrator of the smart contract\n /// @param _soulboundIdentity Address of the Soulbound identity contract\n /// @param _extension Extension of the soul name\n /// @param _contractURI URI of the smart contract metadata\n constructor(\n address admin,\n ISoulboundIdentity _soulboundIdentity,\n string memory _extension,\n string memory _contractURI\n ) MasaNFT(admin, \"Masa Soul Name\", \"MSN\", \"\") {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulboundIdentity;\n extension = _extension;\n contractURI = _contractURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the extension of the soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _extension Extension of the soul name\n function setExtension(string memory _extension)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (\n keccak256(abi.encodePacked((extension))) ==\n keccak256(abi.encodePacked((_extension)))\n ) revert SameValue();\n extension = _extension;\n }\n\n /// @notice Sets the URI of the smart contract metadata\n /// @dev The caller must have the admin role to call this function\n /// @param _contractURI URI of the smart contract metadata\n function setContractURI(string memory _contractURI)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (\n keccak256(abi.encodePacked((contractURI))) ==\n keccak256(abi.encodePacked((_contractURI)))\n ) revert SameValue();\n contractURI = _contractURI;\n }\n\n /* ========== MUTATIVE FUNCTIONS ========== */\n\n /// @notice Mints a new soul name\n /// @dev The caller can mint more than one name. The soul name must be unique.\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param yearsPeriod Years of validity of the name\n /// @param _tokenURI URI of the NFT\n function mint(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) public override nonReentrant returns (uint256) {\n if (!isAvailable(name)) revert NameAlreadyExists(name);\n if (bytes(name).length == 0) revert ZeroLengthName(name);\n if (yearsPeriod == 0) revert ZeroYearsPeriod(yearsPeriod);\n if (soulboundIdentity.balanceOf(to) == 0)\n revert AddressDoesNotHaveIdentity(to);\n if (\n !Utils.startsWith(_tokenURI, \"ar://\") &&\n !Utils.startsWith(_tokenURI, \"ipfs://\")\n ) revert InvalidTokenURI(_tokenURI);\n\n uint256 tokenId = _mintWithCounter(to);\n _setTokenURI(tokenId, _tokenURI);\n\n tokenData[tokenId].name = name;\n tokenData[tokenId].expirationDate = block.timestamp.add(\n YEAR.mul(yearsPeriod)\n );\n\n string memory lowercaseName = Utils.toLowerCase(name);\n nameData[lowercaseName].tokenId = tokenId;\n nameData[lowercaseName].exists = true;\n\n return tokenId;\n }\n\n /// @notice Update the expiration date of a soul name\n /// @dev The caller must be the owner or an approved address of the soul name.\n /// @param tokenId TokenId of the soul name\n /// @param yearsPeriod Years of validity of the name\n function renewYearsPeriod(uint256 tokenId, uint256 yearsPeriod) external {\n // ERC721: caller is not token owner nor approved\n if (!_isApprovedOrOwner(_msgSender(), tokenId))\n revert CallerNotOwner(_msgSender());\n if (yearsPeriod == 0) revert ZeroYearsPeriod(yearsPeriod);\n\n // check that the last registered tokenId for that name is the current token\n string memory lowercaseName = Utils.toLowerCase(\n tokenData[tokenId].name\n );\n if (nameData[lowercaseName].tokenId != tokenId)\n revert NameRegisteredByOtherAccount(lowercaseName, tokenId);\n\n // check if the name is expired\n if (tokenData[tokenId].expirationDate < block.timestamp) {\n tokenData[tokenId].expirationDate = block.timestamp.add(\n YEAR.mul(yearsPeriod)\n );\n } else {\n tokenData[tokenId].expirationDate = tokenData[tokenId]\n .expirationDate\n .add(YEAR.mul(yearsPeriod));\n }\n\n emit YearsPeriodRenewed(\n tokenId,\n yearsPeriod,\n tokenData[tokenId].expirationDate\n );\n }\n\n /// @notice Burn a soul name\n /// @dev The caller must be the owner or an approved address of the soul name.\n /// @param tokenId TokenId of the soul name to burn\n function burn(uint256 tokenId) public override {\n if (!_exists(tokenId)) revert TokenNotFound(tokenId);\n\n string memory lowercaseName = Utils.toLowerCase(\n tokenData[tokenId].name\n );\n\n // remove info from tokenIdName and tokenData\n delete tokenData[tokenId];\n\n // if the last owner of the name is burning it, remove the name from nameData\n if (nameData[lowercaseName].tokenId == tokenId) {\n delete nameData[lowercaseName];\n }\n\n if (bytes(_tokenURIs[tokenId]).length != 0) {\n _URIs[_tokenURIs[tokenId]] = false;\n delete _tokenURIs[tokenId];\n }\n\n super.burn(tokenId);\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Returns the extension of the soul name\n /// @dev This function is used to get the extension of the soul name\n /// @return Extension of the soul name\n function getExtension() external view override returns (string memory) {\n return extension;\n }\n\n /// @notice Checks if a soul name is available\n /// @dev This function queries if a soul name already exists and is in the available state\n /// @param name Name of the soul name\n /// @return available `true` if the soul name is available, `false` otherwise\n function isAvailable(string memory name)\n public\n view\n override\n returns (bool available)\n {\n string memory lowercaseName = Utils.toLowerCase(name);\n if (nameData[lowercaseName].exists) {\n uint256 tokenId = nameData[lowercaseName].tokenId;\n return tokenData[tokenId].expirationDate < block.timestamp;\n } else {\n return true;\n }\n }\n\n /// @notice Returns the information of a soul name\n /// @dev This function queries the information of a soul name\n /// @param name Name of the soul name\n /// @return sbtName Soul name, in upper/lower case and extension\n /// @return linked `true` if the soul name is linked, `false` otherwise\n /// @return identityId Identity id of the soul name\n /// @return tokenId SoulName id of the soul name\n /// @return expirationDate Expiration date of the soul name\n /// @return active `true` if the soul name is active, `false` otherwise\n function getTokenData(string memory name)\n external\n view\n override\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n )\n {\n tokenId = _getTokenId(name);\n address _owner = ownerOf(tokenId);\n bool _linked = soulboundIdentity.balanceOf(_owner) > 0;\n uint256 _identityId = 0;\n if (_linked) {\n _identityId = soulboundIdentity.tokenOfOwner(_owner);\n }\n\n TokenData memory _tokenData = tokenData[tokenId];\n\n return (\n _getName(_tokenData.name),\n _linked,\n _identityId,\n tokenId,\n _tokenData.expirationDate,\n _tokenData.expirationDate >= block.timestamp\n );\n }\n\n /// @notice Returns the token id of a soul name\n /// @dev This function queries the token id of a soul name\n /// @param name Name of the soul name\n /// @return SoulName id of the soul name\n function getTokenId(string memory name)\n external\n view\n override\n returns (uint256)\n {\n return _getTokenId(name);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified identity Id\n /// @param identityId TokenId of the identity\n /// @return sbtNames Array of soul names associated to the identity Id\n function getSoulNames(uint256 identityId)\n external\n view\n override\n returns (string[] memory sbtNames)\n {\n // return owner if exists\n address _owner = soulboundIdentity.ownerOf(identityId);\n\n return getSoulNames(_owner);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified account\n /// @param owner Address of the owner of the identities\n /// @return sbtNames Array of soul names associated to the account\n function getSoulNames(address owner)\n public\n view\n override\n returns (string[] memory sbtNames)\n {\n uint256 results = 0;\n uint256 balance = balanceOf(owner);\n\n for (uint256 i = 0; i < balance; i++) {\n uint256 tokenId = tokenOfOwnerByIndex(owner, i);\n if (tokenData[tokenId].expirationDate >= block.timestamp) {\n results = results.add(1);\n }\n }\n\n string[] memory _sbtNames = new string[](results);\n uint256 index = 0;\n\n for (uint256 i = 0; i < balance; i++) {\n uint256 tokenId = tokenOfOwnerByIndex(owner, i);\n if (tokenData[tokenId].expirationDate >= block.timestamp) {\n _sbtNames[index] = Utils.toLowerCase(tokenData[tokenId].name);\n index = index.add(1);\n }\n }\n\n // return identity names if exists and are active\n return _sbtNames;\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev This function returns the token URI of the soul name specified by the name\n /// @param name Name of the soul name\n /// @return URI of the soulname associated to a name\n function tokenURI(string memory name)\n external\n view\n virtual\n returns (string memory)\n {\n uint256 tokenId = _getTokenId(name);\n return tokenURI(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId NFT to get the URI of\n /// @return URI of the NFT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory _tokenURI = _tokenURIs[tokenId];\n string memory base = _baseURI();\n\n // If there is no base URI, return the token URI.\n if (bytes(base).length == 0) {\n return _tokenURI;\n }\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n if (bytes(_tokenURI).length > 0) {\n return string(abi.encodePacked(base, _tokenURI));\n }\n\n return super.tokenURI(tokenId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========== */\n\n function _getName(string memory name) private view returns (string memory) {\n return string(bytes.concat(bytes(name), bytes(extension)));\n }\n\n function _getTokenId(string memory name) private view returns (uint256) {\n string memory lowercaseName = Utils.toLowerCase(name);\n if (!nameData[lowercaseName].exists) revert NameNotFound(name);\n\n return nameData[lowercaseName].tokenId;\n }\n\n function _setTokenURI(uint256 tokenId, string memory _tokenURI)\n internal\n virtual\n {\n if (!_exists(tokenId)) revert TokenNotFound(tokenId);\n if (_URIs[_tokenURI]) revert URIAlreadyExists(_tokenURI);\n\n _tokenURIs[tokenId] = _tokenURI;\n _URIs[_tokenURI] = true;\n }\n\n /* ========== MODIFIERS ========== */\n\n /* ========== EVENTS ========== */\n\n event YearsPeriodRenewed(\n uint256 tokenId,\n uint256 yearsPeriod,\n uint256 newExpirationDate\n );\n}\n" - }, - "contracts/libraries/Utils.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\n/// @title Utilities library for Masa Contracts Identity repository\n/// @author Masa Finance\n/// @notice Library of utilities for Masa Contracts Identity repository\nlibrary Utils {\n struct slice {\n uint256 _len;\n uint256 _ptr;\n }\n\n function toLowerCase(string memory _str)\n internal\n pure\n returns (string memory)\n {\n bytes memory bStr = bytes(_str);\n bytes memory bLower = new bytes(bStr.length);\n\n for (uint256 i = 0; i < bStr.length; i++) {\n // Uppercase character...\n if ((bStr[i] >= 0x41) && (bStr[i] <= 0x5A)) {\n // So we add 0x20 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 0x20);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n\n function toSlice(string memory self) private pure returns (slice memory) {\n uint256 ptr;\n assembly {\n ptr := add(self, 0x20)\n }\n return slice(bytes(self).length, ptr);\n }\n\n function startsWith(string memory str, string memory needle)\n internal\n pure\n returns (bool)\n {\n slice memory s_str = toSlice(str);\n slice memory s_needle = toSlice(needle);\n\n if (s_str._len < s_needle._len) {\n return false;\n }\n\n if (s_str._ptr == s_needle._ptr) {\n return true;\n }\n\n bool equal;\n assembly {\n let length := mload(s_needle)\n let selfptr := mload(add(s_str, 0x20))\n let needleptr := mload(add(s_needle, 0x20))\n equal := eq(\n keccak256(selfptr, length),\n keccak256(needleptr, length)\n )\n }\n return equal;\n }\n}\n" - }, - "contracts/tokens/MasaNFT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\n/// @title MasaNFT\n/// @author Masa Finance\n/// @notice Non-fungible token is a token that is not fungible.\n/// @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard,\n/// that inherits from {ERC721Enumerable}, {Ownable}, {AccessControl} and {ERC721Burnable}.\nabstract contract MasaNFT is\n ERC721,\n ERC721Enumerable,\n Ownable,\n AccessControl,\n ERC721Burnable\n{\n /* ========== STATE VARIABLES =========================================== */\n\n using Strings for uint256;\n using Counters for Counters.Counter;\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n Counters.Counter private _tokenIdCounter;\n\n string private _baseTokenURI;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new NFT\n /// @dev Creates a new Non-fungible token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) ERC721(name, symbol) {\n Ownable.transferOwnership(admin);\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n _grantRole(MINTER_ROLE, admin);\n\n _baseTokenURI = baseTokenURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n function _mintWithCounter(address to)\n internal\n onlyRole(MINTER_ROLE)\n returns (uint256)\n {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _safeMint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns true if the token exists\n /// @dev Returns true if the token has been minted\n /// @param tokenId Token to check\n /// @return True if the token exists\n function exists(uint256 tokenId) external view returns (bool) {\n return _exists(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId NFT to get the URI of\n /// @return URI of the NFT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\"))\n : \"\";\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC721, ERC721Enumerable, AccessControl)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override(ERC721, ERC721Enumerable) {\n super._beforeTokenTransfer(from, to, tokenId);\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/ERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"./IERC721Enumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721.balanceOf(owner), \"ERC721Enumerable: owner index out of bounds\");\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721Enumerable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @title ERC721 Burnable Token\n * @dev ERC721 Token that can be burned (destroyed).\n */\nabstract contract ERC721Burnable is Context, ERC721 {\n /**\n * @dev Burns `tokenId`. See {ERC721-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _burn(tokenId);\n }\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Counters.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" - }, - "contracts/SoulLinker.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./dex/PaymentGateway.sol\";\nimport \"./interfaces/ILinkableSBT.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\n\n/// @title Soul linker\n/// @author Masa Finance\n/// @notice Soul linker smart contract that let add links to a Soulbound token.\ncontract SoulLinker is PaymentGateway, EIP712, Pausable, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n ISoulboundIdentity public soulboundIdentity;\n\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n mapping(address => mapping(uint256 => mapping(uint256 => mapping(uint256 => LinkData))))\n private _links;\n // token => tokenId => readerIdentityId\n mapping(address => mapping(uint256 => uint256[]))\n private _linkReaderIdentityIds;\n // token => tokenId => readerIdentityId => signatureDate\n mapping(address => mapping(uint256 => mapping(uint256 => uint256[])))\n private _linkSignatureDates;\n // readerIdentityId => ReaderLink\n mapping(uint256 => ReaderLink[]) private _readerLinks;\n\n struct LinkData {\n bool exists;\n uint256 ownerIdentityId;\n uint256 expirationDate;\n bool isRevoked;\n }\n\n struct ReaderLink {\n address token;\n uint256 tokenId;\n uint256 signatureDate;\n }\n\n struct LinkKey {\n uint256 readerIdentityId;\n uint256 signatureDate;\n }\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soul linker\n /// @param admin Administrator of the smart contract\n /// @param _soulboundIdentity Soulbound identity smart contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n ISoulboundIdentity _soulboundIdentity,\n PaymentParams memory paymentParams\n ) EIP712(\"SoulLinker\", \"1.0.0\") PaymentGateway(admin, paymentParams) {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulboundIdentity;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Pauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Stores the link, validating the signature of the given read link request\n /// @dev The token must be linked to this soul linker\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n /// @param expirationDate Expiration date of the signature\n /// @param signature Signature of the read link request made by the owner\n function addLink(\n address paymentMethod,\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address readerAddress = soulboundIdentity.ownerOf(readerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (readerAddress != _msgSender()) revert CallerNotReader(_msgSender());\n if (ownerIdentityId == readerIdentityId)\n revert IdentityOwnerIsReader(readerIdentityId);\n if (signatureDate == 0) revert InvalidSignatureDate(signatureDate);\n if (expirationDate < block.timestamp)\n revert ValidPeriodExpired(expirationDate);\n if (_links[token][tokenId][readerIdentityId][signatureDate].exists)\n revert LinkAlreadyExists(\n token,\n tokenId,\n readerIdentityId,\n signatureDate\n );\n if (\n !_verify(\n _hash(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n ),\n signature,\n ownerAddress\n )\n ) revert InvalidSignature();\n\n _pay(paymentMethod, getPriceForAddLink(paymentMethod, token));\n\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate] = LinkData(\n true,\n ownerIdentityId,\n expirationDate,\n false\n );\n if (_linkSignatureDates[token][tokenId][readerIdentityId].length == 0) {\n _linkReaderIdentityIds[token][tokenId].push(readerIdentityId);\n }\n _linkSignatureDates[token][tokenId][readerIdentityId].push(\n signatureDate\n );\n _readerLinks[readerIdentityId].push(\n ReaderLink(token, tokenId, signatureDate)\n );\n\n emit LinkAdded(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n );\n }\n\n /// @notice Revokes the link\n /// @dev The links can be revoked, wether the token is linked or not.\n /// The caller must be the owner of the token.\n /// The owner of the token can revoke a link even if the reader has not added it yet.\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n function revokeLink(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n ) external whenNotPaused {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (ownerAddress != _msgSender()) revert CallerNotOwner(_msgSender());\n if (ownerIdentityId == readerIdentityId)\n revert IdentityOwnerIsReader(readerIdentityId);\n if (_links[token][tokenId][readerIdentityId][signatureDate].isRevoked)\n revert LinkAlreadyRevoked();\n\n if (_links[token][tokenId][readerIdentityId][signatureDate].exists) {\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate]\n .isRevoked = true;\n } else {\n // if the link doesn't exist, store it\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate] = LinkData(\n true,\n ownerIdentityId,\n 0,\n true\n );\n if (\n _linkSignatureDates[token][tokenId][readerIdentityId].length ==\n 0\n ) {\n _linkReaderIdentityIds[token][tokenId].push(readerIdentityId);\n }\n _linkSignatureDates[token][tokenId][readerIdentityId].push(\n signatureDate\n );\n _readerLinks[readerIdentityId].push(\n ReaderLink(token, tokenId, signatureDate)\n );\n }\n\n emit LinkRevoked(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate\n );\n }\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the identityId owned by the given token\n /// @dev The token must be linked to this soul linker\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @return Id of the identity\n function getIdentityId(address token, uint256 tokenId)\n external\n view\n returns (uint256)\n {\n address owner = IERC721Enumerable(token).ownerOf(tokenId);\n return soulboundIdentity.tokenOfOwner(owner);\n }\n\n /// @notice Returns the list of connected SBTs by a given SBT token\n /// @param identityId Id of the identity\n /// @param token Address of the SBT contract\n /// @return List of connected SBTs\n function getSBTConnections(uint256 identityId, address token)\n external\n view\n returns (uint256[] memory)\n {\n address owner = soulboundIdentity.ownerOf(identityId);\n\n return getSBTConnections(owner, token);\n }\n\n /// @notice Returns the list of connected SBTs by a given SBT token\n /// @param owner Address of the owner of the identity\n /// @param token Address of the SBT contract\n /// @return List of connectec SBTs\n function getSBTConnections(address owner, address token)\n public\n view\n returns (uint256[] memory)\n {\n uint256 connections = IERC721Enumerable(token).balanceOf(owner);\n uint256[] memory sbtConnections = new uint256[](connections);\n for (uint256 i = 0; i < connections; i++) {\n sbtConnections[i] = IERC721Enumerable(token).tokenOfOwnerByIndex(\n owner,\n i\n );\n }\n\n return sbtConnections;\n }\n\n /// @notice Returns the list of link signature dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @return List of linked SBTs\n function getLinks(address token, uint256 tokenId)\n public\n view\n returns (LinkKey[] memory)\n {\n uint256 nLinkKeys = 0;\n for (\n uint256 i = 0;\n i < _linkReaderIdentityIds[token][tokenId].length;\n i++\n ) {\n uint256 readerIdentityId = _linkReaderIdentityIds[token][tokenId][\n i\n ];\n for (\n uint256 j = 0;\n j <\n _linkSignatureDates[token][tokenId][readerIdentityId].length;\n j++\n ) {\n nLinkKeys++;\n }\n }\n\n LinkKey[] memory linkKeys = new LinkKey[](nLinkKeys);\n uint256 n = 0;\n for (\n uint256 i = 0;\n i < _linkReaderIdentityIds[token][tokenId].length;\n i++\n ) {\n uint256 readerIdentityId = _linkReaderIdentityIds[token][tokenId][\n i\n ];\n for (\n uint256 j = 0;\n j <\n _linkSignatureDates[token][tokenId][readerIdentityId].length;\n j++\n ) {\n uint256 signatureDate = _linkSignatureDates[token][tokenId][\n readerIdentityId\n ][j];\n linkKeys[n].readerIdentityId = readerIdentityId;\n linkKeys[n].signatureDate = signatureDate;\n n++;\n }\n }\n return linkKeys;\n }\n\n /// @notice Returns the list of link signature dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @return List of linked SBTs\n function getLinkSignatureDates(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId\n ) external view returns (uint256[] memory) {\n return _linkSignatureDates[token][tokenId][readerIdentityId];\n }\n\n /// @notice Returns the information of link dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @param signatureDate Signature date of the signature\n /// @return linkData List of linked SBTs\n function getLinkInfo(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId,\n uint256 signatureDate\n ) external view returns (LinkData memory) {\n return _links[token][tokenId][readerIdentityId][signatureDate];\n }\n\n /// @notice Returns the list of links for a given reader identity id\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @return List of links for the reader\n function getReaderLinks(uint256 readerIdentityId)\n public\n view\n returns (ReaderLink[] memory)\n {\n return _readerLinks[readerIdentityId];\n }\n\n /// @notice Validates the link of the given read link request and returns the\n /// data that reader can read if the link is valid\n /// @dev The token must be linked to this soul linker\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n /// @return True if the link is valid\n function validateLink(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n ) external view returns (bool) {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n LinkData memory link = _links[token][tokenId][readerIdentityId][\n signatureDate\n ];\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (!link.exists) revert LinkDoesNotExist();\n if (link.expirationDate < block.timestamp)\n revert ValidPeriodExpired(link.expirationDate);\n if (link.isRevoked) revert LinkAlreadyRevoked();\n\n return true;\n }\n\n /// @notice Returns the price for storing a link\n /// @dev Returns the current pricing for storing a link\n /// @param paymentMethod Address of token that user want to pay\n /// @param token Token that user want to store link\n /// @return Current price for storing a link\n function getPriceForAddLink(address paymentMethod, address token)\n public\n view\n returns (uint256)\n {\n uint256 addLinkPrice = ILinkableSBT(token).addLinkPrice();\n uint256 addLinkPriceMASA = ILinkableSBT(token).addLinkPriceMASA();\n if (addLinkPrice == 0 && addLinkPriceMASA == 0) {\n return 0;\n } else if (\n paymentMethod == masaToken &&\n enabledPaymentMethod[paymentMethod] &&\n addLinkPriceMASA > 0\n ) {\n // price in MASA without conversion rate\n return addLinkPriceMASA;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return addLinkPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, addLinkPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Link(uint256 readerIdentityId,uint256 ownerIdentityId,address token,uint256 tokenId,uint256 signatureDate,uint256 expirationDate)\"\n ),\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n )\n )\n );\n }\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address owner\n ) internal pure returns (bool) {\n return ECDSA.recover(digest, signature) == owner;\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event LinkAdded(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate\n );\n\n event LinkRevoked(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n );\n}\n" - }, - "contracts/interfaces/ILinkableSBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../tokens/SBT/ISBT.sol\";\n\ninterface ILinkableSBT is ISBT {\n function addLinkPrice() external view returns (uint256);\n\n function addLinkPriceMASA() external view returns (uint256);\n\n function queryLinkPrice() external view returns (uint256);\n\n function queryLinkPriceMASA() external view returns (uint256);\n}\n" - }, - "contracts/SoulboundIdentity.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\nimport \"./tokens/MasaSBTAuthority.sol\";\n\n/// @title Soulbound Identity\n/// @author Masa Finance\n/// @notice Soulbound token that represents an identity.\n/// @dev Soulbound identity, that inherits from the SBT contract.\ncontract SoulboundIdentity is\n MasaSBTAuthority,\n ISoulboundIdentity,\n ReentrancyGuard\n{\n /* ========== STATE VARIABLES =========================================== */\n\n ISoulName public soulName;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound identity\n /// @dev Creates a new soulbound identity, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n constructor(address admin, string memory baseTokenURI)\n MasaSBTAuthority(admin, \"Masa Identity\", \"MID\", baseTokenURI)\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulName contract address linked to this identity\n /// @dev The caller must have the admin role to call this function\n /// @param _soulName Address of the SoulName contract\n function setSoulName(ISoulName _soulName)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulName) == address(0)) revert ZeroAddress();\n if (soulName == _soulName) revert SameValue();\n soulName = _soulName;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new soulbound identity\n /// @dev The caller can only mint one identity per address\n /// @param to Address of the admin of the new identity\n function mint(address to) public override returns (uint256) {\n // Soulbound identity already created!\n if (balanceOf(to) > 0) revert IdentityAlreadyCreated(to);\n\n return _mintWithCounter(to);\n }\n\n /// @notice Mints a new soulbound identity with a SoulName associated to it\n /// @dev The caller can only mint one identity per address, and the name must be unique\n /// @param to Address of the admin of the new identity\n /// @param name Name of the new identity\n /// @param yearsPeriod Years of validity of the name\n /// @param _tokenURI URI of the NFT\n function mintIdentityWithName(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external override soulNameAlreadySet nonReentrant returns (uint256) {\n uint256 identityId = mint(to);\n soulName.mint(to, name, yearsPeriod, _tokenURI);\n\n return identityId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the address of the SoulName contract linked to this identity\n /// @dev This function returns the address of the SoulName contract linked to this identity\n /// @return Address of the SoulName contract\n function getSoulName() external view override returns (ISoulName) {\n return soulName;\n }\n\n /// @notice Returns the extension of the soul name\n /// @dev This function returns the extension of the soul name\n /// @return Extension of the soul name\n function getExtension() external view returns (string memory) {\n return soulName.getExtension();\n }\n\n /// @notice Returns the owner address of an identity\n /// @dev This function returns the owner address of the identity specified by the tokenId\n /// @param tokenId TokenId of the identity\n /// @return Address of the owner of the identity\n function ownerOf(uint256 tokenId)\n public\n view\n override(SBT, ISBT)\n returns (address)\n {\n return super.ownerOf(tokenId);\n }\n\n /// @notice Returns the owner address of a soul name\n /// @dev This function returns the owner address of the soul name identity specified by the name\n /// @param name Name of the soul name\n /// @return Address of the owner of the identity\n function ownerOf(string memory name)\n external\n view\n soulNameAlreadySet\n returns (address)\n {\n (, , uint256 identityId, , , ) = soulName.getTokenData(name);\n return super.ownerOf(identityId);\n }\n\n /// @notice Returns the URI of a soul name\n /// @dev This function returns the token URI of the soul name identity specified by the name\n /// @param name Name of the soul name\n /// @return URI of the identity associated to a soul name\n function tokenURI(string memory name)\n external\n view\n soulNameAlreadySet\n returns (string memory)\n {\n (, , uint256 identityId, , , ) = soulName.getTokenData(name);\n return super.tokenURI(identityId);\n }\n\n /// @notice Returns the URI of the owner of an identity\n /// @dev This function returns the token URI of the identity owned by an account\n /// @param owner Address of the owner of the identity\n /// @return URI of the identity owned by the account\n function tokenURI(address owner) external view returns (string memory) {\n uint256 tokenId = tokenOfOwner(owner);\n return super.tokenURI(tokenId);\n }\n\n /// @notice Returns the identity id of an account\n /// @dev This function returns the tokenId of the identity owned by an account\n /// @param owner Address of the owner of the identity\n /// @return TokenId of the identity owned by the account\n function tokenOfOwner(address owner)\n public\n view\n override\n returns (uint256)\n {\n return super.tokenOfOwnerByIndex(owner, 0);\n }\n\n /// @notice Checks if a soul name is available\n /// @dev This function queries if a soul name already exists and is in the available state\n /// @param name Name of the soul name\n /// @return available `true` if the soul name is available, `false` otherwise\n function isAvailable(string memory name)\n external\n view\n soulNameAlreadySet\n returns (bool available)\n {\n return soulName.isAvailable(name);\n }\n\n /// @notice Returns the information of a soul name\n /// @dev This function queries the information of a soul name\n /// @param name Name of the soul name\n /// @return sbtName Soul name, in upper/lower case and extension\n /// @return linked `true` if the soul name is linked, `false` otherwise\n /// @return identityId Identity id of the soul name\n /// @return tokenId SoulName id of the soul name\n /// @return expirationDate Expiration date of the soul name\n /// @return active `true` if the soul name is active, `false` otherwise\n function getTokenData(string memory name)\n external\n view\n soulNameAlreadySet\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n )\n {\n return soulName.getTokenData(name);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified account\n /// @param owner Address of the owner of the identities\n /// @return sbtNames Array of soul names associated to the account\n function getSoulNames(address owner)\n external\n view\n soulNameAlreadySet\n returns (string[] memory sbtNames)\n {\n return soulName.getSoulNames(owner);\n }\n\n // SoulName -> SoulboundIdentity.tokenId\n // SoulName -> account -> SoulboundIdentity.tokenId\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified identity Id\n /// @param tokenId TokenId of the identity\n /// @return sbtNames Array of soul names associated to the identity Id\n function getSoulNames(uint256 tokenId)\n external\n view\n soulNameAlreadySet\n returns (string[] memory sbtNames)\n {\n return soulName.getSoulNames(tokenId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /* ========== MODIFIERS ================================================= */\n\n modifier soulNameAlreadySet() {\n if (address(soulName) == address(0)) revert SoulNameContractNotSet();\n _;\n }\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/MasaSBTAuthority.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nimport \"./MasaSBT.sol\";\n\n/// @title MasaSBT\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBTAuthority is MasaSBT {\n /* ========== STATE VARIABLES =========================================== */\n\n using Counters for Counters.Counter;\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n Counters.Counter private _tokenIdCounter;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) MasaSBT(admin, name, symbol, baseTokenURI) {\n _grantRole(MINTER_ROLE, admin);\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n function _mintWithCounter(address to)\n internal\n virtual\n onlyRole(MINTER_ROLE)\n returns (uint256)\n {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _mint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/MasaSBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/ILinkableSBT.sol\";\nimport \"./SBT/SBT.sol\";\nimport \"./SBT/extensions/SBTEnumerable.sol\";\nimport \"./SBT/extensions/SBTBurnable.sol\";\n\n/// @title MasaSBT\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBT is\n SBT,\n SBTEnumerable,\n AccessControl,\n SBTBurnable,\n ILinkableSBT\n{\n /* ========== STATE VARIABLES =========================================== */\n\n using Strings for uint256;\n\n string private _baseTokenURI;\n\n uint256 public override addLinkPrice; // price in stable coin\n uint256 public override addLinkPriceMASA; // price in MASA\n uint256 public override queryLinkPrice; // price in stable coin\n uint256 public override queryLinkPriceMASA; // price in MASA\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) SBT(name, symbol) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n\n _baseTokenURI = baseTokenURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the price for adding the link in SoulLinker in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _addLinkPrice New price for adding the link in SoulLinker in stable coin\n function setAddLinkPrice(uint256 _addLinkPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (addLinkPrice == _addLinkPrice) revert SameValue();\n addLinkPrice = _addLinkPrice;\n }\n\n /// @notice Sets the price for adding the link in SoulLinker in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _addLinkPriceMASA New price for adding the link in SoulLinker in MASA\n function setAddLinkPriceMASA(uint256 _addLinkPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (addLinkPriceMASA == _addLinkPriceMASA) revert SameValue();\n addLinkPriceMASA = _addLinkPriceMASA;\n }\n\n /// @notice Sets the price for reading data in SoulLinker in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _queryLinkPrice New price for reading data in SoulLinker in stable coin\n function setQueryLinkPrice(uint256 _queryLinkPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (queryLinkPrice == _queryLinkPrice) revert SameValue();\n queryLinkPrice = _queryLinkPrice;\n }\n\n /// @notice Sets the price for reading data in SoulLinker in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _queryLinkPriceMASA New price for reading data in SoulLinker in MASA\n function setQueryLinkPriceMASA(uint256 _queryLinkPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (queryLinkPriceMASA == _queryLinkPriceMASA) revert SameValue();\n queryLinkPriceMASA = _queryLinkPriceMASA;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns true if the token exists\n /// @dev Returns true if the token has been minted\n /// @param tokenId Token to check\n /// @return True if the token exists\n function exists(uint256 tokenId) external view returns (bool) {\n return _exists(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId SBT to get the URI of\n /// @return URI of the SBT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\"))\n : \"\";\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(SBT, SBTEnumerable, AccessControl, IERC165)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override(SBT, SBTEnumerable) {\n super._beforeTokenTransfer(from, to, tokenId);\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/SBT/SBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\nimport \"./ISBT.sol\";\nimport \"./extensions/ISBTMetadata.sol\";\n\n/// @title SBT\n/// @author Masa Finance\n/// @notice Soulbound token is an NFT token that is not transferable.\ncontract SBT is Context, ERC165, ISBT, ISBTMetadata {\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165, IERC165)\n returns (bool)\n {\n return\n interfaceId == type(ISBT).interfaceId ||\n interfaceId == type(ISBTMetadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {ISBT-balanceOf}.\n */\n function balanceOf(address owner)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(owner != address(0), \"SBT: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {ISBT-ownerOf}.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n address owner = _owners[tokenId];\n require(owner != address(0), \"SBT: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {ISBTMetadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {ISBTMetadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {ISBTMetadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\n : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isOwner(address spender, uint256 tokenId)\n internal\n view\n virtual\n returns (bool)\n {\n address owner = SBT.ownerOf(tokenId);\n return (spender == owner);\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Mint} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"SBT: mint to the zero address\");\n require(!_exists(tokenId), \"SBT: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Mint(to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n *\n * Requirements:\n * - `tokenId` must exist.\n *\n * Emits a {Burn} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = SBT.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Burn(owner, tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"SBT: invalid token ID\");\n }\n\n /**\n * @dev Hook that is called before any token minting/burning\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address,\n address,\n uint256\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any minting/burning of tokens\n *\n * Calling conditions:\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address,\n address,\n uint256\n ) internal virtual {}\n}\n" - }, - "contracts/tokens/SBT/extensions/SBTEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../SBT.sol\";\nimport \"./ISBTEnumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {SBT} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract SBTEnumerable is SBT, ISBTEnumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, SBT)\n returns (bool)\n {\n return\n interfaceId == type(ISBTEnumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {ISBTEnumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(\n index < SBT.balanceOf(owner),\n \"SBTEnumerable: owner index out of bounds\"\n );\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {ISBTEnumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {ISBTEnumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(\n index < SBTEnumerable.totalSupply(),\n \"SBTEnumerable: global index out of bounds\"\n );\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = SBT.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)\n private\n {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = SBT.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" - }, - "contracts/tokens/SBT/extensions/SBTBurnable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\nimport \"../SBT.sol\";\n\n/**\n * @title SBT Burnable Token\n * @dev SBT Token that can be burned (destroyed).\n */\nabstract contract SBTBurnable is Context, SBT {\n /**\n * @dev Burns `tokenId`. See {SBT-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(\n _isOwner(_msgSender(), tokenId),\n \"SBT: caller is not token owner\"\n );\n _burn(tokenId);\n }\n}\n" - }, - "contracts/tokens/SBT/extensions/ISBTMetadata.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../ISBT.sol\";\n\n/**\n * @title SBT Soulbound Token Standard, optional metadata extension\n */\ninterface ISBTMetadata is ISBT {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "contracts/tokens/SBT/extensions/ISBTEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../ISBT.sol\";\n\n/**\n * @title SBT Soulbound Token Standard, optional enumeration extension\n */\ninterface ISBTEnumerable is ISBT {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" - }, - "contracts/SoulboundCreditScore.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./tokens/MasaSBTSelfSovereign.sol\";\n\n/// @title Soulbound Credit Score\n/// @author Masa Finance\n/// @notice Soulbound token that represents a credit score.\n/// @dev Soulbound credit score, that inherits from the SBT contract.\ncontract SoulboundCreditScore is MasaSBTSelfSovereign, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound credit score\n /// @dev Creates a new soulbound credit score, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory baseTokenURI,\n ISoulboundIdentity soulboundIdentity,\n PaymentParams memory paymentParams\n )\n MasaSBTSelfSovereign(\n admin,\n \"Masa Credit Score\",\n \"MCS\",\n baseTokenURI,\n soulboundIdentity,\n paymentParams\n )\n EIP712(\"SoulboundCreditScore\", \"1.0.0\")\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param identityId TokenId of the identity to mint the NFT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The NFT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) public payable virtual nonReentrant returns (uint256) {\n address to = soulboundIdentity.ownerOf(identityId);\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n if (balanceOf(to) > 0) revert CreditScoreAlreadyCreated(to);\n\n _verify(\n _hash(identityId, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit SoulboundCreditScoreMintedToIdentity(\n tokenId,\n identityId,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param to The address to mint the SBT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The SBT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) external payable virtual returns (uint256) {\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n if (balanceOf(to) > 0) revert CreditScoreAlreadyCreated(to);\n\n _verify(\n _hash(to, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit SoulboundCreditScoreMintedToAddress(\n tokenId,\n to,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintCreditScore(uint256 identityId,address authorityAddress,uint256 signatureDate)\"\n ),\n identityId,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n function _hash(\n address to,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintCreditScore(address to,address authorityAddress,uint256 signatureDate)\"\n ),\n to,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event SoulboundCreditScoreMintedToIdentity(\n uint256 tokenId,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n\n event SoulboundCreditScoreMintedToAddress(\n uint256 tokenId,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n}\n" - }, - "contracts/tokens/MasaSBTSelfSovereign.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/ISoulboundIdentity.sol\";\nimport \"../dex/PaymentGateway.sol\";\nimport \"./MasaSBT.sol\";\n\n/// @title MasaSBTSelfSovereign\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// Adds a link to a SoulboundIdentity SC to let minting using the identityId\n/// Adds a payment gateway to let minting paying a fee\n/// Adds a self-sovereign protocol to let minting using an authority signature\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBTSelfSovereign is PaymentGateway, MasaSBT, EIP712 {\n /* ========== STATE VARIABLES =========================================== */\n\n using Counters for Counters.Counter;\n\n Counters.Counter private _tokenIdCounter;\n\n ISoulboundIdentity public soulboundIdentity;\n\n uint256 public mintPrice; // price in stable coin\n uint256 public mintPriceMASA; // price in MASA\n\n mapping(address => bool) public authorities;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI,\n ISoulboundIdentity _soulboundIdentity,\n PaymentParams memory paymentParams\n )\n PaymentGateway(admin, paymentParams)\n MasaSBT(admin, name, symbol, baseTokenURI)\n {\n soulboundIdentity = _soulboundIdentity;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this SBT\n /// @dev The caller must be the admin to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the price of minting in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _mintPrice New price of minting in stable coin\n function setMintPrice(uint256 _mintPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (mintPrice == _mintPrice) revert SameValue();\n mintPrice = _mintPrice;\n }\n\n /// @notice Sets the price of minting in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _mintPriceMASA New price of minting in MASA\n function setMintPriceMASA(uint256 _mintPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (mintPriceMASA == _mintPriceMASA) revert SameValue();\n mintPriceMASA = _mintPriceMASA;\n }\n\n /// @notice Adds a new authority to the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority New authority to add\n function addAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (authorities[_authority]) revert AlreadyAdded();\n\n authorities[_authority] = true;\n }\n\n /// @notice Removes an authority from the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority Authority to remove\n function removeAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\n\n authorities[_authority] = false;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the identityId owned by the given token\n /// @param tokenId Id of the token\n /// @return Id of the identity\n function getIdentityId(uint256 tokenId) external view returns (uint256) {\n if (soulboundIdentity == ISoulboundIdentity(address(0)))\n revert NotLinkedToAnIdentitySBT();\n\n address owner = super.ownerOf(tokenId);\n return soulboundIdentity.tokenOfOwner(owner);\n }\n\n /// @notice Returns the price for minting\n /// @dev Returns current pricing for minting\n /// @param paymentMethod Address of token that user want to pay\n /// @return Current price for minting in the given payment method\n function getMintPrice(address paymentMethod) public view returns (uint256) {\n if (mintPrice == 0 && mintPriceMASA == 0) {\n return 0;\n } else if (\n paymentMethod == masaToken &&\n enabledPaymentMethod[paymentMethod] &&\n mintPriceMASA > 0\n ) {\n // price in MASA without conversion rate\n return mintPriceMASA;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return mintPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, mintPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(AccessControl, MasaSBT)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address signer\n ) internal view {\n address _signer = ECDSA.recover(digest, signature);\n if (_signer != signer) revert InvalidSignature();\n if (!authorities[_signer]) revert NotAuthorized(_signer);\n }\n\n function _mintWithCounter(address to) internal virtual returns (uint256) {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _mint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/Soulbound2FA.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./tokens/MasaSBTSelfSovereign.sol\";\n\n/// @title Soulbound Two-factor authentication (2FA)\n/// @author Masa Finance\n/// @notice Soulbound token that represents a Two-factor authentication (2FA)\n/// @dev Soulbound 2FA, that inherits from the SBT contract.\ncontract Soulbound2FA is MasaSBTSelfSovereign, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound Two-factor authentication (2FA)\n /// @dev Creates a new soulbound 2FA, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory baseTokenURI,\n ISoulboundIdentity soulboundIdentity,\n PaymentParams memory paymentParams\n )\n MasaSBTSelfSovereign(\n admin,\n \"Masa 2FA\",\n \"M2F\",\n baseTokenURI,\n soulboundIdentity,\n paymentParams\n )\n EIP712(\"Soulbound2FA\", \"1.0.0\")\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param identityId TokenId of the identity to mint the NFT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The NFT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) public payable virtual nonReentrant returns (uint256) {\n address to = soulboundIdentity.ownerOf(identityId);\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n\n _verify(\n _hash(identityId, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit Soulbound2FAMintedToIdentity(\n tokenId,\n identityId,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param to The address to mint the SBT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The SBT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) external payable virtual returns (uint256) {\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n\n _verify(\n _hash(to, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit Soulbound2FAMintedToAddress(\n tokenId,\n to,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Mint2FA(uint256 identityId,address authorityAddress,uint256 signatureDate)\"\n ),\n identityId,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n function _hash(\n address to,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Mint2FA(address to,address authorityAddress,uint256 signatureDate)\"\n ),\n to,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event Soulbound2FAMintedToIdentity(\n uint256 tokenId,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n\n event Soulbound2FAMintedToAddress(\n uint256 tokenId,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 1, - "details": { - "yul": false - } - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates", - "devdoc", - "userdoc" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/bsctest/.chainId b/deployments/bsctest/.chainId deleted file mode 100644 index c4fbb1cfa..000000000 --- a/deployments/bsctest/.chainId +++ /dev/null @@ -1 +0,0 @@ -97 \ No newline at end of file diff --git a/deployments/bsctest/Soulbound2FA.json b/deployments/bsctest/Soulbound2FA.json deleted file mode 100644 index 572871d28..000000000 --- a/deployments/bsctest/Soulbound2FA.json +++ /dev/null @@ -1,1923 +0,0 @@ -{ - "address": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "admin", - "type": "address" - }, - { - "internalType": "string", - "name": "baseTokenURI", - "type": "string" - }, - { - "internalType": "contract ISoulboundIdentity", - "name": "soulboundIdentity", - "type": "address" - }, - { - "components": [ - { - "internalType": "address", - "name": "swapRouter", - "type": "address" - }, - { - "internalType": "address", - "name": "wrappedNativeToken", - "type": "address" - }, - { - "internalType": "address", - "name": "stableCoin", - "type": "address" - }, - { - "internalType": "address", - "name": "masaToken", - "type": "address" - }, - { - "internalType": "address", - "name": "reserveWallet", - "type": "address" - } - ], - "internalType": "struct PaymentGateway.PaymentParams", - "name": "paymentParams", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "AlreadyAdded", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "AuthorityNotExists", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "caller", - "type": "address" - } - ], - "name": "CallerNotOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InsufficientEthAmount", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - } - ], - "name": "InvalidPaymentMethod", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidSignature", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - } - ], - "name": "InvalidToken", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "erc20token", - "type": "address" - } - ], - "name": "NonExistingErc20Token", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "signer", - "type": "address" - } - ], - "name": "NotAuthorized", - "type": "error" - }, - { - "inputs": [], - "name": "NotLinkedToAnIdentitySBT", - "type": "error" - }, - { - "inputs": [], - "name": "RefundFailed", - "type": "error" - }, - { - "inputs": [], - "name": "SameValue", - "type": "error" - }, - { - "inputs": [], - "name": "TransferFailed", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "Burn", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - } - ], - "name": "Soulbound2FAMintedToAddress", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "identityId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - } - ], - "name": "Soulbound2FAMintedToIdentity", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_authority", - "type": "address" - } - ], - "name": "addAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "addLinkPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "addLinkPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "authorities", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_paymentMethod", - "type": "address" - } - ], - "name": "disablePaymentMethod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_paymentMethod", - "type": "address" - } - ], - "name": "enablePaymentMethod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "enabledPaymentMethod", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "enabledPaymentMethods", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "exists", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEnabledPaymentMethods", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getIdentityId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - } - ], - "name": "getMintPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "masaToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "internalType": "uint256", - "name": "identityId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "mintPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "mintPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "queryLinkPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "queryLinkPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_authority", - "type": "address" - } - ], - "name": "removeAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "reserveWallet", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_addLinkPrice", - "type": "uint256" - } - ], - "name": "setAddLinkPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_addLinkPriceMASA", - "type": "uint256" - } - ], - "name": "setAddLinkPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_masaToken", - "type": "address" - } - ], - "name": "setMasaToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintPrice", - "type": "uint256" - } - ], - "name": "setMintPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintPriceMASA", - "type": "uint256" - } - ], - "name": "setMintPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_queryLinkPrice", - "type": "uint256" - } - ], - "name": "setQueryLinkPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_queryLinkPriceMASA", - "type": "uint256" - } - ], - "name": "setQueryLinkPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_reserveWallet", - "type": "address" - } - ], - "name": "setReserveWallet", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ISoulboundIdentity", - "name": "_soulboundIdentity", - "type": "address" - } - ], - "name": "setSoulboundIdentity", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_stableCoin", - "type": "address" - } - ], - "name": "setStableCoin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_swapRouter", - "type": "address" - } - ], - "name": "setSwapRouter", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_wrappedNativeToken", - "type": "address" - } - ], - "name": "setWrappedNativeToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "soulboundIdentity", - "outputs": [ - { - "internalType": "contract ISoulboundIdentity", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "stableCoin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "swapRouter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenOfOwnerByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "wrappedNativeToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0x67e43c06a905ef1d6a414b9071dd943bf1858894570de3cef0f86247b9a3936e", - "receipt": { - "to": null, - "from": "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28", - "contractAddress": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "transactionIndex": 8, - "gasUsed": "3587630", - "logsBloom": "0x00000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000020000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000000000020000080000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000400000000000000000000000000000000000000000100000000000024000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x98b7429018fa5aa799c8cdf7738a9d4076f379145721db3b6961ab379f03f2ac", - "transactionHash": "0x67e43c06a905ef1d6a414b9071dd943bf1858894570de3cef0f86247b9a3936e", - "logs": [ - { - "transactionIndex": 8, - "blockNumber": 26829051, - "transactionHash": "0x67e43c06a905ef1d6a414b9071dd943bf1858894570de3cef0f86247b9a3936e", - "address": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28" - ], - "data": "0x", - "logIndex": 22, - "blockHash": "0x98b7429018fa5aa799c8cdf7738a9d4076f379145721db3b6961ab379f03f2ac" - } - ], - "blockNumber": 26829051, - "cumulativeGasUsed": "4890825", - "status": 1, - "byzantium": true - }, - "args": [ - "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28", - "https://beta.metadata.masa.finance/v1.0/2fa/", - "0x0000000000000000000000000000000000000000", - [ - "0xD99D1c33F9fC3444f8101754aBC46c52416550D1", - "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", - "0x64544969ed7EBf5f083679233325356EbE738930", - "0xEC5dCb5Dbf4B114C9d0F65BcCAb49EC54F6A0867", - "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28" - ] - ], - "numDeployments": 1, - "solcInputHash": "ba20b0945b3d8227cd3974f83be2ddaf", - "metadata": "{\"compiler\":{\"version\":\"0.8.7+commit.e28d00a7\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"baseTokenURI\",\"type\":\"string\"},{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"soulboundIdentity\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"swapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wrappedNativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stableCoin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"masaToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"reserveWallet\",\"type\":\"address\"}],\"internalType\":\"struct PaymentGateway.PaymentParams\",\"name\":\"paymentParams\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"authority\",\"type\":\"address\"}],\"name\":\"AuthorityNotExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"}],\"name\":\"CallerNotOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"}],\"name\":\"InvalidPaymentMethod\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSignature\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"InvalidToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"erc20token\",\"type\":\"address\"}],\"name\":\"NonExistingErc20Token\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"}],\"name\":\"NotAuthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotLinkedToAnIdentitySBT\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RefundFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SameValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TransferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"}],\"name\":\"Soulbound2FAMintedToAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"identityId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"}],\"name\":\"Soulbound2FAMintedToIdentity\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authority\",\"type\":\"address\"}],\"name\":\"addAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addLinkPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addLinkPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"authorities\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_paymentMethod\",\"type\":\"address\"}],\"name\":\"disablePaymentMethod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_paymentMethod\",\"type\":\"address\"}],\"name\":\"enablePaymentMethod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"enabledPaymentMethod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"enabledPaymentMethods\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEnabledPaymentMethods\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getIdentityId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"}],\"name\":\"getMintPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"masaToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"identityId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"queryLinkPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"queryLinkPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authority\",\"type\":\"address\"}],\"name\":\"removeAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveWallet\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_addLinkPrice\",\"type\":\"uint256\"}],\"name\":\"setAddLinkPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_addLinkPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setAddLinkPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_masaToken\",\"type\":\"address\"}],\"name\":\"setMasaToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintPrice\",\"type\":\"uint256\"}],\"name\":\"setMintPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setMintPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_queryLinkPrice\",\"type\":\"uint256\"}],\"name\":\"setQueryLinkPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_queryLinkPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setQueryLinkPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_reserveWallet\",\"type\":\"address\"}],\"name\":\"setReserveWallet\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"_soulboundIdentity\",\"type\":\"address\"}],\"name\":\"setSoulboundIdentity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_stableCoin\",\"type\":\"address\"}],\"name\":\"setStableCoin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_swapRouter\",\"type\":\"address\"}],\"name\":\"setSwapRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wrappedNativeToken\",\"type\":\"address\"}],\"name\":\"setWrappedNativeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"soulboundIdentity\",\"outputs\":[{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stableCoin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedNativeToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Masa Finance\",\"details\":\"Soulbound 2FA, that inherits from the SBT contract.\",\"kind\":\"dev\",\"methods\":{\"addAuthority(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_authority\":\"New authority to add\"}},\"balanceOf(address)\":{\"details\":\"See {ISBT-balanceOf}.\"},\"burn(uint256)\":{\"details\":\"Burns `tokenId`. See {SBT-_burn}. Requirements: - The caller must own `tokenId` or be an approved operator.\"},\"constructor\":{\"details\":\"Creates a new soulbound 2FA, inheriting from the SBT contract.\",\"params\":{\"admin\":\"Administrator of the smart contract\",\"baseTokenURI\":\"Base URI of the token\",\"paymentParams\":\"Payment gateway params\",\"soulboundIdentity\":\"Address of the SoulboundIdentity contract\"}},\"disablePaymentMethod(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_paymentMethod\":\"Token to remove\"}},\"enablePaymentMethod(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_paymentMethod\":\"New token to add\"}},\"exists(uint256)\":{\"details\":\"Returns true if the token has been minted\",\"params\":{\"tokenId\":\"Token to check\"},\"returns\":{\"_0\":\"True if the token exists\"}},\"getEnabledPaymentMethods()\":{\"details\":\"Returns the address of all available payment methods\",\"returns\":{\"_0\":\"Array of all enabled payment methods\"}},\"getIdentityId(uint256)\":{\"params\":{\"tokenId\":\"Id of the token\"},\"returns\":{\"_0\":\"Id of the identity\"}},\"getMintPrice(address)\":{\"details\":\"Returns current pricing for minting\",\"params\":{\"paymentMethod\":\"Address of token that user want to pay\"},\"returns\":{\"_0\":\"Current price for minting in the given payment method\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"mint(address,address,address,uint256,bytes)\":{\"details\":\"The caller must have the MINTER role\",\"params\":{\"authorityAddress\":\"Address of the authority that signed the message\",\"paymentMethod\":\"Address of token that user want to pay\",\"signature\":\"Signature of the message\",\"signatureDate\":\"Date of the signature\",\"to\":\"The address to mint the SBT to\"},\"returns\":{\"_0\":\"The SBT ID of the newly minted SBT\"}},\"mint(address,uint256,address,uint256,bytes)\":{\"details\":\"The caller must have the MINTER role\",\"params\":{\"authorityAddress\":\"Address of the authority that signed the message\",\"identityId\":\"TokenId of the identity to mint the NFT to\",\"paymentMethod\":\"Address of token that user want to pay\",\"signature\":\"Signature of the message\",\"signatureDate\":\"Date of the signature\"},\"returns\":{\"_0\":\"The NFT ID of the newly minted SBT\"}},\"name()\":{\"details\":\"See {ISBTMetadata-name}.\"},\"ownerOf(uint256)\":{\"details\":\"See {ISBT-ownerOf}.\"},\"removeAuthority(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_authority\":\"Authority to remove\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setAddLinkPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_addLinkPrice\":\"New price for adding the link in SoulLinker in stable coin\"}},\"setAddLinkPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_addLinkPriceMASA\":\"New price for adding the link in SoulLinker in MASA\"}},\"setMasaToken(address)\":{\"details\":\"The caller must have the admin role to call this function It can be set to address(0) to disable paying in MASA\",\"params\":{\"_masaToken\":\"New utility token to pay the fee in\"}},\"setMintPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_mintPrice\":\"New price of minting in stable coin\"}},\"setMintPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_mintPriceMASA\":\"New price of minting in MASA\"}},\"setQueryLinkPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_queryLinkPrice\":\"New price for reading data in SoulLinker in stable coin\"}},\"setQueryLinkPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_queryLinkPriceMASA\":\"New price for reading data in SoulLinker in MASA\"}},\"setReserveWallet(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_reserveWallet\":\"New reserve wallet\"}},\"setSoulboundIdentity(address)\":{\"details\":\"The caller must be the admin to call this function\",\"params\":{\"_soulboundIdentity\":\"Address of the SoulboundIdentity contract\"}},\"setStableCoin(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_stableCoin\":\"New stable coin to pay the fee in\"}},\"setSwapRouter(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_swapRouter\":\"New swap router address\"}},\"setWrappedNativeToken(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_wrappedNativeToken\":\"New wrapped native token address\"}},\"supportsInterface(bytes4)\":{\"details\":\"Interface identification is specified in ERC-165.\",\"params\":{\"interfaceId\":\"The interface identifier, as specified in ERC-165\"},\"returns\":{\"_0\":\"`true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise\"}},\"symbol()\":{\"details\":\"See {ISBTMetadata-symbol}.\"},\"tokenByIndex(uint256)\":{\"details\":\"See {ISBTEnumerable-tokenByIndex}.\"},\"tokenOfOwnerByIndex(address,uint256)\":{\"details\":\"See {ISBTEnumerable-tokenOfOwnerByIndex}.\"},\"tokenURI(uint256)\":{\"details\":\"Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the \\\"ERC721 Metadata JSON Schema\\\".\",\"params\":{\"tokenId\":\"SBT to get the URI of\"},\"returns\":{\"_0\":\"URI of the SBT\"}},\"totalSupply()\":{\"details\":\"See {ISBTEnumerable-totalSupply}.\"}},\"title\":\"Soulbound Two-factor authentication (2FA)\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addAuthority(address)\":{\"notice\":\"Adds a new authority to the list of authorities\"},\"constructor\":{\"notice\":\"Creates a new soulbound Two-factor authentication (2FA)\"},\"disablePaymentMethod(address)\":{\"notice\":\"Removes a token as a valid payment method\"},\"enablePaymentMethod(address)\":{\"notice\":\"Adds a new token as a valid payment method\"},\"exists(uint256)\":{\"notice\":\"Returns true if the token exists\"},\"getEnabledPaymentMethods()\":{\"notice\":\"Returns all available payment methods\"},\"getIdentityId(uint256)\":{\"notice\":\"Returns the identityId owned by the given token\"},\"getMintPrice(address)\":{\"notice\":\"Returns the price for minting\"},\"mint(address,address,address,uint256,bytes)\":{\"notice\":\"Mints a new SBT\"},\"mint(address,uint256,address,uint256,bytes)\":{\"notice\":\"Mints a new SBT\"},\"removeAuthority(address)\":{\"notice\":\"Removes an authority from the list of authorities\"},\"setAddLinkPrice(uint256)\":{\"notice\":\"Sets the price for adding the link in SoulLinker in stable coin\"},\"setAddLinkPriceMASA(uint256)\":{\"notice\":\"Sets the price for adding the link in SoulLinker in MASA\"},\"setMasaToken(address)\":{\"notice\":\"Sets the utility token to pay the fee in (MASA)\"},\"setMintPrice(uint256)\":{\"notice\":\"Sets the price of minting in stable coin\"},\"setMintPriceMASA(uint256)\":{\"notice\":\"Sets the price of minting in MASA\"},\"setQueryLinkPrice(uint256)\":{\"notice\":\"Sets the price for reading data in SoulLinker in stable coin\"},\"setQueryLinkPriceMASA(uint256)\":{\"notice\":\"Sets the price for reading data in SoulLinker in MASA\"},\"setReserveWallet(address)\":{\"notice\":\"Set the reserve wallet\"},\"setSoulboundIdentity(address)\":{\"notice\":\"Sets the SoulboundIdentity contract address linked to this SBT\"},\"setStableCoin(address)\":{\"notice\":\"Sets the stable coin to pay the fee in (USDC)\"},\"setSwapRouter(address)\":{\"notice\":\"Sets the swap router address\"},\"setWrappedNativeToken(address)\":{\"notice\":\"Sets the wrapped native token address\"},\"supportsInterface(bytes4)\":{\"notice\":\"Query if a contract implements an interface\"},\"tokenURI(uint256)\":{\"notice\":\"A distinct Uniform Resource Identifier (URI) for a given asset.\"}},\"notice\":\"Soulbound token that represents a Two-factor authentication (2FA)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Soulbound2FA.sol\":\"Soulbound2FA\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"details\":{\"constantOptimizer\":true,\"cse\":true,\"deduplicate\":true,\"inliner\":true,\"jumpdestRemover\":true,\"orderLiterals\":true,\"peephole\":true,\"yul\":false},\"runs\":1},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(uint160(account), 20),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5b35d8e68aeaccc685239bd9dd79b9ba01a0357930f8a3307ab85511733d9724\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Counters.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Counters\\n * @author Matt Condon (@shrugs)\\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\\n *\\n * Include with `using Counters for Counters.Counter;`\\n */\\nlibrary Counters {\\n struct Counter {\\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\\n // this feature: see https://github.com/ethereum/solidity/issues/4637\\n uint256 _value; // default: 0\\n }\\n\\n function current(Counter storage counter) internal view returns (uint256) {\\n return counter._value;\\n }\\n\\n function increment(Counter storage counter) internal {\\n unchecked {\\n counter._value += 1;\\n }\\n }\\n\\n function decrement(Counter storage counter) internal {\\n uint256 value = counter._value;\\n require(value > 0, \\\"Counter: decrement overflow\\\");\\n unchecked {\\n counter._value = value - 1;\\n }\\n }\\n\\n function reset(Counter storage counter) internal {\\n counter._value = 0;\\n }\\n}\\n\",\"keccak256\":\"0xf0018c2440fbe238dd3a8732fa8e17a0f9dce84d31451dc8a32f6d62b349c9f1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xdb7f5c28fc61cda0bd8ab60ce288e206b791643bcd3ba464a70cbec18895a2f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./ECDSA.sol\\\";\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\\n *\\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\\n *\\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\\n * ({_hashTypedDataV4}).\\n *\\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\\n * the chain id to protect against replay attacks on an eventual fork of the chain.\\n *\\n * NOTE: This contract implements the version of the encoding known as \\\"v4\\\", as implemented by the JSON RPC method\\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\\n *\\n * _Available since v3.4._\\n */\\nabstract contract EIP712 {\\n /* solhint-disable var-name-mixedcase */\\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\\n // invalidate the cached domain separator if the chain id changes.\\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\\n uint256 private immutable _CACHED_CHAIN_ID;\\n address private immutable _CACHED_THIS;\\n\\n bytes32 private immutable _HASHED_NAME;\\n bytes32 private immutable _HASHED_VERSION;\\n bytes32 private immutable _TYPE_HASH;\\n\\n /* solhint-enable var-name-mixedcase */\\n\\n /**\\n * @dev Initializes the domain separator and parameter caches.\\n *\\n * The meaning of `name` and `version` is specified in\\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\\n *\\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\\n * - `version`: the current major version of the signing domain.\\n *\\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\\n * contract upgrade].\\n */\\n constructor(string memory name, string memory version) {\\n bytes32 hashedName = keccak256(bytes(name));\\n bytes32 hashedVersion = keccak256(bytes(version));\\n bytes32 typeHash = keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n );\\n _HASHED_NAME = hashedName;\\n _HASHED_VERSION = hashedVersion;\\n _CACHED_CHAIN_ID = block.chainid;\\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\\n _CACHED_THIS = address(this);\\n _TYPE_HASH = typeHash;\\n }\\n\\n /**\\n * @dev Returns the domain separator for the current chain.\\n */\\n function _domainSeparatorV4() internal view returns (bytes32) {\\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\\n return _CACHED_DOMAIN_SEPARATOR;\\n } else {\\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\\n }\\n }\\n\\n function _buildDomainSeparator(\\n bytes32 typeHash,\\n bytes32 nameHash,\\n bytes32 versionHash\\n ) private view returns (bytes32) {\\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\\n }\\n\\n /**\\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\\n * function returns the hash of the fully encoded EIP712 message for this domain.\\n *\\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\\n *\\n * ```solidity\\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\\n * keccak256(\\\"Mail(address to,string contents)\\\"),\\n * mailTo,\\n * keccak256(bytes(mailContents))\\n * )));\\n * address signer = ECDSA.recover(digest, signature);\\n * ```\\n */\\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\\n }\\n}\\n\",\"keccak256\":\"0x6688fad58b9ec0286d40fa957152e575d5d8bd4c3aa80985efdb11b44f776ae7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a * b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"contracts/Soulbound2FA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\nimport \\\"./libraries/Errors.sol\\\";\\nimport \\\"./tokens/MasaSBTSelfSovereign.sol\\\";\\n\\n/// @title Soulbound Two-factor authentication (2FA)\\n/// @author Masa Finance\\n/// @notice Soulbound token that represents a Two-factor authentication (2FA)\\n/// @dev Soulbound 2FA, that inherits from the SBT contract.\\ncontract Soulbound2FA is MasaSBTSelfSovereign, ReentrancyGuard {\\n /* ========== STATE VARIABLES =========================================== */\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound Two-factor authentication (2FA)\\n /// @dev Creates a new soulbound 2FA, inheriting from the SBT contract.\\n /// @param admin Administrator of the smart contract\\n /// @param baseTokenURI Base URI of the token\\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\\n /// @param paymentParams Payment gateway params\\n constructor(\\n address admin,\\n string memory baseTokenURI,\\n ISoulboundIdentity soulboundIdentity,\\n PaymentParams memory paymentParams\\n )\\n MasaSBTSelfSovereign(\\n admin,\\n \\\"Masa 2FA\\\",\\n \\\"M2F\\\",\\n baseTokenURI,\\n soulboundIdentity,\\n paymentParams\\n )\\n EIP712(\\\"Soulbound2FA\\\", \\\"1.0.0\\\")\\n {}\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /// @notice Mints a new SBT\\n /// @dev The caller must have the MINTER role\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param identityId TokenId of the identity to mint the NFT to\\n /// @param authorityAddress Address of the authority that signed the message\\n /// @param signatureDate Date of the signature\\n /// @param signature Signature of the message\\n /// @return The NFT ID of the newly minted SBT\\n function mint(\\n address paymentMethod,\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate,\\n bytes calldata signature\\n ) public payable virtual nonReentrant returns (uint256) {\\n address to = soulboundIdentity.ownerOf(identityId);\\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\\n\\n _verify(\\n _hash(identityId, authorityAddress, signatureDate),\\n signature,\\n authorityAddress\\n );\\n\\n _pay(paymentMethod, getMintPrice(paymentMethod));\\n\\n uint256 tokenId = _mintWithCounter(to);\\n\\n emit Soulbound2FAMintedToIdentity(\\n tokenId,\\n identityId,\\n authorityAddress,\\n signatureDate,\\n paymentMethod,\\n mintPrice\\n );\\n\\n return tokenId;\\n }\\n\\n /// @notice Mints a new SBT\\n /// @dev The caller must have the MINTER role\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param to The address to mint the SBT to\\n /// @param authorityAddress Address of the authority that signed the message\\n /// @param signatureDate Date of the signature\\n /// @param signature Signature of the message\\n /// @return The SBT ID of the newly minted SBT\\n function mint(\\n address paymentMethod,\\n address to,\\n address authorityAddress,\\n uint256 signatureDate,\\n bytes calldata signature\\n ) external payable virtual returns (uint256) {\\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\\n\\n _verify(\\n _hash(to, authorityAddress, signatureDate),\\n signature,\\n authorityAddress\\n );\\n\\n _pay(paymentMethod, getMintPrice(paymentMethod));\\n\\n uint256 tokenId = _mintWithCounter(to);\\n\\n emit Soulbound2FAMintedToAddress(\\n tokenId,\\n to,\\n authorityAddress,\\n signatureDate,\\n paymentMethod,\\n mintPrice\\n );\\n\\n return tokenId;\\n }\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _hash(\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate\\n ) internal view returns (bytes32) {\\n return\\n _hashTypedDataV4(\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Mint2FA(uint256 identityId,address authorityAddress,uint256 signatureDate)\\\"\\n ),\\n identityId,\\n authorityAddress,\\n signatureDate\\n )\\n )\\n );\\n }\\n\\n function _hash(\\n address to,\\n address authorityAddress,\\n uint256 signatureDate\\n ) internal view returns (bytes32) {\\n return\\n _hashTypedDataV4(\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Mint2FA(address to,address authorityAddress,uint256 signatureDate)\\\"\\n ),\\n to,\\n authorityAddress,\\n signatureDate\\n )\\n )\\n );\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n\\n event Soulbound2FAMintedToIdentity(\\n uint256 tokenId,\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate,\\n address paymentMethod,\\n uint256 mintPrice\\n );\\n\\n event Soulbound2FAMintedToAddress(\\n uint256 tokenId,\\n address to,\\n address authorityAddress,\\n uint256 signatureDate,\\n address paymentMethod,\\n uint256 mintPrice\\n );\\n}\\n\",\"keccak256\":\"0x09363a0ec6d1313b4f3164262b699566875e0738b075c730a58414dfd8afddb6\",\"license\":\"MIT\"},\"contracts/dex/PaymentGateway.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/dex/IUniswapRouter.sol\\\";\\n\\n/// @title Pay using a Decentralized automated market maker (AMM) when needed\\n/// @author Masa Finance\\n/// @notice Smart contract to call a Dex AMM smart contract to pay to a reserve wallet recipient\\n/// @dev This smart contract will call the Uniswap Router interface, based on\\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\\nabstract contract PaymentGateway is AccessControl {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n\\n struct PaymentParams {\\n address swapRouter; // Swap router address\\n address wrappedNativeToken; // Wrapped native token address\\n address stableCoin; // Stable coin to pay the fee in (USDC)\\n address masaToken; // Utility token to pay the fee in (MASA)\\n address reserveWallet; // Wallet that will receive the fee\\n }\\n\\n /* ========== STATE VARIABLES =========================================== */\\n\\n address public swapRouter;\\n address public wrappedNativeToken;\\n\\n address public stableCoin; // USDC. It also needs to be enabled as payment method, if we want to pay in USDC\\n address public masaToken; // MASA. It also needs to be enabled as payment method, if we want to pay in MASA\\n\\n // enabled payment methods: ETH and ERC20 tokens\\n mapping(address => bool) public enabledPaymentMethod;\\n address[] public enabledPaymentMethods;\\n\\n address public reserveWallet;\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new Dex AMM\\n /// @dev Creates a new Decentralized automated market maker (AMM) smart contract,\\n // that will call the Uniswap Router interface\\n /// @param admin Administrator of the smart contract\\n /// @param paymentParams Payment params\\n constructor(address admin, PaymentParams memory paymentParams) {\\n if (paymentParams.swapRouter == address(0)) revert ZeroAddress();\\n if (paymentParams.wrappedNativeToken == address(0))\\n revert ZeroAddress();\\n if (paymentParams.stableCoin == address(0)) revert ZeroAddress();\\n if (paymentParams.reserveWallet == address(0)) revert ZeroAddress();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\\n\\n swapRouter = paymentParams.swapRouter;\\n wrappedNativeToken = paymentParams.wrappedNativeToken;\\n stableCoin = paymentParams.stableCoin;\\n masaToken = paymentParams.masaToken;\\n reserveWallet = paymentParams.reserveWallet;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the swap router address\\n /// @dev The caller must have the admin role to call this function\\n /// @param _swapRouter New swap router address\\n function setSwapRouter(address _swapRouter)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_swapRouter == address(0)) revert ZeroAddress();\\n if (swapRouter == _swapRouter) revert SameValue();\\n swapRouter = _swapRouter;\\n }\\n\\n /// @notice Sets the wrapped native token address\\n /// @dev The caller must have the admin role to call this function\\n /// @param _wrappedNativeToken New wrapped native token address\\n function setWrappedNativeToken(address _wrappedNativeToken)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_wrappedNativeToken == address(0)) revert ZeroAddress();\\n if (wrappedNativeToken == _wrappedNativeToken) revert SameValue();\\n wrappedNativeToken = _wrappedNativeToken;\\n }\\n\\n /// @notice Sets the stable coin to pay the fee in (USDC)\\n /// @dev The caller must have the admin role to call this function\\n /// @param _stableCoin New stable coin to pay the fee in\\n function setStableCoin(address _stableCoin)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_stableCoin == address(0)) revert ZeroAddress();\\n if (stableCoin == _stableCoin) revert SameValue();\\n stableCoin = _stableCoin;\\n }\\n\\n /// @notice Sets the utility token to pay the fee in (MASA)\\n /// @dev The caller must have the admin role to call this function\\n /// It can be set to address(0) to disable paying in MASA\\n /// @param _masaToken New utility token to pay the fee in\\n function setMasaToken(address _masaToken)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (masaToken == _masaToken) revert SameValue();\\n masaToken = _masaToken;\\n }\\n\\n /// @notice Adds a new token as a valid payment method\\n /// @dev The caller must have the admin role to call this function\\n /// @param _paymentMethod New token to add\\n function enablePaymentMethod(address _paymentMethod)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (enabledPaymentMethod[_paymentMethod]) revert AlreadyAdded();\\n\\n enabledPaymentMethod[_paymentMethod] = true;\\n enabledPaymentMethods.push(_paymentMethod);\\n }\\n\\n /// @notice Removes a token as a valid payment method\\n /// @dev The caller must have the admin role to call this function\\n /// @param _paymentMethod Token to remove\\n function disablePaymentMethod(address _paymentMethod)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (!enabledPaymentMethod[_paymentMethod])\\n revert NonExistingErc20Token(_paymentMethod);\\n\\n enabledPaymentMethod[_paymentMethod] = false;\\n for (uint256 i = 0; i < enabledPaymentMethods.length; i++) {\\n if (enabledPaymentMethods[i] == _paymentMethod) {\\n enabledPaymentMethods[i] = enabledPaymentMethods[\\n enabledPaymentMethods.length - 1\\n ];\\n enabledPaymentMethods.pop();\\n break;\\n }\\n }\\n }\\n\\n /// @notice Set the reserve wallet\\n /// @dev The caller must have the admin role to call this function\\n /// @param _reserveWallet New reserve wallet\\n function setReserveWallet(address _reserveWallet)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_reserveWallet == address(0)) revert ZeroAddress();\\n if (_reserveWallet == reserveWallet) revert SameValue();\\n reserveWallet = _reserveWallet;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns all available payment methods\\n /// @dev Returns the address of all available payment methods\\n /// @return Array of all enabled payment methods\\n function getEnabledPaymentMethods()\\n external\\n view\\n returns (address[] memory)\\n {\\n return enabledPaymentMethods;\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n /// @notice Converts an amount from a stable coin to a payment method amount\\n /// @dev This method will perform the swap between the stable coin and the\\n /// payment method, and return the amount of the payment method,\\n /// performing the swap if necessary\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param amount Price to be converted in the specified payment method\\n function _convertFromStableCoin(address paymentMethod, uint256 amount)\\n internal\\n view\\n returns (uint256)\\n {\\n if (!enabledPaymentMethod[paymentMethod] || paymentMethod == stableCoin)\\n revert InvalidToken(paymentMethod);\\n\\n if (paymentMethod == address(0)) {\\n return _estimateSwapAmount(wrappedNativeToken, stableCoin, amount);\\n } else {\\n return _estimateSwapAmount(paymentMethod, stableCoin, amount);\\n }\\n }\\n\\n /// @notice Performs the payment in any payment method\\n /// @dev This method will transfer the funds to the reserve wallet, performing\\n /// the swap if necessary\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param amount Price to be paid in the specified payment method\\n function _pay(address paymentMethod, uint256 amount) internal {\\n if (amount == 0) return;\\n if (!enabledPaymentMethod[paymentMethod])\\n revert InvalidPaymentMethod(paymentMethod);\\n if (paymentMethod == address(0)) {\\n // ETH\\n if (msg.value < amount) revert InsufficientEthAmount(amount);\\n (bool success, ) = payable(reserveWallet).call{value: amount}(\\\"\\\");\\n if (!success) revert TransferFailed();\\n if (msg.value > amount) {\\n // return diff\\n uint256 refund = msg.value.sub(amount);\\n (success, ) = payable(msg.sender).call{value: refund}(\\\"\\\");\\n if (!success) revert RefundFailed();\\n }\\n } else {\\n // ERC20 token, including MASA and USDC\\n IERC20(paymentMethod).safeTransferFrom(\\n msg.sender,\\n reserveWallet,\\n amount\\n );\\n }\\n }\\n\\n function _estimateSwapAmount(\\n address _fromToken,\\n address _toToken,\\n uint256 _amountOut\\n ) private view returns (uint256) {\\n uint256[] memory amounts;\\n address[] memory path;\\n path = _getPathFromTokenToToken(_fromToken, _toToken);\\n amounts = IUniswapRouter(swapRouter).getAmountsIn(_amountOut, path);\\n return amounts[0];\\n }\\n\\n function _getPathFromTokenToToken(address fromToken, address toToken)\\n private\\n view\\n returns (address[] memory)\\n {\\n if (fromToken == wrappedNativeToken || toToken == wrappedNativeToken) {\\n address[] memory path = new address[](2);\\n path[0] = fromToken == wrappedNativeToken\\n ? wrappedNativeToken\\n : fromToken;\\n path[1] = toToken == wrappedNativeToken\\n ? wrappedNativeToken\\n : toToken;\\n return path;\\n } else {\\n address[] memory path = new address[](3);\\n path[0] = fromToken;\\n path[1] = wrappedNativeToken;\\n path[2] = toToken;\\n return path;\\n }\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0xe5262dbf09717fd9c0283f2ec1b519062e525d36edd399f42f8ae9325564d0b1\",\"license\":\"MIT\"},\"contracts/interfaces/ILinkableSBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../tokens/SBT/ISBT.sol\\\";\\n\\ninterface ILinkableSBT is ISBT {\\n function addLinkPrice() external view returns (uint256);\\n\\n function addLinkPriceMASA() external view returns (uint256);\\n\\n function queryLinkPrice() external view returns (uint256);\\n\\n function queryLinkPriceMASA() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x1015d56aa9b3250816385ea78bb865a315d1882313e43381df64b587016bd3c0\",\"license\":\"MIT\"},\"contracts/interfaces/ISoulName.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\ninterface ISoulName {\\n function mint(\\n address to,\\n string memory name,\\n uint256 yearsPeriod,\\n string memory _tokenURI\\n ) external returns (uint256);\\n\\n function getExtension() external view returns (string memory);\\n\\n function isAvailable(string memory name)\\n external\\n view\\n returns (bool available);\\n\\n function getTokenData(string memory name)\\n external\\n view\\n returns (\\n string memory sbtName,\\n bool linked,\\n uint256 identityId,\\n uint256 tokenId,\\n uint256 expirationDate,\\n bool active\\n );\\n\\n function getTokenId(string memory name) external view returns (uint256);\\n\\n function getSoulNames(address owner)\\n external\\n view\\n returns (string[] memory sbtNames);\\n\\n function getSoulNames(uint256 identityId)\\n external\\n view\\n returns (string[] memory sbtNames);\\n}\\n\",\"keccak256\":\"0x8793d235ae8c9d723280f7ef0b35f1fb8a3fd0a706c7d9943c7a68db850e31c7\",\"license\":\"MIT\"},\"contracts/interfaces/ISoulboundIdentity.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../tokens/SBT/ISBT.sol\\\";\\n\\nimport \\\"./ISoulName.sol\\\";\\n\\ninterface ISoulboundIdentity is ISBT {\\n function mint(address to) external returns (uint256);\\n\\n function mintIdentityWithName(\\n address to,\\n string memory name,\\n uint256 yearsPeriod,\\n string memory _tokenURI\\n ) external returns (uint256);\\n\\n function getSoulName() external view returns (ISoulName);\\n\\n function tokenOfOwner(address owner) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x443506c61e4b65b8587c43928ed004d880feb4e272a56f474bb8def5d9090c0a\",\"license\":\"MIT\"},\"contracts/interfaces/dex/IUniswapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\n/// @title Uniswap Router interface\\n/// @author Masa Finance\\n/// @notice Interface of the Uniswap Router contract\\n/// @dev This interface is used to interact with the Uniswap Router contract,\\n/// and gets the most important functions of the contract. It's based on\\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\\ninterface IUniswapRouter {\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function getAmountsOut(uint256 amountIn, address[] calldata path)\\n external\\n view\\n returns (uint256[] memory amounts);\\n\\n function getAmountsIn(uint256 amountOut, address[] calldata path)\\n external\\n view\\n returns (uint256[] memory amounts);\\n}\\n\",\"keccak256\":\"0xc5821fe554ec90d78f9d0fc5a627346e9e0542a9af5722e6707933853c867d4f\",\"license\":\"MIT\"},\"contracts/libraries/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nerror AddressDoesNotHaveIdentity(address to);\\nerror AlreadyAdded();\\nerror AuthorityNotExists(address authority);\\nerror CallerNotOwner(address caller);\\nerror CallerNotReader(address caller);\\nerror CreditScoreAlreadyCreated(address to);\\nerror IdentityAlreadyCreated(address to);\\nerror IdentityOwnerIsReader(uint256 readerIdentityId);\\nerror InsufficientEthAmount(uint256 amount);\\nerror IdentityOwnerNotTokenOwner(uint256 tokenId, uint256 ownerIdentityId);\\nerror InvalidPaymentMethod(address paymentMethod);\\nerror InvalidSignature();\\nerror InvalidSignatureDate(uint256 signatureDate);\\nerror InvalidToken(address token);\\nerror InvalidTokenURI(string tokenURI);\\nerror LinkAlreadyExists(\\n address token,\\n uint256 tokenId,\\n uint256 readerIdentityId,\\n uint256 signatureDate\\n);\\nerror LinkAlreadyRevoked();\\nerror LinkDoesNotExist();\\nerror NameAlreadyExists(string name);\\nerror NameNotFound(string name);\\nerror NameRegisteredByOtherAccount(string name, uint256 tokenId);\\nerror NotAuthorized(address signer);\\nerror NonExistingErc20Token(address erc20token);\\nerror NotLinkedToAnIdentitySBT();\\nerror RefundFailed();\\nerror SameValue();\\nerror SBTAlreadyLinked(address token);\\nerror SoulNameContractNotSet();\\nerror TokenNotFound(uint256 tokenId);\\nerror TransferFailed();\\nerror URIAlreadyExists(string tokenURI);\\nerror ValidPeriodExpired(uint256 expirationDate);\\nerror ZeroAddress();\\nerror ZeroLengthName(string name);\\nerror ZeroYearsPeriod(uint256 yearsPeriod);\\n\",\"keccak256\":\"0x6f844a5a2149390d1ad7113b302b7ae539c27b0e861133554dbe8c2e00fb99e7\",\"license\":\"MIT\"},\"contracts/tokens/MasaSBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/ILinkableSBT.sol\\\";\\nimport \\\"./SBT/SBT.sol\\\";\\nimport \\\"./SBT/extensions/SBTEnumerable.sol\\\";\\nimport \\\"./SBT/extensions/SBTBurnable.sol\\\";\\n\\n/// @title MasaSBT\\n/// @author Masa Finance\\n/// @notice Soulbound token. Non-fungible token that is not transferable.\\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\\nabstract contract MasaSBT is\\n SBT,\\n SBTEnumerable,\\n AccessControl,\\n SBTBurnable,\\n ILinkableSBT\\n{\\n /* ========== STATE VARIABLES =========================================== */\\n\\n using Strings for uint256;\\n\\n string private _baseTokenURI;\\n\\n uint256 public override addLinkPrice; // price in stable coin\\n uint256 public override addLinkPriceMASA; // price in MASA\\n uint256 public override queryLinkPrice; // price in stable coin\\n uint256 public override queryLinkPriceMASA; // price in MASA\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound token\\n /// @dev Creates a new soulbound token\\n /// @param admin Administrator of the smart contract\\n /// @param name Name of the token\\n /// @param symbol Symbol of the token\\n /// @param baseTokenURI Base URI of the token\\n constructor(\\n address admin,\\n string memory name,\\n string memory symbol,\\n string memory baseTokenURI\\n ) SBT(name, symbol) {\\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\\n\\n _baseTokenURI = baseTokenURI;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the price for adding the link in SoulLinker in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _addLinkPrice New price for adding the link in SoulLinker in stable coin\\n function setAddLinkPrice(uint256 _addLinkPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (addLinkPrice == _addLinkPrice) revert SameValue();\\n addLinkPrice = _addLinkPrice;\\n }\\n\\n /// @notice Sets the price for adding the link in SoulLinker in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _addLinkPriceMASA New price for adding the link in SoulLinker in MASA\\n function setAddLinkPriceMASA(uint256 _addLinkPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (addLinkPriceMASA == _addLinkPriceMASA) revert SameValue();\\n addLinkPriceMASA = _addLinkPriceMASA;\\n }\\n\\n /// @notice Sets the price for reading data in SoulLinker in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _queryLinkPrice New price for reading data in SoulLinker in stable coin\\n function setQueryLinkPrice(uint256 _queryLinkPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (queryLinkPrice == _queryLinkPrice) revert SameValue();\\n queryLinkPrice = _queryLinkPrice;\\n }\\n\\n /// @notice Sets the price for reading data in SoulLinker in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _queryLinkPriceMASA New price for reading data in SoulLinker in MASA\\n function setQueryLinkPriceMASA(uint256 _queryLinkPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (queryLinkPriceMASA == _queryLinkPriceMASA) revert SameValue();\\n queryLinkPriceMASA = _queryLinkPriceMASA;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns true if the token exists\\n /// @dev Returns true if the token has been minted\\n /// @param tokenId Token to check\\n /// @return True if the token exists\\n function exists(uint256 tokenId) external view returns (bool) {\\n return _exists(tokenId);\\n }\\n\\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\\n /// @dev Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC\\n /// 3986. The URI may point to a JSON file that conforms to the \\\"ERC721\\n /// Metadata JSON Schema\\\".\\n /// @param tokenId SBT to get the URI of\\n /// @return URI of the SBT\\n function tokenURI(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (string memory)\\n {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return\\n bytes(baseURI).length > 0\\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \\\".json\\\"))\\n : \\\"\\\";\\n }\\n\\n /// @notice Query if a contract implements an interface\\n /// @dev Interface identification is specified in ERC-165.\\n /// @param interfaceId The interface identifier, as specified in ERC-165\\n /// @return `true` if the contract implements `interfaceId` and\\n /// `interfaceId` is not 0xffffffff, `false` otherwise\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(SBT, SBTEnumerable, AccessControl, IERC165)\\n returns (bool)\\n {\\n return super.supportsInterface(interfaceId);\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _baseURI() internal view virtual override returns (string memory) {\\n return _baseTokenURI;\\n }\\n\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual override(SBT, SBTEnumerable) {\\n super._beforeTokenTransfer(from, to, tokenId);\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0x97a3f6aba32056305a1831e553d0557c4d9f4eed7407962ec47902d6699d7e37\",\"license\":\"MIT\"},\"contracts/tokens/MasaSBTSelfSovereign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Counters.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/ISoulboundIdentity.sol\\\";\\nimport \\\"../dex/PaymentGateway.sol\\\";\\nimport \\\"./MasaSBT.sol\\\";\\n\\n/// @title MasaSBTSelfSovereign\\n/// @author Masa Finance\\n/// @notice Soulbound token. Non-fungible token that is not transferable.\\n/// Adds a link to a SoulboundIdentity SC to let minting using the identityId\\n/// Adds a payment gateway to let minting paying a fee\\n/// Adds a self-sovereign protocol to let minting using an authority signature\\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\\nabstract contract MasaSBTSelfSovereign is PaymentGateway, MasaSBT, EIP712 {\\n /* ========== STATE VARIABLES =========================================== */\\n\\n using Counters for Counters.Counter;\\n\\n Counters.Counter private _tokenIdCounter;\\n\\n ISoulboundIdentity public soulboundIdentity;\\n\\n uint256 public mintPrice; // price in stable coin\\n uint256 public mintPriceMASA; // price in MASA\\n\\n mapping(address => bool) public authorities;\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound token\\n /// @dev Creates a new soulbound token\\n /// @param admin Administrator of the smart contract\\n /// @param name Name of the token\\n /// @param symbol Symbol of the token\\n /// @param baseTokenURI Base URI of the token\\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\\n /// @param paymentParams Payment gateway params\\n constructor(\\n address admin,\\n string memory name,\\n string memory symbol,\\n string memory baseTokenURI,\\n ISoulboundIdentity _soulboundIdentity,\\n PaymentParams memory paymentParams\\n )\\n PaymentGateway(admin, paymentParams)\\n MasaSBT(admin, name, symbol, baseTokenURI)\\n {\\n soulboundIdentity = _soulboundIdentity;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the SoulboundIdentity contract address linked to this SBT\\n /// @dev The caller must be the admin to call this function\\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\\n soulboundIdentity = _soulboundIdentity;\\n }\\n\\n /// @notice Sets the price of minting in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _mintPrice New price of minting in stable coin\\n function setMintPrice(uint256 _mintPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (mintPrice == _mintPrice) revert SameValue();\\n mintPrice = _mintPrice;\\n }\\n\\n /// @notice Sets the price of minting in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _mintPriceMASA New price of minting in MASA\\n function setMintPriceMASA(uint256 _mintPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (mintPriceMASA == _mintPriceMASA) revert SameValue();\\n mintPriceMASA = _mintPriceMASA;\\n }\\n\\n /// @notice Adds a new authority to the list of authorities\\n /// @dev The caller must have the admin role to call this function\\n /// @param _authority New authority to add\\n function addAuthority(address _authority)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_authority == address(0)) revert ZeroAddress();\\n if (authorities[_authority]) revert AlreadyAdded();\\n\\n authorities[_authority] = true;\\n }\\n\\n /// @notice Removes an authority from the list of authorities\\n /// @dev The caller must have the admin role to call this function\\n /// @param _authority Authority to remove\\n function removeAuthority(address _authority)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_authority == address(0)) revert ZeroAddress();\\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\\n\\n authorities[_authority] = false;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns the identityId owned by the given token\\n /// @param tokenId Id of the token\\n /// @return Id of the identity\\n function getIdentityId(uint256 tokenId) external view returns (uint256) {\\n if (soulboundIdentity == ISoulboundIdentity(address(0)))\\n revert NotLinkedToAnIdentitySBT();\\n\\n address owner = super.ownerOf(tokenId);\\n return soulboundIdentity.tokenOfOwner(owner);\\n }\\n\\n /// @notice Returns the price for minting\\n /// @dev Returns current pricing for minting\\n /// @param paymentMethod Address of token that user want to pay\\n /// @return Current price for minting in the given payment method\\n function getMintPrice(address paymentMethod) public view returns (uint256) {\\n if (mintPrice == 0 && mintPriceMASA == 0) {\\n return 0;\\n } else if (\\n paymentMethod == masaToken &&\\n enabledPaymentMethod[paymentMethod] &&\\n mintPriceMASA > 0\\n ) {\\n // price in MASA without conversion rate\\n return mintPriceMASA;\\n } else if (\\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\\n ) {\\n // stable coin\\n return mintPrice;\\n } else if (enabledPaymentMethod[paymentMethod]) {\\n // ETH and ERC 20 token\\n return _convertFromStableCoin(paymentMethod, mintPrice);\\n } else {\\n revert InvalidPaymentMethod(paymentMethod);\\n }\\n }\\n\\n /// @notice Query if a contract implements an interface\\n /// @dev Interface identification is specified in ERC-165.\\n /// @param interfaceId The interface identifier, as specified in ERC-165\\n /// @return `true` if the contract implements `interfaceId` and\\n /// `interfaceId` is not 0xffffffff, `false` otherwise\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(AccessControl, MasaSBT)\\n returns (bool)\\n {\\n return super.supportsInterface(interfaceId);\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _verify(\\n bytes32 digest,\\n bytes memory signature,\\n address signer\\n ) internal view {\\n address _signer = ECDSA.recover(digest, signature);\\n if (_signer != signer) revert InvalidSignature();\\n if (!authorities[_signer]) revert NotAuthorized(_signer);\\n }\\n\\n function _mintWithCounter(address to) internal virtual returns (uint256) {\\n uint256 tokenId = _tokenIdCounter.current();\\n _tokenIdCounter.increment();\\n _mint(to, tokenId);\\n\\n return tokenId;\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0xbfdfe31ae30bc6cb5ba35cb273d7acb3f905ca50c9f107e06a4d1bc54ed238d2\",\"license\":\"MIT\"},\"contracts/tokens/SBT/ISBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ninterface ISBT is IERC165 {\\n /// @dev This emits when an SBT is newly minted.\\n /// This event emits when SBTs are created\\n event Mint(address indexed _owner, uint256 indexed _tokenId);\\n\\n /// @dev This emits when an SBT is burned\\n /// This event emits when SBTs are destroyed\\n event Burn(address indexed _owner, uint256 indexed _tokenId);\\n\\n /// @notice Count all SBTs assigned to an owner\\n /// @dev SBTs assigned to the zero address are considered invalid, and this\\n /// function throws for queries about the zero address.\\n /// @param _owner An address for whom to query the balance\\n /// @return The number of SBTs owned by `_owner`, possibly zero\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice Find the owner of an SBT\\n /// @dev SBTs assigned to zero address are considered invalid, and queries\\n /// about them do throw.\\n /// @param _tokenId The identifier for an SBT\\n /// @return The address of the owner of the SBT\\n function ownerOf(uint256 _tokenId) external view returns (address);\\n}\\n\",\"keccak256\":\"0xe3bbe44185c28e82bafd54b2197ea0971af74864dd1e7148ac4bbc673d52d738\",\"license\":\"MIT\"},\"contracts/tokens/SBT/SBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/ERC165.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\n\\nimport \\\"./ISBT.sol\\\";\\nimport \\\"./extensions/ISBTMetadata.sol\\\";\\n\\n/// @title SBT\\n/// @author Masa Finance\\n/// @notice Soulbound token is an NFT token that is not transferable.\\ncontract SBT is Context, ERC165, ISBT, ISBTMetadata {\\n using Strings for uint256;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Mapping from token ID to owner address\\n mapping(uint256 => address) private _owners;\\n\\n // Mapping owner address to token count\\n mapping(address => uint256) private _balances;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(ERC165, IERC165)\\n returns (bool)\\n {\\n return\\n interfaceId == type(ISBT).interfaceId ||\\n interfaceId == type(ISBTMetadata).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {ISBT-balanceOf}.\\n */\\n function balanceOf(address owner)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(owner != address(0), \\\"SBT: address zero is not a valid owner\\\");\\n return _balances[owner];\\n }\\n\\n /**\\n * @dev See {ISBT-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (address)\\n {\\n address owner = _owners[tokenId];\\n require(owner != address(0), \\\"SBT: invalid token ID\\\");\\n return owner;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (string memory)\\n {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return\\n bytes(baseURI).length > 0\\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\\n : \\\"\\\";\\n }\\n\\n /**\\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\\n * by default, can be overridden in child contracts.\\n */\\n function _baseURI() internal view virtual returns (string memory) {\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isOwner(address spender, uint256 tokenId)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n address owner = SBT.ownerOf(tokenId);\\n return (spender == owner);\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _owners[tokenId] != address(0);\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Mint} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"SBT: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"SBT: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId);\\n\\n _balances[to] += 1;\\n _owners[tokenId] = to;\\n\\n emit Mint(to, tokenId);\\n\\n _afterTokenTransfer(address(0), to, tokenId);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n *\\n * Requirements:\\n * - `tokenId` must exist.\\n *\\n * Emits a {Burn} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = SBT.ownerOf(tokenId);\\n\\n _beforeTokenTransfer(owner, address(0), tokenId);\\n\\n _balances[owner] -= 1;\\n delete _owners[tokenId];\\n\\n emit Burn(owner, tokenId);\\n\\n _afterTokenTransfer(owner, address(0), tokenId);\\n }\\n\\n /**\\n * @dev Reverts if the `tokenId` has not been minted yet.\\n */\\n function _requireMinted(uint256 tokenId) internal view virtual {\\n require(_exists(tokenId), \\\"SBT: invalid token ID\\\");\\n }\\n\\n /**\\n * @dev Hook that is called before any token minting/burning\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address,\\n address,\\n uint256\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any minting/burning of tokens\\n *\\n * Calling conditions:\\n * - when `from` and `to` are both non-zero.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address,\\n address,\\n uint256\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x0248d73f3daa5e2fe5d306a0366e56f6f3c85ba461de46a3f0c5235b9d19af0e\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/ISBTEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../ISBT.sol\\\";\\n\\n/**\\n * @title SBT Soulbound Token Standard, optional enumeration extension\\n */\\ninterface ISBTEnumerable is ISBT {\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x3cfc53065d044d199a7af437aa9768d4a777caf702b2634ae65b4f896ba9ef3c\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/ISBTMetadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../ISBT.sol\\\";\\n\\n/**\\n * @title SBT Soulbound Token Standard, optional metadata extension\\n */\\ninterface ISBTMetadata is ISBT {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xfaff9e3f2be62198273767a93c4a82bcbe2909be23ec48fdbf5f1564fb690aee\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/SBTBurnable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\n\\nimport \\\"../SBT.sol\\\";\\n\\n/**\\n * @title SBT Burnable Token\\n * @dev SBT Token that can be burned (destroyed).\\n */\\nabstract contract SBTBurnable is Context, SBT {\\n /**\\n * @dev Burns `tokenId`. See {SBT-_burn}.\\n *\\n * Requirements:\\n *\\n * - The caller must own `tokenId` or be an approved operator.\\n */\\n function burn(uint256 tokenId) public virtual {\\n //solhint-disable-next-line max-line-length\\n require(\\n _isOwner(_msgSender(), tokenId),\\n \\\"SBT: caller is not token owner\\\"\\n );\\n _burn(tokenId);\\n }\\n}\\n\",\"keccak256\":\"0xffdf66fb4023f2aa75bc8bdf4ea2b8d27380f3fb4f1df8a65793f6605de10966\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/SBTEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../SBT.sol\\\";\\nimport \\\"./ISBTEnumerable.sol\\\";\\n\\n/**\\n * @dev This implements an optional extension of {SBT} defined in the EIP that adds\\n * enumerability of all the token ids in the contract as well as all token ids owned by each\\n * account.\\n */\\nabstract contract SBTEnumerable is SBT, ISBTEnumerable {\\n // Mapping from owner to list of owned token IDs\\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\\n\\n // Mapping from token ID to index of the owner tokens list\\n mapping(uint256 => uint256) private _ownedTokensIndex;\\n\\n // Array with all token ids, used for enumeration\\n uint256[] private _allTokens;\\n\\n // Mapping from token id to position in the allTokens array\\n mapping(uint256 => uint256) private _allTokensIndex;\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(IERC165, SBT)\\n returns (bool)\\n {\\n return\\n interfaceId == type(ISBTEnumerable).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-tokenOfOwnerByIndex}.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(\\n index < SBT.balanceOf(owner),\\n \\\"SBTEnumerable: owner index out of bounds\\\"\\n );\\n return _ownedTokens[owner][index];\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _allTokens.length;\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-tokenByIndex}.\\n */\\n function tokenByIndex(uint256 index)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(\\n index < SBTEnumerable.totalSupply(),\\n \\\"SBTEnumerable: global index out of bounds\\\"\\n );\\n return _allTokens[index];\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting\\n * and burning.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual override {\\n super._beforeTokenTransfer(from, to, tokenId);\\n\\n if (from == address(0)) {\\n _addTokenToAllTokensEnumeration(tokenId);\\n } else if (from != to) {\\n _removeTokenFromOwnerEnumeration(from, tokenId);\\n }\\n if (to == address(0)) {\\n _removeTokenFromAllTokensEnumeration(tokenId);\\n } else if (to != from) {\\n _addTokenToOwnerEnumeration(to, tokenId);\\n }\\n }\\n\\n /**\\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\\n * @param to address representing the new owner of the given token ID\\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\\n */\\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\\n uint256 length = SBT.balanceOf(to);\\n _ownedTokens[to][length] = tokenId;\\n _ownedTokensIndex[tokenId] = length;\\n }\\n\\n /**\\n * @dev Private function to add a token to this extension's token tracking data structures.\\n * @param tokenId uint256 ID of the token to be added to the tokens list\\n */\\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\\n _allTokensIndex[tokenId] = _allTokens.length;\\n _allTokens.push(tokenId);\\n }\\n\\n /**\\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\\n * @param from address representing the previous owner of the given token ID\\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\\n */\\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)\\n private\\n {\\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\\n // then delete the last slot (swap and pop).\\n\\n uint256 lastTokenIndex = SBT.balanceOf(from) - 1;\\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\\n\\n // When the token to delete is the last token, the swap operation is unnecessary\\n if (tokenIndex != lastTokenIndex) {\\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\\n\\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\\n }\\n\\n // This also deletes the contents at the last position of the array\\n delete _ownedTokensIndex[tokenId];\\n delete _ownedTokens[from][lastTokenIndex];\\n }\\n\\n /**\\n * @dev Private function to remove a token from this extension's token tracking data structures.\\n * This has O(1) time complexity, but alters the order of the _allTokens array.\\n * @param tokenId uint256 ID of the token to be removed from the tokens list\\n */\\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\\n // then delete the last slot (swap and pop).\\n\\n uint256 lastTokenIndex = _allTokens.length - 1;\\n uint256 tokenIndex = _allTokensIndex[tokenId];\\n\\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\\n uint256 lastTokenId = _allTokens[lastTokenIndex];\\n\\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\\n\\n // This also deletes the contents at the last position of the array\\n delete _allTokensIndex[tokenId];\\n _allTokens.pop();\\n }\\n}\\n\",\"keccak256\":\"0x6d18005011564b08decc293aed48684d29cc6872e1d5ace5514e42b86ea675a5\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x6101406040523480156200001257600080fd5b50604051620042f8380380620042f88339810160408190526200003591620005a4565b83604051806040016040528060088152602001674d6173612032464160c01b8152506040518060400160405280600381526020016226992360e91b8152508585856040518060400160405280600c81526020016b536f756c626f756e6432464160a01b815250604051806040016040528060058152602001640312e302e360dc1b815250878787878b8784848160009080519060200190620000d9929190620003d7565b508051620000ef906001906020840190620003d7565b505081516001600160a01b0316151590506200011e5760405163d92e233d60e01b815260040160405180910390fd5b60208101516001600160a01b03166200014a5760405163d92e233d60e01b815260040160405180910390fd5b60408101516001600160a01b0316620001765760405163d92e233d60e01b815260040160405180910390fd5b60808101516001600160a01b0316620001a25760405163d92e233d60e01b815260040160405180910390fd5b620001af600083620002e3565b8051600980546001600160a01b03199081166001600160a01b03938416179091556020830151600a805483169184169190911790556040830151600b805483169184169190911790556060830151600c80548316918416919091179055608090920151600f80549093169116179055506200022c600085620002e3565b805162000241906010906020840190620003d7565b5050845160208087019190912085519186019190912060e08290526101008190524660a05290935091507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90506200029b8184846200036e565b6080523060601b60c052610120525050601680546001600160a01b0319166001600160a01b03959095169490941790935550506001601a5550620007fc975050505050505050565b620002ef8282620003aa565b6200036a5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620003293390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600083838346306040516020016200038b95949392919062000647565b6040516020818303038152906040528051906020012090509392505050565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b828054620003e5906200073e565b90600052602060002090601f01602090048101928262000409576000855562000454565b82601f106200042457805160ff191683800117855562000454565b8280016001018555821562000454579182015b828111156200045457825182559160200191906001019062000437565b506200046292915062000466565b5090565b5b8082111562000462576000815560010162000467565b6000620004946200048e84620006bc565b6200069d565b905082815260208101848484011115620004b157620004b1600080fd5b620004be8482856200070b565b509392505050565b8051620003d181620007d7565b8051620003d181620007f1565b600082601f830112620004f657620004f6600080fd5b8151620005088482602086016200047d565b949350505050565b600060a08284031215620005275762000527600080fd5b6200053360a06200069d565b90506000620005438484620004c6565b82525060206200055684848301620004c6565b60208301525060406200056c84828501620004c6565b60408301525060606200058284828501620004c6565b60608301525060806200059884828501620004c6565b60808301525092915050565b6000806000806101008587031215620005c057620005c0600080fd5b6000620005ce8787620004c6565b94505060208501516001600160401b03811115620005ef57620005ef600080fd5b620005fd87828801620004e0565b93505060406200061087828801620004d3565b9250506060620006238782880162000510565b91505092959194509250565b6200063a81620006ec565b82525050565b806200063a565b60a0810162000657828862000640565b62000666602083018762000640565b62000675604083018662000640565b62000684606083018562000640565b6200069360808301846200062f565b9695505050505050565b6000620006a960405190565b9050620006b782826200076f565b919050565b60006001600160401b03821115620006d857620006d8620007b7565b620006e382620007cd565b60200192915050565b60006001600160a01b038216620003d1565b6000620003d182620006ec565b60005b83811015620007285781810151838201526020016200070e565b8381111562000738576000848401525b50505050565b6002810460018216806200075357607f821691505b60208210811415620007695762000769620007a1565b50919050565b6200077a82620007cd565b81018181106001600160401b03821117156200079a576200079a620007b7565b6040525050565b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b620007e281620006ec565b8114620007ee57600080fd5b50565b620007e281620006fe565b60805160a05160c05160601c60e0516101005161012051613aa96200084f600039600061220a0152600061224c0152600061222b0152600061218f015260006121b9015260006121e30152613aa96000f3fe60806040526004361061025a5760003560e01c806301ffc9a71461025f5780630513c3e91461029557806306fdde03146102c257806310200519146102e457806313150b481461030657806317fcb39b1461032957806318160ddd146103495780631830e8811461035e5780631f37c1241461037457806320d558aa1461038a57806323af4e171461039d578063248a9ca3146103bf57806326defa73146103df578063289c686b146103ff5780632f2ff15d1461041f5780632f745c591461043f57806336568abe1461045f5780633ad3033e1461047f5780633c72ae701461049f57806341273657146104bf57806342966c68146104df5780634962a158146104ff5780634f558e791461051f5780634f6ccce71461053f5780636352211e1461055f5780636817c76c1461057f57806370a0823114610595578063719d0f2b146105b557806376ad1997146105d5578063776d1a54146105f557806377bed5ed1461060b5780637a0d1646146106385780637ad09dff146106685780637db8cb681461067b57806391223d691461069b57806391d14854146106cb57806394a665e9146106eb57806395d89b411461070b578063992642e514610720578063a217fddf14610740578063b97d6b2314610755578063c1177d191461076b578063c31c9c071461078b578063c86aadb6146107ab578063c87b56dd146107cb578063d544e010146107eb578063d547741f1461080b578063d72b11bd1461082b578063da058ae31461084b578063dda4fa8f1461086b578063ebda43961461088b578063f4a0a528146108ab578063fd48ac83146108cb575b600080fd5b34801561026b57600080fd5b5061027f61027a366004612f33565b6108eb565b60405161028c919061356d565b60405180910390f35b3480156102a157600080fd5b506102b56102b0366004612edf565b6108fc565b60405161028c9190613526565b3480156102ce57600080fd5b506102d7610926565b60405161028c919061365a565b3480156102f057600080fd5b506102f96109b8565b60405161028c919061355c565b34801561031257600080fd5b5061031c60145481565b60405161028c919061357b565b34801561033557600080fd5b50600a546102b5906001600160a01b031681565b34801561035557600080fd5b5060065461031c565b34801561036a57600080fd5b5061031c60185481565b34801561038057600080fd5b5061031c60115481565b61031c610398366004612e4b565b610a19565b3480156103a957600080fd5b506103bd6103b8366004612d37565b610bba565b005b3480156103cb57600080fd5b5061031c6103da366004612edf565b610c3e565b3480156103eb57600080fd5b506103bd6103fa366004612d37565b610c53565b34801561040b57600080fd5b506103bd61041a366004612edf565b610ce4565b34801561042b57600080fd5b506103bd61043a366004612f00565b610d18565b34801561044b57600080fd5b5061031c61045a366004612e0e565b610d39565b34801561046b57600080fd5b506103bd61047a366004612f00565b610d8b565b34801561048b57600080fd5b506103bd61049a366004612f54565b610dc1565b3480156104ab57600080fd5b506103bd6104ba366004612edf565b610e1e565b3480156104cb57600080fd5b506103bd6104da366004612d37565b610e52565b3480156104eb57600080fd5b506103bd6104fa366004612edf565b610ed6565b34801561050b57600080fd5b506103bd61051a366004612edf565b610f08565b34801561052b57600080fd5b5061027f61053a366004612edf565b610f3c565b34801561054b57600080fd5b5061031c61055a366004612edf565b610f47565b34801561056b57600080fd5b506102b561057a366004612edf565b610f95565b34801561058b57600080fd5b5061031c60175481565b3480156105a157600080fd5b5061031c6105b0366004612d37565b610fca565b3480156105c157600080fd5b5061031c6105d0366004612d37565b61100e565b3480156105e157600080fd5b506103bd6105f0366004612d37565b61110e565b34801561060157600080fd5b5061031c60125481565b34801561061757600080fd5b5060165461062b906001600160a01b031681565b60405161028c919061364c565b34801561064457600080fd5b5061027f610653366004612d37565b600d6020526000908152604090205460ff1681565b61031c610676366004612d79565b61116b565b34801561068757600080fd5b506103bd610696366004612edf565b611239565b3480156106a757600080fd5b5061027f6106b6366004612d37565b60196020526000908152604090205460ff1681565b3480156106d757600080fd5b5061027f6106e6366004612f00565b61126d565b3480156106f757600080fd5b506103bd610706366004612d37565b611298565b34801561071757600080fd5b506102d7611405565b34801561072c57600080fd5b50600b546102b5906001600160a01b031681565b34801561074c57600080fd5b5061031c600081565b34801561076157600080fd5b5061031c60135481565b34801561077757600080fd5b5061031c610786366004612edf565b611414565b34801561079757600080fd5b506009546102b5906001600160a01b031681565b3480156107b757600080fd5b506103bd6107c6366004612d37565b6114d3565b3480156107d757600080fd5b506102d76107e6366004612edf565b61157f565b3480156107f757600080fd5b506103bd610806366004612d37565b6115e5565b34801561081757600080fd5b506103bd610826366004612f00565b611674565b34801561083757600080fd5b50600f546102b5906001600160a01b031681565b34801561085757600080fd5b506103bd610866366004612d37565b611690565b34801561087757600080fd5b506103bd610886366004612d37565b611714565b34801561089757600080fd5b50600c546102b5906001600160a01b031681565b3480156108b757600080fd5b506103bd6108c6366004612edf565b611798565b3480156108d757600080fd5b506103bd6108e6366004612edf565b6117cc565b60006108f682611800565b92915050565b600e818154811061090c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600080546109359061390b565b80601f01602080910402602001604051908101604052809291908181526020018280546109619061390b565b80156109ae5780601f10610983576101008083540402835291602001916109ae565b820191906000526020600020905b81548152906001019060200180831161099157829003601f168201915b5050505050905090565b6060600e8054806020026020016040519081016040528092919081815260200182805480156109ae57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f2575050505050905090565b60006002601a541415610a475760405162461bcd60e51b8152600401610a3e9061375b565b60405180910390fd5b6002601a556016546040516331a9108f60e11b81526000916001600160a01b031690636352211e90610a7d908a9060040161357b565b60206040518083038186803b158015610a9557600080fd5b505afa158015610aa9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acd9190612d58565b90506001600160a01b0381163314610afb57335b60405163060296c760e31b8152600401610a3e9190613526565b610b47610b0988888861180b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b925061186a915050565b610b5988610b548a61100e565b6118eb565b6000610b6482611a91565b90507f2acd987f463cc0a2358ed0e6aafd383842212a5d7b82c9fb5e0999a44733c490818989898d601754604051610ba1969594939291906137ea565b60405180910390a16001601a5598975050505050505050565b6000610bc581611ab7565b6001600160a01b038216610bec5760405163d92e233d60e01b815260040160405180910390fd5b600b546001600160a01b0383811691161415610c1b5760405163c23f6ccb60e01b815260040160405180910390fd5b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526008602052604090206001015490565b6000610c5e81611ab7565b6001600160a01b038216610c855760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1615610cbf5760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000908152601960205260409020805460ff19166001179055565b6000610cef81611ab7565b816011541415610d125760405163c23f6ccb60e01b815260040160405180910390fd5b50601155565b610d2182610c3e565b610d2a81611ab7565b610d348383611ac1565b505050565b6000610d4483610fca565b8210610d625760405162461bcd60e51b8152600401610a3e906136ab565b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b0381163314610db35760405162461bcd60e51b8152600401610a3e9061376b565b610dbd8282611b47565b5050565b6000610dcc81611ab7565b6016546001600160a01b0383811691161415610dfb5760405163c23f6ccb60e01b815260040160405180910390fd5b50601680546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e2981611ab7565b816012541415610e4c5760405163c23f6ccb60e01b815260040160405180910390fd5b50601255565b6000610e5d81611ab7565b6001600160a01b038216610e845760405163d92e233d60e01b815260040160405180910390fd5b6009546001600160a01b0383811691161415610eb35760405163c23f6ccb60e01b815260040160405180910390fd5b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b610ee03382611bae565b610efc5760405162461bcd60e51b8152600401610a3e906136eb565b610f0581611bd1565b50565b6000610f1381611ab7565b816018541415610f365760405163c23f6ccb60e01b815260040160405180910390fd5b50601855565b60006108f682611c6b565b6000610f5260065490565b8210610f705760405162461bcd60e51b8152600401610a3e9061374b565b60068281548110610f8357610f83613a02565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108f65760405162461bcd60e51b8152600401610a3e9061371b565b60006001600160a01b038216610ff25760405162461bcd60e51b8152600401610a3e906136db565b506001600160a01b031660009081526003602052604090205490565b600060175460001480156110225750601854155b1561102f57506000919050565b600c546001600160a01b03838116911614801561106457506001600160a01b0382166000908152600d602052604090205460ff165b801561107257506000601854115b1561107f57505060185490565b600b546001600160a01b0383811691161480156110b457506001600160a01b0382166000908152600d602052604090205460ff165b156110c157505060175490565b6001600160a01b0382166000908152600d602052604090205460ff16156110ee576108f682601754611c88565b81604051630ac29ab760e31b8152600401610a3e9190613526565b919050565b600061111981611ab7565b600c546001600160a01b03838116911614156111485760405163c23f6ccb60e01b815260040160405180910390fd5b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03861633146111835733610ae1565b6111cf611191878787611d27565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061186a915050565b6111dc87610b548961100e565b60006111e787611a91565b90507fba3afdf6e7965ed8d31aeefc9ffbaf04262d250621df85cef0ef13a8a4487cba818888888c6017546040516112249695949392919061377b565b60405180910390a190505b9695505050505050565b600061124481611ab7565b8160145414156112675760405163c23f6ccb60e01b815260040160405180910390fd5b50601455565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006112a381611ab7565b6001600160a01b0382166000908152600d602052604090205460ff166112de57816040516318317bd560e01b8152600401610a3e9190613526565b6001600160a01b0382166000908152600d60205260408120805460ff191690555b600e54811015610d3457826001600160a01b0316600e828154811061132657611326613a02565b6000918252602090912001546001600160a01b031614156113f357600e80546113519060019061388a565b8154811061136157611361613a02565b600091825260209091200154600e80546001600160a01b03909216918390811061138d5761138d613a02565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e8054806113cc576113cc6139ec565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b806113fd81613965565b9150506112ff565b6060600180546109359061390b565b6016546000906001600160a01b031661144057604051630d7fe67b60e41b815260040160405180910390fd5b600061144b83610f95565b60165460405163294cdf0d60e01b81529192506001600160a01b03169063294cdf0d9061147c908490600401613526565b60206040518083038186803b15801561149457600080fd5b505afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc9190612f75565b9392505050565b60006114de81611ab7565b6001600160a01b0382166000908152600d602052604090205460ff16156115185760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600e805491820181559091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319169091179055565b606061158a82611d63565b6000611594611d88565b905060008151116115b457604051806020016040528060008152506114cc565b806115be84611d97565b6040516020016115cf92919061346d565b6040516020818303038152906040529392505050565b60006115f081611ab7565b6001600160a01b0382166116175760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1661165257816040516324b1f80560e21b8152600401610a3e9190613526565b506001600160a01b03166000908152601960205260409020805460ff19169055565b61167d82610c3e565b61168681611ab7565b610d348383611b47565b600061169b81611ab7565b6001600160a01b0382166116c25760405163d92e233d60e01b815260040160405180910390fd5b600a546001600160a01b03838116911614156116f15760405163c23f6ccb60e01b815260040160405180910390fd5b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061171f81611ab7565b6001600160a01b0382166117465760405163d92e233d60e01b815260040160405180910390fd5b600f546001600160a01b03838116911614156117755760405163c23f6ccb60e01b815260040160405180910390fd5b50600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006117a381611ab7565b8160175414156117c65760405163c23f6ccb60e01b815260040160405180910390fd5b50601755565b60006117d781611ab7565b8160135414156117fa5760405163c23f6ccb60e01b815260040160405180910390fd5b50601355565b60006108f682611e94565b60006118627f34ec28456d08f4e49693917808b7282a69eadae2824d33b92474bc8bdfdb7be68585856040516020016118479493929190613609565b60405160208183030381529060405280519060200120611eb9565b949350505050565b60006118768484611ecc565b9050816001600160a01b0316816001600160a01b0316146118aa57604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b03811660009081526019602052604090205460ff166118e55780604051634a0bfec160e01b8152600401610a3e9190613526565b50505050565b806118f4575050565b6001600160a01b0382166000908152600d602052604090205460ff1661192f5781604051630ac29ab760e31b8152600401610a3e9190613526565b6001600160a01b038216611a755780341015611960578060405163091a6d0f60e01b8152600401610a3e919061357b565b600f546040516000916001600160a01b031690839061197e906134cc565b60006040518083038185875af1925050503d80600081146119bb576040519150601f19603f3d011682016040523d82523d6000602084013e6119c0565b606091505b50509050806119e2576040516312171d8360e31b815260040160405180910390fd5b81341115610d345760006119f63484611ef0565b9050336001600160a01b031681604051611a0f906134cc565b60006040518083038185875af1925050503d8060008114611a4c576040519150601f19603f3d011682016040523d82523d6000602084013e611a51565b606091505b505080925050816118e557604051633c31275160e21b815260040160405180910390fd5b600f54610dbd906001600160a01b038481169133911684611efc565b600080611a9d60155490565b9050611aad601580546001019055565b6108f68382611f54565b610f058133612030565b611acb828261126d565b610dbd5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611b51828261126d565b15610dbd5760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611bba83610f95565b6001600160a01b0385811691161491505092915050565b6000611bdc82610f95565b9050611bea81600084612094565b6001600160a01b0381166000908152600360205260408120805460019290611c1390849061388a565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6001600160a01b0382166000908152600d602052604081205460ff161580611cbd5750600b546001600160a01b038481169116145b15611cdd578260405163961c9a4f60e01b8152600401610a3e9190613526565b6001600160a01b038316611d0f57600a54600b54611d08916001600160a01b0390811691168461209f565b90506108f6565b600b54611d089084906001600160a01b03168461209f565b60006118627fe84d61ea5268441d87c5a96690bcc830d3d14781947a5181464911a7ff7dcc5d8585856040516020016118479493929190613589565b611d6c81611c6b565b610f055760405162461bcd60e51b8152600401610a3e9061371b565b6060601080546109359061390b565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf81613965565b9150611dde9050600a83613857565b9150611dbf565b6000816001600160401b03811115611dff57611dff613a18565b6040519080825280601f01601f191660200182016040528015611e29576020820181803683370190505b5090505b841561186257611e3e60018361388a565b9150611e4b600a86613980565b611e5690603061383f565b60f81b818381518110611e6b57611e6b613a02565b60200101906001600160f81b031916908160001a905350611e8d600a86613857565b9450611e2d565b60006001600160e01b03198216637965db0b60e01b14806108f657506108f68261215d565b60006108f6611ec6612182565b83612275565b6000806000611edb85856122a8565b91509150611ee8816122ee565b509392505050565b60006114cc828461388a565b6118e5846323b872dd60e01b858585604051602401611f1d93929190613534565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526123d3565b6001600160a01b038216611f7a5760405162461bcd60e51b8152600401610a3e9061369b565b611f8381611c6b565b15611fa05760405162461bcd60e51b8152600401610a3e9061370b565b611fac60008383612094565b6001600160a01b0382166000908152600360205260408120805460019290611fd590849061383f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b61203a828261126d565b610dbd57612052816001600160a01b03166014612462565b61205d836020612462565b60405160200161206e9291906134d4565b60408051601f198184030181529082905262461bcd60e51b8252610a3e9160040161365a565b610d348383836125cd565b60006060806120ae8686612685565b6009546040516307c0329d60e21b81529192506001600160a01b031690631f00ca74906120e190879085906004016137ca565b60006040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121359190810190612e84565b91508160008151811061214a5761214a613a02565b6020026020010151925050509392505050565b60006001600160e01b0319821663780e9d6360e01b14806108f657506108f682612817565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156121db57507f000000000000000000000000000000000000000000000000000000000000000046145b1561220557507f000000000000000000000000000000000000000000000000000000000000000090565b6122707f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612867565b905090565b6000828260405160200161228a92919061349b565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156122df5760208301516040840151606085015160001a6122d3878285856128a1565b945094505050506122e7565b506000905060025b9250929050565b6000816004811115612302576123026139c0565b141561230b5750565b600181600481111561231f5761231f6139c0565b141561233d5760405162461bcd60e51b8152600401610a3e9061366b565b6002816004811115612351576123516139c0565b141561236f5760405162461bcd60e51b8152600401610a3e9061368b565b6003816004811115612383576123836139c0565b14156123a15760405162461bcd60e51b8152600401610a3e906136bb565b60048160048111156123b5576123b56139c0565b1415610f055760405162461bcd60e51b8152600401610a3e906136fb565b6000612428826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129779092919063ffffffff16565b805190915015610d3457808060200190518101906124469190612ebe565b610d345760405162461bcd60e51b8152600401610a3e9061373b565b6060600061247183600261386b565b61247c90600261383f565b6001600160401b0381111561249357612493613a18565b6040519080825280601f01601f1916602001820160405280156124bd576020820181803683370190505b509050600360fc1b816000815181106124d8576124d8613a02565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061250757612507613a02565b60200101906001600160f81b031916908160001a905350600061252b84600261386b565b61253690600161383f565b90505b60018111156125ae576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256a5761256a613a02565b1a60f81b82828151811061258057612580613a02565b60200101906001600160f81b031916908160001a90535060049490941c936125a7816138f4565b9050612539565b5083156114cc5760405162461bcd60e51b8152600401610a3e9061367b565b6001600160a01b0383166126285761262381600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b61264b565b816001600160a01b0316836001600160a01b03161461264b5761264b8382612986565b6001600160a01b03821661266257610d3481612a23565b826001600160a01b0316826001600160a01b031614610d3457610d348282612ad2565b600a546060906001600160a01b03848116911614806126b15750600a546001600160a01b038381169116145b1561277b5760408051600280825260608201835260009260208301908036833701905050600a549091506001600160a01b038581169116146126f35783612700565b600a546001600160a01b03165b8160008151811061271357612713613a02565b6001600160a01b039283166020918202929092010152600a5484821691161461273c5782612749565b600a546001600160a01b03165b8160018151811061275c5761275c613a02565b6001600160a01b039092166020928302919091019091015290506108f6565b604080516003808252608082019092526000916020820160608036833701905050905083816000815181106127b2576127b2613a02565b6001600160a01b039283166020918202929092010152600a548251911690829060019081106127e3576127e3613a02565b60200260200101906001600160a01b031690816001600160a01b031681525050828160028151811061275c5761275c613a02565b60006001600160e01b031982166313f2a32f60e01b148061284857506001600160e01b03198216635b5e139f60e01b145b806108f657506301ffc9a760e01b6001600160e01b03198316146108f6565b600083838346306040516020016128829594939291906135c7565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156128ce575060009050600361296e565b8460ff16601b141580156128e657508460ff16601c14155b156128f7575060009050600461296e565b60006001878787876040516000815260200160405260405161291c9493929190613624565b6020604051602081039080840390855afa15801561293e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129675760006001925092505061296e565b9150600090505b94509492505050565b60606118628484600085612b16565b6000600161299384610fca565b61299d919061388a565b6000838152600560205260409020549091508082146129f0576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b600654600090612a359060019061388a565b60008381526007602052604081205460068054939450909284908110612a5d57612a5d613a02565b906000526020600020015490508060068381548110612a7e57612a7e613a02565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480612ab657612ab66139ec565b6001900381819060005260206000200160009055905550505050565b6000612add83610fca565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b606082471015612b385760405162461bcd60e51b8152600401610a3e906136cb565b6001600160a01b0385163b612b5f5760405162461bcd60e51b8152600401610a3e9061372b565b600080866001600160a01b03168587604051612b7b9190613461565b60006040518083038185875af1925050503d8060008114612bb8576040519150601f19603f3d011682016040523d82523d6000602084013e612bbd565b606091505b5091509150612bcd828286612bd8565b979650505050505050565b60608315612be75750816114cc565b825115612bf75782518084602001fd5b8160405162461bcd60e51b8152600401610a3e919061365a565b6000612c24612c1f8461381c565b613805565b90508083825260208201905082856020860282011115612c4657612c46600080fd5b60005b85811015612c725781612c5c8882612d2c565b8452506020928301929190910190600101612c49565b5050509392505050565b80356108f681613a38565b80516108f681613a38565b600082601f830112612ca657612ca6600080fd5b8151611862848260208601612c11565b80516108f681613a4c565b80356108f681613a54565b80356108f681613a5a565b60008083601f840112612cec57612cec600080fd5b5081356001600160401b03811115612d0657612d06600080fd5b6020830191508360018202830111156122e7576122e7600080fd5b80356108f681613a6a565b80516108f681613a54565b600060208284031215612d4c57612d4c600080fd5b60006118628484612c7c565b600060208284031215612d6d57612d6d600080fd5b60006118628484612c87565b60008060008060008060a08789031215612d9557612d95600080fd5b6000612da18989612c7c565b9650506020612db289828a01612c7c565b9550506040612dc389828a01612c7c565b9450506060612dd489828a01612cc1565b93505060808701356001600160401b03811115612df357612df3600080fd5b612dff89828a01612cd7565b92509250509295509295509295565b60008060408385031215612e2457612e24600080fd5b6000612e308585612c7c565b9250506020612e4185828601612cc1565b9150509250929050565b60008060008060008060a08789031215612e6757612e67600080fd5b6000612e738989612c7c565b9650506020612db289828a01612cc1565b600060208284031215612e9957612e99600080fd5b81516001600160401b03811115612eb257612eb2600080fd5b61186284828501612c92565b600060208284031215612ed357612ed3600080fd5b60006118628484612cb6565b600060208284031215612ef457612ef4600080fd5b60006118628484612cc1565b60008060408385031215612f1657612f16600080fd5b6000612f228585612cc1565b9250506020612e4185828601612c7c565b600060208284031215612f4857612f48600080fd5b60006118628484612ccc565b600060208284031215612f6957612f69600080fd5b60006118628484612d21565b600060208284031215612f8a57612f8a600080fd5b60006118628484612d2c565b6000612fa28383612faa565b505060200190565b612fb3816138a1565b82525050565b6000612fc3825190565b80845260209384019383018060005b83811015612ff7578151612fe68882612f96565b975060208301925050600101612fd2565b509495945050505050565b801515612fb3565b80612fb3565b600061301a825190565b6130288185602086016138c8565b9290920192915050565b612fb3816138bd565b6000613045825190565b80845260208401935061305c8185602086016138c8565b61306581613a2e565b9093019392505050565b601881526000602082017745434453413a20696e76616c6964207369676e617475726560401b815291505b5060200190565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e749101908152600061309a565b601f81526000602082017f45434453413a20696e76616c6964207369676e6174757265206c656e677468008152915061309a565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061309a565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b6020820152915061317c565b602681526000602082017f416464726573733a20696e73756666696369656e742062616c616e636520666f8152651c8818d85b1b60d21b6020820152915061317c565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b6020820152915061317c565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061309a565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b6020820152915061317c565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061309a565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061309a565b601d81526000602082017f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000008152915061309a565b602a81526000602082017f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b6020820152915061317c565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b6020820152915061317c565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c008152915061309a565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b6020820152915061317c565b60ff8116612fb3565b60006114cc8284613010565b60006134798285613010565b91506134858284613010565b64173539b7b760d91b8152915060058201611862565b61190160f01b815260020160006134b2828561300a565b6020820191506134c2828461300a565b5060200192915050565b6000816108f6565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006135008285613010565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110191506118628284613010565b602081016108f68284612faa565b606081016135428286612faa565b61354f6020830185612faa565b611862604083018461300a565b602080825281016114cc8184612fb9565b602081016108f68284613002565b602081016108f6828461300a565b60808101613597828761300a565b6135a46020830186612faa565b6135b16040830185612faa565b6135be606083018461300a565b95945050505050565b60a081016135d5828861300a565b6135e2602083018761300a565b6135ef604083018661300a565b6135fc606083018561300a565b61122f6080830184612faa565b60808101613617828761300a565b6135a4602083018661300a565b60808101613632828761300a565b61363f6020830186613458565b6135b1604083018561300a565b602081016108f68284613032565b602080825281016114cc818461303b565b602080825281016108f68161306f565b602080825281016108f6816130a1565b602080825281016108f6816130d3565b602080825281016108f681613107565b602080825281016108f68161313b565b602080825281016108f681613183565b602080825281016108f6816131c2565b602080825281016108f681613205565b602080825281016108f681613248565b602080825281016108f68161327c565b602080825281016108f6816132bb565b602080825281016108f6816132eb565b602080825281016108f681613317565b602080825281016108f68161334b565b602080825281016108f681613392565b602080825281016108f6816133d8565b602080825281016108f68161340c565b60c08101613789828961300a565b6137966020830188612faa565b6137a36040830187612faa565b6137b0606083018661300a565b6137bd6080830185612faa565b612bcd60a083018461300a565b604081016137d8828561300a565b81810360208301526118628184612fb9565b60c081016137f8828961300a565b613796602083018861300a565b600061381060405190565b90506111098282613938565b60006001600160401b0382111561383557613835613a18565b5060209081020190565b6000821982111561385257613852613994565b500190565b600082613866576138666139aa565b500490565b600081600019048311821515161561388557613885613994565b500290565b60008282101561389c5761389c613994565b500390565b60006001600160a01b0382166108f6565b60006108f6826138a1565b60006108f6826138b2565b60005b838110156138e35781810151838201526020016138cb565b838111156118e55750506000910152565b60008161390357613903613994565b506000190190565b60028104600182168061391f57607f821691505b60208210811415613932576139326139d6565b50919050565b61394182613a2e565b81018181106001600160401b038211171561395e5761395e613a18565b6040525050565b600060001982141561397957613979613994565b5060010190565b60008261398f5761398f6139aa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b613a41816138a1565b8114610f0557600080fd5b801515613a41565b80613a41565b6001600160e01b03198116613a41565b613a41816138b256fea2646970667358221220d10d652bb5f49377047195872f4159a146a1be86a941ac6fb28339769132b85264736f6c63430008070033", - "deployedBytecode": "0x60806040526004361061025a5760003560e01c806301ffc9a71461025f5780630513c3e91461029557806306fdde03146102c257806310200519146102e457806313150b481461030657806317fcb39b1461032957806318160ddd146103495780631830e8811461035e5780631f37c1241461037457806320d558aa1461038a57806323af4e171461039d578063248a9ca3146103bf57806326defa73146103df578063289c686b146103ff5780632f2ff15d1461041f5780632f745c591461043f57806336568abe1461045f5780633ad3033e1461047f5780633c72ae701461049f57806341273657146104bf57806342966c68146104df5780634962a158146104ff5780634f558e791461051f5780634f6ccce71461053f5780636352211e1461055f5780636817c76c1461057f57806370a0823114610595578063719d0f2b146105b557806376ad1997146105d5578063776d1a54146105f557806377bed5ed1461060b5780637a0d1646146106385780637ad09dff146106685780637db8cb681461067b57806391223d691461069b57806391d14854146106cb57806394a665e9146106eb57806395d89b411461070b578063992642e514610720578063a217fddf14610740578063b97d6b2314610755578063c1177d191461076b578063c31c9c071461078b578063c86aadb6146107ab578063c87b56dd146107cb578063d544e010146107eb578063d547741f1461080b578063d72b11bd1461082b578063da058ae31461084b578063dda4fa8f1461086b578063ebda43961461088b578063f4a0a528146108ab578063fd48ac83146108cb575b600080fd5b34801561026b57600080fd5b5061027f61027a366004612f33565b6108eb565b60405161028c919061356d565b60405180910390f35b3480156102a157600080fd5b506102b56102b0366004612edf565b6108fc565b60405161028c9190613526565b3480156102ce57600080fd5b506102d7610926565b60405161028c919061365a565b3480156102f057600080fd5b506102f96109b8565b60405161028c919061355c565b34801561031257600080fd5b5061031c60145481565b60405161028c919061357b565b34801561033557600080fd5b50600a546102b5906001600160a01b031681565b34801561035557600080fd5b5060065461031c565b34801561036a57600080fd5b5061031c60185481565b34801561038057600080fd5b5061031c60115481565b61031c610398366004612e4b565b610a19565b3480156103a957600080fd5b506103bd6103b8366004612d37565b610bba565b005b3480156103cb57600080fd5b5061031c6103da366004612edf565b610c3e565b3480156103eb57600080fd5b506103bd6103fa366004612d37565b610c53565b34801561040b57600080fd5b506103bd61041a366004612edf565b610ce4565b34801561042b57600080fd5b506103bd61043a366004612f00565b610d18565b34801561044b57600080fd5b5061031c61045a366004612e0e565b610d39565b34801561046b57600080fd5b506103bd61047a366004612f00565b610d8b565b34801561048b57600080fd5b506103bd61049a366004612f54565b610dc1565b3480156104ab57600080fd5b506103bd6104ba366004612edf565b610e1e565b3480156104cb57600080fd5b506103bd6104da366004612d37565b610e52565b3480156104eb57600080fd5b506103bd6104fa366004612edf565b610ed6565b34801561050b57600080fd5b506103bd61051a366004612edf565b610f08565b34801561052b57600080fd5b5061027f61053a366004612edf565b610f3c565b34801561054b57600080fd5b5061031c61055a366004612edf565b610f47565b34801561056b57600080fd5b506102b561057a366004612edf565b610f95565b34801561058b57600080fd5b5061031c60175481565b3480156105a157600080fd5b5061031c6105b0366004612d37565b610fca565b3480156105c157600080fd5b5061031c6105d0366004612d37565b61100e565b3480156105e157600080fd5b506103bd6105f0366004612d37565b61110e565b34801561060157600080fd5b5061031c60125481565b34801561061757600080fd5b5060165461062b906001600160a01b031681565b60405161028c919061364c565b34801561064457600080fd5b5061027f610653366004612d37565b600d6020526000908152604090205460ff1681565b61031c610676366004612d79565b61116b565b34801561068757600080fd5b506103bd610696366004612edf565b611239565b3480156106a757600080fd5b5061027f6106b6366004612d37565b60196020526000908152604090205460ff1681565b3480156106d757600080fd5b5061027f6106e6366004612f00565b61126d565b3480156106f757600080fd5b506103bd610706366004612d37565b611298565b34801561071757600080fd5b506102d7611405565b34801561072c57600080fd5b50600b546102b5906001600160a01b031681565b34801561074c57600080fd5b5061031c600081565b34801561076157600080fd5b5061031c60135481565b34801561077757600080fd5b5061031c610786366004612edf565b611414565b34801561079757600080fd5b506009546102b5906001600160a01b031681565b3480156107b757600080fd5b506103bd6107c6366004612d37565b6114d3565b3480156107d757600080fd5b506102d76107e6366004612edf565b61157f565b3480156107f757600080fd5b506103bd610806366004612d37565b6115e5565b34801561081757600080fd5b506103bd610826366004612f00565b611674565b34801561083757600080fd5b50600f546102b5906001600160a01b031681565b34801561085757600080fd5b506103bd610866366004612d37565b611690565b34801561087757600080fd5b506103bd610886366004612d37565b611714565b34801561089757600080fd5b50600c546102b5906001600160a01b031681565b3480156108b757600080fd5b506103bd6108c6366004612edf565b611798565b3480156108d757600080fd5b506103bd6108e6366004612edf565b6117cc565b60006108f682611800565b92915050565b600e818154811061090c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600080546109359061390b565b80601f01602080910402602001604051908101604052809291908181526020018280546109619061390b565b80156109ae5780601f10610983576101008083540402835291602001916109ae565b820191906000526020600020905b81548152906001019060200180831161099157829003601f168201915b5050505050905090565b6060600e8054806020026020016040519081016040528092919081815260200182805480156109ae57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f2575050505050905090565b60006002601a541415610a475760405162461bcd60e51b8152600401610a3e9061375b565b60405180910390fd5b6002601a556016546040516331a9108f60e11b81526000916001600160a01b031690636352211e90610a7d908a9060040161357b565b60206040518083038186803b158015610a9557600080fd5b505afa158015610aa9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acd9190612d58565b90506001600160a01b0381163314610afb57335b60405163060296c760e31b8152600401610a3e9190613526565b610b47610b0988888861180b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b925061186a915050565b610b5988610b548a61100e565b6118eb565b6000610b6482611a91565b90507f2acd987f463cc0a2358ed0e6aafd383842212a5d7b82c9fb5e0999a44733c490818989898d601754604051610ba1969594939291906137ea565b60405180910390a16001601a5598975050505050505050565b6000610bc581611ab7565b6001600160a01b038216610bec5760405163d92e233d60e01b815260040160405180910390fd5b600b546001600160a01b0383811691161415610c1b5760405163c23f6ccb60e01b815260040160405180910390fd5b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526008602052604090206001015490565b6000610c5e81611ab7565b6001600160a01b038216610c855760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1615610cbf5760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000908152601960205260409020805460ff19166001179055565b6000610cef81611ab7565b816011541415610d125760405163c23f6ccb60e01b815260040160405180910390fd5b50601155565b610d2182610c3e565b610d2a81611ab7565b610d348383611ac1565b505050565b6000610d4483610fca565b8210610d625760405162461bcd60e51b8152600401610a3e906136ab565b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b0381163314610db35760405162461bcd60e51b8152600401610a3e9061376b565b610dbd8282611b47565b5050565b6000610dcc81611ab7565b6016546001600160a01b0383811691161415610dfb5760405163c23f6ccb60e01b815260040160405180910390fd5b50601680546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e2981611ab7565b816012541415610e4c5760405163c23f6ccb60e01b815260040160405180910390fd5b50601255565b6000610e5d81611ab7565b6001600160a01b038216610e845760405163d92e233d60e01b815260040160405180910390fd5b6009546001600160a01b0383811691161415610eb35760405163c23f6ccb60e01b815260040160405180910390fd5b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b610ee03382611bae565b610efc5760405162461bcd60e51b8152600401610a3e906136eb565b610f0581611bd1565b50565b6000610f1381611ab7565b816018541415610f365760405163c23f6ccb60e01b815260040160405180910390fd5b50601855565b60006108f682611c6b565b6000610f5260065490565b8210610f705760405162461bcd60e51b8152600401610a3e9061374b565b60068281548110610f8357610f83613a02565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108f65760405162461bcd60e51b8152600401610a3e9061371b565b60006001600160a01b038216610ff25760405162461bcd60e51b8152600401610a3e906136db565b506001600160a01b031660009081526003602052604090205490565b600060175460001480156110225750601854155b1561102f57506000919050565b600c546001600160a01b03838116911614801561106457506001600160a01b0382166000908152600d602052604090205460ff165b801561107257506000601854115b1561107f57505060185490565b600b546001600160a01b0383811691161480156110b457506001600160a01b0382166000908152600d602052604090205460ff165b156110c157505060175490565b6001600160a01b0382166000908152600d602052604090205460ff16156110ee576108f682601754611c88565b81604051630ac29ab760e31b8152600401610a3e9190613526565b919050565b600061111981611ab7565b600c546001600160a01b03838116911614156111485760405163c23f6ccb60e01b815260040160405180910390fd5b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03861633146111835733610ae1565b6111cf611191878787611d27565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061186a915050565b6111dc87610b548961100e565b60006111e787611a91565b90507fba3afdf6e7965ed8d31aeefc9ffbaf04262d250621df85cef0ef13a8a4487cba818888888c6017546040516112249695949392919061377b565b60405180910390a190505b9695505050505050565b600061124481611ab7565b8160145414156112675760405163c23f6ccb60e01b815260040160405180910390fd5b50601455565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006112a381611ab7565b6001600160a01b0382166000908152600d602052604090205460ff166112de57816040516318317bd560e01b8152600401610a3e9190613526565b6001600160a01b0382166000908152600d60205260408120805460ff191690555b600e54811015610d3457826001600160a01b0316600e828154811061132657611326613a02565b6000918252602090912001546001600160a01b031614156113f357600e80546113519060019061388a565b8154811061136157611361613a02565b600091825260209091200154600e80546001600160a01b03909216918390811061138d5761138d613a02565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e8054806113cc576113cc6139ec565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b806113fd81613965565b9150506112ff565b6060600180546109359061390b565b6016546000906001600160a01b031661144057604051630d7fe67b60e41b815260040160405180910390fd5b600061144b83610f95565b60165460405163294cdf0d60e01b81529192506001600160a01b03169063294cdf0d9061147c908490600401613526565b60206040518083038186803b15801561149457600080fd5b505afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc9190612f75565b9392505050565b60006114de81611ab7565b6001600160a01b0382166000908152600d602052604090205460ff16156115185760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600e805491820181559091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319169091179055565b606061158a82611d63565b6000611594611d88565b905060008151116115b457604051806020016040528060008152506114cc565b806115be84611d97565b6040516020016115cf92919061346d565b6040516020818303038152906040529392505050565b60006115f081611ab7565b6001600160a01b0382166116175760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1661165257816040516324b1f80560e21b8152600401610a3e9190613526565b506001600160a01b03166000908152601960205260409020805460ff19169055565b61167d82610c3e565b61168681611ab7565b610d348383611b47565b600061169b81611ab7565b6001600160a01b0382166116c25760405163d92e233d60e01b815260040160405180910390fd5b600a546001600160a01b03838116911614156116f15760405163c23f6ccb60e01b815260040160405180910390fd5b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061171f81611ab7565b6001600160a01b0382166117465760405163d92e233d60e01b815260040160405180910390fd5b600f546001600160a01b03838116911614156117755760405163c23f6ccb60e01b815260040160405180910390fd5b50600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006117a381611ab7565b8160175414156117c65760405163c23f6ccb60e01b815260040160405180910390fd5b50601755565b60006117d781611ab7565b8160135414156117fa5760405163c23f6ccb60e01b815260040160405180910390fd5b50601355565b60006108f682611e94565b60006118627f34ec28456d08f4e49693917808b7282a69eadae2824d33b92474bc8bdfdb7be68585856040516020016118479493929190613609565b60405160208183030381529060405280519060200120611eb9565b949350505050565b60006118768484611ecc565b9050816001600160a01b0316816001600160a01b0316146118aa57604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b03811660009081526019602052604090205460ff166118e55780604051634a0bfec160e01b8152600401610a3e9190613526565b50505050565b806118f4575050565b6001600160a01b0382166000908152600d602052604090205460ff1661192f5781604051630ac29ab760e31b8152600401610a3e9190613526565b6001600160a01b038216611a755780341015611960578060405163091a6d0f60e01b8152600401610a3e919061357b565b600f546040516000916001600160a01b031690839061197e906134cc565b60006040518083038185875af1925050503d80600081146119bb576040519150601f19603f3d011682016040523d82523d6000602084013e6119c0565b606091505b50509050806119e2576040516312171d8360e31b815260040160405180910390fd5b81341115610d345760006119f63484611ef0565b9050336001600160a01b031681604051611a0f906134cc565b60006040518083038185875af1925050503d8060008114611a4c576040519150601f19603f3d011682016040523d82523d6000602084013e611a51565b606091505b505080925050816118e557604051633c31275160e21b815260040160405180910390fd5b600f54610dbd906001600160a01b038481169133911684611efc565b600080611a9d60155490565b9050611aad601580546001019055565b6108f68382611f54565b610f058133612030565b611acb828261126d565b610dbd5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611b51828261126d565b15610dbd5760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611bba83610f95565b6001600160a01b0385811691161491505092915050565b6000611bdc82610f95565b9050611bea81600084612094565b6001600160a01b0381166000908152600360205260408120805460019290611c1390849061388a565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6001600160a01b0382166000908152600d602052604081205460ff161580611cbd5750600b546001600160a01b038481169116145b15611cdd578260405163961c9a4f60e01b8152600401610a3e9190613526565b6001600160a01b038316611d0f57600a54600b54611d08916001600160a01b0390811691168461209f565b90506108f6565b600b54611d089084906001600160a01b03168461209f565b60006118627fe84d61ea5268441d87c5a96690bcc830d3d14781947a5181464911a7ff7dcc5d8585856040516020016118479493929190613589565b611d6c81611c6b565b610f055760405162461bcd60e51b8152600401610a3e9061371b565b6060601080546109359061390b565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf81613965565b9150611dde9050600a83613857565b9150611dbf565b6000816001600160401b03811115611dff57611dff613a18565b6040519080825280601f01601f191660200182016040528015611e29576020820181803683370190505b5090505b841561186257611e3e60018361388a565b9150611e4b600a86613980565b611e5690603061383f565b60f81b818381518110611e6b57611e6b613a02565b60200101906001600160f81b031916908160001a905350611e8d600a86613857565b9450611e2d565b60006001600160e01b03198216637965db0b60e01b14806108f657506108f68261215d565b60006108f6611ec6612182565b83612275565b6000806000611edb85856122a8565b91509150611ee8816122ee565b509392505050565b60006114cc828461388a565b6118e5846323b872dd60e01b858585604051602401611f1d93929190613534565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526123d3565b6001600160a01b038216611f7a5760405162461bcd60e51b8152600401610a3e9061369b565b611f8381611c6b565b15611fa05760405162461bcd60e51b8152600401610a3e9061370b565b611fac60008383612094565b6001600160a01b0382166000908152600360205260408120805460019290611fd590849061383f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b61203a828261126d565b610dbd57612052816001600160a01b03166014612462565b61205d836020612462565b60405160200161206e9291906134d4565b60408051601f198184030181529082905262461bcd60e51b8252610a3e9160040161365a565b610d348383836125cd565b60006060806120ae8686612685565b6009546040516307c0329d60e21b81529192506001600160a01b031690631f00ca74906120e190879085906004016137ca565b60006040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121359190810190612e84565b91508160008151811061214a5761214a613a02565b6020026020010151925050509392505050565b60006001600160e01b0319821663780e9d6360e01b14806108f657506108f682612817565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156121db57507f000000000000000000000000000000000000000000000000000000000000000046145b1561220557507f000000000000000000000000000000000000000000000000000000000000000090565b6122707f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612867565b905090565b6000828260405160200161228a92919061349b565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156122df5760208301516040840151606085015160001a6122d3878285856128a1565b945094505050506122e7565b506000905060025b9250929050565b6000816004811115612302576123026139c0565b141561230b5750565b600181600481111561231f5761231f6139c0565b141561233d5760405162461bcd60e51b8152600401610a3e9061366b565b6002816004811115612351576123516139c0565b141561236f5760405162461bcd60e51b8152600401610a3e9061368b565b6003816004811115612383576123836139c0565b14156123a15760405162461bcd60e51b8152600401610a3e906136bb565b60048160048111156123b5576123b56139c0565b1415610f055760405162461bcd60e51b8152600401610a3e906136fb565b6000612428826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129779092919063ffffffff16565b805190915015610d3457808060200190518101906124469190612ebe565b610d345760405162461bcd60e51b8152600401610a3e9061373b565b6060600061247183600261386b565b61247c90600261383f565b6001600160401b0381111561249357612493613a18565b6040519080825280601f01601f1916602001820160405280156124bd576020820181803683370190505b509050600360fc1b816000815181106124d8576124d8613a02565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061250757612507613a02565b60200101906001600160f81b031916908160001a905350600061252b84600261386b565b61253690600161383f565b90505b60018111156125ae576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256a5761256a613a02565b1a60f81b82828151811061258057612580613a02565b60200101906001600160f81b031916908160001a90535060049490941c936125a7816138f4565b9050612539565b5083156114cc5760405162461bcd60e51b8152600401610a3e9061367b565b6001600160a01b0383166126285761262381600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b61264b565b816001600160a01b0316836001600160a01b03161461264b5761264b8382612986565b6001600160a01b03821661266257610d3481612a23565b826001600160a01b0316826001600160a01b031614610d3457610d348282612ad2565b600a546060906001600160a01b03848116911614806126b15750600a546001600160a01b038381169116145b1561277b5760408051600280825260608201835260009260208301908036833701905050600a549091506001600160a01b038581169116146126f35783612700565b600a546001600160a01b03165b8160008151811061271357612713613a02565b6001600160a01b039283166020918202929092010152600a5484821691161461273c5782612749565b600a546001600160a01b03165b8160018151811061275c5761275c613a02565b6001600160a01b039092166020928302919091019091015290506108f6565b604080516003808252608082019092526000916020820160608036833701905050905083816000815181106127b2576127b2613a02565b6001600160a01b039283166020918202929092010152600a548251911690829060019081106127e3576127e3613a02565b60200260200101906001600160a01b031690816001600160a01b031681525050828160028151811061275c5761275c613a02565b60006001600160e01b031982166313f2a32f60e01b148061284857506001600160e01b03198216635b5e139f60e01b145b806108f657506301ffc9a760e01b6001600160e01b03198316146108f6565b600083838346306040516020016128829594939291906135c7565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156128ce575060009050600361296e565b8460ff16601b141580156128e657508460ff16601c14155b156128f7575060009050600461296e565b60006001878787876040516000815260200160405260405161291c9493929190613624565b6020604051602081039080840390855afa15801561293e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129675760006001925092505061296e565b9150600090505b94509492505050565b60606118628484600085612b16565b6000600161299384610fca565b61299d919061388a565b6000838152600560205260409020549091508082146129f0576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b600654600090612a359060019061388a565b60008381526007602052604081205460068054939450909284908110612a5d57612a5d613a02565b906000526020600020015490508060068381548110612a7e57612a7e613a02565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480612ab657612ab66139ec565b6001900381819060005260206000200160009055905550505050565b6000612add83610fca565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b606082471015612b385760405162461bcd60e51b8152600401610a3e906136cb565b6001600160a01b0385163b612b5f5760405162461bcd60e51b8152600401610a3e9061372b565b600080866001600160a01b03168587604051612b7b9190613461565b60006040518083038185875af1925050503d8060008114612bb8576040519150601f19603f3d011682016040523d82523d6000602084013e612bbd565b606091505b5091509150612bcd828286612bd8565b979650505050505050565b60608315612be75750816114cc565b825115612bf75782518084602001fd5b8160405162461bcd60e51b8152600401610a3e919061365a565b6000612c24612c1f8461381c565b613805565b90508083825260208201905082856020860282011115612c4657612c46600080fd5b60005b85811015612c725781612c5c8882612d2c565b8452506020928301929190910190600101612c49565b5050509392505050565b80356108f681613a38565b80516108f681613a38565b600082601f830112612ca657612ca6600080fd5b8151611862848260208601612c11565b80516108f681613a4c565b80356108f681613a54565b80356108f681613a5a565b60008083601f840112612cec57612cec600080fd5b5081356001600160401b03811115612d0657612d06600080fd5b6020830191508360018202830111156122e7576122e7600080fd5b80356108f681613a6a565b80516108f681613a54565b600060208284031215612d4c57612d4c600080fd5b60006118628484612c7c565b600060208284031215612d6d57612d6d600080fd5b60006118628484612c87565b60008060008060008060a08789031215612d9557612d95600080fd5b6000612da18989612c7c565b9650506020612db289828a01612c7c565b9550506040612dc389828a01612c7c565b9450506060612dd489828a01612cc1565b93505060808701356001600160401b03811115612df357612df3600080fd5b612dff89828a01612cd7565b92509250509295509295509295565b60008060408385031215612e2457612e24600080fd5b6000612e308585612c7c565b9250506020612e4185828601612cc1565b9150509250929050565b60008060008060008060a08789031215612e6757612e67600080fd5b6000612e738989612c7c565b9650506020612db289828a01612cc1565b600060208284031215612e9957612e99600080fd5b81516001600160401b03811115612eb257612eb2600080fd5b61186284828501612c92565b600060208284031215612ed357612ed3600080fd5b60006118628484612cb6565b600060208284031215612ef457612ef4600080fd5b60006118628484612cc1565b60008060408385031215612f1657612f16600080fd5b6000612f228585612cc1565b9250506020612e4185828601612c7c565b600060208284031215612f4857612f48600080fd5b60006118628484612ccc565b600060208284031215612f6957612f69600080fd5b60006118628484612d21565b600060208284031215612f8a57612f8a600080fd5b60006118628484612d2c565b6000612fa28383612faa565b505060200190565b612fb3816138a1565b82525050565b6000612fc3825190565b80845260209384019383018060005b83811015612ff7578151612fe68882612f96565b975060208301925050600101612fd2565b509495945050505050565b801515612fb3565b80612fb3565b600061301a825190565b6130288185602086016138c8565b9290920192915050565b612fb3816138bd565b6000613045825190565b80845260208401935061305c8185602086016138c8565b61306581613a2e565b9093019392505050565b601881526000602082017745434453413a20696e76616c6964207369676e617475726560401b815291505b5060200190565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e749101908152600061309a565b601f81526000602082017f45434453413a20696e76616c6964207369676e6174757265206c656e677468008152915061309a565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061309a565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b6020820152915061317c565b602681526000602082017f416464726573733a20696e73756666696369656e742062616c616e636520666f8152651c8818d85b1b60d21b6020820152915061317c565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b6020820152915061317c565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061309a565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b6020820152915061317c565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061309a565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061309a565b601d81526000602082017f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000008152915061309a565b602a81526000602082017f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b6020820152915061317c565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b6020820152915061317c565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c008152915061309a565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b6020820152915061317c565b60ff8116612fb3565b60006114cc8284613010565b60006134798285613010565b91506134858284613010565b64173539b7b760d91b8152915060058201611862565b61190160f01b815260020160006134b2828561300a565b6020820191506134c2828461300a565b5060200192915050565b6000816108f6565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006135008285613010565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110191506118628284613010565b602081016108f68284612faa565b606081016135428286612faa565b61354f6020830185612faa565b611862604083018461300a565b602080825281016114cc8184612fb9565b602081016108f68284613002565b602081016108f6828461300a565b60808101613597828761300a565b6135a46020830186612faa565b6135b16040830185612faa565b6135be606083018461300a565b95945050505050565b60a081016135d5828861300a565b6135e2602083018761300a565b6135ef604083018661300a565b6135fc606083018561300a565b61122f6080830184612faa565b60808101613617828761300a565b6135a4602083018661300a565b60808101613632828761300a565b61363f6020830186613458565b6135b1604083018561300a565b602081016108f68284613032565b602080825281016114cc818461303b565b602080825281016108f68161306f565b602080825281016108f6816130a1565b602080825281016108f6816130d3565b602080825281016108f681613107565b602080825281016108f68161313b565b602080825281016108f681613183565b602080825281016108f6816131c2565b602080825281016108f681613205565b602080825281016108f681613248565b602080825281016108f68161327c565b602080825281016108f6816132bb565b602080825281016108f6816132eb565b602080825281016108f681613317565b602080825281016108f68161334b565b602080825281016108f681613392565b602080825281016108f6816133d8565b602080825281016108f68161340c565b60c08101613789828961300a565b6137966020830188612faa565b6137a36040830187612faa565b6137b0606083018661300a565b6137bd6080830185612faa565b612bcd60a083018461300a565b604081016137d8828561300a565b81810360208301526118628184612fb9565b60c081016137f8828961300a565b613796602083018861300a565b600061381060405190565b90506111098282613938565b60006001600160401b0382111561383557613835613a18565b5060209081020190565b6000821982111561385257613852613994565b500190565b600082613866576138666139aa565b500490565b600081600019048311821515161561388557613885613994565b500290565b60008282101561389c5761389c613994565b500390565b60006001600160a01b0382166108f6565b60006108f6826138a1565b60006108f6826138b2565b60005b838110156138e35781810151838201526020016138cb565b838111156118e55750506000910152565b60008161390357613903613994565b506000190190565b60028104600182168061391f57607f821691505b60208210811415613932576139326139d6565b50919050565b61394182613a2e565b81018181106001600160401b038211171561395e5761395e613a18565b6040525050565b600060001982141561397957613979613994565b5060010190565b60008261398f5761398f6139aa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b613a41816138a1565b8114610f0557600080fd5b801515613a41565b80613a41565b6001600160e01b03198116613a41565b613a41816138b256fea2646970667358221220d10d652bb5f49377047195872f4159a146a1be86a941ac6fb28339769132b85264736f6c63430008070033", - "devdoc": { - "author": "Masa Finance", - "details": "Soulbound 2FA, that inherits from the SBT contract.", - "kind": "dev", - "methods": { - "addAuthority(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_authority": "New authority to add" - } - }, - "balanceOf(address)": { - "details": "See {ISBT-balanceOf}." - }, - "burn(uint256)": { - "details": "Burns `tokenId`. See {SBT-_burn}. Requirements: - The caller must own `tokenId` or be an approved operator." - }, - "constructor": { - "details": "Creates a new soulbound 2FA, inheriting from the SBT contract.", - "params": { - "admin": "Administrator of the smart contract", - "baseTokenURI": "Base URI of the token", - "paymentParams": "Payment gateway params", - "soulboundIdentity": "Address of the SoulboundIdentity contract" - } - }, - "disablePaymentMethod(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_paymentMethod": "Token to remove" - } - }, - "enablePaymentMethod(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_paymentMethod": "New token to add" - } - }, - "exists(uint256)": { - "details": "Returns true if the token has been minted", - "params": { - "tokenId": "Token to check" - }, - "returns": { - "_0": "True if the token exists" - } - }, - "getEnabledPaymentMethods()": { - "details": "Returns the address of all available payment methods", - "returns": { - "_0": "Array of all enabled payment methods" - } - }, - "getIdentityId(uint256)": { - "params": { - "tokenId": "Id of the token" - }, - "returns": { - "_0": "Id of the identity" - } - }, - "getMintPrice(address)": { - "details": "Returns current pricing for minting", - "params": { - "paymentMethod": "Address of token that user want to pay" - }, - "returns": { - "_0": "Current price for minting in the given payment method" - } - }, - "getRoleAdmin(bytes32)": { - "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." - }, - "grantRole(bytes32,address)": { - "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event." - }, - "hasRole(bytes32,address)": { - "details": "Returns `true` if `account` has been granted `role`." - }, - "mint(address,address,address,uint256,bytes)": { - "details": "The caller must have the MINTER role", - "params": { - "authorityAddress": "Address of the authority that signed the message", - "paymentMethod": "Address of token that user want to pay", - "signature": "Signature of the message", - "signatureDate": "Date of the signature", - "to": "The address to mint the SBT to" - }, - "returns": { - "_0": "The SBT ID of the newly minted SBT" - } - }, - "mint(address,uint256,address,uint256,bytes)": { - "details": "The caller must have the MINTER role", - "params": { - "authorityAddress": "Address of the authority that signed the message", - "identityId": "TokenId of the identity to mint the NFT to", - "paymentMethod": "Address of token that user want to pay", - "signature": "Signature of the message", - "signatureDate": "Date of the signature" - }, - "returns": { - "_0": "The NFT ID of the newly minted SBT" - } - }, - "name()": { - "details": "See {ISBTMetadata-name}." - }, - "ownerOf(uint256)": { - "details": "See {ISBT-ownerOf}." - }, - "removeAuthority(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_authority": "Authority to remove" - } - }, - "renounceRole(bytes32,address)": { - "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event." - }, - "revokeRole(bytes32,address)": { - "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event." - }, - "setAddLinkPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_addLinkPrice": "New price for adding the link in SoulLinker in stable coin" - } - }, - "setAddLinkPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_addLinkPriceMASA": "New price for adding the link in SoulLinker in MASA" - } - }, - "setMasaToken(address)": { - "details": "The caller must have the admin role to call this function It can be set to address(0) to disable paying in MASA", - "params": { - "_masaToken": "New utility token to pay the fee in" - } - }, - "setMintPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_mintPrice": "New price of minting in stable coin" - } - }, - "setMintPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_mintPriceMASA": "New price of minting in MASA" - } - }, - "setQueryLinkPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_queryLinkPrice": "New price for reading data in SoulLinker in stable coin" - } - }, - "setQueryLinkPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_queryLinkPriceMASA": "New price for reading data in SoulLinker in MASA" - } - }, - "setReserveWallet(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_reserveWallet": "New reserve wallet" - } - }, - "setSoulboundIdentity(address)": { - "details": "The caller must be the admin to call this function", - "params": { - "_soulboundIdentity": "Address of the SoulboundIdentity contract" - } - }, - "setStableCoin(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_stableCoin": "New stable coin to pay the fee in" - } - }, - "setSwapRouter(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_swapRouter": "New swap router address" - } - }, - "setWrappedNativeToken(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_wrappedNativeToken": "New wrapped native token address" - } - }, - "supportsInterface(bytes4)": { - "details": "Interface identification is specified in ERC-165.", - "params": { - "interfaceId": "The interface identifier, as specified in ERC-165" - }, - "returns": { - "_0": "`true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise" - } - }, - "symbol()": { - "details": "See {ISBTMetadata-symbol}." - }, - "tokenByIndex(uint256)": { - "details": "See {ISBTEnumerable-tokenByIndex}." - }, - "tokenOfOwnerByIndex(address,uint256)": { - "details": "See {ISBTEnumerable-tokenOfOwnerByIndex}." - }, - "tokenURI(uint256)": { - "details": "Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the \"ERC721 Metadata JSON Schema\".", - "params": { - "tokenId": "SBT to get the URI of" - }, - "returns": { - "_0": "URI of the SBT" - } - }, - "totalSupply()": { - "details": "See {ISBTEnumerable-totalSupply}." - } - }, - "title": "Soulbound Two-factor authentication (2FA)", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "addAuthority(address)": { - "notice": "Adds a new authority to the list of authorities" - }, - "constructor": { - "notice": "Creates a new soulbound Two-factor authentication (2FA)" - }, - "disablePaymentMethod(address)": { - "notice": "Removes a token as a valid payment method" - }, - "enablePaymentMethod(address)": { - "notice": "Adds a new token as a valid payment method" - }, - "exists(uint256)": { - "notice": "Returns true if the token exists" - }, - "getEnabledPaymentMethods()": { - "notice": "Returns all available payment methods" - }, - "getIdentityId(uint256)": { - "notice": "Returns the identityId owned by the given token" - }, - "getMintPrice(address)": { - "notice": "Returns the price for minting" - }, - "mint(address,address,address,uint256,bytes)": { - "notice": "Mints a new SBT" - }, - "mint(address,uint256,address,uint256,bytes)": { - "notice": "Mints a new SBT" - }, - "removeAuthority(address)": { - "notice": "Removes an authority from the list of authorities" - }, - "setAddLinkPrice(uint256)": { - "notice": "Sets the price for adding the link in SoulLinker in stable coin" - }, - "setAddLinkPriceMASA(uint256)": { - "notice": "Sets the price for adding the link in SoulLinker in MASA" - }, - "setMasaToken(address)": { - "notice": "Sets the utility token to pay the fee in (MASA)" - }, - "setMintPrice(uint256)": { - "notice": "Sets the price of minting in stable coin" - }, - "setMintPriceMASA(uint256)": { - "notice": "Sets the price of minting in MASA" - }, - "setQueryLinkPrice(uint256)": { - "notice": "Sets the price for reading data in SoulLinker in stable coin" - }, - "setQueryLinkPriceMASA(uint256)": { - "notice": "Sets the price for reading data in SoulLinker in MASA" - }, - "setReserveWallet(address)": { - "notice": "Set the reserve wallet" - }, - "setSoulboundIdentity(address)": { - "notice": "Sets the SoulboundIdentity contract address linked to this SBT" - }, - "setStableCoin(address)": { - "notice": "Sets the stable coin to pay the fee in (USDC)" - }, - "setSwapRouter(address)": { - "notice": "Sets the swap router address" - }, - "setWrappedNativeToken(address)": { - "notice": "Sets the wrapped native token address" - }, - "supportsInterface(bytes4)": { - "notice": "Query if a contract implements an interface" - }, - "tokenURI(uint256)": { - "notice": "A distinct Uniform Resource Identifier (URI) for a given asset." - } - }, - "notice": "Soulbound token that represents a Two-factor authentication (2FA)", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 9702, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_name", - "offset": 0, - "slot": "0", - "type": "t_string_storage" - }, - { - "astId": 9704, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_symbol", - "offset": 0, - "slot": "1", - "type": "t_string_storage" - }, - { - "astId": 9708, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_owners", - "offset": 0, - "slot": "2", - "type": "t_mapping(t_uint256,t_address)" - }, - { - "astId": 9712, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_balances", - "offset": 0, - "slot": "3", - "type": "t_mapping(t_address,t_uint256)" - }, - { - "astId": 10171, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_ownedTokens", - "offset": 0, - "slot": "4", - "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))" - }, - { - "astId": 10175, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_ownedTokensIndex", - "offset": 0, - "slot": "5", - "type": "t_mapping(t_uint256,t_uint256)" - }, - { - "astId": 10178, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_allTokens", - "offset": 0, - "slot": "6", - "type": "t_array(t_uint256)dyn_storage" - }, - { - "astId": 10182, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_allTokensIndex", - "offset": 0, - "slot": "7", - "type": "t_mapping(t_uint256,t_uint256)" - }, - { - "astId": 24, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_roles", - "offset": 0, - "slot": "8", - "type": "t_mapping(t_bytes32,t_struct(RoleData)19_storage)" - }, - { - "astId": 7619, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "swapRouter", - "offset": 0, - "slot": "9", - "type": "t_address" - }, - { - "astId": 7621, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "wrappedNativeToken", - "offset": 0, - "slot": "10", - "type": "t_address" - }, - { - "astId": 7623, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "stableCoin", - "offset": 0, - "slot": "11", - "type": "t_address" - }, - { - "astId": 7625, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "masaToken", - "offset": 0, - "slot": "12", - "type": "t_address" - }, - { - "astId": 7629, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "enabledPaymentMethod", - "offset": 0, - "slot": "13", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 7632, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "enabledPaymentMethods", - "offset": 0, - "slot": "14", - "type": "t_array(t_address)dyn_storage" - }, - { - "astId": 7634, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "reserveWallet", - "offset": 0, - "slot": "15", - "type": "t_address" - }, - { - "astId": 8976, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_baseTokenURI", - "offset": 0, - "slot": "16", - "type": "t_string_storage" - }, - { - "astId": 8979, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "addLinkPrice", - "offset": 0, - "slot": "17", - "type": "t_uint256" - }, - { - "astId": 8982, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "addLinkPriceMASA", - "offset": 0, - "slot": "18", - "type": "t_uint256" - }, - { - "astId": 8985, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "queryLinkPrice", - "offset": 0, - "slot": "19", - "type": "t_uint256" - }, - { - "astId": 8988, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "queryLinkPriceMASA", - "offset": 0, - "slot": "20", - "type": "t_uint256" - }, - { - "astId": 9297, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_tokenIdCounter", - "offset": 0, - "slot": "21", - "type": "t_struct(Counter)2798_storage" - }, - { - "astId": 9300, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "soulboundIdentity", - "offset": 0, - "slot": "22", - "type": "t_contract(ISoulboundIdentity)8379" - }, - { - "astId": 9302, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "mintPrice", - "offset": 0, - "slot": "23", - "type": "t_uint256" - }, - { - "astId": 9304, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "mintPriceMASA", - "offset": 0, - "slot": "24", - "type": "t_uint256" - }, - { - "astId": 9308, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "authorities", - "offset": 0, - "slot": "25", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 624, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_status", - "offset": 0, - "slot": "26", - "type": "t_uint256" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_address)dyn_storage": { - "base": "t_address", - "encoding": "dynamic_array", - "label": "address[]", - "numberOfBytes": "32" - }, - "t_array(t_uint256)dyn_storage": { - "base": "t_uint256", - "encoding": "dynamic_array", - "label": "uint256[]", - "numberOfBytes": "32" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_contract(ISoulboundIdentity)8379": { - "encoding": "inplace", - "label": "contract ISoulboundIdentity", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_bool)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => mapping(uint256 => uint256))", - "numberOfBytes": "32", - "value": "t_mapping(t_uint256,t_uint256)" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_bytes32,t_struct(RoleData)19_storage)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => struct AccessControl.RoleData)", - "numberOfBytes": "32", - "value": "t_struct(RoleData)19_storage" - }, - "t_mapping(t_uint256,t_address)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => address)", - "numberOfBytes": "32", - "value": "t_address" - }, - "t_mapping(t_uint256,t_uint256)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_string_storage": { - "encoding": "bytes", - "label": "string", - "numberOfBytes": "32" - }, - "t_struct(Counter)2798_storage": { - "encoding": "inplace", - "label": "struct Counters.Counter", - "members": [ - { - "astId": 2797, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_value", - "offset": 0, - "slot": "0", - "type": "t_uint256" - } - ], - "numberOfBytes": "32" - }, - "t_struct(RoleData)19_storage": { - "encoding": "inplace", - "label": "struct AccessControl.RoleData", - "members": [ - { - "astId": 16, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "members", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 18, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "adminRole", - "offset": 0, - "slot": "1", - "type": "t_bytes32" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} \ No newline at end of file diff --git a/deployments/bsctest/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json b/deployments/bsctest/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json deleted file mode 100644 index 456dfd96a..000000000 --- a/deployments/bsctest/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/dex/PaymentGateway.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/dex/IUniswapRouter.sol\";\n\n/// @title Pay using a Decentralized automated market maker (AMM) when needed\n/// @author Masa Finance\n/// @notice Smart contract to call a Dex AMM smart contract to pay to a reserve wallet recipient\n/// @dev This smart contract will call the Uniswap Router interface, based on\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\nabstract contract PaymentGateway is AccessControl {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n\n struct PaymentParams {\n address swapRouter; // Swap router address\n address wrappedNativeToken; // Wrapped native token address\n address stableCoin; // Stable coin to pay the fee in (USDC)\n address masaToken; // Utility token to pay the fee in (MASA)\n address reserveWallet; // Wallet that will receive the fee\n }\n\n /* ========== STATE VARIABLES =========================================== */\n\n address public swapRouter;\n address public wrappedNativeToken;\n\n address public stableCoin; // USDC. It also needs to be enabled as payment method, if we want to pay in USDC\n address public masaToken; // MASA. It also needs to be enabled as payment method, if we want to pay in MASA\n\n // enabled payment methods: ETH and ERC20 tokens\n mapping(address => bool) public enabledPaymentMethod;\n address[] public enabledPaymentMethods;\n\n address public reserveWallet;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new Dex AMM\n /// @dev Creates a new Decentralized automated market maker (AMM) smart contract,\n // that will call the Uniswap Router interface\n /// @param admin Administrator of the smart contract\n /// @param paymentParams Payment params\n constructor(address admin, PaymentParams memory paymentParams) {\n if (paymentParams.swapRouter == address(0)) revert ZeroAddress();\n if (paymentParams.wrappedNativeToken == address(0))\n revert ZeroAddress();\n if (paymentParams.stableCoin == address(0)) revert ZeroAddress();\n if (paymentParams.reserveWallet == address(0)) revert ZeroAddress();\n\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n\n swapRouter = paymentParams.swapRouter;\n wrappedNativeToken = paymentParams.wrappedNativeToken;\n stableCoin = paymentParams.stableCoin;\n masaToken = paymentParams.masaToken;\n reserveWallet = paymentParams.reserveWallet;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the swap router address\n /// @dev The caller must have the admin role to call this function\n /// @param _swapRouter New swap router address\n function setSwapRouter(address _swapRouter)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_swapRouter == address(0)) revert ZeroAddress();\n if (swapRouter == _swapRouter) revert SameValue();\n swapRouter = _swapRouter;\n }\n\n /// @notice Sets the wrapped native token address\n /// @dev The caller must have the admin role to call this function\n /// @param _wrappedNativeToken New wrapped native token address\n function setWrappedNativeToken(address _wrappedNativeToken)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_wrappedNativeToken == address(0)) revert ZeroAddress();\n if (wrappedNativeToken == _wrappedNativeToken) revert SameValue();\n wrappedNativeToken = _wrappedNativeToken;\n }\n\n /// @notice Sets the stable coin to pay the fee in (USDC)\n /// @dev The caller must have the admin role to call this function\n /// @param _stableCoin New stable coin to pay the fee in\n function setStableCoin(address _stableCoin)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_stableCoin == address(0)) revert ZeroAddress();\n if (stableCoin == _stableCoin) revert SameValue();\n stableCoin = _stableCoin;\n }\n\n /// @notice Sets the utility token to pay the fee in (MASA)\n /// @dev The caller must have the admin role to call this function\n /// It can be set to address(0) to disable paying in MASA\n /// @param _masaToken New utility token to pay the fee in\n function setMasaToken(address _masaToken)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (masaToken == _masaToken) revert SameValue();\n masaToken = _masaToken;\n }\n\n /// @notice Adds a new token as a valid payment method\n /// @dev The caller must have the admin role to call this function\n /// @param _paymentMethod New token to add\n function enablePaymentMethod(address _paymentMethod)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (enabledPaymentMethod[_paymentMethod]) revert AlreadyAdded();\n\n enabledPaymentMethod[_paymentMethod] = true;\n enabledPaymentMethods.push(_paymentMethod);\n }\n\n /// @notice Removes a token as a valid payment method\n /// @dev The caller must have the admin role to call this function\n /// @param _paymentMethod Token to remove\n function disablePaymentMethod(address _paymentMethod)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (!enabledPaymentMethod[_paymentMethod])\n revert NonExistingErc20Token(_paymentMethod);\n\n enabledPaymentMethod[_paymentMethod] = false;\n for (uint256 i = 0; i < enabledPaymentMethods.length; i++) {\n if (enabledPaymentMethods[i] == _paymentMethod) {\n enabledPaymentMethods[i] = enabledPaymentMethods[\n enabledPaymentMethods.length - 1\n ];\n enabledPaymentMethods.pop();\n break;\n }\n }\n }\n\n /// @notice Set the reserve wallet\n /// @dev The caller must have the admin role to call this function\n /// @param _reserveWallet New reserve wallet\n function setReserveWallet(address _reserveWallet)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_reserveWallet == address(0)) revert ZeroAddress();\n if (_reserveWallet == reserveWallet) revert SameValue();\n reserveWallet = _reserveWallet;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns all available payment methods\n /// @dev Returns the address of all available payment methods\n /// @return Array of all enabled payment methods\n function getEnabledPaymentMethods()\n external\n view\n returns (address[] memory)\n {\n return enabledPaymentMethods;\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /// @notice Converts an amount from a stable coin to a payment method amount\n /// @dev This method will perform the swap between the stable coin and the\n /// payment method, and return the amount of the payment method,\n /// performing the swap if necessary\n /// @param paymentMethod Address of token that user want to pay\n /// @param amount Price to be converted in the specified payment method\n function _convertFromStableCoin(address paymentMethod, uint256 amount)\n internal\n view\n returns (uint256)\n {\n if (!enabledPaymentMethod[paymentMethod] || paymentMethod == stableCoin)\n revert InvalidToken(paymentMethod);\n\n if (paymentMethod == address(0)) {\n return _estimateSwapAmount(wrappedNativeToken, stableCoin, amount);\n } else {\n return _estimateSwapAmount(paymentMethod, stableCoin, amount);\n }\n }\n\n /// @notice Performs the payment in any payment method\n /// @dev This method will transfer the funds to the reserve wallet, performing\n /// the swap if necessary\n /// @param paymentMethod Address of token that user want to pay\n /// @param amount Price to be paid in the specified payment method\n function _pay(address paymentMethod, uint256 amount) internal {\n if (amount == 0) return;\n if (!enabledPaymentMethod[paymentMethod])\n revert InvalidPaymentMethod(paymentMethod);\n if (paymentMethod == address(0)) {\n // ETH\n if (msg.value < amount) revert InsufficientEthAmount(amount);\n (bool success, ) = payable(reserveWallet).call{value: amount}(\"\");\n if (!success) revert TransferFailed();\n if (msg.value > amount) {\n // return diff\n uint256 refund = msg.value.sub(amount);\n (success, ) = payable(msg.sender).call{value: refund}(\"\");\n if (!success) revert RefundFailed();\n }\n } else {\n // ERC20 token, including MASA and USDC\n IERC20(paymentMethod).safeTransferFrom(\n msg.sender,\n reserveWallet,\n amount\n );\n }\n }\n\n function _estimateSwapAmount(\n address _fromToken,\n address _toToken,\n uint256 _amountOut\n ) private view returns (uint256) {\n uint256[] memory amounts;\n address[] memory path;\n path = _getPathFromTokenToToken(_fromToken, _toToken);\n amounts = IUniswapRouter(swapRouter).getAmountsIn(_amountOut, path);\n return amounts[0];\n }\n\n function _getPathFromTokenToToken(address fromToken, address toToken)\n private\n view\n returns (address[] memory)\n {\n if (fromToken == wrappedNativeToken || toToken == wrappedNativeToken) {\n address[] memory path = new address[](2);\n path[0] = fromToken == wrappedNativeToken\n ? wrappedNativeToken\n : fromToken;\n path[1] = toToken == wrappedNativeToken\n ? wrappedNativeToken\n : toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = fromToken;\n path[1] = wrappedNativeToken;\n path[2] = toToken;\n return path;\n }\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" - }, - "contracts/libraries/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nerror AddressDoesNotHaveIdentity(address to);\nerror AlreadyAdded();\nerror AuthorityNotExists(address authority);\nerror CallerNotOwner(address caller);\nerror CallerNotReader(address caller);\nerror CreditScoreAlreadyCreated(address to);\nerror IdentityAlreadyCreated(address to);\nerror IdentityOwnerIsReader(uint256 readerIdentityId);\nerror InsufficientEthAmount(uint256 amount);\nerror IdentityOwnerNotTokenOwner(uint256 tokenId, uint256 ownerIdentityId);\nerror InvalidPaymentMethod(address paymentMethod);\nerror InvalidSignature();\nerror InvalidSignatureDate(uint256 signatureDate);\nerror InvalidToken(address token);\nerror InvalidTokenURI(string tokenURI);\nerror LinkAlreadyExists(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId,\n uint256 signatureDate\n);\nerror LinkAlreadyRevoked();\nerror LinkDoesNotExist();\nerror NameAlreadyExists(string name);\nerror NameNotFound(string name);\nerror NameRegisteredByOtherAccount(string name, uint256 tokenId);\nerror NotAuthorized(address signer);\nerror NonExistingErc20Token(address erc20token);\nerror NotLinkedToAnIdentitySBT();\nerror RefundFailed();\nerror SameValue();\nerror SBTAlreadyLinked(address token);\nerror SoulNameContractNotSet();\nerror TokenNotFound(uint256 tokenId);\nerror TransferFailed();\nerror URIAlreadyExists(string tokenURI);\nerror ValidPeriodExpired(uint256 expirationDate);\nerror ZeroAddress();\nerror ZeroLengthName(string name);\nerror ZeroYearsPeriod(uint256 yearsPeriod);\n" - }, - "contracts/interfaces/dex/IUniswapRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\n/// @title Uniswap Router interface\n/// @author Masa Finance\n/// @notice Interface of the Uniswap Router contract\n/// @dev This interface is used to interact with the Uniswap Router contract,\n/// and gets the most important functions of the contract. It's based on\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\ninterface IUniswapRouter {\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "contracts/SoulStore.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./dex/PaymentGateway.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\n\n/// @title Soul Store\n/// @author Masa Finance\n/// @notice Soul Store, that can mint new Soulbound Identities and Soul Name NFTs, paying a fee\n/// @dev From this smart contract we can mint new Soulbound Identities and Soul Name NFTs.\n/// This minting can be done paying a fee in ETH, USDC or MASA\ncontract SoulStore is PaymentGateway, Pausable, ReentrancyGuard, EIP712 {\n using SafeMath for uint256;\n\n /* ========== STATE VARIABLES ========== */\n\n ISoulboundIdentity public soulboundIdentity;\n\n mapping(uint256 => uint256) public nameRegistrationPricePerYear; // (length --> price in stable coin per year)\n\n mapping(address => bool) public authorities;\n\n /* ========== INITIALIZE ========== */\n\n /// @notice Creates a new Soul Store\n /// @dev Creates a new Soul Store, that has the role to minting new Soulbound Identities\n /// and Soul Name NFTs, paying a fee\n /// @param admin Administrator of the smart contract\n /// @param _soulBoundIdentity Address of the Soulbound identity contract\n /// @param _nameRegistrationPricePerYear Price of the default name registering in stable coin per year\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n ISoulboundIdentity _soulBoundIdentity,\n uint256 _nameRegistrationPricePerYear,\n PaymentParams memory paymentParams\n ) PaymentGateway(admin, paymentParams) EIP712(\"SoulStore\", \"1.0.0\") {\n if (address(_soulBoundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulBoundIdentity;\n\n nameRegistrationPricePerYear[0] = _nameRegistrationPricePerYear; // name price for default length per year\n }\n\n /* ========== RESTRICTED FUNCTIONS ========== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this store\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity New SoulboundIdentity contract address\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the price of the name registering per one year in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _nameLength Length of the name\n /// @param _nameRegistrationPricePerYear New price of the name registering per one\n /// year in stable coin for that name length per year\n function setNameRegistrationPricePerYear(\n uint256 _nameLength,\n uint256 _nameRegistrationPricePerYear\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\n if (\n nameRegistrationPricePerYear[_nameLength] ==\n _nameRegistrationPricePerYear\n ) revert SameValue();\n nameRegistrationPricePerYear[\n _nameLength\n ] = _nameRegistrationPricePerYear;\n }\n\n /// @notice Adds a new authority to the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority New authority to add\n function addAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (authorities[_authority]) revert AlreadyAdded();\n\n authorities[_authority] = true;\n }\n\n /// @notice Removes an authority from the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority Authority to remove\n function removeAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\n\n authorities[_authority] = false;\n }\n\n /// @notice Pauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function pause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function unpause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /* ========== MUTATIVE FUNCTIONS ========== */\n\n /// @notice Mints a new Soulbound Identity and Name purchasing it\n /// @dev This function allows the purchase of a soulbound identity and name using\n /// stable coin (USDC), native token (ETH) or utility token (MASA)\n /// @param paymentMethod Address of token that user want to pay\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soulbound identity\n function purchaseIdentityAndName(\n address paymentMethod,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant returns (uint256) {\n _pay(\n paymentMethod,\n getPriceForMintingName(paymentMethod, nameLength, yearsPeriod)\n );\n\n // finalize purchase\n return\n _mintSoulboundIdentityAndName(\n _msgSender(),\n name,\n nameLength,\n yearsPeriod,\n tokenURI,\n authorityAddress,\n signature\n );\n }\n\n /// @notice Mints a new Soulbound Identity purchasing it\n /// @dev This function allows the purchase of a soulbound identity for free\n /// @return TokenId of the new soulbound identity\n function purchaseIdentity()\n external\n whenNotPaused\n nonReentrant\n returns (uint256)\n {\n // finalize purchase\n return _mintSoulboundIdentity(_msgSender());\n }\n\n /// @notice Mints a new Soul Name purchasing it\n /// @dev This function allows the purchase of a soul name using\n /// stable coin (USDC), native token (ETH) or utility token (MASA)\n /// @param paymentMethod Address of token that user want to pay\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new sou name\n function purchaseName(\n address paymentMethod,\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant returns (uint256) {\n _pay(\n paymentMethod,\n getPriceForMintingName(paymentMethod, nameLength, yearsPeriod)\n );\n\n // finalize purchase\n return\n _mintSoulName(\n to,\n name,\n nameLength,\n yearsPeriod,\n tokenURI,\n authorityAddress,\n signature\n );\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Returns the price of register a name per year in stable coin for an specific length\n /// @dev Returns the price for registering per year in USD for an specific name length\n /// @param nameLength Length of the name\n /// @return Price in stable coin for that name length\n function getNameRegistrationPricePerYear(uint256 nameLength)\n public\n view\n returns (uint256)\n {\n uint256 price = nameRegistrationPricePerYear[nameLength];\n if (price == 0) {\n // if not found, return the default price\n price = nameRegistrationPricePerYear[0];\n }\n return price;\n }\n\n /// @notice Returns the price of the name minting\n /// @dev Returns current pricing for name minting for a given name length and years period\n /// @param paymentMethod Address of token that user want to pay\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @return Current price of the name minting in the given payment method\n function getPriceForMintingName(\n address paymentMethod,\n uint256 nameLength,\n uint256 yearsPeriod\n ) public view returns (uint256) {\n uint256 mintPrice = getNameRegistrationPricePerYear(nameLength).mul(\n yearsPeriod\n );\n\n if (mintPrice == 0) {\n return 0;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return mintPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, mintPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /* ========== PRIVATE FUNCTIONS ========== */\n\n /// @notice Mints a new Soulbound Identity and Name\n /// @dev The final step of all purchase options. Will mint a\n /// new Soulbound Identity and a Soul Name NFT and emit the purchase event\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soulbound identity\n function _mintSoulboundIdentityAndName(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) internal returns (uint256) {\n _verify(\n _hash(to, name, nameLength, yearsPeriod, tokenURI),\n signature,\n authorityAddress\n );\n\n // mint Soulbound identity token\n uint256 tokenId = soulboundIdentity.mintIdentityWithName(\n to,\n name,\n yearsPeriod,\n tokenURI\n );\n\n emit SoulboundIdentityAndNamePurchased(to, tokenId, name, yearsPeriod);\n\n return tokenId;\n }\n\n /// @notice Mints a new Soulbound Identity\n /// @dev The final step of all purchase options. Will mint a\n /// new Soulbound Identity and emit the purchase event\n /// @param to Address of the owner of the new identity\n /// @return TokenId of the new soulbound identity\n function _mintSoulboundIdentity(address to) internal returns (uint256) {\n // mint Soulbound identity token\n uint256 tokenId = soulboundIdentity.mint(to);\n\n emit SoulboundIdentityPurchased(to, tokenId);\n\n return tokenId;\n }\n\n /// @notice Mints a new Soul Name\n /// @dev The final step of all purchase options. Will mint a\n /// new Soul Name NFT and emit the purchase event\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soul name\n function _mintSoulName(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) internal returns (uint256) {\n _verify(\n _hash(to, name, nameLength, yearsPeriod, tokenURI),\n signature,\n authorityAddress\n );\n\n // mint Soul Name token\n ISoulName soulName = soulboundIdentity.getSoulName();\n\n uint256 tokenId = soulName.mint(to, name, yearsPeriod, tokenURI);\n\n emit SoulNamePurchased(to, tokenId, name, yearsPeriod);\n\n return tokenId;\n }\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address signer\n ) internal view {\n address _signer = ECDSA.recover(digest, signature);\n if (_signer != signer) revert InvalidSignature();\n if (!authorities[_signer]) revert NotAuthorized(_signer);\n }\n\n function _hash(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintSoulName(address to,string name,uint256 nameLength,uint256 yearsPeriod,string tokenURI)\"\n ),\n to,\n keccak256(bytes(name)),\n nameLength,\n yearsPeriod,\n keccak256(bytes(tokenURI))\n )\n )\n );\n }\n\n /* ========== MODIFIERS ========== */\n\n /* ========== EVENTS ========== */\n\n event SoulboundIdentityAndNamePurchased(\n address indexed account,\n uint256 tokenId,\n string indexed name,\n uint256 yearsPeriod\n );\n\n event SoulboundIdentityPurchased(address indexed account, uint256 tokenId);\n\n event SoulNamePurchased(\n address indexed account,\n uint256 tokenId,\n string indexed name,\n uint256 yearsPeriod\n );\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" - }, - "@openzeppelin/contracts/security/ReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "contracts/interfaces/ISoulboundIdentity.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../tokens/SBT/ISBT.sol\";\n\nimport \"./ISoulName.sol\";\n\ninterface ISoulboundIdentity is ISBT {\n function mint(address to) external returns (uint256);\n\n function mintIdentityWithName(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external returns (uint256);\n\n function getSoulName() external view returns (ISoulName);\n\n function tokenOfOwner(address owner) external view returns (uint256);\n}\n" - }, - "contracts/interfaces/ISoulName.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\ninterface ISoulName {\n function mint(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external returns (uint256);\n\n function getExtension() external view returns (string memory);\n\n function isAvailable(string memory name)\n external\n view\n returns (bool available);\n\n function getTokenData(string memory name)\n external\n view\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n );\n\n function getTokenId(string memory name) external view returns (uint256);\n\n function getSoulNames(address owner)\n external\n view\n returns (string[] memory sbtNames);\n\n function getSoulNames(uint256 identityId)\n external\n view\n returns (string[] memory sbtNames);\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "contracts/tokens/SBT/ISBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\ninterface ISBT is IERC165 {\n /// @dev This emits when an SBT is newly minted.\n /// This event emits when SBTs are created\n event Mint(address indexed _owner, uint256 indexed _tokenId);\n\n /// @dev This emits when an SBT is burned\n /// This event emits when SBTs are destroyed\n event Burn(address indexed _owner, uint256 indexed _tokenId);\n\n /// @notice Count all SBTs assigned to an owner\n /// @dev SBTs assigned to the zero address are considered invalid, and this\n /// function throws for queries about the zero address.\n /// @param _owner An address for whom to query the balance\n /// @return The number of SBTs owned by `_owner`, possibly zero\n function balanceOf(address _owner) external view returns (uint256);\n\n /// @notice Find the owner of an SBT\n /// @dev SBTs assigned to zero address are considered invalid, and queries\n /// about them do throw.\n /// @param _tokenId The identifier for an SBT\n /// @return The address of the owner of the SBT\n function ownerOf(uint256 _tokenId) external view returns (address);\n}\n" - }, - "contracts/SoulName.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./libraries/Utils.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\nimport \"./tokens/MasaNFT.sol\";\n\n/// @title SoulName NFT\n/// @author Masa Finance\n/// @notice SoulName NFT that points to a Soulbound identity token\n/// @dev SoulName NFT, that inherits from the NFT contract, and points to a Soulbound identity token.\n/// It has an extension, and stores all the information about the identity names.\ncontract SoulName is MasaNFT, ISoulName, ReentrancyGuard {\n /* ========== STATE VARIABLES ========== */\n using SafeMath for uint256;\n\n uint256 constant YEAR = 31536000; // 60 seconds * 60 minutes * 24 hours * 365 days\n\n ISoulboundIdentity public soulboundIdentity;\n string public extension; // suffix of the names (.sol?)\n\n // contractURI() points to the smart contract metadata\n // see https://docs.opensea.io/docs/contract-level-metadata\n string public contractURI;\n\n // Optional mapping for token URIs\n mapping(uint256 => string) private _tokenURIs;\n mapping(string => bool) private _URIs; // used to check if a uri is already used\n\n mapping(uint256 => TokenData) public tokenData; // used to store the data of the token id\n mapping(string => NameData) public nameData; // stores the token id of the current active soul name\n\n struct TokenData {\n string name; // Name with lowercase and uppercase\n uint256 expirationDate;\n }\n\n struct NameData {\n bool exists;\n uint256 tokenId;\n }\n\n /* ========== INITIALIZE ========== */\n\n /// @notice Creates a new SoulName NFT\n /// @dev Creates a new SoulName NFT, that points to a Soulbound identity, inheriting from the NFT contract.\n /// @param admin Administrator of the smart contract\n /// @param _soulboundIdentity Address of the Soulbound identity contract\n /// @param _extension Extension of the soul name\n /// @param _contractURI URI of the smart contract metadata\n constructor(\n address admin,\n ISoulboundIdentity _soulboundIdentity,\n string memory _extension,\n string memory _contractURI\n ) MasaNFT(admin, \"Masa Soul Name\", \"MSN\", \"\") {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulboundIdentity;\n extension = _extension;\n contractURI = _contractURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the extension of the soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _extension Extension of the soul name\n function setExtension(string memory _extension)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (\n keccak256(abi.encodePacked((extension))) ==\n keccak256(abi.encodePacked((_extension)))\n ) revert SameValue();\n extension = _extension;\n }\n\n /// @notice Sets the URI of the smart contract metadata\n /// @dev The caller must have the admin role to call this function\n /// @param _contractURI URI of the smart contract metadata\n function setContractURI(string memory _contractURI)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (\n keccak256(abi.encodePacked((contractURI))) ==\n keccak256(abi.encodePacked((_contractURI)))\n ) revert SameValue();\n contractURI = _contractURI;\n }\n\n /* ========== MUTATIVE FUNCTIONS ========== */\n\n /// @notice Mints a new soul name\n /// @dev The caller can mint more than one name. The soul name must be unique.\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param yearsPeriod Years of validity of the name\n /// @param _tokenURI URI of the NFT\n function mint(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) public override nonReentrant returns (uint256) {\n if (!isAvailable(name)) revert NameAlreadyExists(name);\n if (bytes(name).length == 0) revert ZeroLengthName(name);\n if (yearsPeriod == 0) revert ZeroYearsPeriod(yearsPeriod);\n if (soulboundIdentity.balanceOf(to) == 0)\n revert AddressDoesNotHaveIdentity(to);\n if (\n !Utils.startsWith(_tokenURI, \"ar://\") &&\n !Utils.startsWith(_tokenURI, \"ipfs://\")\n ) revert InvalidTokenURI(_tokenURI);\n\n uint256 tokenId = _mintWithCounter(to);\n _setTokenURI(tokenId, _tokenURI);\n\n tokenData[tokenId].name = name;\n tokenData[tokenId].expirationDate = block.timestamp.add(\n YEAR.mul(yearsPeriod)\n );\n\n string memory lowercaseName = Utils.toLowerCase(name);\n nameData[lowercaseName].tokenId = tokenId;\n nameData[lowercaseName].exists = true;\n\n return tokenId;\n }\n\n /// @notice Update the expiration date of a soul name\n /// @dev The caller must be the owner or an approved address of the soul name.\n /// @param tokenId TokenId of the soul name\n /// @param yearsPeriod Years of validity of the name\n function renewYearsPeriod(uint256 tokenId, uint256 yearsPeriod) external {\n // ERC721: caller is not token owner nor approved\n if (!_isApprovedOrOwner(_msgSender(), tokenId))\n revert CallerNotOwner(_msgSender());\n if (yearsPeriod == 0) revert ZeroYearsPeriod(yearsPeriod);\n\n // check that the last registered tokenId for that name is the current token\n string memory lowercaseName = Utils.toLowerCase(\n tokenData[tokenId].name\n );\n if (nameData[lowercaseName].tokenId != tokenId)\n revert NameRegisteredByOtherAccount(lowercaseName, tokenId);\n\n // check if the name is expired\n if (tokenData[tokenId].expirationDate < block.timestamp) {\n tokenData[tokenId].expirationDate = block.timestamp.add(\n YEAR.mul(yearsPeriod)\n );\n } else {\n tokenData[tokenId].expirationDate = tokenData[tokenId]\n .expirationDate\n .add(YEAR.mul(yearsPeriod));\n }\n\n emit YearsPeriodRenewed(\n tokenId,\n yearsPeriod,\n tokenData[tokenId].expirationDate\n );\n }\n\n /// @notice Burn a soul name\n /// @dev The caller must be the owner or an approved address of the soul name.\n /// @param tokenId TokenId of the soul name to burn\n function burn(uint256 tokenId) public override {\n if (!_exists(tokenId)) revert TokenNotFound(tokenId);\n\n string memory lowercaseName = Utils.toLowerCase(\n tokenData[tokenId].name\n );\n\n // remove info from tokenIdName and tokenData\n delete tokenData[tokenId];\n\n // if the last owner of the name is burning it, remove the name from nameData\n if (nameData[lowercaseName].tokenId == tokenId) {\n delete nameData[lowercaseName];\n }\n\n if (bytes(_tokenURIs[tokenId]).length != 0) {\n _URIs[_tokenURIs[tokenId]] = false;\n delete _tokenURIs[tokenId];\n }\n\n super.burn(tokenId);\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Returns the extension of the soul name\n /// @dev This function is used to get the extension of the soul name\n /// @return Extension of the soul name\n function getExtension() external view override returns (string memory) {\n return extension;\n }\n\n /// @notice Checks if a soul name is available\n /// @dev This function queries if a soul name already exists and is in the available state\n /// @param name Name of the soul name\n /// @return available `true` if the soul name is available, `false` otherwise\n function isAvailable(string memory name)\n public\n view\n override\n returns (bool available)\n {\n string memory lowercaseName = Utils.toLowerCase(name);\n if (nameData[lowercaseName].exists) {\n uint256 tokenId = nameData[lowercaseName].tokenId;\n return tokenData[tokenId].expirationDate < block.timestamp;\n } else {\n return true;\n }\n }\n\n /// @notice Returns the information of a soul name\n /// @dev This function queries the information of a soul name\n /// @param name Name of the soul name\n /// @return sbtName Soul name, in upper/lower case and extension\n /// @return linked `true` if the soul name is linked, `false` otherwise\n /// @return identityId Identity id of the soul name\n /// @return tokenId SoulName id of the soul name\n /// @return expirationDate Expiration date of the soul name\n /// @return active `true` if the soul name is active, `false` otherwise\n function getTokenData(string memory name)\n external\n view\n override\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n )\n {\n tokenId = _getTokenId(name);\n address _owner = ownerOf(tokenId);\n bool _linked = soulboundIdentity.balanceOf(_owner) > 0;\n uint256 _identityId = 0;\n if (_linked) {\n _identityId = soulboundIdentity.tokenOfOwner(_owner);\n }\n\n TokenData memory _tokenData = tokenData[tokenId];\n\n return (\n _getName(_tokenData.name),\n _linked,\n _identityId,\n tokenId,\n _tokenData.expirationDate,\n _tokenData.expirationDate >= block.timestamp\n );\n }\n\n /// @notice Returns the token id of a soul name\n /// @dev This function queries the token id of a soul name\n /// @param name Name of the soul name\n /// @return SoulName id of the soul name\n function getTokenId(string memory name)\n external\n view\n override\n returns (uint256)\n {\n return _getTokenId(name);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified identity Id\n /// @param identityId TokenId of the identity\n /// @return sbtNames Array of soul names associated to the identity Id\n function getSoulNames(uint256 identityId)\n external\n view\n override\n returns (string[] memory sbtNames)\n {\n // return owner if exists\n address _owner = soulboundIdentity.ownerOf(identityId);\n\n return getSoulNames(_owner);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified account\n /// @param owner Address of the owner of the identities\n /// @return sbtNames Array of soul names associated to the account\n function getSoulNames(address owner)\n public\n view\n override\n returns (string[] memory sbtNames)\n {\n uint256 results = 0;\n uint256 balance = balanceOf(owner);\n\n for (uint256 i = 0; i < balance; i++) {\n uint256 tokenId = tokenOfOwnerByIndex(owner, i);\n if (tokenData[tokenId].expirationDate >= block.timestamp) {\n results = results.add(1);\n }\n }\n\n string[] memory _sbtNames = new string[](results);\n uint256 index = 0;\n\n for (uint256 i = 0; i < balance; i++) {\n uint256 tokenId = tokenOfOwnerByIndex(owner, i);\n if (tokenData[tokenId].expirationDate >= block.timestamp) {\n _sbtNames[index] = Utils.toLowerCase(tokenData[tokenId].name);\n index = index.add(1);\n }\n }\n\n // return identity names if exists and are active\n return _sbtNames;\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev This function returns the token URI of the soul name specified by the name\n /// @param name Name of the soul name\n /// @return URI of the soulname associated to a name\n function tokenURI(string memory name)\n external\n view\n virtual\n returns (string memory)\n {\n uint256 tokenId = _getTokenId(name);\n return tokenURI(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId NFT to get the URI of\n /// @return URI of the NFT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory _tokenURI = _tokenURIs[tokenId];\n string memory base = _baseURI();\n\n // If there is no base URI, return the token URI.\n if (bytes(base).length == 0) {\n return _tokenURI;\n }\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n if (bytes(_tokenURI).length > 0) {\n return string(abi.encodePacked(base, _tokenURI));\n }\n\n return super.tokenURI(tokenId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========== */\n\n function _getName(string memory name) private view returns (string memory) {\n return string(bytes.concat(bytes(name), bytes(extension)));\n }\n\n function _getTokenId(string memory name) private view returns (uint256) {\n string memory lowercaseName = Utils.toLowerCase(name);\n if (!nameData[lowercaseName].exists) revert NameNotFound(name);\n\n return nameData[lowercaseName].tokenId;\n }\n\n function _setTokenURI(uint256 tokenId, string memory _tokenURI)\n internal\n virtual\n {\n if (!_exists(tokenId)) revert TokenNotFound(tokenId);\n if (_URIs[_tokenURI]) revert URIAlreadyExists(_tokenURI);\n\n _tokenURIs[tokenId] = _tokenURI;\n _URIs[_tokenURI] = true;\n }\n\n /* ========== MODIFIERS ========== */\n\n /* ========== EVENTS ========== */\n\n event YearsPeriodRenewed(\n uint256 tokenId,\n uint256 yearsPeriod,\n uint256 newExpirationDate\n );\n}\n" - }, - "contracts/libraries/Utils.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\n/// @title Utilities library for Masa Contracts Identity repository\n/// @author Masa Finance\n/// @notice Library of utilities for Masa Contracts Identity repository\nlibrary Utils {\n struct slice {\n uint256 _len;\n uint256 _ptr;\n }\n\n function toLowerCase(string memory _str)\n internal\n pure\n returns (string memory)\n {\n bytes memory bStr = bytes(_str);\n bytes memory bLower = new bytes(bStr.length);\n\n for (uint256 i = 0; i < bStr.length; i++) {\n // Uppercase character...\n if ((bStr[i] >= 0x41) && (bStr[i] <= 0x5A)) {\n // So we add 0x20 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 0x20);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n\n function toSlice(string memory self) private pure returns (slice memory) {\n uint256 ptr;\n assembly {\n ptr := add(self, 0x20)\n }\n return slice(bytes(self).length, ptr);\n }\n\n function startsWith(string memory str, string memory needle)\n internal\n pure\n returns (bool)\n {\n slice memory s_str = toSlice(str);\n slice memory s_needle = toSlice(needle);\n\n if (s_str._len < s_needle._len) {\n return false;\n }\n\n if (s_str._ptr == s_needle._ptr) {\n return true;\n }\n\n bool equal;\n assembly {\n let length := mload(s_needle)\n let selfptr := mload(add(s_str, 0x20))\n let needleptr := mload(add(s_needle, 0x20))\n equal := eq(\n keccak256(selfptr, length),\n keccak256(needleptr, length)\n )\n }\n return equal;\n }\n}\n" - }, - "contracts/tokens/MasaNFT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\n/// @title MasaNFT\n/// @author Masa Finance\n/// @notice Non-fungible token is a token that is not fungible.\n/// @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard,\n/// that inherits from {ERC721Enumerable}, {Ownable}, {AccessControl} and {ERC721Burnable}.\nabstract contract MasaNFT is\n ERC721,\n ERC721Enumerable,\n Ownable,\n AccessControl,\n ERC721Burnable\n{\n /* ========== STATE VARIABLES =========================================== */\n\n using Strings for uint256;\n using Counters for Counters.Counter;\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n Counters.Counter private _tokenIdCounter;\n\n string private _baseTokenURI;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new NFT\n /// @dev Creates a new Non-fungible token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) ERC721(name, symbol) {\n Ownable.transferOwnership(admin);\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n _grantRole(MINTER_ROLE, admin);\n\n _baseTokenURI = baseTokenURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n function _mintWithCounter(address to)\n internal\n onlyRole(MINTER_ROLE)\n returns (uint256)\n {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _safeMint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns true if the token exists\n /// @dev Returns true if the token has been minted\n /// @param tokenId Token to check\n /// @return True if the token exists\n function exists(uint256 tokenId) external view returns (bool) {\n return _exists(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId NFT to get the URI of\n /// @return URI of the NFT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\"))\n : \"\";\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC721, ERC721Enumerable, AccessControl)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override(ERC721, ERC721Enumerable) {\n super._beforeTokenTransfer(from, to, tokenId);\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/ERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"./IERC721Enumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721.balanceOf(owner), \"ERC721Enumerable: owner index out of bounds\");\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721Enumerable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @title ERC721 Burnable Token\n * @dev ERC721 Token that can be burned (destroyed).\n */\nabstract contract ERC721Burnable is Context, ERC721 {\n /**\n * @dev Burns `tokenId`. See {ERC721-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _burn(tokenId);\n }\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Counters.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" - }, - "contracts/SoulLinker.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./dex/PaymentGateway.sol\";\nimport \"./interfaces/ILinkableSBT.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\n\n/// @title Soul linker\n/// @author Masa Finance\n/// @notice Soul linker smart contract that let add links to a Soulbound token.\ncontract SoulLinker is PaymentGateway, EIP712, Pausable, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n ISoulboundIdentity public soulboundIdentity;\n\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n mapping(address => mapping(uint256 => mapping(uint256 => mapping(uint256 => LinkData))))\n private _links;\n // token => tokenId => readerIdentityId\n mapping(address => mapping(uint256 => uint256[]))\n private _linkReaderIdentityIds;\n // token => tokenId => readerIdentityId => signatureDate\n mapping(address => mapping(uint256 => mapping(uint256 => uint256[])))\n private _linkSignatureDates;\n // readerIdentityId => ReaderLink\n mapping(uint256 => ReaderLink[]) private _readerLinks;\n\n struct LinkData {\n bool exists;\n uint256 ownerIdentityId;\n uint256 expirationDate;\n bool isRevoked;\n }\n\n struct ReaderLink {\n address token;\n uint256 tokenId;\n uint256 signatureDate;\n }\n\n struct LinkKey {\n uint256 readerIdentityId;\n uint256 signatureDate;\n }\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soul linker\n /// @param admin Administrator of the smart contract\n /// @param _soulboundIdentity Soulbound identity smart contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n ISoulboundIdentity _soulboundIdentity,\n PaymentParams memory paymentParams\n ) EIP712(\"SoulLinker\", \"1.0.0\") PaymentGateway(admin, paymentParams) {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulboundIdentity;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Pauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Stores the link, validating the signature of the given read link request\n /// @dev The token must be linked to this soul linker\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n /// @param expirationDate Expiration date of the signature\n /// @param signature Signature of the read link request made by the owner\n function addLink(\n address paymentMethod,\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address readerAddress = soulboundIdentity.ownerOf(readerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (readerAddress != _msgSender()) revert CallerNotReader(_msgSender());\n if (ownerIdentityId == readerIdentityId)\n revert IdentityOwnerIsReader(readerIdentityId);\n if (signatureDate == 0) revert InvalidSignatureDate(signatureDate);\n if (expirationDate < block.timestamp)\n revert ValidPeriodExpired(expirationDate);\n if (_links[token][tokenId][readerIdentityId][signatureDate].exists)\n revert LinkAlreadyExists(\n token,\n tokenId,\n readerIdentityId,\n signatureDate\n );\n if (\n !_verify(\n _hash(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n ),\n signature,\n ownerAddress\n )\n ) revert InvalidSignature();\n\n _pay(paymentMethod, getPriceForAddLink(paymentMethod, token));\n\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate] = LinkData(\n true,\n ownerIdentityId,\n expirationDate,\n false\n );\n if (_linkSignatureDates[token][tokenId][readerIdentityId].length == 0) {\n _linkReaderIdentityIds[token][tokenId].push(readerIdentityId);\n }\n _linkSignatureDates[token][tokenId][readerIdentityId].push(\n signatureDate\n );\n _readerLinks[readerIdentityId].push(\n ReaderLink(token, tokenId, signatureDate)\n );\n\n emit LinkAdded(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n );\n }\n\n /// @notice Revokes the link\n /// @dev The links can be revoked, wether the token is linked or not.\n /// The caller must be the owner of the token.\n /// The owner of the token can revoke a link even if the reader has not added it yet.\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n function revokeLink(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n ) external whenNotPaused {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (ownerAddress != _msgSender()) revert CallerNotOwner(_msgSender());\n if (ownerIdentityId == readerIdentityId)\n revert IdentityOwnerIsReader(readerIdentityId);\n if (_links[token][tokenId][readerIdentityId][signatureDate].isRevoked)\n revert LinkAlreadyRevoked();\n\n if (_links[token][tokenId][readerIdentityId][signatureDate].exists) {\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate]\n .isRevoked = true;\n } else {\n // if the link doesn't exist, store it\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate] = LinkData(\n true,\n ownerIdentityId,\n 0,\n true\n );\n if (\n _linkSignatureDates[token][tokenId][readerIdentityId].length ==\n 0\n ) {\n _linkReaderIdentityIds[token][tokenId].push(readerIdentityId);\n }\n _linkSignatureDates[token][tokenId][readerIdentityId].push(\n signatureDate\n );\n _readerLinks[readerIdentityId].push(\n ReaderLink(token, tokenId, signatureDate)\n );\n }\n\n emit LinkRevoked(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate\n );\n }\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the identityId owned by the given token\n /// @dev The token must be linked to this soul linker\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @return Id of the identity\n function getIdentityId(address token, uint256 tokenId)\n external\n view\n returns (uint256)\n {\n address owner = IERC721Enumerable(token).ownerOf(tokenId);\n return soulboundIdentity.tokenOfOwner(owner);\n }\n\n /// @notice Returns the list of connected SBTs by a given SBT token\n /// @param identityId Id of the identity\n /// @param token Address of the SBT contract\n /// @return List of connected SBTs\n function getSBTConnections(uint256 identityId, address token)\n external\n view\n returns (uint256[] memory)\n {\n address owner = soulboundIdentity.ownerOf(identityId);\n\n return getSBTConnections(owner, token);\n }\n\n /// @notice Returns the list of connected SBTs by a given SBT token\n /// @param owner Address of the owner of the identity\n /// @param token Address of the SBT contract\n /// @return List of connectec SBTs\n function getSBTConnections(address owner, address token)\n public\n view\n returns (uint256[] memory)\n {\n uint256 connections = IERC721Enumerable(token).balanceOf(owner);\n uint256[] memory sbtConnections = new uint256[](connections);\n for (uint256 i = 0; i < connections; i++) {\n sbtConnections[i] = IERC721Enumerable(token).tokenOfOwnerByIndex(\n owner,\n i\n );\n }\n\n return sbtConnections;\n }\n\n /// @notice Returns the list of link signature dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @return List of linked SBTs\n function getLinks(address token, uint256 tokenId)\n public\n view\n returns (LinkKey[] memory)\n {\n uint256 nLinkKeys = 0;\n for (\n uint256 i = 0;\n i < _linkReaderIdentityIds[token][tokenId].length;\n i++\n ) {\n uint256 readerIdentityId = _linkReaderIdentityIds[token][tokenId][\n i\n ];\n for (\n uint256 j = 0;\n j <\n _linkSignatureDates[token][tokenId][readerIdentityId].length;\n j++\n ) {\n nLinkKeys++;\n }\n }\n\n LinkKey[] memory linkKeys = new LinkKey[](nLinkKeys);\n uint256 n = 0;\n for (\n uint256 i = 0;\n i < _linkReaderIdentityIds[token][tokenId].length;\n i++\n ) {\n uint256 readerIdentityId = _linkReaderIdentityIds[token][tokenId][\n i\n ];\n for (\n uint256 j = 0;\n j <\n _linkSignatureDates[token][tokenId][readerIdentityId].length;\n j++\n ) {\n uint256 signatureDate = _linkSignatureDates[token][tokenId][\n readerIdentityId\n ][j];\n linkKeys[n].readerIdentityId = readerIdentityId;\n linkKeys[n].signatureDate = signatureDate;\n n++;\n }\n }\n return linkKeys;\n }\n\n /// @notice Returns the list of link signature dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @return List of linked SBTs\n function getLinkSignatureDates(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId\n ) external view returns (uint256[] memory) {\n return _linkSignatureDates[token][tokenId][readerIdentityId];\n }\n\n /// @notice Returns the information of link dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @param signatureDate Signature date of the signature\n /// @return linkData List of linked SBTs\n function getLinkInfo(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId,\n uint256 signatureDate\n ) external view returns (LinkData memory) {\n return _links[token][tokenId][readerIdentityId][signatureDate];\n }\n\n /// @notice Returns the list of links for a given reader identity id\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @return List of links for the reader\n function getReaderLinks(uint256 readerIdentityId)\n public\n view\n returns (ReaderLink[] memory)\n {\n return _readerLinks[readerIdentityId];\n }\n\n /// @notice Validates the link of the given read link request and returns the\n /// data that reader can read if the link is valid\n /// @dev The token must be linked to this soul linker\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n /// @return True if the link is valid\n function validateLink(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n ) external view returns (bool) {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n LinkData memory link = _links[token][tokenId][readerIdentityId][\n signatureDate\n ];\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (!link.exists) revert LinkDoesNotExist();\n if (link.expirationDate < block.timestamp)\n revert ValidPeriodExpired(link.expirationDate);\n if (link.isRevoked) revert LinkAlreadyRevoked();\n\n return true;\n }\n\n /// @notice Returns the price for storing a link\n /// @dev Returns the current pricing for storing a link\n /// @param paymentMethod Address of token that user want to pay\n /// @param token Token that user want to store link\n /// @return Current price for storing a link\n function getPriceForAddLink(address paymentMethod, address token)\n public\n view\n returns (uint256)\n {\n uint256 addLinkPrice = ILinkableSBT(token).addLinkPrice();\n uint256 addLinkPriceMASA = ILinkableSBT(token).addLinkPriceMASA();\n if (addLinkPrice == 0 && addLinkPriceMASA == 0) {\n return 0;\n } else if (\n paymentMethod == masaToken &&\n enabledPaymentMethod[paymentMethod] &&\n addLinkPriceMASA > 0\n ) {\n // price in MASA without conversion rate\n return addLinkPriceMASA;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return addLinkPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, addLinkPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Link(uint256 readerIdentityId,uint256 ownerIdentityId,address token,uint256 tokenId,uint256 signatureDate,uint256 expirationDate)\"\n ),\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n )\n )\n );\n }\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address owner\n ) internal pure returns (bool) {\n return ECDSA.recover(digest, signature) == owner;\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event LinkAdded(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate\n );\n\n event LinkRevoked(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n );\n}\n" - }, - "contracts/interfaces/ILinkableSBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../tokens/SBT/ISBT.sol\";\n\ninterface ILinkableSBT is ISBT {\n function addLinkPrice() external view returns (uint256);\n\n function addLinkPriceMASA() external view returns (uint256);\n\n function queryLinkPrice() external view returns (uint256);\n\n function queryLinkPriceMASA() external view returns (uint256);\n}\n" - }, - "contracts/SoulboundIdentity.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\nimport \"./tokens/MasaSBTAuthority.sol\";\n\n/// @title Soulbound Identity\n/// @author Masa Finance\n/// @notice Soulbound token that represents an identity.\n/// @dev Soulbound identity, that inherits from the SBT contract.\ncontract SoulboundIdentity is\n MasaSBTAuthority,\n ISoulboundIdentity,\n ReentrancyGuard\n{\n /* ========== STATE VARIABLES =========================================== */\n\n ISoulName public soulName;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound identity\n /// @dev Creates a new soulbound identity, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n constructor(address admin, string memory baseTokenURI)\n MasaSBTAuthority(admin, \"Masa Identity\", \"MID\", baseTokenURI)\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulName contract address linked to this identity\n /// @dev The caller must have the admin role to call this function\n /// @param _soulName Address of the SoulName contract\n function setSoulName(ISoulName _soulName)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulName) == address(0)) revert ZeroAddress();\n if (soulName == _soulName) revert SameValue();\n soulName = _soulName;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new soulbound identity\n /// @dev The caller can only mint one identity per address\n /// @param to Address of the admin of the new identity\n function mint(address to) public override returns (uint256) {\n // Soulbound identity already created!\n if (balanceOf(to) > 0) revert IdentityAlreadyCreated(to);\n\n return _mintWithCounter(to);\n }\n\n /// @notice Mints a new soulbound identity with a SoulName associated to it\n /// @dev The caller can only mint one identity per address, and the name must be unique\n /// @param to Address of the admin of the new identity\n /// @param name Name of the new identity\n /// @param yearsPeriod Years of validity of the name\n /// @param _tokenURI URI of the NFT\n function mintIdentityWithName(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external override soulNameAlreadySet nonReentrant returns (uint256) {\n uint256 identityId = mint(to);\n soulName.mint(to, name, yearsPeriod, _tokenURI);\n\n return identityId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the address of the SoulName contract linked to this identity\n /// @dev This function returns the address of the SoulName contract linked to this identity\n /// @return Address of the SoulName contract\n function getSoulName() external view override returns (ISoulName) {\n return soulName;\n }\n\n /// @notice Returns the extension of the soul name\n /// @dev This function returns the extension of the soul name\n /// @return Extension of the soul name\n function getExtension() external view returns (string memory) {\n return soulName.getExtension();\n }\n\n /// @notice Returns the owner address of an identity\n /// @dev This function returns the owner address of the identity specified by the tokenId\n /// @param tokenId TokenId of the identity\n /// @return Address of the owner of the identity\n function ownerOf(uint256 tokenId)\n public\n view\n override(SBT, ISBT)\n returns (address)\n {\n return super.ownerOf(tokenId);\n }\n\n /// @notice Returns the owner address of a soul name\n /// @dev This function returns the owner address of the soul name identity specified by the name\n /// @param name Name of the soul name\n /// @return Address of the owner of the identity\n function ownerOf(string memory name)\n external\n view\n soulNameAlreadySet\n returns (address)\n {\n (, , uint256 identityId, , , ) = soulName.getTokenData(name);\n return super.ownerOf(identityId);\n }\n\n /// @notice Returns the URI of a soul name\n /// @dev This function returns the token URI of the soul name identity specified by the name\n /// @param name Name of the soul name\n /// @return URI of the identity associated to a soul name\n function tokenURI(string memory name)\n external\n view\n soulNameAlreadySet\n returns (string memory)\n {\n (, , uint256 identityId, , , ) = soulName.getTokenData(name);\n return super.tokenURI(identityId);\n }\n\n /// @notice Returns the URI of the owner of an identity\n /// @dev This function returns the token URI of the identity owned by an account\n /// @param owner Address of the owner of the identity\n /// @return URI of the identity owned by the account\n function tokenURI(address owner) external view returns (string memory) {\n uint256 tokenId = tokenOfOwner(owner);\n return super.tokenURI(tokenId);\n }\n\n /// @notice Returns the identity id of an account\n /// @dev This function returns the tokenId of the identity owned by an account\n /// @param owner Address of the owner of the identity\n /// @return TokenId of the identity owned by the account\n function tokenOfOwner(address owner)\n public\n view\n override\n returns (uint256)\n {\n return super.tokenOfOwnerByIndex(owner, 0);\n }\n\n /// @notice Checks if a soul name is available\n /// @dev This function queries if a soul name already exists and is in the available state\n /// @param name Name of the soul name\n /// @return available `true` if the soul name is available, `false` otherwise\n function isAvailable(string memory name)\n external\n view\n soulNameAlreadySet\n returns (bool available)\n {\n return soulName.isAvailable(name);\n }\n\n /// @notice Returns the information of a soul name\n /// @dev This function queries the information of a soul name\n /// @param name Name of the soul name\n /// @return sbtName Soul name, in upper/lower case and extension\n /// @return linked `true` if the soul name is linked, `false` otherwise\n /// @return identityId Identity id of the soul name\n /// @return tokenId SoulName id of the soul name\n /// @return expirationDate Expiration date of the soul name\n /// @return active `true` if the soul name is active, `false` otherwise\n function getTokenData(string memory name)\n external\n view\n soulNameAlreadySet\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n )\n {\n return soulName.getTokenData(name);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified account\n /// @param owner Address of the owner of the identities\n /// @return sbtNames Array of soul names associated to the account\n function getSoulNames(address owner)\n external\n view\n soulNameAlreadySet\n returns (string[] memory sbtNames)\n {\n return soulName.getSoulNames(owner);\n }\n\n // SoulName -> SoulboundIdentity.tokenId\n // SoulName -> account -> SoulboundIdentity.tokenId\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified identity Id\n /// @param tokenId TokenId of the identity\n /// @return sbtNames Array of soul names associated to the identity Id\n function getSoulNames(uint256 tokenId)\n external\n view\n soulNameAlreadySet\n returns (string[] memory sbtNames)\n {\n return soulName.getSoulNames(tokenId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /* ========== MODIFIERS ================================================= */\n\n modifier soulNameAlreadySet() {\n if (address(soulName) == address(0)) revert SoulNameContractNotSet();\n _;\n }\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/MasaSBTAuthority.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nimport \"./MasaSBT.sol\";\n\n/// @title MasaSBT\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBTAuthority is MasaSBT {\n /* ========== STATE VARIABLES =========================================== */\n\n using Counters for Counters.Counter;\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n Counters.Counter private _tokenIdCounter;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) MasaSBT(admin, name, symbol, baseTokenURI) {\n _grantRole(MINTER_ROLE, admin);\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n function _mintWithCounter(address to)\n internal\n virtual\n onlyRole(MINTER_ROLE)\n returns (uint256)\n {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _mint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/MasaSBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/ILinkableSBT.sol\";\nimport \"./SBT/SBT.sol\";\nimport \"./SBT/extensions/SBTEnumerable.sol\";\nimport \"./SBT/extensions/SBTBurnable.sol\";\n\n/// @title MasaSBT\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBT is\n SBT,\n SBTEnumerable,\n AccessControl,\n SBTBurnable,\n ILinkableSBT\n{\n /* ========== STATE VARIABLES =========================================== */\n\n using Strings for uint256;\n\n string private _baseTokenURI;\n\n uint256 public override addLinkPrice; // price in stable coin\n uint256 public override addLinkPriceMASA; // price in MASA\n uint256 public override queryLinkPrice; // price in stable coin\n uint256 public override queryLinkPriceMASA; // price in MASA\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) SBT(name, symbol) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n\n _baseTokenURI = baseTokenURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the price for adding the link in SoulLinker in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _addLinkPrice New price for adding the link in SoulLinker in stable coin\n function setAddLinkPrice(uint256 _addLinkPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (addLinkPrice == _addLinkPrice) revert SameValue();\n addLinkPrice = _addLinkPrice;\n }\n\n /// @notice Sets the price for adding the link in SoulLinker in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _addLinkPriceMASA New price for adding the link in SoulLinker in MASA\n function setAddLinkPriceMASA(uint256 _addLinkPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (addLinkPriceMASA == _addLinkPriceMASA) revert SameValue();\n addLinkPriceMASA = _addLinkPriceMASA;\n }\n\n /// @notice Sets the price for reading data in SoulLinker in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _queryLinkPrice New price for reading data in SoulLinker in stable coin\n function setQueryLinkPrice(uint256 _queryLinkPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (queryLinkPrice == _queryLinkPrice) revert SameValue();\n queryLinkPrice = _queryLinkPrice;\n }\n\n /// @notice Sets the price for reading data in SoulLinker in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _queryLinkPriceMASA New price for reading data in SoulLinker in MASA\n function setQueryLinkPriceMASA(uint256 _queryLinkPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (queryLinkPriceMASA == _queryLinkPriceMASA) revert SameValue();\n queryLinkPriceMASA = _queryLinkPriceMASA;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns true if the token exists\n /// @dev Returns true if the token has been minted\n /// @param tokenId Token to check\n /// @return True if the token exists\n function exists(uint256 tokenId) external view returns (bool) {\n return _exists(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId SBT to get the URI of\n /// @return URI of the SBT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\"))\n : \"\";\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(SBT, SBTEnumerable, AccessControl, IERC165)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override(SBT, SBTEnumerable) {\n super._beforeTokenTransfer(from, to, tokenId);\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/SBT/SBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\nimport \"./ISBT.sol\";\nimport \"./extensions/ISBTMetadata.sol\";\n\n/// @title SBT\n/// @author Masa Finance\n/// @notice Soulbound token is an NFT token that is not transferable.\ncontract SBT is Context, ERC165, ISBT, ISBTMetadata {\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165, IERC165)\n returns (bool)\n {\n return\n interfaceId == type(ISBT).interfaceId ||\n interfaceId == type(ISBTMetadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {ISBT-balanceOf}.\n */\n function balanceOf(address owner)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(owner != address(0), \"SBT: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {ISBT-ownerOf}.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n address owner = _owners[tokenId];\n require(owner != address(0), \"SBT: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {ISBTMetadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {ISBTMetadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {ISBTMetadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\n : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isOwner(address spender, uint256 tokenId)\n internal\n view\n virtual\n returns (bool)\n {\n address owner = SBT.ownerOf(tokenId);\n return (spender == owner);\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Mint} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"SBT: mint to the zero address\");\n require(!_exists(tokenId), \"SBT: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Mint(to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n *\n * Requirements:\n * - `tokenId` must exist.\n *\n * Emits a {Burn} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = SBT.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Burn(owner, tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"SBT: invalid token ID\");\n }\n\n /**\n * @dev Hook that is called before any token minting/burning\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address,\n address,\n uint256\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any minting/burning of tokens\n *\n * Calling conditions:\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address,\n address,\n uint256\n ) internal virtual {}\n}\n" - }, - "contracts/tokens/SBT/extensions/SBTEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../SBT.sol\";\nimport \"./ISBTEnumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {SBT} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract SBTEnumerable is SBT, ISBTEnumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, SBT)\n returns (bool)\n {\n return\n interfaceId == type(ISBTEnumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {ISBTEnumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(\n index < SBT.balanceOf(owner),\n \"SBTEnumerable: owner index out of bounds\"\n );\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {ISBTEnumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {ISBTEnumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(\n index < SBTEnumerable.totalSupply(),\n \"SBTEnumerable: global index out of bounds\"\n );\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = SBT.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)\n private\n {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = SBT.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" - }, - "contracts/tokens/SBT/extensions/SBTBurnable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\nimport \"../SBT.sol\";\n\n/**\n * @title SBT Burnable Token\n * @dev SBT Token that can be burned (destroyed).\n */\nabstract contract SBTBurnable is Context, SBT {\n /**\n * @dev Burns `tokenId`. See {SBT-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(\n _isOwner(_msgSender(), tokenId),\n \"SBT: caller is not token owner\"\n );\n _burn(tokenId);\n }\n}\n" - }, - "contracts/tokens/SBT/extensions/ISBTMetadata.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../ISBT.sol\";\n\n/**\n * @title SBT Soulbound Token Standard, optional metadata extension\n */\ninterface ISBTMetadata is ISBT {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "contracts/tokens/SBT/extensions/ISBTEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../ISBT.sol\";\n\n/**\n * @title SBT Soulbound Token Standard, optional enumeration extension\n */\ninterface ISBTEnumerable is ISBT {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" - }, - "contracts/SoulboundCreditScore.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./tokens/MasaSBTSelfSovereign.sol\";\n\n/// @title Soulbound Credit Score\n/// @author Masa Finance\n/// @notice Soulbound token that represents a credit score.\n/// @dev Soulbound credit score, that inherits from the SBT contract.\ncontract SoulboundCreditScore is MasaSBTSelfSovereign, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound credit score\n /// @dev Creates a new soulbound credit score, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory baseTokenURI,\n ISoulboundIdentity soulboundIdentity,\n PaymentParams memory paymentParams\n )\n MasaSBTSelfSovereign(\n admin,\n \"Masa Credit Score\",\n \"MCS\",\n baseTokenURI,\n soulboundIdentity,\n paymentParams\n )\n EIP712(\"SoulboundCreditScore\", \"1.0.0\")\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param identityId TokenId of the identity to mint the NFT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The NFT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) public payable virtual nonReentrant returns (uint256) {\n address to = soulboundIdentity.ownerOf(identityId);\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n if (balanceOf(to) > 0) revert CreditScoreAlreadyCreated(to);\n\n _verify(\n _hash(identityId, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit SoulboundCreditScoreMintedToIdentity(\n tokenId,\n identityId,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param to The address to mint the SBT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The SBT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) external payable virtual returns (uint256) {\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n if (balanceOf(to) > 0) revert CreditScoreAlreadyCreated(to);\n\n _verify(\n _hash(to, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit SoulboundCreditScoreMintedToAddress(\n tokenId,\n to,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintCreditScore(uint256 identityId,address authorityAddress,uint256 signatureDate)\"\n ),\n identityId,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n function _hash(\n address to,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintCreditScore(address to,address authorityAddress,uint256 signatureDate)\"\n ),\n to,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event SoulboundCreditScoreMintedToIdentity(\n uint256 tokenId,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n\n event SoulboundCreditScoreMintedToAddress(\n uint256 tokenId,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n}\n" - }, - "contracts/tokens/MasaSBTSelfSovereign.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/ISoulboundIdentity.sol\";\nimport \"../dex/PaymentGateway.sol\";\nimport \"./MasaSBT.sol\";\n\n/// @title MasaSBTSelfSovereign\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// Adds a link to a SoulboundIdentity SC to let minting using the identityId\n/// Adds a payment gateway to let minting paying a fee\n/// Adds a self-sovereign protocol to let minting using an authority signature\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBTSelfSovereign is PaymentGateway, MasaSBT, EIP712 {\n /* ========== STATE VARIABLES =========================================== */\n\n using Counters for Counters.Counter;\n\n Counters.Counter private _tokenIdCounter;\n\n ISoulboundIdentity public soulboundIdentity;\n\n uint256 public mintPrice; // price in stable coin\n uint256 public mintPriceMASA; // price in MASA\n\n mapping(address => bool) public authorities;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI,\n ISoulboundIdentity _soulboundIdentity,\n PaymentParams memory paymentParams\n )\n PaymentGateway(admin, paymentParams)\n MasaSBT(admin, name, symbol, baseTokenURI)\n {\n soulboundIdentity = _soulboundIdentity;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this SBT\n /// @dev The caller must be the admin to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the price of minting in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _mintPrice New price of minting in stable coin\n function setMintPrice(uint256 _mintPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (mintPrice == _mintPrice) revert SameValue();\n mintPrice = _mintPrice;\n }\n\n /// @notice Sets the price of minting in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _mintPriceMASA New price of minting in MASA\n function setMintPriceMASA(uint256 _mintPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (mintPriceMASA == _mintPriceMASA) revert SameValue();\n mintPriceMASA = _mintPriceMASA;\n }\n\n /// @notice Adds a new authority to the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority New authority to add\n function addAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (authorities[_authority]) revert AlreadyAdded();\n\n authorities[_authority] = true;\n }\n\n /// @notice Removes an authority from the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority Authority to remove\n function removeAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\n\n authorities[_authority] = false;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the identityId owned by the given token\n /// @param tokenId Id of the token\n /// @return Id of the identity\n function getIdentityId(uint256 tokenId) external view returns (uint256) {\n if (soulboundIdentity == ISoulboundIdentity(address(0)))\n revert NotLinkedToAnIdentitySBT();\n\n address owner = super.ownerOf(tokenId);\n return soulboundIdentity.tokenOfOwner(owner);\n }\n\n /// @notice Returns the price for minting\n /// @dev Returns current pricing for minting\n /// @param paymentMethod Address of token that user want to pay\n /// @return Current price for minting in the given payment method\n function getMintPrice(address paymentMethod) public view returns (uint256) {\n if (mintPrice == 0 && mintPriceMASA == 0) {\n return 0;\n } else if (\n paymentMethod == masaToken &&\n enabledPaymentMethod[paymentMethod] &&\n mintPriceMASA > 0\n ) {\n // price in MASA without conversion rate\n return mintPriceMASA;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return mintPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, mintPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(AccessControl, MasaSBT)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address signer\n ) internal view {\n address _signer = ECDSA.recover(digest, signature);\n if (_signer != signer) revert InvalidSignature();\n if (!authorities[_signer]) revert NotAuthorized(_signer);\n }\n\n function _mintWithCounter(address to) internal virtual returns (uint256) {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _mint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/Soulbound2FA.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./tokens/MasaSBTSelfSovereign.sol\";\n\n/// @title Soulbound Two-factor authentication (2FA)\n/// @author Masa Finance\n/// @notice Soulbound token that represents a Two-factor authentication (2FA)\n/// @dev Soulbound 2FA, that inherits from the SBT contract.\ncontract Soulbound2FA is MasaSBTSelfSovereign, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound Two-factor authentication (2FA)\n /// @dev Creates a new soulbound 2FA, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory baseTokenURI,\n ISoulboundIdentity soulboundIdentity,\n PaymentParams memory paymentParams\n )\n MasaSBTSelfSovereign(\n admin,\n \"Masa 2FA\",\n \"M2F\",\n baseTokenURI,\n soulboundIdentity,\n paymentParams\n )\n EIP712(\"Soulbound2FA\", \"1.0.0\")\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param identityId TokenId of the identity to mint the NFT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The NFT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) public payable virtual nonReentrant returns (uint256) {\n address to = soulboundIdentity.ownerOf(identityId);\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n\n _verify(\n _hash(identityId, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit Soulbound2FAMintedToIdentity(\n tokenId,\n identityId,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param to The address to mint the SBT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The SBT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) external payable virtual returns (uint256) {\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n\n _verify(\n _hash(to, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit Soulbound2FAMintedToAddress(\n tokenId,\n to,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Mint2FA(uint256 identityId,address authorityAddress,uint256 signatureDate)\"\n ),\n identityId,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n function _hash(\n address to,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Mint2FA(address to,address authorityAddress,uint256 signatureDate)\"\n ),\n to,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event Soulbound2FAMintedToIdentity(\n uint256 tokenId,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n\n event Soulbound2FAMintedToAddress(\n uint256 tokenId,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 1, - "details": { - "yul": false - } - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates", - "devdoc", - "userdoc" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/mumbai/.chainId b/deployments/mumbai/.chainId deleted file mode 100644 index d7e2f72ce..000000000 --- a/deployments/mumbai/.chainId +++ /dev/null @@ -1 +0,0 @@ -80001 \ No newline at end of file diff --git a/deployments/mumbai/Soulbound2FA.json b/deployments/mumbai/Soulbound2FA.json deleted file mode 100644 index 1b4715542..000000000 --- a/deployments/mumbai/Soulbound2FA.json +++ /dev/null @@ -1,1938 +0,0 @@ -{ - "address": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "admin", - "type": "address" - }, - { - "internalType": "string", - "name": "baseTokenURI", - "type": "string" - }, - { - "internalType": "contract ISoulboundIdentity", - "name": "soulboundIdentity", - "type": "address" - }, - { - "components": [ - { - "internalType": "address", - "name": "swapRouter", - "type": "address" - }, - { - "internalType": "address", - "name": "wrappedNativeToken", - "type": "address" - }, - { - "internalType": "address", - "name": "stableCoin", - "type": "address" - }, - { - "internalType": "address", - "name": "masaToken", - "type": "address" - }, - { - "internalType": "address", - "name": "reserveWallet", - "type": "address" - } - ], - "internalType": "struct PaymentGateway.PaymentParams", - "name": "paymentParams", - "type": "tuple" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "AlreadyAdded", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "AuthorityNotExists", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "caller", - "type": "address" - } - ], - "name": "CallerNotOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "InsufficientEthAmount", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - } - ], - "name": "InvalidPaymentMethod", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidSignature", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - } - ], - "name": "InvalidToken", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "erc20token", - "type": "address" - } - ], - "name": "NonExistingErc20Token", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "signer", - "type": "address" - } - ], - "name": "NotAuthorized", - "type": "error" - }, - { - "inputs": [], - "name": "NotLinkedToAnIdentitySBT", - "type": "error" - }, - { - "inputs": [], - "name": "RefundFailed", - "type": "error" - }, - { - "inputs": [], - "name": "SameValue", - "type": "error" - }, - { - "inputs": [], - "name": "TransferFailed", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "Burn", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - } - ], - "name": "Soulbound2FAMintedToAddress", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "identityId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "mintPrice", - "type": "uint256" - } - ], - "name": "Soulbound2FAMintedToIdentity", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_authority", - "type": "address" - } - ], - "name": "addAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "addLinkPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "addLinkPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "authorities", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_paymentMethod", - "type": "address" - } - ], - "name": "disablePaymentMethod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_paymentMethod", - "type": "address" - } - ], - "name": "enablePaymentMethod", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "enabledPaymentMethod", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "enabledPaymentMethods", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "exists", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getEnabledPaymentMethods", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getIdentityId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - } - ], - "name": "getMintPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "masaToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "internalType": "uint256", - "name": "identityId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "paymentMethod", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "address", - "name": "authorityAddress", - "type": "address" - }, - { - "internalType": "uint256", - "name": "signatureDate", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "mintPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "mintPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "queryLinkPrice", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "queryLinkPriceMASA", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_authority", - "type": "address" - } - ], - "name": "removeAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "reserveWallet", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_addLinkPrice", - "type": "uint256" - } - ], - "name": "setAddLinkPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_addLinkPriceMASA", - "type": "uint256" - } - ], - "name": "setAddLinkPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_masaToken", - "type": "address" - } - ], - "name": "setMasaToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintPrice", - "type": "uint256" - } - ], - "name": "setMintPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_mintPriceMASA", - "type": "uint256" - } - ], - "name": "setMintPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_queryLinkPrice", - "type": "uint256" - } - ], - "name": "setQueryLinkPrice", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_queryLinkPriceMASA", - "type": "uint256" - } - ], - "name": "setQueryLinkPriceMASA", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_reserveWallet", - "type": "address" - } - ], - "name": "setReserveWallet", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract ISoulboundIdentity", - "name": "_soulboundIdentity", - "type": "address" - } - ], - "name": "setSoulboundIdentity", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_stableCoin", - "type": "address" - } - ], - "name": "setStableCoin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_swapRouter", - "type": "address" - } - ], - "name": "setSwapRouter", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_wrappedNativeToken", - "type": "address" - } - ], - "name": "setWrappedNativeToken", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "soulboundIdentity", - "outputs": [ - { - "internalType": "contract ISoulboundIdentity", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "stableCoin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "swapRouter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenOfOwnerByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "wrappedNativeToken", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "transactionHash": "0xe134b3c530b2a956331d39c715c13e208319c90b5fbc4ddd0e314684c51eb2c3", - "receipt": { - "to": null, - "from": "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28", - "contractAddress": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "transactionIndex": 1, - "gasUsed": "3604830", - "logsBloom": "0x00000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000200000000000000000000000000000000000000020800000000000000000000100000000004000000000020000000000000000000800000000000000000080000000000000000000000000000000000000000000000020000080000080000000000000000000200000000000000000000000000000000000000000000000001000000000004000000400000000000001000000000000000000000000000100100040000024000000000000000000000000000000000000000000000000000000000000100000", - "blockHash": "0xcf89f10d537baf63d457ab72701f6683b01555e62fe9efc1b468a5b8b31798c4", - "transactionHash": "0xe134b3c530b2a956331d39c715c13e208319c90b5fbc4ddd0e314684c51eb2c3", - "logs": [ - { - "transactionIndex": 1, - "blockNumber": 31599244, - "transactionHash": "0xe134b3c530b2a956331d39c715c13e208319c90b5fbc4ddd0e314684c51eb2c3", - "address": "0x6F89e72570089799A4FCBfC66790e5726d5c7F6a", - "topics": [ - "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28" - ], - "data": "0x", - "logIndex": 5, - "blockHash": "0xcf89f10d537baf63d457ab72701f6683b01555e62fe9efc1b468a5b8b31798c4" - }, - { - "transactionIndex": 1, - "blockNumber": 31599244, - "transactionHash": "0xe134b3c530b2a956331d39c715c13e208319c90b5fbc4ddd0e314684c51eb2c3", - "address": "0x0000000000000000000000000000000000001010", - "topics": [ - "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", - "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x00000000000000000000000046c9cda3f83c5c13c767a07b6e80aed302e40b28", - "0x000000000000000000000000be188d6641e8b680743a4815dfa0f6208038960f" - ], - "data": "0x00000000000000000000000000000000000000000000000002204b62c97249e600000000000000000000000000000000000000000000000006f45c2bb35a1f800000000000000000000000000000000000000000000029689694aa24ef4c416e00000000000000000000000000000000000000000000000004d410c8e9e7d59a00000000000000000000000000000000000000000000296898b4f587b8be8b54", - "logIndex": 6, - "blockHash": "0xcf89f10d537baf63d457ab72701f6683b01555e62fe9efc1b468a5b8b31798c4" - } - ], - "blockNumber": 31599244, - "cumulativeGasUsed": "3746186", - "status": 1, - "byzantium": true - }, - "args": [ - "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28", - "https://beta.metadata.masa.finance/v1.0/2fa/", - "0x0000000000000000000000000000000000000000", - [ - "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", - "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", - "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747", - "0xd393b1E02dA9831Ff419e22eA105aAe4c47E1253", - "0x46c9cdA3F83C5c13C767A07b6E80aEd302E40B28" - ] - ], - "numDeployments": 1, - "solcInputHash": "ba20b0945b3d8227cd3974f83be2ddaf", - "metadata": "{\"compiler\":{\"version\":\"0.8.7+commit.e28d00a7\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"baseTokenURI\",\"type\":\"string\"},{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"soulboundIdentity\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"swapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wrappedNativeToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stableCoin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"masaToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"reserveWallet\",\"type\":\"address\"}],\"internalType\":\"struct PaymentGateway.PaymentParams\",\"name\":\"paymentParams\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"authority\",\"type\":\"address\"}],\"name\":\"AuthorityNotExists\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"}],\"name\":\"CallerNotOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"InsufficientEthAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"}],\"name\":\"InvalidPaymentMethod\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSignature\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"InvalidToken\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"erc20token\",\"type\":\"address\"}],\"name\":\"NonExistingErc20Token\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"}],\"name\":\"NotAuthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotLinkedToAnIdentitySBT\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RefundFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SameValue\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TransferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"}],\"name\":\"Mint\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"}],\"name\":\"Soulbound2FAMintedToAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"identityId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"mintPrice\",\"type\":\"uint256\"}],\"name\":\"Soulbound2FAMintedToIdentity\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authority\",\"type\":\"address\"}],\"name\":\"addAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addLinkPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addLinkPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"authorities\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_paymentMethod\",\"type\":\"address\"}],\"name\":\"disablePaymentMethod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_paymentMethod\",\"type\":\"address\"}],\"name\":\"enablePaymentMethod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"enabledPaymentMethod\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"enabledPaymentMethods\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEnabledPaymentMethods\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getIdentityId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"}],\"name\":\"getMintPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"masaToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"identityId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"paymentMethod\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorityAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signatureDate\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"queryLinkPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"queryLinkPriceMASA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_authority\",\"type\":\"address\"}],\"name\":\"removeAuthority\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reserveWallet\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_addLinkPrice\",\"type\":\"uint256\"}],\"name\":\"setAddLinkPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_addLinkPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setAddLinkPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_masaToken\",\"type\":\"address\"}],\"name\":\"setMasaToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintPrice\",\"type\":\"uint256\"}],\"name\":\"setMintPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_mintPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setMintPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_queryLinkPrice\",\"type\":\"uint256\"}],\"name\":\"setQueryLinkPrice\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_queryLinkPriceMASA\",\"type\":\"uint256\"}],\"name\":\"setQueryLinkPriceMASA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_reserveWallet\",\"type\":\"address\"}],\"name\":\"setReserveWallet\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"_soulboundIdentity\",\"type\":\"address\"}],\"name\":\"setSoulboundIdentity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_stableCoin\",\"type\":\"address\"}],\"name\":\"setStableCoin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_swapRouter\",\"type\":\"address\"}],\"name\":\"setSwapRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wrappedNativeToken\",\"type\":\"address\"}],\"name\":\"setWrappedNativeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"soulboundIdentity\",\"outputs\":[{\"internalType\":\"contract ISoulboundIdentity\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stableCoin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wrappedNativeToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Masa Finance\",\"details\":\"Soulbound 2FA, that inherits from the SBT contract.\",\"kind\":\"dev\",\"methods\":{\"addAuthority(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_authority\":\"New authority to add\"}},\"balanceOf(address)\":{\"details\":\"See {ISBT-balanceOf}.\"},\"burn(uint256)\":{\"details\":\"Burns `tokenId`. See {SBT-_burn}. Requirements: - The caller must own `tokenId` or be an approved operator.\"},\"constructor\":{\"details\":\"Creates a new soulbound 2FA, inheriting from the SBT contract.\",\"params\":{\"admin\":\"Administrator of the smart contract\",\"baseTokenURI\":\"Base URI of the token\",\"paymentParams\":\"Payment gateway params\",\"soulboundIdentity\":\"Address of the SoulboundIdentity contract\"}},\"disablePaymentMethod(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_paymentMethod\":\"Token to remove\"}},\"enablePaymentMethod(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_paymentMethod\":\"New token to add\"}},\"exists(uint256)\":{\"details\":\"Returns true if the token has been minted\",\"params\":{\"tokenId\":\"Token to check\"},\"returns\":{\"_0\":\"True if the token exists\"}},\"getEnabledPaymentMethods()\":{\"details\":\"Returns the address of all available payment methods\",\"returns\":{\"_0\":\"Array of all enabled payment methods\"}},\"getIdentityId(uint256)\":{\"params\":{\"tokenId\":\"Id of the token\"},\"returns\":{\"_0\":\"Id of the identity\"}},\"getMintPrice(address)\":{\"details\":\"Returns current pricing for minting\",\"params\":{\"paymentMethod\":\"Address of token that user want to pay\"},\"returns\":{\"_0\":\"Current price for minting in the given payment method\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"mint(address,address,address,uint256,bytes)\":{\"details\":\"The caller must have the MINTER role\",\"params\":{\"authorityAddress\":\"Address of the authority that signed the message\",\"paymentMethod\":\"Address of token that user want to pay\",\"signature\":\"Signature of the message\",\"signatureDate\":\"Date of the signature\",\"to\":\"The address to mint the SBT to\"},\"returns\":{\"_0\":\"The SBT ID of the newly minted SBT\"}},\"mint(address,uint256,address,uint256,bytes)\":{\"details\":\"The caller must have the MINTER role\",\"params\":{\"authorityAddress\":\"Address of the authority that signed the message\",\"identityId\":\"TokenId of the identity to mint the NFT to\",\"paymentMethod\":\"Address of token that user want to pay\",\"signature\":\"Signature of the message\",\"signatureDate\":\"Date of the signature\"},\"returns\":{\"_0\":\"The NFT ID of the newly minted SBT\"}},\"name()\":{\"details\":\"See {ISBTMetadata-name}.\"},\"ownerOf(uint256)\":{\"details\":\"See {ISBT-ownerOf}.\"},\"removeAuthority(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_authority\":\"Authority to remove\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setAddLinkPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_addLinkPrice\":\"New price for adding the link in SoulLinker in stable coin\"}},\"setAddLinkPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_addLinkPriceMASA\":\"New price for adding the link in SoulLinker in MASA\"}},\"setMasaToken(address)\":{\"details\":\"The caller must have the admin role to call this function It can be set to address(0) to disable paying in MASA\",\"params\":{\"_masaToken\":\"New utility token to pay the fee in\"}},\"setMintPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_mintPrice\":\"New price of minting in stable coin\"}},\"setMintPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_mintPriceMASA\":\"New price of minting in MASA\"}},\"setQueryLinkPrice(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_queryLinkPrice\":\"New price for reading data in SoulLinker in stable coin\"}},\"setQueryLinkPriceMASA(uint256)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_queryLinkPriceMASA\":\"New price for reading data in SoulLinker in MASA\"}},\"setReserveWallet(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_reserveWallet\":\"New reserve wallet\"}},\"setSoulboundIdentity(address)\":{\"details\":\"The caller must be the admin to call this function\",\"params\":{\"_soulboundIdentity\":\"Address of the SoulboundIdentity contract\"}},\"setStableCoin(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_stableCoin\":\"New stable coin to pay the fee in\"}},\"setSwapRouter(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_swapRouter\":\"New swap router address\"}},\"setWrappedNativeToken(address)\":{\"details\":\"The caller must have the admin role to call this function\",\"params\":{\"_wrappedNativeToken\":\"New wrapped native token address\"}},\"supportsInterface(bytes4)\":{\"details\":\"Interface identification is specified in ERC-165.\",\"params\":{\"interfaceId\":\"The interface identifier, as specified in ERC-165\"},\"returns\":{\"_0\":\"`true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise\"}},\"symbol()\":{\"details\":\"See {ISBTMetadata-symbol}.\"},\"tokenByIndex(uint256)\":{\"details\":\"See {ISBTEnumerable-tokenByIndex}.\"},\"tokenOfOwnerByIndex(address,uint256)\":{\"details\":\"See {ISBTEnumerable-tokenOfOwnerByIndex}.\"},\"tokenURI(uint256)\":{\"details\":\"Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the \\\"ERC721 Metadata JSON Schema\\\".\",\"params\":{\"tokenId\":\"SBT to get the URI of\"},\"returns\":{\"_0\":\"URI of the SBT\"}},\"totalSupply()\":{\"details\":\"See {ISBTEnumerable-totalSupply}.\"}},\"title\":\"Soulbound Two-factor authentication (2FA)\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addAuthority(address)\":{\"notice\":\"Adds a new authority to the list of authorities\"},\"constructor\":{\"notice\":\"Creates a new soulbound Two-factor authentication (2FA)\"},\"disablePaymentMethod(address)\":{\"notice\":\"Removes a token as a valid payment method\"},\"enablePaymentMethod(address)\":{\"notice\":\"Adds a new token as a valid payment method\"},\"exists(uint256)\":{\"notice\":\"Returns true if the token exists\"},\"getEnabledPaymentMethods()\":{\"notice\":\"Returns all available payment methods\"},\"getIdentityId(uint256)\":{\"notice\":\"Returns the identityId owned by the given token\"},\"getMintPrice(address)\":{\"notice\":\"Returns the price for minting\"},\"mint(address,address,address,uint256,bytes)\":{\"notice\":\"Mints a new SBT\"},\"mint(address,uint256,address,uint256,bytes)\":{\"notice\":\"Mints a new SBT\"},\"removeAuthority(address)\":{\"notice\":\"Removes an authority from the list of authorities\"},\"setAddLinkPrice(uint256)\":{\"notice\":\"Sets the price for adding the link in SoulLinker in stable coin\"},\"setAddLinkPriceMASA(uint256)\":{\"notice\":\"Sets the price for adding the link in SoulLinker in MASA\"},\"setMasaToken(address)\":{\"notice\":\"Sets the utility token to pay the fee in (MASA)\"},\"setMintPrice(uint256)\":{\"notice\":\"Sets the price of minting in stable coin\"},\"setMintPriceMASA(uint256)\":{\"notice\":\"Sets the price of minting in MASA\"},\"setQueryLinkPrice(uint256)\":{\"notice\":\"Sets the price for reading data in SoulLinker in stable coin\"},\"setQueryLinkPriceMASA(uint256)\":{\"notice\":\"Sets the price for reading data in SoulLinker in MASA\"},\"setReserveWallet(address)\":{\"notice\":\"Set the reserve wallet\"},\"setSoulboundIdentity(address)\":{\"notice\":\"Sets the SoulboundIdentity contract address linked to this SBT\"},\"setStableCoin(address)\":{\"notice\":\"Sets the stable coin to pay the fee in (USDC)\"},\"setSwapRouter(address)\":{\"notice\":\"Sets the swap router address\"},\"setWrappedNativeToken(address)\":{\"notice\":\"Sets the wrapped native token address\"},\"supportsInterface(bytes4)\":{\"notice\":\"Query if a contract implements an interface\"},\"tokenURI(uint256)\":{\"notice\":\"A distinct Uniform Resource Identifier (URI) for a given asset.\"}},\"notice\":\"Soulbound token that represents a Two-factor authentication (2FA)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Soulbound2FA.sol\":\"Soulbound2FA\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"details\":{\"constantOptimizer\":true,\"cse\":true,\"deduplicate\":true,\"inliner\":true,\"jumpdestRemover\":true,\"orderLiterals\":true,\"peephole\":true,\"yul\":false},\"runs\":1},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControl.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\nimport \\\"../utils/Strings.sol\\\";\\nimport \\\"../utils/introspection/ERC165.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n Strings.toHexString(uint160(account), 20),\\n \\\" is missing role \\\",\\n Strings.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5b35d8e68aeaccc685239bd9dd79b9ba01a0357930f8a3307ab85511733d9724\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/IAccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControl {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Counters.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title Counters\\n * @author Matt Condon (@shrugs)\\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\\n *\\n * Include with `using Counters for Counters.Counter;`\\n */\\nlibrary Counters {\\n struct Counter {\\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\\n // this feature: see https://github.com/ethereum/solidity/issues/4637\\n uint256 _value; // default: 0\\n }\\n\\n function current(Counter storage counter) internal view returns (uint256) {\\n return counter._value;\\n }\\n\\n function increment(Counter storage counter) internal {\\n unchecked {\\n counter._value += 1;\\n }\\n }\\n\\n function decrement(Counter storage counter) internal {\\n uint256 value = counter._value;\\n require(value > 0, \\\"Counter: decrement overflow\\\");\\n unchecked {\\n counter._value = value - 1;\\n }\\n }\\n\\n function reset(Counter storage counter) internal {\\n counter._value = 0;\\n }\\n}\\n\",\"keccak256\":\"0xf0018c2440fbe238dd3a8732fa8e17a0f9dce84d31451dc8a32f6d62b349c9f1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0xdb7f5c28fc61cda0bd8ab60ce288e206b791643bcd3ba464a70cbec18895a2f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./ECDSA.sol\\\";\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\\n *\\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\\n *\\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\\n * ({_hashTypedDataV4}).\\n *\\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\\n * the chain id to protect against replay attacks on an eventual fork of the chain.\\n *\\n * NOTE: This contract implements the version of the encoding known as \\\"v4\\\", as implemented by the JSON RPC method\\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\\n *\\n * _Available since v3.4._\\n */\\nabstract contract EIP712 {\\n /* solhint-disable var-name-mixedcase */\\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\\n // invalidate the cached domain separator if the chain id changes.\\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\\n uint256 private immutable _CACHED_CHAIN_ID;\\n address private immutable _CACHED_THIS;\\n\\n bytes32 private immutable _HASHED_NAME;\\n bytes32 private immutable _HASHED_VERSION;\\n bytes32 private immutable _TYPE_HASH;\\n\\n /* solhint-enable var-name-mixedcase */\\n\\n /**\\n * @dev Initializes the domain separator and parameter caches.\\n *\\n * The meaning of `name` and `version` is specified in\\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\\n *\\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\\n * - `version`: the current major version of the signing domain.\\n *\\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\\n * contract upgrade].\\n */\\n constructor(string memory name, string memory version) {\\n bytes32 hashedName = keccak256(bytes(name));\\n bytes32 hashedVersion = keccak256(bytes(version));\\n bytes32 typeHash = keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n );\\n _HASHED_NAME = hashedName;\\n _HASHED_VERSION = hashedVersion;\\n _CACHED_CHAIN_ID = block.chainid;\\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\\n _CACHED_THIS = address(this);\\n _TYPE_HASH = typeHash;\\n }\\n\\n /**\\n * @dev Returns the domain separator for the current chain.\\n */\\n function _domainSeparatorV4() internal view returns (bytes32) {\\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\\n return _CACHED_DOMAIN_SEPARATOR;\\n } else {\\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\\n }\\n }\\n\\n function _buildDomainSeparator(\\n bytes32 typeHash,\\n bytes32 nameHash,\\n bytes32 versionHash\\n ) private view returns (bytes32) {\\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\\n }\\n\\n /**\\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\\n * function returns the hash of the fully encoded EIP712 message for this domain.\\n *\\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\\n *\\n * ```solidity\\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\\n * keccak256(\\\"Mail(address to,string contents)\\\"),\\n * mailTo,\\n * keccak256(bytes(mailContents))\\n * )));\\n * address signer = ECDSA.recover(digest, signature);\\n * ```\\n */\\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\\n }\\n}\\n\",\"keccak256\":\"0x6688fad58b9ec0286d40fa957152e575d5d8bd4c3aa80985efdb11b44f776ae7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165 is IERC165 {\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165).interfaceId;\\n }\\n}\\n\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n// CAUTION\\n// This version of SafeMath should only be used with Solidity 0.8 or later,\\n// because it relies on the compiler's built in overflow checks.\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations.\\n *\\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\\n * now has built in overflow checking.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a * b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator.\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(\\n uint256 a,\\n uint256 b,\\n string memory errorMessage\\n ) internal pure returns (uint256) {\\n unchecked {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0f633a0223d9a1dcccfcf38a64c9de0874dfcbfac0c6941ccf074d63a2ce0e1e\",\"license\":\"MIT\"},\"contracts/Soulbound2FA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\nimport \\\"./libraries/Errors.sol\\\";\\nimport \\\"./tokens/MasaSBTSelfSovereign.sol\\\";\\n\\n/// @title Soulbound Two-factor authentication (2FA)\\n/// @author Masa Finance\\n/// @notice Soulbound token that represents a Two-factor authentication (2FA)\\n/// @dev Soulbound 2FA, that inherits from the SBT contract.\\ncontract Soulbound2FA is MasaSBTSelfSovereign, ReentrancyGuard {\\n /* ========== STATE VARIABLES =========================================== */\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound Two-factor authentication (2FA)\\n /// @dev Creates a new soulbound 2FA, inheriting from the SBT contract.\\n /// @param admin Administrator of the smart contract\\n /// @param baseTokenURI Base URI of the token\\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\\n /// @param paymentParams Payment gateway params\\n constructor(\\n address admin,\\n string memory baseTokenURI,\\n ISoulboundIdentity soulboundIdentity,\\n PaymentParams memory paymentParams\\n )\\n MasaSBTSelfSovereign(\\n admin,\\n \\\"Masa 2FA\\\",\\n \\\"M2F\\\",\\n baseTokenURI,\\n soulboundIdentity,\\n paymentParams\\n )\\n EIP712(\\\"Soulbound2FA\\\", \\\"1.0.0\\\")\\n {}\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /// @notice Mints a new SBT\\n /// @dev The caller must have the MINTER role\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param identityId TokenId of the identity to mint the NFT to\\n /// @param authorityAddress Address of the authority that signed the message\\n /// @param signatureDate Date of the signature\\n /// @param signature Signature of the message\\n /// @return The NFT ID of the newly minted SBT\\n function mint(\\n address paymentMethod,\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate,\\n bytes calldata signature\\n ) public payable virtual nonReentrant returns (uint256) {\\n address to = soulboundIdentity.ownerOf(identityId);\\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\\n\\n _verify(\\n _hash(identityId, authorityAddress, signatureDate),\\n signature,\\n authorityAddress\\n );\\n\\n _pay(paymentMethod, getMintPrice(paymentMethod));\\n\\n uint256 tokenId = _mintWithCounter(to);\\n\\n emit Soulbound2FAMintedToIdentity(\\n tokenId,\\n identityId,\\n authorityAddress,\\n signatureDate,\\n paymentMethod,\\n mintPrice\\n );\\n\\n return tokenId;\\n }\\n\\n /// @notice Mints a new SBT\\n /// @dev The caller must have the MINTER role\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param to The address to mint the SBT to\\n /// @param authorityAddress Address of the authority that signed the message\\n /// @param signatureDate Date of the signature\\n /// @param signature Signature of the message\\n /// @return The SBT ID of the newly minted SBT\\n function mint(\\n address paymentMethod,\\n address to,\\n address authorityAddress,\\n uint256 signatureDate,\\n bytes calldata signature\\n ) external payable virtual returns (uint256) {\\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\\n\\n _verify(\\n _hash(to, authorityAddress, signatureDate),\\n signature,\\n authorityAddress\\n );\\n\\n _pay(paymentMethod, getMintPrice(paymentMethod));\\n\\n uint256 tokenId = _mintWithCounter(to);\\n\\n emit Soulbound2FAMintedToAddress(\\n tokenId,\\n to,\\n authorityAddress,\\n signatureDate,\\n paymentMethod,\\n mintPrice\\n );\\n\\n return tokenId;\\n }\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _hash(\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate\\n ) internal view returns (bytes32) {\\n return\\n _hashTypedDataV4(\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Mint2FA(uint256 identityId,address authorityAddress,uint256 signatureDate)\\\"\\n ),\\n identityId,\\n authorityAddress,\\n signatureDate\\n )\\n )\\n );\\n }\\n\\n function _hash(\\n address to,\\n address authorityAddress,\\n uint256 signatureDate\\n ) internal view returns (bytes32) {\\n return\\n _hashTypedDataV4(\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Mint2FA(address to,address authorityAddress,uint256 signatureDate)\\\"\\n ),\\n to,\\n authorityAddress,\\n signatureDate\\n )\\n )\\n );\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n\\n event Soulbound2FAMintedToIdentity(\\n uint256 tokenId,\\n uint256 identityId,\\n address authorityAddress,\\n uint256 signatureDate,\\n address paymentMethod,\\n uint256 mintPrice\\n );\\n\\n event Soulbound2FAMintedToAddress(\\n uint256 tokenId,\\n address to,\\n address authorityAddress,\\n uint256 signatureDate,\\n address paymentMethod,\\n uint256 mintPrice\\n );\\n}\\n\",\"keccak256\":\"0x09363a0ec6d1313b4f3164262b699566875e0738b075c730a58414dfd8afddb6\",\"license\":\"MIT\"},\"contracts/dex/PaymentGateway.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/SafeMath.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/dex/IUniswapRouter.sol\\\";\\n\\n/// @title Pay using a Decentralized automated market maker (AMM) when needed\\n/// @author Masa Finance\\n/// @notice Smart contract to call a Dex AMM smart contract to pay to a reserve wallet recipient\\n/// @dev This smart contract will call the Uniswap Router interface, based on\\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\\nabstract contract PaymentGateway is AccessControl {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n\\n struct PaymentParams {\\n address swapRouter; // Swap router address\\n address wrappedNativeToken; // Wrapped native token address\\n address stableCoin; // Stable coin to pay the fee in (USDC)\\n address masaToken; // Utility token to pay the fee in (MASA)\\n address reserveWallet; // Wallet that will receive the fee\\n }\\n\\n /* ========== STATE VARIABLES =========================================== */\\n\\n address public swapRouter;\\n address public wrappedNativeToken;\\n\\n address public stableCoin; // USDC. It also needs to be enabled as payment method, if we want to pay in USDC\\n address public masaToken; // MASA. It also needs to be enabled as payment method, if we want to pay in MASA\\n\\n // enabled payment methods: ETH and ERC20 tokens\\n mapping(address => bool) public enabledPaymentMethod;\\n address[] public enabledPaymentMethods;\\n\\n address public reserveWallet;\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new Dex AMM\\n /// @dev Creates a new Decentralized automated market maker (AMM) smart contract,\\n // that will call the Uniswap Router interface\\n /// @param admin Administrator of the smart contract\\n /// @param paymentParams Payment params\\n constructor(address admin, PaymentParams memory paymentParams) {\\n if (paymentParams.swapRouter == address(0)) revert ZeroAddress();\\n if (paymentParams.wrappedNativeToken == address(0))\\n revert ZeroAddress();\\n if (paymentParams.stableCoin == address(0)) revert ZeroAddress();\\n if (paymentParams.reserveWallet == address(0)) revert ZeroAddress();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\\n\\n swapRouter = paymentParams.swapRouter;\\n wrappedNativeToken = paymentParams.wrappedNativeToken;\\n stableCoin = paymentParams.stableCoin;\\n masaToken = paymentParams.masaToken;\\n reserveWallet = paymentParams.reserveWallet;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the swap router address\\n /// @dev The caller must have the admin role to call this function\\n /// @param _swapRouter New swap router address\\n function setSwapRouter(address _swapRouter)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_swapRouter == address(0)) revert ZeroAddress();\\n if (swapRouter == _swapRouter) revert SameValue();\\n swapRouter = _swapRouter;\\n }\\n\\n /// @notice Sets the wrapped native token address\\n /// @dev The caller must have the admin role to call this function\\n /// @param _wrappedNativeToken New wrapped native token address\\n function setWrappedNativeToken(address _wrappedNativeToken)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_wrappedNativeToken == address(0)) revert ZeroAddress();\\n if (wrappedNativeToken == _wrappedNativeToken) revert SameValue();\\n wrappedNativeToken = _wrappedNativeToken;\\n }\\n\\n /// @notice Sets the stable coin to pay the fee in (USDC)\\n /// @dev The caller must have the admin role to call this function\\n /// @param _stableCoin New stable coin to pay the fee in\\n function setStableCoin(address _stableCoin)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_stableCoin == address(0)) revert ZeroAddress();\\n if (stableCoin == _stableCoin) revert SameValue();\\n stableCoin = _stableCoin;\\n }\\n\\n /// @notice Sets the utility token to pay the fee in (MASA)\\n /// @dev The caller must have the admin role to call this function\\n /// It can be set to address(0) to disable paying in MASA\\n /// @param _masaToken New utility token to pay the fee in\\n function setMasaToken(address _masaToken)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (masaToken == _masaToken) revert SameValue();\\n masaToken = _masaToken;\\n }\\n\\n /// @notice Adds a new token as a valid payment method\\n /// @dev The caller must have the admin role to call this function\\n /// @param _paymentMethod New token to add\\n function enablePaymentMethod(address _paymentMethod)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (enabledPaymentMethod[_paymentMethod]) revert AlreadyAdded();\\n\\n enabledPaymentMethod[_paymentMethod] = true;\\n enabledPaymentMethods.push(_paymentMethod);\\n }\\n\\n /// @notice Removes a token as a valid payment method\\n /// @dev The caller must have the admin role to call this function\\n /// @param _paymentMethod Token to remove\\n function disablePaymentMethod(address _paymentMethod)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (!enabledPaymentMethod[_paymentMethod])\\n revert NonExistingErc20Token(_paymentMethod);\\n\\n enabledPaymentMethod[_paymentMethod] = false;\\n for (uint256 i = 0; i < enabledPaymentMethods.length; i++) {\\n if (enabledPaymentMethods[i] == _paymentMethod) {\\n enabledPaymentMethods[i] = enabledPaymentMethods[\\n enabledPaymentMethods.length - 1\\n ];\\n enabledPaymentMethods.pop();\\n break;\\n }\\n }\\n }\\n\\n /// @notice Set the reserve wallet\\n /// @dev The caller must have the admin role to call this function\\n /// @param _reserveWallet New reserve wallet\\n function setReserveWallet(address _reserveWallet)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_reserveWallet == address(0)) revert ZeroAddress();\\n if (_reserveWallet == reserveWallet) revert SameValue();\\n reserveWallet = _reserveWallet;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns all available payment methods\\n /// @dev Returns the address of all available payment methods\\n /// @return Array of all enabled payment methods\\n function getEnabledPaymentMethods()\\n external\\n view\\n returns (address[] memory)\\n {\\n return enabledPaymentMethods;\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n /// @notice Converts an amount from a stable coin to a payment method amount\\n /// @dev This method will perform the swap between the stable coin and the\\n /// payment method, and return the amount of the payment method,\\n /// performing the swap if necessary\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param amount Price to be converted in the specified payment method\\n function _convertFromStableCoin(address paymentMethod, uint256 amount)\\n internal\\n view\\n returns (uint256)\\n {\\n if (!enabledPaymentMethod[paymentMethod] || paymentMethod == stableCoin)\\n revert InvalidToken(paymentMethod);\\n\\n if (paymentMethod == address(0)) {\\n return _estimateSwapAmount(wrappedNativeToken, stableCoin, amount);\\n } else {\\n return _estimateSwapAmount(paymentMethod, stableCoin, amount);\\n }\\n }\\n\\n /// @notice Performs the payment in any payment method\\n /// @dev This method will transfer the funds to the reserve wallet, performing\\n /// the swap if necessary\\n /// @param paymentMethod Address of token that user want to pay\\n /// @param amount Price to be paid in the specified payment method\\n function _pay(address paymentMethod, uint256 amount) internal {\\n if (amount == 0) return;\\n if (!enabledPaymentMethod[paymentMethod])\\n revert InvalidPaymentMethod(paymentMethod);\\n if (paymentMethod == address(0)) {\\n // ETH\\n if (msg.value < amount) revert InsufficientEthAmount(amount);\\n (bool success, ) = payable(reserveWallet).call{value: amount}(\\\"\\\");\\n if (!success) revert TransferFailed();\\n if (msg.value > amount) {\\n // return diff\\n uint256 refund = msg.value.sub(amount);\\n (success, ) = payable(msg.sender).call{value: refund}(\\\"\\\");\\n if (!success) revert RefundFailed();\\n }\\n } else {\\n // ERC20 token, including MASA and USDC\\n IERC20(paymentMethod).safeTransferFrom(\\n msg.sender,\\n reserveWallet,\\n amount\\n );\\n }\\n }\\n\\n function _estimateSwapAmount(\\n address _fromToken,\\n address _toToken,\\n uint256 _amountOut\\n ) private view returns (uint256) {\\n uint256[] memory amounts;\\n address[] memory path;\\n path = _getPathFromTokenToToken(_fromToken, _toToken);\\n amounts = IUniswapRouter(swapRouter).getAmountsIn(_amountOut, path);\\n return amounts[0];\\n }\\n\\n function _getPathFromTokenToToken(address fromToken, address toToken)\\n private\\n view\\n returns (address[] memory)\\n {\\n if (fromToken == wrappedNativeToken || toToken == wrappedNativeToken) {\\n address[] memory path = new address[](2);\\n path[0] = fromToken == wrappedNativeToken\\n ? wrappedNativeToken\\n : fromToken;\\n path[1] = toToken == wrappedNativeToken\\n ? wrappedNativeToken\\n : toToken;\\n return path;\\n } else {\\n address[] memory path = new address[](3);\\n path[0] = fromToken;\\n path[1] = wrappedNativeToken;\\n path[2] = toToken;\\n return path;\\n }\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0xe5262dbf09717fd9c0283f2ec1b519062e525d36edd399f42f8ae9325564d0b1\",\"license\":\"MIT\"},\"contracts/interfaces/ILinkableSBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../tokens/SBT/ISBT.sol\\\";\\n\\ninterface ILinkableSBT is ISBT {\\n function addLinkPrice() external view returns (uint256);\\n\\n function addLinkPriceMASA() external view returns (uint256);\\n\\n function queryLinkPrice() external view returns (uint256);\\n\\n function queryLinkPriceMASA() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x1015d56aa9b3250816385ea78bb865a315d1882313e43381df64b587016bd3c0\",\"license\":\"MIT\"},\"contracts/interfaces/ISoulName.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\ninterface ISoulName {\\n function mint(\\n address to,\\n string memory name,\\n uint256 yearsPeriod,\\n string memory _tokenURI\\n ) external returns (uint256);\\n\\n function getExtension() external view returns (string memory);\\n\\n function isAvailable(string memory name)\\n external\\n view\\n returns (bool available);\\n\\n function getTokenData(string memory name)\\n external\\n view\\n returns (\\n string memory sbtName,\\n bool linked,\\n uint256 identityId,\\n uint256 tokenId,\\n uint256 expirationDate,\\n bool active\\n );\\n\\n function getTokenId(string memory name) external view returns (uint256);\\n\\n function getSoulNames(address owner)\\n external\\n view\\n returns (string[] memory sbtNames);\\n\\n function getSoulNames(uint256 identityId)\\n external\\n view\\n returns (string[] memory sbtNames);\\n}\\n\",\"keccak256\":\"0x8793d235ae8c9d723280f7ef0b35f1fb8a3fd0a706c7d9943c7a68db850e31c7\",\"license\":\"MIT\"},\"contracts/interfaces/ISoulboundIdentity.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../tokens/SBT/ISBT.sol\\\";\\n\\nimport \\\"./ISoulName.sol\\\";\\n\\ninterface ISoulboundIdentity is ISBT {\\n function mint(address to) external returns (uint256);\\n\\n function mintIdentityWithName(\\n address to,\\n string memory name,\\n uint256 yearsPeriod,\\n string memory _tokenURI\\n ) external returns (uint256);\\n\\n function getSoulName() external view returns (ISoulName);\\n\\n function tokenOfOwner(address owner) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x443506c61e4b65b8587c43928ed004d880feb4e272a56f474bb8def5d9090c0a\",\"license\":\"MIT\"},\"contracts/interfaces/dex/IUniswapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\n/// @title Uniswap Router interface\\n/// @author Masa Finance\\n/// @notice Interface of the Uniswap Router contract\\n/// @dev This interface is used to interact with the Uniswap Router contract,\\n/// and gets the most important functions of the contract. It's based on\\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\\ninterface IUniswapRouter {\\n function swapExactTokensForTokens(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function swapExactETHForTokens(\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external payable returns (uint256[] memory amounts);\\n\\n function swapExactTokensForETH(\\n uint256 amountIn,\\n uint256 amountOutMin,\\n address[] calldata path,\\n address to,\\n uint256 deadline\\n ) external returns (uint256[] memory amounts);\\n\\n function getAmountsOut(uint256 amountIn, address[] calldata path)\\n external\\n view\\n returns (uint256[] memory amounts);\\n\\n function getAmountsIn(uint256 amountOut, address[] calldata path)\\n external\\n view\\n returns (uint256[] memory amounts);\\n}\\n\",\"keccak256\":\"0xc5821fe554ec90d78f9d0fc5a627346e9e0542a9af5722e6707933853c867d4f\",\"license\":\"MIT\"},\"contracts/libraries/Errors.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nerror AddressDoesNotHaveIdentity(address to);\\nerror AlreadyAdded();\\nerror AuthorityNotExists(address authority);\\nerror CallerNotOwner(address caller);\\nerror CallerNotReader(address caller);\\nerror CreditScoreAlreadyCreated(address to);\\nerror IdentityAlreadyCreated(address to);\\nerror IdentityOwnerIsReader(uint256 readerIdentityId);\\nerror InsufficientEthAmount(uint256 amount);\\nerror IdentityOwnerNotTokenOwner(uint256 tokenId, uint256 ownerIdentityId);\\nerror InvalidPaymentMethod(address paymentMethod);\\nerror InvalidSignature();\\nerror InvalidSignatureDate(uint256 signatureDate);\\nerror InvalidToken(address token);\\nerror InvalidTokenURI(string tokenURI);\\nerror LinkAlreadyExists(\\n address token,\\n uint256 tokenId,\\n uint256 readerIdentityId,\\n uint256 signatureDate\\n);\\nerror LinkAlreadyRevoked();\\nerror LinkDoesNotExist();\\nerror NameAlreadyExists(string name);\\nerror NameNotFound(string name);\\nerror NameRegisteredByOtherAccount(string name, uint256 tokenId);\\nerror NotAuthorized(address signer);\\nerror NonExistingErc20Token(address erc20token);\\nerror NotLinkedToAnIdentitySBT();\\nerror RefundFailed();\\nerror SameValue();\\nerror SBTAlreadyLinked(address token);\\nerror SoulNameContractNotSet();\\nerror TokenNotFound(uint256 tokenId);\\nerror TransferFailed();\\nerror URIAlreadyExists(string tokenURI);\\nerror ValidPeriodExpired(uint256 expirationDate);\\nerror ZeroAddress();\\nerror ZeroLengthName(string name);\\nerror ZeroYearsPeriod(uint256 yearsPeriod);\\n\",\"keccak256\":\"0x6f844a5a2149390d1ad7113b302b7ae539c27b0e861133554dbe8c2e00fb99e7\",\"license\":\"MIT\"},\"contracts/tokens/MasaSBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/ILinkableSBT.sol\\\";\\nimport \\\"./SBT/SBT.sol\\\";\\nimport \\\"./SBT/extensions/SBTEnumerable.sol\\\";\\nimport \\\"./SBT/extensions/SBTBurnable.sol\\\";\\n\\n/// @title MasaSBT\\n/// @author Masa Finance\\n/// @notice Soulbound token. Non-fungible token that is not transferable.\\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\\nabstract contract MasaSBT is\\n SBT,\\n SBTEnumerable,\\n AccessControl,\\n SBTBurnable,\\n ILinkableSBT\\n{\\n /* ========== STATE VARIABLES =========================================== */\\n\\n using Strings for uint256;\\n\\n string private _baseTokenURI;\\n\\n uint256 public override addLinkPrice; // price in stable coin\\n uint256 public override addLinkPriceMASA; // price in MASA\\n uint256 public override queryLinkPrice; // price in stable coin\\n uint256 public override queryLinkPriceMASA; // price in MASA\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound token\\n /// @dev Creates a new soulbound token\\n /// @param admin Administrator of the smart contract\\n /// @param name Name of the token\\n /// @param symbol Symbol of the token\\n /// @param baseTokenURI Base URI of the token\\n constructor(\\n address admin,\\n string memory name,\\n string memory symbol,\\n string memory baseTokenURI\\n ) SBT(name, symbol) {\\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\\n\\n _baseTokenURI = baseTokenURI;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the price for adding the link in SoulLinker in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _addLinkPrice New price for adding the link in SoulLinker in stable coin\\n function setAddLinkPrice(uint256 _addLinkPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (addLinkPrice == _addLinkPrice) revert SameValue();\\n addLinkPrice = _addLinkPrice;\\n }\\n\\n /// @notice Sets the price for adding the link in SoulLinker in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _addLinkPriceMASA New price for adding the link in SoulLinker in MASA\\n function setAddLinkPriceMASA(uint256 _addLinkPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (addLinkPriceMASA == _addLinkPriceMASA) revert SameValue();\\n addLinkPriceMASA = _addLinkPriceMASA;\\n }\\n\\n /// @notice Sets the price for reading data in SoulLinker in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _queryLinkPrice New price for reading data in SoulLinker in stable coin\\n function setQueryLinkPrice(uint256 _queryLinkPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (queryLinkPrice == _queryLinkPrice) revert SameValue();\\n queryLinkPrice = _queryLinkPrice;\\n }\\n\\n /// @notice Sets the price for reading data in SoulLinker in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _queryLinkPriceMASA New price for reading data in SoulLinker in MASA\\n function setQueryLinkPriceMASA(uint256 _queryLinkPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (queryLinkPriceMASA == _queryLinkPriceMASA) revert SameValue();\\n queryLinkPriceMASA = _queryLinkPriceMASA;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns true if the token exists\\n /// @dev Returns true if the token has been minted\\n /// @param tokenId Token to check\\n /// @return True if the token exists\\n function exists(uint256 tokenId) external view returns (bool) {\\n return _exists(tokenId);\\n }\\n\\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\\n /// @dev Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC\\n /// 3986. The URI may point to a JSON file that conforms to the \\\"ERC721\\n /// Metadata JSON Schema\\\".\\n /// @param tokenId SBT to get the URI of\\n /// @return URI of the SBT\\n function tokenURI(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (string memory)\\n {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return\\n bytes(baseURI).length > 0\\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \\\".json\\\"))\\n : \\\"\\\";\\n }\\n\\n /// @notice Query if a contract implements an interface\\n /// @dev Interface identification is specified in ERC-165.\\n /// @param interfaceId The interface identifier, as specified in ERC-165\\n /// @return `true` if the contract implements `interfaceId` and\\n /// `interfaceId` is not 0xffffffff, `false` otherwise\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(SBT, SBTEnumerable, AccessControl, IERC165)\\n returns (bool)\\n {\\n return super.supportsInterface(interfaceId);\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _baseURI() internal view virtual override returns (string memory) {\\n return _baseTokenURI;\\n }\\n\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual override(SBT, SBTEnumerable) {\\n super._beforeTokenTransfer(from, to, tokenId);\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0x97a3f6aba32056305a1831e553d0557c4d9f4eed7407962ec47902d6699d7e37\",\"license\":\"MIT\"},\"contracts/tokens/MasaSBTSelfSovereign.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Counters.sol\\\";\\n\\nimport \\\"../libraries/Errors.sol\\\";\\nimport \\\"../interfaces/ISoulboundIdentity.sol\\\";\\nimport \\\"../dex/PaymentGateway.sol\\\";\\nimport \\\"./MasaSBT.sol\\\";\\n\\n/// @title MasaSBTSelfSovereign\\n/// @author Masa Finance\\n/// @notice Soulbound token. Non-fungible token that is not transferable.\\n/// Adds a link to a SoulboundIdentity SC to let minting using the identityId\\n/// Adds a payment gateway to let minting paying a fee\\n/// Adds a self-sovereign protocol to let minting using an authority signature\\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\\nabstract contract MasaSBTSelfSovereign is PaymentGateway, MasaSBT, EIP712 {\\n /* ========== STATE VARIABLES =========================================== */\\n\\n using Counters for Counters.Counter;\\n\\n Counters.Counter private _tokenIdCounter;\\n\\n ISoulboundIdentity public soulboundIdentity;\\n\\n uint256 public mintPrice; // price in stable coin\\n uint256 public mintPriceMASA; // price in MASA\\n\\n mapping(address => bool) public authorities;\\n\\n /* ========== INITIALIZE ================================================ */\\n\\n /// @notice Creates a new soulbound token\\n /// @dev Creates a new soulbound token\\n /// @param admin Administrator of the smart contract\\n /// @param name Name of the token\\n /// @param symbol Symbol of the token\\n /// @param baseTokenURI Base URI of the token\\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\\n /// @param paymentParams Payment gateway params\\n constructor(\\n address admin,\\n string memory name,\\n string memory symbol,\\n string memory baseTokenURI,\\n ISoulboundIdentity _soulboundIdentity,\\n PaymentParams memory paymentParams\\n )\\n PaymentGateway(admin, paymentParams)\\n MasaSBT(admin, name, symbol, baseTokenURI)\\n {\\n soulboundIdentity = _soulboundIdentity;\\n }\\n\\n /* ========== RESTRICTED FUNCTIONS ====================================== */\\n\\n /// @notice Sets the SoulboundIdentity contract address linked to this SBT\\n /// @dev The caller must be the admin to call this function\\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\\n soulboundIdentity = _soulboundIdentity;\\n }\\n\\n /// @notice Sets the price of minting in stable coin\\n /// @dev The caller must have the admin role to call this function\\n /// @param _mintPrice New price of minting in stable coin\\n function setMintPrice(uint256 _mintPrice)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (mintPrice == _mintPrice) revert SameValue();\\n mintPrice = _mintPrice;\\n }\\n\\n /// @notice Sets the price of minting in MASA\\n /// @dev The caller must have the admin role to call this function\\n /// @param _mintPriceMASA New price of minting in MASA\\n function setMintPriceMASA(uint256 _mintPriceMASA)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (mintPriceMASA == _mintPriceMASA) revert SameValue();\\n mintPriceMASA = _mintPriceMASA;\\n }\\n\\n /// @notice Adds a new authority to the list of authorities\\n /// @dev The caller must have the admin role to call this function\\n /// @param _authority New authority to add\\n function addAuthority(address _authority)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_authority == address(0)) revert ZeroAddress();\\n if (authorities[_authority]) revert AlreadyAdded();\\n\\n authorities[_authority] = true;\\n }\\n\\n /// @notice Removes an authority from the list of authorities\\n /// @dev The caller must have the admin role to call this function\\n /// @param _authority Authority to remove\\n function removeAuthority(address _authority)\\n external\\n onlyRole(DEFAULT_ADMIN_ROLE)\\n {\\n if (_authority == address(0)) revert ZeroAddress();\\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\\n\\n authorities[_authority] = false;\\n }\\n\\n /* ========== MUTATIVE FUNCTIONS ======================================== */\\n\\n /* ========== VIEWS ===================================================== */\\n\\n /// @notice Returns the identityId owned by the given token\\n /// @param tokenId Id of the token\\n /// @return Id of the identity\\n function getIdentityId(uint256 tokenId) external view returns (uint256) {\\n if (soulboundIdentity == ISoulboundIdentity(address(0)))\\n revert NotLinkedToAnIdentitySBT();\\n\\n address owner = super.ownerOf(tokenId);\\n return soulboundIdentity.tokenOfOwner(owner);\\n }\\n\\n /// @notice Returns the price for minting\\n /// @dev Returns current pricing for minting\\n /// @param paymentMethod Address of token that user want to pay\\n /// @return Current price for minting in the given payment method\\n function getMintPrice(address paymentMethod) public view returns (uint256) {\\n if (mintPrice == 0 && mintPriceMASA == 0) {\\n return 0;\\n } else if (\\n paymentMethod == masaToken &&\\n enabledPaymentMethod[paymentMethod] &&\\n mintPriceMASA > 0\\n ) {\\n // price in MASA without conversion rate\\n return mintPriceMASA;\\n } else if (\\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\\n ) {\\n // stable coin\\n return mintPrice;\\n } else if (enabledPaymentMethod[paymentMethod]) {\\n // ETH and ERC 20 token\\n return _convertFromStableCoin(paymentMethod, mintPrice);\\n } else {\\n revert InvalidPaymentMethod(paymentMethod);\\n }\\n }\\n\\n /// @notice Query if a contract implements an interface\\n /// @dev Interface identification is specified in ERC-165.\\n /// @param interfaceId The interface identifier, as specified in ERC-165\\n /// @return `true` if the contract implements `interfaceId` and\\n /// `interfaceId` is not 0xffffffff, `false` otherwise\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(AccessControl, MasaSBT)\\n returns (bool)\\n {\\n return super.supportsInterface(interfaceId);\\n }\\n\\n /* ========== PRIVATE FUNCTIONS ========================================= */\\n\\n function _verify(\\n bytes32 digest,\\n bytes memory signature,\\n address signer\\n ) internal view {\\n address _signer = ECDSA.recover(digest, signature);\\n if (_signer != signer) revert InvalidSignature();\\n if (!authorities[_signer]) revert NotAuthorized(_signer);\\n }\\n\\n function _mintWithCounter(address to) internal virtual returns (uint256) {\\n uint256 tokenId = _tokenIdCounter.current();\\n _tokenIdCounter.increment();\\n _mint(to, tokenId);\\n\\n return tokenId;\\n }\\n\\n /* ========== MODIFIERS ================================================= */\\n\\n /* ========== EVENTS ==================================================== */\\n}\\n\",\"keccak256\":\"0xbfdfe31ae30bc6cb5ba35cb273d7acb3f905ca50c9f107e06a4d1bc54ed238d2\",\"license\":\"MIT\"},\"contracts/tokens/SBT/ISBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ninterface ISBT is IERC165 {\\n /// @dev This emits when an SBT is newly minted.\\n /// This event emits when SBTs are created\\n event Mint(address indexed _owner, uint256 indexed _tokenId);\\n\\n /// @dev This emits when an SBT is burned\\n /// This event emits when SBTs are destroyed\\n event Burn(address indexed _owner, uint256 indexed _tokenId);\\n\\n /// @notice Count all SBTs assigned to an owner\\n /// @dev SBTs assigned to the zero address are considered invalid, and this\\n /// function throws for queries about the zero address.\\n /// @param _owner An address for whom to query the balance\\n /// @return The number of SBTs owned by `_owner`, possibly zero\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice Find the owner of an SBT\\n /// @dev SBTs assigned to zero address are considered invalid, and queries\\n /// about them do throw.\\n /// @param _tokenId The identifier for an SBT\\n /// @return The address of the owner of the SBT\\n function ownerOf(uint256 _tokenId) external view returns (address);\\n}\\n\",\"keccak256\":\"0xe3bbe44185c28e82bafd54b2197ea0971af74864dd1e7148ac4bbc673d52d738\",\"license\":\"MIT\"},\"contracts/tokens/SBT/SBT.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/introspection/ERC165.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/Strings.sol\\\";\\n\\nimport \\\"./ISBT.sol\\\";\\nimport \\\"./extensions/ISBTMetadata.sol\\\";\\n\\n/// @title SBT\\n/// @author Masa Finance\\n/// @notice Soulbound token is an NFT token that is not transferable.\\ncontract SBT is Context, ERC165, ISBT, ISBTMetadata {\\n using Strings for uint256;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Mapping from token ID to owner address\\n mapping(uint256 => address) private _owners;\\n\\n // Mapping owner address to token count\\n mapping(address => uint256) private _balances;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(ERC165, IERC165)\\n returns (bool)\\n {\\n return\\n interfaceId == type(ISBT).interfaceId ||\\n interfaceId == type(ISBTMetadata).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {ISBT-balanceOf}.\\n */\\n function balanceOf(address owner)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(owner != address(0), \\\"SBT: address zero is not a valid owner\\\");\\n return _balances[owner];\\n }\\n\\n /**\\n * @dev See {ISBT-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (address)\\n {\\n address owner = _owners[tokenId];\\n require(owner != address(0), \\\"SBT: invalid token ID\\\");\\n return owner;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {ISBTMetadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId)\\n public\\n view\\n virtual\\n override\\n returns (string memory)\\n {\\n _requireMinted(tokenId);\\n\\n string memory baseURI = _baseURI();\\n return\\n bytes(baseURI).length > 0\\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\\n : \\\"\\\";\\n }\\n\\n /**\\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\\n * by default, can be overridden in child contracts.\\n */\\n function _baseURI() internal view virtual returns (string memory) {\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isOwner(address spender, uint256 tokenId)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n address owner = SBT.ownerOf(tokenId);\\n return (spender == owner);\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _owners[tokenId] != address(0);\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Mint} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"SBT: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"SBT: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId);\\n\\n _balances[to] += 1;\\n _owners[tokenId] = to;\\n\\n emit Mint(to, tokenId);\\n\\n _afterTokenTransfer(address(0), to, tokenId);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n *\\n * Requirements:\\n * - `tokenId` must exist.\\n *\\n * Emits a {Burn} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = SBT.ownerOf(tokenId);\\n\\n _beforeTokenTransfer(owner, address(0), tokenId);\\n\\n _balances[owner] -= 1;\\n delete _owners[tokenId];\\n\\n emit Burn(owner, tokenId);\\n\\n _afterTokenTransfer(owner, address(0), tokenId);\\n }\\n\\n /**\\n * @dev Reverts if the `tokenId` has not been minted yet.\\n */\\n function _requireMinted(uint256 tokenId) internal view virtual {\\n require(_exists(tokenId), \\\"SBT: invalid token ID\\\");\\n }\\n\\n /**\\n * @dev Hook that is called before any token minting/burning\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address,\\n address,\\n uint256\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any minting/burning of tokens\\n *\\n * Calling conditions:\\n * - when `from` and `to` are both non-zero.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address,\\n address,\\n uint256\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0x0248d73f3daa5e2fe5d306a0366e56f6f3c85ba461de46a3f0c5235b9d19af0e\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/ISBTEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../ISBT.sol\\\";\\n\\n/**\\n * @title SBT Soulbound Token Standard, optional enumeration extension\\n */\\ninterface ISBTEnumerable is ISBT {\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x3cfc53065d044d199a7af437aa9768d4a777caf702b2634ae65b4f896ba9ef3c\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/ISBTMetadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../ISBT.sol\\\";\\n\\n/**\\n * @title SBT Soulbound Token Standard, optional metadata extension\\n */\\ninterface ISBTMetadata is ISBT {\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xfaff9e3f2be62198273767a93c4a82bcbe2909be23ec48fdbf5f1564fb690aee\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/SBTBurnable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"@openzeppelin/contracts/utils/Context.sol\\\";\\n\\nimport \\\"../SBT.sol\\\";\\n\\n/**\\n * @title SBT Burnable Token\\n * @dev SBT Token that can be burned (destroyed).\\n */\\nabstract contract SBTBurnable is Context, SBT {\\n /**\\n * @dev Burns `tokenId`. See {SBT-_burn}.\\n *\\n * Requirements:\\n *\\n * - The caller must own `tokenId` or be an approved operator.\\n */\\n function burn(uint256 tokenId) public virtual {\\n //solhint-disable-next-line max-line-length\\n require(\\n _isOwner(_msgSender(), tokenId),\\n \\\"SBT: caller is not token owner\\\"\\n );\\n _burn(tokenId);\\n }\\n}\\n\",\"keccak256\":\"0xffdf66fb4023f2aa75bc8bdf4ea2b8d27380f3fb4f1df8a65793f6605de10966\",\"license\":\"MIT\"},\"contracts/tokens/SBT/extensions/SBTEnumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.7;\\n\\nimport \\\"../SBT.sol\\\";\\nimport \\\"./ISBTEnumerable.sol\\\";\\n\\n/**\\n * @dev This implements an optional extension of {SBT} defined in the EIP that adds\\n * enumerability of all the token ids in the contract as well as all token ids owned by each\\n * account.\\n */\\nabstract contract SBTEnumerable is SBT, ISBTEnumerable {\\n // Mapping from owner to list of owned token IDs\\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\\n\\n // Mapping from token ID to index of the owner tokens list\\n mapping(uint256 => uint256) private _ownedTokensIndex;\\n\\n // Array with all token ids, used for enumeration\\n uint256[] private _allTokens;\\n\\n // Mapping from token id to position in the allTokens array\\n mapping(uint256 => uint256) private _allTokensIndex;\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId)\\n public\\n view\\n virtual\\n override(IERC165, SBT)\\n returns (bool)\\n {\\n return\\n interfaceId == type(ISBTEnumerable).interfaceId ||\\n super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-tokenOfOwnerByIndex}.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(\\n index < SBT.balanceOf(owner),\\n \\\"SBTEnumerable: owner index out of bounds\\\"\\n );\\n return _ownedTokens[owner][index];\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _allTokens.length;\\n }\\n\\n /**\\n * @dev See {ISBTEnumerable-tokenByIndex}.\\n */\\n function tokenByIndex(uint256 index)\\n public\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n require(\\n index < SBTEnumerable.totalSupply(),\\n \\\"SBTEnumerable: global index out of bounds\\\"\\n );\\n return _allTokens[index];\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting\\n * and burning.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 tokenId\\n ) internal virtual override {\\n super._beforeTokenTransfer(from, to, tokenId);\\n\\n if (from == address(0)) {\\n _addTokenToAllTokensEnumeration(tokenId);\\n } else if (from != to) {\\n _removeTokenFromOwnerEnumeration(from, tokenId);\\n }\\n if (to == address(0)) {\\n _removeTokenFromAllTokensEnumeration(tokenId);\\n } else if (to != from) {\\n _addTokenToOwnerEnumeration(to, tokenId);\\n }\\n }\\n\\n /**\\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\\n * @param to address representing the new owner of the given token ID\\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\\n */\\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\\n uint256 length = SBT.balanceOf(to);\\n _ownedTokens[to][length] = tokenId;\\n _ownedTokensIndex[tokenId] = length;\\n }\\n\\n /**\\n * @dev Private function to add a token to this extension's token tracking data structures.\\n * @param tokenId uint256 ID of the token to be added to the tokens list\\n */\\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\\n _allTokensIndex[tokenId] = _allTokens.length;\\n _allTokens.push(tokenId);\\n }\\n\\n /**\\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\\n * @param from address representing the previous owner of the given token ID\\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\\n */\\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)\\n private\\n {\\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\\n // then delete the last slot (swap and pop).\\n\\n uint256 lastTokenIndex = SBT.balanceOf(from) - 1;\\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\\n\\n // When the token to delete is the last token, the swap operation is unnecessary\\n if (tokenIndex != lastTokenIndex) {\\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\\n\\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\\n }\\n\\n // This also deletes the contents at the last position of the array\\n delete _ownedTokensIndex[tokenId];\\n delete _ownedTokens[from][lastTokenIndex];\\n }\\n\\n /**\\n * @dev Private function to remove a token from this extension's token tracking data structures.\\n * This has O(1) time complexity, but alters the order of the _allTokens array.\\n * @param tokenId uint256 ID of the token to be removed from the tokens list\\n */\\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\\n // then delete the last slot (swap and pop).\\n\\n uint256 lastTokenIndex = _allTokens.length - 1;\\n uint256 tokenIndex = _allTokensIndex[tokenId];\\n\\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\\n uint256 lastTokenId = _allTokens[lastTokenIndex];\\n\\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\\n\\n // This also deletes the contents at the last position of the array\\n delete _allTokensIndex[tokenId];\\n _allTokens.pop();\\n }\\n}\\n\",\"keccak256\":\"0x6d18005011564b08decc293aed48684d29cc6872e1d5ace5514e42b86ea675a5\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x6101406040523480156200001257600080fd5b50604051620042f8380380620042f88339810160408190526200003591620005a4565b83604051806040016040528060088152602001674d6173612032464160c01b8152506040518060400160405280600381526020016226992360e91b8152508585856040518060400160405280600c81526020016b536f756c626f756e6432464160a01b815250604051806040016040528060058152602001640312e302e360dc1b815250878787878b8784848160009080519060200190620000d9929190620003d7565b508051620000ef906001906020840190620003d7565b505081516001600160a01b0316151590506200011e5760405163d92e233d60e01b815260040160405180910390fd5b60208101516001600160a01b03166200014a5760405163d92e233d60e01b815260040160405180910390fd5b60408101516001600160a01b0316620001765760405163d92e233d60e01b815260040160405180910390fd5b60808101516001600160a01b0316620001a25760405163d92e233d60e01b815260040160405180910390fd5b620001af600083620002e3565b8051600980546001600160a01b03199081166001600160a01b03938416179091556020830151600a805483169184169190911790556040830151600b805483169184169190911790556060830151600c80548316918416919091179055608090920151600f80549093169116179055506200022c600085620002e3565b805162000241906010906020840190620003d7565b5050845160208087019190912085519186019190912060e08290526101008190524660a05290935091507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90506200029b8184846200036e565b6080523060601b60c052610120525050601680546001600160a01b0319166001600160a01b03959095169490941790935550506001601a5550620007fc975050505050505050565b620002ef8282620003aa565b6200036a5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620003293390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600083838346306040516020016200038b95949392919062000647565b6040516020818303038152906040528051906020012090509392505050565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b828054620003e5906200073e565b90600052602060002090601f01602090048101928262000409576000855562000454565b82601f106200042457805160ff191683800117855562000454565b8280016001018555821562000454579182015b828111156200045457825182559160200191906001019062000437565b506200046292915062000466565b5090565b5b8082111562000462576000815560010162000467565b6000620004946200048e84620006bc565b6200069d565b905082815260208101848484011115620004b157620004b1600080fd5b620004be8482856200070b565b509392505050565b8051620003d181620007d7565b8051620003d181620007f1565b600082601f830112620004f657620004f6600080fd5b8151620005088482602086016200047d565b949350505050565b600060a08284031215620005275762000527600080fd5b6200053360a06200069d565b90506000620005438484620004c6565b82525060206200055684848301620004c6565b60208301525060406200056c84828501620004c6565b60408301525060606200058284828501620004c6565b60608301525060806200059884828501620004c6565b60808301525092915050565b6000806000806101008587031215620005c057620005c0600080fd5b6000620005ce8787620004c6565b94505060208501516001600160401b03811115620005ef57620005ef600080fd5b620005fd87828801620004e0565b93505060406200061087828801620004d3565b9250506060620006238782880162000510565b91505092959194509250565b6200063a81620006ec565b82525050565b806200063a565b60a0810162000657828862000640565b62000666602083018762000640565b62000675604083018662000640565b62000684606083018562000640565b6200069360808301846200062f565b9695505050505050565b6000620006a960405190565b9050620006b782826200076f565b919050565b60006001600160401b03821115620006d857620006d8620007b7565b620006e382620007cd565b60200192915050565b60006001600160a01b038216620003d1565b6000620003d182620006ec565b60005b83811015620007285781810151838201526020016200070e565b8381111562000738576000848401525b50505050565b6002810460018216806200075357607f821691505b60208210811415620007695762000769620007a1565b50919050565b6200077a82620007cd565b81018181106001600160401b03821117156200079a576200079a620007b7565b6040525050565b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b620007e281620006ec565b8114620007ee57600080fd5b50565b620007e281620006fe565b60805160a05160c05160601c60e0516101005161012051613aa96200084f600039600061220a0152600061224c0152600061222b0152600061218f015260006121b9015260006121e30152613aa96000f3fe60806040526004361061025a5760003560e01c806301ffc9a71461025f5780630513c3e91461029557806306fdde03146102c257806310200519146102e457806313150b481461030657806317fcb39b1461032957806318160ddd146103495780631830e8811461035e5780631f37c1241461037457806320d558aa1461038a57806323af4e171461039d578063248a9ca3146103bf57806326defa73146103df578063289c686b146103ff5780632f2ff15d1461041f5780632f745c591461043f57806336568abe1461045f5780633ad3033e1461047f5780633c72ae701461049f57806341273657146104bf57806342966c68146104df5780634962a158146104ff5780634f558e791461051f5780634f6ccce71461053f5780636352211e1461055f5780636817c76c1461057f57806370a0823114610595578063719d0f2b146105b557806376ad1997146105d5578063776d1a54146105f557806377bed5ed1461060b5780637a0d1646146106385780637ad09dff146106685780637db8cb681461067b57806391223d691461069b57806391d14854146106cb57806394a665e9146106eb57806395d89b411461070b578063992642e514610720578063a217fddf14610740578063b97d6b2314610755578063c1177d191461076b578063c31c9c071461078b578063c86aadb6146107ab578063c87b56dd146107cb578063d544e010146107eb578063d547741f1461080b578063d72b11bd1461082b578063da058ae31461084b578063dda4fa8f1461086b578063ebda43961461088b578063f4a0a528146108ab578063fd48ac83146108cb575b600080fd5b34801561026b57600080fd5b5061027f61027a366004612f33565b6108eb565b60405161028c919061356d565b60405180910390f35b3480156102a157600080fd5b506102b56102b0366004612edf565b6108fc565b60405161028c9190613526565b3480156102ce57600080fd5b506102d7610926565b60405161028c919061365a565b3480156102f057600080fd5b506102f96109b8565b60405161028c919061355c565b34801561031257600080fd5b5061031c60145481565b60405161028c919061357b565b34801561033557600080fd5b50600a546102b5906001600160a01b031681565b34801561035557600080fd5b5060065461031c565b34801561036a57600080fd5b5061031c60185481565b34801561038057600080fd5b5061031c60115481565b61031c610398366004612e4b565b610a19565b3480156103a957600080fd5b506103bd6103b8366004612d37565b610bba565b005b3480156103cb57600080fd5b5061031c6103da366004612edf565b610c3e565b3480156103eb57600080fd5b506103bd6103fa366004612d37565b610c53565b34801561040b57600080fd5b506103bd61041a366004612edf565b610ce4565b34801561042b57600080fd5b506103bd61043a366004612f00565b610d18565b34801561044b57600080fd5b5061031c61045a366004612e0e565b610d39565b34801561046b57600080fd5b506103bd61047a366004612f00565b610d8b565b34801561048b57600080fd5b506103bd61049a366004612f54565b610dc1565b3480156104ab57600080fd5b506103bd6104ba366004612edf565b610e1e565b3480156104cb57600080fd5b506103bd6104da366004612d37565b610e52565b3480156104eb57600080fd5b506103bd6104fa366004612edf565b610ed6565b34801561050b57600080fd5b506103bd61051a366004612edf565b610f08565b34801561052b57600080fd5b5061027f61053a366004612edf565b610f3c565b34801561054b57600080fd5b5061031c61055a366004612edf565b610f47565b34801561056b57600080fd5b506102b561057a366004612edf565b610f95565b34801561058b57600080fd5b5061031c60175481565b3480156105a157600080fd5b5061031c6105b0366004612d37565b610fca565b3480156105c157600080fd5b5061031c6105d0366004612d37565b61100e565b3480156105e157600080fd5b506103bd6105f0366004612d37565b61110e565b34801561060157600080fd5b5061031c60125481565b34801561061757600080fd5b5060165461062b906001600160a01b031681565b60405161028c919061364c565b34801561064457600080fd5b5061027f610653366004612d37565b600d6020526000908152604090205460ff1681565b61031c610676366004612d79565b61116b565b34801561068757600080fd5b506103bd610696366004612edf565b611239565b3480156106a757600080fd5b5061027f6106b6366004612d37565b60196020526000908152604090205460ff1681565b3480156106d757600080fd5b5061027f6106e6366004612f00565b61126d565b3480156106f757600080fd5b506103bd610706366004612d37565b611298565b34801561071757600080fd5b506102d7611405565b34801561072c57600080fd5b50600b546102b5906001600160a01b031681565b34801561074c57600080fd5b5061031c600081565b34801561076157600080fd5b5061031c60135481565b34801561077757600080fd5b5061031c610786366004612edf565b611414565b34801561079757600080fd5b506009546102b5906001600160a01b031681565b3480156107b757600080fd5b506103bd6107c6366004612d37565b6114d3565b3480156107d757600080fd5b506102d76107e6366004612edf565b61157f565b3480156107f757600080fd5b506103bd610806366004612d37565b6115e5565b34801561081757600080fd5b506103bd610826366004612f00565b611674565b34801561083757600080fd5b50600f546102b5906001600160a01b031681565b34801561085757600080fd5b506103bd610866366004612d37565b611690565b34801561087757600080fd5b506103bd610886366004612d37565b611714565b34801561089757600080fd5b50600c546102b5906001600160a01b031681565b3480156108b757600080fd5b506103bd6108c6366004612edf565b611798565b3480156108d757600080fd5b506103bd6108e6366004612edf565b6117cc565b60006108f682611800565b92915050565b600e818154811061090c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600080546109359061390b565b80601f01602080910402602001604051908101604052809291908181526020018280546109619061390b565b80156109ae5780601f10610983576101008083540402835291602001916109ae565b820191906000526020600020905b81548152906001019060200180831161099157829003601f168201915b5050505050905090565b6060600e8054806020026020016040519081016040528092919081815260200182805480156109ae57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f2575050505050905090565b60006002601a541415610a475760405162461bcd60e51b8152600401610a3e9061375b565b60405180910390fd5b6002601a556016546040516331a9108f60e11b81526000916001600160a01b031690636352211e90610a7d908a9060040161357b565b60206040518083038186803b158015610a9557600080fd5b505afa158015610aa9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acd9190612d58565b90506001600160a01b0381163314610afb57335b60405163060296c760e31b8152600401610a3e9190613526565b610b47610b0988888861180b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b925061186a915050565b610b5988610b548a61100e565b6118eb565b6000610b6482611a91565b90507f2acd987f463cc0a2358ed0e6aafd383842212a5d7b82c9fb5e0999a44733c490818989898d601754604051610ba1969594939291906137ea565b60405180910390a16001601a5598975050505050505050565b6000610bc581611ab7565b6001600160a01b038216610bec5760405163d92e233d60e01b815260040160405180910390fd5b600b546001600160a01b0383811691161415610c1b5760405163c23f6ccb60e01b815260040160405180910390fd5b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526008602052604090206001015490565b6000610c5e81611ab7565b6001600160a01b038216610c855760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1615610cbf5760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000908152601960205260409020805460ff19166001179055565b6000610cef81611ab7565b816011541415610d125760405163c23f6ccb60e01b815260040160405180910390fd5b50601155565b610d2182610c3e565b610d2a81611ab7565b610d348383611ac1565b505050565b6000610d4483610fca565b8210610d625760405162461bcd60e51b8152600401610a3e906136ab565b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b0381163314610db35760405162461bcd60e51b8152600401610a3e9061376b565b610dbd8282611b47565b5050565b6000610dcc81611ab7565b6016546001600160a01b0383811691161415610dfb5760405163c23f6ccb60e01b815260040160405180910390fd5b50601680546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e2981611ab7565b816012541415610e4c5760405163c23f6ccb60e01b815260040160405180910390fd5b50601255565b6000610e5d81611ab7565b6001600160a01b038216610e845760405163d92e233d60e01b815260040160405180910390fd5b6009546001600160a01b0383811691161415610eb35760405163c23f6ccb60e01b815260040160405180910390fd5b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b610ee03382611bae565b610efc5760405162461bcd60e51b8152600401610a3e906136eb565b610f0581611bd1565b50565b6000610f1381611ab7565b816018541415610f365760405163c23f6ccb60e01b815260040160405180910390fd5b50601855565b60006108f682611c6b565b6000610f5260065490565b8210610f705760405162461bcd60e51b8152600401610a3e9061374b565b60068281548110610f8357610f83613a02565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108f65760405162461bcd60e51b8152600401610a3e9061371b565b60006001600160a01b038216610ff25760405162461bcd60e51b8152600401610a3e906136db565b506001600160a01b031660009081526003602052604090205490565b600060175460001480156110225750601854155b1561102f57506000919050565b600c546001600160a01b03838116911614801561106457506001600160a01b0382166000908152600d602052604090205460ff165b801561107257506000601854115b1561107f57505060185490565b600b546001600160a01b0383811691161480156110b457506001600160a01b0382166000908152600d602052604090205460ff165b156110c157505060175490565b6001600160a01b0382166000908152600d602052604090205460ff16156110ee576108f682601754611c88565b81604051630ac29ab760e31b8152600401610a3e9190613526565b919050565b600061111981611ab7565b600c546001600160a01b03838116911614156111485760405163c23f6ccb60e01b815260040160405180910390fd5b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03861633146111835733610ae1565b6111cf611191878787611d27565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061186a915050565b6111dc87610b548961100e565b60006111e787611a91565b90507fba3afdf6e7965ed8d31aeefc9ffbaf04262d250621df85cef0ef13a8a4487cba818888888c6017546040516112249695949392919061377b565b60405180910390a190505b9695505050505050565b600061124481611ab7565b8160145414156112675760405163c23f6ccb60e01b815260040160405180910390fd5b50601455565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006112a381611ab7565b6001600160a01b0382166000908152600d602052604090205460ff166112de57816040516318317bd560e01b8152600401610a3e9190613526565b6001600160a01b0382166000908152600d60205260408120805460ff191690555b600e54811015610d3457826001600160a01b0316600e828154811061132657611326613a02565b6000918252602090912001546001600160a01b031614156113f357600e80546113519060019061388a565b8154811061136157611361613a02565b600091825260209091200154600e80546001600160a01b03909216918390811061138d5761138d613a02565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e8054806113cc576113cc6139ec565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b806113fd81613965565b9150506112ff565b6060600180546109359061390b565b6016546000906001600160a01b031661144057604051630d7fe67b60e41b815260040160405180910390fd5b600061144b83610f95565b60165460405163294cdf0d60e01b81529192506001600160a01b03169063294cdf0d9061147c908490600401613526565b60206040518083038186803b15801561149457600080fd5b505afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc9190612f75565b9392505050565b60006114de81611ab7565b6001600160a01b0382166000908152600d602052604090205460ff16156115185760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600e805491820181559091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319169091179055565b606061158a82611d63565b6000611594611d88565b905060008151116115b457604051806020016040528060008152506114cc565b806115be84611d97565b6040516020016115cf92919061346d565b6040516020818303038152906040529392505050565b60006115f081611ab7565b6001600160a01b0382166116175760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1661165257816040516324b1f80560e21b8152600401610a3e9190613526565b506001600160a01b03166000908152601960205260409020805460ff19169055565b61167d82610c3e565b61168681611ab7565b610d348383611b47565b600061169b81611ab7565b6001600160a01b0382166116c25760405163d92e233d60e01b815260040160405180910390fd5b600a546001600160a01b03838116911614156116f15760405163c23f6ccb60e01b815260040160405180910390fd5b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061171f81611ab7565b6001600160a01b0382166117465760405163d92e233d60e01b815260040160405180910390fd5b600f546001600160a01b03838116911614156117755760405163c23f6ccb60e01b815260040160405180910390fd5b50600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006117a381611ab7565b8160175414156117c65760405163c23f6ccb60e01b815260040160405180910390fd5b50601755565b60006117d781611ab7565b8160135414156117fa5760405163c23f6ccb60e01b815260040160405180910390fd5b50601355565b60006108f682611e94565b60006118627f34ec28456d08f4e49693917808b7282a69eadae2824d33b92474bc8bdfdb7be68585856040516020016118479493929190613609565b60405160208183030381529060405280519060200120611eb9565b949350505050565b60006118768484611ecc565b9050816001600160a01b0316816001600160a01b0316146118aa57604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b03811660009081526019602052604090205460ff166118e55780604051634a0bfec160e01b8152600401610a3e9190613526565b50505050565b806118f4575050565b6001600160a01b0382166000908152600d602052604090205460ff1661192f5781604051630ac29ab760e31b8152600401610a3e9190613526565b6001600160a01b038216611a755780341015611960578060405163091a6d0f60e01b8152600401610a3e919061357b565b600f546040516000916001600160a01b031690839061197e906134cc565b60006040518083038185875af1925050503d80600081146119bb576040519150601f19603f3d011682016040523d82523d6000602084013e6119c0565b606091505b50509050806119e2576040516312171d8360e31b815260040160405180910390fd5b81341115610d345760006119f63484611ef0565b9050336001600160a01b031681604051611a0f906134cc565b60006040518083038185875af1925050503d8060008114611a4c576040519150601f19603f3d011682016040523d82523d6000602084013e611a51565b606091505b505080925050816118e557604051633c31275160e21b815260040160405180910390fd5b600f54610dbd906001600160a01b038481169133911684611efc565b600080611a9d60155490565b9050611aad601580546001019055565b6108f68382611f54565b610f058133612030565b611acb828261126d565b610dbd5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611b51828261126d565b15610dbd5760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611bba83610f95565b6001600160a01b0385811691161491505092915050565b6000611bdc82610f95565b9050611bea81600084612094565b6001600160a01b0381166000908152600360205260408120805460019290611c1390849061388a565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6001600160a01b0382166000908152600d602052604081205460ff161580611cbd5750600b546001600160a01b038481169116145b15611cdd578260405163961c9a4f60e01b8152600401610a3e9190613526565b6001600160a01b038316611d0f57600a54600b54611d08916001600160a01b0390811691168461209f565b90506108f6565b600b54611d089084906001600160a01b03168461209f565b60006118627fe84d61ea5268441d87c5a96690bcc830d3d14781947a5181464911a7ff7dcc5d8585856040516020016118479493929190613589565b611d6c81611c6b565b610f055760405162461bcd60e51b8152600401610a3e9061371b565b6060601080546109359061390b565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf81613965565b9150611dde9050600a83613857565b9150611dbf565b6000816001600160401b03811115611dff57611dff613a18565b6040519080825280601f01601f191660200182016040528015611e29576020820181803683370190505b5090505b841561186257611e3e60018361388a565b9150611e4b600a86613980565b611e5690603061383f565b60f81b818381518110611e6b57611e6b613a02565b60200101906001600160f81b031916908160001a905350611e8d600a86613857565b9450611e2d565b60006001600160e01b03198216637965db0b60e01b14806108f657506108f68261215d565b60006108f6611ec6612182565b83612275565b6000806000611edb85856122a8565b91509150611ee8816122ee565b509392505050565b60006114cc828461388a565b6118e5846323b872dd60e01b858585604051602401611f1d93929190613534565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526123d3565b6001600160a01b038216611f7a5760405162461bcd60e51b8152600401610a3e9061369b565b611f8381611c6b565b15611fa05760405162461bcd60e51b8152600401610a3e9061370b565b611fac60008383612094565b6001600160a01b0382166000908152600360205260408120805460019290611fd590849061383f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b61203a828261126d565b610dbd57612052816001600160a01b03166014612462565b61205d836020612462565b60405160200161206e9291906134d4565b60408051601f198184030181529082905262461bcd60e51b8252610a3e9160040161365a565b610d348383836125cd565b60006060806120ae8686612685565b6009546040516307c0329d60e21b81529192506001600160a01b031690631f00ca74906120e190879085906004016137ca565b60006040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121359190810190612e84565b91508160008151811061214a5761214a613a02565b6020026020010151925050509392505050565b60006001600160e01b0319821663780e9d6360e01b14806108f657506108f682612817565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156121db57507f000000000000000000000000000000000000000000000000000000000000000046145b1561220557507f000000000000000000000000000000000000000000000000000000000000000090565b6122707f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612867565b905090565b6000828260405160200161228a92919061349b565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156122df5760208301516040840151606085015160001a6122d3878285856128a1565b945094505050506122e7565b506000905060025b9250929050565b6000816004811115612302576123026139c0565b141561230b5750565b600181600481111561231f5761231f6139c0565b141561233d5760405162461bcd60e51b8152600401610a3e9061366b565b6002816004811115612351576123516139c0565b141561236f5760405162461bcd60e51b8152600401610a3e9061368b565b6003816004811115612383576123836139c0565b14156123a15760405162461bcd60e51b8152600401610a3e906136bb565b60048160048111156123b5576123b56139c0565b1415610f055760405162461bcd60e51b8152600401610a3e906136fb565b6000612428826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129779092919063ffffffff16565b805190915015610d3457808060200190518101906124469190612ebe565b610d345760405162461bcd60e51b8152600401610a3e9061373b565b6060600061247183600261386b565b61247c90600261383f565b6001600160401b0381111561249357612493613a18565b6040519080825280601f01601f1916602001820160405280156124bd576020820181803683370190505b509050600360fc1b816000815181106124d8576124d8613a02565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061250757612507613a02565b60200101906001600160f81b031916908160001a905350600061252b84600261386b565b61253690600161383f565b90505b60018111156125ae576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256a5761256a613a02565b1a60f81b82828151811061258057612580613a02565b60200101906001600160f81b031916908160001a90535060049490941c936125a7816138f4565b9050612539565b5083156114cc5760405162461bcd60e51b8152600401610a3e9061367b565b6001600160a01b0383166126285761262381600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b61264b565b816001600160a01b0316836001600160a01b03161461264b5761264b8382612986565b6001600160a01b03821661266257610d3481612a23565b826001600160a01b0316826001600160a01b031614610d3457610d348282612ad2565b600a546060906001600160a01b03848116911614806126b15750600a546001600160a01b038381169116145b1561277b5760408051600280825260608201835260009260208301908036833701905050600a549091506001600160a01b038581169116146126f35783612700565b600a546001600160a01b03165b8160008151811061271357612713613a02565b6001600160a01b039283166020918202929092010152600a5484821691161461273c5782612749565b600a546001600160a01b03165b8160018151811061275c5761275c613a02565b6001600160a01b039092166020928302919091019091015290506108f6565b604080516003808252608082019092526000916020820160608036833701905050905083816000815181106127b2576127b2613a02565b6001600160a01b039283166020918202929092010152600a548251911690829060019081106127e3576127e3613a02565b60200260200101906001600160a01b031690816001600160a01b031681525050828160028151811061275c5761275c613a02565b60006001600160e01b031982166313f2a32f60e01b148061284857506001600160e01b03198216635b5e139f60e01b145b806108f657506301ffc9a760e01b6001600160e01b03198316146108f6565b600083838346306040516020016128829594939291906135c7565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156128ce575060009050600361296e565b8460ff16601b141580156128e657508460ff16601c14155b156128f7575060009050600461296e565b60006001878787876040516000815260200160405260405161291c9493929190613624565b6020604051602081039080840390855afa15801561293e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129675760006001925092505061296e565b9150600090505b94509492505050565b60606118628484600085612b16565b6000600161299384610fca565b61299d919061388a565b6000838152600560205260409020549091508082146129f0576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b600654600090612a359060019061388a565b60008381526007602052604081205460068054939450909284908110612a5d57612a5d613a02565b906000526020600020015490508060068381548110612a7e57612a7e613a02565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480612ab657612ab66139ec565b6001900381819060005260206000200160009055905550505050565b6000612add83610fca565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b606082471015612b385760405162461bcd60e51b8152600401610a3e906136cb565b6001600160a01b0385163b612b5f5760405162461bcd60e51b8152600401610a3e9061372b565b600080866001600160a01b03168587604051612b7b9190613461565b60006040518083038185875af1925050503d8060008114612bb8576040519150601f19603f3d011682016040523d82523d6000602084013e612bbd565b606091505b5091509150612bcd828286612bd8565b979650505050505050565b60608315612be75750816114cc565b825115612bf75782518084602001fd5b8160405162461bcd60e51b8152600401610a3e919061365a565b6000612c24612c1f8461381c565b613805565b90508083825260208201905082856020860282011115612c4657612c46600080fd5b60005b85811015612c725781612c5c8882612d2c565b8452506020928301929190910190600101612c49565b5050509392505050565b80356108f681613a38565b80516108f681613a38565b600082601f830112612ca657612ca6600080fd5b8151611862848260208601612c11565b80516108f681613a4c565b80356108f681613a54565b80356108f681613a5a565b60008083601f840112612cec57612cec600080fd5b5081356001600160401b03811115612d0657612d06600080fd5b6020830191508360018202830111156122e7576122e7600080fd5b80356108f681613a6a565b80516108f681613a54565b600060208284031215612d4c57612d4c600080fd5b60006118628484612c7c565b600060208284031215612d6d57612d6d600080fd5b60006118628484612c87565b60008060008060008060a08789031215612d9557612d95600080fd5b6000612da18989612c7c565b9650506020612db289828a01612c7c565b9550506040612dc389828a01612c7c565b9450506060612dd489828a01612cc1565b93505060808701356001600160401b03811115612df357612df3600080fd5b612dff89828a01612cd7565b92509250509295509295509295565b60008060408385031215612e2457612e24600080fd5b6000612e308585612c7c565b9250506020612e4185828601612cc1565b9150509250929050565b60008060008060008060a08789031215612e6757612e67600080fd5b6000612e738989612c7c565b9650506020612db289828a01612cc1565b600060208284031215612e9957612e99600080fd5b81516001600160401b03811115612eb257612eb2600080fd5b61186284828501612c92565b600060208284031215612ed357612ed3600080fd5b60006118628484612cb6565b600060208284031215612ef457612ef4600080fd5b60006118628484612cc1565b60008060408385031215612f1657612f16600080fd5b6000612f228585612cc1565b9250506020612e4185828601612c7c565b600060208284031215612f4857612f48600080fd5b60006118628484612ccc565b600060208284031215612f6957612f69600080fd5b60006118628484612d21565b600060208284031215612f8a57612f8a600080fd5b60006118628484612d2c565b6000612fa28383612faa565b505060200190565b612fb3816138a1565b82525050565b6000612fc3825190565b80845260209384019383018060005b83811015612ff7578151612fe68882612f96565b975060208301925050600101612fd2565b509495945050505050565b801515612fb3565b80612fb3565b600061301a825190565b6130288185602086016138c8565b9290920192915050565b612fb3816138bd565b6000613045825190565b80845260208401935061305c8185602086016138c8565b61306581613a2e565b9093019392505050565b601881526000602082017745434453413a20696e76616c6964207369676e617475726560401b815291505b5060200190565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e749101908152600061309a565b601f81526000602082017f45434453413a20696e76616c6964207369676e6174757265206c656e677468008152915061309a565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061309a565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b6020820152915061317c565b602681526000602082017f416464726573733a20696e73756666696369656e742062616c616e636520666f8152651c8818d85b1b60d21b6020820152915061317c565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b6020820152915061317c565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061309a565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b6020820152915061317c565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061309a565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061309a565b601d81526000602082017f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000008152915061309a565b602a81526000602082017f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b6020820152915061317c565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b6020820152915061317c565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c008152915061309a565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b6020820152915061317c565b60ff8116612fb3565b60006114cc8284613010565b60006134798285613010565b91506134858284613010565b64173539b7b760d91b8152915060058201611862565b61190160f01b815260020160006134b2828561300a565b6020820191506134c2828461300a565b5060200192915050565b6000816108f6565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006135008285613010565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110191506118628284613010565b602081016108f68284612faa565b606081016135428286612faa565b61354f6020830185612faa565b611862604083018461300a565b602080825281016114cc8184612fb9565b602081016108f68284613002565b602081016108f6828461300a565b60808101613597828761300a565b6135a46020830186612faa565b6135b16040830185612faa565b6135be606083018461300a565b95945050505050565b60a081016135d5828861300a565b6135e2602083018761300a565b6135ef604083018661300a565b6135fc606083018561300a565b61122f6080830184612faa565b60808101613617828761300a565b6135a4602083018661300a565b60808101613632828761300a565b61363f6020830186613458565b6135b1604083018561300a565b602081016108f68284613032565b602080825281016114cc818461303b565b602080825281016108f68161306f565b602080825281016108f6816130a1565b602080825281016108f6816130d3565b602080825281016108f681613107565b602080825281016108f68161313b565b602080825281016108f681613183565b602080825281016108f6816131c2565b602080825281016108f681613205565b602080825281016108f681613248565b602080825281016108f68161327c565b602080825281016108f6816132bb565b602080825281016108f6816132eb565b602080825281016108f681613317565b602080825281016108f68161334b565b602080825281016108f681613392565b602080825281016108f6816133d8565b602080825281016108f68161340c565b60c08101613789828961300a565b6137966020830188612faa565b6137a36040830187612faa565b6137b0606083018661300a565b6137bd6080830185612faa565b612bcd60a083018461300a565b604081016137d8828561300a565b81810360208301526118628184612fb9565b60c081016137f8828961300a565b613796602083018861300a565b600061381060405190565b90506111098282613938565b60006001600160401b0382111561383557613835613a18565b5060209081020190565b6000821982111561385257613852613994565b500190565b600082613866576138666139aa565b500490565b600081600019048311821515161561388557613885613994565b500290565b60008282101561389c5761389c613994565b500390565b60006001600160a01b0382166108f6565b60006108f6826138a1565b60006108f6826138b2565b60005b838110156138e35781810151838201526020016138cb565b838111156118e55750506000910152565b60008161390357613903613994565b506000190190565b60028104600182168061391f57607f821691505b60208210811415613932576139326139d6565b50919050565b61394182613a2e565b81018181106001600160401b038211171561395e5761395e613a18565b6040525050565b600060001982141561397957613979613994565b5060010190565b60008261398f5761398f6139aa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b613a41816138a1565b8114610f0557600080fd5b801515613a41565b80613a41565b6001600160e01b03198116613a41565b613a41816138b256fea2646970667358221220d10d652bb5f49377047195872f4159a146a1be86a941ac6fb28339769132b85264736f6c63430008070033", - "deployedBytecode": "0x60806040526004361061025a5760003560e01c806301ffc9a71461025f5780630513c3e91461029557806306fdde03146102c257806310200519146102e457806313150b481461030657806317fcb39b1461032957806318160ddd146103495780631830e8811461035e5780631f37c1241461037457806320d558aa1461038a57806323af4e171461039d578063248a9ca3146103bf57806326defa73146103df578063289c686b146103ff5780632f2ff15d1461041f5780632f745c591461043f57806336568abe1461045f5780633ad3033e1461047f5780633c72ae701461049f57806341273657146104bf57806342966c68146104df5780634962a158146104ff5780634f558e791461051f5780634f6ccce71461053f5780636352211e1461055f5780636817c76c1461057f57806370a0823114610595578063719d0f2b146105b557806376ad1997146105d5578063776d1a54146105f557806377bed5ed1461060b5780637a0d1646146106385780637ad09dff146106685780637db8cb681461067b57806391223d691461069b57806391d14854146106cb57806394a665e9146106eb57806395d89b411461070b578063992642e514610720578063a217fddf14610740578063b97d6b2314610755578063c1177d191461076b578063c31c9c071461078b578063c86aadb6146107ab578063c87b56dd146107cb578063d544e010146107eb578063d547741f1461080b578063d72b11bd1461082b578063da058ae31461084b578063dda4fa8f1461086b578063ebda43961461088b578063f4a0a528146108ab578063fd48ac83146108cb575b600080fd5b34801561026b57600080fd5b5061027f61027a366004612f33565b6108eb565b60405161028c919061356d565b60405180910390f35b3480156102a157600080fd5b506102b56102b0366004612edf565b6108fc565b60405161028c9190613526565b3480156102ce57600080fd5b506102d7610926565b60405161028c919061365a565b3480156102f057600080fd5b506102f96109b8565b60405161028c919061355c565b34801561031257600080fd5b5061031c60145481565b60405161028c919061357b565b34801561033557600080fd5b50600a546102b5906001600160a01b031681565b34801561035557600080fd5b5060065461031c565b34801561036a57600080fd5b5061031c60185481565b34801561038057600080fd5b5061031c60115481565b61031c610398366004612e4b565b610a19565b3480156103a957600080fd5b506103bd6103b8366004612d37565b610bba565b005b3480156103cb57600080fd5b5061031c6103da366004612edf565b610c3e565b3480156103eb57600080fd5b506103bd6103fa366004612d37565b610c53565b34801561040b57600080fd5b506103bd61041a366004612edf565b610ce4565b34801561042b57600080fd5b506103bd61043a366004612f00565b610d18565b34801561044b57600080fd5b5061031c61045a366004612e0e565b610d39565b34801561046b57600080fd5b506103bd61047a366004612f00565b610d8b565b34801561048b57600080fd5b506103bd61049a366004612f54565b610dc1565b3480156104ab57600080fd5b506103bd6104ba366004612edf565b610e1e565b3480156104cb57600080fd5b506103bd6104da366004612d37565b610e52565b3480156104eb57600080fd5b506103bd6104fa366004612edf565b610ed6565b34801561050b57600080fd5b506103bd61051a366004612edf565b610f08565b34801561052b57600080fd5b5061027f61053a366004612edf565b610f3c565b34801561054b57600080fd5b5061031c61055a366004612edf565b610f47565b34801561056b57600080fd5b506102b561057a366004612edf565b610f95565b34801561058b57600080fd5b5061031c60175481565b3480156105a157600080fd5b5061031c6105b0366004612d37565b610fca565b3480156105c157600080fd5b5061031c6105d0366004612d37565b61100e565b3480156105e157600080fd5b506103bd6105f0366004612d37565b61110e565b34801561060157600080fd5b5061031c60125481565b34801561061757600080fd5b5060165461062b906001600160a01b031681565b60405161028c919061364c565b34801561064457600080fd5b5061027f610653366004612d37565b600d6020526000908152604090205460ff1681565b61031c610676366004612d79565b61116b565b34801561068757600080fd5b506103bd610696366004612edf565b611239565b3480156106a757600080fd5b5061027f6106b6366004612d37565b60196020526000908152604090205460ff1681565b3480156106d757600080fd5b5061027f6106e6366004612f00565b61126d565b3480156106f757600080fd5b506103bd610706366004612d37565b611298565b34801561071757600080fd5b506102d7611405565b34801561072c57600080fd5b50600b546102b5906001600160a01b031681565b34801561074c57600080fd5b5061031c600081565b34801561076157600080fd5b5061031c60135481565b34801561077757600080fd5b5061031c610786366004612edf565b611414565b34801561079757600080fd5b506009546102b5906001600160a01b031681565b3480156107b757600080fd5b506103bd6107c6366004612d37565b6114d3565b3480156107d757600080fd5b506102d76107e6366004612edf565b61157f565b3480156107f757600080fd5b506103bd610806366004612d37565b6115e5565b34801561081757600080fd5b506103bd610826366004612f00565b611674565b34801561083757600080fd5b50600f546102b5906001600160a01b031681565b34801561085757600080fd5b506103bd610866366004612d37565b611690565b34801561087757600080fd5b506103bd610886366004612d37565b611714565b34801561089757600080fd5b50600c546102b5906001600160a01b031681565b3480156108b757600080fd5b506103bd6108c6366004612edf565b611798565b3480156108d757600080fd5b506103bd6108e6366004612edf565b6117cc565b60006108f682611800565b92915050565b600e818154811061090c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6060600080546109359061390b565b80601f01602080910402602001604051908101604052809291908181526020018280546109619061390b565b80156109ae5780601f10610983576101008083540402835291602001916109ae565b820191906000526020600020905b81548152906001019060200180831161099157829003601f168201915b5050505050905090565b6060600e8054806020026020016040519081016040528092919081815260200182805480156109ae57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f2575050505050905090565b60006002601a541415610a475760405162461bcd60e51b8152600401610a3e9061375b565b60405180910390fd5b6002601a556016546040516331a9108f60e11b81526000916001600160a01b031690636352211e90610a7d908a9060040161357b565b60206040518083038186803b158015610a9557600080fd5b505afa158015610aa9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acd9190612d58565b90506001600160a01b0381163314610afb57335b60405163060296c760e31b8152600401610a3e9190613526565b610b47610b0988888861180b565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b925061186a915050565b610b5988610b548a61100e565b6118eb565b6000610b6482611a91565b90507f2acd987f463cc0a2358ed0e6aafd383842212a5d7b82c9fb5e0999a44733c490818989898d601754604051610ba1969594939291906137ea565b60405180910390a16001601a5598975050505050505050565b6000610bc581611ab7565b6001600160a01b038216610bec5760405163d92e233d60e01b815260040160405180910390fd5b600b546001600160a01b0383811691161415610c1b5760405163c23f6ccb60e01b815260040160405180910390fd5b50600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526008602052604090206001015490565b6000610c5e81611ab7565b6001600160a01b038216610c855760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1615610cbf5760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000908152601960205260409020805460ff19166001179055565b6000610cef81611ab7565b816011541415610d125760405163c23f6ccb60e01b815260040160405180910390fd5b50601155565b610d2182610c3e565b610d2a81611ab7565b610d348383611ac1565b505050565b6000610d4483610fca565b8210610d625760405162461bcd60e51b8152600401610a3e906136ab565b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b0381163314610db35760405162461bcd60e51b8152600401610a3e9061376b565b610dbd8282611b47565b5050565b6000610dcc81611ab7565b6016546001600160a01b0383811691161415610dfb5760405163c23f6ccb60e01b815260040160405180910390fd5b50601680546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e2981611ab7565b816012541415610e4c5760405163c23f6ccb60e01b815260040160405180910390fd5b50601255565b6000610e5d81611ab7565b6001600160a01b038216610e845760405163d92e233d60e01b815260040160405180910390fd5b6009546001600160a01b0383811691161415610eb35760405163c23f6ccb60e01b815260040160405180910390fd5b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b610ee03382611bae565b610efc5760405162461bcd60e51b8152600401610a3e906136eb565b610f0581611bd1565b50565b6000610f1381611ab7565b816018541415610f365760405163c23f6ccb60e01b815260040160405180910390fd5b50601855565b60006108f682611c6b565b6000610f5260065490565b8210610f705760405162461bcd60e51b8152600401610a3e9061374b565b60068281548110610f8357610f83613a02565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108f65760405162461bcd60e51b8152600401610a3e9061371b565b60006001600160a01b038216610ff25760405162461bcd60e51b8152600401610a3e906136db565b506001600160a01b031660009081526003602052604090205490565b600060175460001480156110225750601854155b1561102f57506000919050565b600c546001600160a01b03838116911614801561106457506001600160a01b0382166000908152600d602052604090205460ff165b801561107257506000601854115b1561107f57505060185490565b600b546001600160a01b0383811691161480156110b457506001600160a01b0382166000908152600d602052604090205460ff165b156110c157505060175490565b6001600160a01b0382166000908152600d602052604090205460ff16156110ee576108f682601754611c88565b81604051630ac29ab760e31b8152600401610a3e9190613526565b919050565b600061111981611ab7565b600c546001600160a01b03838116911614156111485760405163c23f6ccb60e01b815260040160405180910390fd5b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03861633146111835733610ae1565b6111cf611191878787611d27565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061186a915050565b6111dc87610b548961100e565b60006111e787611a91565b90507fba3afdf6e7965ed8d31aeefc9ffbaf04262d250621df85cef0ef13a8a4487cba818888888c6017546040516112249695949392919061377b565b60405180910390a190505b9695505050505050565b600061124481611ab7565b8160145414156112675760405163c23f6ccb60e01b815260040160405180910390fd5b50601455565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006112a381611ab7565b6001600160a01b0382166000908152600d602052604090205460ff166112de57816040516318317bd560e01b8152600401610a3e9190613526565b6001600160a01b0382166000908152600d60205260408120805460ff191690555b600e54811015610d3457826001600160a01b0316600e828154811061132657611326613a02565b6000918252602090912001546001600160a01b031614156113f357600e80546113519060019061388a565b8154811061136157611361613a02565b600091825260209091200154600e80546001600160a01b03909216918390811061138d5761138d613a02565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600e8054806113cc576113cc6139ec565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b806113fd81613965565b9150506112ff565b6060600180546109359061390b565b6016546000906001600160a01b031661144057604051630d7fe67b60e41b815260040160405180910390fd5b600061144b83610f95565b60165460405163294cdf0d60e01b81529192506001600160a01b03169063294cdf0d9061147c908490600401613526565b60206040518083038186803b15801561149457600080fd5b505afa1580156114a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cc9190612f75565b9392505050565b60006114de81611ab7565b6001600160a01b0382166000908152600d602052604090205460ff16156115185760405163f411c32760e01b815260040160405180910390fd5b506001600160a01b03166000818152600d60205260408120805460ff19166001908117909155600e805491820181559091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319169091179055565b606061158a82611d63565b6000611594611d88565b905060008151116115b457604051806020016040528060008152506114cc565b806115be84611d97565b6040516020016115cf92919061346d565b6040516020818303038152906040529392505050565b60006115f081611ab7565b6001600160a01b0382166116175760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03821660009081526019602052604090205460ff1661165257816040516324b1f80560e21b8152600401610a3e9190613526565b506001600160a01b03166000908152601960205260409020805460ff19169055565b61167d82610c3e565b61168681611ab7565b610d348383611b47565b600061169b81611ab7565b6001600160a01b0382166116c25760405163d92e233d60e01b815260040160405180910390fd5b600a546001600160a01b03838116911614156116f15760405163c23f6ccb60e01b815260040160405180910390fd5b50600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600061171f81611ab7565b6001600160a01b0382166117465760405163d92e233d60e01b815260040160405180910390fd5b600f546001600160a01b03838116911614156117755760405163c23f6ccb60e01b815260040160405180910390fd5b50600f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006117a381611ab7565b8160175414156117c65760405163c23f6ccb60e01b815260040160405180910390fd5b50601755565b60006117d781611ab7565b8160135414156117fa5760405163c23f6ccb60e01b815260040160405180910390fd5b50601355565b60006108f682611e94565b60006118627f34ec28456d08f4e49693917808b7282a69eadae2824d33b92474bc8bdfdb7be68585856040516020016118479493929190613609565b60405160208183030381529060405280519060200120611eb9565b949350505050565b60006118768484611ecc565b9050816001600160a01b0316816001600160a01b0316146118aa57604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b03811660009081526019602052604090205460ff166118e55780604051634a0bfec160e01b8152600401610a3e9190613526565b50505050565b806118f4575050565b6001600160a01b0382166000908152600d602052604090205460ff1661192f5781604051630ac29ab760e31b8152600401610a3e9190613526565b6001600160a01b038216611a755780341015611960578060405163091a6d0f60e01b8152600401610a3e919061357b565b600f546040516000916001600160a01b031690839061197e906134cc565b60006040518083038185875af1925050503d80600081146119bb576040519150601f19603f3d011682016040523d82523d6000602084013e6119c0565b606091505b50509050806119e2576040516312171d8360e31b815260040160405180910390fd5b81341115610d345760006119f63484611ef0565b9050336001600160a01b031681604051611a0f906134cc565b60006040518083038185875af1925050503d8060008114611a4c576040519150601f19603f3d011682016040523d82523d6000602084013e611a51565b606091505b505080925050816118e557604051633c31275160e21b815260040160405180910390fd5b600f54610dbd906001600160a01b038481169133911684611efc565b600080611a9d60155490565b9050611aad601580546001019055565b6108f68382611f54565b610f058133612030565b611acb828261126d565b610dbd5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611b51828261126d565b15610dbd5760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080611bba83610f95565b6001600160a01b0385811691161491505092915050565b6000611bdc82610f95565b9050611bea81600084612094565b6001600160a01b0381166000908152600360205260408120805460019290611c1390849061388a565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6001600160a01b0382166000908152600d602052604081205460ff161580611cbd5750600b546001600160a01b038481169116145b15611cdd578260405163961c9a4f60e01b8152600401610a3e9190613526565b6001600160a01b038316611d0f57600a54600b54611d08916001600160a01b0390811691168461209f565b90506108f6565b600b54611d089084906001600160a01b03168461209f565b60006118627fe84d61ea5268441d87c5a96690bcc830d3d14781947a5181464911a7ff7dcc5d8585856040516020016118479493929190613589565b611d6c81611c6b565b610f055760405162461bcd60e51b8152600401610a3e9061371b565b6060601080546109359061390b565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf81613965565b9150611dde9050600a83613857565b9150611dbf565b6000816001600160401b03811115611dff57611dff613a18565b6040519080825280601f01601f191660200182016040528015611e29576020820181803683370190505b5090505b841561186257611e3e60018361388a565b9150611e4b600a86613980565b611e5690603061383f565b60f81b818381518110611e6b57611e6b613a02565b60200101906001600160f81b031916908160001a905350611e8d600a86613857565b9450611e2d565b60006001600160e01b03198216637965db0b60e01b14806108f657506108f68261215d565b60006108f6611ec6612182565b83612275565b6000806000611edb85856122a8565b91509150611ee8816122ee565b509392505050565b60006114cc828461388a565b6118e5846323b872dd60e01b858585604051602401611f1d93929190613534565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526123d3565b6001600160a01b038216611f7a5760405162461bcd60e51b8152600401610a3e9061369b565b611f8381611c6b565b15611fa05760405162461bcd60e51b8152600401610a3e9061370b565b611fac60008383612094565b6001600160a01b0382166000908152600360205260408120805460019290611fd590849061383f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b61203a828261126d565b610dbd57612052816001600160a01b03166014612462565b61205d836020612462565b60405160200161206e9291906134d4565b60408051601f198184030181529082905262461bcd60e51b8252610a3e9160040161365a565b610d348383836125cd565b60006060806120ae8686612685565b6009546040516307c0329d60e21b81529192506001600160a01b031690631f00ca74906120e190879085906004016137ca565b60006040518083038186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121359190810190612e84565b91508160008151811061214a5761214a613a02565b6020026020010151925050509392505050565b60006001600160e01b0319821663780e9d6360e01b14806108f657506108f682612817565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156121db57507f000000000000000000000000000000000000000000000000000000000000000046145b1561220557507f000000000000000000000000000000000000000000000000000000000000000090565b6122707f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612867565b905090565b6000828260405160200161228a92919061349b565b60405160208183030381529060405280519060200120905092915050565b6000808251604114156122df5760208301516040840151606085015160001a6122d3878285856128a1565b945094505050506122e7565b506000905060025b9250929050565b6000816004811115612302576123026139c0565b141561230b5750565b600181600481111561231f5761231f6139c0565b141561233d5760405162461bcd60e51b8152600401610a3e9061366b565b6002816004811115612351576123516139c0565b141561236f5760405162461bcd60e51b8152600401610a3e9061368b565b6003816004811115612383576123836139c0565b14156123a15760405162461bcd60e51b8152600401610a3e906136bb565b60048160048111156123b5576123b56139c0565b1415610f055760405162461bcd60e51b8152600401610a3e906136fb565b6000612428826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166129779092919063ffffffff16565b805190915015610d3457808060200190518101906124469190612ebe565b610d345760405162461bcd60e51b8152600401610a3e9061373b565b6060600061247183600261386b565b61247c90600261383f565b6001600160401b0381111561249357612493613a18565b6040519080825280601f01601f1916602001820160405280156124bd576020820181803683370190505b509050600360fc1b816000815181106124d8576124d8613a02565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061250757612507613a02565b60200101906001600160f81b031916908160001a905350600061252b84600261386b565b61253690600161383f565b90505b60018111156125ae576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256a5761256a613a02565b1a60f81b82828151811061258057612580613a02565b60200101906001600160f81b031916908160001a90535060049490941c936125a7816138f4565b9050612539565b5083156114cc5760405162461bcd60e51b8152600401610a3e9061367b565b6001600160a01b0383166126285761262381600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b61264b565b816001600160a01b0316836001600160a01b03161461264b5761264b8382612986565b6001600160a01b03821661266257610d3481612a23565b826001600160a01b0316826001600160a01b031614610d3457610d348282612ad2565b600a546060906001600160a01b03848116911614806126b15750600a546001600160a01b038381169116145b1561277b5760408051600280825260608201835260009260208301908036833701905050600a549091506001600160a01b038581169116146126f35783612700565b600a546001600160a01b03165b8160008151811061271357612713613a02565b6001600160a01b039283166020918202929092010152600a5484821691161461273c5782612749565b600a546001600160a01b03165b8160018151811061275c5761275c613a02565b6001600160a01b039092166020928302919091019091015290506108f6565b604080516003808252608082019092526000916020820160608036833701905050905083816000815181106127b2576127b2613a02565b6001600160a01b039283166020918202929092010152600a548251911690829060019081106127e3576127e3613a02565b60200260200101906001600160a01b031690816001600160a01b031681525050828160028151811061275c5761275c613a02565b60006001600160e01b031982166313f2a32f60e01b148061284857506001600160e01b03198216635b5e139f60e01b145b806108f657506301ffc9a760e01b6001600160e01b03198316146108f6565b600083838346306040516020016128829594939291906135c7565b6040516020818303038152906040528051906020012090509392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b038311156128ce575060009050600361296e565b8460ff16601b141580156128e657508460ff16601c14155b156128f7575060009050600461296e565b60006001878787876040516000815260200160405260405161291c9493929190613624565b6020604051602081039080840390855afa15801561293e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129675760006001925092505061296e565b9150600090505b94509492505050565b60606118628484600085612b16565b6000600161299384610fca565b61299d919061388a565b6000838152600560205260409020549091508082146129f0576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b600654600090612a359060019061388a565b60008381526007602052604081205460068054939450909284908110612a5d57612a5d613a02565b906000526020600020015490508060068381548110612a7e57612a7e613a02565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480612ab657612ab66139ec565b6001900381819060005260206000200160009055905550505050565b6000612add83610fca565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b606082471015612b385760405162461bcd60e51b8152600401610a3e906136cb565b6001600160a01b0385163b612b5f5760405162461bcd60e51b8152600401610a3e9061372b565b600080866001600160a01b03168587604051612b7b9190613461565b60006040518083038185875af1925050503d8060008114612bb8576040519150601f19603f3d011682016040523d82523d6000602084013e612bbd565b606091505b5091509150612bcd828286612bd8565b979650505050505050565b60608315612be75750816114cc565b825115612bf75782518084602001fd5b8160405162461bcd60e51b8152600401610a3e919061365a565b6000612c24612c1f8461381c565b613805565b90508083825260208201905082856020860282011115612c4657612c46600080fd5b60005b85811015612c725781612c5c8882612d2c565b8452506020928301929190910190600101612c49565b5050509392505050565b80356108f681613a38565b80516108f681613a38565b600082601f830112612ca657612ca6600080fd5b8151611862848260208601612c11565b80516108f681613a4c565b80356108f681613a54565b80356108f681613a5a565b60008083601f840112612cec57612cec600080fd5b5081356001600160401b03811115612d0657612d06600080fd5b6020830191508360018202830111156122e7576122e7600080fd5b80356108f681613a6a565b80516108f681613a54565b600060208284031215612d4c57612d4c600080fd5b60006118628484612c7c565b600060208284031215612d6d57612d6d600080fd5b60006118628484612c87565b60008060008060008060a08789031215612d9557612d95600080fd5b6000612da18989612c7c565b9650506020612db289828a01612c7c565b9550506040612dc389828a01612c7c565b9450506060612dd489828a01612cc1565b93505060808701356001600160401b03811115612df357612df3600080fd5b612dff89828a01612cd7565b92509250509295509295509295565b60008060408385031215612e2457612e24600080fd5b6000612e308585612c7c565b9250506020612e4185828601612cc1565b9150509250929050565b60008060008060008060a08789031215612e6757612e67600080fd5b6000612e738989612c7c565b9650506020612db289828a01612cc1565b600060208284031215612e9957612e99600080fd5b81516001600160401b03811115612eb257612eb2600080fd5b61186284828501612c92565b600060208284031215612ed357612ed3600080fd5b60006118628484612cb6565b600060208284031215612ef457612ef4600080fd5b60006118628484612cc1565b60008060408385031215612f1657612f16600080fd5b6000612f228585612cc1565b9250506020612e4185828601612c7c565b600060208284031215612f4857612f48600080fd5b60006118628484612ccc565b600060208284031215612f6957612f69600080fd5b60006118628484612d21565b600060208284031215612f8a57612f8a600080fd5b60006118628484612d2c565b6000612fa28383612faa565b505060200190565b612fb3816138a1565b82525050565b6000612fc3825190565b80845260209384019383018060005b83811015612ff7578151612fe68882612f96565b975060208301925050600101612fd2565b509495945050505050565b801515612fb3565b80612fb3565b600061301a825190565b6130288185602086016138c8565b9290920192915050565b612fb3816138bd565b6000613045825190565b80845260208401935061305c8185602086016138c8565b61306581613a2e565b9093019392505050565b601881526000602082017745434453413a20696e76616c6964207369676e617475726560401b815291505b5060200190565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e749101908152600061309a565b601f81526000602082017f45434453413a20696e76616c6964207369676e6174757265206c656e677468008152915061309a565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061309a565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202773272076616c815261756560f01b6020820152915061317c565b602681526000602082017f416464726573733a20696e73756666696369656e742062616c616e636520666f8152651c8818d85b1b60d21b6020820152915061317c565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b6020820152915061317c565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061309a565b602281526000602082017f45434453413a20696e76616c6964207369676e6174757265202776272076616c815261756560f01b6020820152915061317c565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061309a565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061309a565b601d81526000602082017f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000008152915061309a565b602a81526000602082017f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b6020820152915061317c565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b6020820152915061317c565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c008152915061309a565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b6020820152915061317c565b60ff8116612fb3565b60006114cc8284613010565b60006134798285613010565b91506134858284613010565b64173539b7b760d91b8152915060058201611862565b61190160f01b815260020160006134b2828561300a565b6020820191506134c2828461300a565b5060200192915050565b6000816108f6565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006135008285613010565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110191506118628284613010565b602081016108f68284612faa565b606081016135428286612faa565b61354f6020830185612faa565b611862604083018461300a565b602080825281016114cc8184612fb9565b602081016108f68284613002565b602081016108f6828461300a565b60808101613597828761300a565b6135a46020830186612faa565b6135b16040830185612faa565b6135be606083018461300a565b95945050505050565b60a081016135d5828861300a565b6135e2602083018761300a565b6135ef604083018661300a565b6135fc606083018561300a565b61122f6080830184612faa565b60808101613617828761300a565b6135a4602083018661300a565b60808101613632828761300a565b61363f6020830186613458565b6135b1604083018561300a565b602081016108f68284613032565b602080825281016114cc818461303b565b602080825281016108f68161306f565b602080825281016108f6816130a1565b602080825281016108f6816130d3565b602080825281016108f681613107565b602080825281016108f68161313b565b602080825281016108f681613183565b602080825281016108f6816131c2565b602080825281016108f681613205565b602080825281016108f681613248565b602080825281016108f68161327c565b602080825281016108f6816132bb565b602080825281016108f6816132eb565b602080825281016108f681613317565b602080825281016108f68161334b565b602080825281016108f681613392565b602080825281016108f6816133d8565b602080825281016108f68161340c565b60c08101613789828961300a565b6137966020830188612faa565b6137a36040830187612faa565b6137b0606083018661300a565b6137bd6080830185612faa565b612bcd60a083018461300a565b604081016137d8828561300a565b81810360208301526118628184612fb9565b60c081016137f8828961300a565b613796602083018861300a565b600061381060405190565b90506111098282613938565b60006001600160401b0382111561383557613835613a18565b5060209081020190565b6000821982111561385257613852613994565b500190565b600082613866576138666139aa565b500490565b600081600019048311821515161561388557613885613994565b500290565b60008282101561389c5761389c613994565b500390565b60006001600160a01b0382166108f6565b60006108f6826138a1565b60006108f6826138b2565b60005b838110156138e35781810151838201526020016138cb565b838111156118e55750506000910152565b60008161390357613903613994565b506000190190565b60028104600182168061391f57607f821691505b60208210811415613932576139326139d6565b50919050565b61394182613a2e565b81018181106001600160401b038211171561395e5761395e613a18565b6040525050565b600060001982141561397957613979613994565b5060010190565b60008261398f5761398f6139aa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b613a41816138a1565b8114610f0557600080fd5b801515613a41565b80613a41565b6001600160e01b03198116613a41565b613a41816138b256fea2646970667358221220d10d652bb5f49377047195872f4159a146a1be86a941ac6fb28339769132b85264736f6c63430008070033", - "devdoc": { - "author": "Masa Finance", - "details": "Soulbound 2FA, that inherits from the SBT contract.", - "kind": "dev", - "methods": { - "addAuthority(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_authority": "New authority to add" - } - }, - "balanceOf(address)": { - "details": "See {ISBT-balanceOf}." - }, - "burn(uint256)": { - "details": "Burns `tokenId`. See {SBT-_burn}. Requirements: - The caller must own `tokenId` or be an approved operator." - }, - "constructor": { - "details": "Creates a new soulbound 2FA, inheriting from the SBT contract.", - "params": { - "admin": "Administrator of the smart contract", - "baseTokenURI": "Base URI of the token", - "paymentParams": "Payment gateway params", - "soulboundIdentity": "Address of the SoulboundIdentity contract" - } - }, - "disablePaymentMethod(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_paymentMethod": "Token to remove" - } - }, - "enablePaymentMethod(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_paymentMethod": "New token to add" - } - }, - "exists(uint256)": { - "details": "Returns true if the token has been minted", - "params": { - "tokenId": "Token to check" - }, - "returns": { - "_0": "True if the token exists" - } - }, - "getEnabledPaymentMethods()": { - "details": "Returns the address of all available payment methods", - "returns": { - "_0": "Array of all enabled payment methods" - } - }, - "getIdentityId(uint256)": { - "params": { - "tokenId": "Id of the token" - }, - "returns": { - "_0": "Id of the identity" - } - }, - "getMintPrice(address)": { - "details": "Returns current pricing for minting", - "params": { - "paymentMethod": "Address of token that user want to pay" - }, - "returns": { - "_0": "Current price for minting in the given payment method" - } - }, - "getRoleAdmin(bytes32)": { - "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." - }, - "grantRole(bytes32,address)": { - "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event." - }, - "hasRole(bytes32,address)": { - "details": "Returns `true` if `account` has been granted `role`." - }, - "mint(address,address,address,uint256,bytes)": { - "details": "The caller must have the MINTER role", - "params": { - "authorityAddress": "Address of the authority that signed the message", - "paymentMethod": "Address of token that user want to pay", - "signature": "Signature of the message", - "signatureDate": "Date of the signature", - "to": "The address to mint the SBT to" - }, - "returns": { - "_0": "The SBT ID of the newly minted SBT" - } - }, - "mint(address,uint256,address,uint256,bytes)": { - "details": "The caller must have the MINTER role", - "params": { - "authorityAddress": "Address of the authority that signed the message", - "identityId": "TokenId of the identity to mint the NFT to", - "paymentMethod": "Address of token that user want to pay", - "signature": "Signature of the message", - "signatureDate": "Date of the signature" - }, - "returns": { - "_0": "The NFT ID of the newly minted SBT" - } - }, - "name()": { - "details": "See {ISBTMetadata-name}." - }, - "ownerOf(uint256)": { - "details": "See {ISBT-ownerOf}." - }, - "removeAuthority(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_authority": "Authority to remove" - } - }, - "renounceRole(bytes32,address)": { - "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event." - }, - "revokeRole(bytes32,address)": { - "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event." - }, - "setAddLinkPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_addLinkPrice": "New price for adding the link in SoulLinker in stable coin" - } - }, - "setAddLinkPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_addLinkPriceMASA": "New price for adding the link in SoulLinker in MASA" - } - }, - "setMasaToken(address)": { - "details": "The caller must have the admin role to call this function It can be set to address(0) to disable paying in MASA", - "params": { - "_masaToken": "New utility token to pay the fee in" - } - }, - "setMintPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_mintPrice": "New price of minting in stable coin" - } - }, - "setMintPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_mintPriceMASA": "New price of minting in MASA" - } - }, - "setQueryLinkPrice(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_queryLinkPrice": "New price for reading data in SoulLinker in stable coin" - } - }, - "setQueryLinkPriceMASA(uint256)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_queryLinkPriceMASA": "New price for reading data in SoulLinker in MASA" - } - }, - "setReserveWallet(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_reserveWallet": "New reserve wallet" - } - }, - "setSoulboundIdentity(address)": { - "details": "The caller must be the admin to call this function", - "params": { - "_soulboundIdentity": "Address of the SoulboundIdentity contract" - } - }, - "setStableCoin(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_stableCoin": "New stable coin to pay the fee in" - } - }, - "setSwapRouter(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_swapRouter": "New swap router address" - } - }, - "setWrappedNativeToken(address)": { - "details": "The caller must have the admin role to call this function", - "params": { - "_wrappedNativeToken": "New wrapped native token address" - } - }, - "supportsInterface(bytes4)": { - "details": "Interface identification is specified in ERC-165.", - "params": { - "interfaceId": "The interface identifier, as specified in ERC-165" - }, - "returns": { - "_0": "`true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise" - } - }, - "symbol()": { - "details": "See {ISBTMetadata-symbol}." - }, - "tokenByIndex(uint256)": { - "details": "See {ISBTEnumerable-tokenByIndex}." - }, - "tokenOfOwnerByIndex(address,uint256)": { - "details": "See {ISBTEnumerable-tokenOfOwnerByIndex}." - }, - "tokenURI(uint256)": { - "details": "Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the \"ERC721 Metadata JSON Schema\".", - "params": { - "tokenId": "SBT to get the URI of" - }, - "returns": { - "_0": "URI of the SBT" - } - }, - "totalSupply()": { - "details": "See {ISBTEnumerable-totalSupply}." - } - }, - "title": "Soulbound Two-factor authentication (2FA)", - "version": 1 - }, - "userdoc": { - "kind": "user", - "methods": { - "addAuthority(address)": { - "notice": "Adds a new authority to the list of authorities" - }, - "constructor": { - "notice": "Creates a new soulbound Two-factor authentication (2FA)" - }, - "disablePaymentMethod(address)": { - "notice": "Removes a token as a valid payment method" - }, - "enablePaymentMethod(address)": { - "notice": "Adds a new token as a valid payment method" - }, - "exists(uint256)": { - "notice": "Returns true if the token exists" - }, - "getEnabledPaymentMethods()": { - "notice": "Returns all available payment methods" - }, - "getIdentityId(uint256)": { - "notice": "Returns the identityId owned by the given token" - }, - "getMintPrice(address)": { - "notice": "Returns the price for minting" - }, - "mint(address,address,address,uint256,bytes)": { - "notice": "Mints a new SBT" - }, - "mint(address,uint256,address,uint256,bytes)": { - "notice": "Mints a new SBT" - }, - "removeAuthority(address)": { - "notice": "Removes an authority from the list of authorities" - }, - "setAddLinkPrice(uint256)": { - "notice": "Sets the price for adding the link in SoulLinker in stable coin" - }, - "setAddLinkPriceMASA(uint256)": { - "notice": "Sets the price for adding the link in SoulLinker in MASA" - }, - "setMasaToken(address)": { - "notice": "Sets the utility token to pay the fee in (MASA)" - }, - "setMintPrice(uint256)": { - "notice": "Sets the price of minting in stable coin" - }, - "setMintPriceMASA(uint256)": { - "notice": "Sets the price of minting in MASA" - }, - "setQueryLinkPrice(uint256)": { - "notice": "Sets the price for reading data in SoulLinker in stable coin" - }, - "setQueryLinkPriceMASA(uint256)": { - "notice": "Sets the price for reading data in SoulLinker in MASA" - }, - "setReserveWallet(address)": { - "notice": "Set the reserve wallet" - }, - "setSoulboundIdentity(address)": { - "notice": "Sets the SoulboundIdentity contract address linked to this SBT" - }, - "setStableCoin(address)": { - "notice": "Sets the stable coin to pay the fee in (USDC)" - }, - "setSwapRouter(address)": { - "notice": "Sets the swap router address" - }, - "setWrappedNativeToken(address)": { - "notice": "Sets the wrapped native token address" - }, - "supportsInterface(bytes4)": { - "notice": "Query if a contract implements an interface" - }, - "tokenURI(uint256)": { - "notice": "A distinct Uniform Resource Identifier (URI) for a given asset." - } - }, - "notice": "Soulbound token that represents a Two-factor authentication (2FA)", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 9702, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_name", - "offset": 0, - "slot": "0", - "type": "t_string_storage" - }, - { - "astId": 9704, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_symbol", - "offset": 0, - "slot": "1", - "type": "t_string_storage" - }, - { - "astId": 9708, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_owners", - "offset": 0, - "slot": "2", - "type": "t_mapping(t_uint256,t_address)" - }, - { - "astId": 9712, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_balances", - "offset": 0, - "slot": "3", - "type": "t_mapping(t_address,t_uint256)" - }, - { - "astId": 10171, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_ownedTokens", - "offset": 0, - "slot": "4", - "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))" - }, - { - "astId": 10175, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_ownedTokensIndex", - "offset": 0, - "slot": "5", - "type": "t_mapping(t_uint256,t_uint256)" - }, - { - "astId": 10178, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_allTokens", - "offset": 0, - "slot": "6", - "type": "t_array(t_uint256)dyn_storage" - }, - { - "astId": 10182, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_allTokensIndex", - "offset": 0, - "slot": "7", - "type": "t_mapping(t_uint256,t_uint256)" - }, - { - "astId": 24, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_roles", - "offset": 0, - "slot": "8", - "type": "t_mapping(t_bytes32,t_struct(RoleData)19_storage)" - }, - { - "astId": 7619, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "swapRouter", - "offset": 0, - "slot": "9", - "type": "t_address" - }, - { - "astId": 7621, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "wrappedNativeToken", - "offset": 0, - "slot": "10", - "type": "t_address" - }, - { - "astId": 7623, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "stableCoin", - "offset": 0, - "slot": "11", - "type": "t_address" - }, - { - "astId": 7625, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "masaToken", - "offset": 0, - "slot": "12", - "type": "t_address" - }, - { - "astId": 7629, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "enabledPaymentMethod", - "offset": 0, - "slot": "13", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 7632, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "enabledPaymentMethods", - "offset": 0, - "slot": "14", - "type": "t_array(t_address)dyn_storage" - }, - { - "astId": 7634, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "reserveWallet", - "offset": 0, - "slot": "15", - "type": "t_address" - }, - { - "astId": 8976, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_baseTokenURI", - "offset": 0, - "slot": "16", - "type": "t_string_storage" - }, - { - "astId": 8979, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "addLinkPrice", - "offset": 0, - "slot": "17", - "type": "t_uint256" - }, - { - "astId": 8982, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "addLinkPriceMASA", - "offset": 0, - "slot": "18", - "type": "t_uint256" - }, - { - "astId": 8985, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "queryLinkPrice", - "offset": 0, - "slot": "19", - "type": "t_uint256" - }, - { - "astId": 8988, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "queryLinkPriceMASA", - "offset": 0, - "slot": "20", - "type": "t_uint256" - }, - { - "astId": 9297, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_tokenIdCounter", - "offset": 0, - "slot": "21", - "type": "t_struct(Counter)2798_storage" - }, - { - "astId": 9300, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "soulboundIdentity", - "offset": 0, - "slot": "22", - "type": "t_contract(ISoulboundIdentity)8379" - }, - { - "astId": 9302, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "mintPrice", - "offset": 0, - "slot": "23", - "type": "t_uint256" - }, - { - "astId": 9304, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "mintPriceMASA", - "offset": 0, - "slot": "24", - "type": "t_uint256" - }, - { - "astId": 9308, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "authorities", - "offset": 0, - "slot": "25", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 624, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_status", - "offset": 0, - "slot": "26", - "type": "t_uint256" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_address)dyn_storage": { - "base": "t_address", - "encoding": "dynamic_array", - "label": "address[]", - "numberOfBytes": "32" - }, - "t_array(t_uint256)dyn_storage": { - "base": "t_uint256", - "encoding": "dynamic_array", - "label": "uint256[]", - "numberOfBytes": "32" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_bytes32": { - "encoding": "inplace", - "label": "bytes32", - "numberOfBytes": "32" - }, - "t_contract(ISoulboundIdentity)8379": { - "encoding": "inplace", - "label": "contract ISoulboundIdentity", - "numberOfBytes": "20" - }, - "t_mapping(t_address,t_bool)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => mapping(uint256 => uint256))", - "numberOfBytes": "32", - "value": "t_mapping(t_uint256,t_uint256)" - }, - "t_mapping(t_address,t_uint256)": { - "encoding": "mapping", - "key": "t_address", - "label": "mapping(address => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_mapping(t_bytes32,t_struct(RoleData)19_storage)": { - "encoding": "mapping", - "key": "t_bytes32", - "label": "mapping(bytes32 => struct AccessControl.RoleData)", - "numberOfBytes": "32", - "value": "t_struct(RoleData)19_storage" - }, - "t_mapping(t_uint256,t_address)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => address)", - "numberOfBytes": "32", - "value": "t_address" - }, - "t_mapping(t_uint256,t_uint256)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => uint256)", - "numberOfBytes": "32", - "value": "t_uint256" - }, - "t_string_storage": { - "encoding": "bytes", - "label": "string", - "numberOfBytes": "32" - }, - "t_struct(Counter)2798_storage": { - "encoding": "inplace", - "label": "struct Counters.Counter", - "members": [ - { - "astId": 2797, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "_value", - "offset": 0, - "slot": "0", - "type": "t_uint256" - } - ], - "numberOfBytes": "32" - }, - "t_struct(RoleData)19_storage": { - "encoding": "inplace", - "label": "struct AccessControl.RoleData", - "members": [ - { - "astId": 16, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "members", - "offset": 0, - "slot": "0", - "type": "t_mapping(t_address,t_bool)" - }, - { - "astId": 18, - "contract": "contracts/Soulbound2FA.sol:Soulbound2FA", - "label": "adminRole", - "offset": 0, - "slot": "1", - "type": "t_bytes32" - } - ], - "numberOfBytes": "64" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - } - } - } -} \ No newline at end of file diff --git a/deployments/mumbai/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json b/deployments/mumbai/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json deleted file mode 100644 index 456dfd96a..000000000 --- a/deployments/mumbai/solcInputs/ba20b0945b3d8227cd3974f83be2ddaf.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "contracts/dex/PaymentGateway.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/dex/IUniswapRouter.sol\";\n\n/// @title Pay using a Decentralized automated market maker (AMM) when needed\n/// @author Masa Finance\n/// @notice Smart contract to call a Dex AMM smart contract to pay to a reserve wallet recipient\n/// @dev This smart contract will call the Uniswap Router interface, based on\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\nabstract contract PaymentGateway is AccessControl {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n\n struct PaymentParams {\n address swapRouter; // Swap router address\n address wrappedNativeToken; // Wrapped native token address\n address stableCoin; // Stable coin to pay the fee in (USDC)\n address masaToken; // Utility token to pay the fee in (MASA)\n address reserveWallet; // Wallet that will receive the fee\n }\n\n /* ========== STATE VARIABLES =========================================== */\n\n address public swapRouter;\n address public wrappedNativeToken;\n\n address public stableCoin; // USDC. It also needs to be enabled as payment method, if we want to pay in USDC\n address public masaToken; // MASA. It also needs to be enabled as payment method, if we want to pay in MASA\n\n // enabled payment methods: ETH and ERC20 tokens\n mapping(address => bool) public enabledPaymentMethod;\n address[] public enabledPaymentMethods;\n\n address public reserveWallet;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new Dex AMM\n /// @dev Creates a new Decentralized automated market maker (AMM) smart contract,\n // that will call the Uniswap Router interface\n /// @param admin Administrator of the smart contract\n /// @param paymentParams Payment params\n constructor(address admin, PaymentParams memory paymentParams) {\n if (paymentParams.swapRouter == address(0)) revert ZeroAddress();\n if (paymentParams.wrappedNativeToken == address(0))\n revert ZeroAddress();\n if (paymentParams.stableCoin == address(0)) revert ZeroAddress();\n if (paymentParams.reserveWallet == address(0)) revert ZeroAddress();\n\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n\n swapRouter = paymentParams.swapRouter;\n wrappedNativeToken = paymentParams.wrappedNativeToken;\n stableCoin = paymentParams.stableCoin;\n masaToken = paymentParams.masaToken;\n reserveWallet = paymentParams.reserveWallet;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the swap router address\n /// @dev The caller must have the admin role to call this function\n /// @param _swapRouter New swap router address\n function setSwapRouter(address _swapRouter)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_swapRouter == address(0)) revert ZeroAddress();\n if (swapRouter == _swapRouter) revert SameValue();\n swapRouter = _swapRouter;\n }\n\n /// @notice Sets the wrapped native token address\n /// @dev The caller must have the admin role to call this function\n /// @param _wrappedNativeToken New wrapped native token address\n function setWrappedNativeToken(address _wrappedNativeToken)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_wrappedNativeToken == address(0)) revert ZeroAddress();\n if (wrappedNativeToken == _wrappedNativeToken) revert SameValue();\n wrappedNativeToken = _wrappedNativeToken;\n }\n\n /// @notice Sets the stable coin to pay the fee in (USDC)\n /// @dev The caller must have the admin role to call this function\n /// @param _stableCoin New stable coin to pay the fee in\n function setStableCoin(address _stableCoin)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_stableCoin == address(0)) revert ZeroAddress();\n if (stableCoin == _stableCoin) revert SameValue();\n stableCoin = _stableCoin;\n }\n\n /// @notice Sets the utility token to pay the fee in (MASA)\n /// @dev The caller must have the admin role to call this function\n /// It can be set to address(0) to disable paying in MASA\n /// @param _masaToken New utility token to pay the fee in\n function setMasaToken(address _masaToken)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (masaToken == _masaToken) revert SameValue();\n masaToken = _masaToken;\n }\n\n /// @notice Adds a new token as a valid payment method\n /// @dev The caller must have the admin role to call this function\n /// @param _paymentMethod New token to add\n function enablePaymentMethod(address _paymentMethod)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (enabledPaymentMethod[_paymentMethod]) revert AlreadyAdded();\n\n enabledPaymentMethod[_paymentMethod] = true;\n enabledPaymentMethods.push(_paymentMethod);\n }\n\n /// @notice Removes a token as a valid payment method\n /// @dev The caller must have the admin role to call this function\n /// @param _paymentMethod Token to remove\n function disablePaymentMethod(address _paymentMethod)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (!enabledPaymentMethod[_paymentMethod])\n revert NonExistingErc20Token(_paymentMethod);\n\n enabledPaymentMethod[_paymentMethod] = false;\n for (uint256 i = 0; i < enabledPaymentMethods.length; i++) {\n if (enabledPaymentMethods[i] == _paymentMethod) {\n enabledPaymentMethods[i] = enabledPaymentMethods[\n enabledPaymentMethods.length - 1\n ];\n enabledPaymentMethods.pop();\n break;\n }\n }\n }\n\n /// @notice Set the reserve wallet\n /// @dev The caller must have the admin role to call this function\n /// @param _reserveWallet New reserve wallet\n function setReserveWallet(address _reserveWallet)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_reserveWallet == address(0)) revert ZeroAddress();\n if (_reserveWallet == reserveWallet) revert SameValue();\n reserveWallet = _reserveWallet;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns all available payment methods\n /// @dev Returns the address of all available payment methods\n /// @return Array of all enabled payment methods\n function getEnabledPaymentMethods()\n external\n view\n returns (address[] memory)\n {\n return enabledPaymentMethods;\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /// @notice Converts an amount from a stable coin to a payment method amount\n /// @dev This method will perform the swap between the stable coin and the\n /// payment method, and return the amount of the payment method,\n /// performing the swap if necessary\n /// @param paymentMethod Address of token that user want to pay\n /// @param amount Price to be converted in the specified payment method\n function _convertFromStableCoin(address paymentMethod, uint256 amount)\n internal\n view\n returns (uint256)\n {\n if (!enabledPaymentMethod[paymentMethod] || paymentMethod == stableCoin)\n revert InvalidToken(paymentMethod);\n\n if (paymentMethod == address(0)) {\n return _estimateSwapAmount(wrappedNativeToken, stableCoin, amount);\n } else {\n return _estimateSwapAmount(paymentMethod, stableCoin, amount);\n }\n }\n\n /// @notice Performs the payment in any payment method\n /// @dev This method will transfer the funds to the reserve wallet, performing\n /// the swap if necessary\n /// @param paymentMethod Address of token that user want to pay\n /// @param amount Price to be paid in the specified payment method\n function _pay(address paymentMethod, uint256 amount) internal {\n if (amount == 0) return;\n if (!enabledPaymentMethod[paymentMethod])\n revert InvalidPaymentMethod(paymentMethod);\n if (paymentMethod == address(0)) {\n // ETH\n if (msg.value < amount) revert InsufficientEthAmount(amount);\n (bool success, ) = payable(reserveWallet).call{value: amount}(\"\");\n if (!success) revert TransferFailed();\n if (msg.value > amount) {\n // return diff\n uint256 refund = msg.value.sub(amount);\n (success, ) = payable(msg.sender).call{value: refund}(\"\");\n if (!success) revert RefundFailed();\n }\n } else {\n // ERC20 token, including MASA and USDC\n IERC20(paymentMethod).safeTransferFrom(\n msg.sender,\n reserveWallet,\n amount\n );\n }\n }\n\n function _estimateSwapAmount(\n address _fromToken,\n address _toToken,\n uint256 _amountOut\n ) private view returns (uint256) {\n uint256[] memory amounts;\n address[] memory path;\n path = _getPathFromTokenToToken(_fromToken, _toToken);\n amounts = IUniswapRouter(swapRouter).getAmountsIn(_amountOut, path);\n return amounts[0];\n }\n\n function _getPathFromTokenToToken(address fromToken, address toToken)\n private\n view\n returns (address[] memory)\n {\n if (fromToken == wrappedNativeToken || toToken == wrappedNativeToken) {\n address[] memory path = new address[](2);\n path[0] = fromToken == wrappedNativeToken\n ? wrappedNativeToken\n : fromToken;\n path[1] = toToken == wrappedNativeToken\n ? wrappedNativeToken\n : toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = fromToken;\n path[1] = wrappedNativeToken;\n path[2] = toToken;\n return path;\n }\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "@openzeppelin/contracts/access/AccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/IERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" - }, - "@openzeppelin/contracts/utils/math/SafeMath.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n return a * b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(\n uint256 a,\n uint256 b,\n string memory errorMessage\n ) internal pure returns (uint256) {\n unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n" - }, - "contracts/libraries/Errors.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nerror AddressDoesNotHaveIdentity(address to);\nerror AlreadyAdded();\nerror AuthorityNotExists(address authority);\nerror CallerNotOwner(address caller);\nerror CallerNotReader(address caller);\nerror CreditScoreAlreadyCreated(address to);\nerror IdentityAlreadyCreated(address to);\nerror IdentityOwnerIsReader(uint256 readerIdentityId);\nerror InsufficientEthAmount(uint256 amount);\nerror IdentityOwnerNotTokenOwner(uint256 tokenId, uint256 ownerIdentityId);\nerror InvalidPaymentMethod(address paymentMethod);\nerror InvalidSignature();\nerror InvalidSignatureDate(uint256 signatureDate);\nerror InvalidToken(address token);\nerror InvalidTokenURI(string tokenURI);\nerror LinkAlreadyExists(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId,\n uint256 signatureDate\n);\nerror LinkAlreadyRevoked();\nerror LinkDoesNotExist();\nerror NameAlreadyExists(string name);\nerror NameNotFound(string name);\nerror NameRegisteredByOtherAccount(string name, uint256 tokenId);\nerror NotAuthorized(address signer);\nerror NonExistingErc20Token(address erc20token);\nerror NotLinkedToAnIdentitySBT();\nerror RefundFailed();\nerror SameValue();\nerror SBTAlreadyLinked(address token);\nerror SoulNameContractNotSet();\nerror TokenNotFound(uint256 tokenId);\nerror TransferFailed();\nerror URIAlreadyExists(string tokenURI);\nerror ValidPeriodExpired(uint256 expirationDate);\nerror ZeroAddress();\nerror ZeroLengthName(string name);\nerror ZeroYearsPeriod(uint256 yearsPeriod);\n" - }, - "contracts/interfaces/dex/IUniswapRouter.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\n/// @title Uniswap Router interface\n/// @author Masa Finance\n/// @notice Interface of the Uniswap Router contract\n/// @dev This interface is used to interact with the Uniswap Router contract,\n/// and gets the most important functions of the contract. It's based on\n/// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router01.sol\ninterface IUniswapRouter {\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n}\n" - }, - "@openzeppelin/contracts/access/IAccessControl.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" - }, - "@openzeppelin/contracts/utils/Context.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Strings.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/ERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" - }, - "@openzeppelin/contracts/utils/introspection/IERC165.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" - }, - "contracts/SoulStore.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./dex/PaymentGateway.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\n\n/// @title Soul Store\n/// @author Masa Finance\n/// @notice Soul Store, that can mint new Soulbound Identities and Soul Name NFTs, paying a fee\n/// @dev From this smart contract we can mint new Soulbound Identities and Soul Name NFTs.\n/// This minting can be done paying a fee in ETH, USDC or MASA\ncontract SoulStore is PaymentGateway, Pausable, ReentrancyGuard, EIP712 {\n using SafeMath for uint256;\n\n /* ========== STATE VARIABLES ========== */\n\n ISoulboundIdentity public soulboundIdentity;\n\n mapping(uint256 => uint256) public nameRegistrationPricePerYear; // (length --> price in stable coin per year)\n\n mapping(address => bool) public authorities;\n\n /* ========== INITIALIZE ========== */\n\n /// @notice Creates a new Soul Store\n /// @dev Creates a new Soul Store, that has the role to minting new Soulbound Identities\n /// and Soul Name NFTs, paying a fee\n /// @param admin Administrator of the smart contract\n /// @param _soulBoundIdentity Address of the Soulbound identity contract\n /// @param _nameRegistrationPricePerYear Price of the default name registering in stable coin per year\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n ISoulboundIdentity _soulBoundIdentity,\n uint256 _nameRegistrationPricePerYear,\n PaymentParams memory paymentParams\n ) PaymentGateway(admin, paymentParams) EIP712(\"SoulStore\", \"1.0.0\") {\n if (address(_soulBoundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulBoundIdentity;\n\n nameRegistrationPricePerYear[0] = _nameRegistrationPricePerYear; // name price for default length per year\n }\n\n /* ========== RESTRICTED FUNCTIONS ========== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this store\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity New SoulboundIdentity contract address\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the price of the name registering per one year in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _nameLength Length of the name\n /// @param _nameRegistrationPricePerYear New price of the name registering per one\n /// year in stable coin for that name length per year\n function setNameRegistrationPricePerYear(\n uint256 _nameLength,\n uint256 _nameRegistrationPricePerYear\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\n if (\n nameRegistrationPricePerYear[_nameLength] ==\n _nameRegistrationPricePerYear\n ) revert SameValue();\n nameRegistrationPricePerYear[\n _nameLength\n ] = _nameRegistrationPricePerYear;\n }\n\n /// @notice Adds a new authority to the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority New authority to add\n function addAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (authorities[_authority]) revert AlreadyAdded();\n\n authorities[_authority] = true;\n }\n\n /// @notice Removes an authority from the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority Authority to remove\n function removeAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\n\n authorities[_authority] = false;\n }\n\n /// @notice Pauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function pause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function unpause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /* ========== MUTATIVE FUNCTIONS ========== */\n\n /// @notice Mints a new Soulbound Identity and Name purchasing it\n /// @dev This function allows the purchase of a soulbound identity and name using\n /// stable coin (USDC), native token (ETH) or utility token (MASA)\n /// @param paymentMethod Address of token that user want to pay\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soulbound identity\n function purchaseIdentityAndName(\n address paymentMethod,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant returns (uint256) {\n _pay(\n paymentMethod,\n getPriceForMintingName(paymentMethod, nameLength, yearsPeriod)\n );\n\n // finalize purchase\n return\n _mintSoulboundIdentityAndName(\n _msgSender(),\n name,\n nameLength,\n yearsPeriod,\n tokenURI,\n authorityAddress,\n signature\n );\n }\n\n /// @notice Mints a new Soulbound Identity purchasing it\n /// @dev This function allows the purchase of a soulbound identity for free\n /// @return TokenId of the new soulbound identity\n function purchaseIdentity()\n external\n whenNotPaused\n nonReentrant\n returns (uint256)\n {\n // finalize purchase\n return _mintSoulboundIdentity(_msgSender());\n }\n\n /// @notice Mints a new Soul Name purchasing it\n /// @dev This function allows the purchase of a soul name using\n /// stable coin (USDC), native token (ETH) or utility token (MASA)\n /// @param paymentMethod Address of token that user want to pay\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new sou name\n function purchaseName(\n address paymentMethod,\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant returns (uint256) {\n _pay(\n paymentMethod,\n getPriceForMintingName(paymentMethod, nameLength, yearsPeriod)\n );\n\n // finalize purchase\n return\n _mintSoulName(\n to,\n name,\n nameLength,\n yearsPeriod,\n tokenURI,\n authorityAddress,\n signature\n );\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Returns the price of register a name per year in stable coin for an specific length\n /// @dev Returns the price for registering per year in USD for an specific name length\n /// @param nameLength Length of the name\n /// @return Price in stable coin for that name length\n function getNameRegistrationPricePerYear(uint256 nameLength)\n public\n view\n returns (uint256)\n {\n uint256 price = nameRegistrationPricePerYear[nameLength];\n if (price == 0) {\n // if not found, return the default price\n price = nameRegistrationPricePerYear[0];\n }\n return price;\n }\n\n /// @notice Returns the price of the name minting\n /// @dev Returns current pricing for name minting for a given name length and years period\n /// @param paymentMethod Address of token that user want to pay\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @return Current price of the name minting in the given payment method\n function getPriceForMintingName(\n address paymentMethod,\n uint256 nameLength,\n uint256 yearsPeriod\n ) public view returns (uint256) {\n uint256 mintPrice = getNameRegistrationPricePerYear(nameLength).mul(\n yearsPeriod\n );\n\n if (mintPrice == 0) {\n return 0;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return mintPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, mintPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /* ========== PRIVATE FUNCTIONS ========== */\n\n /// @notice Mints a new Soulbound Identity and Name\n /// @dev The final step of all purchase options. Will mint a\n /// new Soulbound Identity and a Soul Name NFT and emit the purchase event\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soulbound identity\n function _mintSoulboundIdentityAndName(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) internal returns (uint256) {\n _verify(\n _hash(to, name, nameLength, yearsPeriod, tokenURI),\n signature,\n authorityAddress\n );\n\n // mint Soulbound identity token\n uint256 tokenId = soulboundIdentity.mintIdentityWithName(\n to,\n name,\n yearsPeriod,\n tokenURI\n );\n\n emit SoulboundIdentityAndNamePurchased(to, tokenId, name, yearsPeriod);\n\n return tokenId;\n }\n\n /// @notice Mints a new Soulbound Identity\n /// @dev The final step of all purchase options. Will mint a\n /// new Soulbound Identity and emit the purchase event\n /// @param to Address of the owner of the new identity\n /// @return TokenId of the new soulbound identity\n function _mintSoulboundIdentity(address to) internal returns (uint256) {\n // mint Soulbound identity token\n uint256 tokenId = soulboundIdentity.mint(to);\n\n emit SoulboundIdentityPurchased(to, tokenId);\n\n return tokenId;\n }\n\n /// @notice Mints a new Soul Name\n /// @dev The final step of all purchase options. Will mint a\n /// new Soul Name NFT and emit the purchase event\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param nameLength Length of the name\n /// @param yearsPeriod Years of validity of the name\n /// @param tokenURI URI of the NFT\n /// @param authorityAddress Address of the authority\n /// @param signature Signature of the authority\n /// @return TokenId of the new soul name\n function _mintSoulName(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI,\n address authorityAddress,\n bytes calldata signature\n ) internal returns (uint256) {\n _verify(\n _hash(to, name, nameLength, yearsPeriod, tokenURI),\n signature,\n authorityAddress\n );\n\n // mint Soul Name token\n ISoulName soulName = soulboundIdentity.getSoulName();\n\n uint256 tokenId = soulName.mint(to, name, yearsPeriod, tokenURI);\n\n emit SoulNamePurchased(to, tokenId, name, yearsPeriod);\n\n return tokenId;\n }\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address signer\n ) internal view {\n address _signer = ECDSA.recover(digest, signature);\n if (_signer != signer) revert InvalidSignature();\n if (!authorities[_signer]) revert NotAuthorized(_signer);\n }\n\n function _hash(\n address to,\n string memory name,\n uint256 nameLength,\n uint256 yearsPeriod,\n string memory tokenURI\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintSoulName(address to,string name,uint256 nameLength,uint256 yearsPeriod,string tokenURI)\"\n ),\n to,\n keccak256(bytes(name)),\n nameLength,\n yearsPeriod,\n keccak256(bytes(tokenURI))\n )\n )\n );\n }\n\n /* ========== MODIFIERS ========== */\n\n /* ========== EVENTS ========== */\n\n event SoulboundIdentityAndNamePurchased(\n address indexed account,\n uint256 tokenId,\n string indexed name,\n uint256 yearsPeriod\n );\n\n event SoulboundIdentityPurchased(address indexed account, uint256 tokenId);\n\n event SoulNamePurchased(\n address indexed account,\n uint256 tokenId,\n string indexed name,\n uint256 yearsPeriod\n );\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" - }, - "@openzeppelin/contracts/security/ReentrancyGuard.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" - }, - "@openzeppelin/contracts/security/Pausable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n require(!paused(), \"Pausable: paused\");\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n require(paused(), \"Pausable: not paused\");\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" - }, - "contracts/interfaces/ISoulboundIdentity.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../tokens/SBT/ISBT.sol\";\n\nimport \"./ISoulName.sol\";\n\ninterface ISoulboundIdentity is ISBT {\n function mint(address to) external returns (uint256);\n\n function mintIdentityWithName(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external returns (uint256);\n\n function getSoulName() external view returns (ISoulName);\n\n function tokenOfOwner(address owner) external view returns (uint256);\n}\n" - }, - "contracts/interfaces/ISoulName.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\ninterface ISoulName {\n function mint(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external returns (uint256);\n\n function getExtension() external view returns (string memory);\n\n function isAvailable(string memory name)\n external\n view\n returns (bool available);\n\n function getTokenData(string memory name)\n external\n view\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n );\n\n function getTokenId(string memory name) external view returns (uint256);\n\n function getSoulNames(address owner)\n external\n view\n returns (string[] memory sbtNames);\n\n function getSoulNames(uint256 identityId)\n external\n view\n returns (string[] memory sbtNames);\n}\n" - }, - "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" - }, - "contracts/tokens/SBT/ISBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\ninterface ISBT is IERC165 {\n /// @dev This emits when an SBT is newly minted.\n /// This event emits when SBTs are created\n event Mint(address indexed _owner, uint256 indexed _tokenId);\n\n /// @dev This emits when an SBT is burned\n /// This event emits when SBTs are destroyed\n event Burn(address indexed _owner, uint256 indexed _tokenId);\n\n /// @notice Count all SBTs assigned to an owner\n /// @dev SBTs assigned to the zero address are considered invalid, and this\n /// function throws for queries about the zero address.\n /// @param _owner An address for whom to query the balance\n /// @return The number of SBTs owned by `_owner`, possibly zero\n function balanceOf(address _owner) external view returns (uint256);\n\n /// @notice Find the owner of an SBT\n /// @dev SBTs assigned to zero address are considered invalid, and queries\n /// about them do throw.\n /// @param _tokenId The identifier for an SBT\n /// @return The address of the owner of the SBT\n function ownerOf(uint256 _tokenId) external view returns (address);\n}\n" - }, - "contracts/SoulName.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./libraries/Utils.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\nimport \"./tokens/MasaNFT.sol\";\n\n/// @title SoulName NFT\n/// @author Masa Finance\n/// @notice SoulName NFT that points to a Soulbound identity token\n/// @dev SoulName NFT, that inherits from the NFT contract, and points to a Soulbound identity token.\n/// It has an extension, and stores all the information about the identity names.\ncontract SoulName is MasaNFT, ISoulName, ReentrancyGuard {\n /* ========== STATE VARIABLES ========== */\n using SafeMath for uint256;\n\n uint256 constant YEAR = 31536000; // 60 seconds * 60 minutes * 24 hours * 365 days\n\n ISoulboundIdentity public soulboundIdentity;\n string public extension; // suffix of the names (.sol?)\n\n // contractURI() points to the smart contract metadata\n // see https://docs.opensea.io/docs/contract-level-metadata\n string public contractURI;\n\n // Optional mapping for token URIs\n mapping(uint256 => string) private _tokenURIs;\n mapping(string => bool) private _URIs; // used to check if a uri is already used\n\n mapping(uint256 => TokenData) public tokenData; // used to store the data of the token id\n mapping(string => NameData) public nameData; // stores the token id of the current active soul name\n\n struct TokenData {\n string name; // Name with lowercase and uppercase\n uint256 expirationDate;\n }\n\n struct NameData {\n bool exists;\n uint256 tokenId;\n }\n\n /* ========== INITIALIZE ========== */\n\n /// @notice Creates a new SoulName NFT\n /// @dev Creates a new SoulName NFT, that points to a Soulbound identity, inheriting from the NFT contract.\n /// @param admin Administrator of the smart contract\n /// @param _soulboundIdentity Address of the Soulbound identity contract\n /// @param _extension Extension of the soul name\n /// @param _contractURI URI of the smart contract metadata\n constructor(\n address admin,\n ISoulboundIdentity _soulboundIdentity,\n string memory _extension,\n string memory _contractURI\n ) MasaNFT(admin, \"Masa Soul Name\", \"MSN\", \"\") {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulboundIdentity;\n extension = _extension;\n contractURI = _contractURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the extension of the soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _extension Extension of the soul name\n function setExtension(string memory _extension)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (\n keccak256(abi.encodePacked((extension))) ==\n keccak256(abi.encodePacked((_extension)))\n ) revert SameValue();\n extension = _extension;\n }\n\n /// @notice Sets the URI of the smart contract metadata\n /// @dev The caller must have the admin role to call this function\n /// @param _contractURI URI of the smart contract metadata\n function setContractURI(string memory _contractURI)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (\n keccak256(abi.encodePacked((contractURI))) ==\n keccak256(abi.encodePacked((_contractURI)))\n ) revert SameValue();\n contractURI = _contractURI;\n }\n\n /* ========== MUTATIVE FUNCTIONS ========== */\n\n /// @notice Mints a new soul name\n /// @dev The caller can mint more than one name. The soul name must be unique.\n /// @param to Address of the owner of the new soul name\n /// @param name Name of the new soul name\n /// @param yearsPeriod Years of validity of the name\n /// @param _tokenURI URI of the NFT\n function mint(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) public override nonReentrant returns (uint256) {\n if (!isAvailable(name)) revert NameAlreadyExists(name);\n if (bytes(name).length == 0) revert ZeroLengthName(name);\n if (yearsPeriod == 0) revert ZeroYearsPeriod(yearsPeriod);\n if (soulboundIdentity.balanceOf(to) == 0)\n revert AddressDoesNotHaveIdentity(to);\n if (\n !Utils.startsWith(_tokenURI, \"ar://\") &&\n !Utils.startsWith(_tokenURI, \"ipfs://\")\n ) revert InvalidTokenURI(_tokenURI);\n\n uint256 tokenId = _mintWithCounter(to);\n _setTokenURI(tokenId, _tokenURI);\n\n tokenData[tokenId].name = name;\n tokenData[tokenId].expirationDate = block.timestamp.add(\n YEAR.mul(yearsPeriod)\n );\n\n string memory lowercaseName = Utils.toLowerCase(name);\n nameData[lowercaseName].tokenId = tokenId;\n nameData[lowercaseName].exists = true;\n\n return tokenId;\n }\n\n /// @notice Update the expiration date of a soul name\n /// @dev The caller must be the owner or an approved address of the soul name.\n /// @param tokenId TokenId of the soul name\n /// @param yearsPeriod Years of validity of the name\n function renewYearsPeriod(uint256 tokenId, uint256 yearsPeriod) external {\n // ERC721: caller is not token owner nor approved\n if (!_isApprovedOrOwner(_msgSender(), tokenId))\n revert CallerNotOwner(_msgSender());\n if (yearsPeriod == 0) revert ZeroYearsPeriod(yearsPeriod);\n\n // check that the last registered tokenId for that name is the current token\n string memory lowercaseName = Utils.toLowerCase(\n tokenData[tokenId].name\n );\n if (nameData[lowercaseName].tokenId != tokenId)\n revert NameRegisteredByOtherAccount(lowercaseName, tokenId);\n\n // check if the name is expired\n if (tokenData[tokenId].expirationDate < block.timestamp) {\n tokenData[tokenId].expirationDate = block.timestamp.add(\n YEAR.mul(yearsPeriod)\n );\n } else {\n tokenData[tokenId].expirationDate = tokenData[tokenId]\n .expirationDate\n .add(YEAR.mul(yearsPeriod));\n }\n\n emit YearsPeriodRenewed(\n tokenId,\n yearsPeriod,\n tokenData[tokenId].expirationDate\n );\n }\n\n /// @notice Burn a soul name\n /// @dev The caller must be the owner or an approved address of the soul name.\n /// @param tokenId TokenId of the soul name to burn\n function burn(uint256 tokenId) public override {\n if (!_exists(tokenId)) revert TokenNotFound(tokenId);\n\n string memory lowercaseName = Utils.toLowerCase(\n tokenData[tokenId].name\n );\n\n // remove info from tokenIdName and tokenData\n delete tokenData[tokenId];\n\n // if the last owner of the name is burning it, remove the name from nameData\n if (nameData[lowercaseName].tokenId == tokenId) {\n delete nameData[lowercaseName];\n }\n\n if (bytes(_tokenURIs[tokenId]).length != 0) {\n _URIs[_tokenURIs[tokenId]] = false;\n delete _tokenURIs[tokenId];\n }\n\n super.burn(tokenId);\n }\n\n /* ========== VIEWS ========== */\n\n /// @notice Returns the extension of the soul name\n /// @dev This function is used to get the extension of the soul name\n /// @return Extension of the soul name\n function getExtension() external view override returns (string memory) {\n return extension;\n }\n\n /// @notice Checks if a soul name is available\n /// @dev This function queries if a soul name already exists and is in the available state\n /// @param name Name of the soul name\n /// @return available `true` if the soul name is available, `false` otherwise\n function isAvailable(string memory name)\n public\n view\n override\n returns (bool available)\n {\n string memory lowercaseName = Utils.toLowerCase(name);\n if (nameData[lowercaseName].exists) {\n uint256 tokenId = nameData[lowercaseName].tokenId;\n return tokenData[tokenId].expirationDate < block.timestamp;\n } else {\n return true;\n }\n }\n\n /// @notice Returns the information of a soul name\n /// @dev This function queries the information of a soul name\n /// @param name Name of the soul name\n /// @return sbtName Soul name, in upper/lower case and extension\n /// @return linked `true` if the soul name is linked, `false` otherwise\n /// @return identityId Identity id of the soul name\n /// @return tokenId SoulName id of the soul name\n /// @return expirationDate Expiration date of the soul name\n /// @return active `true` if the soul name is active, `false` otherwise\n function getTokenData(string memory name)\n external\n view\n override\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n )\n {\n tokenId = _getTokenId(name);\n address _owner = ownerOf(tokenId);\n bool _linked = soulboundIdentity.balanceOf(_owner) > 0;\n uint256 _identityId = 0;\n if (_linked) {\n _identityId = soulboundIdentity.tokenOfOwner(_owner);\n }\n\n TokenData memory _tokenData = tokenData[tokenId];\n\n return (\n _getName(_tokenData.name),\n _linked,\n _identityId,\n tokenId,\n _tokenData.expirationDate,\n _tokenData.expirationDate >= block.timestamp\n );\n }\n\n /// @notice Returns the token id of a soul name\n /// @dev This function queries the token id of a soul name\n /// @param name Name of the soul name\n /// @return SoulName id of the soul name\n function getTokenId(string memory name)\n external\n view\n override\n returns (uint256)\n {\n return _getTokenId(name);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified identity Id\n /// @param identityId TokenId of the identity\n /// @return sbtNames Array of soul names associated to the identity Id\n function getSoulNames(uint256 identityId)\n external\n view\n override\n returns (string[] memory sbtNames)\n {\n // return owner if exists\n address _owner = soulboundIdentity.ownerOf(identityId);\n\n return getSoulNames(_owner);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified account\n /// @param owner Address of the owner of the identities\n /// @return sbtNames Array of soul names associated to the account\n function getSoulNames(address owner)\n public\n view\n override\n returns (string[] memory sbtNames)\n {\n uint256 results = 0;\n uint256 balance = balanceOf(owner);\n\n for (uint256 i = 0; i < balance; i++) {\n uint256 tokenId = tokenOfOwnerByIndex(owner, i);\n if (tokenData[tokenId].expirationDate >= block.timestamp) {\n results = results.add(1);\n }\n }\n\n string[] memory _sbtNames = new string[](results);\n uint256 index = 0;\n\n for (uint256 i = 0; i < balance; i++) {\n uint256 tokenId = tokenOfOwnerByIndex(owner, i);\n if (tokenData[tokenId].expirationDate >= block.timestamp) {\n _sbtNames[index] = Utils.toLowerCase(tokenData[tokenId].name);\n index = index.add(1);\n }\n }\n\n // return identity names if exists and are active\n return _sbtNames;\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev This function returns the token URI of the soul name specified by the name\n /// @param name Name of the soul name\n /// @return URI of the soulname associated to a name\n function tokenURI(string memory name)\n external\n view\n virtual\n returns (string memory)\n {\n uint256 tokenId = _getTokenId(name);\n return tokenURI(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId NFT to get the URI of\n /// @return URI of the NFT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory _tokenURI = _tokenURIs[tokenId];\n string memory base = _baseURI();\n\n // If there is no base URI, return the token URI.\n if (bytes(base).length == 0) {\n return _tokenURI;\n }\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n if (bytes(_tokenURI).length > 0) {\n return string(abi.encodePacked(base, _tokenURI));\n }\n\n return super.tokenURI(tokenId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========== */\n\n function _getName(string memory name) private view returns (string memory) {\n return string(bytes.concat(bytes(name), bytes(extension)));\n }\n\n function _getTokenId(string memory name) private view returns (uint256) {\n string memory lowercaseName = Utils.toLowerCase(name);\n if (!nameData[lowercaseName].exists) revert NameNotFound(name);\n\n return nameData[lowercaseName].tokenId;\n }\n\n function _setTokenURI(uint256 tokenId, string memory _tokenURI)\n internal\n virtual\n {\n if (!_exists(tokenId)) revert TokenNotFound(tokenId);\n if (_URIs[_tokenURI]) revert URIAlreadyExists(_tokenURI);\n\n _tokenURIs[tokenId] = _tokenURI;\n _URIs[_tokenURI] = true;\n }\n\n /* ========== MODIFIERS ========== */\n\n /* ========== EVENTS ========== */\n\n event YearsPeriodRenewed(\n uint256 tokenId,\n uint256 yearsPeriod,\n uint256 newExpirationDate\n );\n}\n" - }, - "contracts/libraries/Utils.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\n/// @title Utilities library for Masa Contracts Identity repository\n/// @author Masa Finance\n/// @notice Library of utilities for Masa Contracts Identity repository\nlibrary Utils {\n struct slice {\n uint256 _len;\n uint256 _ptr;\n }\n\n function toLowerCase(string memory _str)\n internal\n pure\n returns (string memory)\n {\n bytes memory bStr = bytes(_str);\n bytes memory bLower = new bytes(bStr.length);\n\n for (uint256 i = 0; i < bStr.length; i++) {\n // Uppercase character...\n if ((bStr[i] >= 0x41) && (bStr[i] <= 0x5A)) {\n // So we add 0x20 to make it lowercase\n bLower[i] = bytes1(uint8(bStr[i]) + 0x20);\n } else {\n bLower[i] = bStr[i];\n }\n }\n return string(bLower);\n }\n\n function toSlice(string memory self) private pure returns (slice memory) {\n uint256 ptr;\n assembly {\n ptr := add(self, 0x20)\n }\n return slice(bytes(self).length, ptr);\n }\n\n function startsWith(string memory str, string memory needle)\n internal\n pure\n returns (bool)\n {\n slice memory s_str = toSlice(str);\n slice memory s_needle = toSlice(needle);\n\n if (s_str._len < s_needle._len) {\n return false;\n }\n\n if (s_str._ptr == s_needle._ptr) {\n return true;\n }\n\n bool equal;\n assembly {\n let length := mload(s_needle)\n let selfptr := mload(add(s_str, 0x20))\n let needleptr := mload(add(s_needle, 0x20))\n equal := eq(\n keccak256(selfptr, length),\n keccak256(needleptr, length)\n )\n }\n return equal;\n }\n}\n" - }, - "contracts/tokens/MasaNFT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\n/// @title MasaNFT\n/// @author Masa Finance\n/// @notice Non-fungible token is a token that is not fungible.\n/// @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard,\n/// that inherits from {ERC721Enumerable}, {Ownable}, {AccessControl} and {ERC721Burnable}.\nabstract contract MasaNFT is\n ERC721,\n ERC721Enumerable,\n Ownable,\n AccessControl,\n ERC721Burnable\n{\n /* ========== STATE VARIABLES =========================================== */\n\n using Strings for uint256;\n using Counters for Counters.Counter;\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n Counters.Counter private _tokenIdCounter;\n\n string private _baseTokenURI;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new NFT\n /// @dev Creates a new Non-fungible token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) ERC721(name, symbol) {\n Ownable.transferOwnership(admin);\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n _grantRole(MINTER_ROLE, admin);\n\n _baseTokenURI = baseTokenURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n function _mintWithCounter(address to)\n internal\n onlyRole(MINTER_ROLE)\n returns (uint256)\n {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _safeMint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns true if the token exists\n /// @dev Returns true if the token has been minted\n /// @param tokenId Token to check\n /// @return True if the token exists\n function exists(uint256 tokenId) external view returns (bool) {\n return _exists(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId NFT to get the URI of\n /// @return URI of the NFT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\"))\n : \"\";\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC721, ERC721Enumerable, AccessControl)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override(ERC721, ERC721Enumerable) {\n super._beforeTokenTransfer(from, to, tokenId);\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/ERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not token owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n _requireMinted(tokenId);\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _safeTransfer(from, to, tokenId, data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits an {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"ERC721: invalid token ID\");\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"./IERC721Enumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721.balanceOf(owner), \"ERC721Enumerable: owner index out of bounds\");\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721Enumerable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @title ERC721 Burnable Token\n * @dev ERC721 Token that can be burned (destroyed).\n */\nabstract contract ERC721Burnable is Context, ERC721 {\n /**\n * @dev Burns `tokenId`. See {ERC721-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n _burn(tokenId);\n }\n}\n" - }, - "@openzeppelin/contracts/access/Ownable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" - }, - "@openzeppelin/contracts/utils/Counters.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" - }, - "contracts/SoulLinker.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./dex/PaymentGateway.sol\";\nimport \"./interfaces/ILinkableSBT.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\n\n/// @title Soul linker\n/// @author Masa Finance\n/// @notice Soul linker smart contract that let add links to a Soulbound token.\ncontract SoulLinker is PaymentGateway, EIP712, Pausable, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n ISoulboundIdentity public soulboundIdentity;\n\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n mapping(address => mapping(uint256 => mapping(uint256 => mapping(uint256 => LinkData))))\n private _links;\n // token => tokenId => readerIdentityId\n mapping(address => mapping(uint256 => uint256[]))\n private _linkReaderIdentityIds;\n // token => tokenId => readerIdentityId => signatureDate\n mapping(address => mapping(uint256 => mapping(uint256 => uint256[])))\n private _linkSignatureDates;\n // readerIdentityId => ReaderLink\n mapping(uint256 => ReaderLink[]) private _readerLinks;\n\n struct LinkData {\n bool exists;\n uint256 ownerIdentityId;\n uint256 expirationDate;\n bool isRevoked;\n }\n\n struct ReaderLink {\n address token;\n uint256 tokenId;\n uint256 signatureDate;\n }\n\n struct LinkKey {\n uint256 readerIdentityId;\n uint256 signatureDate;\n }\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soul linker\n /// @param admin Administrator of the smart contract\n /// @param _soulboundIdentity Soulbound identity smart contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n ISoulboundIdentity _soulboundIdentity,\n PaymentParams memory paymentParams\n ) EIP712(\"SoulLinker\", \"1.0.0\") PaymentGateway(admin, paymentParams) {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n\n soulboundIdentity = _soulboundIdentity;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this soul name\n /// @dev The caller must have the admin role to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulboundIdentity) == address(0)) revert ZeroAddress();\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Pauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpauses the smart contract\n /// @dev The caller must have the admin role to call this function\n function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Stores the link, validating the signature of the given read link request\n /// @dev The token must be linked to this soul linker\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n /// @param expirationDate Expiration date of the signature\n /// @param signature Signature of the read link request made by the owner\n function addLink(\n address paymentMethod,\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate,\n bytes calldata signature\n ) external payable whenNotPaused nonReentrant {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address readerAddress = soulboundIdentity.ownerOf(readerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (readerAddress != _msgSender()) revert CallerNotReader(_msgSender());\n if (ownerIdentityId == readerIdentityId)\n revert IdentityOwnerIsReader(readerIdentityId);\n if (signatureDate == 0) revert InvalidSignatureDate(signatureDate);\n if (expirationDate < block.timestamp)\n revert ValidPeriodExpired(expirationDate);\n if (_links[token][tokenId][readerIdentityId][signatureDate].exists)\n revert LinkAlreadyExists(\n token,\n tokenId,\n readerIdentityId,\n signatureDate\n );\n if (\n !_verify(\n _hash(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n ),\n signature,\n ownerAddress\n )\n ) revert InvalidSignature();\n\n _pay(paymentMethod, getPriceForAddLink(paymentMethod, token));\n\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate] = LinkData(\n true,\n ownerIdentityId,\n expirationDate,\n false\n );\n if (_linkSignatureDates[token][tokenId][readerIdentityId].length == 0) {\n _linkReaderIdentityIds[token][tokenId].push(readerIdentityId);\n }\n _linkSignatureDates[token][tokenId][readerIdentityId].push(\n signatureDate\n );\n _readerLinks[readerIdentityId].push(\n ReaderLink(token, tokenId, signatureDate)\n );\n\n emit LinkAdded(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n );\n }\n\n /// @notice Revokes the link\n /// @dev The links can be revoked, wether the token is linked or not.\n /// The caller must be the owner of the token.\n /// The owner of the token can revoke a link even if the reader has not added it yet.\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n function revokeLink(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n ) external whenNotPaused {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (ownerAddress != _msgSender()) revert CallerNotOwner(_msgSender());\n if (ownerIdentityId == readerIdentityId)\n revert IdentityOwnerIsReader(readerIdentityId);\n if (_links[token][tokenId][readerIdentityId][signatureDate].isRevoked)\n revert LinkAlreadyRevoked();\n\n if (_links[token][tokenId][readerIdentityId][signatureDate].exists) {\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate]\n .isRevoked = true;\n } else {\n // if the link doesn't exist, store it\n // token => tokenId => readerIdentityId => signatureDate => LinkData\n _links[token][tokenId][readerIdentityId][signatureDate] = LinkData(\n true,\n ownerIdentityId,\n 0,\n true\n );\n if (\n _linkSignatureDates[token][tokenId][readerIdentityId].length ==\n 0\n ) {\n _linkReaderIdentityIds[token][tokenId].push(readerIdentityId);\n }\n _linkSignatureDates[token][tokenId][readerIdentityId].push(\n signatureDate\n );\n _readerLinks[readerIdentityId].push(\n ReaderLink(token, tokenId, signatureDate)\n );\n }\n\n emit LinkRevoked(\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate\n );\n }\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the identityId owned by the given token\n /// @dev The token must be linked to this soul linker\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @return Id of the identity\n function getIdentityId(address token, uint256 tokenId)\n external\n view\n returns (uint256)\n {\n address owner = IERC721Enumerable(token).ownerOf(tokenId);\n return soulboundIdentity.tokenOfOwner(owner);\n }\n\n /// @notice Returns the list of connected SBTs by a given SBT token\n /// @param identityId Id of the identity\n /// @param token Address of the SBT contract\n /// @return List of connected SBTs\n function getSBTConnections(uint256 identityId, address token)\n external\n view\n returns (uint256[] memory)\n {\n address owner = soulboundIdentity.ownerOf(identityId);\n\n return getSBTConnections(owner, token);\n }\n\n /// @notice Returns the list of connected SBTs by a given SBT token\n /// @param owner Address of the owner of the identity\n /// @param token Address of the SBT contract\n /// @return List of connectec SBTs\n function getSBTConnections(address owner, address token)\n public\n view\n returns (uint256[] memory)\n {\n uint256 connections = IERC721Enumerable(token).balanceOf(owner);\n uint256[] memory sbtConnections = new uint256[](connections);\n for (uint256 i = 0; i < connections; i++) {\n sbtConnections[i] = IERC721Enumerable(token).tokenOfOwnerByIndex(\n owner,\n i\n );\n }\n\n return sbtConnections;\n }\n\n /// @notice Returns the list of link signature dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @return List of linked SBTs\n function getLinks(address token, uint256 tokenId)\n public\n view\n returns (LinkKey[] memory)\n {\n uint256 nLinkKeys = 0;\n for (\n uint256 i = 0;\n i < _linkReaderIdentityIds[token][tokenId].length;\n i++\n ) {\n uint256 readerIdentityId = _linkReaderIdentityIds[token][tokenId][\n i\n ];\n for (\n uint256 j = 0;\n j <\n _linkSignatureDates[token][tokenId][readerIdentityId].length;\n j++\n ) {\n nLinkKeys++;\n }\n }\n\n LinkKey[] memory linkKeys = new LinkKey[](nLinkKeys);\n uint256 n = 0;\n for (\n uint256 i = 0;\n i < _linkReaderIdentityIds[token][tokenId].length;\n i++\n ) {\n uint256 readerIdentityId = _linkReaderIdentityIds[token][tokenId][\n i\n ];\n for (\n uint256 j = 0;\n j <\n _linkSignatureDates[token][tokenId][readerIdentityId].length;\n j++\n ) {\n uint256 signatureDate = _linkSignatureDates[token][tokenId][\n readerIdentityId\n ][j];\n linkKeys[n].readerIdentityId = readerIdentityId;\n linkKeys[n].signatureDate = signatureDate;\n n++;\n }\n }\n return linkKeys;\n }\n\n /// @notice Returns the list of link signature dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @return List of linked SBTs\n function getLinkSignatureDates(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId\n ) external view returns (uint256[] memory) {\n return _linkSignatureDates[token][tokenId][readerIdentityId];\n }\n\n /// @notice Returns the information of link dates for a given SBT token and reader\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @param signatureDate Signature date of the signature\n /// @return linkData List of linked SBTs\n function getLinkInfo(\n address token,\n uint256 tokenId,\n uint256 readerIdentityId,\n uint256 signatureDate\n ) external view returns (LinkData memory) {\n return _links[token][tokenId][readerIdentityId][signatureDate];\n }\n\n /// @notice Returns the list of links for a given reader identity id\n /// @param readerIdentityId Id of the identity of the reader of the SBT\n /// @return List of links for the reader\n function getReaderLinks(uint256 readerIdentityId)\n public\n view\n returns (ReaderLink[] memory)\n {\n return _readerLinks[readerIdentityId];\n }\n\n /// @notice Validates the link of the given read link request and returns the\n /// data that reader can read if the link is valid\n /// @dev The token must be linked to this soul linker\n /// @param readerIdentityId Id of the identity of the reader\n /// @param ownerIdentityId Id of the identity of the owner of the SBT\n /// @param token Address of the SBT contract\n /// @param tokenId Id of the token\n /// @param signatureDate Signature date of the signature\n /// @return True if the link is valid\n function validateLink(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n ) external view returns (bool) {\n address ownerAddress = soulboundIdentity.ownerOf(ownerIdentityId);\n address tokenOwner = IERC721Enumerable(token).ownerOf(tokenId);\n\n LinkData memory link = _links[token][tokenId][readerIdentityId][\n signatureDate\n ];\n\n if (ownerAddress != tokenOwner)\n revert IdentityOwnerNotTokenOwner(tokenId, ownerIdentityId);\n if (!link.exists) revert LinkDoesNotExist();\n if (link.expirationDate < block.timestamp)\n revert ValidPeriodExpired(link.expirationDate);\n if (link.isRevoked) revert LinkAlreadyRevoked();\n\n return true;\n }\n\n /// @notice Returns the price for storing a link\n /// @dev Returns the current pricing for storing a link\n /// @param paymentMethod Address of token that user want to pay\n /// @param token Token that user want to store link\n /// @return Current price for storing a link\n function getPriceForAddLink(address paymentMethod, address token)\n public\n view\n returns (uint256)\n {\n uint256 addLinkPrice = ILinkableSBT(token).addLinkPrice();\n uint256 addLinkPriceMASA = ILinkableSBT(token).addLinkPriceMASA();\n if (addLinkPrice == 0 && addLinkPriceMASA == 0) {\n return 0;\n } else if (\n paymentMethod == masaToken &&\n enabledPaymentMethod[paymentMethod] &&\n addLinkPriceMASA > 0\n ) {\n // price in MASA without conversion rate\n return addLinkPriceMASA;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return addLinkPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, addLinkPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Link(uint256 readerIdentityId,uint256 ownerIdentityId,address token,uint256 tokenId,uint256 signatureDate,uint256 expirationDate)\"\n ),\n readerIdentityId,\n ownerIdentityId,\n token,\n tokenId,\n signatureDate,\n expirationDate\n )\n )\n );\n }\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address owner\n ) internal pure returns (bool) {\n return ECDSA.recover(digest, signature) == owner;\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event LinkAdded(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate,\n uint256 expirationDate\n );\n\n event LinkRevoked(\n uint256 readerIdentityId,\n uint256 ownerIdentityId,\n address token,\n uint256 tokenId,\n uint256 signatureDate\n );\n}\n" - }, - "contracts/interfaces/ILinkableSBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../tokens/SBT/ISBT.sol\";\n\ninterface ILinkableSBT is ISBT {\n function addLinkPrice() external view returns (uint256);\n\n function addLinkPriceMASA() external view returns (uint256);\n\n function queryLinkPrice() external view returns (uint256);\n\n function queryLinkPriceMASA() external view returns (uint256);\n}\n" - }, - "contracts/SoulboundIdentity.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./interfaces/ISoulboundIdentity.sol\";\nimport \"./interfaces/ISoulName.sol\";\nimport \"./tokens/MasaSBTAuthority.sol\";\n\n/// @title Soulbound Identity\n/// @author Masa Finance\n/// @notice Soulbound token that represents an identity.\n/// @dev Soulbound identity, that inherits from the SBT contract.\ncontract SoulboundIdentity is\n MasaSBTAuthority,\n ISoulboundIdentity,\n ReentrancyGuard\n{\n /* ========== STATE VARIABLES =========================================== */\n\n ISoulName public soulName;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound identity\n /// @dev Creates a new soulbound identity, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n constructor(address admin, string memory baseTokenURI)\n MasaSBTAuthority(admin, \"Masa Identity\", \"MID\", baseTokenURI)\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulName contract address linked to this identity\n /// @dev The caller must have the admin role to call this function\n /// @param _soulName Address of the SoulName contract\n function setSoulName(ISoulName _soulName)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (address(_soulName) == address(0)) revert ZeroAddress();\n if (soulName == _soulName) revert SameValue();\n soulName = _soulName;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new soulbound identity\n /// @dev The caller can only mint one identity per address\n /// @param to Address of the admin of the new identity\n function mint(address to) public override returns (uint256) {\n // Soulbound identity already created!\n if (balanceOf(to) > 0) revert IdentityAlreadyCreated(to);\n\n return _mintWithCounter(to);\n }\n\n /// @notice Mints a new soulbound identity with a SoulName associated to it\n /// @dev The caller can only mint one identity per address, and the name must be unique\n /// @param to Address of the admin of the new identity\n /// @param name Name of the new identity\n /// @param yearsPeriod Years of validity of the name\n /// @param _tokenURI URI of the NFT\n function mintIdentityWithName(\n address to,\n string memory name,\n uint256 yearsPeriod,\n string memory _tokenURI\n ) external override soulNameAlreadySet nonReentrant returns (uint256) {\n uint256 identityId = mint(to);\n soulName.mint(to, name, yearsPeriod, _tokenURI);\n\n return identityId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the address of the SoulName contract linked to this identity\n /// @dev This function returns the address of the SoulName contract linked to this identity\n /// @return Address of the SoulName contract\n function getSoulName() external view override returns (ISoulName) {\n return soulName;\n }\n\n /// @notice Returns the extension of the soul name\n /// @dev This function returns the extension of the soul name\n /// @return Extension of the soul name\n function getExtension() external view returns (string memory) {\n return soulName.getExtension();\n }\n\n /// @notice Returns the owner address of an identity\n /// @dev This function returns the owner address of the identity specified by the tokenId\n /// @param tokenId TokenId of the identity\n /// @return Address of the owner of the identity\n function ownerOf(uint256 tokenId)\n public\n view\n override(SBT, ISBT)\n returns (address)\n {\n return super.ownerOf(tokenId);\n }\n\n /// @notice Returns the owner address of a soul name\n /// @dev This function returns the owner address of the soul name identity specified by the name\n /// @param name Name of the soul name\n /// @return Address of the owner of the identity\n function ownerOf(string memory name)\n external\n view\n soulNameAlreadySet\n returns (address)\n {\n (, , uint256 identityId, , , ) = soulName.getTokenData(name);\n return super.ownerOf(identityId);\n }\n\n /// @notice Returns the URI of a soul name\n /// @dev This function returns the token URI of the soul name identity specified by the name\n /// @param name Name of the soul name\n /// @return URI of the identity associated to a soul name\n function tokenURI(string memory name)\n external\n view\n soulNameAlreadySet\n returns (string memory)\n {\n (, , uint256 identityId, , , ) = soulName.getTokenData(name);\n return super.tokenURI(identityId);\n }\n\n /// @notice Returns the URI of the owner of an identity\n /// @dev This function returns the token URI of the identity owned by an account\n /// @param owner Address of the owner of the identity\n /// @return URI of the identity owned by the account\n function tokenURI(address owner) external view returns (string memory) {\n uint256 tokenId = tokenOfOwner(owner);\n return super.tokenURI(tokenId);\n }\n\n /// @notice Returns the identity id of an account\n /// @dev This function returns the tokenId of the identity owned by an account\n /// @param owner Address of the owner of the identity\n /// @return TokenId of the identity owned by the account\n function tokenOfOwner(address owner)\n public\n view\n override\n returns (uint256)\n {\n return super.tokenOfOwnerByIndex(owner, 0);\n }\n\n /// @notice Checks if a soul name is available\n /// @dev This function queries if a soul name already exists and is in the available state\n /// @param name Name of the soul name\n /// @return available `true` if the soul name is available, `false` otherwise\n function isAvailable(string memory name)\n external\n view\n soulNameAlreadySet\n returns (bool available)\n {\n return soulName.isAvailable(name);\n }\n\n /// @notice Returns the information of a soul name\n /// @dev This function queries the information of a soul name\n /// @param name Name of the soul name\n /// @return sbtName Soul name, in upper/lower case and extension\n /// @return linked `true` if the soul name is linked, `false` otherwise\n /// @return identityId Identity id of the soul name\n /// @return tokenId SoulName id of the soul name\n /// @return expirationDate Expiration date of the soul name\n /// @return active `true` if the soul name is active, `false` otherwise\n function getTokenData(string memory name)\n external\n view\n soulNameAlreadySet\n returns (\n string memory sbtName,\n bool linked,\n uint256 identityId,\n uint256 tokenId,\n uint256 expirationDate,\n bool active\n )\n {\n return soulName.getTokenData(name);\n }\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified account\n /// @param owner Address of the owner of the identities\n /// @return sbtNames Array of soul names associated to the account\n function getSoulNames(address owner)\n external\n view\n soulNameAlreadySet\n returns (string[] memory sbtNames)\n {\n return soulName.getSoulNames(owner);\n }\n\n // SoulName -> SoulboundIdentity.tokenId\n // SoulName -> account -> SoulboundIdentity.tokenId\n\n /// @notice Returns all the active soul names of an account\n /// @dev This function queries all the identity names of the specified identity Id\n /// @param tokenId TokenId of the identity\n /// @return sbtNames Array of soul names associated to the identity Id\n function getSoulNames(uint256 tokenId)\n external\n view\n soulNameAlreadySet\n returns (string[] memory sbtNames)\n {\n return soulName.getSoulNames(tokenId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /* ========== MODIFIERS ================================================= */\n\n modifier soulNameAlreadySet() {\n if (address(soulName) == address(0)) revert SoulNameContractNotSet();\n _;\n }\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/MasaSBTAuthority.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nimport \"./MasaSBT.sol\";\n\n/// @title MasaSBT\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBTAuthority is MasaSBT {\n /* ========== STATE VARIABLES =========================================== */\n\n using Counters for Counters.Counter;\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n Counters.Counter private _tokenIdCounter;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) MasaSBT(admin, name, symbol, baseTokenURI) {\n _grantRole(MINTER_ROLE, admin);\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n function _mintWithCounter(address to)\n internal\n virtual\n onlyRole(MINTER_ROLE)\n returns (uint256)\n {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _mint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/MasaSBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/ILinkableSBT.sol\";\nimport \"./SBT/SBT.sol\";\nimport \"./SBT/extensions/SBTEnumerable.sol\";\nimport \"./SBT/extensions/SBTBurnable.sol\";\n\n/// @title MasaSBT\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBT is\n SBT,\n SBTEnumerable,\n AccessControl,\n SBTBurnable,\n ILinkableSBT\n{\n /* ========== STATE VARIABLES =========================================== */\n\n using Strings for uint256;\n\n string private _baseTokenURI;\n\n uint256 public override addLinkPrice; // price in stable coin\n uint256 public override addLinkPriceMASA; // price in MASA\n uint256 public override queryLinkPrice; // price in stable coin\n uint256 public override queryLinkPriceMASA; // price in MASA\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI\n ) SBT(name, symbol) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n\n _baseTokenURI = baseTokenURI;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the price for adding the link in SoulLinker in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _addLinkPrice New price for adding the link in SoulLinker in stable coin\n function setAddLinkPrice(uint256 _addLinkPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (addLinkPrice == _addLinkPrice) revert SameValue();\n addLinkPrice = _addLinkPrice;\n }\n\n /// @notice Sets the price for adding the link in SoulLinker in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _addLinkPriceMASA New price for adding the link in SoulLinker in MASA\n function setAddLinkPriceMASA(uint256 _addLinkPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (addLinkPriceMASA == _addLinkPriceMASA) revert SameValue();\n addLinkPriceMASA = _addLinkPriceMASA;\n }\n\n /// @notice Sets the price for reading data in SoulLinker in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _queryLinkPrice New price for reading data in SoulLinker in stable coin\n function setQueryLinkPrice(uint256 _queryLinkPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (queryLinkPrice == _queryLinkPrice) revert SameValue();\n queryLinkPrice = _queryLinkPrice;\n }\n\n /// @notice Sets the price for reading data in SoulLinker in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _queryLinkPriceMASA New price for reading data in SoulLinker in MASA\n function setQueryLinkPriceMASA(uint256 _queryLinkPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (queryLinkPriceMASA == _queryLinkPriceMASA) revert SameValue();\n queryLinkPriceMASA = _queryLinkPriceMASA;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns true if the token exists\n /// @dev Returns true if the token has been minted\n /// @param tokenId Token to check\n /// @return True if the token exists\n function exists(uint256 tokenId) external view returns (bool) {\n return _exists(tokenId);\n }\n\n /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.\n /// @dev Throws if `_tokenId` is not a valid SBT. URIs are defined in RFC\n /// 3986. The URI may point to a JSON file that conforms to the \"ERC721\n /// Metadata JSON Schema\".\n /// @param tokenId SBT to get the URI of\n /// @return URI of the SBT\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\"))\n : \"\";\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(SBT, SBTEnumerable, AccessControl, IERC165)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _baseURI() internal view virtual override returns (string memory) {\n return _baseTokenURI;\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override(SBT, SBTEnumerable) {\n super._beforeTokenTransfer(from, to, tokenId);\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/tokens/SBT/SBT.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\nimport \"./ISBT.sol\";\nimport \"./extensions/ISBTMetadata.sol\";\n\n/// @title SBT\n/// @author Masa Finance\n/// @notice Soulbound token is an NFT token that is not transferable.\ncontract SBT is Context, ERC165, ISBT, ISBTMetadata {\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165, IERC165)\n returns (bool)\n {\n return\n interfaceId == type(ISBT).interfaceId ||\n interfaceId == type(ISBTMetadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {ISBT-balanceOf}.\n */\n function balanceOf(address owner)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(owner != address(0), \"SBT: address zero is not a valid owner\");\n return _balances[owner];\n }\n\n /**\n * @dev See {ISBT-ownerOf}.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n address owner = _owners[tokenId];\n require(owner != address(0), \"SBT: invalid token ID\");\n return owner;\n }\n\n /**\n * @dev See {ISBTMetadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {ISBTMetadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {ISBTMetadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n _requireMinted(tokenId);\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length > 0\n ? string(abi.encodePacked(baseURI, tokenId.toString()))\n : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isOwner(address spender, uint256 tokenId)\n internal\n view\n virtual\n returns (bool)\n {\n address owner = SBT.ownerOf(tokenId);\n return (spender == owner);\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Mint} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"SBT: mint to the zero address\");\n require(!_exists(tokenId), \"SBT: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Mint(to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n *\n * Requirements:\n * - `tokenId` must exist.\n *\n * Emits a {Burn} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = SBT.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Burn(owner, tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Reverts if the `tokenId` has not been minted yet.\n */\n function _requireMinted(uint256 tokenId) internal view virtual {\n require(_exists(tokenId), \"SBT: invalid token ID\");\n }\n\n /**\n * @dev Hook that is called before any token minting/burning\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address,\n address,\n uint256\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any minting/burning of tokens\n *\n * Calling conditions:\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address,\n address,\n uint256\n ) internal virtual {}\n}\n" - }, - "contracts/tokens/SBT/extensions/SBTEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../SBT.sol\";\nimport \"./ISBTEnumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {SBT} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract SBTEnumerable is SBT, ISBTEnumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, SBT)\n returns (bool)\n {\n return\n interfaceId == type(ISBTEnumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {ISBTEnumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(\n index < SBT.balanceOf(owner),\n \"SBTEnumerable: owner index out of bounds\"\n );\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {ISBTEnumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {ISBTEnumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index)\n public\n view\n virtual\n override\n returns (uint256)\n {\n require(\n index < SBTEnumerable.totalSupply(),\n \"SBTEnumerable: global index out of bounds\"\n );\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = SBT.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)\n private\n {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = SBT.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" - }, - "contracts/tokens/SBT/extensions/SBTBurnable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\nimport \"../SBT.sol\";\n\n/**\n * @title SBT Burnable Token\n * @dev SBT Token that can be burned (destroyed).\n */\nabstract contract SBTBurnable is Context, SBT {\n /**\n * @dev Burns `tokenId`. See {SBT-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(\n _isOwner(_msgSender(), tokenId),\n \"SBT: caller is not token owner\"\n );\n _burn(tokenId);\n }\n}\n" - }, - "contracts/tokens/SBT/extensions/ISBTMetadata.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../ISBT.sol\";\n\n/**\n * @title SBT Soulbound Token Standard, optional metadata extension\n */\ninterface ISBTMetadata is ISBT {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" - }, - "contracts/tokens/SBT/extensions/ISBTEnumerable.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"../ISBT.sol\";\n\n/**\n * @title SBT Soulbound Token Standard, optional enumeration extension\n */\ninterface ISBTEnumerable is ISBT {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index)\n external\n view\n returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" - }, - "contracts/SoulboundCreditScore.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./tokens/MasaSBTSelfSovereign.sol\";\n\n/// @title Soulbound Credit Score\n/// @author Masa Finance\n/// @notice Soulbound token that represents a credit score.\n/// @dev Soulbound credit score, that inherits from the SBT contract.\ncontract SoulboundCreditScore is MasaSBTSelfSovereign, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound credit score\n /// @dev Creates a new soulbound credit score, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory baseTokenURI,\n ISoulboundIdentity soulboundIdentity,\n PaymentParams memory paymentParams\n )\n MasaSBTSelfSovereign(\n admin,\n \"Masa Credit Score\",\n \"MCS\",\n baseTokenURI,\n soulboundIdentity,\n paymentParams\n )\n EIP712(\"SoulboundCreditScore\", \"1.0.0\")\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param identityId TokenId of the identity to mint the NFT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The NFT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) public payable virtual nonReentrant returns (uint256) {\n address to = soulboundIdentity.ownerOf(identityId);\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n if (balanceOf(to) > 0) revert CreditScoreAlreadyCreated(to);\n\n _verify(\n _hash(identityId, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit SoulboundCreditScoreMintedToIdentity(\n tokenId,\n identityId,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param to The address to mint the SBT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The SBT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) external payable virtual returns (uint256) {\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n if (balanceOf(to) > 0) revert CreditScoreAlreadyCreated(to);\n\n _verify(\n _hash(to, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit SoulboundCreditScoreMintedToAddress(\n tokenId,\n to,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintCreditScore(uint256 identityId,address authorityAddress,uint256 signatureDate)\"\n ),\n identityId,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n function _hash(\n address to,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"MintCreditScore(address to,address authorityAddress,uint256 signatureDate)\"\n ),\n to,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event SoulboundCreditScoreMintedToIdentity(\n uint256 tokenId,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n\n event SoulboundCreditScoreMintedToAddress(\n uint256 tokenId,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n}\n" - }, - "contracts/tokens/MasaSBTSelfSovereign.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\nimport \"../libraries/Errors.sol\";\nimport \"../interfaces/ISoulboundIdentity.sol\";\nimport \"../dex/PaymentGateway.sol\";\nimport \"./MasaSBT.sol\";\n\n/// @title MasaSBTSelfSovereign\n/// @author Masa Finance\n/// @notice Soulbound token. Non-fungible token that is not transferable.\n/// Adds a link to a SoulboundIdentity SC to let minting using the identityId\n/// Adds a payment gateway to let minting paying a fee\n/// Adds a self-sovereign protocol to let minting using an authority signature\n/// @dev Implementation of https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763 Soulbound token.\nabstract contract MasaSBTSelfSovereign is PaymentGateway, MasaSBT, EIP712 {\n /* ========== STATE VARIABLES =========================================== */\n\n using Counters for Counters.Counter;\n\n Counters.Counter private _tokenIdCounter;\n\n ISoulboundIdentity public soulboundIdentity;\n\n uint256 public mintPrice; // price in stable coin\n uint256 public mintPriceMASA; // price in MASA\n\n mapping(address => bool) public authorities;\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound token\n /// @dev Creates a new soulbound token\n /// @param admin Administrator of the smart contract\n /// @param name Name of the token\n /// @param symbol Symbol of the token\n /// @param baseTokenURI Base URI of the token\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory name,\n string memory symbol,\n string memory baseTokenURI,\n ISoulboundIdentity _soulboundIdentity,\n PaymentParams memory paymentParams\n )\n PaymentGateway(admin, paymentParams)\n MasaSBT(admin, name, symbol, baseTokenURI)\n {\n soulboundIdentity = _soulboundIdentity;\n }\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /// @notice Sets the SoulboundIdentity contract address linked to this SBT\n /// @dev The caller must be the admin to call this function\n /// @param _soulboundIdentity Address of the SoulboundIdentity contract\n function setSoulboundIdentity(ISoulboundIdentity _soulboundIdentity)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (soulboundIdentity == _soulboundIdentity) revert SameValue();\n soulboundIdentity = _soulboundIdentity;\n }\n\n /// @notice Sets the price of minting in stable coin\n /// @dev The caller must have the admin role to call this function\n /// @param _mintPrice New price of minting in stable coin\n function setMintPrice(uint256 _mintPrice)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (mintPrice == _mintPrice) revert SameValue();\n mintPrice = _mintPrice;\n }\n\n /// @notice Sets the price of minting in MASA\n /// @dev The caller must have the admin role to call this function\n /// @param _mintPriceMASA New price of minting in MASA\n function setMintPriceMASA(uint256 _mintPriceMASA)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (mintPriceMASA == _mintPriceMASA) revert SameValue();\n mintPriceMASA = _mintPriceMASA;\n }\n\n /// @notice Adds a new authority to the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority New authority to add\n function addAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (authorities[_authority]) revert AlreadyAdded();\n\n authorities[_authority] = true;\n }\n\n /// @notice Removes an authority from the list of authorities\n /// @dev The caller must have the admin role to call this function\n /// @param _authority Authority to remove\n function removeAuthority(address _authority)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (_authority == address(0)) revert ZeroAddress();\n if (!authorities[_authority]) revert AuthorityNotExists(_authority);\n\n authorities[_authority] = false;\n }\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /* ========== VIEWS ===================================================== */\n\n /// @notice Returns the identityId owned by the given token\n /// @param tokenId Id of the token\n /// @return Id of the identity\n function getIdentityId(uint256 tokenId) external view returns (uint256) {\n if (soulboundIdentity == ISoulboundIdentity(address(0)))\n revert NotLinkedToAnIdentitySBT();\n\n address owner = super.ownerOf(tokenId);\n return soulboundIdentity.tokenOfOwner(owner);\n }\n\n /// @notice Returns the price for minting\n /// @dev Returns current pricing for minting\n /// @param paymentMethod Address of token that user want to pay\n /// @return Current price for minting in the given payment method\n function getMintPrice(address paymentMethod) public view returns (uint256) {\n if (mintPrice == 0 && mintPriceMASA == 0) {\n return 0;\n } else if (\n paymentMethod == masaToken &&\n enabledPaymentMethod[paymentMethod] &&\n mintPriceMASA > 0\n ) {\n // price in MASA without conversion rate\n return mintPriceMASA;\n } else if (\n paymentMethod == stableCoin && enabledPaymentMethod[paymentMethod]\n ) {\n // stable coin\n return mintPrice;\n } else if (enabledPaymentMethod[paymentMethod]) {\n // ETH and ERC 20 token\n return _convertFromStableCoin(paymentMethod, mintPrice);\n } else {\n revert InvalidPaymentMethod(paymentMethod);\n }\n }\n\n /// @notice Query if a contract implements an interface\n /// @dev Interface identification is specified in ERC-165.\n /// @param interfaceId The interface identifier, as specified in ERC-165\n /// @return `true` if the contract implements `interfaceId` and\n /// `interfaceId` is not 0xffffffff, `false` otherwise\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(AccessControl, MasaSBT)\n returns (bool)\n {\n return super.supportsInterface(interfaceId);\n }\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _verify(\n bytes32 digest,\n bytes memory signature,\n address signer\n ) internal view {\n address _signer = ECDSA.recover(digest, signature);\n if (_signer != signer) revert InvalidSignature();\n if (!authorities[_signer]) revert NotAuthorized(_signer);\n }\n\n function _mintWithCounter(address to) internal virtual returns (uint256) {\n uint256 tokenId = _tokenIdCounter.current();\n _tokenIdCounter.increment();\n _mint(to, tokenId);\n\n return tokenId;\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n}\n" - }, - "contracts/Soulbound2FA.sol": { - "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"./libraries/Errors.sol\";\nimport \"./tokens/MasaSBTSelfSovereign.sol\";\n\n/// @title Soulbound Two-factor authentication (2FA)\n/// @author Masa Finance\n/// @notice Soulbound token that represents a Two-factor authentication (2FA)\n/// @dev Soulbound 2FA, that inherits from the SBT contract.\ncontract Soulbound2FA is MasaSBTSelfSovereign, ReentrancyGuard {\n /* ========== STATE VARIABLES =========================================== */\n\n /* ========== INITIALIZE ================================================ */\n\n /// @notice Creates a new soulbound Two-factor authentication (2FA)\n /// @dev Creates a new soulbound 2FA, inheriting from the SBT contract.\n /// @param admin Administrator of the smart contract\n /// @param baseTokenURI Base URI of the token\n /// @param soulboundIdentity Address of the SoulboundIdentity contract\n /// @param paymentParams Payment gateway params\n constructor(\n address admin,\n string memory baseTokenURI,\n ISoulboundIdentity soulboundIdentity,\n PaymentParams memory paymentParams\n )\n MasaSBTSelfSovereign(\n admin,\n \"Masa 2FA\",\n \"M2F\",\n baseTokenURI,\n soulboundIdentity,\n paymentParams\n )\n EIP712(\"Soulbound2FA\", \"1.0.0\")\n {}\n\n /* ========== RESTRICTED FUNCTIONS ====================================== */\n\n /* ========== MUTATIVE FUNCTIONS ======================================== */\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param identityId TokenId of the identity to mint the NFT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The NFT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) public payable virtual nonReentrant returns (uint256) {\n address to = soulboundIdentity.ownerOf(identityId);\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n\n _verify(\n _hash(identityId, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit Soulbound2FAMintedToIdentity(\n tokenId,\n identityId,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /// @notice Mints a new SBT\n /// @dev The caller must have the MINTER role\n /// @param paymentMethod Address of token that user want to pay\n /// @param to The address to mint the SBT to\n /// @param authorityAddress Address of the authority that signed the message\n /// @param signatureDate Date of the signature\n /// @param signature Signature of the message\n /// @return The SBT ID of the newly minted SBT\n function mint(\n address paymentMethod,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n bytes calldata signature\n ) external payable virtual returns (uint256) {\n if (to != _msgSender()) revert CallerNotOwner(_msgSender());\n\n _verify(\n _hash(to, authorityAddress, signatureDate),\n signature,\n authorityAddress\n );\n\n _pay(paymentMethod, getMintPrice(paymentMethod));\n\n uint256 tokenId = _mintWithCounter(to);\n\n emit Soulbound2FAMintedToAddress(\n tokenId,\n to,\n authorityAddress,\n signatureDate,\n paymentMethod,\n mintPrice\n );\n\n return tokenId;\n }\n\n /* ========== VIEWS ===================================================== */\n\n /* ========== PRIVATE FUNCTIONS ========================================= */\n\n function _hash(\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Mint2FA(uint256 identityId,address authorityAddress,uint256 signatureDate)\"\n ),\n identityId,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n function _hash(\n address to,\n address authorityAddress,\n uint256 signatureDate\n ) internal view returns (bytes32) {\n return\n _hashTypedDataV4(\n keccak256(\n abi.encode(\n keccak256(\n \"Mint2FA(address to,address authorityAddress,uint256 signatureDate)\"\n ),\n to,\n authorityAddress,\n signatureDate\n )\n )\n );\n }\n\n /* ========== MODIFIERS ================================================= */\n\n /* ========== EVENTS ==================================================== */\n\n event Soulbound2FAMintedToIdentity(\n uint256 tokenId,\n uint256 identityId,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n\n event Soulbound2FAMintedToAddress(\n uint256 tokenId,\n address to,\n address authorityAddress,\n uint256 signatureDate,\n address paymentMethod,\n uint256 mintPrice\n );\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 1, - "details": { - "yul": false - } - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates", - "devdoc", - "userdoc" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file