diff --git a/package.json b/package.json index a7784b2..2ceb42d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperplay/quests-ui", - "version": "0.0.22", + "version": "0.0.23", "description": "", "main": "index.js", "scripts": { @@ -25,7 +25,7 @@ "types": "dist/index.d.ts", "devDependencies": { "@hyperplay/chains": "^0.3.0", - "@hyperplay/ui": "^1.7.17", + "@hyperplay/ui": "^1.8.0", "@hyperplay/utils": "^0.2.3", "@tanstack/react-query": "^5.51.23", "@types/react": "^18.3.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa0b705..4537114 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,8 +16,8 @@ importers: specifier: ^0.3.0 version: 0.3.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10) '@hyperplay/ui': - specifier: ^1.7.17 - version: 1.7.17(@emotion/react@11.13.0(@types/react@18.3.3)(react@18.3.1))(@mantine/carousel@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/dropzone@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-autoplay@8.1.8(embla-carousel@8.1.8))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react-markdown@9.0.1(@types/react@18.3.3)(react@18.3.1))(react@18.3.1) + specifier: ^1.8.0 + version: 1.8.1(@emotion/react@11.13.0(@types/react@18.3.3)(react@18.3.1))(@mantine/carousel@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/dropzone@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(bufferutil@4.0.8)(embla-carousel-autoplay@8.1.8(embla-carousel@8.1.8))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react-markdown@9.0.1(@types/react@18.3.3)(react@18.3.1))(react@18.3.1)(utf-8-validate@5.0.10) '@hyperplay/utils': specifier: ^0.2.3 version: 0.2.3 @@ -84,6 +84,9 @@ packages: '@adraffy/ens-normalize@1.10.0': resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} + '@adraffy/ens-normalize@1.10.1': + resolution: {integrity: sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==} + '@ampproject/remapping@2.3.0': resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} @@ -1032,6 +1035,63 @@ packages: resolution: {integrity: sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA==} engines: {node: '>=14'} + '@ethersproject/abi@5.7.0': + resolution: {integrity: sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==} + + '@ethersproject/abstract-provider@5.7.0': + resolution: {integrity: sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==} + + '@ethersproject/abstract-signer@5.7.0': + resolution: {integrity: sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==} + + '@ethersproject/address@5.7.0': + resolution: {integrity: sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==} + + '@ethersproject/base64@5.7.0': + resolution: {integrity: sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==} + + '@ethersproject/bignumber@5.7.0': + resolution: {integrity: sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==} + + '@ethersproject/bytes@5.7.0': + resolution: {integrity: sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==} + + '@ethersproject/constants@5.7.0': + resolution: {integrity: sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==} + + '@ethersproject/contracts@5.7.0': + resolution: {integrity: sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==} + + '@ethersproject/hash@5.7.0': + resolution: {integrity: sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==} + + '@ethersproject/keccak256@5.7.0': + resolution: {integrity: sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==} + + '@ethersproject/logger@5.7.0': + resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} + + '@ethersproject/networks@5.7.1': + resolution: {integrity: sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==} + + '@ethersproject/properties@5.7.0': + resolution: {integrity: sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==} + + '@ethersproject/rlp@5.7.0': + resolution: {integrity: sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==} + + '@ethersproject/signing-key@5.7.0': + resolution: {integrity: sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==} + + '@ethersproject/strings@5.7.0': + resolution: {integrity: sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==} + + '@ethersproject/transactions@5.7.0': + resolution: {integrity: sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==} + + '@ethersproject/web@5.7.1': + resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==} + '@floating-ui/core@1.6.7': resolution: {integrity: sha512-yDzVT/Lm101nQ5TCVeK65LtdN7Tj4Qpr9RTXJ2vPFLqtLxwOrpoxAHAJI8J3yYWUc40J0BDBheaitK5SJmno2g==} @@ -1053,6 +1113,28 @@ packages: '@floating-ui/utils@0.2.7': resolution: {integrity: sha512-X8R8Oj771YRl/w+c1HqAC1szL8zWQRwFvgDwT129k9ACdBoud/+/rX9V0qiMl6LWUdP9voC2nDVZYPMQQsb6eA==} + '@fortawesome/fontawesome-common-types@6.6.0': + resolution: {integrity: sha512-xyX0X9mc0kyz9plIyryrRbl7ngsA9jz77mCZJsUkLl+ZKs0KWObgaEBoSgQiYWAsSmjz/yjl0F++Got0Mdp4Rw==} + engines: {node: '>=6'} + + '@fortawesome/fontawesome-svg-core@6.6.0': + resolution: {integrity: sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg==} + engines: {node: '>=6'} + + '@fortawesome/free-regular-svg-icons@6.6.0': + resolution: {integrity: sha512-Yv9hDzL4aI73BEwSEh20clrY8q/uLxawaQ98lekBx6t9dQKDHcDzzV1p2YtBGTtolYtNqcWdniOnhzB+JPnQEQ==} + engines: {node: '>=6'} + + '@fortawesome/free-solid-svg-icons@6.6.0': + resolution: {integrity: sha512-IYv/2skhEDFc2WGUcqvFJkeK39Q+HyPf5GHUrT/l2pKbtgEIv1al1TKd6qStR5OIwQdN1GZP54ci3y4mroJWjA==} + engines: {node: '>=6'} + + '@fortawesome/react-fontawesome@0.2.2': + resolution: {integrity: sha512-EnkrprPNqI6SXJl//m29hpaNzOp1bruISWaOiRtkMi/xSvHJlzc2j2JAYS7egxt/EbjSNV/k6Xy0AQI6vB2+1g==} + peerDependencies: + '@fortawesome/fontawesome-svg-core': ~1 || ~6 + react: '>=16.3' + '@hapi/hoek@9.3.0': resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==} @@ -1072,11 +1154,14 @@ packages: resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} deprecated: Use @eslint/object-schema instead + '@hyperplay/chains@0.2.10': + resolution: {integrity: sha512-TUe9vJo9jXx23pb5QlGuW6xo6JmXYjqXKJSma//aUPZ99HU8I/lATlyqdXwozPfQ2qGsAYn58FCTo2kbF+J+8w==} + '@hyperplay/chains@0.3.0': resolution: {integrity: sha512-7FcQSR6bIZnfJXpwDHEX4tcjMJQw/oW97h6qT+Q0eDsMdipa9m6ZJm3hybqq9asLpxlX0BV5cn01S8nRHOg9Pg==} - '@hyperplay/ui@1.7.17': - resolution: {integrity: sha512-NUNDJNBVxjij5dwIJ+kvOtiIZMWz/cvzAyQwjmXfOH/zeGc24MXkZQE6RKrHDcD06zKrEYWlcd6S+8ghQ6jM3w==} + '@hyperplay/ui@1.8.1': + resolution: {integrity: sha512-EH8ZqbZLRqHcILZPEiai8XSt2BlSf42PWQntQwlkLDnCdhYv8yY1UrXNWPQL8zY1FZnws/MBrAV4NmtyN3TcFA==} peerDependencies: '@emotion/react': ^11.11.0 '@mantine/carousel': ^7.5.1 @@ -1089,6 +1174,9 @@ packages: react-dom: ^17.0.0 || ^18.0.0 react-markdown: 9.0.1 + '@hyperplay/utils@0.1.4': + resolution: {integrity: sha512-brHHvhSl5fOLIX2hCp2ZP0dfdMHb8uGME3o3NjK0imVdYlspUVe1YXp5x9P5O2iJn+7C3oPlbLARsC/KTDWSJw==} + '@hyperplay/utils@0.2.3': resolution: {integrity: sha512-KxSFUA/3SOjU+LfteLQZ60u7x8F6okZ3lATHKkopDWg6DET6OLjZ5OMaxolyimqYe3yndnAwo6qTzEAjsHGyww==} @@ -1303,12 +1391,19 @@ packages: resolution: {integrity: sha512-z10PF9JV6SbjFq+/rYabM+8CVlMokgl8RFGvieSGNTmrkQanfHn+15XBrhG3BgUfvmTeSeyShfOHpG0i9zEdcg==} deprecated: Motion One for Vue is deprecated. Use Oku Motion instead https://oku-ui.com/motion + '@noble/curves@1.2.0': + resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} + '@noble/curves@1.4.0': resolution: {integrity: sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==} '@noble/curves@1.4.2': resolution: {integrity: sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==} + '@noble/hashes@1.3.2': + resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} + engines: {node: '>= 16'} + '@noble/hashes@1.4.0': resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} engines: {node: '>= 16'} @@ -1793,6 +1888,14 @@ packages: '@swc/types@0.1.12': resolution: {integrity: sha512-wBJA+SdtkbFhHjTMYH+dEH1y4VpfGdAc2Kw/LK09i9bXd/K6j6PkDcFCEzb6iVfZMkPRrl/q0e3toqTAJdkIVA==} + '@tabler/icons-react@2.47.0': + resolution: {integrity: sha512-iqly2FvCF/qUbgmvS8E40rVeYY7laltc5GUjRxQj59DuX0x/6CpKHTXt86YlI2whg4czvd/c8Ce8YR08uEku0g==} + peerDependencies: + react: ^16.5.1 || ^17.0.0 || ^18.0.0 + + '@tabler/icons@2.47.0': + resolution: {integrity: sha512-4w5evLh+7FUUiA1GucvGj2ReX2TvOjEr4ejXdwL/bsjoSkof6r1gQmzqI+VHrE2CpJpB3al7bCTulOkFa/RcyA==} + '@tanstack/query-core@5.51.21': resolution: {integrity: sha512-POQxm42IUp6n89kKWF4IZi18v3fxQWFRolvBA6phNVmA8psdfB1MvDnGacCJdS+EOX12w/CyHM62z//rHmYmvw==} @@ -1840,6 +1943,9 @@ packages: '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} + '@types/node@18.15.13': + resolution: {integrity: sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==} + '@types/node@18.19.44': resolution: {integrity: sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==} @@ -1942,6 +2048,9 @@ packages: '@ungap/structured-clone@1.2.0': resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + '@valist/sdk@2.10.5': + resolution: {integrity: sha512-2m95VJfljJQXaSUfqfVwfHsaVcgynY4yy6wKjIsACYgiKkzck2XqjyAOtLhRESyzvuNvBA/ypj0mP+JxdmCtOw==} + '@vitejs/plugin-react-swc@3.7.0': resolution: {integrity: sha512-yrknSb3Dci6svCd/qhHqhFPDSw0QtjumcqdKMoNNzmOl5lMXTTiqzjWtG4Qask2HdvvzaNgSunbQGet8/GrKdA==} peerDependencies: @@ -2116,6 +2225,9 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + aes-js@4.0.0-beta.5: + resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} + ajv-draft-04@1.0.0: resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} peerDependencies: @@ -2244,6 +2356,11 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} + axios-retry@4.5.0: + resolution: {integrity: sha512-aR99oXhpEDGo0UuAlYcn2iGRds30k366Zfa05XWScR9QaQD4JYiP3/1Qt1u7YlefUOK+cn0CcwoL1oefavQUlQ==} + peerDependencies: + axios: 0.x || 1.x + axios@1.7.4: resolution: {integrity: sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==} @@ -2713,6 +2830,9 @@ packages: electron-to-chromium@1.5.7: resolution: {integrity: sha512-6FTNWIWMxMy/ZY6799nBlPtF1DFDQ6VQJ7yyDP27SJNt5lwtQ5ufqVvHylb3fdQefvRcgA3fKcFMJi9OLwBRNw==} + elliptic@6.5.4: + resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} + elliptic@6.5.7: resolution: {integrity: sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==} @@ -2950,9 +3070,16 @@ packages: eth-rpc-errors@4.0.3: resolution: {integrity: sha512-Z3ymjopaoft7JDoxZcEb3pwdGh7yiYMhOwm2doUt6ASXlMavpNlK6Cre0+IMl2VSGyEU9rkiperQhp5iRxn5Pg==} + ethereum-blockies-base64@1.0.2: + resolution: {integrity: sha512-Vg2HTm7slcWNKaRhCUl/L3b4KrB8ohQXdd5Pu3OI897EcR6tVRvUqdTwAyx+dnmoDzj8e2bwBLDQ50ByFmcz6w==} + ethereum-cryptography@2.2.1: resolution: {integrity: sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg==} + ethers@6.13.3: + resolution: {integrity: sha512-/DzbZOLVtoO4fKvvQwpEucHAQgIwBGWuRvBdwE/lMXgXvvHHTSkn7XqAQ2b+gjJzZDJjWA9OD05bVceVOsBHbg==} + engines: {node: '>=14.0.0'} + event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} @@ -3473,6 +3600,10 @@ packages: resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} engines: {node: '>= 0.4'} + is-retry-allowed@2.2.0: + resolution: {integrity: sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==} + engines: {node: '>=10'} + is-set@2.0.3: resolution: {integrity: sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==} engines: {node: '>= 0.4'} @@ -3594,6 +3725,9 @@ packages: joi@17.13.3: resolution: {integrity: sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==} + js-sha3@0.8.0: + resolution: {integrity: sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -4333,6 +4467,9 @@ packages: resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==} engines: {node: '>=10.13.0'} + pnglib@0.0.1: + resolution: {integrity: sha512-95ChzOoYLOPIyVmL+Y6X+abKGXUJlvOVLkB1QQkyXl7Uczc6FElUy/x01NS7r2GX6GRezloO/ecCX9h4U9KadA==} + pony-cause@2.1.11: resolution: {integrity: sha512-M7LhCsdNbNgiLYiP4WjsfLUuFmCfnjdF6jKe2R9NKl4WFN+HZPGHJZ9lnLP7f9ZnKe3U9nuWD0szirmj+migUg==} engines: {node: '>=12.0.0'} @@ -5153,6 +5290,9 @@ packages: tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + tslib@2.4.0: + resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} + tslib@2.6.3: resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} @@ -5674,6 +5814,8 @@ snapshots: '@adraffy/ens-normalize@1.10.0': {} + '@adraffy/ens-normalize@1.10.1': {} + '@ampproject/remapping@2.3.0': dependencies: '@jridgewell/gen-mapping': 0.3.5 @@ -6813,6 +6955,142 @@ snapshots: ethereum-cryptography: 2.2.1 micro-ftch: 0.3.1 + '@ethersproject/abi@5.7.0': + dependencies: + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + + '@ethersproject/abstract-provider@5.7.0': + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + + '@ethersproject/abstract-signer@5.7.0': + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + + '@ethersproject/address@5.7.0': + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/rlp': 5.7.0 + + '@ethersproject/base64@5.7.0': + dependencies: + '@ethersproject/bytes': 5.7.0 + + '@ethersproject/bignumber@5.7.0': + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + bn.js: 5.2.1 + + '@ethersproject/bytes@5.7.0': + dependencies: + '@ethersproject/logger': 5.7.0 + + '@ethersproject/constants@5.7.0': + dependencies: + '@ethersproject/bignumber': 5.7.0 + + '@ethersproject/contracts@5.7.0': + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + + '@ethersproject/hash@5.7.0': + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + + '@ethersproject/keccak256@5.7.0': + dependencies: + '@ethersproject/bytes': 5.7.0 + js-sha3: 0.8.0 + + '@ethersproject/logger@5.7.0': {} + + '@ethersproject/networks@5.7.1': + dependencies: + '@ethersproject/logger': 5.7.0 + + '@ethersproject/properties@5.7.0': + dependencies: + '@ethersproject/logger': 5.7.0 + + '@ethersproject/rlp@5.7.0': + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + + '@ethersproject/signing-key@5.7.0': + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + bn.js: 5.2.1 + elliptic: 6.5.4 + hash.js: 1.1.7 + + '@ethersproject/strings@5.7.0': + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + + '@ethersproject/transactions@5.7.0': + dependencies: + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + + '@ethersproject/web@5.7.1': + dependencies: + '@ethersproject/base64': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@floating-ui/core@1.6.7': dependencies: '@floating-ui/utils': 0.2.7 @@ -6838,6 +7116,26 @@ snapshots: '@floating-ui/utils@0.2.7': {} + '@fortawesome/fontawesome-common-types@6.6.0': {} + + '@fortawesome/fontawesome-svg-core@6.6.0': + dependencies: + '@fortawesome/fontawesome-common-types': 6.6.0 + + '@fortawesome/free-regular-svg-icons@6.6.0': + dependencies: + '@fortawesome/fontawesome-common-types': 6.6.0 + + '@fortawesome/free-solid-svg-icons@6.6.0': + dependencies: + '@fortawesome/fontawesome-common-types': 6.6.0 + + '@fortawesome/react-fontawesome@0.2.2(@fortawesome/fontawesome-svg-core@6.6.0)(react@18.3.1)': + dependencies: + '@fortawesome/fontawesome-svg-core': 6.6.0 + prop-types: 15.8.1 + react: 18.3.1 + '@hapi/hoek@9.3.0': {} '@hapi/topo@5.1.0': @@ -6856,6 +7154,12 @@ snapshots: '@humanwhocodes/object-schema@2.0.3': {} + '@hyperplay/chains@0.2.10': + dependencies: + axios: 1.7.4 + transitivePeerDependencies: + - debug + '@hyperplay/chains@0.3.0(bufferutil@4.0.8)(typescript@5.5.4)(utf-8-validate@5.0.10)': dependencies: axios: 1.7.4 @@ -6867,18 +7171,36 @@ snapshots: - utf-8-validate - zod - '@hyperplay/ui@1.7.17(@emotion/react@11.13.0(@types/react@18.3.3)(react@18.3.1))(@mantine/carousel@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/dropzone@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-autoplay@8.1.8(embla-carousel@8.1.8))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react-markdown@9.0.1(@types/react@18.3.3)(react@18.3.1))(react@18.3.1)': + '@hyperplay/ui@1.8.1(@emotion/react@11.13.0(@types/react@18.3.3)(react@18.3.1))(@mantine/carousel@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/dropzone@7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(bufferutil@4.0.8)(embla-carousel-autoplay@8.1.8(embla-carousel@8.1.8))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react-markdown@9.0.1(@types/react@18.3.3)(react@18.3.1))(react@18.3.1)(utf-8-validate@5.0.10)': dependencies: '@emotion/react': 11.13.0(@types/react@18.3.3)(react@18.3.1) + '@fortawesome/fontawesome-svg-core': 6.6.0 + '@fortawesome/free-regular-svg-icons': 6.6.0 + '@fortawesome/free-solid-svg-icons': 6.6.0 + '@fortawesome/react-fontawesome': 0.2.2(@fortawesome/fontawesome-svg-core@6.6.0)(react@18.3.1) + '@hyperplay/chains': 0.2.10 + '@hyperplay/utils': 0.1.4 '@mantine/carousel': 7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(embla-carousel-react@8.1.8(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@mantine/core': 7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@mantine/dropzone': 7.12.1(@mantine/core@7.12.1(@mantine/hooks@7.12.1(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@mantine/hooks@7.12.1(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@mantine/hooks': 7.12.1(react@18.3.1) + '@tabler/icons-react': 2.47.0(react@18.3.1) + '@valist/sdk': 2.10.5(bufferutil@4.0.8)(utf-8-validate@5.0.10) embla-carousel-autoplay: 8.1.8(embla-carousel@8.1.8) embla-carousel-react: 8.1.8(react@18.3.1) + ethereum-blockies-base64: 1.0.2 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) react-markdown: 9.0.1(@types/react@18.3.3)(react@18.3.1) + transitivePeerDependencies: + - bufferutil + - debug + - encoding + - utf-8-validate + + '@hyperplay/utils@0.1.4': + dependencies: + bignumber.js: 9.1.2 '@hyperplay/utils@0.2.3': dependencies: @@ -7238,6 +7560,10 @@ snapshots: '@motionone/dom': 10.18.0 tslib: 2.6.3 + '@noble/curves@1.2.0': + dependencies: + '@noble/hashes': 1.3.2 + '@noble/curves@1.4.0': dependencies: '@noble/hashes': 1.4.0 @@ -7246,6 +7572,8 @@ snapshots: dependencies: '@noble/hashes': 1.4.0 + '@noble/hashes@1.3.2': {} + '@noble/hashes@1.4.0': {} '@nodelib/fs.scandir@2.1.5': @@ -7899,6 +8227,14 @@ snapshots: dependencies: '@swc/counter': 0.1.3 + '@tabler/icons-react@2.47.0(react@18.3.1)': + dependencies: + '@tabler/icons': 2.47.0 + prop-types: 15.8.1 + react: 18.3.1 + + '@tabler/icons@2.47.0': {} + '@tanstack/query-core@5.51.21': {} '@tanstack/react-query@5.51.23(react@18.3.1)': @@ -7946,6 +8282,8 @@ snapshots: dependencies: '@types/node': 22.3.0 + '@types/node@18.15.13': {} + '@types/node@18.19.44': dependencies: undici-types: 5.26.5 @@ -8072,6 +8410,19 @@ snapshots: '@ungap/structured-clone@1.2.0': {} + '@valist/sdk@2.10.5(bufferutil@4.0.8)(utf-8-validate@5.0.10)': + dependencies: + '@ethersproject/contracts': 5.7.0 + axios: 1.7.4 + axios-retry: 4.5.0(axios@1.7.4) + ethers: 6.13.3(bufferutil@4.0.8)(utf-8-validate@5.0.10) + node-fetch: 2.7.0 + transitivePeerDependencies: + - bufferutil + - debug + - encoding + - utf-8-validate + '@vitejs/plugin-react-swc@3.7.0(vite@5.4.0(@types/node@22.3.0)(sass-embedded@1.77.8)(terser@5.31.6))': dependencies: '@swc/core': 1.7.10 @@ -8526,6 +8877,8 @@ snapshots: acorn@8.12.1: {} + aes-js@4.0.0-beta.5: {} + ajv-draft-04@1.0.0(ajv@8.13.0): optionalDependencies: ajv: 8.13.0 @@ -8679,6 +9032,11 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 + axios-retry@4.5.0(axios@1.7.4): + dependencies: + axios: 1.7.4 + is-retry-allowed: 2.2.0 + axios@1.7.4: dependencies: follow-redirects: 1.15.6 @@ -9146,6 +9504,16 @@ snapshots: electron-to-chromium@1.5.7: {} + elliptic@6.5.4: + dependencies: + bn.js: 4.12.0 + brorand: 1.1.0 + hash.js: 1.1.7 + hmac-drbg: 1.0.1 + inherits: 2.0.4 + minimalistic-assert: 1.0.1 + minimalistic-crypto-utils: 1.0.1 + elliptic@6.5.7: dependencies: bn.js: 4.12.0 @@ -9524,6 +9892,10 @@ snapshots: dependencies: fast-safe-stringify: 2.1.1 + ethereum-blockies-base64@1.0.2: + dependencies: + pnglib: 0.0.1 + ethereum-cryptography@2.2.1: dependencies: '@noble/curves': 1.4.2 @@ -9531,6 +9903,19 @@ snapshots: '@scure/bip32': 1.4.0 '@scure/bip39': 1.3.0 + ethers@6.13.3(bufferutil@4.0.8)(utf-8-validate@5.0.10): + dependencies: + '@adraffy/ens-normalize': 1.10.1 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@types/node': 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + event-target-shim@5.0.1: {} eventemitter2@6.4.9: {} @@ -10057,6 +10442,8 @@ snapshots: call-bind: 1.0.7 has-tostringtag: 1.0.2 + is-retry-allowed@2.2.0: {} + is-set@2.0.3: {} is-shared-array-buffer@1.0.3: @@ -10199,6 +10586,8 @@ snapshots: '@sideway/formula': 3.0.1 '@sideway/pinpoint': 2.0.0 + js-sha3@0.8.0: {} + js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -11193,6 +11582,8 @@ snapshots: pngjs@5.0.0: {} + pnglib@0.0.1: {} + pony-cause@2.1.11: {} possible-typed-array-names@1.0.0: {} @@ -12068,6 +12459,8 @@ snapshots: tslib@1.14.1: {} + tslib@2.4.0: {} + tslib@2.6.3: {} type-check@0.4.0: diff --git a/src/components/QuestDetailsWrapper/index.tsx b/src/components/QuestDetailsWrapper/index.tsx index ea98082..deac446 100644 --- a/src/components/QuestDetailsWrapper/index.tsx +++ b/src/components/QuestDetailsWrapper/index.tsx @@ -22,7 +22,10 @@ import { mintReward } from '../../helpers/mintReward' import { resyncExternalTasks as resyncExternalTasksHelper } from '../../helpers/resyncExternalTask' import useGetUserPlayStreak from '../../hooks/useGetUserPlayStreak' import { useMutation, useQueryClient } from '@tanstack/react-query' -import { getPlaystreakArgsFromQuestData } from '../../helpers/getPlaystreakArgsFromQuestData' +import { + getPlaystreakArgsFromQuestData, + resetSessionStartedTime +} from '../../helpers/getPlaystreakArgsFromQuestData' import { useGetRewards } from '../../hooks/useGetRewards' import { chainMap, parseChainMetadataToViemChain } from '@hyperplay/chains' import { InfoAlertProps } from '@hyperplay/ui/dist/components/AlertCard' @@ -69,6 +72,8 @@ export interface QuestDetailsWrapperProps { tokenId?: number ) => Promise confirmRewardClaim: (params: ConfirmClaimParams) => Promise + questsWithExternalPlayStreakSync: number[] + syncPlayStreakWithExternalSource: (questId: number) => Promise resyncExternalTask: (rewardId: string) => Promise getExternalTaskCredits: (rewardId: string) => Promise syncPlaySession: (appName: string, runner: Runner) => Promise @@ -107,7 +112,9 @@ export function QuestDetailsWrapper({ tOverride, sessionEmail, checkG7ConnectionStatus, - isQuestsPage + isQuestsPage, + syncPlayStreakWithExternalSource, + questsWithExternalPlayStreakSync }: QuestDetailsWrapperProps) { const rewardTypeClaimEnabled = flags.rewardTypeClaimEnabled const { @@ -309,6 +316,7 @@ export function QuestDetailsWrapper({ }, sync: t('quest.sync', 'Sync'), streakProgressI18n: { + sync: t('quest.playstreak.sync', 'Sync Progress'), streakProgress: t('quest.playstreak.streakProgress', 'Streak Progress'), days: t('quest.playstreak.days', 'days'), playToStart: t( @@ -587,14 +595,24 @@ export function QuestDetailsWrapper({ eligible: false, steamAccountLinked: true }, - playStreak: getPlaystreakArgsFromQuestData( + playStreak: getPlaystreakArgsFromQuestData({ questMeta, questPlayStreakData, - isSignedIn - ) + useModuleInitTimeForSessionStartTime: isSignedIn, + onSync: async () => { + if (questsWithExternalPlayStreakSync.includes(questMeta.id)) { + await syncPlayStreakWithExternalSource(questMeta.id) + } else { + await syncPlaySession(projectId, 'hyperplay') + resetSessionStartedTime() + logInfo(`Synced play session for quest ${questMeta.id}`) + console.log(`Synced play session for quest ${questMeta.id}`) + } + questPlayStreakResult.invalidateQuery() + } + }) }, rewards: questRewards ?? [], - i18n, onClaimClick: async () => { if (isRewardOnChain) { setShowWarning(true) @@ -616,7 +634,8 @@ export function QuestDetailsWrapper({ }, isSyncing: resyncMutation.isPending, chainTooltips: {}, - isQuestsPage + isQuestsPage, + i18n } questDetails = ( <> @@ -657,6 +676,7 @@ export function QuestDetailsWrapper({ steamAccountLinked: false }, playStreak: { + onSync: () => console.log('loading...'), currentStreakInDays: 0, requiredStreakInDays: 1, minimumSessionTimeInSeconds: 100, @@ -664,7 +684,6 @@ export function QuestDetailsWrapper({ lastPlaySessionCompletedDateTimeUTC: new Date().toISOString() } }, - i18n, rewards: [], onClaimClick: () => console.log('claim clicked for ', questMeta?.name), onSignInClick: () => console.log('sign in clicked for ', questMeta?.name), @@ -673,7 +692,8 @@ export function QuestDetailsWrapper({ collapseIsOpen, toggleCollapse: () => setCollapseIsOpen(!collapseIsOpen), isSignedIn, - isQuestsPage + isQuestsPage, + i18n } questDetails = ( void +}): PlayStreakEligibility { let sessionStartedTime = undefined if (useModuleInitTimeForSessionStartTime) { sessionStartedTime = dateTimeCurrentSessionStartedInMsSinceEpoch } return { + onSync, requiredStreakInDays: questMeta?.eligibility?.play_streak.required_playstreak_in_days ?? 0, currentStreakInDays: questPlayStreakData?.current_playstreak_in_days ?? 0, diff --git a/src/hooks/useSyncPlayStreakWithExternalSource.ts b/src/hooks/useSyncPlayStreakWithExternalSource.ts new file mode 100644 index 0000000..ae13e28 --- /dev/null +++ b/src/hooks/useSyncPlayStreakWithExternalSource.ts @@ -0,0 +1,58 @@ +import { useMutation, UseMutationOptions } from '@tanstack/react-query' + +type MutationParams = { + questId: number + address: string +} + +export interface UseSyncPlayStreakProps { + getCSRFToken: () => Promise + syncPlayStreakWithExternalSource: (params: { + quest_id: number + signature: string + }) => Promise + checkPendingSync: (params: { + wallet: string + questId: number + }) => Promise + signMessage: (message: string) => Promise + mutationOptions?: Omit< + UseMutationOptions, + 'mutationFn' + > +} + +export const useSyncPlayStreakWithExternalSource = ({ + getCSRFToken, + syncPlayStreakWithExternalSource, + checkPendingSync, + signMessage, + mutationOptions = {} +}: UseSyncPlayStreakProps) => { + return useMutation({ + mutationFn: async ({ questId, address }: MutationParams) => { + let hasPendingSync = false + + try { + hasPendingSync = await checkPendingSync({ wallet: address, questId }) + } catch (error) { + console.error('Error checking pending sync', error) + } + + if (!hasPendingSync) { + console.log('No pending sync found, skipping external sync') + return + } + + const csrfToken = await getCSRFToken() + const message = `Sync play-streak of quest with ID: ${questId} \n\nNonce: ${csrfToken}` + const signature = await signMessage(message) + + await syncPlayStreakWithExternalSource({ + quest_id: questId, + signature + }) + }, + ...mutationOptions + }) +} diff --git a/src/index.ts b/src/index.ts index 2ea2df3..7c6a0cc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,5 @@ export { QuestDetailsWrapper } from './components/QuestDetailsWrapper' export type { TrackEventFn } from './types/analytics' export * from './hooks/useCheckG7ConnectionStatus' +export * from './hooks/useSyncPlayStreakWithExternalSource' +export * from './helpers/getPlaystreakArgsFromQuestData'