@mezo-org/passport 0.4.0-dev.5 → 0.4.0-dev.51
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 +22 -48
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +27 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +61 -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 +26 -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 +89 -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 +96 -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
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
|
|
2
|
-
export
|
|
2
|
+
export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData";
|
|
3
3
|
export * from "./useGetAccountByAddress";
|
|
4
4
|
export * from "./useGetAccountByMezoId";
|
|
5
5
|
export * from "./useGetCurrentAccount";
|
|
6
6
|
export * from "./useGetSession";
|
|
7
7
|
export * from "./useLinkAccount";
|
|
8
|
+
export * from "./useRefreshPassport";
|
|
8
9
|
export * from "./useSignInWithDiscord";
|
|
9
10
|
export * from "./useSignInWithWallet";
|
|
10
11
|
export * from "./useSignOut";
|
|
11
12
|
export * from "./useSignUpWithWallet";
|
|
13
|
+
export { useInvalidateTokensBalances, useResetTokensBalances, } from "./useTokensBalances";
|
|
12
14
|
export * from "./useUpdateMezoId";
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
|
|
2
|
-
export
|
|
2
|
+
export { useInvalidateBorrowData, useResetBorrowData } from "./useBorrowData";
|
|
3
3
|
export * from "./useGetAccountByAddress";
|
|
4
4
|
export * from "./useGetAccountByMezoId";
|
|
5
5
|
export * from "./useGetCurrentAccount";
|
|
6
6
|
export * from "./useGetSession";
|
|
7
7
|
export * from "./useLinkAccount";
|
|
8
|
+
export * from "./useRefreshPassport";
|
|
8
9
|
export * from "./useSignInWithDiscord";
|
|
9
10
|
export * from "./useSignInWithWallet";
|
|
10
11
|
export * from "./useSignOut";
|
|
11
12
|
export * from "./useSignUpWithWallet";
|
|
13
|
+
export { useInvalidateTokensBalances, useResetTokensBalances, } from "./useTokensBalances";
|
|
12
14
|
export * from "./useUpdateMezoId";
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to fetch assets conversion rates.
|
|
3
|
+
* @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
|
|
4
|
+
* @returns {}.data.{}.price - The latest asset price.
|
|
5
|
+
* @returns {}.data.{}.digits - The latest asset price digits.
|
|
6
|
+
* @returns {}.isPending - Whether the request is pending.
|
|
7
|
+
* @returns {}.isError - Whether there was an error fetching the price.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useAssetsConversionRates(): {
|
|
10
|
+
data: {
|
|
11
|
+
t: {
|
|
12
|
+
price: bigint;
|
|
13
|
+
decimals: number;
|
|
14
|
+
};
|
|
15
|
+
btc: {
|
|
16
|
+
price: bigint;
|
|
17
|
+
decimals: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
isPending: boolean;
|
|
21
|
+
isError: boolean;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=useAssetsConversionRates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAssetsConversionRates.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAssetsConversionRates.ts"],"names":[],"mappings":"AAiCA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB;;;;;;;;;;;;;EAsDvC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useReadContract } from "wagmi";
|
|
3
|
+
import { ONE_SECOND_MS } from "../utils/time";
|
|
4
|
+
import { QUERY_KEYS } from "./constants";
|
|
5
|
+
import { usePortalApiClient } from "./usePortalApiClient";
|
|
6
|
+
import { priceOracleContract } from "../lib/contracts";
|
|
7
|
+
import { fromFloatToBigInt } from "../utils/numbers";
|
|
8
|
+
import { CHAIN_ID } from "../constants";
|
|
9
|
+
import { usePassportContext } from "./usePassportContext";
|
|
10
|
+
const BTC_TARGET_DIGITS = 18;
|
|
11
|
+
const T_TARGET_DIGITS = 10;
|
|
12
|
+
// If the oracle has not been updated in at least 60 seconds, it is stale.
|
|
13
|
+
const MAX_PRICE_DELAY = 60 * ONE_SECOND_MS;
|
|
14
|
+
/**
|
|
15
|
+
* Scales the price by the number of digits.
|
|
16
|
+
* @dev Oracles returns prices with variable number of digits. This function
|
|
17
|
+
* scales the price to a fixed number of digits ensuring consistency.
|
|
18
|
+
* @param price - The price to scale.
|
|
19
|
+
* @param priceDigits - The number of digits in the price.
|
|
20
|
+
* @returns The scaled price.
|
|
21
|
+
*/
|
|
22
|
+
function scalePriceByDigits(price, priceDigits) {
|
|
23
|
+
if (priceDigits > BTC_TARGET_DIGITS) {
|
|
24
|
+
return price / 10n ** BigInt(priceDigits - BTC_TARGET_DIGITS);
|
|
25
|
+
}
|
|
26
|
+
if (priceDigits < BTC_TARGET_DIGITS) {
|
|
27
|
+
return price * 10n ** BigInt(BTC_TARGET_DIGITS - priceDigits);
|
|
28
|
+
}
|
|
29
|
+
return price;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hook to fetch assets conversion rates.
|
|
33
|
+
* @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
|
|
34
|
+
* @returns {}.data.{}.price - The latest asset price.
|
|
35
|
+
* @returns {}.data.{}.digits - The latest asset price digits.
|
|
36
|
+
* @returns {}.isPending - Whether the request is pending.
|
|
37
|
+
* @returns {}.isError - Whether there was an error fetching the price.
|
|
38
|
+
*/
|
|
39
|
+
export function useAssetsConversionRates() {
|
|
40
|
+
const portalApiClient = usePortalApiClient();
|
|
41
|
+
const { environment = "mainnet" } = usePassportContext();
|
|
42
|
+
const btcPrice = useReadContract({
|
|
43
|
+
...priceOracleContract,
|
|
44
|
+
functionName: "latestRoundData",
|
|
45
|
+
query: {
|
|
46
|
+
refetchInterval: ({ state }) => {
|
|
47
|
+
if (!state.data)
|
|
48
|
+
return MAX_PRICE_DELAY;
|
|
49
|
+
const [, , , updatedAt] = state.data ?? [];
|
|
50
|
+
if (!updatedAt)
|
|
51
|
+
return MAX_PRICE_DELAY;
|
|
52
|
+
const age = Date.now() - Number(updatedAt) * 1000;
|
|
53
|
+
return age > MAX_PRICE_DELAY
|
|
54
|
+
? // If the data is stale, we want to refetch as soon as possible, but
|
|
55
|
+
// not faster than once per second, to avoid excessive requests.
|
|
56
|
+
// Math.max ensures the interval is at least 1 second.
|
|
57
|
+
Math.max(ONE_SECOND_MS, MAX_PRICE_DELAY - age)
|
|
58
|
+
: MAX_PRICE_DELAY - age;
|
|
59
|
+
},
|
|
60
|
+
select: (data) => {
|
|
61
|
+
const [, answer] = data;
|
|
62
|
+
return scalePriceByDigits(answer, BTC_TARGET_DIGITS);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
chainId: CHAIN_ID[environment],
|
|
66
|
+
});
|
|
67
|
+
const tPrice = useQuery({
|
|
68
|
+
queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
|
|
69
|
+
queryFn: () => portalApiClient.getPortalStatistics(),
|
|
70
|
+
select: (data) => fromFloatToBigInt(data.currentUsdPerTToken, T_TARGET_DIGITS),
|
|
71
|
+
refetchInterval: MAX_PRICE_DELAY,
|
|
72
|
+
throwOnError: true,
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
data: {
|
|
76
|
+
t: {
|
|
77
|
+
price: tPrice.data ?? 0n,
|
|
78
|
+
decimals: T_TARGET_DIGITS,
|
|
79
|
+
},
|
|
80
|
+
btc: {
|
|
81
|
+
price: btcPrice.data ?? 0n,
|
|
82
|
+
decimals: BTC_TARGET_DIGITS,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
isPending: tPrice.isPending || btcPrice.isPending,
|
|
86
|
+
isError: tPrice.isError || btcPrice.isError,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=useAssetsConversionRates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAssetsConversionRates.js","sourceRoot":"","sources":["../../../src/hooks/useAssetsConversionRates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAA;AAC1B,0EAA0E;AAC1E,MAAM,eAAe,GAAG,EAAE,GAAG,aAAa,CAAA;AAE1C;;;;;;;GAOG;AACH,SAAS,kBAAkB,CAAC,KAAa,EAAE,WAAmB;IAC5D,IAAI,WAAW,GAAG,iBAAiB,EAAE,CAAC;QACpC,OAAO,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,WAAW,GAAG,iBAAiB,CAAC,CAAA;IAC/D,CAAC;IACD,IAAI,WAAW,GAAG,iBAAiB,EAAE,CAAC;QACpC,OAAO,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,iBAAiB,GAAG,WAAW,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAC5C,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAExD,MAAM,QAAQ,GAAG,eAAe,CAAC;QAC/B,GAAG,mBAAmB;QACtB,YAAY,EAAE,iBAAiB;QAC/B,KAAK,EAAE;YACL,eAAe,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;gBAC7B,IAAI,CAAC,KAAK,CAAC,IAAI;oBAAE,OAAO,eAAe,CAAA;gBAEvC,MAAM,CAAC,EAAE,AAAD,EAAG,AAAD,EAAG,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAA;gBAC1C,IAAI,CAAC,SAAS;oBAAE,OAAO,eAAe,CAAA;gBAEtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;gBAEjD,OAAO,GAAG,GAAG,eAAe;oBAC1B,CAAC,CAAC,oEAAoE;wBACpE,gEAAgE;wBAChE,sDAAsD;wBACtD,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,eAAe,GAAG,GAAG,CAAC;oBAChD,CAAC,CAAC,eAAe,GAAG,GAAG,CAAA;YAC3B,CAAC;YACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACf,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;gBACvB,OAAO,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;YACtD,CAAC;SACF;QACD,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC;KAC/B,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,QAAQ,CAAC;QACtB,QAAQ,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC;QAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,mBAAmB,EAAE;QACpD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC;QAC9D,eAAe,EAAE,eAAe;QAChC,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE;YACJ,CAAC,EAAE;gBACD,KAAK,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;gBACxB,QAAQ,EAAE,eAAe;aAC1B;YACD,GAAG,EAAE;gBACH,KAAK,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;gBAC1B,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS;QACjD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO;KAC5C,CAAA;AACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function useAuthApiClient(): import("../api
|
|
1
|
+
export declare function useAuthApiClient(): import("../api").AuthApiClient;
|
|
2
2
|
//# sourceMappingURL=useAuthApiClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthApiClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthApiClient.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"useAuthApiClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthApiClient.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,mCAG/B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { Session } from "../api";
|
|
3
|
+
declare function useAuthenticateWithWallet(shouldCreateAccount?: boolean, mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
|
|
4
4
|
data: undefined;
|
|
5
5
|
variables: undefined;
|
|
6
6
|
error: null;
|
|
@@ -15,28 +15,8 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
|
|
|
15
15
|
failureReason: Error | null;
|
|
16
16
|
isPaused: boolean;
|
|
17
17
|
submittedAt: number;
|
|
18
|
-
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
19
|
-
|
|
20
|
-
expiresAt: number;
|
|
21
|
-
sessionLinks: {
|
|
22
|
-
_links: {
|
|
23
|
-
account: "/session/account";
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
} | {
|
|
27
|
-
redirectTo: string;
|
|
28
|
-
}, Error, void, unknown>;
|
|
29
|
-
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
30
|
-
expiresIn: number;
|
|
31
|
-
expiresAt: number;
|
|
32
|
-
sessionLinks: {
|
|
33
|
-
_links: {
|
|
34
|
-
account: "/session/account";
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
} | {
|
|
38
|
-
redirectTo: string;
|
|
39
|
-
}, Error, void, unknown>;
|
|
18
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
19
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
40
20
|
} | {
|
|
41
21
|
data: undefined;
|
|
42
22
|
variables: void;
|
|
@@ -52,28 +32,8 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
|
|
|
52
32
|
failureReason: Error | null;
|
|
53
33
|
isPaused: boolean;
|
|
54
34
|
submittedAt: number;
|
|
55
|
-
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
56
|
-
|
|
57
|
-
expiresAt: number;
|
|
58
|
-
sessionLinks: {
|
|
59
|
-
_links: {
|
|
60
|
-
account: "/session/account";
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
} | {
|
|
64
|
-
redirectTo: string;
|
|
65
|
-
}, Error, void, unknown>;
|
|
66
|
-
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
67
|
-
expiresIn: number;
|
|
68
|
-
expiresAt: number;
|
|
69
|
-
sessionLinks: {
|
|
70
|
-
_links: {
|
|
71
|
-
account: "/session/account";
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
} | {
|
|
75
|
-
redirectTo: string;
|
|
76
|
-
}, Error, void, unknown>;
|
|
35
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
36
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
77
37
|
} | {
|
|
78
38
|
data: undefined;
|
|
79
39
|
error: Error;
|
|
@@ -89,40 +49,10 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
|
|
|
89
49
|
failureReason: Error | null;
|
|
90
50
|
isPaused: boolean;
|
|
91
51
|
submittedAt: number;
|
|
92
|
-
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
93
|
-
|
|
94
|
-
expiresAt: number;
|
|
95
|
-
sessionLinks: {
|
|
96
|
-
_links: {
|
|
97
|
-
account: "/session/account";
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
} | {
|
|
101
|
-
redirectTo: string;
|
|
102
|
-
}, Error, void, unknown>;
|
|
103
|
-
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
104
|
-
expiresIn: number;
|
|
105
|
-
expiresAt: number;
|
|
106
|
-
sessionLinks: {
|
|
107
|
-
_links: {
|
|
108
|
-
account: "/session/account";
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
} | {
|
|
112
|
-
redirectTo: string;
|
|
113
|
-
}, Error, void, unknown>;
|
|
52
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
53
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
114
54
|
} | {
|
|
115
|
-
data:
|
|
116
|
-
expiresIn: number;
|
|
117
|
-
expiresAt: number;
|
|
118
|
-
sessionLinks: {
|
|
119
|
-
_links: {
|
|
120
|
-
account: "/session/account";
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
} | {
|
|
124
|
-
redirectTo: string;
|
|
125
|
-
};
|
|
55
|
+
data: Session;
|
|
126
56
|
error: null;
|
|
127
57
|
variables: void;
|
|
128
58
|
isError: false;
|
|
@@ -136,28 +66,8 @@ declare function useAuthenticateWithWallet({ signUp, }?: {
|
|
|
136
66
|
failureReason: Error | null;
|
|
137
67
|
isPaused: boolean;
|
|
138
68
|
submittedAt: number;
|
|
139
|
-
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<
|
|
140
|
-
|
|
141
|
-
expiresAt: number;
|
|
142
|
-
sessionLinks: {
|
|
143
|
-
_links: {
|
|
144
|
-
account: "/session/account";
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
} | {
|
|
148
|
-
redirectTo: string;
|
|
149
|
-
}, Error, void, unknown>;
|
|
150
|
-
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
151
|
-
expiresIn: number;
|
|
152
|
-
expiresAt: number;
|
|
153
|
-
sessionLinks: {
|
|
154
|
-
_links: {
|
|
155
|
-
account: "/session/account";
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
} | {
|
|
159
|
-
redirectTo: string;
|
|
160
|
-
}, Error, void, unknown>;
|
|
69
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
70
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
161
71
|
};
|
|
162
72
|
export { useAuthenticateWithWallet };
|
|
163
73
|
//# sourceMappingURL=useAuthenticateWithWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAA;AAMpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGrC,iBAAS,yBAAyB,CAChC,mBAAmB,UAAQ,EAC3B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoFP;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
|
|
@@ -1,52 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useBitcoinAccount } from "@mezo-org/orangekit";
|
|
1
|
+
import { useSignMessage } from "wagmi";
|
|
3
2
|
import { useMutation } from "@tanstack/react-query";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
3
|
import { useCreateAccount } from "./useCreateAccount";
|
|
6
4
|
import { useCreateSession } from "./useCreateSession";
|
|
7
5
|
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
|
|
8
6
|
import { createSignInWithWalletMessage } from "../utils/siww";
|
|
9
7
|
import { useGetAccountByAddress } from "./useGetAccountByAddress";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const {
|
|
8
|
+
import useWalletAccount from "./useWalletAccount";
|
|
9
|
+
function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
|
|
10
|
+
const { walletAddress, chainId, connector, networkFamily } = useWalletAccount();
|
|
13
11
|
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
14
12
|
const { createSessionAsync } = useCreateSession();
|
|
15
13
|
const { createAccountAsync } = useCreateAccount();
|
|
16
14
|
const { signMessageAsync } = useSignMessage();
|
|
17
|
-
const
|
|
18
|
-
|
|
15
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, {
|
|
16
|
+
enabled: false,
|
|
17
|
+
retry: false,
|
|
18
|
+
});
|
|
19
19
|
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
20
20
|
mutationFn: async () => {
|
|
21
|
-
if (!
|
|
21
|
+
if (!walletAddress) {
|
|
22
22
|
throw new Error("Sign in error: Wallet not connected!");
|
|
23
23
|
}
|
|
24
24
|
const nonce = await ensureNoSessionAndFetchNonce();
|
|
25
|
-
const
|
|
26
|
-
const messageResult = createSignInWithWalletMessage(btcAddress ? btcAddress : address, nonce, networkFamily, chainId);
|
|
25
|
+
const messageResult = createSignInWithWalletMessage(walletAddress, nonce, networkFamily, chainId);
|
|
27
26
|
const signatureResult = await signMessageAsync({
|
|
28
27
|
message: messageResult,
|
|
29
28
|
connector,
|
|
30
29
|
});
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
30
|
+
if (shouldCreateAccount) {
|
|
31
|
+
const getAccountByAddressResult = await getAccountByAddress();
|
|
32
|
+
if (getAccountByAddressResult.data) {
|
|
33
|
+
throw new Error("Wallet authentication failed: Account creation failed. Account already exists.");
|
|
34
|
+
}
|
|
35
|
+
if (getAccountByAddressResult.error) {
|
|
36
|
+
throw new Error(`Wallet authentication failed: Account creation failed. Could not verify if account already exists: ${getAccountByAddressResult.error}`);
|
|
37
|
+
}
|
|
38
|
+
// Fetch was successful, but no account was found
|
|
39
|
+
try {
|
|
34
40
|
const createAccountResult = await createAccountAsync({
|
|
35
41
|
type: "wallet",
|
|
36
42
|
message: messageResult,
|
|
37
43
|
signature: signatureResult,
|
|
38
44
|
});
|
|
39
45
|
if (!createAccountResult) {
|
|
40
|
-
throw new Error("
|
|
46
|
+
throw new Error("Failed to create new account");
|
|
41
47
|
}
|
|
42
48
|
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error(`Wallet authentication failed: Account creation failed: ${error}`);
|
|
51
|
+
}
|
|
43
52
|
}
|
|
44
|
-
return createSessionAsync({
|
|
53
|
+
return (await createSessionAsync({
|
|
45
54
|
type: "wallet",
|
|
46
55
|
message: messageResult,
|
|
47
56
|
signature: signatureResult,
|
|
48
|
-
});
|
|
57
|
+
}));
|
|
58
|
+
// ^ By passing type: "wallet" we know for sure the return type is Session
|
|
49
59
|
},
|
|
60
|
+
...mutationOptions,
|
|
50
61
|
});
|
|
51
62
|
return {
|
|
52
63
|
authenticateWithWallet: mutate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBitcoinPriceConversion copy.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion copy.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,OAAO,UAAU,mBAAmB,SAyB1C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useReadContracts } from "wagmi";
|
|
2
|
+
import { priceOracleContract } from "../lib/contracts";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
/**
|
|
5
|
+
@dev Used to convert an oracle price answer to an 18-digit precision uint
|
|
6
|
+
*/
|
|
7
|
+
const TARGET_DIGITS = 18;
|
|
8
|
+
/**
|
|
9
|
+
* @dev Scales oracle's response up/down to 1e18 precisoin.
|
|
10
|
+
*/
|
|
11
|
+
function scalePriceByDigits(_price, _priceDigits) {
|
|
12
|
+
if (_priceDigits > TARGET_DIGITS) {
|
|
13
|
+
return _price / 10n ** BigInt(_priceDigits - TARGET_DIGITS);
|
|
14
|
+
}
|
|
15
|
+
if (_priceDigits < TARGET_DIGITS) {
|
|
16
|
+
return _price * 10n ** BigInt(TARGET_DIGITS - _priceDigits);
|
|
17
|
+
}
|
|
18
|
+
return _price;
|
|
19
|
+
}
|
|
20
|
+
export default function useBitcoinPriceFeed() {
|
|
21
|
+
const { data, isPending, isError } = useReadContracts({
|
|
22
|
+
contracts: [
|
|
23
|
+
{
|
|
24
|
+
...priceOracleContract,
|
|
25
|
+
functionName: "latestRoundData",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
...priceOracleContract,
|
|
29
|
+
functionName: "decimals",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
const convertBitcointoUsd = useCallback((btcAmount) => {
|
|
34
|
+
if (isError || isPending)
|
|
35
|
+
return 0n;
|
|
36
|
+
if (data.some((r) => r.status !== "success"))
|
|
37
|
+
return 0n;
|
|
38
|
+
const [latestRoundData, decimals] = data;
|
|
39
|
+
const [, btcPrice] = latestRoundData.result;
|
|
40
|
+
const decimalsValue = decimals.result;
|
|
41
|
+
}, [data, isPending, isError]);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=useBitcoinPriceConversion%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBitcoinPriceConversion copy.js","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAEnC;;EAEE;AACF,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAAc,EAAE,YAAoB;IAC9D,IAAI,YAAY,GAAG,aAAa,EAAE,CAAC;QACjC,OAAO,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,YAAY,GAAG,aAAa,CAAC,CAAA;IAC7D,CAAC;IACD,IAAI,YAAY,GAAG,aAAa,EAAE,CAAC;QACjC,OAAO,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB;IACzC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;QACpD,SAAS,EAAE;YACT;gBACE,GAAG,mBAAmB;gBACtB,YAAY,EAAE,iBAAiB;aAChC;YACD;gBACE,GAAG,mBAAmB;gBACtB,YAAY,EAAE,UAAU;aACzB;SACF;KACF,CAAC,CAAA;IAEF,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,SAAiB,EAAE,EAAE;QACpB,IAAI,OAAO,IAAI,SAAS;YAAE,OAAO,EAAE,CAAA;QACnC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC;YAAE,OAAO,EAAE,CAAA;QAEvD,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAA;QACxC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,eAAe,CAAC,MAA6B,CAAA;QAClE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAgB,CAAA;IACjD,CAAC,EACD,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAC3B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { UseBaseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
type AssetsUsdConversion = {
|
|
3
|
+
usd: Record<"btc" | "eth" | "t", number>;
|
|
4
|
+
};
|
|
5
|
+
export default function useAssetsConversionRates(useQueryOptions?: Partial<UseBaseQueryOptions<AssetsUsdConversion>>): import("wagmi").UseReadContractsReturnType<readonly [{
|
|
6
|
+
readonly functionName: "latestRoundData";
|
|
7
|
+
readonly address: import("viem").Address;
|
|
8
|
+
readonly abi: readonly [{
|
|
9
|
+
readonly inputs: readonly [];
|
|
10
|
+
readonly name: "decimals";
|
|
11
|
+
readonly outputs: readonly [{
|
|
12
|
+
readonly internalType: "uint8";
|
|
13
|
+
readonly name: "";
|
|
14
|
+
readonly type: "uint8";
|
|
15
|
+
}];
|
|
16
|
+
readonly stateMutability: "view";
|
|
17
|
+
readonly type: "function";
|
|
18
|
+
}, {
|
|
19
|
+
readonly inputs: readonly [];
|
|
20
|
+
readonly name: "latestRoundData";
|
|
21
|
+
readonly outputs: readonly [{
|
|
22
|
+
readonly internalType: "uint80";
|
|
23
|
+
readonly name: "roundId";
|
|
24
|
+
readonly type: "uint80";
|
|
25
|
+
}, {
|
|
26
|
+
readonly internalType: "int256";
|
|
27
|
+
readonly name: "answer";
|
|
28
|
+
readonly type: "int256";
|
|
29
|
+
}, {
|
|
30
|
+
readonly internalType: "uint256";
|
|
31
|
+
readonly name: "startedAt";
|
|
32
|
+
readonly type: "uint256";
|
|
33
|
+
}, {
|
|
34
|
+
readonly internalType: "uint256";
|
|
35
|
+
readonly name: "updatedAt";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}, {
|
|
38
|
+
readonly internalType: "uint80";
|
|
39
|
+
readonly name: "answeredInRound";
|
|
40
|
+
readonly type: "uint80";
|
|
41
|
+
}];
|
|
42
|
+
readonly stateMutability: "view";
|
|
43
|
+
readonly type: "function";
|
|
44
|
+
}];
|
|
45
|
+
}, {
|
|
46
|
+
readonly functionName: "decimals";
|
|
47
|
+
readonly address: import("viem").Address;
|
|
48
|
+
readonly abi: readonly [{
|
|
49
|
+
readonly inputs: readonly [];
|
|
50
|
+
readonly name: "decimals";
|
|
51
|
+
readonly outputs: readonly [{
|
|
52
|
+
readonly internalType: "uint8";
|
|
53
|
+
readonly name: "";
|
|
54
|
+
readonly type: "uint8";
|
|
55
|
+
}];
|
|
56
|
+
readonly stateMutability: "view";
|
|
57
|
+
readonly type: "function";
|
|
58
|
+
}, {
|
|
59
|
+
readonly inputs: readonly [];
|
|
60
|
+
readonly name: "latestRoundData";
|
|
61
|
+
readonly outputs: readonly [{
|
|
62
|
+
readonly internalType: "uint80";
|
|
63
|
+
readonly name: "roundId";
|
|
64
|
+
readonly type: "uint80";
|
|
65
|
+
}, {
|
|
66
|
+
readonly internalType: "int256";
|
|
67
|
+
readonly name: "answer";
|
|
68
|
+
readonly type: "int256";
|
|
69
|
+
}, {
|
|
70
|
+
readonly internalType: "uint256";
|
|
71
|
+
readonly name: "startedAt";
|
|
72
|
+
readonly type: "uint256";
|
|
73
|
+
}, {
|
|
74
|
+
readonly internalType: "uint256";
|
|
75
|
+
readonly name: "updatedAt";
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
}, {
|
|
78
|
+
readonly internalType: "uint80";
|
|
79
|
+
readonly name: "answeredInRound";
|
|
80
|
+
readonly type: "uint80";
|
|
81
|
+
}];
|
|
82
|
+
readonly stateMutability: "view";
|
|
83
|
+
readonly type: "function";
|
|
84
|
+
}];
|
|
85
|
+
}], true, [{
|
|
86
|
+
error: Error;
|
|
87
|
+
result?: undefined;
|
|
88
|
+
status: "failure";
|
|
89
|
+
} | {
|
|
90
|
+
error?: undefined;
|
|
91
|
+
result: readonly [bigint, bigint, bigint, bigint, bigint];
|
|
92
|
+
status: "success";
|
|
93
|
+
}, {
|
|
94
|
+
error: Error;
|
|
95
|
+
result?: undefined;
|
|
96
|
+
status: "failure";
|
|
97
|
+
} | {
|
|
98
|
+
error?: undefined;
|
|
99
|
+
result: number;
|
|
100
|
+
status: "success";
|
|
101
|
+
}]>;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=useBitcoinPriceConversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBitcoinPriceConversion.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAQrE,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,GAAG,EAAE,MAAM,CAAC,CAAA;CACzC,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,eAAe,GAAE,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoDxE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useReadContracts } from "wagmi";
|
|
2
|
+
import { priceOracleContract } from "../lib/contracts";
|
|
3
|
+
export default function useAssetsConversionRates(useQueryOptions = {}) {
|
|
4
|
+
// const portalApiClient = usePortalApiClient()
|
|
5
|
+
// const config = useConfig()
|
|
6
|
+
return useReadContracts({
|
|
7
|
+
contracts: [
|
|
8
|
+
{
|
|
9
|
+
...priceOracleContract,
|
|
10
|
+
functionName: "latestRoundData",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
...priceOracleContract,
|
|
14
|
+
functionName: "decimals",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
// return useQuery({
|
|
19
|
+
// queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
|
|
20
|
+
// queryFn: async () => {
|
|
21
|
+
// const { currentUsdPerBtc, currentUsdPerEth, currentUsdPerTToken } =
|
|
22
|
+
// await portalApiClient.getPortalStatistics()
|
|
23
|
+
// const [latestRoundData, decimals] = await readContracts(config, {
|
|
24
|
+
// contracts: [
|
|
25
|
+
// {
|
|
26
|
+
// ...priceOracleContract,
|
|
27
|
+
// functionName: "latestRoundData",
|
|
28
|
+
// },
|
|
29
|
+
// {
|
|
30
|
+
// ...priceOracleContract,
|
|
31
|
+
// functionName: "decimals",
|
|
32
|
+
// },
|
|
33
|
+
// ],
|
|
34
|
+
// })
|
|
35
|
+
// const [, btcPrice = 0n] = latestRoundData.result ?? []
|
|
36
|
+
// const decimalsValue = decimals.result ?? 0
|
|
37
|
+
// return {
|
|
38
|
+
// usd: {
|
|
39
|
+
// btc: Number(currentUsdPerBtc),
|
|
40
|
+
// eth: Number(currentUsdPerEth),
|
|
41
|
+
// t: Number(currentUsdPerTToken),
|
|
42
|
+
// },
|
|
43
|
+
// }
|
|
44
|
+
// },
|
|
45
|
+
// staleTime: 30 * ONE_MINUTE_MS,
|
|
46
|
+
// retry: 1,
|
|
47
|
+
// ...useQueryOptions,
|
|
48
|
+
// })
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=useBitcoinPriceConversion.js.map
|