@mezo-org/passport 0.4.0-dev.5 → 0.4.0-dev.50
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 +36 -59
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +21 -49
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +24 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +54 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/endpoint-error.d.ts +4 -0
- package/dist/src/api/endpoint-error.d.ts.map +1 -0
- package/dist/src/api/endpoint-error.js +6 -0
- package/dist/src/api/endpoint-error.js.map +1 -0
- package/dist/src/api/fetch-error copy.d.ts +5 -0
- package/dist/src/api/fetch-error copy.d.ts.map +1 -0
- package/dist/src/api/fetch-error copy.js +8 -0
- package/dist/src/api/fetch-error copy.js.map +1 -0
- package/dist/src/api/fetch-error.d.ts +5 -0
- package/dist/src/api/fetch-error.d.ts.map +1 -0
- package/dist/src/api/fetch-error.js +8 -0
- package/dist/src/api/fetch-error.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/portal.d.ts +26 -0
- package/dist/src/api/portal.d.ts.map +1 -0
- package/dist/src/api/portal.js +23 -0
- package/dist/src/api/portal.js.map +1 -0
- package/dist/src/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +8 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +39 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +23 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +27 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +27 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +68 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts +13 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +34 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +7 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +34 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +7 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +53 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +7 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +48 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +15 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +9 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +48 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +23 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +57 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +64 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +44 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.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/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/config.d.ts +17 -5
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +51 -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/constants.d.ts +1 -0
- package/dist/src/hooks/constants.d.ts.map +1 -1
- package/dist/src/hooks/constants.js +1 -0
- package/dist/src/hooks/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +3 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +3 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +23 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +85 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
- package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +12 -102
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +28 -17
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBitcoinPriceConversion copy.d.ts +2 -0
- package/dist/src/hooks/useBitcoinPriceConversion copy.d.ts.map +1 -0
- package/dist/src/hooks/useBitcoinPriceConversion copy.js +43 -0
- package/dist/src/hooks/useBitcoinPriceConversion copy.js.map +1 -0
- package/dist/src/hooks/useBitcoinPriceConversion.d.ts +103 -0
- package/dist/src/hooks/useBitcoinPriceConversion.d.ts.map +1 -0
- package/dist/src/hooks/useBitcoinPriceConversion.js +50 -0
- package/dist/src/hooks/useBitcoinPriceConversion.js.map +1 -0
- package/dist/src/hooks/useBitcoinPriceFeed.d.ts +15 -0
- package/dist/src/hooks/useBitcoinPriceFeed.d.ts.map +1 -0
- package/dist/src/hooks/useBitcoinPriceFeed.js +67 -0
- package/dist/src/hooks/useBitcoinPriceFeed.js.map +1 -0
- package/dist/src/hooks/useBorrowData.d.ts +60 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +122 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts +23 -173
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +7 -4
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useCreateSession.d.ts +12 -101
- package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
- package/dist/src/hooks/useCreateSession.js +10 -8
- package/dist/src/hooks/useCreateSession.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +47 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +99 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +25 -3
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useGetSession.d.ts +1 -1
- package/dist/src/hooks/useGetSession.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +15 -175
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +7 -4
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
- package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
- package/dist/src/hooks/usePortalApiClient.js +6 -0
- package/dist/src/hooks/usePortalApiClient.js.map +1 -0
- 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/useSignInWithDiscord.d.ts +12 -100
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithDiscord.js +6 -3
- package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +2 -2
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignOut.d.ts +12 -28
- package/dist/src/hooks/useSignOut.d.ts.map +1 -1
- package/dist/src/hooks/useSignOut.js +7 -4
- package/dist/src/hooks/useSignOut.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +12 -100
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.js +2 -2
- package/dist/src/hooks/useSignUpWithWallet.js.map +1 -1
- package/dist/src/hooks/useTokensBalances.d.ts +74 -0
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
- package/dist/src/hooks/useTokensBalances.js +140 -0
- package/dist/src/hooks/useTokensBalances.js.map +1 -0
- package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.js +7 -4
- package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +13 -0
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
- package/dist/src/hooks/useWalletAccount.js +29 -0
- package/dist/src/hooks/useWalletAccount.js.map +1 -0
- 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 +58 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- package/dist/src/lib/contracts/price-oracle.d.ts +43 -0
- package/dist/src/lib/contracts/price-oracle.d.ts.map +1 -0
- package/dist/src/lib/contracts/price-oracle.js +52 -0
- package/dist/src/lib/contracts/price-oracle.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 +10 -13
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +11 -20
- 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 +15 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +37 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +2 -0
- package/dist/src/utils/address.test.d.ts.map +1 -0
- package/dist/src/utils/address.test.js +40 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/cryptoAssets.d.ts +44 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +132 -0
- package/dist/src/utils/cryptoAssets.js.map +1 -0
- package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
- package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.test.js +67 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +14 -0
- package/dist/src/utils/currency.d.ts.map +1 -0
- package/dist/src/utils/currency.js +27 -0
- package/dist/src/utils/currency.js.map +1 -0
- package/dist/src/utils/currency.test.d.ts +2 -0
- package/dist/src/utils/currency.test.d.ts.map +1 -0
- package/dist/src/utils/currency.test.js +34 -0
- package/dist/src/utils/currency.test.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +58 -0
- package/dist/src/utils/numbers.d.ts.map +1 -0
- package/dist/src/utils/numbers.js +132 -0
- package/dist/src/utils/numbers.js.map +1 -0
- package/dist/src/utils/numbers.test.d.ts +2 -0
- package/dist/src/utils/numbers.test.d.ts.map +1 -0
- package/dist/src/utils/numbers.test.js +170 -0
- package/dist/src/utils/numbers.test.js.map +1 -0
- package/package.json +14 -8
- package/src/api/auth.ts +73 -128
- package/src/api/client.ts +87 -0
- package/src/api/fetch-error.ts +8 -0
- package/src/api/index.ts +2 -0
- package/src/api/portal.ts +53 -0
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +76 -0
- package/src/components/Dropdown/Content.tsx +98 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
- package/src/components/Dropdown/Dropdown.tsx +148 -0
- package/src/components/Dropdown/ListingItem.tsx +80 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +75 -0
- package/src/components/Dropdown/README.md +41 -0
- package/src/components/Dropdown/Receive/Receive.tsx +119 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +101 -0
- package/src/components/Dropdown/Root/AccountAssetItem.tsx +26 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +30 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +68 -0
- package/src/components/Dropdown/Root/Root.tsx +147 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +128 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +91 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/config.ts +77 -20
- package/src/constants.ts +12 -4
- package/src/hooks/constants.ts +1 -0
- package/src/hooks/index.ts +6 -1
- package/src/hooks/useAssetsConversionRates.ts +92 -0
- package/src/hooks/useAuthenticateWithWallet.ts +44 -23
- package/src/hooks/useBorrowData.ts +143 -0
- package/src/hooks/useCreateAccount.ts +19 -5
- package/src/hooks/useCreateSession.ts +22 -9
- package/src/hooks/useDropdownData.ts +149 -0
- package/src/hooks/useGetAccountByAddress.ts +2 -2
- package/src/hooks/useGetAccountByMezoId.ts +2 -2
- package/src/hooks/useGetCurrentAccount.ts +46 -6
- package/src/hooks/useGetSession.ts +1 -1
- package/src/hooks/useLinkAccount.ts +18 -5
- package/src/hooks/usePortalApiClient.ts +6 -0
- package/src/hooks/useRefreshPassport.ts +56 -0
- package/src/hooks/useSignInWithDiscord.ts +14 -5
- package/src/hooks/useSignInWithWallet.ts +9 -2
- package/src/hooks/useSignOut.ts +18 -4
- package/src/hooks/useSignUpWithWallet.ts +9 -2
- package/src/hooks/useTokensBalances.ts +187 -0
- package/src/hooks/useUpdateMezoId.ts +19 -4
- package/src/hooks/useWalletAccount.ts +55 -0
- package/src/hooks/useWatchTransferEvents.ts +74 -0
- package/src/index.ts +12 -1
- package/src/lib/contracts/index.ts +90 -0
- package/src/lib/contracts/priceOracle.ts +53 -0
- package/src/provider.ts +30 -37
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +48 -0
- package/src/utils/address.ts +45 -0
- package/src/utils/cryptoAssets.test.ts +79 -0
- package/src/utils/cryptoAssets.ts +173 -0
- package/src/utils/currency.test.ts +38 -0
- package/src/utils/currency.ts +32 -0
- package/src/utils/numbers.test.ts +220 -0
- package/src/utils/numbers.ts +188 -0
package/src/api/auth.ts
CHANGED
|
@@ -1,151 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
queryParams?: Record<string, string | undefined>
|
|
4
|
-
}
|
|
5
|
-
type PassportIdentityProvider = "wallet" | "discord" | "email"
|
|
1
|
+
import { ApiClient } from "./client"
|
|
2
|
+
import { FetchError } from "./fetch-error"
|
|
6
3
|
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
type AuthProvider = "discord"
|
|
5
|
+
|
|
6
|
+
export type LinkedWalletAccount = {
|
|
7
|
+
type: "wallet"
|
|
8
|
+
btcAddress?: string
|
|
10
9
|
evmAddress: string
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
type
|
|
12
|
+
export type LinkedProviderAccount = {
|
|
13
|
+
type: AuthProvider
|
|
14
|
+
name: string
|
|
14
15
|
id: string
|
|
15
|
-
|
|
16
|
-
provider: PassportIdentityProvider
|
|
17
|
-
providers: PassportIdentityProvider[]
|
|
18
|
-
}
|
|
19
|
-
user_metadata: AccountPublicData
|
|
16
|
+
avatarUrl: string
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
export type LinkedAccount =
|
|
25
|
-
| {
|
|
26
|
-
type: "wallet"
|
|
27
|
-
btcAddress?: string
|
|
28
|
-
evmAddress: string
|
|
29
|
-
}
|
|
30
|
-
| {
|
|
31
|
-
type: AuthProvider
|
|
32
|
-
name: string
|
|
33
|
-
id: string
|
|
34
|
-
avatarUrl: string
|
|
35
|
-
}
|
|
19
|
+
export type LinkedAccount = LinkedWalletAccount | LinkedProviderAccount
|
|
36
20
|
|
|
37
21
|
type Account = {
|
|
38
22
|
mezoId: string
|
|
39
23
|
hasModifiedMezoId: boolean
|
|
40
24
|
linkedAccounts: LinkedAccount[]
|
|
41
|
-
authUser: AuthUser
|
|
42
25
|
}
|
|
43
26
|
|
|
44
|
-
type Session = {
|
|
27
|
+
export type Session = {
|
|
45
28
|
expiresIn: number
|
|
46
29
|
expiresAt: number
|
|
47
30
|
sessionLinks: {
|
|
48
31
|
_links: {
|
|
49
|
-
account:
|
|
32
|
+
account: string
|
|
50
33
|
}
|
|
51
34
|
}
|
|
52
35
|
}
|
|
53
36
|
|
|
54
|
-
type AuthenticationProviderRedirectResponse = {
|
|
37
|
+
export type AuthenticationProviderRedirectResponse = {
|
|
55
38
|
redirectTo: string
|
|
56
39
|
}
|
|
57
40
|
|
|
58
|
-
type
|
|
59
|
-
type: "wallet"
|
|
41
|
+
type SignatureData = {
|
|
60
42
|
message: string
|
|
61
43
|
signature: string
|
|
62
44
|
}
|
|
63
45
|
|
|
46
|
+
// Request and Response types
|
|
47
|
+
export type GetSessionResponse = Session | { nonce: string }
|
|
48
|
+
|
|
64
49
|
export type CreateSessionRequest =
|
|
65
|
-
|
|
|
50
|
+
| ({ type: "wallet" } & SignatureData)
|
|
66
51
|
| { type: "discord" }
|
|
52
|
+
export type CreateSessionResponse =
|
|
53
|
+
| Session
|
|
54
|
+
| AuthenticationProviderRedirectResponse
|
|
67
55
|
|
|
68
|
-
export type
|
|
69
|
-
|
|
70
|
-
export type CreateAccountRequest = WalletAccountCredentials
|
|
71
|
-
|
|
72
|
-
export type GetSessionResponse = Session | { nonce: string }
|
|
56
|
+
export type DeleteSessionResponse = { message: string }
|
|
73
57
|
|
|
74
58
|
export type GetCurrentAccountResponse = Partial<Account> | null
|
|
75
59
|
|
|
76
60
|
export type GetAccountByMezoIdOrAddressResponse = {
|
|
77
61
|
mezoId?: string
|
|
78
|
-
linkedAccounts?: LinkedAccount[]
|
|
62
|
+
linkedAccounts?: Extract<LinkedAccount, { type: "wallet" }>[]
|
|
79
63
|
}
|
|
80
64
|
|
|
81
|
-
export
|
|
65
|
+
export type LinkAccountRequest = CreateSessionRequest
|
|
66
|
+
export type LinkAccountResponse =
|
|
67
|
+
| Account
|
|
68
|
+
| AuthenticationProviderRedirectResponse
|
|
69
|
+
|
|
70
|
+
export type CreateAccountRequest = { type: "wallet" } & SignatureData
|
|
71
|
+
export type CreateAccountResponse = Account
|
|
72
|
+
|
|
73
|
+
export type UpdateMezoIdResponse = Account
|
|
74
|
+
|
|
75
|
+
export const AUTH_API_ENDPOINTS_BY_ENV = {
|
|
82
76
|
mainnet: "https://api.mezo.org",
|
|
83
77
|
testnet: "https://api.test.mezo.org",
|
|
84
78
|
}
|
|
85
79
|
|
|
86
|
-
export class AuthApiClient {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* The request handler for the Passport API. It accepts an API endpoint and
|
|
95
|
-
* request options.
|
|
96
|
-
* @dev Generic type `D` is a type of returned object from the function
|
|
97
|
-
* @dev WARNING: This function hardcodes `credentials: "include"`, meaning
|
|
98
|
-
* cookies and authentication headers will be sent with every request. Ensure
|
|
99
|
-
* this is safe if you plan to use it in other contexts than auth api worker.
|
|
100
|
-
* @param endpoint - The API endpoint to request. Should start with
|
|
101
|
-
* forward slash ("/")
|
|
102
|
-
* @param options - The request options, the `RequestInit` type with
|
|
103
|
-
* additional type-safe properties
|
|
104
|
-
* @returns The promise of the API response
|
|
105
|
-
*/
|
|
106
|
-
protected async handleRequest<D>(
|
|
107
|
-
endpoint: `/${string}`,
|
|
108
|
-
options: RequestHandlerOptions,
|
|
109
|
-
): Promise<D> {
|
|
110
|
-
const {
|
|
111
|
-
method,
|
|
112
|
-
headers,
|
|
113
|
-
body,
|
|
114
|
-
queryParams = {},
|
|
115
|
-
...restOptions
|
|
116
|
-
} = options || {}
|
|
117
|
-
|
|
118
|
-
// If last character in apiUrl is forward slash we are removing it
|
|
119
|
-
const authApiUrlRoute = this.apiUrl.replace(/\/$/, "")
|
|
120
|
-
const url = new URL(`${authApiUrlRoute}${endpoint}`)
|
|
121
|
-
|
|
122
|
-
// Removes falsy values (e.g. null, undefined etc.) from query params and
|
|
123
|
-
// appends remaining ones to the URL
|
|
124
|
-
Object.entries(queryParams)
|
|
125
|
-
.filter(([, value]) => value) // Remove falsy values
|
|
126
|
-
.forEach(([key, value]) => url.searchParams.append(key, value!))
|
|
127
|
-
|
|
128
|
-
const response = await fetch(url, {
|
|
129
|
-
method,
|
|
130
|
-
credentials: "include",
|
|
131
|
-
headers: {
|
|
132
|
-
"Content-Type": "application/json",
|
|
133
|
-
...headers,
|
|
134
|
-
},
|
|
135
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
136
|
-
...restOptions,
|
|
80
|
+
export class AuthApiClient extends ApiClient {
|
|
81
|
+
constructor(
|
|
82
|
+
environment: keyof typeof AUTH_API_ENDPOINTS_BY_ENV = "mainnet",
|
|
83
|
+
apiUrl?: string,
|
|
84
|
+
) {
|
|
85
|
+
super({
|
|
86
|
+
apiUrl: apiUrl ?? AUTH_API_ENDPOINTS_BY_ENV[environment],
|
|
137
87
|
})
|
|
138
|
-
|
|
139
|
-
const data = await response.json()
|
|
140
|
-
|
|
141
|
-
if (!response.ok || data?.error) {
|
|
142
|
-
const error =
|
|
143
|
-
data?.error ||
|
|
144
|
-
`An error occurred when handling API request: ${JSON.stringify(data)}`
|
|
145
|
-
throw new Error(`Error [${response.status}]: ${error}`)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return data as D
|
|
149
88
|
}
|
|
150
89
|
|
|
151
90
|
async getSession(code?: string) {
|
|
@@ -158,21 +97,16 @@ export class AuthApiClient {
|
|
|
158
97
|
}
|
|
159
98
|
|
|
160
99
|
async createSession(createSessionRequest: CreateSessionRequest) {
|
|
161
|
-
const data = await this.handleRequest<
|
|
162
|
-
"
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
body: createSessionRequest,
|
|
166
|
-
},
|
|
167
|
-
)
|
|
100
|
+
const data = await this.handleRequest<CreateSessionResponse>("/session", {
|
|
101
|
+
method: "POST",
|
|
102
|
+
body: createSessionRequest,
|
|
103
|
+
})
|
|
168
104
|
|
|
169
105
|
return data
|
|
170
106
|
}
|
|
171
107
|
|
|
172
108
|
async deleteSession() {
|
|
173
|
-
const data = await this.handleRequest<{
|
|
174
|
-
message: string
|
|
175
|
-
}>("/session", {
|
|
109
|
+
const data = await this.handleRequest<DeleteSessionResponse>("/session", {
|
|
176
110
|
method: "DELETE",
|
|
177
111
|
})
|
|
178
112
|
|
|
@@ -191,29 +125,40 @@ export class AuthApiClient {
|
|
|
191
125
|
}
|
|
192
126
|
|
|
193
127
|
async getAccountByMezoIdOrAddress(mezoIdOrAddress: string) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
128
|
+
let data
|
|
129
|
+
try {
|
|
130
|
+
data = await this.handleRequest<GetAccountByMezoIdOrAddressResponse>(
|
|
131
|
+
`/accounts/${mezoIdOrAddress}`,
|
|
132
|
+
{
|
|
133
|
+
method: "GET",
|
|
134
|
+
},
|
|
135
|
+
)
|
|
136
|
+
} catch (error) {
|
|
137
|
+
// Return null if account is not found instead of throwing an error
|
|
138
|
+
if (error instanceof FetchError && error.status === 404) {
|
|
139
|
+
data = null
|
|
140
|
+
} else {
|
|
141
|
+
throw error
|
|
142
|
+
}
|
|
143
|
+
}
|
|
200
144
|
|
|
201
145
|
return data
|
|
202
146
|
}
|
|
203
147
|
|
|
204
148
|
async linkAccount(linkAccountRequest: LinkAccountRequest) {
|
|
205
|
-
const data = await this.handleRequest<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
149
|
+
const data = await this.handleRequest<LinkAccountResponse>(
|
|
150
|
+
"/session/account/linked-accounts",
|
|
151
|
+
{
|
|
152
|
+
method: "POST",
|
|
153
|
+
body: linkAccountRequest,
|
|
154
|
+
},
|
|
155
|
+
)
|
|
211
156
|
|
|
212
157
|
return data
|
|
213
158
|
}
|
|
214
159
|
|
|
215
160
|
async createAccount(createAccountRequest: CreateAccountRequest) {
|
|
216
|
-
const data = await this.handleRequest<
|
|
161
|
+
const data = await this.handleRequest<CreateAccountResponse>("/accounts", {
|
|
217
162
|
method: "POST",
|
|
218
163
|
body: createAccountRequest,
|
|
219
164
|
})
|
|
@@ -222,7 +167,7 @@ export class AuthApiClient {
|
|
|
222
167
|
}
|
|
223
168
|
|
|
224
169
|
async updateMezoId(newMezoId: string) {
|
|
225
|
-
const data = await this.handleRequest<
|
|
170
|
+
const data = await this.handleRequest<UpdateMezoIdResponse>(
|
|
226
171
|
"/session/account",
|
|
227
172
|
{
|
|
228
173
|
method: "PATCH",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { FetchError } from "./fetch-error"
|
|
2
|
+
|
|
3
|
+
type RequestHandlerOptions = Omit<RequestInit, "credentials" | "body"> & {
|
|
4
|
+
body?: Record<string, unknown>
|
|
5
|
+
queryParams?: Record<string, string | undefined>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ENDS_WITH_VERSIONING_REGEX = /\/v\d+(?=\/|$)/
|
|
9
|
+
const TRAILING_SLASH_REGEX = /\/$/
|
|
10
|
+
|
|
11
|
+
export abstract class ApiClient {
|
|
12
|
+
private apiUrl: string
|
|
13
|
+
|
|
14
|
+
constructor(opts: { apiUrl: string; removeVersioning?: boolean }) {
|
|
15
|
+
const { apiUrl, removeVersioning = false } = opts
|
|
16
|
+
|
|
17
|
+
if (removeVersioning) {
|
|
18
|
+
this.apiUrl = apiUrl.replace(ENDS_WITH_VERSIONING_REGEX, "")
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
this.apiUrl = apiUrl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The request handler for the Passport API. It accepts an API endpoint and
|
|
26
|
+
* request options.
|
|
27
|
+
* @dev Generic type `D` is a type of returned object from the function
|
|
28
|
+
* @dev WARNING: This function hardcodes `credentials: "include"`, meaning
|
|
29
|
+
* cookies and authentication headers will be sent with every request. Ensure
|
|
30
|
+
* this is safe if you plan to use it in other contexts than auth api worker.
|
|
31
|
+
* @param endpoint - The API endpoint to request. Should start with
|
|
32
|
+
* forward slash ("/")
|
|
33
|
+
* @param options - The request options, the `RequestInit` type with
|
|
34
|
+
* additional type-safe properties
|
|
35
|
+
* @returns The promise of the API response
|
|
36
|
+
*/
|
|
37
|
+
protected async handleRequest<D>(
|
|
38
|
+
endpoint: `/${string}`,
|
|
39
|
+
options: RequestHandlerOptions = {},
|
|
40
|
+
): Promise<D> {
|
|
41
|
+
try {
|
|
42
|
+
const { method, body, queryParams = {}, ...restOptions } = options
|
|
43
|
+
|
|
44
|
+
// If last character in apiUrl is forward slash we are removing it
|
|
45
|
+
const authApiUrlRoute = this.apiUrl.replace(TRAILING_SLASH_REGEX, "")
|
|
46
|
+
const url = new URL(`${authApiUrlRoute}${endpoint}`)
|
|
47
|
+
|
|
48
|
+
// Removes falsy values (e.g. null, undefined etc.) from query params and
|
|
49
|
+
// appends remaining ones to the URL
|
|
50
|
+
Object.entries(queryParams)
|
|
51
|
+
.filter(([, value]) => value) // Remove falsy values
|
|
52
|
+
.forEach(([key, value]) => url.searchParams.append(key, value!))
|
|
53
|
+
|
|
54
|
+
const response = await fetch(url, {
|
|
55
|
+
method,
|
|
56
|
+
credentials: "include",
|
|
57
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
58
|
+
...restOptions,
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const data = await response.json()
|
|
62
|
+
|
|
63
|
+
if (!response.ok || data?.error) {
|
|
64
|
+
const error =
|
|
65
|
+
data?.error ||
|
|
66
|
+
`An error occurred when handling API request: ${JSON.stringify(data)}`
|
|
67
|
+
throw new FetchError(
|
|
68
|
+
response.status,
|
|
69
|
+
`Error [${response.status}]: ${error}`,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return data as D
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (error instanceof FetchError) {
|
|
76
|
+
throw error
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const errorMessage =
|
|
80
|
+
error instanceof Error ? error.message : JSON.stringify(error)
|
|
81
|
+
throw new FetchError(
|
|
82
|
+
500,
|
|
83
|
+
`Error [500]: An error occurred when handling API request: ${errorMessage}`,
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ApiClient } from "./client"
|
|
2
|
+
|
|
3
|
+
type PortalStatistics = {
|
|
4
|
+
hodlers: number
|
|
5
|
+
depositedBitcoin: string
|
|
6
|
+
tvl: number
|
|
7
|
+
currentUsdPerBtc: string
|
|
8
|
+
currentUsdPerEth: string
|
|
9
|
+
currentUsdPerTToken: string
|
|
10
|
+
usdPerBtc24hChange: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type PortalMats = {
|
|
14
|
+
totalMats: number
|
|
15
|
+
inactiveMats: number
|
|
16
|
+
matsActivated: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const PORTAL_API_ENDPOINTS_BY_ENV = {
|
|
20
|
+
mainnet: "https://api.mezo.org/api/",
|
|
21
|
+
testnet: "https://api.test.mezo.org/api/",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class PortalApiClient extends ApiClient {
|
|
25
|
+
constructor(
|
|
26
|
+
environment: keyof typeof PORTAL_API_ENDPOINTS_BY_ENV = "mainnet",
|
|
27
|
+
apiUrl?: string,
|
|
28
|
+
) {
|
|
29
|
+
super({
|
|
30
|
+
apiUrl: apiUrl ?? PORTAL_API_ENDPOINTS_BY_ENV[environment],
|
|
31
|
+
removeVersioning: true,
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getPortalStatistics() {
|
|
36
|
+
const data = await this.handleRequest<PortalStatistics>("/v1/statistics", {
|
|
37
|
+
method: "GET",
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
return data
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getPortalMats(address: string) {
|
|
44
|
+
const data = await this.handleRequest<PortalMats>(
|
|
45
|
+
`/v2/account/${address}/mats`,
|
|
46
|
+
{
|
|
47
|
+
method: "GET",
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return data
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Block, BlockProps } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { SVGProps } from "react"
|
|
3
|
+
|
|
4
|
+
function DefaultAvatar(props: SVGProps<SVGSVGElement>) {
|
|
5
|
+
return (
|
|
6
|
+
<svg viewBox="0 0 214 214" fill="none" {...props}>
|
|
7
|
+
<rect y="-0.478027" width="166.379" height="81.7091" fill="#FF004D" />
|
|
8
|
+
<rect x="166" y="-0.478027" width="48" height="82" fill="black" />
|
|
9
|
+
<rect
|
|
10
|
+
x="166.379"
|
|
11
|
+
y="81.231"
|
|
12
|
+
width="24.1044"
|
|
13
|
+
height="132.291"
|
|
14
|
+
fill="#DFFF80"
|
|
15
|
+
/>
|
|
16
|
+
<rect
|
|
17
|
+
x="118.758"
|
|
18
|
+
y="81.231"
|
|
19
|
+
width="24.1044"
|
|
20
|
+
height="132.291"
|
|
21
|
+
fill="#FF5500"
|
|
22
|
+
/>
|
|
23
|
+
<rect
|
|
24
|
+
x="71.1372"
|
|
25
|
+
y="81.231"
|
|
26
|
+
width="24.1044"
|
|
27
|
+
height="132.291"
|
|
28
|
+
fill="#5A59A7"
|
|
29
|
+
/>
|
|
30
|
+
<rect
|
|
31
|
+
x="23.5166"
|
|
32
|
+
y="81.231"
|
|
33
|
+
width="24.1044"
|
|
34
|
+
height="132.291"
|
|
35
|
+
fill="#47B5FF"
|
|
36
|
+
/>
|
|
37
|
+
<rect y="81.231" width="23.5165" height="132.291" fill="#A3C238" />
|
|
38
|
+
<rect
|
|
39
|
+
x="190.483"
|
|
40
|
+
y="81.231"
|
|
41
|
+
width="23.5165"
|
|
42
|
+
height="132.291"
|
|
43
|
+
fill="#6E6E70"
|
|
44
|
+
/>
|
|
45
|
+
<rect
|
|
46
|
+
x="142.863"
|
|
47
|
+
y="81.231"
|
|
48
|
+
width="23.5165"
|
|
49
|
+
height="132.291"
|
|
50
|
+
fill="#0A3C01"
|
|
51
|
+
/>
|
|
52
|
+
<rect
|
|
53
|
+
x="95.2417"
|
|
54
|
+
y="81.231"
|
|
55
|
+
width="23.5165"
|
|
56
|
+
height="132.291"
|
|
57
|
+
fill="#F2A91F"
|
|
58
|
+
/>
|
|
59
|
+
<rect
|
|
60
|
+
x="47.6211"
|
|
61
|
+
y="81.231"
|
|
62
|
+
width="23.5165"
|
|
63
|
+
height="132.291"
|
|
64
|
+
fill="#6B3D01"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function DefaultAvatarComponent(props: BlockProps) {
|
|
71
|
+
return <Block as={DefaultAvatar} {...props} />
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default DefaultAvatarComponent
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Block, Button, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { forwardRef, ReactNode, useMemo } from "react"
|
|
3
|
+
|
|
4
|
+
type ConnectedTriggerProps = Omit<ButtonProps, "children" | "size"> & {
|
|
5
|
+
avatar: ReactNode
|
|
6
|
+
size?: "medium" | "large"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const ConnectedTrigger = forwardRef<HTMLButtonElement, ConnectedTriggerProps>(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
const { onClick, avatar, size = "medium", ...restProps } = props
|
|
12
|
+
|
|
13
|
+
const [, theme] = useStyletron()
|
|
14
|
+
|
|
15
|
+
const avatarSize = useMemo(() => {
|
|
16
|
+
const sizeMap = {
|
|
17
|
+
medium: theme.sizing.scale950,
|
|
18
|
+
large: theme.sizing.scale1400,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return sizeMap[size]
|
|
22
|
+
}, [theme, size])
|
|
23
|
+
|
|
24
|
+
const buttonPadding = useMemo(() => {
|
|
25
|
+
const paddingMap = {
|
|
26
|
+
medium: theme.sizing.scale0,
|
|
27
|
+
large: theme.sizing.scale100,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return paddingMap[size]
|
|
31
|
+
}, [theme, size])
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Button
|
|
35
|
+
overrides={{
|
|
36
|
+
BaseButton: {
|
|
37
|
+
props: { ref, ...restProps },
|
|
38
|
+
style: {
|
|
39
|
+
borderRadius: "100%",
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
padding: buttonPadding,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}}
|
|
45
|
+
onClick={onClick}
|
|
46
|
+
>
|
|
47
|
+
{typeof avatar === "string" ? (
|
|
48
|
+
<Block
|
|
49
|
+
width={avatarSize}
|
|
50
|
+
height={avatarSize}
|
|
51
|
+
as="img"
|
|
52
|
+
src={avatar}
|
|
53
|
+
alt=""
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<Block
|
|
57
|
+
width={avatarSize}
|
|
58
|
+
height={avatarSize}
|
|
59
|
+
overrides={{
|
|
60
|
+
Block: {
|
|
61
|
+
style: {
|
|
62
|
+
borderRadius: "100%",
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{avatar}
|
|
69
|
+
</Block>
|
|
70
|
+
)}
|
|
71
|
+
</Button>
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
export default ConnectedTrigger
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Block, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { useEffect } from "react"
|
|
3
|
+
import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
|
|
4
|
+
import Root from "./Root/Root"
|
|
5
|
+
import Receive from "./Receive/Receive"
|
|
6
|
+
import { DetailedCryptoAsset } from "../../utils/cryptoAssets"
|
|
7
|
+
import TestnetTopBanner from "./TestnetTopBanner"
|
|
8
|
+
|
|
9
|
+
type ContentProps = {
|
|
10
|
+
mezoId: string
|
|
11
|
+
matsBalance: number
|
|
12
|
+
accountAddress: string
|
|
13
|
+
walletAddress: string
|
|
14
|
+
walletType: "bitcoin" | "evm"
|
|
15
|
+
usdTotalBalance: number
|
|
16
|
+
usdTroveDebt: number
|
|
17
|
+
usdCollateral: number
|
|
18
|
+
assets: {
|
|
19
|
+
btc: DetailedCryptoAsset
|
|
20
|
+
musd: DetailedCryptoAsset
|
|
21
|
+
}
|
|
22
|
+
otherAssetsCount: number
|
|
23
|
+
otherAssetsUsdTotal: number
|
|
24
|
+
onSignOut?: () => void
|
|
25
|
+
onOtherAssetsClick?: () => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function Content(props: ContentProps) {
|
|
29
|
+
const {
|
|
30
|
+
mezoId,
|
|
31
|
+
accountAddress,
|
|
32
|
+
walletAddress,
|
|
33
|
+
walletType,
|
|
34
|
+
usdTotalBalance,
|
|
35
|
+
assets,
|
|
36
|
+
matsBalance,
|
|
37
|
+
usdTroveDebt,
|
|
38
|
+
usdCollateral,
|
|
39
|
+
otherAssetsCount,
|
|
40
|
+
otherAssetsUsdTotal,
|
|
41
|
+
onSignOut,
|
|
42
|
+
onOtherAssetsClick,
|
|
43
|
+
} = props
|
|
44
|
+
|
|
45
|
+
const [_, theme] = useStyletron()
|
|
46
|
+
|
|
47
|
+
const currentView = useDropdownStore((state) => state.view)
|
|
48
|
+
const setView = useDropdownStore((state) => state.setView)
|
|
49
|
+
|
|
50
|
+
useEffect(
|
|
51
|
+
() => () => {
|
|
52
|
+
setView(DropdownView.ROOT)
|
|
53
|
+
},
|
|
54
|
+
[setView],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Block
|
|
59
|
+
display="inline-flex"
|
|
60
|
+
flexDirection="column"
|
|
61
|
+
backgroundColor={theme.colors.backgroundPrimary}
|
|
62
|
+
width="100%"
|
|
63
|
+
overrides={{
|
|
64
|
+
Block: {
|
|
65
|
+
style: {
|
|
66
|
+
boxSizing: "border-box",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<TestnetTopBanner />
|
|
72
|
+
|
|
73
|
+
{currentView === DropdownView.ROOT && (
|
|
74
|
+
<Root
|
|
75
|
+
mezoId={mezoId}
|
|
76
|
+
accountAddress={accountAddress}
|
|
77
|
+
walletAddress={walletAddress}
|
|
78
|
+
walletType={walletType}
|
|
79
|
+
usdTotalBalance={usdTotalBalance}
|
|
80
|
+
assets={assets}
|
|
81
|
+
matsBalance={matsBalance}
|
|
82
|
+
usdTroveDebt={usdTroveDebt}
|
|
83
|
+
usdCollateral={usdCollateral}
|
|
84
|
+
otherAssetsCount={otherAssetsCount}
|
|
85
|
+
otherAssetsUsdTotal={otherAssetsUsdTotal}
|
|
86
|
+
onSignOut={onSignOut}
|
|
87
|
+
onOtherAssetsClick={onOtherAssetsClick}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
{currentView === DropdownView.RECEIVE && (
|
|
92
|
+
<Receive address={accountAddress} />
|
|
93
|
+
)}
|
|
94
|
+
</Block>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default Content
|