@mezo-org/passport 0.4.0-dev.1 → 0.4.0-dev.10

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.
Files changed (233) hide show
  1. package/dist/src/api/auth.d.ts +57 -52
  2. package/dist/src/api/auth.d.ts.map +1 -1
  3. package/dist/src/api/auth.js +22 -53
  4. package/dist/src/api/auth.js.map +1 -1
  5. package/dist/src/api/client.d.ts +24 -0
  6. package/dist/src/api/client.d.ts.map +1 -0
  7. package/dist/src/api/client.js +54 -0
  8. package/dist/src/api/client.js.map +1 -0
  9. package/dist/src/api/fetch-error.d.ts +5 -0
  10. package/dist/src/api/fetch-error.d.ts.map +1 -0
  11. package/dist/src/api/fetch-error.js +8 -0
  12. package/dist/src/api/fetch-error.js.map +1 -0
  13. package/dist/src/api/index.d.ts +3 -0
  14. package/dist/src/api/index.d.ts.map +1 -0
  15. package/dist/src/api/index.js +3 -0
  16. package/dist/src/api/index.js.map +1 -0
  17. package/dist/src/api/portal.d.ts +32 -0
  18. package/dist/src/api/portal.d.ts.map +1 -0
  19. package/dist/src/api/portal.js +23 -0
  20. package/dist/src/api/portal.js.map +1 -0
  21. package/dist/src/assets/DefaultAvatar.d.ts +5 -0
  22. package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
  23. package/dist/src/assets/DefaultAvatar.js +21 -0
  24. package/dist/src/assets/DefaultAvatar.js.map +1 -0
  25. package/dist/src/components/Dropdown/AccountAddress.d.ts +8 -0
  26. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +1 -0
  27. package/dist/src/components/Dropdown/AccountAddress.js +66 -0
  28. package/dist/src/components/Dropdown/AccountAddress.js.map +1 -0
  29. package/dist/src/components/Dropdown/AccountAssets.d.ts +14 -0
  30. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +1 -0
  31. package/dist/src/components/Dropdown/AccountAssets.js +44 -0
  32. package/dist/src/components/Dropdown/AccountAssets.js.map +1 -0
  33. package/dist/src/components/Dropdown/AccountBalance.d.ts +7 -0
  34. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +1 -0
  35. package/dist/src/components/Dropdown/AccountBalance.js +18 -0
  36. package/dist/src/components/Dropdown/AccountBalance.js.map +1 -0
  37. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +7 -0
  38. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
  39. package/dist/src/components/Dropdown/ConnectedTrigger.js +30 -0
  40. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
  41. package/dist/src/components/Dropdown/Content.d.ts +9 -0
  42. package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
  43. package/dist/src/components/Dropdown/Content.js +69 -0
  44. package/dist/src/components/Dropdown/Content.js.map +1 -0
  45. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
  46. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
  47. package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
  48. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
  49. package/dist/src/components/Dropdown/Dropdown.d.ts +20 -0
  50. package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
  51. package/dist/src/components/Dropdown/Dropdown.js +64 -0
  52. package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
  53. package/dist/src/components/Dropdown/WelcomeBlock.d.ts +8 -0
  54. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +1 -0
  55. package/dist/src/components/Dropdown/WelcomeBlock.js +44 -0
  56. package/dist/src/components/Dropdown/WelcomeBlock.js.map +1 -0
  57. package/dist/src/components/Dropdown/index.d.ts +3 -0
  58. package/dist/src/components/Dropdown/index.d.ts.map +1 -0
  59. package/dist/src/components/Dropdown/index.js +2 -0
  60. package/dist/src/components/Dropdown/index.js.map +1 -0
  61. package/dist/src/components/index.d.ts +2 -0
  62. package/dist/src/components/index.d.ts.map +1 -0
  63. package/dist/src/components/index.js +2 -0
  64. package/dist/src/components/index.js.map +1 -0
  65. package/dist/src/hooks/constants.d.ts +3 -3
  66. package/dist/src/hooks/constants.js +4 -4
  67. package/dist/src/hooks/constants.js.map +1 -1
  68. package/dist/src/hooks/index.d.ts +1 -4
  69. package/dist/src/hooks/index.d.ts.map +1 -1
  70. package/dist/src/hooks/index.js +1 -4
  71. package/dist/src/hooks/index.js.map +1 -1
  72. package/dist/src/hooks/useAssetsUSDConversion.d.ts +8 -0
  73. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +1 -0
  74. package/dist/src/hooks/useAssetsUSDConversion.js +21 -0
  75. package/dist/src/hooks/useAssetsUSDConversion.js.map +1 -0
  76. package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
  77. package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
  78. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
  79. package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
  80. package/dist/src/hooks/useAuthenticateWithWallet.js +69 -0
  81. package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
  82. package/dist/src/hooks/useCreateAccount.d.ts +41 -137
  83. package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
  84. package/dist/src/hooks/useCreateAccount.js +8 -10
  85. package/dist/src/hooks/useCreateAccount.js.map +1 -1
  86. package/dist/src/hooks/useCreateSession.d.ts +12 -182
  87. package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
  88. package/dist/src/hooks/useCreateSession.js +12 -18
  89. package/dist/src/hooks/useCreateSession.js.map +1 -1
  90. package/dist/src/hooks/useDropdownData.d.ts +45 -0
  91. package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
  92. package/dist/src/hooks/useDropdownData.js +74 -0
  93. package/dist/src/hooks/useDropdownData.js.map +1 -0
  94. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts +5 -0
  95. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -0
  96. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +34 -0
  97. package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -0
  98. package/dist/src/hooks/useGetAccountByAddress.d.ts +3 -5
  99. package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
  100. package/dist/src/hooks/useGetAccountByAddress.js +3 -4
  101. package/dist/src/hooks/useGetAccountByAddress.js.map +1 -1
  102. package/dist/src/hooks/useGetAccountByMezoId.d.ts +3 -5
  103. package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
  104. package/dist/src/hooks/useGetAccountByMezoId.js +3 -4
  105. package/dist/src/hooks/useGetAccountByMezoId.js.map +1 -1
  106. package/dist/src/hooks/useGetCurrentAccount.d.ts +14 -8
  107. package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
  108. package/dist/src/hooks/useGetCurrentAccount.js +28 -6
  109. package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
  110. package/dist/src/hooks/useGetSession.d.ts +3 -20
  111. package/dist/src/hooks/useGetSession.d.ts.map +1 -1
  112. package/dist/src/hooks/useGetSession.js +2 -2
  113. package/dist/src/hooks/useGetSession.js.map +1 -1
  114. package/dist/src/hooks/useLinkAccount.d.ts +15 -121
  115. package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
  116. package/dist/src/hooks/useLinkAccount.js +8 -21
  117. package/dist/src/hooks/useLinkAccount.js.map +1 -1
  118. package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
  119. package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
  120. package/dist/src/hooks/usePortalApiClient.js +6 -0
  121. package/dist/src/hooks/usePortalApiClient.js.map +1 -0
  122. package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -181
  123. package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
  124. package/dist/src/hooks/useSignInWithDiscord.js +11 -22
  125. package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
  126. package/dist/src/hooks/useSignInWithWallet.d.ts +12 -181
  127. package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
  128. package/dist/src/hooks/useSignInWithWallet.js +6 -43
  129. package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
  130. package/dist/src/hooks/useSignOut.d.ts +12 -28
  131. package/dist/src/hooks/useSignOut.d.ts.map +1 -1
  132. package/dist/src/hooks/useSignOut.js +11 -6
  133. package/dist/src/hooks/useSignOut.js.map +1 -1
  134. package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
  135. package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
  136. package/dist/src/hooks/useSignUpWithWallet.js +11 -0
  137. package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
  138. package/dist/src/hooks/useUpdateMezoId.d.ts +30 -82
  139. package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
  140. package/dist/src/hooks/useUpdateMezoId.js +8 -12
  141. package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
  142. package/dist/src/hooks/useWalletAccount.d.ts +12 -0
  143. package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
  144. package/dist/src/hooks/useWalletAccount.js +28 -0
  145. package/dist/src/hooks/useWalletAccount.js.map +1 -0
  146. package/dist/src/index.d.ts +1 -0
  147. package/dist/src/index.d.ts.map +1 -1
  148. package/dist/src/index.js +1 -0
  149. package/dist/src/index.js.map +1 -1
  150. package/dist/src/provider.d.ts +10 -13
  151. package/dist/src/provider.d.ts.map +1 -1
  152. package/dist/src/provider.js +11 -20
  153. package/dist/src/provider.js.map +1 -1
  154. package/dist/src/utils/address.d.ts +15 -0
  155. package/dist/src/utils/address.d.ts.map +1 -0
  156. package/dist/src/utils/address.js +35 -0
  157. package/dist/src/utils/address.js.map +1 -0
  158. package/dist/src/utils/address.test.d.ts +2 -0
  159. package/dist/src/utils/address.test.d.ts.map +1 -0
  160. package/dist/src/utils/address.test.js +32 -0
  161. package/dist/src/utils/address.test.js.map +1 -0
  162. package/dist/src/utils/cryptoAssets.d.ts +28 -0
  163. package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
  164. package/dist/src/utils/cryptoAssets.js +73 -0
  165. package/dist/src/utils/cryptoAssets.js.map +1 -0
  166. package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
  167. package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
  168. package/dist/src/utils/cryptoAssets.test.js +50 -0
  169. package/dist/src/utils/cryptoAssets.test.js.map +1 -0
  170. package/dist/src/utils/currency.d.ts +14 -0
  171. package/dist/src/utils/currency.d.ts.map +1 -0
  172. package/dist/src/utils/currency.js +27 -0
  173. package/dist/src/utils/currency.js.map +1 -0
  174. package/dist/src/utils/currency.test.d.ts +2 -0
  175. package/dist/src/utils/currency.test.d.ts.map +1 -0
  176. package/dist/src/utils/currency.test.js +34 -0
  177. package/dist/src/utils/currency.test.js.map +1 -0
  178. package/dist/src/utils/numbers.d.ts +26 -0
  179. package/dist/src/utils/numbers.d.ts.map +1 -0
  180. package/dist/src/utils/numbers.js +40 -0
  181. package/dist/src/utils/numbers.js.map +1 -0
  182. package/dist/src/utils/numbers.test.d.ts +2 -0
  183. package/dist/src/utils/numbers.test.d.ts.map +1 -0
  184. package/dist/src/utils/numbers.test.js +54 -0
  185. package/dist/src/utils/numbers.test.js.map +1 -0
  186. package/package.json +9 -3
  187. package/src/api/auth.ts +104 -129
  188. package/src/api/client.ts +78 -0
  189. package/src/api/fetch-error.ts +8 -0
  190. package/src/api/index.ts +2 -0
  191. package/src/api/portal.ts +56 -0
  192. package/src/assets/DefaultAvatar.tsx +74 -0
  193. package/src/components/Dropdown/AccountAddress.tsx +130 -0
  194. package/src/components/Dropdown/AccountAssets.tsx +110 -0
  195. package/src/components/Dropdown/AccountBalance.tsx +38 -0
  196. package/src/components/Dropdown/ConnectedTrigger.tsx +56 -0
  197. package/src/components/Dropdown/Content.tsx +148 -0
  198. package/src/components/Dropdown/DisconnectedTrigger.tsx +36 -0
  199. package/src/components/Dropdown/Dropdown.tsx +111 -0
  200. package/src/components/Dropdown/README.md +51 -0
  201. package/src/components/Dropdown/WelcomeBlock.tsx +92 -0
  202. package/src/components/Dropdown/index.ts +2 -0
  203. package/src/components/index.ts +1 -0
  204. package/src/hooks/constants.ts +4 -4
  205. package/src/hooks/index.ts +1 -4
  206. package/src/hooks/useAssetsUSDConversion.ts +31 -0
  207. package/src/hooks/useAuthenticateWithWallet.ts +98 -0
  208. package/src/hooks/useCreateAccount.ts +20 -11
  209. package/src/hooks/useCreateSession.ts +24 -18
  210. package/src/hooks/useDropdownData.ts +131 -0
  211. package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +46 -0
  212. package/src/hooks/useGetAccountByAddress.ts +11 -5
  213. package/src/hooks/useGetAccountByMezoId.ts +11 -5
  214. package/src/hooks/useGetCurrentAccount.ts +53 -7
  215. package/src/hooks/useGetSession.ts +10 -3
  216. package/src/hooks/useLinkAccount.ts +19 -31
  217. package/src/hooks/usePortalApiClient.ts +6 -0
  218. package/src/hooks/useSignInWithDiscord.ts +19 -28
  219. package/src/hooks/useSignInWithWallet.ts +14 -54
  220. package/src/hooks/useSignOut.ts +22 -6
  221. package/src/hooks/useSignUpWithWallet.ts +21 -0
  222. package/src/hooks/useUpdateMezoId.ts +20 -12
  223. package/src/hooks/useWalletAccount.ts +53 -0
  224. package/src/index.ts +1 -0
  225. package/src/provider.ts +30 -37
  226. package/src/utils/address.test.ts +38 -0
  227. package/src/utils/address.ts +43 -0
  228. package/src/utils/cryptoAssets.test.ts +61 -0
  229. package/src/utils/cryptoAssets.ts +93 -0
  230. package/src/utils/currency.test.ts +38 -0
  231. package/src/utils/currency.ts +32 -0
  232. package/src/utils/numbers.test.ts +73 -0
  233. package/src/utils/numbers.ts +55 -0
