@mezo-org/passport 0.4.0-dev.9 → 0.5.1-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -22
- package/dist/src/api/auth.d.ts +7 -3
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +3 -1
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +4 -1
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +9 -2
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/portal.d.ts +3 -9
- package/dist/src/api/portal.d.ts.map +1 -1
- package/dist/src/api/portal.js +8 -5
- package/dist/src/api/portal.js.map +1 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +2 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.js +29 -20
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -1
- package/dist/src/components/Dropdown/Content.d.ts +4 -5
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.js +19 -61
- package/dist/src/components/Dropdown/Content.js.map +1 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +2 -2
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +9 -6
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.js +10 -10
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.d.ts +14 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +42 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +8 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +32 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +4 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +64 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +49 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +35 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
- package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +43 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +45 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +66 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +88 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.js +67 -0
- package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
- package/dist/src/config.d.ts +19 -5
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +58 -14
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +11 -3
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +12 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +18 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +67 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +13 -13
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +9 -8
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.d.ts +108 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +201 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +22 -1
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +4 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +19 -13
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +20 -1
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
- package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
- package/dist/src/hooks/useRefreshPassport.js +44 -0
- package/dist/src/hooks/useRefreshPassport.js.map +1 -0
- package/dist/src/hooks/useSignInWithWallet.d.ts +13 -13
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +13 -13
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useTokensBalances.d.ts +75 -0
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
- package/dist/src/hooks/useTokensBalances.js +181 -0
- package/dist/src/hooks/useTokensBalances.js.map +1 -0
- package/dist/src/hooks/useValidateMezoId.d.ts +8 -0
- package/dist/src/hooks/useValidateMezoId.d.ts.map +1 -0
- package/dist/src/hooks/useValidateMezoId.js +24 -0
- package/dist/src/hooks/useValidateMezoId.js.map +1 -0
- package/dist/src/hooks/useWalletAccount.d.ts +2 -1
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +20 -15
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
- package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
- package/dist/src/hooks/useWatchTransferEvents.js +63 -0
- package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +13 -0
- package/dist/src/lib/contracts/index.d.ts.map +1 -0
- package/dist/src/lib/contracts/index.js +66 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
- package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
- package/dist/src/lib/contracts/priceOracle.js +52 -0
- package/dist/src/lib/contracts/priceOracle.js.map +1 -0
- package/dist/src/provider.d.ts +7 -1
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +4 -1
- package/dist/src/provider.js.map +1 -1
- package/dist/src/stores/dropdownStore.d.ts +12 -0
- package/dist/src/stores/dropdownStore.d.ts.map +1 -0
- package/dist/src/stores/dropdownStore.js +13 -0
- package/dist/src/stores/dropdownStore.js.map +1 -0
- package/dist/src/utils/address.d.ts +1 -1
- package/dist/src/utils/address.d.ts.map +1 -1
- package/dist/src/utils/address.js +2 -0
- package/dist/src/utils/address.js.map +1 -1
- package/dist/src/utils/address.test.js +8 -5
- package/dist/src/utils/address.test.js.map +1 -1
- package/dist/src/utils/assets.d.ts +145 -0
- package/dist/src/utils/assets.d.ts.map +1 -0
- package/dist/src/utils/assets.js +100 -0
- package/dist/src/utils/assets.js.map +1 -0
- package/dist/src/utils/assets.test.d.ts +2 -0
- package/dist/src/utils/assets.test.d.ts.map +1 -0
- package/dist/src/utils/assets.test.js +46 -0
- package/dist/src/utils/assets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +13 -2
- package/dist/src/utils/currency.d.ts.map +1 -1
- package/dist/src/utils/currency.js +22 -8
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/currency.test.js +44 -1
- package/dist/src/utils/currency.test.js.map +1 -1
- package/dist/src/utils/mezoId.d.ts +7 -0
- package/dist/src/utils/mezoId.d.ts.map +1 -0
- package/dist/src/utils/mezoId.js +41 -0
- package/dist/src/utils/mezoId.js.map +1 -0
- package/dist/src/utils/number2.d.ts +106 -0
- package/dist/src/utils/number2.d.ts.map +1 -0
- package/dist/src/utils/number2.js +289 -0
- package/dist/src/utils/number2.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +15 -33
- package/dist/src/utils/numbers.d.ts.map +1 -1
- package/dist/src/utils/numbers.js +26 -70
- package/dist/src/utils/numbers.js.map +1 -1
- package/dist/src/utils/numbers.test.js +46 -42
- package/dist/src/utils/numbers.test.js.map +1 -1
- package/dist/src/utils/siww.d.ts +1 -0
- package/dist/src/utils/siww.d.ts.map +1 -1
- package/dist/src/utils/siww.js +50 -12
- package/dist/src/utils/siww.js.map +1 -1
- package/dist/src/utils/wagmi.d.ts +3 -0
- package/dist/src/utils/wagmi.d.ts.map +1 -0
- package/dist/src/utils/wagmi.js +7 -0
- package/dist/src/utils/wagmi.js.map +1 -0
- package/dist/src/wallet/index.d.ts +1 -1
- package/dist/src/wallet/index.d.ts.map +1 -1
- package/dist/src/wallet/index.js +1 -1
- package/dist/src/wallet/index.js.map +1 -1
- package/package.json +11 -8
- package/src/api/auth.ts +8 -4
- package/src/api/client.ts +11 -2
- package/src/api/portal.ts +11 -14
- package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
- package/src/components/Dropdown/Content.tsx +26 -121
- package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
- package/src/components/Dropdown/Dropdown.tsx +29 -17
- package/src/components/Dropdown/ListingItem.tsx +176 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +87 -0
- package/src/components/Dropdown/README.md +10 -18
- package/src/components/Dropdown/Receive/Receive.tsx +144 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +99 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +75 -0
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
- package/src/components/Dropdown/Root/AccountError.tsx +34 -0
- package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +85 -0
- package/src/components/Dropdown/Root/Root.tsx +77 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +123 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +173 -0
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/config.ts +88 -20
- package/src/constants.ts +12 -4
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useAssetsConversionRates.ts +79 -0
- package/src/hooks/useAuthenticateWithWallet.ts +30 -14
- package/src/hooks/useBorrowData.ts +246 -0
- package/src/hooks/useCreateAccount.ts +29 -2
- package/src/hooks/useGetCurrentAccount.ts +5 -7
- package/src/hooks/useLinkAccount.ts +37 -4
- package/src/hooks/useRefreshPassport.ts +56 -0
- package/src/hooks/useSignInWithWallet.ts +2 -2
- package/src/hooks/useSignUpWithWallet.ts +2 -2
- package/src/hooks/useTokensBalances.ts +265 -0
- package/src/hooks/useValidateMezoId.ts +31 -0
- package/src/hooks/useWalletAccount.ts +32 -20
- package/src/hooks/useWatchTransferEvents.ts +74 -0
- package/src/index.ts +12 -1
- package/src/lib/contracts/index.ts +99 -0
- package/src/lib/contracts/priceOracle.ts +53 -0
- package/src/provider.ts +11 -3
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +10 -6
- package/src/utils/address.ts +5 -3
- package/src/utils/assets.test.ts +57 -0
- package/src/utils/assets.ts +103 -0
- package/src/utils/currency.test.ts +77 -1
- package/src/utils/currency.ts +35 -9
- package/src/utils/mezoId.ts +51 -0
- package/src/utils/number2.ts +419 -0
- package/src/utils/numbers.test.ts +49 -42
- package/src/utils/numbers.ts +33 -95
- package/src/utils/siww.ts +71 -16
- package/src/utils/wagmi.ts +12 -0
- package/src/wallet/index.ts +3 -2
- package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
- package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountAddress.js +0 -58
- package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
- package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
- package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountAssets.js +0 -44
- package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
- package/dist/src/components/Dropdown/AccountBalance.d.ts +0 -7
- package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountBalance.js +0 -18
- package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts +0 -8
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
- package/dist/src/components/Dropdown/WelcomeBlock.js +0 -44
- package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
- package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
- package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
- package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
- package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
- package/dist/src/hooks/useDropdownData.d.ts +0 -44
- package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
- package/dist/src/hooks/useDropdownData.js +0 -73
- package/dist/src/hooks/useDropdownData.js.map +0 -1
- package/dist/src/utils/cryptoAssets.d.ts +0 -28
- package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.js +0 -73
- package/dist/src/utils/cryptoAssets.js.map +0 -1
- package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
- package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.test.js +0 -49
- package/dist/src/utils/cryptoAssets.test.js.map +0 -1
- package/src/components/Dropdown/AccountAddress.tsx +0 -111
- package/src/components/Dropdown/AccountAssets.tsx +0 -110
- package/src/components/Dropdown/AccountBalance.tsx +0 -38
- package/src/components/Dropdown/WelcomeBlock.tsx +0 -92
- package/src/hooks/useAssetsUSDConversion.ts +0 -31
- package/src/hooks/useDropdownData.ts +0 -130
- package/src/utils/cryptoAssets.test.ts +0 -59
- package/src/utils/cryptoAssets.ts +0 -93
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
2
|
+
import React, { useMemo } from "react"
|
|
3
|
+
import { AnimatePresence, motion } from "motion/react"
|
|
4
|
+
import { Block, useStyletron } from "@mezo-org/mezo-clay"
|
|
5
|
+
|
|
6
|
+
type SlotNumberProps = {
|
|
7
|
+
className?: string
|
|
8
|
+
children: number
|
|
9
|
+
formatFunction?: (value: number) => string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type SlotNumberDigitProps = {
|
|
13
|
+
className?: string
|
|
14
|
+
children: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function SlotNumberDigit(props: SlotNumberDigitProps) {
|
|
18
|
+
const { children: value, ...restProps } = props
|
|
19
|
+
|
|
20
|
+
const [css] = useStyletron()
|
|
21
|
+
|
|
22
|
+
const digits = [...Array(10).keys()]
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<AnimatePresence initial={false}>
|
|
26
|
+
<motion.div
|
|
27
|
+
initial={{
|
|
28
|
+
y: "100%",
|
|
29
|
+
}}
|
|
30
|
+
animate={{
|
|
31
|
+
y: "0%",
|
|
32
|
+
}}
|
|
33
|
+
layout="position"
|
|
34
|
+
className={css({
|
|
35
|
+
position: "relative",
|
|
36
|
+
})}
|
|
37
|
+
{...restProps}
|
|
38
|
+
>
|
|
39
|
+
<Block
|
|
40
|
+
overrides={{
|
|
41
|
+
Block: {
|
|
42
|
+
style: {
|
|
43
|
+
visibility: "hidden",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{value}
|
|
49
|
+
</Block>
|
|
50
|
+
|
|
51
|
+
<motion.div
|
|
52
|
+
className={css({
|
|
53
|
+
display: "flex",
|
|
54
|
+
flexDirection: "column",
|
|
55
|
+
position: "absolute",
|
|
56
|
+
inset: 0,
|
|
57
|
+
height: "fit-content",
|
|
58
|
+
})}
|
|
59
|
+
initial={false}
|
|
60
|
+
animate={{ y: `${(value / 10) * -100}%` }}
|
|
61
|
+
transition={{
|
|
62
|
+
type: "spring",
|
|
63
|
+
damping: 16,
|
|
64
|
+
stiffness: 220,
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
{digits.map((digit) => (
|
|
68
|
+
<Block as="span" key={digit}>
|
|
69
|
+
{digit}
|
|
70
|
+
</Block>
|
|
71
|
+
))}
|
|
72
|
+
</motion.div>
|
|
73
|
+
</motion.div>
|
|
74
|
+
</AnimatePresence>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* SlotNumber component displays a number with animated digits.
|
|
80
|
+
*
|
|
81
|
+
* @typedef {object} SlotNumberProps
|
|
82
|
+
* @property {number} children - The number to display.
|
|
83
|
+
* @property {function} [formatFunction] - Optional function to format the number.
|
|
84
|
+
* @property {BlockProps} [restProps] - Additional properties for the Block component.
|
|
85
|
+
* @see https://pyszkowski.dev/writings/slot-number
|
|
86
|
+
* @returns {JSX.Element} The rendered SlotNumber component.
|
|
87
|
+
*/
|
|
88
|
+
function SlotNumber(props: SlotNumberProps) {
|
|
89
|
+
const { children: value, formatFunction, ...restProps } = props
|
|
90
|
+
|
|
91
|
+
const [css] = useStyletron()
|
|
92
|
+
|
|
93
|
+
const characters = useMemo(() => {
|
|
94
|
+
const formattedValue = formatFunction
|
|
95
|
+
? formatFunction(value)
|
|
96
|
+
: value.toString()
|
|
97
|
+
|
|
98
|
+
return formattedValue
|
|
99
|
+
.split("")
|
|
100
|
+
.map((character) => (/^[0-9]$/.test(character) ? +character : character))
|
|
101
|
+
.reverse()
|
|
102
|
+
}, [formatFunction, value])
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<motion.div
|
|
106
|
+
layout
|
|
107
|
+
className={css({
|
|
108
|
+
display: "inline-flex",
|
|
109
|
+
flexDirection: "row-reverse",
|
|
110
|
+
justifyContent: "flex-end",
|
|
111
|
+
overflow: "hidden",
|
|
112
|
+
userSelect: "none",
|
|
113
|
+
})}
|
|
114
|
+
{...restProps}
|
|
115
|
+
>
|
|
116
|
+
{characters.map((character, index) =>
|
|
117
|
+
typeof character === "number" ? (
|
|
118
|
+
<SlotNumberDigit key={`slot-number-character-${index}`}>
|
|
119
|
+
{character}
|
|
120
|
+
</SlotNumberDigit>
|
|
121
|
+
) : (
|
|
122
|
+
<motion.span layout key={`slot-number-character-${index}`}>
|
|
123
|
+
{character}
|
|
124
|
+
</motion.span>
|
|
125
|
+
),
|
|
126
|
+
)}
|
|
127
|
+
</motion.div>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default SlotNumber
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
Block,
|
|
4
|
+
InfoCircle,
|
|
5
|
+
LabelSmall,
|
|
6
|
+
useStyletron,
|
|
7
|
+
} from "@mezo-org/mezo-clay"
|
|
8
|
+
import { usePassportContext } from "../../hooks/usePassportContext"
|
|
9
|
+
|
|
10
|
+
export default function TestnetTopBanner() {
|
|
11
|
+
const [, theme] = useStyletron()
|
|
12
|
+
|
|
13
|
+
const { environment } = usePassportContext()
|
|
14
|
+
|
|
15
|
+
if (environment !== "testnet") {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Block
|
|
21
|
+
display="flex"
|
|
22
|
+
alignItems="center"
|
|
23
|
+
padding={`${theme.sizing.scale700} ${theme.sizing.scale600}`}
|
|
24
|
+
backgroundColor={theme.colors.warning}
|
|
25
|
+
>
|
|
26
|
+
<InfoCircle size={theme.sizing.scale550} />
|
|
27
|
+
<LabelSmall marginLeft={theme.sizing.scale500}>
|
|
28
|
+
You are using testnet funds.
|
|
29
|
+
</LabelSmall>
|
|
30
|
+
</Block>
|
|
31
|
+
)
|
|
32
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { http } from "viem"
|
|
2
1
|
import { Chain, getDefaultConfig, WalletList } from "@rainbow-me/rainbowkit"
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
Config,
|
|
4
|
+
createConfig,
|
|
5
|
+
CreateConfigParameters,
|
|
6
|
+
http,
|
|
7
|
+
webSocket,
|
|
8
|
+
} from "wagmi"
|
|
9
|
+
import { walletConnectWallet } from "@rainbow-me/rainbowkit/wallets"
|
|
10
|
+
import { CHAIN_ID, mezoMainnet, mezoTestnet, RPC_BY_NETWORK } from "./constants"
|
|
5
11
|
import { getOKXWallet, getUnisatWallet, getXverseWallet } from "./wallet"
|
|
6
12
|
|
|
7
13
|
type WagmiConfigParameters = Omit<
|
|
@@ -10,6 +16,7 @@ type WagmiConfigParameters = Omit<
|
|
|
10
16
|
>
|
|
11
17
|
type GetDefaultConfigParameters = WagmiConfigParameters & {
|
|
12
18
|
appName: string
|
|
19
|
+
mezoNetwork?: "mainnet" | "testnet"
|
|
13
20
|
appDescription?: string
|
|
14
21
|
appUrl?: string
|
|
15
22
|
appIcon?: string
|
|
@@ -20,7 +27,8 @@ type GetDefaultConfigParameters = WagmiConfigParameters & {
|
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
const transports = {
|
|
23
|
-
[CHAIN_ID.
|
|
30
|
+
[CHAIN_ID.mainnet]: http(RPC_BY_NETWORK.mainnet.http),
|
|
31
|
+
[CHAIN_ID.testnet]: http(RPC_BY_NETWORK.testnet.http),
|
|
24
32
|
} as Pick<CreateConfigParameters, "transports">
|
|
25
33
|
|
|
26
34
|
export const defaultConfig: Required<
|
|
@@ -34,39 +42,99 @@ export const defaultConfig: Required<
|
|
|
34
42
|
> = {
|
|
35
43
|
transports,
|
|
36
44
|
walletConnectProjectId: "",
|
|
37
|
-
chains: [
|
|
45
|
+
chains: [mezoMainnet, mezoTestnet],
|
|
38
46
|
multiInjectedProviderDiscovery: true,
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
const
|
|
42
|
-
rpcUrl: RPC_BY_NETWORK.testnet,
|
|
49
|
+
const bitcoinWalletTestnetConfig = {
|
|
50
|
+
rpcUrl: RPC_BY_NETWORK.testnet.http,
|
|
43
51
|
chainId: CHAIN_ID.testnet,
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
const bitcoinWalletMainnetConfig = {
|
|
55
|
+
rpcUrl: RPC_BY_NETWORK.mainnet.http,
|
|
56
|
+
chainId: CHAIN_ID.mainnet,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const unisatWalletMezoTestnet = getUnisatWallet(
|
|
60
|
+
bitcoinWalletTestnetConfig,
|
|
61
|
+
)
|
|
62
|
+
export const okxWalletMezoTestnet = getOKXWallet(bitcoinWalletTestnetConfig)
|
|
63
|
+
export const xverseWalletMezoTestnet = getXverseWallet(
|
|
64
|
+
bitcoinWalletTestnetConfig,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
export const unisatWalletMezoMainnet = getUnisatWallet(
|
|
68
|
+
bitcoinWalletMainnetConfig,
|
|
69
|
+
)
|
|
70
|
+
export const okxWalletMezoMainnet = getOKXWallet(bitcoinWalletMainnetConfig)
|
|
71
|
+
export const xverseWalletMezoMainnet = getXverseWallet(
|
|
72
|
+
bitcoinWalletMainnetConfig,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
export const preconfiguredWalletConnectWallet = (projectId: string) =>
|
|
76
|
+
walletConnectWallet({
|
|
77
|
+
projectId,
|
|
78
|
+
options: {
|
|
79
|
+
qrModalOptions: {
|
|
80
|
+
enableExplorer: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
})
|
|
49
84
|
|
|
50
|
-
export function getDefaultWallets(
|
|
85
|
+
export function getDefaultWallets(
|
|
86
|
+
network: "mainnet" | "testnet" = "mainnet",
|
|
87
|
+
): WalletList {
|
|
51
88
|
return [
|
|
52
89
|
{
|
|
53
90
|
groupName: "Bitcoin",
|
|
54
|
-
wallets:
|
|
91
|
+
wallets:
|
|
92
|
+
network === "mainnet"
|
|
93
|
+
? [
|
|
94
|
+
unisatWalletMezoMainnet,
|
|
95
|
+
okxWalletMezoMainnet,
|
|
96
|
+
xverseWalletMezoMainnet,
|
|
97
|
+
]
|
|
98
|
+
: [
|
|
99
|
+
unisatWalletMezoTestnet,
|
|
100
|
+
okxWalletMezoTestnet,
|
|
101
|
+
xverseWalletMezoTestnet,
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
groupName: "Ethereum",
|
|
106
|
+
wallets: [({ projectId }) => preconfiguredWalletConnectWallet(projectId)],
|
|
55
107
|
},
|
|
56
108
|
]
|
|
57
109
|
}
|
|
58
110
|
|
|
59
|
-
export function getConfig({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
111
|
+
export function getConfig(config: GetDefaultConfigParameters): Config {
|
|
112
|
+
const {
|
|
113
|
+
appName,
|
|
114
|
+
mezoNetwork = "mainnet",
|
|
115
|
+
walletConnectProjectId = defaultConfig.walletConnectProjectId,
|
|
116
|
+
...restParameters
|
|
117
|
+
} = config
|
|
118
|
+
|
|
119
|
+
const wallets = config.bitcoinWallets ?? [...getDefaultWallets(mezoNetwork)]
|
|
120
|
+
|
|
65
121
|
return getDefaultConfig({
|
|
66
122
|
...defaultConfig,
|
|
67
123
|
appName,
|
|
68
|
-
wallets
|
|
69
|
-
projectId: walletConnectProjectId
|
|
124
|
+
wallets,
|
|
125
|
+
projectId: walletConnectProjectId,
|
|
70
126
|
...restParameters,
|
|
71
127
|
})
|
|
72
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* This config is only used to listen for Transfer events on mezo chain.
|
|
132
|
+
* Should not be exported in index for public use.
|
|
133
|
+
*/
|
|
134
|
+
export const simpleWssMezoConfig = createConfig({
|
|
135
|
+
chains: [mezoMainnet, mezoTestnet],
|
|
136
|
+
transports: {
|
|
137
|
+
[mezoMainnet.id]: webSocket(RPC_BY_NETWORK.mainnet.webSocket),
|
|
138
|
+
[mezoTestnet.id]: webSocket(RPC_BY_NETWORK.testnet.webSocket),
|
|
139
|
+
},
|
|
140
|
+
})
|
package/src/constants.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mezoMainnet, mezoTestnet } from "@mezo-org/orangekit"
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { mezoMainnet, mezoTestnet } from "@mezo-org/orangekit"
|
|
4
4
|
|
|
5
5
|
export const CHAIN_ID = {
|
|
6
|
-
testnet:
|
|
6
|
+
testnet: mezoTestnet.id,
|
|
7
|
+
mainnet: mezoMainnet.id,
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const RPC_BY_NETWORK = {
|
|
10
|
-
|
|
11
|
+
mainnet: {
|
|
12
|
+
http: mezoMainnet.rpcUrls.default.http[0],
|
|
13
|
+
webSocket: mezoMainnet.rpcUrls.default.webSocket?.[0],
|
|
14
|
+
},
|
|
15
|
+
testnet: {
|
|
16
|
+
http: mezoTestnet.rpcUrls.default.http[0],
|
|
17
|
+
webSocket: mezoTestnet.rpcUrls.default.webSocket?.[0],
|
|
18
|
+
},
|
|
11
19
|
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -6,13 +6,20 @@ export {
|
|
|
6
6
|
useSubscribeToConnectorEvent,
|
|
7
7
|
useSubscribeToWalletNetworkDoesNotMatchProviderChain,
|
|
8
8
|
} from "@mezo-org/orangekit"
|
|
9
|
+
export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData"
|
|
9
10
|
export * from "./useGetAccountByAddress"
|
|
10
11
|
export * from "./useGetAccountByMezoId"
|
|
11
12
|
export * from "./useGetCurrentAccount"
|
|
12
13
|
export * from "./useGetSession"
|
|
13
14
|
export * from "./useLinkAccount"
|
|
15
|
+
export * from "./useRefreshPassport"
|
|
14
16
|
export * from "./useSignInWithDiscord"
|
|
15
17
|
export * from "./useSignInWithWallet"
|
|
16
18
|
export * from "./useSignOut"
|
|
17
19
|
export * from "./useSignUpWithWallet"
|
|
20
|
+
export {
|
|
21
|
+
useInvalidateTokensBalances,
|
|
22
|
+
useResetTokensBalances,
|
|
23
|
+
} from "./useTokensBalances"
|
|
18
24
|
export * from "./useUpdateMezoId"
|
|
25
|
+
export * from "./useValidateMezoId"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query"
|
|
2
|
+
import { useConfig } from "wagmi"
|
|
3
|
+
import { readContract } from "wagmi/actions"
|
|
4
|
+
import { parseUnits } from "viem"
|
|
5
|
+
import { ONE_SECOND_MS } from "../utils/time"
|
|
6
|
+
import { usePortalApiClient } from "./usePortalApiClient"
|
|
7
|
+
import { priceOracleContract } from "../lib/contracts"
|
|
8
|
+
import { CHAIN_ID } from "../constants"
|
|
9
|
+
import { usePassportContext } from "./usePassportContext"
|
|
10
|
+
import { normalizePrecision } from "../utils/numbers"
|
|
11
|
+
|
|
12
|
+
export const CONVERSION_RATE_DECIMALS = 18
|
|
13
|
+
|
|
14
|
+
// If the oracle has not been updated in at least 60 seconds, it is stale.
|
|
15
|
+
const MAX_PRICE_DELAY = 60 * ONE_SECOND_MS
|
|
16
|
+
|
|
17
|
+
export const QUERY_KEY = "passport.assetsConversionRates"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Hook to fetch assets conversion rates.
|
|
21
|
+
* @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
|
|
22
|
+
* @returns {}.data.{}.price - The latest asset price.
|
|
23
|
+
* @returns {}.data.{}.digits - The latest asset price digits.
|
|
24
|
+
* @returns {}.isPending - Whether the request is pending.
|
|
25
|
+
* @returns {}.isError - Whether there was an error fetching the price.
|
|
26
|
+
*/
|
|
27
|
+
export function useAssetsConversionRates() {
|
|
28
|
+
const portalApiClient = usePortalApiClient()
|
|
29
|
+
const { environment = "mainnet" } = usePassportContext()
|
|
30
|
+
const config = useConfig()
|
|
31
|
+
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: [QUERY_KEY],
|
|
34
|
+
queryFn: async () =>
|
|
35
|
+
Promise.all([
|
|
36
|
+
portalApiClient.getPortalStatistics(),
|
|
37
|
+
readContract(config, {
|
|
38
|
+
...priceOracleContract,
|
|
39
|
+
functionName: "latestRoundData",
|
|
40
|
+
chainId: CHAIN_ID[environment],
|
|
41
|
+
}),
|
|
42
|
+
]),
|
|
43
|
+
select: ([portalStatistics, btcPriceData]) => {
|
|
44
|
+
const tTokenConversionRate = portalStatistics.currentUsdPerTToken
|
|
45
|
+
const [, btcConversionRate] = btcPriceData
|
|
46
|
+
|
|
47
|
+
const tPrice = parseUnits(tTokenConversionRate, CONVERSION_RATE_DECIMALS)
|
|
48
|
+
const btcPrice = normalizePrecision(
|
|
49
|
+
btcConversionRate,
|
|
50
|
+
CONVERSION_RATE_DECIMALS,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
rates: {
|
|
55
|
+
mT: tPrice,
|
|
56
|
+
BTC: btcPrice,
|
|
57
|
+
},
|
|
58
|
+
decimals: CONVERSION_RATE_DECIMALS,
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
refetchInterval: ({ state }) => {
|
|
62
|
+
if (!state.data) return MAX_PRICE_DELAY
|
|
63
|
+
|
|
64
|
+
const [, btcPriceData] = state.data
|
|
65
|
+
const [, , , updatedAt] = btcPriceData
|
|
66
|
+
|
|
67
|
+
if (!updatedAt) return MAX_PRICE_DELAY
|
|
68
|
+
|
|
69
|
+
const age = Date.now() - Number(updatedAt) * 1000
|
|
70
|
+
|
|
71
|
+
return age > MAX_PRICE_DELAY
|
|
72
|
+
? // If the data is stale, we want to refetch as soon as possible, but
|
|
73
|
+
// not faster than once per second, to avoid excessive requests.
|
|
74
|
+
// Math.max ensures the interval is at least 1 second.
|
|
75
|
+
Math.max(ONE_SECOND_MS, MAX_PRICE_DELAY - age)
|
|
76
|
+
: MAX_PRICE_DELAY - age
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { useSignMessage } from "wagmi"
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DefaultError,
|
|
4
|
+
MutationOptions,
|
|
5
|
+
useMutation,
|
|
6
|
+
} from "@tanstack/react-query"
|
|
3
7
|
import { useCreateAccount } from "./useCreateAccount"
|
|
4
8
|
import { useCreateSession } from "./useCreateSession"
|
|
5
9
|
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce"
|
|
6
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
createSignInWithWalletMessage,
|
|
12
|
+
verifyDomainInSignInWithWalletMessage,
|
|
13
|
+
} from "../utils/siww"
|
|
7
14
|
import { useGetAccountByAddress } from "./useGetAccountByAddress"
|
|
8
15
|
import type { Session } from "../api"
|
|
9
16
|
import useWalletAccount from "./useWalletAccount"
|
|
@@ -11,40 +18,49 @@ import useWalletAccount from "./useWalletAccount"
|
|
|
11
18
|
function useAuthenticateWithWallet(
|
|
12
19
|
shouldCreateAccount = false,
|
|
13
20
|
mutationOptions: Omit<
|
|
14
|
-
MutationOptions<Session>,
|
|
21
|
+
MutationOptions<Session, DefaultError, number | void>,
|
|
15
22
|
"mutationFn" | "mutationKey"
|
|
16
23
|
> = {},
|
|
17
24
|
) {
|
|
18
|
-
const
|
|
25
|
+
const walletAccount = useWalletAccount()
|
|
19
26
|
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce()
|
|
20
27
|
const { createSessionAsync } = useCreateSession()
|
|
21
28
|
const { createAccountAsync } = useCreateAccount()
|
|
22
29
|
const { signMessageAsync } = useSignMessage()
|
|
23
30
|
|
|
24
|
-
const { refetch: getAccountByAddress } = useGetAccountByAddress(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(
|
|
32
|
+
walletAccount.walletAddress,
|
|
33
|
+
{
|
|
34
|
+
enabled: false,
|
|
35
|
+
retry: false,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
28
38
|
|
|
29
39
|
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
30
|
-
mutationFn: async () => {
|
|
31
|
-
if (!
|
|
40
|
+
mutationFn: async (chainId?: number | void) => {
|
|
41
|
+
if (!walletAccount.walletAddress) {
|
|
32
42
|
throw new Error("Sign in error: Wallet not connected!")
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
const nonce = await ensureNoSessionAndFetchNonce()
|
|
36
46
|
|
|
37
47
|
const messageResult = createSignInWithWalletMessage(
|
|
38
|
-
|
|
48
|
+
walletAccount.walletAddress,
|
|
39
49
|
nonce,
|
|
40
|
-
networkFamily
|
|
41
|
-
chainId,
|
|
50
|
+
walletAccount.networkFamily!,
|
|
51
|
+
chainId ?? walletAccount.chainId,
|
|
42
52
|
)
|
|
43
53
|
const signatureResult = await signMessageAsync({
|
|
44
54
|
message: messageResult,
|
|
45
|
-
connector,
|
|
55
|
+
connector: walletAccount.connector,
|
|
46
56
|
})
|
|
47
57
|
|
|
58
|
+
await verifyDomainInSignInWithWalletMessage(
|
|
59
|
+
messageResult,
|
|
60
|
+
signatureResult,
|
|
61
|
+
nonce,
|
|
62
|
+
)
|
|
63
|
+
|
|
48
64
|
if (shouldCreateAccount) {
|
|
49
65
|
const getAccountByAddressResult = await getAccountByAddress()
|
|
50
66
|
|