diff --git a/package.json b/package.json index eaf0b1f..3700a9e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@0xsequence/design-system": "^1.0.13", "@0xsequence/indexer": "^1.1.3", "@0xsequence/network": "^1.1.3", - "@0xsequence/waas": "0.0.0-20231113164400", + "@0xsequence/waas": "0.0.0-20231121142317", "@react-oauth/google": "^0.11.1", "@vanilla-extract/css": "^1.12.0", "axios": "^1.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 703f5e1..c038eab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ dependencies: specifier: ^1.1.3 version: 1.4.0(ethers@5.7.2) '@0xsequence/waas': - specifier: 0.0.0-20231113164400 - version: 0.0.0-20231113164400 + specifier: 0.0.0-20231121142317 + version: 0.0.0-20231121142317 '@react-oauth/google': specifier: ^0.11.1 version: 0.11.1(react-dom@18.2.0)(react@18.2.0) @@ -156,8 +156,8 @@ packages: js-base64: 3.7.5 dev: false - /@0xsequence/waas@0.0.0-20231113164400: - resolution: {integrity: sha512-0HrQe/vU8uWs9D6RBSEX+K0iJedSLoGeeOgNh+jsJvykbll3YxfXYawitiXMzdiqyB86tEYmBU5jinZaLUddnw==} + /@0xsequence/waas@0.0.0-20231121142317: + resolution: {integrity: sha512-oOS62pkPFN5JVHQZDzMG3HgHtbkyxyKE5DV1S9/0XZOlLuCNaGp7M9CIAd0r+q7tUKXh3iihna0Nm4P/CBhJ3A==} dependencies: '@aws-sdk/client-cognito-identity-provider': 3.449.0 '@aws-sdk/client-kms': 3.449.0 diff --git a/src/App.tsx b/src/App.tsx index 8dc4dc8..f580729 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,8 +22,8 @@ function App() { const [walletAddress, setWalletAddress] = useState() const [fetchWalletAddressError, setFetchWalletAddressError] = useState() - const [sessionValidationSalt, setSessionValidationSalt] = useState() const [sessionValidationCode, setSessionValidationCode] = useState([]) + const [isValidateSessionPending, setIsValidateSessionPending] = useState(false) const [isFinishValidateSessionPending, setIsFinishValidateSessionPending] = useState(false) useEffect(() => { @@ -47,28 +47,33 @@ function App() { useEffect(() => { const code = sessionValidationCode.join('') - if (code.length === 6 && sessionValidationSalt) { - sequence.finishValidateSession(sessionValidationSalt, code) + if (code.length === 6) { setIsFinishValidateSessionPending(true) + sequence.finishValidateSession(code) } }, [sessionValidationCode]) - sequence.onValidationRequired(salt => { - setSessionValidationSalt(salt) - sequence.waitForSessionValid(600 * 1000, 4000).then((isValid: boolean) => { - console.log('isValid', isValid) - if (isValid) { - setSessionValidationSalt(undefined) - } - setSessionValidationCode([]) - setIsFinishValidateSessionPending(false) + useEffect(() => { + const removeCallback = sequence.onValidationRequired(() => { + setIsValidateSessionPending(true) + + sequence.waitForSessionValid(600 * 1000, 4000).then((isValid: boolean) => { + console.log('isValid', isValid) + setSessionValidationCode([]) + setIsValidateSessionPending(false) + setIsFinishValidateSessionPending(false) + }) }) - }) + return () => { + removeCallback.then((cb: any) => cb()) + } + }, []); + return ( <> - {sessionValidationSalt && ( + {isValidateSessionPending && (