@@ -1,22 +1,18 @@
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 useUpdateMezoId(useMutationOptions = {}) {
4
+ export function useUpdateMezoId(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: (newMezoId) => authApiClient.updateMezoId(newMezoId),
9
- onSuccess: () => {
10
- queryClient.resetQueries({
11
- queryKey: [QUERY_KEYS.ACCOUNT_BY_ADDRESS],
12
- exact: false,
13
- });
14
- queryClient.resetQueries({
15
- queryKey: [QUERY_KEYS.ACCOUNT_BY_MEZO_ID],
16
- exact: false,
17
- });
10
+ onSuccess: (data, variables, context) => {
11
+ queryClient.resetQueries({ queryKey: [QUERY_KEYS.ACCOUNT] });
12
+ if (customOnSuccess)
13
+ customOnSuccess(data, variables, context);
18
14
  },
19
- ...useMutationOptions,
15
+ ...restMutationOptions,
20
16
  });
21
17
  return { updateMezoId: mutate, updateMezoIdAsync: mutateAsync, ...rest };
22
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useUpdateMezoId.js","sourceRoot":"","sources":["../../../src/hooks/useUpdateMezoId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,UAAU,eAAe,CAAC,kBAAkB,GAAG,EAAE;IACrD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,SAAS,CAAC;QACxE,SAAS,EAAE,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AAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC1E,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Address } from "viem";
2
+ import { Connector } from "wagmi";
3
+ type UseWalletAccountReturn = {
4
+ address?: string | Address;
5
+ isConnected: boolean;
6
+ networkFamily: "bitcoin" | "evm";
7
+ connector?: Connector;
8
+ chainId?: number;
9
+ };
10
+ export default function useWalletAccount(): UseWalletAccountReturn;
11
+ export {};
12
+ //# sourceMappingURL=useWalletAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWalletAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWalletAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAc,MAAM,OAAO,CAAA;AAE7C,KAAK,sBAAsB,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,SAAS,GAAG,KAAK,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAMD,MAAM,CAAC,OAAO,UAAU,gBAAgB,IAAI,sBAAsB,CAkCjE"}
@@ -0,0 +1,28 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { useMemo } from "react";
3
+ import { useAccount } from "wagmi";
4
+ export default function useWalletAccount() {
5
+ const { address: evmAddress, connector, chainId } = useAccount();
6
+ const networkFamily = useMemo(() => (connector?.type !== "orangekit" ? "evm" : "bitcoin"), [connector]);
7
+ const { data: btcData } = useQuery({
8
+ queryKey: [connector?.id],
9
+ queryFn: async () => {
10
+ const bitcoinProvider = connector.getBitcoinProvider();
11
+ const address = await bitcoinProvider.getAddress();
12
+ const balance = await bitcoinProvider.getBalance();
13
+ return {
14
+ address,
15
+ balance,
16
+ };
17
+ },
18
+ });
19
+ const { address: btcAddress } = btcData || {};
20
+ return {
21
+ address: networkFamily === "bitcoin" ? btcAddress : evmAddress,
22
+ isConnected: networkFamily === "bitcoin" ? !!btcAddress : !!evmAddress,
23
+ networkFamily,
24
+ connector,
25
+ chainId,
26
+ };
27
+ }
28
+ //# sourceMappingURL=useWalletAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWalletAccount.js","sourceRoot":"","sources":["../../../src/hooks/useWalletAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAa,UAAU,EAAE,MAAM,OAAO,CAAA;AAc7C,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACtC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAEhE,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,EAC3D,CAAC,SAAS,CAAC,CACZ,CAAA;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QACjC,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,eAAe,GACnB,SACD,CAAC,kBAAkB,EAAE,CAAA;YAEtB,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,CAAA;YAClD,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,CAAA;YAElD,OAAO;gBACL,OAAO;gBACP,OAAO;aACR,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAE7C,OAAO;QACL,OAAO,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;QAC9D,WAAW,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU;QACtE,aAAa;QACb,SAAS;QACT,OAAO;KACC,CAAA;AACZ,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from "./components";
1
2
  export * from "./config";
