diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 6a6dcae6f89..d42a8681ef8 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -43,7 +43,7 @@ "@onekeyhq/components": "*", "@onekeyhq/kit": "*", "@onekeyhq/shared": "*", - "@privy-io/expo": "0.40.0", + "@privy-io/expo": "0.42.0", "@privy-io/expo-native-extensions": "^0.0.3", "@react-native-async-storage/async-storage": "1.22.0", "@react-native-community/netinfo": "^11.4.1", diff --git a/package.json b/package.json index 350bfa5db5f..8818c013191 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@polkadot/extension-inject": "0.46.6", "@polkadot/types": "11.3.1", "@polkadot/util-crypto": "12.6.2", - "@privy-io/react-auth": "2.0.4", + "@privy-io/react-auth": "1.98.4", "@revenuecat/purchases-js": "^0.15.1", "@sentry/browser": "8.42.0", "@sentry/core": "8.42.0", diff --git a/packages/kit/src/views/Prime/components/PrivyProvider.native.tsx b/packages/kit/src/views/Prime/components/PrivyProvider.native.tsx index 4fea8e93c26..c62542c9f75 100644 --- a/packages/kit/src/views/Prime/components/PrivyProvider.native.tsx +++ b/packages/kit/src/views/Prime/components/PrivyProvider.native.tsx @@ -11,15 +11,16 @@ function PrivyAuthSyncToAtom() { } export function PrivyProvider({ children }: { children: React.ReactNode }) { - const appId = process.env.PRIVY_APP_ID ?? ''; - const clientId = process.env.PRIVY_MOBILE_CLIENT_ID ?? ''; + const appId = process.env.PRIVY_APP_ID ?? 'cm5599w1609v7kfpecfmser60'; + const clientId = + process.env.PRIVY_MOBILE_CLIENT_ID ?? + 'client-WY5fBvyK4K8iTegm8s91XNttaKsDN9mJeTJUu1FXxckKp'; if (!appId) { throw new Error('PRIVY_APP_ID is not set'); } if (!clientId) { throw new Error('PRIVY_MOBILE_CLIENT_ID is not set'); } - // throw new Error('PRIVY_MOBILE_CLIENT_ID is not set'); return ( diff --git a/packages/kit/src/views/Prime/components/PrivyProvider.tsx b/packages/kit/src/views/Prime/components/PrivyProvider.tsx index 5fe02d2d443..55233d223f3 100644 --- a/packages/kit/src/views/Prime/components/PrivyProvider.tsx +++ b/packages/kit/src/views/Prime/components/PrivyProvider.tsx @@ -8,11 +8,16 @@ function PrivyAuthSyncToAtom() { } export function PrivyProvider({ children }: { children: React.ReactNode }) { - const appId = process.env.PRIVY_APP_ID ?? ''; - console.log('nnnn', process.env); + const appId = process.env.PRIVY_APP_ID ?? 'cm5599w1609v7kfpecfmser60'; + const clientId = + process.env.PRIVY_MOBILE_CLIENT_ID ?? + 'client-WY5fBvyK4K8iTegm8s91XNttaKsDN9mJeTJUu1FXxckKp'; if (!appId) { throw new Error('PRIVY_APP_ID is not set'); } + if (!clientId) { + throw new Error('PRIVY_MOBILE_CLIENT_ID is not set'); + } // TODO: ext error // Embedded wallet is only available over HTTPS diff --git a/packages/kit/src/views/Prime/hooks/PrimeSignupTest.tsx b/packages/kit/src/views/Prime/hooks/PrimeSignupTest.tsx new file mode 100644 index 00000000000..5864b722a76 --- /dev/null +++ b/packages/kit/src/views/Prime/hooks/PrimeSignupTest.tsx @@ -0,0 +1,42 @@ +import { useState } from 'react'; + +import { useLoginWithEmail } from '@privy-io/expo'; + +import { Button, Input, OTPInput, Toast, YStack } from '@onekeyhq/components'; + +export function PrimeSignupTest() { + const [email, setEmail] = useState('limichange@hotmail.com'); + const { sendCode, loginWithCode, state } = useLoginWithEmail({ + onSendCodeSuccess() { + Toast.message({ + title: 'onSendCodeSuccess', + }); + }, + onLoginSuccess(user, isNewUser) { + Toast.success({ + title: 'onLoginSuccess', + message: `user${JSON.stringify(user, null, 2)}`, + }); + }, + onError(error) { + console.log('error', error); + // show a toast, update form errors, etc... + }, + }); + const [codeEmail, setCodeEmail] = useState(''); + return ( + + + + + + + ); +} diff --git a/packages/kit/src/views/Prime/hooks/usePrivyUniversalV2/usePrivyUniversalV2.native.ts b/packages/kit/src/views/Prime/hooks/usePrivyUniversalV2/usePrivyUniversalV2.native.ts index 8d8be0bbbd9..e091f24d2f7 100644 --- a/packages/kit/src/views/Prime/hooks/usePrivyUniversalV2/usePrivyUniversalV2.native.ts +++ b/packages/kit/src/views/Prime/hooks/usePrivyUniversalV2/usePrivyUniversalV2.native.ts @@ -1,6 +1,7 @@ import { useLoginWithEmail, usePrivy } from '@privy-io/expo'; import type { IUsePrivyUniversalV2 } from './usePrivyUniversalV2Types'; +import { Toast } from '@onekeyhq/components'; export function usePrivyUniversalV2(): IUsePrivyUniversalV2 { const { logout, isReady, getAccessToken, user } = usePrivy(); @@ -10,6 +11,11 @@ export function usePrivyUniversalV2(): IUsePrivyUniversalV2 { useLoginWithEmail: (args) => { const { onComplete, onError } = args || {}; const { sendCode, loginWithCode, state } = useLoginWithEmail({ + onSendCodeSuccess: () => { + Toast.success({ + title: 'send code', + }); + }, onLoginSuccess: () => { onComplete?.(); }, diff --git a/packages/kit/src/views/Prime/pages/PrimeDashboard/PrimeDashboard.tsx b/packages/kit/src/views/Prime/pages/PrimeDashboard/PrimeDashboard.tsx index f5cc5eb1625..a77e86304f4 100644 --- a/packages/kit/src/views/Prime/pages/PrimeDashboard/PrimeDashboard.tsx +++ b/packages/kit/src/views/Prime/pages/PrimeDashboard/PrimeDashboard.tsx @@ -110,9 +110,7 @@ export default function PrimeDashboard() { if (!user?.isLoggedIn) { await loginWithEmail(); - } - - if (platformEnv.isNative) { + } else if (platformEnv.isNative) { ActionList.show({ title: 'Purchase', onClose: () => {}, @@ -304,6 +302,8 @@ export default function PrimeDashboard() { PaywallPackages + + {/* */} =8 <10" + peerDependencies: + permissionless: ^0.2.10 + viem: ^2.21.36 + peerDependenciesMeta: + permissionless: + optional: true + viem: + optional: true + checksum: 10/8f2e5dff2fbd37bdadcf680a1139d782cfa68d1cc33969f3ed1f88f963f0601bf4306362872442052f4d9737d613407a118d6f51d0279749ca4f17d4540a8966 + languageName: node + linkType: hard + +"@privy-io/js-sdk-core@npm:0.41.1": + version: 0.41.1 + resolution: "@privy-io/js-sdk-core@npm:0.41.1" dependencies: "@ethersproject/abstract-signer": "npm:^5.7.0" "@ethersproject/bignumber": "npm:^5.7.0" @@ -9088,7 +9128,7 @@ __metadata: "@ethersproject/transactions": "npm:^5.7.0" "@ethersproject/units": "npm:^5.7.0" "@privy-io/api-base": "npm:^1.4.2" - "@privy-io/public-api": "npm:2.18.0" + "@privy-io/public-api": "npm:2.18.2" eventemitter3: "npm:^5.0.1" fetch-retry: "npm:^5.0.6" jose: "npm:^4.15.5" @@ -9104,34 +9144,57 @@ __metadata: optional: true viem: optional: true - checksum: 10/12b71e6ba1d19bb21be375ee783e1326948c0b2a6467e6ad07997c65e37f20975af33d06c905e9cd8a54a5b237db1374dff68ea986e3702fc17d3d1cd8cd52f3 + checksum: 10/a437362b791b78bde55d3a831da6d01ac77b8486562d868ae686eacc2786426b51d3e350725e2ef10ea73649e04b94b99f1f4e62268c02462d1849caaf8088d6 languageName: node linkType: hard -"@privy-io/public-api@npm:2.18.0": - version: 2.18.0 - resolution: "@privy-io/public-api@npm:2.18.0" +"@privy-io/public-api@npm:2.15.8": + version: 2.15.8 + resolution: "@privy-io/public-api@npm:2.15.8" + dependencies: + "@privy-io/api-base": "npm:1.4.1" + bs58: "npm:^5.0.0" + ethers: "npm:^5.7.2" + libphonenumber-js: "npm:^1.10.31" + zod: "npm:^3.22.4" + checksum: 10/bf7ec8d8c608c2ef206a4a1ae87354e3626d78e0d23f83e00b31056a0ab8f57fff144c60bb614665b2abc3d0aabc6076fcd85f85e82ef08f557ca3b16e638fba + languageName: node + linkType: hard + +"@privy-io/public-api@npm:2.18.2": + version: 2.18.2 + resolution: "@privy-io/public-api@npm:2.18.2" dependencies: "@privy-io/api-base": "npm:1.4.2" bs58: "npm:^5.0.0" ethers: "npm:^5.7.2" libphonenumber-js: "npm:^1.10.31" zod: "npm:^3.22.4" - checksum: 10/66faaeab5f58b9b1315d93a943800e62b786608cd92936c0097a4d5e381f3b70ee5e9822052972c5e977bad9c17048ede8564d7c3a3a98314817a6f71f43ee40 + checksum: 10/0368a5f275e83b4aa02f9cf3bb7ecaf17aecaa83990db634906a8b424181a951da2b67b28b17357bb6df80028c39b0ff3c69ba5f06453fc04c974ce669ef0f87 languageName: node linkType: hard -"@privy-io/react-auth@npm:2.0.4": - version: 2.0.4 - resolution: "@privy-io/react-auth@npm:2.0.4" +"@privy-io/react-auth@npm:1.98.4": + version: 1.98.4 + resolution: "@privy-io/react-auth@npm:1.98.4" dependencies: "@coinbase/wallet-sdk": "npm:4.0.3" + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/contracts": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/providers": "npm:^5.7.1" + "@ethersproject/strings": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + "@ethersproject/units": "npm:^5.7.0" "@floating-ui/react": "npm:^0.26.22" "@headlessui/react": "npm:^2.2.0" "@heroicons/react": "npm:^2.1.1" "@marsidev/react-turnstile": "npm:^0.4.1" "@metamask/eth-sig-util": "npm:^6.0.0" - "@privy-io/js-sdk-core": "npm:0.40.0" + "@privy-io/js-sdk-core": "npm:0.36.1" "@simplewebauthn/browser": "npm:^9.0.1" "@solana/wallet-adapter-base": "npm:^0.9.23" "@solana/wallet-standard-wallet-adapter-base": "npm:^1.1.2" @@ -9159,9 +9222,11 @@ __metadata: tinycolor2: "npm:^1.6.0" uuid: "npm:>=8 <10" viem: "npm:^2.21.9" - zustand: "npm:^5.0.0" + web3-core: "npm:^1.8.0" + web3-core-helpers: "npm:^1.8.0" + zustand: "npm:^5.0.1" peerDependencies: - "@abstract-foundation/agw-client": ^1.0.0 + "@abstract-foundation/agw-client": ^0.1.0 "@solana/web3.js": ^1.95.8 permissionless: ^0.2.10 react: ^18 || ^19 @@ -9173,7 +9238,7 @@ __metadata: optional: true permissionless: optional: true - checksum: 10/ac4911f2343254e012228a716e0e934ce0cae7c7f5166dbedcce4238b190ba8268c48a1884666ae135afbc8c156ace222abe718d3828d5f92687fd3cfbe4f0b3 + checksum: 10/fcf98771e0cc03e2c472ea7a6876a5a5dd479348f7abda93ba01971eceba8aecb1e8973d99ed1a27fb6f98dda8a0cf6475f5ecf6004549823cbfa0aaeaa41245 languageName: node linkType: hard @@ -40904,6 +40969,16 @@ __metadata: languageName: node linkType: hard +"web3-core-helpers@npm:1.10.4, web3-core-helpers@npm:^1.8.0": + version: 1.10.4 + resolution: "web3-core-helpers@npm:1.10.4" + dependencies: + web3-eth-iban: "npm:1.10.4" + web3-utils: "npm:1.10.4" + checksum: 10/9c22942827bed0e46ae491a0bee3cd60cea636f9b0408b11bb341b0370e58a94358025657405142c2a24f3912a8f947e6e977d594d9ba66e11dedce3c5c4a7f4 + languageName: node + linkType: hard + "web3-core-method@npm:1.10.3": version: 1.10.3 resolution: "web3-core-method@npm:1.10.3" @@ -40917,6 +40992,19 @@ __metadata: languageName: node linkType: hard +"web3-core-method@npm:1.10.4": + version: 1.10.4 + resolution: "web3-core-method@npm:1.10.4" + dependencies: + "@ethersproject/transactions": "npm:^5.6.2" + web3-core-helpers: "npm:1.10.4" + web3-core-promievent: "npm:1.10.4" + web3-core-subscriptions: "npm:1.10.4" + web3-utils: "npm:1.10.4" + checksum: 10/d942beba3999c084333f5c808ada2a90930d55d148d5f8cc51a2135f8ab3f101fa5ce0d732a60830e8cad2af844bbed6cf0b6250863003adafb08c7ffa9fbd5f + languageName: node + linkType: hard + "web3-core-promievent@npm:1.10.3": version: 1.10.3 resolution: "web3-core-promievent@npm:1.10.3" @@ -40926,6 +41014,15 @@ __metadata: languageName: node linkType: hard +"web3-core-promievent@npm:1.10.4": + version: 1.10.4 + resolution: "web3-core-promievent@npm:1.10.4" + dependencies: + eventemitter3: "npm:4.0.4" + checksum: 10/a792c74aa5c91dc63fb493af04628ecfa08b9e6ceea402dfe53f718b019c41d63a0200bf3045dd23ec3c42b8d7474ac96eb4cb4456060becc551c2cacbd02bb1 + languageName: node + linkType: hard + "web3-core-requestmanager@npm:1.10.3": version: 1.10.3 resolution: "web3-core-requestmanager@npm:1.10.3" @@ -40939,6 +41036,19 @@ __metadata: languageName: node linkType: hard +"web3-core-requestmanager@npm:1.10.4": + version: 1.10.4 + resolution: "web3-core-requestmanager@npm:1.10.4" + dependencies: + util: "npm:^0.12.5" + web3-core-helpers: "npm:1.10.4" + web3-providers-http: "npm:1.10.4" + web3-providers-ipc: "npm:1.10.4" + web3-providers-ws: "npm:1.10.4" + checksum: 10/c26bf616cc156b2198bf634084978d66cf384cf2b174324b6ada071a8c9e9be7855d72c09453308d1a46b50874c18ff9b75193f8736c2b285cdc32209391880c + languageName: node + linkType: hard + "web3-core-subscriptions@npm:1.10.3": version: 1.10.3 resolution: "web3-core-subscriptions@npm:1.10.3" @@ -40949,6 +41059,16 @@ __metadata: languageName: node linkType: hard +"web3-core-subscriptions@npm:1.10.4": + version: 1.10.4 + resolution: "web3-core-subscriptions@npm:1.10.4" + dependencies: + eventemitter3: "npm:4.0.4" + web3-core-helpers: "npm:1.10.4" + checksum: 10/b1652988c0925ab1d5c27e67a816ec6bcb32f37f59c7314e1f02552233fbc486a0de579aeb660d77d82452b63e9feaa98317ec7897cd7aeb140595c8e176d0eb + languageName: node + linkType: hard + "web3-core@npm:1.10.3": version: 1.10.3 resolution: "web3-core@npm:1.10.3" @@ -40964,6 +41084,21 @@ __metadata: languageName: node linkType: hard +"web3-core@npm:^1.8.0": + version: 1.10.4 + resolution: "web3-core@npm:1.10.4" + dependencies: + "@types/bn.js": "npm:^5.1.1" + "@types/node": "npm:^12.12.6" + bignumber.js: "npm:^9.0.0" + web3-core-helpers: "npm:1.10.4" + web3-core-method: "npm:1.10.4" + web3-core-requestmanager: "npm:1.10.4" + web3-utils: "npm:1.10.4" + checksum: 10/138c5abff27a48d16584fdbe56b940f9efe7cd2463d768f42c5fcdfc97d0dc4fc41e09ff1ffb8c8ff79b22a69e9efbf5af27c4b6a0d888c351202f03a8b01b8e + languageName: node + linkType: hard + "web3-eth-abi@npm:1.10.3": version: 1.10.3 resolution: "web3-eth-abi@npm:1.10.3" @@ -41034,6 +41169,16 @@ __metadata: languageName: node linkType: hard +"web3-eth-iban@npm:1.10.4": + version: 1.10.4 + resolution: "web3-eth-iban@npm:1.10.4" + dependencies: + bn.js: "npm:^5.2.1" + web3-utils: "npm:1.10.4" + checksum: 10/b5e33aaf3d41608ed59ea98c703271eefcd30aea15163cda4bc8713f9716eb40b816e8047022ebf71391250983acfe58e65551461109a53e266f4b824c4a0678 + languageName: node + linkType: hard + "web3-eth-personal@npm:1.10.3": version: 1.10.3 resolution: "web3-eth-personal@npm:1.10.3" @@ -41091,6 +41236,18 @@ __metadata: languageName: node linkType: hard +"web3-providers-http@npm:1.10.4": + version: 1.10.4 + resolution: "web3-providers-http@npm:1.10.4" + dependencies: + abortcontroller-polyfill: "npm:^1.7.5" + cross-fetch: "npm:^4.0.0" + es6-promise: "npm:^4.2.8" + web3-core-helpers: "npm:1.10.4" + checksum: 10/2ff27d45cc7c7b1e8f07a7917fe1502fef59e211b2ee97851369f9b6dab99ce81b0bef50f9ecf36286137fc41f1230f04b55b090d30f870fbc5ef1972d165b5f + languageName: node + linkType: hard + "web3-providers-ipc@npm:1.10.3": version: 1.10.3 resolution: "web3-providers-ipc@npm:1.10.3" @@ -41101,6 +41258,16 @@ __metadata: languageName: node linkType: hard +"web3-providers-ipc@npm:1.10.4": + version: 1.10.4 + resolution: "web3-providers-ipc@npm:1.10.4" + dependencies: + oboe: "npm:2.1.5" + web3-core-helpers: "npm:1.10.4" + checksum: 10/cd33a954f59ba3a9ca466dca0d6563f46c56879dc249d885b8edfee077f9f58ccf591ba06855e1d69baba52a8719c03684b0ba7b33d836bfdd4c6166e289c0d4 + languageName: node + linkType: hard + "web3-providers-ws@npm:1.10.3": version: 1.10.3 resolution: "web3-providers-ws@npm:1.10.3" @@ -41112,6 +41279,17 @@ __metadata: languageName: node linkType: hard +"web3-providers-ws@npm:1.10.4": + version: 1.10.4 + resolution: "web3-providers-ws@npm:1.10.4" + dependencies: + eventemitter3: "npm:4.0.4" + web3-core-helpers: "npm:1.10.4" + websocket: "npm:^1.0.32" + checksum: 10/98cb76473ae1060e21ff474768a04c6dcd91724f24a1fac2d4a5f186a35bd2f119605fbb28423dfe5be33755b1e5808b10514ddaf326b57573b447efc84ef730 + languageName: node + linkType: hard + "web3-shh@npm:1.10.3": version: 1.10.3 resolution: "web3-shh@npm:1.10.3" @@ -41140,6 +41318,22 @@ __metadata: languageName: node linkType: hard +"web3-utils@npm:1.10.4": + version: 1.10.4 + resolution: "web3-utils@npm:1.10.4" + dependencies: + "@ethereumjs/util": "npm:^8.1.0" + bn.js: "npm:^5.2.1" + ethereum-bloom-filters: "npm:^1.0.6" + ethereum-cryptography: "npm:^2.1.2" + ethjs-unit: "npm:0.1.6" + number-to-bn: "npm:1.7.0" + randombytes: "npm:^2.1.0" + utf8: "npm:3.0.0" + checksum: 10/3e586b638cdae9fa45b7698e8a511ae2cbf60e219a900351ae38d384beaaf67424ac6e1d9c5098c3fb8f2ff3cc65a70d977a20bdce3dad542cb50deb666ea2a3 + languageName: node + linkType: hard + "web3@npm:^1.7.3": version: 1.10.3 resolution: "web3@npm:1.10.3" @@ -42404,7 +42598,7 @@ __metadata: languageName: node linkType: hard -"zustand@npm:^5.0.0": +"zustand@npm:^5.0.1": version: 5.0.3 resolution: "zustand@npm:5.0.3" peerDependencies: