@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBitcoinPriceConversion.js","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceConversion.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAKnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAMtD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,kBAAqE,EAAE;IAEvE,+CAA+C;IAC/C,6BAA6B;IAE7B,OAAO,gBAAgB,CAAC;QACtB,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,sBAAsB;IACtB,oDAAoD;IACpD,6BAA6B;IAC7B,4EAA4E;IAC5E,sDAAsD;IAEtD,0EAA0E;IAC1E,uBAAuB;IACvB,cAAc;IACd,sCAAsC;IACtC,+CAA+C;IAC/C,eAAe;IACf,cAAc;IACd,sCAAsC;IACtC,wCAAwC;IACxC,eAAe;IACf,aAAa;IACb,WAAW;IAEX,+DAA+D;IAC/D,mDAAmD;IAEnD,iBAAiB;IACjB,iBAAiB;IACjB,2CAA2C;IAC3C,2CAA2C;IAC3C,4CAA4C;IAC5C,aAAa;IACb,UAAU;IACV,SAAS;IACT,qCAAqC;IACrC,gBAAgB;IAChB,0BAA0B;IAC1B,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to fetch the latest Bitcoin price from the price oracle contract.
|
|
3
|
+
* @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
|
|
4
|
+
* @returns {}.price - The latest Bitcoin price.
|
|
5
|
+
* @returns {}.decimals - The number of decimals for the price.
|
|
6
|
+
* @returns {}.isPending - Whether the request is pending.
|
|
7
|
+
* @returns {}.isError - Whether there was an error fetching the price.
|
|
8
|
+
*/
|
|
9
|
+
export default function useBitcoinPriceFeed(): {
|
|
10
|
+
price: bigint | null;
|
|
11
|
+
decimals: number;
|
|
12
|
+
isPending: boolean;
|
|
13
|
+
isError: boolean;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useBitcoinPriceFeed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBitcoinPriceFeed.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceFeed.ts"],"names":[],"mappings":"AA2BA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB;;;;;EAqC1C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useReadContract } from "wagmi";
|
|
3
|
+
import { priceOracleContract } from "../lib/contracts";
|
|
4
|
+
import { ONE_SECOND_MS } from "../utils/time";
|
|
5
|
+
const TARGET_DIGITS = 18;
|
|
6
|
+
// If the oracle has not been updated in at least 60 seconds, it is stale.
|
|
7
|
+
const MAX_PRICE_DELAY = 60 * ONE_SECOND_MS;
|
|
8
|
+
/**
|
|
9
|
+
* Scales the price by the number of digits.
|
|
10
|
+
* @dev Oracles returns prices with variable number of digits. This function
|
|
11
|
+
* scales the price to a fixed number of digits ensuring consistency.
|
|
12
|
+
* @param price - The price to scale.
|
|
13
|
+
* @param priceDigits - The number of digits in the price.
|
|
14
|
+
* @returns The scaled price.
|
|
15
|
+
*/
|
|
16
|
+
function scalePriceByDigits(price, priceDigits) {
|
|
17
|
+
if (priceDigits > TARGET_DIGITS) {
|
|
18
|
+
return price / 10n ** BigInt(priceDigits - TARGET_DIGITS);
|
|
19
|
+
}
|
|
20
|
+
if (priceDigits < TARGET_DIGITS) {
|
|
21
|
+
return price * 10n ** BigInt(TARGET_DIGITS - priceDigits);
|
|
22
|
+
}
|
|
23
|
+
return price;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook to fetch the latest Bitcoin price from the price oracle contract.
|
|
27
|
+
* @see https://github.com/mezo-org/musd/blob/f0b2030315f0d8b0fc11a9fc778856fe4673051f/solidity/contracts/PriceFeed.sol
|
|
28
|
+
* @returns {}.price - The latest Bitcoin price.
|
|
29
|
+
* @returns {}.decimals - The number of decimals for the price.
|
|
30
|
+
* @returns {}.isPending - Whether the request is pending.
|
|
31
|
+
* @returns {}.isError - Whether there was an error fetching the price.
|
|
32
|
+
*/
|
|
33
|
+
export default function useBitcoinPriceFeed() {
|
|
34
|
+
const { data, isPending, isError } = useReadContract({
|
|
35
|
+
...priceOracleContract,
|
|
36
|
+
functionName: "latestRoundData",
|
|
37
|
+
query: {
|
|
38
|
+
refetchInterval: ({ state }) => {
|
|
39
|
+
if (!state.data)
|
|
40
|
+
return MAX_PRICE_DELAY;
|
|
41
|
+
const [, , , updatedAt] = state.data ?? [];
|
|
42
|
+
if (!updatedAt)
|
|
43
|
+
return MAX_PRICE_DELAY;
|
|
44
|
+
const age = Date.now() - Number(updatedAt) * 1000;
|
|
45
|
+
return age > MAX_PRICE_DELAY
|
|
46
|
+
? // If the data is stale, we want to refetch as soon as possible, but
|
|
47
|
+
// not faster than once per second, to avoid excessive requests.
|
|
48
|
+
// Math.max ensures the interval is at least 1 second.
|
|
49
|
+
Math.max(ONE_SECOND_MS, MAX_PRICE_DELAY - age)
|
|
50
|
+
: MAX_PRICE_DELAY - age;
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const price = useMemo(() => {
|
|
55
|
+
if (!data || isPending || isError)
|
|
56
|
+
return null;
|
|
57
|
+
const [, answer] = data;
|
|
58
|
+
return scalePriceByDigits(answer, TARGET_DIGITS);
|
|
59
|
+
}, [data, isPending, isError]);
|
|
60
|
+
return {
|
|
61
|
+
price,
|
|
62
|
+
decimals: TARGET_DIGITS,
|
|
63
|
+
isPending,
|
|
64
|
+
isError,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=useBitcoinPriceFeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBitcoinPriceFeed.js","sourceRoot":"","sources":["../../../src/hooks/useBitcoinPriceFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,0EAA0E;AAC1E,MAAM,eAAe,GAAG,EAAE,GAAG,aAAa,CAAA;AAE1C;;;;;;;GAOG;AACH,SAAS,kBAAkB,CAAC,KAAa,EAAE,WAAmB;IAC5D,IAAI,WAAW,GAAG,aAAa,EAAE,CAAC;QAChC,OAAO,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,WAAW,GAAG,aAAa,CAAC,CAAA;IAC3D,CAAC;IACD,IAAI,WAAW,GAAG,aAAa,EAAE,CAAC;QAChC,OAAO,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,aAAa,GAAG,WAAW,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB;IACzC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;QACnD,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;SACF;KACF,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,IAAI,CAAC,IAAI,IAAI,SAAS,IAAI,OAAO;YAAE,OAAO,IAAI,CAAA;QAE9C,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;QAEvB,OAAO,kBAAkB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAClD,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA;IAE9B,OAAO;QACL,KAAK;QACL,QAAQ,EAAE,aAAa;QACvB,SAAS;QACT,OAAO;KACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query hook for getting borrow data. Returns collateral and trove debt for the
|
|
3
|
+
* connected account, based on it's evm address.
|
|
4
|
+
* @param queryOptions Query options passed to the underlying `useQuery` hook.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useBorrowData(queryOptions?: {}): import("wagmi").UseReadContractReturnType<readonly [{
|
|
7
|
+
readonly inputs: readonly [{
|
|
8
|
+
readonly internalType: "address";
|
|
9
|
+
readonly name: "_borrower";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
}];
|
|
12
|
+
readonly name: "getEntireDebtAndColl";
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly internalType: "uint256";
|
|
15
|
+
readonly name: "coll";
|
|
16
|
+
readonly type: "uint256";
|
|
17
|
+
}, {
|
|
18
|
+
readonly internalType: "uint256";
|
|
19
|
+
readonly name: "principal";
|
|
20
|
+
readonly type: "uint256";
|
|
21
|
+
}, {
|
|
22
|
+
readonly internalType: "uint256";
|
|
23
|
+
readonly name: "interest";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly internalType: "uint256";
|
|
27
|
+
readonly name: "pendingCollateral";
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
}, {
|
|
30
|
+
readonly internalType: "uint256";
|
|
31
|
+
readonly name: "pendingPrincipal";
|
|
32
|
+
readonly type: "uint256";
|
|
33
|
+
}, {
|
|
34
|
+
readonly internalType: "uint256";
|
|
35
|
+
readonly name: "pendingInterest";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}];
|
|
38
|
+
readonly stateMutability: "view";
|
|
39
|
+
readonly type: "function";
|
|
40
|
+
}], "getEntireDebtAndColl", [`0x${string}`], {
|
|
41
|
+
collateral: bigint;
|
|
42
|
+
troveDebt: bigint;
|
|
43
|
+
} | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Hook for for invalidating current user's borrow data. Can be used to
|
|
46
|
+
* invalidate borrow data manually, which forces the data to be re-fetched.
|
|
47
|
+
* @returns Function `invalidateBorrowData` for invalidating the borrow data
|
|
48
|
+
*/
|
|
49
|
+
export declare function useInvalidateBorrowData(): {
|
|
50
|
+
invalidateBorrowData: () => Promise<void>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Hook for for resetting current user's borrow data. Can be used to reset
|
|
54
|
+
* borrow data manually, which forces the data to be re-fetched.
|
|
55
|
+
* @returns Function `resetBorrowData` for resetting the borrow data
|
|
56
|
+
*/
|
|
57
|
+
export declare function useResetBorrowData(): {
|
|
58
|
+
resetBorrowData: () => Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=useBorrowData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBorrowData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,YAAY,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAiC9C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB;;EAatC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB;;EAajC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useAccount, useReadContract } from "wagmi";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { ONE_MINUTE_MS } from "../utils/time";
|
|
5
|
+
import { mainnetBorrowContracts, testnetBorrowContracts, } from "../lib/contracts";
|
|
6
|
+
import { usePassportContext } from "./usePassportContext";
|
|
7
|
+
import { CHAIN_ID } from "../constants";
|
|
8
|
+
// Wagmi handles typesafety with ABI const assertions. TypeScript doesn't
|
|
9
|
+
// support importing JSON as const yet so types cannot be inferred from the
|
|
10
|
+
// imported contract. As a workaround there is minimal ABI definition that can
|
|
11
|
+
// be asserted types from.
|
|
12
|
+
// Ref: https://wagmi.sh/core/typescript#const-assert-abis-typed-data
|
|
13
|
+
const TROVE_MANAGER_ABI = [
|
|
14
|
+
{
|
|
15
|
+
inputs: [
|
|
16
|
+
{
|
|
17
|
+
internalType: "address",
|
|
18
|
+
name: "_borrower",
|
|
19
|
+
type: "address",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
name: "getEntireDebtAndColl",
|
|
23
|
+
outputs: [
|
|
24
|
+
{
|
|
25
|
+
internalType: "uint256",
|
|
26
|
+
name: "coll",
|
|
27
|
+
type: "uint256",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
internalType: "uint256",
|
|
31
|
+
name: "principal",
|
|
32
|
+
type: "uint256",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
internalType: "uint256",
|
|
36
|
+
name: "interest",
|
|
37
|
+
type: "uint256",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
internalType: "uint256",
|
|
41
|
+
name: "pendingCollateral",
|
|
42
|
+
type: "uint256",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
internalType: "uint256",
|
|
46
|
+
name: "pendingPrincipal",
|
|
47
|
+
type: "uint256",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
internalType: "uint256",
|
|
51
|
+
name: "pendingInterest",
|
|
52
|
+
type: "uint256",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
stateMutability: "view",
|
|
56
|
+
type: "function",
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Query hook for getting borrow data. Returns collateral and trove debt for the
|
|
61
|
+
* connected account, based on it's evm address.
|
|
62
|
+
* @param queryOptions Query options passed to the underlying `useQuery` hook.
|
|
63
|
+
*/
|
|
64
|
+
export function useBorrowData(queryOptions = {}) {
|
|
65
|
+
const { environment = "mainnet" } = usePassportContext();
|
|
66
|
+
const { address } = useAccount();
|
|
67
|
+
const contractAddress = useMemo(() => {
|
|
68
|
+
if (environment === "mainnet") {
|
|
69
|
+
return mainnetBorrowContracts.TroveManager.address;
|
|
70
|
+
}
|
|
71
|
+
return testnetBorrowContracts.TroveManager.address;
|
|
72
|
+
}, [environment]);
|
|
73
|
+
return useReadContract({
|
|
74
|
+
abi: TROVE_MANAGER_ABI,
|
|
75
|
+
address: contractAddress,
|
|
76
|
+
functionName: "getEntireDebtAndColl",
|
|
77
|
+
args: [address || "0x"],
|
|
78
|
+
query: {
|
|
79
|
+
enabled: !!address,
|
|
80
|
+
staleTime: 5 * ONE_MINUTE_MS,
|
|
81
|
+
retry: 1,
|
|
82
|
+
select: (data) => {
|
|
83
|
+
if (!data)
|
|
84
|
+
return undefined;
|
|
85
|
+
const [collateral, principal, interest] = data;
|
|
86
|
+
return {
|
|
87
|
+
collateral,
|
|
88
|
+
troveDebt: principal + interest,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
...queryOptions,
|
|
92
|
+
},
|
|
93
|
+
chainId: CHAIN_ID[environment],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Hook for for invalidating current user's borrow data. Can be used to
|
|
98
|
+
* invalidate borrow data manually, which forces the data to be re-fetched.
|
|
99
|
+
* @returns Function `invalidateBorrowData` for invalidating the borrow data
|
|
100
|
+
*/
|
|
101
|
+
export function useInvalidateBorrowData() {
|
|
102
|
+
const queryClient = useQueryClient();
|
|
103
|
+
const { queryKey } = useBorrowData();
|
|
104
|
+
const invalidateBorrowDataHandler = useCallback(() => queryClient.invalidateQueries({ queryKey }), [queryClient, queryKey]);
|
|
105
|
+
return {
|
|
106
|
+
invalidateBorrowData: invalidateBorrowDataHandler,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Hook for for resetting current user's borrow data. Can be used to reset
|
|
111
|
+
* borrow data manually, which forces the data to be re-fetched.
|
|
112
|
+
* @returns Function `resetBorrowData` for resetting the borrow data
|
|
113
|
+
*/
|
|
114
|
+
export function useResetBorrowData() {
|
|
115
|
+
const queryClient = useQueryClient();
|
|
116
|
+
const { queryKey } = useBorrowData();
|
|
117
|
+
const resetBorrowDataHandler = useCallback(() => queryClient.resetQueries({ queryKey }), [queryClient, queryKey]);
|
|
118
|
+
return {
|
|
119
|
+
resetBorrowData: resetBorrowDataHandler,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=useBorrowData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBorrowData.js","sourceRoot":"","sources":["../../../src/hooks/useBorrowData.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
+
import type { CreateAccountRequest, CreateAccountResponse } from "../api";
|
|
3
|
+
export declare function useCreateAccount(mutationOptions?: Omit<MutationOptions<CreateAccountResponse, DefaultError, CreateAccountRequest>, "mutationFn" | "mutationKey">): {
|
|
2
4
|
data: undefined;
|
|
3
5
|
variables: undefined;
|
|
4
6
|
error: null;
|
|
@@ -16,52 +18,16 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
16
18
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
17
19
|
mezoId: string;
|
|
18
20
|
hasModifiedMezoId: boolean;
|
|
19
|
-
linkedAccounts: import("../api
|
|
20
|
-
|
|
21
|
-
id: string;
|
|
22
|
-
app_metadata: {
|
|
23
|
-
provider: "wallet" | "discord" | "email";
|
|
24
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
25
|
-
};
|
|
26
|
-
user_metadata: {
|
|
27
|
-
mezoId?: string | undefined;
|
|
28
|
-
btcAddress: string;
|
|
29
|
-
evmAddress: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
}, Error, {
|
|
33
|
-
type: "wallet";
|
|
34
|
-
message: string;
|
|
35
|
-
signature: string;
|
|
36
|
-
}, unknown>;
|
|
21
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
22
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
37
23
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
38
24
|
mezoId: string;
|
|
39
25
|
hasModifiedMezoId: boolean;
|
|
40
|
-
linkedAccounts: import("../api
|
|
41
|
-
|
|
42
|
-
id: string;
|
|
43
|
-
app_metadata: {
|
|
44
|
-
provider: "wallet" | "discord" | "email";
|
|
45
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
46
|
-
};
|
|
47
|
-
user_metadata: {
|
|
48
|
-
mezoId?: string | undefined;
|
|
49
|
-
btcAddress: string;
|
|
50
|
-
evmAddress: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
}, Error, {
|
|
54
|
-
type: "wallet";
|
|
55
|
-
message: string;
|
|
56
|
-
signature: string;
|
|
57
|
-
}, unknown>;
|
|
26
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
27
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
58
28
|
} | {
|
|
59
29
|
data: undefined;
|
|
60
|
-
variables:
|
|
61
|
-
type: "wallet";
|
|
62
|
-
message: string;
|
|
63
|
-
signature: string;
|
|
64
|
-
};
|
|
30
|
+
variables: CreateAccountRequest;
|
|
65
31
|
error: null;
|
|
66
32
|
isError: false;
|
|
67
33
|
isIdle: false;
|
|
@@ -77,53 +43,17 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
77
43
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
78
44
|
mezoId: string;
|
|
79
45
|
hasModifiedMezoId: boolean;
|
|
80
|
-
linkedAccounts: import("../api
|
|
81
|
-
|
|
82
|
-
id: string;
|
|
83
|
-
app_metadata: {
|
|
84
|
-
provider: "wallet" | "discord" | "email";
|
|
85
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
86
|
-
};
|
|
87
|
-
user_metadata: {
|
|
88
|
-
mezoId?: string | undefined;
|
|
89
|
-
btcAddress: string;
|
|
90
|
-
evmAddress: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
}, Error, {
|
|
94
|
-
type: "wallet";
|
|
95
|
-
message: string;
|
|
96
|
-
signature: string;
|
|
97
|
-
}, unknown>;
|
|
46
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
47
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
98
48
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
99
49
|
mezoId: string;
|
|
100
50
|
hasModifiedMezoId: boolean;
|
|
101
|
-
linkedAccounts: import("../api
|
|
102
|
-
|
|
103
|
-
id: string;
|
|
104
|
-
app_metadata: {
|
|
105
|
-
provider: "wallet" | "discord" | "email";
|
|
106
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
107
|
-
};
|
|
108
|
-
user_metadata: {
|
|
109
|
-
mezoId?: string | undefined;
|
|
110
|
-
btcAddress: string;
|
|
111
|
-
evmAddress: string;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
}, Error, {
|
|
115
|
-
type: "wallet";
|
|
116
|
-
message: string;
|
|
117
|
-
signature: string;
|
|
118
|
-
}, unknown>;
|
|
51
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
52
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
119
53
|
} | {
|
|
120
54
|
data: undefined;
|
|
121
55
|
error: Error;
|
|
122
|
-
variables:
|
|
123
|
-
type: "wallet";
|
|
124
|
-
message: string;
|
|
125
|
-
signature: string;
|
|
126
|
-
};
|
|
56
|
+
variables: CreateAccountRequest;
|
|
127
57
|
isError: true;
|
|
128
58
|
isIdle: false;
|
|
129
59
|
isPending: false;
|
|
@@ -138,69 +68,21 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
138
68
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
139
69
|
mezoId: string;
|
|
140
70
|
hasModifiedMezoId: boolean;
|
|
141
|
-
linkedAccounts: import("../api
|
|
142
|
-
|
|
143
|
-
id: string;
|
|
144
|
-
app_metadata: {
|
|
145
|
-
provider: "wallet" | "discord" | "email";
|
|
146
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
147
|
-
};
|
|
148
|
-
user_metadata: {
|
|
149
|
-
mezoId?: string | undefined;
|
|
150
|
-
btcAddress: string;
|
|
151
|
-
evmAddress: string;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
}, Error, {
|
|
155
|
-
type: "wallet";
|
|
156
|
-
message: string;
|
|
157
|
-
signature: string;
|
|
158
|
-
}, unknown>;
|
|
71
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
72
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
159
73
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
160
74
|
mezoId: string;
|
|
161
75
|
hasModifiedMezoId: boolean;
|
|
162
|
-
linkedAccounts: import("../api
|
|
163
|
-
|
|
164
|
-
id: string;
|
|
165
|
-
app_metadata: {
|
|
166
|
-
provider: "wallet" | "discord" | "email";
|
|
167
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
168
|
-
};
|
|
169
|
-
user_metadata: {
|
|
170
|
-
mezoId?: string | undefined;
|
|
171
|
-
btcAddress: string;
|
|
172
|
-
evmAddress: string;
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
}, Error, {
|
|
176
|
-
type: "wallet";
|
|
177
|
-
message: string;
|
|
178
|
-
signature: string;
|
|
179
|
-
}, unknown>;
|
|
76
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
77
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
180
78
|
} | {
|
|
181
79
|
data: {
|
|
182
80
|
mezoId: string;
|
|
183
81
|
hasModifiedMezoId: boolean;
|
|
184
|
-
linkedAccounts: import("../api
|
|
185
|
-
authUser: {
|
|
186
|
-
id: string;
|
|
187
|
-
app_metadata: {
|
|
188
|
-
provider: "wallet" | "discord" | "email";
|
|
189
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
190
|
-
};
|
|
191
|
-
user_metadata: {
|
|
192
|
-
mezoId?: string | undefined;
|
|
193
|
-
btcAddress: string;
|
|
194
|
-
evmAddress: string;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
82
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
197
83
|
};
|
|
198
84
|
error: null;
|
|
199
|
-
variables:
|
|
200
|
-
type: "wallet";
|
|
201
|
-
message: string;
|
|
202
|
-
signature: string;
|
|
203
|
-
};
|
|
85
|
+
variables: CreateAccountRequest;
|
|
204
86
|
isError: false;
|
|
205
87
|
isIdle: false;
|
|
206
88
|
isPending: false;
|
|
@@ -215,44 +97,12 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
215
97
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
216
98
|
mezoId: string;
|
|
217
99
|
hasModifiedMezoId: boolean;
|
|
218
|
-
linkedAccounts: import("../api
|
|
219
|
-
|
|
220
|
-
id: string;
|
|
221
|
-
app_metadata: {
|
|
222
|
-
provider: "wallet" | "discord" | "email";
|
|
223
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
224
|
-
};
|
|
225
|
-
user_metadata: {
|
|
226
|
-
mezoId?: string | undefined;
|
|
227
|
-
btcAddress: string;
|
|
228
|
-
evmAddress: string;
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
}, Error, {
|
|
232
|
-
type: "wallet";
|
|
233
|
-
message: string;
|
|
234
|
-
signature: string;
|
|
235
|
-
}, unknown>;
|
|
100
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
101
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
236
102
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
237
103
|
mezoId: string;
|
|
238
104
|
hasModifiedMezoId: boolean;
|
|
239
|
-
linkedAccounts: import("../api
|
|
240
|
-
|
|
241
|
-
id: string;
|
|
242
|
-
app_metadata: {
|
|
243
|
-
provider: "wallet" | "discord" | "email";
|
|
244
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
245
|
-
};
|
|
246
|
-
user_metadata: {
|
|
247
|
-
mezoId?: string | undefined;
|
|
248
|
-
btcAddress: string;
|
|
249
|
-
evmAddress: string;
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
}, Error, {
|
|
253
|
-
type: "wallet";
|
|
254
|
-
message: string;
|
|
255
|
-
signature: string;
|
|
256
|
-
}, unknown>;
|
|
105
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
106
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
257
107
|
};
|
|
258
108
|
//# sourceMappingURL=useCreateAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAEzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBP"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
1
|
+
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
2
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
3
|
import { QUERY_KEYS } from "./constants";
|
|
4
|
-
export function useCreateAccount(
|
|
4
|
+
export function useCreateAccount(mutationOptions = {}) {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
const authApiClient = useAuthApiClient();
|
|
7
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
7
8
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
8
9
|
mutationFn: (createAccountRequest) => authApiClient.createAccount(createAccountRequest),
|
|
9
|
-
onSuccess: () => {
|
|
10
|
+
onSuccess: (data, variables, context) => {
|
|
10
11
|
queryClient.resetQueries({
|
|
11
12
|
queryKey: [QUERY_KEYS.ACCOUNT],
|
|
12
13
|
});
|
|
14
|
+
if (customOnSuccess)
|
|
15
|
+
customOnSuccess(data, variables, context);
|
|
13
16
|
},
|
|
14
|
-
...
|
|
17
|
+
...restMutationOptions,
|
|
15
18
|
});
|
|
16
19
|
return { createAccount: mutate, createAccountAsync: mutateAsync, ...rest };
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAU,gBAAgB,CAC9B,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAA;IAE9E,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,oBAA0C,EAAE,EAAE,CACzD,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,WAAW,CAAC,YAAY,CAAC;gBACvB,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;aAC/B,CAAC,CAAA;YAEF,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
|