@mezo-org/passport 0.11.0 → 0.12.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cjs/index.js +68 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/dist/esm/index.js +68 -0
  4. package/dist/esm/index.js.map +1 -0
  5. package/dist/index.d.ts +31 -0
  6. package/dist/src/components/Dropdown/AccountAddress.d.ts +8 -0
  7. package/dist/src/components/Dropdown/AccountAddress.d.ts.map +1 -0
  8. package/dist/src/components/Dropdown/AccountAddress.js +66 -0
  9. package/dist/src/components/Dropdown/AccountAddress.js.map +1 -0
  10. package/dist/src/components/Dropdown/AccountAssets.d.ts +13 -0
  11. package/dist/src/components/Dropdown/AccountAssets.d.ts.map +1 -0
  12. package/dist/src/components/Dropdown/AccountAssets.js +43 -0
  13. package/dist/src/components/Dropdown/AccountAssets.js.map +1 -0
  14. package/dist/src/components/Dropdown/AccountBalance.d.ts +7 -0
  15. package/dist/src/components/Dropdown/AccountBalance.d.ts.map +1 -0
  16. package/dist/src/components/Dropdown/AccountBalance.js +16 -0
  17. package/dist/src/components/Dropdown/AccountBalance.js.map +1 -0
  18. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
  19. package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
  20. package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
  21. package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
  22. package/dist/src/components/Dropdown/WelcomeBlock.d.ts +8 -0
  23. package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +1 -0
  24. package/dist/src/components/Dropdown/WelcomeBlock.js +43 -0
  25. package/dist/src/components/Dropdown/WelcomeBlock.js.map +1 -0
  26. package/dist/src/hooks/useAssetsUSDConversion.d.ts +8 -0
  27. package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +1 -0
  28. package/dist/src/hooks/useAssetsUSDConversion.js +21 -0
  29. package/dist/src/hooks/useAssetsUSDConversion.js.map +1 -0
  30. package/dist/src/hooks/useDropdownData.d.ts +47 -0
  31. package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
  32. package/dist/src/hooks/useDropdownData.js +97 -0
  33. package/dist/src/hooks/useDropdownData.js.map +1 -0
  34. package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
  35. package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
  36. package/dist/src/lib/contracts/priceOracle.js +52 -0
  37. package/dist/src/lib/contracts/priceOracle.js.map +1 -0
  38. package/dist/src/lib/contracts/troveManager.d.ts +1401 -0
  39. package/dist/src/lib/contracts/troveManager.d.ts.map +1 -0
  40. package/dist/src/lib/contracts/troveManager.js +1820 -0
  41. package/dist/src/lib/contracts/troveManager.js.map +1 -0
  42. package/dist/src/utils/cryptoAssets.d.ts +44 -0
  43. package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
  44. package/dist/src/utils/cryptoAssets.js +129 -0
  45. package/dist/src/utils/cryptoAssets.js.map +1 -0
  46. package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
  47. package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
  48. package/dist/src/utils/cryptoAssets.test.js +67 -0
  49. package/dist/src/utils/cryptoAssets.test.js.map +1 -0
  50. package/package.json +20 -22