2
3
  export * from "./constants";
3
4
  export * from "./hooks";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
package/dist/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./components";
1
2
  export * from "./config";
2
3
  export * from "./constants";
3
4
  export * from "./hooks";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
@@ -1,20 +1,17 @@
1
- /// <reference types="react" />
2
- import { API_ENDPOINTS_BY_ENV, AuthApiClient } from "./api/auth";
1
+ import { AuthApiClient, PortalApiClient } from "./api";
3
2
  export interface PassportContextValue {
4
3
  authApiClient: AuthApiClient;
4
+ portalApiClient: PortalApiClient;
5
+ environment?: Environment;
5
6
  }
6
7
  export declare const PassportContext: import("react").Context<PassportContextValue | undefined>;
7
- interface PassportProviderProps {
8
- options: {
9
- environment?: keyof typeof API_ENDPOINTS_BY_ENV;
10
- apiUrl?: string;
11
- } & ({
12
- environment: keyof typeof API_ENDPOINTS_BY_ENV;
13
- } | {
14
- apiUrl: string;
15
- });
8
+ type Environment = "mainnet" | "testnet";
9
+ type PassportProviderProps = {
16
10
  children: React.ReactNode;
17
- }
18
- export declare function PassportProvider({ options, children }: PassportProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<PassportContextValue | undefined>>;
11
+ environment?: Environment;
12
+ authApiUrl?: string;
13
+ portalApiUrl?: string;
14
+ };
15
+ export declare function PassportProvider({ environment, authApiUrl, portalApiUrl, children, }: PassportProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<PassportContextValue | undefined>>;
19
16
  export {};
20
17
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED,eAAO,MAAM,eAAe,2DAE3B,CAAA;AAED,UAAU,qBAAqB;IAE7B,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,OAAO,oBAAoB,CAAA;QAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,CACA;QACE,WAAW,EAAE,MAAM,OAAO,oBAAoB,CAAA;KAC/C,GACD;QACE,MAAM,EAAE,MAAM,CAAA;KACf,CACJ,CAAA;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,qBAAqB,6GA6B5E"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAEtD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,aAAa,CAAA;IAC5B,eAAe,EAAE,eAAe,CAAA;IAChC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED,eAAO,MAAM,eAAe,2DAE3B,CAAA;AAED,KAAK,WAAW,GAAG,SAAS,GAAG,SAAS,CAAA;AAExC,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAEzB,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACT,EAAE,qBAAqB,6GAmBvB"}
@@ -1,25 +1,16 @@
1
- import { createContext, createElement, useMemo } from "react";
2
- import { API_ENDPOINTS_BY_ENV, AuthApiClient } from "./api/auth";
1
+ import { createContext, createElement } from "react";
2
+ import { AuthApiClient, PortalApiClient } from "./api";
3
3
  export const PassportContext = createContext(undefined);
4
- export function PassportProvider({ options, children }) {
5
- const { environment, apiUrl } = options;
6
- const finalApiUrl = useMemo(() => {
7
- if (!environment && !apiUrl) {
8
- throw new Error("Neither apiUrl or environment are specified in Passport Provider");
9
- }
10
- if (apiUrl)
11
- return apiUrl;
12
- if (!(environment in API_ENDPOINTS_BY_ENV)) {
13
- throw new Error("Wrong environment passed to PassportProvider.");
14
- }
15
- return API_ENDPOINTS_BY_ENV[environment];
16
- }, [environment, apiUrl]);
4
+ export function PassportProvider({ environment, authApiUrl, portalApiUrl, children, }) {
5
+ if (environment && !["mainnet", "testnet"].includes(environment)) {
6
+ throw new Error("Wrong environment passed to PassportProvider.");
7
+ }
17
8
  return createElement(PassportContext.Provider, {
18
- value: finalApiUrl
19
- ? {
20
- authApiClient: new AuthApiClient(finalApiUrl),
21
- }
22
- : undefined,
9
+ value: {
10
+ authApiClient: new AuthApiClient(environment ?? "mainnet", authApiUrl),
11
+ portalApiClient: new PortalApiClient(environment ?? "mainnet", portalApiUrl),
12
+ environment,
13
+ },
23
14
  }, children);
24
15
  }
25
16
  //# sourceMappingURL=provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAMhE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAC1C,SAAS,CACV,CAAA;AAkBD,MAAM,UAAU,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAyB;IAC3E,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAEvC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;QAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAA;QACH,CAAC;QACD,IA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AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Trims the address to the first 5 and last 5 characters.
3
+ * @param address The address to trim.
4
+ * @returns The trimmed address.
5
+ */
6
+ export declare function trimAddress(address: string): string;
7
+ /**
8
+ * Get the URL of the block explorer page for an address.
9
+ * @param address - The address to link to.
10
+ * @param chainType - The chain type of the address.
11
+ * @param isTestnet - Whether the address is on testnet.
12
+ * @returns The URL of the block explorer page for the address.
13
+ */
14
+ export declare function getAddressExplorerUrl(address: string, chainType: "bitcoin" | "evm", isTestnet: boolean): string;
15
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAYD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,KAAK,EAC5B,SAAS,EAAE,OAAO,UASnB"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Trims the address to the first 5 and last 5 characters.
3
+ * @param address The address to trim.
4
+ * @returns The trimmed address.
5
+ */
6
+ export function trimAddress(address) {
7
+ if (address.length < 11)
8
+ return address;
9
+ const trimmedAddress = `${address.slice(0, 5)}...${address.slice(-5)}`;
10
+ return trimmedAddress;
11
+ }
12
+ const MAINNET_EXPLORER_URLS = {
13
+ bitcoin: "https://mempool.space",
14
+ evm: "https://etherscan.io",
15
+ };
16
+ const TESTNET_EXPLORER_URLS = {
17
+ bitcoin: "https://mempool.space/testnet",
18
+ evm: "https://sepolia.etherscan.io",
19
+ };
20
+ /**
21
+ * Get the URL of the block explorer page for an address.
22
+ * @param address - The address to link to.
23
+ * @param chainType - The chain type of the address.
24
+ * @param isTestnet - Whether the address is on testnet.
25
+ * @returns The URL of the block explorer page for the address.
26
+ */
27
+ export function getAddressExplorerUrl(address, chainType, isTestnet) {
28
+ const EXPLORER_URLS = isTestnet
29
+ ? TESTNET_EXPLORER_URLS
30
+ : MAINNET_EXPLORER_URLS;
31
+ const baseUrl = EXPLORER_URLS[chainType];
32
+ const endpoint = `address/${address}`;
33
+ return `${baseUrl}/${endpoint}`;
34
+ }
35
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,OAAO,CAAA;IAEvC,MAAM,cAAc,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAEtE,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,MAAM,qBAAqB,GAAsC;IAC/D,OAAO,EAAE,uBAAuB;IAChC,GAAG,EAAE,sBAAsB;CAC5B,CAAA;AAED,MAAM,qBAAqB,GAAsC;IAC/D,OAAO,EAAE,+BAA+B;IACxC,GAAG,EAAE,8BAA8B;CACpC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,SAA4B,EAC5B,SAAkB;IAElB,MAAM,aAAa,GAAG,SAAS;QAC7B,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,qBAAqB,CAAA;IACzB,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;IACxC,MAAM,QAAQ,GAAG,WAAW,OAAO,EAAE,CAAA;IAErC,OAAO,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAA;AACjC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=address.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.test.d.ts","sourceRoot":"","sources":["../../../src/utils/address.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import { getAddressExplorerUrl, trimAddress } from "./address";
2
+ describe("trimAddress", () => {
3
+ it("returns full address if length is less than 11", () => {
4
+ expect(trimAddress("0x12345")).toBe("0x12345");
5
+ });
6
+ it("returns trimmed address if length is 11 or more", () => {
7
+ const input = "0x123456789abcdef";
8
+ const expected = "0x123...bcdef";
9
+ expect(trimAddress(input)).toBe(expected);
10
+ });
11
+ });
12
+ describe("getAddressExplorerUrl", () => {
13
+ const btcAddress = "bc1qxyz123";
14
+ const evmAddress = "0x1234567890abcdef";
15
+ it("returns correct mainnet Bitcoin explorer URL", () => {
16
+ const url = getAddressExplorerUrl(btcAddress, "bitcoin", false);
17
+ expect(url).toBe(`https://mempool.space/address/${btcAddress}`);
18
+ });
19
+ it("returns correct testnet Bitcoin explorer URL", () => {
20
+ const url = getAddressExplorerUrl(btcAddress, "bitcoin", true);
21
+ expect(url).toBe(`https://mempool.space/testnet/address/${btcAddress}`);
22
+ });
23
+ it("returns correct mainnet EVM explorer URL", () => {
24
+ const url = getAddressExplorerUrl(evmAddress, "evm", false);
25
+ expect(url).toBe(`https://etherscan.io/address/${evmAddress}`);
26
+ });
27
+ it("returns correct testnet EVM explorer URL", () => {
28
+ const url = getAddressExplorerUrl(evmAddress, "evm", true);
29
+ expect(url).toBe(`https://sepolia.etherscan.io/address/${evmAddress}`);
30
+ });
31
+ });
32
+ //# sourceMappingURL=address.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.test.js","sourceRoot":"","sources":["../../../src/utils/address.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE9D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAA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C,CAAA;QAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,wCAAwC,UAAU,EAAE,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { IconProps } from "@mezo-org/mezo-clay";
2
+ import { FC } from "react";
3
+ export type CryptoAssetKey = "btc" | "eth" | "tbtc" | "wbtc" | "mbtc" | "musd";
4
+ export type CryptoAsset = {
5
+ name: string;
6
+ symbol: string;
7
+ icon: FC<IconProps>;
8
+ decimals: number;
9
+ };
10
+ /**
11
+ * Gets details of given crypto asset
12
+ * @param key The key of crypto asset
13
+ * @returns The crypto asset details
14
+ */
15
+ export declare function getCryptoAsset(key: CryptoAssetKey): CryptoAsset;
16
+ /**
17
+ * Checks if given crypto asset is Bitcoin-like
18
+ * @param key The key of crypto asset
19
+ * @returns True if crypto asset is Bitcoin-like
20
+ */
21
+ export declare function isBitcoinLikeCryptoAsset(key: CryptoAssetKey): boolean;
22
+ /**
23
+ * Checks if given crypto asset is USD-like
24
+ * @param key The key of crypto asset
25
+ * @returns True if crypto asset is USD-like
26
+ */
27
+ export declare function isUsdLikeCryptoAsset(key: CryptoAssetKey): boolean;
28
+ //# sourceMappingURL=cryptoAssets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cryptoAssets.d.ts","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAiB,EAAE,EAAE,MAAM,OAAO,CAAA;AAEzC,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAmDD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,eAEjD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,WAE3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,WAEvD"}
@@ -0,0 +1,73 @@
1
+ import { BitcoinCircle, EthCircle, MUsdCircle, TBtcCircle, } from "@mezo-org/mezo-clay";
2
+ import { createElement } from "react";
3
+ const CRYPTO_ASSETS = {
4
+ btc: {
5
+ name: "Bitcoin",
6
+ symbol: "BTC",
7
+ icon: BitcoinCircle,
8
+ decimals: 8,
9
+ },
10
+ eth: {
11
+ name: "Ethereum",
12
+ symbol: "ETH",
13
+ icon: EthCircle,
14
+ decimals: 18,
15
+ },
16
+ tbtc: {
17
+ name: "Threshold Bitcoin",
18
+ symbol: "tBTC",
19
+ icon: TBtcCircle,
20
+ decimals: 18,
21
+ },
22
+ wbtc: {
23
+ name: "Wrapped Bitcoin",
24
+ symbol: "wBTC",
25
+ icon: (props) => createElement(BitcoinCircle, {
26
+ ...props,
27
+ symbolColor: "#FF8A00",
28
+ color: "#000000",
29
+ }),
30
+ decimals: 8,
31
+ },
32
+ mbtc: {
33
+ name: "Matsnet Bitcoin",
34
+ symbol: "BTC",
35
+ icon: (props) => createElement(BitcoinCircle, {
36
+ ...props,
37
+ symbolColor: "#000000",
38
+ color: "#FFC907",
39
+ }),
40
+ decimals: 18,
41
+ },
42
+ musd: {
43
+ name: "Mezo USD",
44
+ symbol: "MUSD",
45
+ icon: MUsdCircle,
46
+ decimals: 18,
47
+ },
48
+ };
49
+ /**
50
+ * Gets details of given crypto asset
51
+ * @param key The key of crypto asset
52
+ * @returns The crypto asset details
53
+ */
54
+ export function getCryptoAsset(key) {
55
+ return CRYPTO_ASSETS[key];
56
+ }
57
+ /**
58
+ * Checks if given crypto asset is Bitcoin-like
59
+ * @param key The key of crypto asset
60
+ * @returns True if crypto asset is Bitcoin-like
61
+ */
62
+ export function isBitcoinLikeCryptoAsset(key) {
63
+ return ["btc", "tbtc", "wbtc", "mbtc"].includes(key);
64
+ }
65
+ /**
66
+ * Checks if given crypto asset is USD-like
67
+ * @param key The key of crypto asset
68
+ * @returns True if crypto asset is USD-like
69
+ */
70
+ export function isUsdLikeCryptoAsset(key) {
71
+ return ["musd"].includes(key);
72
+ }
73
+ //# sourceMappingURL=cryptoAssets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cryptoAssets.js","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EAET,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAM,MAAM,OAAO,CAAA;AAWzC,MAAM,aAAa,GAAwC;IACzD,GAAG,EAAE;QACH,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,CAAC;KACZ;IACD,GAAG,EAAE;QACH,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,aAAa,CAAC,aAAa,EAAE;YAC3B,GAAG,KAAK;YACR,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,SAAS;SACjB,CAAC;QACJ,QAAQ,EAAE,CAAC;KACZ;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,aAAa,CAAC,aAAa,EAAE;YAC3B,GAAG,KAAK;YACR,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,SAAS;SACjB,CAAC;QACJ,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,EAAE;KACb;CACF,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAmB;IAChD,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAmB;IAC1D,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cryptoAssets.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cryptoAssets.test.d.ts","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { BitcoinCircle, EthCircle, MUsdCircle, TBtcCircle, } from "@mezo-org/mezo-clay";
2
+ import { getCryptoAsset } from "./cryptoAssets";
3
+ // FIXME: Test fails if run in full suite (pnpm test) but works when run in isolation (pnpm test cryptoAssets)
4
+ describe("getCryptoAsset", () => {
5
+ it("returns the correct asset for 'btc'", () => {
6
+ const asset = getCryptoAsset("btc");
7
+ expect(asset.name).toBe("Bitcoin");
8
+ expect(asset.symbol).toBe("BTC");
9
+ expect(asset.decimals).toBe(8);
10
+ expect(asset.icon).toBe(BitcoinCircle);
11
+ });
12
+ it("returns the correct asset for 'eth'", () => {
13
+ const asset = getCryptoAsset("eth");
14
+ expect(asset.name).toBe("Ethereum");
15
+ expect(asset.symbol).toBe("ETH");
16
+ expect(asset.decimals).toBe(18);
17
+ expect(asset.icon).toBe(EthCircle);
18
+ });
19
+ it("returns the correct asset for 'tbtc'", () => {
20
+ const asset = getCryptoAsset("tbtc");
21
+ expect(asset.name).toBe("Threshold Bitcoin");
22
+ expect(asset.symbol).toBe("tBTC");
23
+ expect(asset.decimals).toBe(18);
24
+ expect(asset.icon).toBe(TBtcCircle);
25
+ });
26
+ it("returns the correct asset for 'wbtc'", () => {
27
+ const asset = getCryptoAsset("wbtc");
28
+ expect(asset.name).toBe("Wrapped Bitcoin");
29
+ expect(asset.symbol).toBe("wBTC");
30
+ expect(asset.decimals).toBe(8);
31
+ // FIXME: Test should expect the exact icon component
32
+ expect(asset.icon).toEqual(expect.any(Function));
33
+ });
34
+ it("returns the correct asset for 'mbtc'", () => {
35
+ const asset = getCryptoAsset("mbtc");
36
+ expect(asset.name).toBe("Matsnet Bitcoin");
37
+ expect(asset.symbol).toBe("BTC");
38
+ expect(asset.decimals).toBe(18);
39
+ // FIXME: Test should expect the exact icon component
40
+ expect(asset.icon).toEqual(expect.any(Function));
41
+ });
42
+ it("returns the correct asset for 'musd'", () => {
43
+ const asset = getCryptoAsset("musd");
44
+ expect(asset.name).toBe("Mezo USD");
45
+ expect(asset.symbol).toBe("MUSD");
46
+ expect(asset.decimals).toBe(18);
47
+ expect(asset.icon).toBe(MUsdCircle);
48
+ });
49
+ });
50
+ //# sourceMappingURL=cryptoAssets.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cryptoAssets.test.js","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,qB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EAAE;QAC9C,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;QACpC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACnC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC/B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Formats a number as a currency
3
+ * @param value The value to format
4
+ * @param options The options to pass to the formatter
5
+ * @returns The formatted currency
6
+ */
7
+ export declare function formatCurrency(value: number, options?: Omit<Intl.NumberFormatOptions, "style">): string;
8
+ /**
9
+ * Formats a number as a USD currency
10
+ * @param value The value to format
11
+ * @returns The formatted currency
12
+ */
13
+ export declare function formatUsd(value: number): string;
14
+ //# sourceMappingURL=currency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/utils/currency.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAM,GACpD,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -0,0 +1,27 @@
1
+ const DEFAULT_FORMAT_OPTIONS = {
2
+ style: "currency",
3
+ minimumFractionDigits: 2,
4
+ maximumFractionDigits: 2,
5
+ };
6
+ /**
7
+ * Formats a number as a currency
8
+ * @param value The value to format
9
+ * @param options The options to pass to the formatter
10
+ * @returns The formatted currency
11
+ */
12
+ export function formatCurrency(value, options = {}) {
13
+ const formatter = new Intl.NumberFormat("en-US", {
14
+ ...DEFAULT_FORMAT_OPTIONS,
15
+ ...options,
16
+ });
17
+ return formatter.format(value);
18
+ }
19
+ /**
20
+ * Formats a number as a USD currency
21
+ * @param value The value to format
22
+ * @returns The formatted currency
23
+ */
24
+ export function formatUsd(value) {
25
+ return formatCurrency(value, { currency: "USD" });
26
+ }
27
+ //# sourceMappingURL=currency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/utils/currency.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAA6B;IACvD,KAAK,EAAE,UAAU;IACjB,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;CACzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAa,EACb,UAAmD,EAAE;IAErD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QAC/C,GAAG,sBAAsB;QACzB,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,cAAc,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;AACnD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=currency.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.test.d.ts","sourceRoot":"","sources":["../../../src/utils/currency.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import { formatCurrency, formatUsd } from "./currency";
2
+ describe("formatCurrency", () => {
3
+ it("formats a number as currency with default options", () => {
4
+ const result = formatCurrency(1234.5, { currency: "EUR" });
5
+ expect(result).toBe("€1,234.50");
6
+ });
7
+ it("respects minimumFractionDigits (min = 3, max = 3)", () => {
8
+ const result = formatCurrency(1.2, {
9
+ currency: "USD",
10
+ minimumFractionDigits: 3,
11
+ maximumFractionDigits: 3,
12
+ });
13
+ expect(result).toBe("$1.200");
14
+ });
15
+ it("respects maximumFractionDigits (min = 0, max = 1)", () => {
16
+ const result = formatCurrency(1.234567, {
17
+ currency: "USD",
18
+ minimumFractionDigits: 0,
19
+ maximumFractionDigits: 1,
20
+ });
21
+ expect(result).toBe("$1.2");
22
+ });
23
+ });
24
+ describe("formatUsd", () => {
25
+ it("formats a number as USD", () => {
26
+ const result = formatUsd(99.99);
27
+ expect(result).toBe("$99.99");
28
+ });
29
+ it("formats zero", () => {
30
+ const result = formatUsd(0);
31
+ expect(result).toBe("$0.00");
32
+ });
33
+ });
34
+ //# sourceMappingURL=currency.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.test.js","sourceRoot":"","sources":["../../../src/utils/currency.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,EAAE;YACjC,QAAQ,EAAE,KAAK;YACf,qBAAqB,EAAE,CAAC;YACxB,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAA;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,EAAE;YACtC,QAAQ,EAAE,KAAK;YACf,qBAAqB,EAAE,CAAC;YACxB,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAA;QACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Formats a number or bigint into a human-readable string with K, M, B, or T suffix.
3
+ * @param value The number or bigint to format.
4
+ * @param decimals Number of decimal places to include (ignored for bigint to avoid floating point issues).
5
+ * @returns The formatted number as a string.
6
+ */
7
+ export declare function formatHumanReadableNumber(value: number | bigint, decimals?: number): string;
8
+ /**
9
+ * Returns a number rounded up to the desired number of decimals.
10
+ * @param amount The number to round up.
11
+ * @param desiredDecimals The number of decimals to round up to.
12
+ * @returns The rounded up number.
13
+ * @see https://github.com/thesis/acre/blob/2078d339f4ddce79e69c78529c9d72910dd2640a/dapp/src/utils/numbersUtils.ts#L1-L3
14
+ */
15
+ export declare function roundUpNumber(amount: number, desiredDecimals?: number): number;
16
+ /**
17
+ * Convert a fixed point bigint with precision `fixedPointDecimals` to a
18
+ * floating point number truncated to `desiredDecimals`.
19
+ * @param fixedPoint The fixed point bigint to convert.
20
+ * @param fixedPointDecimals The number of decimals in the fixed point bigint.
21
+ * @param desiredDecimals The number of decimals in the output number.
22
+ * @returns The floating point number truncated to `desiredDecimals`.
23
+ * @see https://github.com/tahowallet/extension/blob/f6b26b7cb4a0a0278b1fccc6319626638f1a6dfa/background/lib/fixed-point.ts#L216-L239
24
+ */
25
+ export declare function fromFixedPoint(fixedPoint: bigint, fixedPointDecimals: number, desiredDecimals?: number): number;
26
+ //# sourceMappingURL=numbers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../../src/utils/numbers.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,SAAI,GACX,MAAM,CAMR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,SAAI,GAAG,MAAM,CAEzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,SAAI,GAClB,MAAM,CAUR"}