@@ -0,0 +1,31 @@
1
+ import * as _mezo_org_orangekit from '@mezo-org/orangekit';
2
+ export { BitcoinWalletConnectionError, WalletNetworkDoesNotMatchProviderChainError, getOKXWallet, getUnisatWallet, getXverseWallet, isUnsupportedBitcoinAddressError, isWalletNetworkDoesNotMatchProviderChainError, mezoMatsnetTestnet, useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain } from '@mezo-org/orangekit';
3
+ import { WalletList, Chain } from '@rainbow-me/rainbowkit';
4
+ import { CreateConfigParameters, Config } from 'wagmi';
5
+
6
+ type WagmiConfigParameters = Omit<CreateConfigParameters, "client" | "connectors" | "chains" | "wallets" | "transports">;
7
+ type GetDefaultConfigParameters = WagmiConfigParameters & {
8
+ appName: string;
9
+ appDescription?: string;
10
+ appUrl?: string;
11
+ appIcon?: string;
12
+ bitcoinWallets?: WalletList;
13
+ walletConnectProjectId?: string;
14
+ chains?: [Chain, ...Chain[]];
15
+ transports?: Pick<CreateConfigParameters, "transports">;
16
+ };
17
+ declare const defaultConfig: Required<Pick<GetDefaultConfigParameters, "transports" | "walletConnectProjectId" | "chains" | "multiInjectedProviderDiscovery">>;
18
+ declare const unisatWallet: _mezo_org_orangekit.CreateWalletFn;
19
+ declare const okxWallet: _mezo_org_orangekit.CreateWalletFn;
20
+ declare const xverseWallet: _mezo_org_orangekit.CreateWalletFn;
21
+ declare function getDefaultWallets(): WalletList;
22
+ declare function getConfig({ appName, bitcoinWallets, walletConnectProjectId, ...restParameters }: GetDefaultConfigParameters): Config;
23
+
24
+ declare const CHAIN_ID: {
25
+ testnet: 31611;
26
+ };
27
+ declare const RPC_BY_NETWORK: {
28
+ testnet: "https://rpc.test.mezo.org";
29
+ };
30
+
31
+ export { CHAIN_ID, RPC_BY_NETWORK, defaultConfig, getConfig, getDefaultWallets, okxWallet, unisatWallet, xverseWallet };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ type AccountAddressProps = {
3
+ address: string;
4
+ type: "bitcoin" | "evm";
5
+ };
6
+ export default function AccountAddress(props: AccountAddressProps): React.JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=AccountAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAddress.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAddress.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAgC,MAAM,OAAO,CAAA;AAMpD,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,GAAG,KAAK,CAAA;CACxB,CAAA;AAID,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBA6GhE"}
@@ -0,0 +1,66 @@
1
+ import { Block, Copy03 as CopyIcon, LinkExternal02 as LinkIcon, ParagraphSmall, useStyletron, } from "@mezo-org/mezo-clay";
2
+ import React, { useCallback, useState } from "react";
3
+ import { useCopyToClipboard } from "usehooks-ts";
4
+ import { usePassportContext } from "../../hooks/usePassportContext";
5
+ import { getAddressExplorerUrl, trimAddress } from "../../utils/address";
6
+ import { getCryptoAsset } from "../../utils/cryptoAssets";
7
+ // TODO: Add visual feedback on copy
8
+ export default function AccountAddress(props) {
9
+ const { address, type } = props;
10
+ const { environment } = usePassportContext();
11
+ const blockExplorerUrl = getAddressExplorerUrl(address, type, environment === "testnet");
12
+ const trimmedAddress = trimAddress(address);
13
+ const { icon: accountIcon } = getCryptoAsset(type === "bitcoin" ? "btc" : "eth");
14
+ const [, theme] = useStyletron();
15
+ const [, copy] = useCopyToClipboard();
16
+ const [isCopiedMessageVisible, setIsCopiedMessageVisible] = useState(false);
17
+ const handleCopyAddress = useCallback(() => {
18
+ copy(address);
19
+ setIsCopiedMessageVisible(true);
20
+ setTimeout(() => {
21
+ setIsCopiedMessageVisible(false);
22
+ }, 2000);
23
+ }, [copy, address]);
24
+ return (React.createElement(Block, { as: "button", onClick: handleCopyAddress, display: "flex", alignItems: "center", backgroundColor: "transparent", padding: `${theme.sizing.scale600} ${theme.sizing.scale500}`, overrides: {
25
+ Block: {
26
+ style: {
27
+ borderWidth: 0,
28
+ cursor: "pointer",
29
+ ":hover": {
30
+ backgroundColor: theme.colors.backgroundTertiary,
31
+ },
32
+ },
33
+ },
34
+ } },
35
+ React.createElement(Block, { as: accountIcon, size: theme.sizing.scale600 }),
36
+ isCopiedMessageVisible ? (React.createElement(ParagraphSmall, { margin: 0, marginLeft: theme.sizing.scale300, color: theme.colors.gray800 }, "Copied address to clipboard")) : (React.createElement(Block, { as: "a", marginLeft: theme.sizing.scale300, href: blockExplorerUrl, target: "_blank", overrides: {
37
+ Block: {
38
+ style: {
39
+ color: "inherit",
40
+ textDecoration: "none",
41
+ ":hover": {
42
+ textDecoration: "underline",
43
+ },
44
+ },
45
+ },
46
+ } },
47
+ React.createElement(ParagraphSmall, { display: "flex", alignItems: "center", margin: 0, color: theme.colors.gray800 },
48
+ trimmedAddress,
49
+ React.createElement(LinkIcon, { display: "inline", size: theme.sizing.scale550, overrides: {
50
+ Svg: {
51
+ style: {
52
+ stroke: "currentColor",
53
+ marginLeft: theme.sizing.scale200,
54
+ },
55
+ },
56
+ } })))),
57
+ React.createElement(CopyIcon, { size: theme.sizing.scale550, overrides: {
58
+ Svg: {
59
+ style: {
60
+ marginLeft: "auto",
61
+ stroke: "currentColor",
62
+ },
63
+ },
64
+ } })));
65
+ }
66
+ //# sourceMappingURL=AccountAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAddress.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAddress.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,QAAQ,EAClB,cAAc,IAAI,QAAQ,EAC1B,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAOzD,oCAAoC;AAEpC,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAA0B;IAC/D,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAE/B,MAAM,EAAE,WAAW,EAAE,G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BACvB;iBACF;aACF,GACD,CACI,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { CryptoAssetKey } from "../../utils/cryptoAssets";
3
+ type AccountAssetsProps = {
4
+ label: string | React.ReactNode;
5
+ assets: {
6
+ type: CryptoAssetKey;
7
+ balance: string;
8
+ balanceInUsd: string;
9
+ }[];
10
+ };
11
+ export default function AccountAssets(props: AccountAssetsProps): React.JSX.Element | null;
12
+ export {};
13
+ //# sourceMappingURL=AccountAssets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAssets.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAssets.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAkB,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,cAAc,EAAkB,MAAM,0BAA0B,CAAA;AAEzE,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,cAAc,CAAA;QACpB,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;KACrB,EAAE,CAAA;CACJ,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,kBAAkB,4BAyF9D"}
@@ -0,0 +1,43 @@
1
+ import { Block, LabelSmall, ParagraphSmall, useStyletron, } from "@mezo-org/mezo-clay";
2
+ import React, { useMemo } from "react";
3
+ import { getCryptoAsset } from "../../utils/cryptoAssets";
4
+ export default function AccountAssets(props) {
5
+ const { label, assets } = props;
6
+ const [, theme] = useStyletron();
7
+ const assetsData = useMemo(() => assets.map((token) => {
8
+ const { name, symbol, icon } = getCryptoAsset(token.type);
9
+ return {
10
+ ...token,
11
+ icon,
12
+ label: name,
13
+ symbol,
14
+ };
15
+ }), [assets]);
16
+ const labelContent = typeof label === "string" ? (React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray800 }, label)) : (label);
17
+ if (assetsData.length === 0) {
18
+ return null;
19
+ }
20
+ return (React.createElement(Block, { padding: `0 ${theme.sizing.scale500}` },
21
+ React.createElement(Block, { margin: `${theme.sizing.scale400} 0` }, labelContent),
22
+ React.createElement(Block, { as: "ul", marginBottom: theme.sizing.scale600, padding: 0, display: "flex", flexDirection: "column", overrides: {
23
+ Block: {
24
+ style: {
25
+ gap: theme.sizing.scale100,
26
+ },
27
+ },
28
+ } }, assetsData.map((asset) => (React.createElement(Block, { as: "li", key: `${asset.type}-${asset.balance}`, display: "flex", justifyContent: "space-between", alignItems: "center", margin: `${theme.sizing.scale100} 0` },
29
+ React.createElement(asset.icon, { size: theme.sizing.scale800, overrides: {
30
+ Svg: {
31
+ style: {
32
+ marginRight: theme.sizing.scale500,
33
+ },
34
+ },
35
+ } }),
36
+ React.createElement(Block, { flex: 1 },
37
+ React.createElement(LabelSmall, { margin: 0 }, asset.label),
38
+ React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray500 }, asset.symbol)),
39
+ React.createElement(Block, { display: "flex", alignItems: "end", flexDirection: "column" },
40
+ React.createElement(LabelSmall, { margin: 0 }, asset.balance),
41
+ React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray500 }, asset.balanceInUsd))))))));
42
+ }
43
+ //# sourceMappingURL=AccountAssets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAssets.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountAssets.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAkB,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAWzE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAyB;IAC7D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA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AK,EAAE,EAAE,CAAC,CACzB,oBAAC,KAAK,IACJ,EAAE,EAAC,IAAI,EACP,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,EACrC,OAAO,EAAC,MAAM,EACd,cAAc,EAAC,eAAe,EAC9B,UAAU,EAAC,QAAQ,EACnB,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,IAAI;YAEpC,oBAAC,KAAK,CAAC,IAAI,IACT,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC3B,SAAS,EAAE;oBACT,GAAG,EAAE;wBACH,KAAK,EAAE;4BACL,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ;yBACnC;qBACF;iBACF,GACD;YAEF,oBAAC,KAAK,IAAC,IAAI,EAAE,CAAC;gBACZ,oBAAC,UAAU,IAAC,MAAM,EAAE,CAAC,IAAG,KAAK,CAAC,KAAK,CAAc;gBACjD,oBAAC,cAAc,IAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,IACnD,KAAK,CAAC,MAAM,CACE,CACX;YAER,oBAAC,KAAK,IAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAC,KAAK,EAAC,aAAa,EAAC,QAAQ;gBAC3D,oBAAC,UAAU,IAAC,MAAM,EAAE,CAAC,IAAG,KAAK,CAAC,OAAO,CAAc;gBACnD,oBAAC,cAAc,IAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,IACnD,KAAK,CAAC,YAAY,CACJ,CACX,CACF,CACT,CAAC,CACI,CACF,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ type AccountBalanceProps = {
3
+ amount: string;
4
+ };
5
+ export default function AccountBalance(props: AccountBalanceProps): React.JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=AccountBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountBalance.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountBalance.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAsBhE"}
@@ -0,0 +1,16 @@
1
+ import { Block, HeadingSmall, ParagraphSmall, useStyletron, } from "@mezo-org/mezo-clay";
2
+ import React from "react";
3
+ export default function AccountBalance(props) {
4
+ const { amount } = props;
5
+ const [, theme] = useStyletron();
6
+ return (React.createElement(Block, { padding: theme.sizing.scale500, overrides: {
7
+ Block: {
8
+ style: {
9
+ borderBottom: `1px solid ${theme.colors.backgroundPrimary}`,
10
+ },
11
+ },
12
+ } },
13
+ React.createElement(ParagraphSmall, { margin: 0, color: theme.colors.gray800 }, "Available balance"),
14
+ React.createElement(HeadingSmall, { margin: 0 }, amount)));
15
+ }
16
+ //# sourceMappingURL=AccountBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountBalance.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/AccountBalance.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAA0B;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IAExB,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,YAAY,EAAE,CAAA;IAEhC,OAAO,CACL,oBAAC,KAAK,IACJ,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC9B,SAAS,EAAE;YACT,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,YAAY,EAAE,aAAa,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE;iBAC5D;aACF;SACF;QAED,oBAAC,cAAc,IAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,wBAErC;QACjB,oBAAC,YAAY,IAAC,MAAM,EAAE,CAAC,IAAG,MAAM,CAAgB,CAC1C,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { CryptoAssetKey } from "../../../utils/cryptoAssets";
3
+ type AccountAssetItemProps = {
4
+ type: CryptoAssetKey;
5
+ amount: string;
6
+ subLabel: string;
7
+ subValue: string;
8
+ };
9
+ export default function AccountAssetItem(props: AccountAssetItemProps): React.JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=AccountAssetItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAssetItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Dropdown/Root/AccountAssetItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,cAAc,EAAkB,MAAM,6BAA6B,CAAA;AAG5E,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,cAAc,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAcpE"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { getCryptoAsset } from "../../../utils/cryptoAssets";
3
+ import ListingItem from "../ListingItem";
4
+ export default function AccountAssetItem(props) {
5
+ const { type, amount, subLabel, subValue } = props;
6
+ const { icon: Icon, name: label } = getCryptoAsset(type);
7
+ return (React.createElement(ListingItem, { icon: Icon, label: label, subLabel: subLabel, value: amount, subValue: subValue }));
8
+ }
9
+ //# sourceMappingURL=AccountAssetItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAssetItem.js","sourceRoot":"","sources":["../../../../../src/components/Dropdown/Root/AccountAssetItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAkB,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,WAAW,MAAM,gBAAgB,CAAA;AASxC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAA4B;IACnE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAElD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;IAExD,OAAO,CACL,oBAAC,WAAW,IACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ type WelcomeBlockProps = {
3
+ mezoId: string;
4
+ matsBalance: string;
5
+ };
6
+ export default function WelcomeBlock(props: WelcomeBlockProps): React.JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=WelcomeBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WelcomeBlock.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/WelcomeBlock.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBAyE5D"}
@@ -0,0 +1,43 @@
1
+ import { Block, HeadingSmall, LabelSmall, Mats, useStyletron, } from "@mezo-org/mezo-clay";
2
+ import React from "react";
3
+ import DefaultAvatar from "../../assets/DefaultAvatar";
4
+ const DOT_DELIMITER_REGEX = /(?=\.)/;
5
+ export default function WelcomeBlock(props) {
6
+ const { mezoId, matsBalance } = props;
7
+ const [name, nameSuffix] = mezoId.split(DOT_DELIMITER_REGEX);
8
+ const [, theme] = useStyletron();
9
+ return (React.createElement(Block, { display: "flex", alignItems: "center", padding: `${theme.sizing.scale600} 0`, marginBottom: theme.sizing.scale300, overrides: {
10
+ Block: {
11
+ style: {
12
+ gap: theme.sizing.scale600,
13
+ },
14
+ },
15
+ } },
16
+ React.createElement(Block, { as: DefaultAvatar, width: theme.sizing.scale1200, height: theme.sizing.scale1200, overrides: {
17
+ Block: {
18
+ style: {
19
+ borderRadius: "100%",
20
+ },
21
+ },
22
+ } }),
23
+ React.createElement(Block, { display: "flex", flexDirection: "column", overrides: {
24
+ Block: {
25
+ style: {
26
+ gap: theme.sizing.scale100,
27
+ },
28
+ },
29
+ } },
30
+ React.createElement(HeadingSmall, { as: "span" },
31
+ React.createElement(Block, { as: "span" }, name),
32
+ React.createElement(Block, { as: "span", color: theme.colors.gray500 }, nameSuffix)),
33
+ React.createElement(LabelSmall, { display: "flex", alignItems: "center", margin: 0, color: theme.colors.contentTertiary, overrides: {
34
+ Block: {
35
+ style: {
36
+ gap: theme.sizing.scale300,
37
+ },
38
+ },
39
+ } },
40
+ React.createElement(Mats, { color: theme.colors.contentPrimary, size: theme.sizing.scale600 }),
41
+ matsBalance))));
42
+ }
43
+ //# sourceMappingURL=WelcomeBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WelcomeBlock.js","sourceRoot":"","sources":["../../../../src/components/Dropdown/WelcomeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAA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C,MAAM,EAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,IACzC,UAAU,CACL,CACK;YAEf,oBAAC,UAAU,IACT,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,QAAQ,EACnB,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe,EACnC,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,KAAK,EAAE;4BACL,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ;yBAC3B;qBACF;iBACF;gBAED,oBAAC,IAAI,IACH,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,EAClC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,GAC3B;gBACD,WAAW,CACD,CACP,CACF,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { UseBaseQueryOptions } from "@tanstack/react-query";
2
+ type AssetsUsdConversion = {
3
+ btcUsd: string;
4
+ ethUsd: string;
5
+ };
6
+ export declare function useAssetsUsdConversion(useQueryOptions?: Partial<UseBaseQueryOptions<AssetsUsdConversion>>): import("@tanstack/react-query").UseQueryResult<AssetsUsdConversion, Error>;
7
+ export {};
8
+ //# sourceMappingURL=useAssetsUSDConversion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAssetsUSDConversion.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAssetsUSDConversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAKrE,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,sBAAsB,CACpC,eAAe,GAAE,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAM,8EAmBxE"}
@@ -0,0 +1,21 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { ONE_MINUTE_MS } from "../utils/time";
3
+ import { QUERY_KEYS } from "./constants";
4
+ import { usePortalApiClient } from "./usePortalApiClient";
5
+ export function useAssetsUsdConversion(useQueryOptions = {}) {
6
+ const portalApiClient = usePortalApiClient();
7
+ return useQuery({
8
+ queryKey: [QUERY_KEYS.ASSETS_USD_CONVERSION],
9
+ queryFn: async () => {
10
+ const { currentUsdPerBtc, currentUsdPerEth } = await portalApiClient.getPortalStatistics();
11
+ return {
12
+ btcUsd: currentUsdPerBtc,
13
+ ethUsd: currentUsdPerEth,
14
+ };
15
+ },
16
+ staleTime: 30 * ONE_MINUTE_MS,
17
+ retry: 1,
18
+ ...useQueryOptions,
19
+ });
20
+ }
21
+ //# sourceMappingURL=useAssetsUSDConversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAssetsUSDConversion.js","sourceRoot":"","sources":["../../../src/hooks/useAssetsUSDConversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAOzD,MAAM,UAAU,sBAAsB,CACpC,kBAAqE,EAAE;IAEvE,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAE5C,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC;QAC5C,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAC1C,MAAM,eAAe,CAAC,mBAAmB,EAAE,CAAA;YAE7C,OAAO;gBACL,MAAM,EAAE,gBAAgB;gBACxB,MAAM,EAAE,gBAAgB;aACzB,CAAA;QACH,CAAC;QACD,SAAS,EAAE,EAAE,GAAG,aAAa;QAC7B,KAAK,EAAE,CAAC;QACR,GAAG,eAAe;KACnB,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { CryptoAssetKey } from "../utils/cryptoAssets";
2
+ export type DropdownCryptoAsset<T = CryptoAssetKey> = {
3
+ type: T;
4
+ balance: bigint;
5
+ };
6
+ /**
7
+ * Aggregates dropdown data for Dropdown component.
8
+ * @param {accountDataRefetchInterval: number, nativeBalanceRefetchInterval: number }
9
+ * Object containing refetch intervals time (in milliseconds) for account data
10
+ * (like mats or mezo id) and for native balance. After that time the specific
11
+ * value should be marked as stale and re-fetched. Default value for both is
12
+ * 90000 (90 secs).
13
+ * @returns Dropdown data.
14
+ * @dev This hook is for internal use only.
15
+ */
16
+ export default function useDropdownData({ accountDataRefetchInterval, nativeBalanceRefetchInterval, }: {
17
+ accountDataRefetchInterval?: number | undefined;
18
+ nativeBalanceRefetchInterval?: number | undefined;
19
+ }): {
20
+ mezoId: string | undefined;
21
+ matsBalance: number;
22
+ accountAddress: `0x${string}` | undefined;
23
+ walletAddress: string | undefined;
24
+ walletType: "bitcoin" | "evm";
25
+ usdTotalBalance: number;
26
+ usdTroveDebt: number;
27
+ usdCollateral: number;
28
+ assets: {
29
+ btc: {
30
+ type: CryptoAssetKey;
31
+ rawBalance: bigint;
32
+ formattedBalance: string;
33
+ usdBalance: number;
34
+ formattedUsdBalance: string;
35
+ };
36
+ musd: {
37
+ type: CryptoAssetKey;
38
+ rawBalance: bigint;
39
+ formattedBalance: string;
40
+ usdBalance: number;
41
+ formattedUsdBalance: string;
42
+ };
43
+ };
44
+ otherAssetsCount: number;
45
+ otherAssetsUsdTotal: number;
46
+ };
47
+ //# sourceMappingURL=useDropdownData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdownData.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAIf,MAAM,uBAAuB,CAAA;AAW9B,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,cAAc,IAAI;IACpD,IAAI,EAAE,CAAC,CAAA;IACP,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AASD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,0BAAkC,EAClC,4BAAoC,GACrC;;;CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4GA"}
@@ -0,0 +1,97 @@
1
+ import { useBalance } from "wagmi";
2
+ import { useGetCurrentAccount } from ".";
3
+ import { getCryptoAsset, isBitcoinLikeCryptoAsset, mapCryptoAssetToDetails, } from "../utils/cryptoAssets";
4
+ import { fromFixedPoint } from "../utils/numbers";
5
+ import { useAssetsConversionRates } from "./useAssetsConversionRates";
6
+ import useWalletAccount from "./useWalletAccount";
7
+ import { useTokensBalances } from "./useTokensBalances";
8
+ import { useBorrowData } from "./useBorrowData";
9
+ import { CHAIN_ID } from "../constants";
10
+ import { usePassportContext } from "./usePassportContext";
11
+ import { useWatchTransferEventsForAllTokens } from "./useWatchTransferEvents";
12
+ import { convertToUsd } from "../utils/currency";
13
+ const DEFAULT_ASSET_DATA = {
14
+ rawBalance: 0n,
15
+ formattedBalance: "0.0000",
16
+ usdBalance: 0,
17
+ formattedUsdBalance: "$0.00",
18
+ };
19
+ /**
20
+ * Aggregates dropdown data for Dropdown component.
21
+ * @param {accountDataRefetchInterval: number, nativeBalanceRefetchInterval: number }
22
+ * Object containing refetch intervals time (in milliseconds) for account data
23
+ * (like mats or mezo id) and for native balance. After that time the specific
24
+ * value should be marked as stale and re-fetched. Default value for both is
25
+ * 90000 (90 secs).
26
+ * @returns Dropdown data.
27
+ * @dev This hook is for internal use only.
28
+ */
29
+ export default function useDropdownData({ accountDataRefetchInterval = 90000, nativeBalanceRefetchInterval = 90000, }) {
30
+ const { walletAddress, accountAddress, networkFamily: walletType, } = useWalletAccount();
31
+ const { environment = "mainnet" } = usePassportContext();
32
+ const { data: btcBalance } = useBalance({
33
+ address: accountAddress,
34
+ chainId: CHAIN_ID[environment],
35
+ query: {
36
+ staleTime: nativeBalanceRefetchInterval,
37
+ refetchInterval: nativeBalanceRefetchInterval,
38
+ },
39
+ });
40
+ const { data: passportAccount } = useGetCurrentAccount({
41
+ staleTime: accountDataRefetchInterval,
42
+ refetchInterval: accountDataRefetchInterval,
43
+ enabled: !!accountAddress,
44
+ });
45
+ const { data: assetsConversionRates } = useAssetsConversionRates();
46
+ const { data: tokensBalances } = useTokensBalances();
47
+ const { data: debt } = useBorrowData();
48
+ useWatchTransferEventsForAllTokens();
49
+ const mezoId = passportAccount?.mezoId;
50
+ const detailedAssets = [
51
+ ["BTC", btcBalance?.value ?? 0n],
52
+ ...Object.entries(tokensBalances ?? {}),
53
+ ].map((asset) => {
54
+ const [type, balance] = asset;
55
+ if (isBitcoinLikeCryptoAsset(type)) {
56
+ return mapCryptoAssetToDetails(type, balance, assetsConversionRates.btc.price, assetsConversionRates.btc.decimals);
57
+ }
58
+ if (type === "mT") {
59
+ return mapCryptoAssetToDetails(type, balance, assetsConversionRates.t.price, assetsConversionRates.t.decimals);
60
+ }
61
+ return mapCryptoAssetToDetails(type, balance, 1n, 0);
62
+ });
63
+ const btcData = detailedAssets.find(({ type }) => type === "BTC");
64
+ const musdData = detailedAssets.find(({ type }) => type === "MUSD");
65
+ const otherAssetsData = detailedAssets.filter(({ type }) => !["BTC", "MUSD"].includes(type));
66
+ const otherAssetsCount = otherAssetsData.filter((asset) => asset.rawBalance !== 0n).length;
67
+ const assets = {
68
+ btc: btcData || {
69
+ type: "BTC",
70
+ ...DEFAULT_ASSET_DATA,
71
+ },
72
+ musd: musdData || {
73
+ type: "mUSD",
74
+ ...DEFAULT_ASSET_DATA,
75
+ },
76
+ };
77
+ const otherAssetsUsdTotal = otherAssetsData.reduce((sum, { usdBalance }) => sum + usdBalance, 0);
78
+ const matsBalance = passportAccount?.mats.totalMats || 0;
79
+ const usdCollateral = convertToUsd(debt?.collateral ?? 0n, getCryptoAsset("MUSD").decimals, assetsConversionRates.btc.price, assetsConversionRates.btc.decimals);
80
+ const usdTroveDebt = fromFixedPoint(debt?.troveDebt ?? 0n, 18);
81
+ const usdTotalBalance = detailedAssets.reduce((sum, { usdBalance }) => sum + usdBalance, 0) +
82
+ usdCollateral;
83
+ return {
84
+ mezoId,
85
+ matsBalance,
86
+ accountAddress,
87
+ walletAddress,
88
+ walletType,
89
+ usdTotalBalance,
90
+ usdTroveDebt,
91
+ usdCollateral,
92
+ assets,
93
+ otherAssetsCount,
94
+ otherAssetsUsdTotal,
95
+ };
96
+ }
97
+ //# sourceMappingURL=useDropdownData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdownData.js","sourceRoot":"","sources":["../../../src/hooks/useDropdownData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AACxC,OAAO,EAEL,cAAc,EACd,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAOhD,MAAM,kBAAkB,GAAG;IACzB,UAAU,EAAE,EAAE;IACd,gBAAgB,EAAE,QAAQ;IAC1B,UAAU,EAAE,CAAC;IACb,mBAAmB,EAAE,OAAO;CAC7B,CAAA;AAED;;;;;;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AAM,CAChD,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,UAAU,EACzC,CAAC,CACF,CAAA;IAED,MAAM,WAAW,GAAG,eAAe,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC,CAAA;IAExD,MAAM,aAAa,GAAG,YAAY,CAChC,IAAI,EAAE,UAAU,IAAI,EAAE,EACtB,cAAc,CAAC,MAAM,CAAC,CAAC,QAAQ,EAC/B,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAC/B,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CACnC,CAAA;IAED,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IAE9D,MAAM,eAAe,GACnB,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC;QACnE,aAAa,CAAA;IAEf,OAAO;QACL,MAAM;QACN,WAAW;QACX,cAAc;QACd,aAAa;QACb,UAAU;QACV,eAAe;QACf,YAAY;QACZ,aAAa;QACb,MAAM;QACN,gBAAgB;QAChB,mBAAmB;KACpB,CAAA;AACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Address } from "viem";
2
+ declare const _default: {
3
+ address: Address;
4
+ abi: readonly [{
5
+ readonly inputs: readonly [];
6
+ readonly name: "decimals";
7
+ readonly outputs: readonly [{
8
+ readonly internalType: "uint8";
9
+ readonly name: "";
10
+ readonly type: "uint8";
11
+ }];
12
+ readonly stateMutability: "view";
13
+ readonly type: "function";
14
+ }, {
15
+ readonly inputs: readonly [];
16
+ readonly name: "latestRoundData";
17
+ readonly outputs: readonly [{
18
+ readonly internalType: "uint80";
19
+ readonly name: "roundId";
20
+ readonly type: "uint80";
21
+ }, {
22
+ readonly internalType: "int256";
23
+ readonly name: "answer";
24
+ readonly type: "int256";
25
+ }, {
26
+ readonly internalType: "uint256";
27
+ readonly name: "startedAt";
28
+ readonly type: "uint256";
29
+ }, {
30
+ readonly internalType: "uint256";
31
+ readonly name: "updatedAt";
32
+ readonly type: "uint256";
33
+ }, {
34
+ readonly internalType: "uint80";
35
+ readonly name: "answeredInRound";
36
+ readonly type: "uint80";
37
+ }];
38
+ readonly stateMutability: "view";
39
+ readonly type: "function";
40
+ }];
41
+ };
42
+ export default _default;
43
+ //# sourceMappingURL=priceOracle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priceOracle.d.ts","sourceRoot":"","sources":["../../../../src/lib/contracts/priceOracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;;aAG6B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AADlE,wBAkDC"}
@@ -0,0 +1,52 @@
1
+ export default {
2
+ address: "0x7b7c000000000000000000000000000000000015",
3
+ abi: [
4
+ {
5
+ inputs: [],
6
+ name: "decimals",
7
+ outputs: [
8
+ {
9
+ internalType: "uint8",
10
+ name: "",
11
+ type: "uint8",
12
+ },
13
+ ],
14
+ stateMutability: "view",
15
+ type: "function",
16
+ },
17
+ {
18
+ inputs: [],
19
+ name: "latestRoundData",
20
+ outputs: [
21
+ {
22
+ internalType: "uint80",
23
+ name: "roundId",
24
+ type: "uint80",
25
+ },
26
+ {
27
+ internalType: "int256",
28
+ name: "answer",
29
+ type: "int256",
30
+ },
31
+ {
32
+ internalType: "uint256",
33
+ name: "startedAt",
34
+ type: "uint256",
35
+ },
36
+ {
37
+ internalType: "uint256",
38
+ name: "updatedAt",
39
+ type: "uint256",
40
+ },
41
+ {
42
+ internalType: "uint80",
43
+ name: "answeredInRound",
44
+ type: "uint80",
45
+ },
46
+ ],
47
+ stateMutability: "view",
48
+ type: "function",
49
+ },
50
+ ],
51
+ };
52
+ //# sourceMappingURL=priceOracle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priceOracle.js","sourceRoot":"","sources":["../../../../src/lib/contracts/priceOracle.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,OAAO,EAAE,4CAAuD;IAChE,GAAG,EAAE;QACH;YACE,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP;oBACE,YAAY,EAAE,OAAO;oBACrB,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,OAAO;iBACd;aACF;YACD,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE;gBACP;oBACE,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,QAAQ;iBACf;gBACD;oBACE,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,QAAQ;iBACf;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,iBAAiB;oBACvB,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;KACO;CACX,CAAA"}