@medialane/ui 0.185.0 → 0.186.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 (187) hide show
  1. package/dist/components/media-wallet/action-button.cjs +54 -0
  2. package/dist/components/media-wallet/action-button.cjs.map +1 -0
  3. package/dist/components/media-wallet/action-button.d.cts +10 -0
  4. package/dist/components/media-wallet/action-button.d.ts +10 -0
  5. package/dist/components/media-wallet/action-button.js +28 -0
  6. package/dist/components/media-wallet/action-button.js.map +1 -0
  7. package/dist/components/media-wallet/action-modal.cjs +84 -0
  8. package/dist/components/media-wallet/action-modal.cjs.map +1 -0
  9. package/dist/components/media-wallet/action-modal.d.cts +20 -0
  10. package/dist/components/media-wallet/action-modal.d.ts +20 -0
  11. package/dist/components/media-wallet/action-modal.js +56 -0
  12. package/dist/components/media-wallet/action-modal.js.map +1 -0
  13. package/dist/components/media-wallet/activate-card.cjs +72 -0
  14. package/dist/components/media-wallet/activate-card.cjs.map +1 -0
  15. package/dist/components/media-wallet/activate-card.d.cts +7 -0
  16. package/dist/components/media-wallet/activate-card.d.ts +7 -0
  17. package/dist/components/media-wallet/activate-card.js +48 -0
  18. package/dist/components/media-wallet/activate-card.js.map +1 -0
  19. package/dist/components/media-wallet/address-qr.cjs +64 -0
  20. package/dist/components/media-wallet/address-qr.cjs.map +1 -0
  21. package/dist/components/media-wallet/address-qr.d.cts +8 -0
  22. package/dist/components/media-wallet/address-qr.d.ts +8 -0
  23. package/dist/components/media-wallet/address-qr.js +30 -0
  24. package/dist/components/media-wallet/address-qr.js.map +1 -0
  25. package/dist/components/media-wallet/back-button.cjs +41 -0
  26. package/dist/components/media-wallet/back-button.cjs.map +1 -0
  27. package/dist/components/media-wallet/back-button.d.cts +7 -0
  28. package/dist/components/media-wallet/back-button.d.ts +7 -0
  29. package/dist/components/media-wallet/back-button.js +17 -0
  30. package/dist/components/media-wallet/back-button.js.map +1 -0
  31. package/dist/components/media-wallet/copy-icon.cjs +49 -0
  32. package/dist/components/media-wallet/copy-icon.cjs.map +1 -0
  33. package/dist/components/media-wallet/copy-icon.d.cts +7 -0
  34. package/dist/components/media-wallet/copy-icon.d.ts +7 -0
  35. package/dist/components/media-wallet/copy-icon.js +25 -0
  36. package/dist/components/media-wallet/copy-icon.js.map +1 -0
  37. package/dist/components/media-wallet/currency-sheet.cjs +54 -0
  38. package/dist/components/media-wallet/currency-sheet.cjs.map +1 -0
  39. package/dist/components/media-wallet/currency-sheet.d.cts +12 -0
  40. package/dist/components/media-wallet/currency-sheet.d.ts +12 -0
  41. package/dist/components/media-wallet/currency-sheet.js +30 -0
  42. package/dist/components/media-wallet/currency-sheet.js.map +1 -0
  43. package/dist/components/media-wallet/media-wallet-activity.cjs +223 -0
  44. package/dist/components/media-wallet/media-wallet-activity.cjs.map +1 -0
  45. package/dist/components/media-wallet/media-wallet-activity.d.cts +12 -0
  46. package/dist/components/media-wallet/media-wallet-activity.d.ts +12 -0
  47. package/dist/components/media-wallet/media-wallet-activity.js +189 -0
  48. package/dist/components/media-wallet/media-wallet-activity.js.map +1 -0
  49. package/dist/components/media-wallet/media-wallet-header.cjs +97 -0
  50. package/dist/components/media-wallet/media-wallet-header.cjs.map +1 -0
  51. package/dist/components/media-wallet/media-wallet-header.d.cts +8 -0
  52. package/dist/components/media-wallet/media-wallet-header.d.ts +8 -0
  53. package/dist/components/media-wallet/media-wallet-header.js +63 -0
  54. package/dist/components/media-wallet/media-wallet-header.js.map +1 -0
  55. package/dist/components/media-wallet/media-wallet-home.cjs +258 -0
  56. package/dist/components/media-wallet/media-wallet-home.cjs.map +1 -0
  57. package/dist/components/media-wallet/media-wallet-home.d.cts +14 -0
  58. package/dist/components/media-wallet/media-wallet-home.d.ts +14 -0
  59. package/dist/components/media-wallet/media-wallet-home.js +224 -0
  60. package/dist/components/media-wallet/media-wallet-home.js.map +1 -0
  61. package/dist/components/media-wallet/media-wallet-overlay.cjs +137 -0
  62. package/dist/components/media-wallet/media-wallet-overlay.cjs.map +1 -0
  63. package/dist/components/media-wallet/media-wallet-overlay.d.cts +14 -0
  64. package/dist/components/media-wallet/media-wallet-overlay.d.ts +14 -0
  65. package/dist/components/media-wallet/media-wallet-overlay.js +102 -0
  66. package/dist/components/media-wallet/media-wallet-overlay.js.map +1 -0
  67. package/dist/components/media-wallet/media-wallet-send.cjs +313 -0
  68. package/dist/components/media-wallet/media-wallet-send.cjs.map +1 -0
  69. package/dist/components/media-wallet/media-wallet-send.d.cts +14 -0
  70. package/dist/components/media-wallet/media-wallet-send.d.ts +14 -0
  71. package/dist/components/media-wallet/media-wallet-send.js +289 -0
  72. package/dist/components/media-wallet/media-wallet-send.js.map +1 -0
  73. package/dist/components/media-wallet/media-wallet-token-detail.cjs +164 -0
  74. package/dist/components/media-wallet/media-wallet-token-detail.cjs.map +1 -0
  75. package/dist/components/media-wallet/media-wallet-token-detail.d.cts +13 -0
  76. package/dist/components/media-wallet/media-wallet-token-detail.d.ts +13 -0
  77. package/dist/components/media-wallet/media-wallet-token-detail.js +140 -0
  78. package/dist/components/media-wallet/media-wallet-token-detail.js.map +1 -0
  79. package/dist/components/media-wallet/media-wallet.cjs +51 -0
  80. package/dist/components/media-wallet/media-wallet.cjs.map +1 -0
  81. package/dist/components/media-wallet/media-wallet.d.cts +13 -0
  82. package/dist/components/media-wallet/media-wallet.d.ts +13 -0
  83. package/dist/components/media-wallet/media-wallet.js +27 -0
  84. package/dist/components/media-wallet/media-wallet.js.map +1 -0
  85. package/dist/components/media-wallet/nft-strip.cjs +85 -0
  86. package/dist/components/media-wallet/nft-strip.cjs.map +1 -0
  87. package/dist/components/media-wallet/nft-strip.d.cts +12 -0
  88. package/dist/components/media-wallet/nft-strip.d.ts +12 -0
  89. package/dist/components/media-wallet/nft-strip.js +51 -0
  90. package/dist/components/media-wallet/nft-strip.js.map +1 -0
  91. package/dist/components/media-wallet/quick-action.cjs +59 -0
  92. package/dist/components/media-wallet/quick-action.cjs.map +1 -0
  93. package/dist/components/media-wallet/quick-action.d.cts +12 -0
  94. package/dist/components/media-wallet/quick-action.d.ts +12 -0
  95. package/dist/components/media-wallet/quick-action.js +35 -0
  96. package/dist/components/media-wallet/quick-action.js.map +1 -0
  97. package/dist/components/media-wallet/receive-card.cjs +86 -0
  98. package/dist/components/media-wallet/receive-card.cjs.map +1 -0
  99. package/dist/components/media-wallet/receive-card.d.cts +7 -0
  100. package/dist/components/media-wallet/receive-card.d.ts +7 -0
  101. package/dist/components/media-wallet/receive-card.js +52 -0
  102. package/dist/components/media-wallet/receive-card.js.map +1 -0
  103. package/dist/components/media-wallet/section-header.cjs +32 -0
  104. package/dist/components/media-wallet/section-header.cjs.map +1 -0
  105. package/dist/components/media-wallet/section-header.d.cts +7 -0
  106. package/dist/components/media-wallet/section-header.d.ts +7 -0
  107. package/dist/components/media-wallet/section-header.js +8 -0
  108. package/dist/components/media-wallet/section-header.js.map +1 -0
  109. package/dist/components/media-wallet/success-dialog.cjs +75 -0
  110. package/dist/components/media-wallet/success-dialog.cjs.map +1 -0
  111. package/dist/components/media-wallet/success-dialog.d.cts +11 -0
  112. package/dist/components/media-wallet/success-dialog.d.ts +11 -0
  113. package/dist/components/media-wallet/success-dialog.js +51 -0
  114. package/dist/components/media-wallet/success-dialog.js.map +1 -0
  115. package/dist/components/media-wallet/types.cjs +37 -0
  116. package/dist/components/media-wallet/types.cjs.map +1 -0
  117. package/dist/components/media-wallet/types.d.cts +66 -0
  118. package/dist/components/media-wallet/types.d.ts +66 -0
  119. package/dist/components/media-wallet/types.js +12 -0
  120. package/dist/components/media-wallet/types.js.map +1 -0
  121. package/dist/components/media-wallet/wallet-activity-icon.cjs +69 -0
  122. package/dist/components/media-wallet/wallet-activity-icon.cjs.map +1 -0
  123. package/dist/components/media-wallet/wallet-activity-icon.d.cts +8 -0
  124. package/dist/components/media-wallet/wallet-activity-icon.d.ts +8 -0
  125. package/dist/components/media-wallet/wallet-activity-icon.js +45 -0
  126. package/dist/components/media-wallet/wallet-activity-icon.js.map +1 -0
  127. package/dist/index.cjs +5 -0
  128. package/dist/index.cjs.map +1 -1
  129. package/dist/index.d.cts +3 -0
  130. package/dist/index.d.ts +3 -0
  131. package/dist/index.js +3 -0
  132. package/dist/index.js.map +1 -1
  133. package/dist/utils/media-wallet/activity-feed.cjs +35 -0
  134. package/dist/utils/media-wallet/activity-feed.cjs.map +1 -0
  135. package/dist/utils/media-wallet/activity-feed.d.cts +14 -0
  136. package/dist/utils/media-wallet/activity-feed.d.ts +14 -0
  137. package/dist/utils/media-wallet/activity-feed.js +11 -0
  138. package/dist/utils/media-wallet/activity-feed.js.map +1 -0
  139. package/dist/utils/media-wallet/confetti.cjs +51 -0
  140. package/dist/utils/media-wallet/confetti.cjs.map +1 -0
  141. package/dist/utils/media-wallet/confetti.d.cts +3 -0
  142. package/dist/utils/media-wallet/confetti.d.ts +3 -0
  143. package/dist/utils/media-wallet/confetti.js +17 -0
  144. package/dist/utils/media-wallet/confetti.js.map +1 -0
  145. package/dist/utils/media-wallet/nft-items.cjs +38 -0
  146. package/dist/utils/media-wallet/nft-items.cjs.map +1 -0
  147. package/dist/utils/media-wallet/nft-items.d.cts +13 -0
  148. package/dist/utils/media-wallet/nft-items.d.ts +13 -0
  149. package/dist/utils/media-wallet/nft-items.js +14 -0
  150. package/dist/utils/media-wallet/nft-items.js.map +1 -0
  151. package/dist/utils/media-wallet/run-intent-calls.cjs +32 -0
  152. package/dist/utils/media-wallet/run-intent-calls.cjs.map +1 -0
  153. package/dist/utils/media-wallet/run-intent-calls.d.cts +16 -0
  154. package/dist/utils/media-wallet/run-intent-calls.d.ts +16 -0
  155. package/dist/utils/media-wallet/run-intent-calls.js +8 -0
  156. package/dist/utils/media-wallet/run-intent-calls.js.map +1 -0
  157. package/dist/utils/media-wallet/use-erc20-balance.cjs +75 -0
  158. package/dist/utils/media-wallet/use-erc20-balance.cjs.map +1 -0
  159. package/dist/utils/media-wallet/use-erc20-balance.d.cts +15 -0
  160. package/dist/utils/media-wallet/use-erc20-balance.d.ts +15 -0
  161. package/dist/utils/media-wallet/use-erc20-balance.js +40 -0
  162. package/dist/utils/media-wallet/use-erc20-balance.js.map +1 -0
  163. package/dist/utils/media-wallet/use-tokens-by-owner.cjs +52 -0
  164. package/dist/utils/media-wallet/use-tokens-by-owner.cjs.map +1 -0
  165. package/dist/utils/media-wallet/use-tokens-by-owner.d.cts +10 -0
  166. package/dist/utils/media-wallet/use-tokens-by-owner.d.ts +10 -0
  167. package/dist/utils/media-wallet/use-tokens-by-owner.js +18 -0
  168. package/dist/utils/media-wallet/use-tokens-by-owner.js.map +1 -0
  169. package/dist/utils/media-wallet/wallet-activity.cjs +83 -0
  170. package/dist/utils/media-wallet/wallet-activity.cjs.map +1 -0
  171. package/dist/utils/media-wallet/wallet-activity.d.cts +7 -0
  172. package/dist/utils/media-wallet/wallet-activity.d.ts +7 -0
  173. package/dist/utils/media-wallet/wallet-activity.js +57 -0
  174. package/dist/utils/media-wallet/wallet-activity.js.map +1 -0
  175. package/dist/utils/media-wallet/wallet-format.cjs +59 -0
  176. package/dist/utils/media-wallet/wallet-format.cjs.map +1 -0
  177. package/dist/utils/media-wallet/wallet-format.d.cts +9 -0
  178. package/dist/utils/media-wallet/wallet-format.d.ts +9 -0
  179. package/dist/utils/media-wallet/wallet-format.js +29 -0
  180. package/dist/utils/media-wallet/wallet-format.js.map +1 -0
  181. package/dist/utils/media-wallet/wallet-tokens.cjs +39 -0
  182. package/dist/utils/media-wallet/wallet-tokens.cjs.map +1 -0
  183. package/dist/utils/media-wallet/wallet-tokens.d.cts +10 -0
  184. package/dist/utils/media-wallet/wallet-tokens.d.ts +10 -0
  185. package/dist/utils/media-wallet/wallet-tokens.js +15 -0
  186. package/dist/utils/media-wallet/wallet-tokens.js.map +1 -0
  187. package/package.json +9 -1
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var use_erc20_balance_exports = {};
31
+ __export(use_erc20_balance_exports, {
32
+ useErc20Balance: () => useErc20Balance,
33
+ useTokenBalance: () => useTokenBalance
34
+ });
35
+ module.exports = __toCommonJS(use_erc20_balance_exports);
36
+ var import_swr = __toESM(require("swr"), 1);
37
+ var import_sdk = require("@medialane/sdk");
38
+ async function fetchErc20Balance(provider, tokenAddress, holderAddress) {
39
+ const result = await provider.callContract(
40
+ {
41
+ contractAddress: tokenAddress,
42
+ entrypoint: "balanceOf",
43
+ calldata: [holderAddress]
44
+ },
45
+ "latest"
46
+ );
47
+ const low = BigInt(result[0]);
48
+ const high = BigInt(result[1]);
49
+ return low + (high << 128n);
50
+ }
51
+ function useErc20Balance(provider, tokenAddress, holderAddress) {
52
+ const { data, error, isLoading } = (0, import_swr.default)(
53
+ tokenAddress && holderAddress ? ["erc20-balance", tokenAddress, holderAddress] : null,
54
+ ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),
55
+ {
56
+ refreshInterval: 3e4,
57
+ revalidateOnFocus: false,
58
+ shouldRetryOnError: false,
59
+ onError: () => {
60
+ }
61
+ }
62
+ );
63
+ return { rawBalance: data ?? null, isLoading, error };
64
+ }
65
+ function useTokenBalance(provider, symbol, holderAddress) {
66
+ const token = symbol ? (0, import_sdk.getListableTokens)().find((t) => t.symbol === symbol) ?? null : null;
67
+ const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);
68
+ return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };
69
+ }
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ useErc20Balance,
73
+ useTokenBalance
74
+ });
75
+ //# sourceMappingURL=use-erc20-balance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/use-erc20-balance.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ProviderInterface } from \"starknet\";\nimport { getListableTokens } from \"@medialane/sdk\";\n\nasync function fetchErc20Balance(provider: ProviderInterface, tokenAddress: string, holderAddress: string): Promise<bigint> {\n const result = await provider.callContract(\n {\n contractAddress: tokenAddress,\n entrypoint: \"balanceOf\",\n calldata: [holderAddress],\n },\n \"latest\"\n );\n\n const low = BigInt(result[0]);\n const high = BigInt(result[1]);\n return low + (high << 128n);\n}\n\nexport function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null) {\n const { data, error, isLoading } = useSWR(\n tokenAddress && holderAddress ? [\"erc20-balance\", tokenAddress, holderAddress] : null,\n ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),\n {\n refreshInterval: 30_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n onError: () => {},\n }\n );\n return { rawBalance: data ?? null, isLoading, error };\n}\n\nexport function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null) {\n const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;\n const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);\n return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAEnB,iBAAkC;AAElC,eAAe,kBAAkB,UAA6B,cAAsB,eAAwC;AAC1H,QAAM,SAAS,MAAM,SAAS;AAAA,IAC5B;AAAA,MACE,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ,UAAU,CAAC,aAAa;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,MAAM,OAAO,OAAO,CAAC,CAAC;AAC5B,QAAM,OAAO,OAAO,OAAO,CAAC,CAAC;AAC7B,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,gBAAgB,UAA6B,cAA6B,eAA8B;AACtH,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC,gBAAgB,gBAAgB,CAAC,iBAAiB,cAAc,aAAa,IAAI;AAAA,IACjF,CAAC,CAAC,EAAE,MAAM,MAAM,MAAM,kBAAkB,UAAU,MAAM,MAAM;AAAA,IAC9D;AAAA,MACE,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,MAAM;AACtD;AAEO,SAAS,gBAAgB,UAA6B,QAAuB,eAA8B;AAChH,QAAM,QAAQ,aAAS,8BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;AACtF,QAAM,EAAE,YAAY,WAAW,MAAM,IAAI,gBAAgB,UAAU,OAAO,WAAW,MAAM,aAAa;AACxG,SAAO,EAAE,YAAY,WAAW,OAAO,UAAU,OAAO,YAAY,GAAG;AACzE;","names":["useSWR"]}
@@ -0,0 +1,15 @@
1
+ import { ProviderInterface } from 'starknet';
2
+
3
+ declare function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null): {
4
+ rawBalance: bigint | null;
5
+ isLoading: boolean;
6
+ error: any;
7
+ };
8
+ declare function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null): {
9
+ rawBalance: bigint | null;
10
+ isLoading: boolean;
11
+ error: any;
12
+ decimals: 6 | 18 | 8;
13
+ };
14
+
15
+ export { useErc20Balance, useTokenBalance };
@@ -0,0 +1,15 @@
1
+ import { ProviderInterface } from 'starknet';
2
+
3
+ declare function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null): {
4
+ rawBalance: bigint | null;
5
+ isLoading: boolean;
6
+ error: any;
7
+ };
8
+ declare function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null): {
9
+ rawBalance: bigint | null;
10
+ isLoading: boolean;
11
+ error: any;
12
+ decimals: 6 | 18 | 8;
13
+ };
14
+
15
+ export { useErc20Balance, useTokenBalance };
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import useSWR from "swr";
3
+ import { getListableTokens } from "@medialane/sdk";
4
+ async function fetchErc20Balance(provider, tokenAddress, holderAddress) {
5
+ const result = await provider.callContract(
6
+ {
7
+ contractAddress: tokenAddress,
8
+ entrypoint: "balanceOf",
9
+ calldata: [holderAddress]
10
+ },
11
+ "latest"
12
+ );
13
+ const low = BigInt(result[0]);
14
+ const high = BigInt(result[1]);
15
+ return low + (high << 128n);
16
+ }
17
+ function useErc20Balance(provider, tokenAddress, holderAddress) {
18
+ const { data, error, isLoading } = useSWR(
19
+ tokenAddress && holderAddress ? ["erc20-balance", tokenAddress, holderAddress] : null,
20
+ ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),
21
+ {
22
+ refreshInterval: 3e4,
23
+ revalidateOnFocus: false,
24
+ shouldRetryOnError: false,
25
+ onError: () => {
26
+ }
27
+ }
28
+ );
29
+ return { rawBalance: data ?? null, isLoading, error };
30
+ }
31
+ function useTokenBalance(provider, symbol, holderAddress) {
32
+ const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;
33
+ const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);
34
+ return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };
35
+ }
36
+ export {
37
+ useErc20Balance,
38
+ useTokenBalance
39
+ };
40
+ //# sourceMappingURL=use-erc20-balance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/use-erc20-balance.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ProviderInterface } from \"starknet\";\nimport { getListableTokens } from \"@medialane/sdk\";\n\nasync function fetchErc20Balance(provider: ProviderInterface, tokenAddress: string, holderAddress: string): Promise<bigint> {\n const result = await provider.callContract(\n {\n contractAddress: tokenAddress,\n entrypoint: \"balanceOf\",\n calldata: [holderAddress],\n },\n \"latest\"\n );\n\n const low = BigInt(result[0]);\n const high = BigInt(result[1]);\n return low + (high << 128n);\n}\n\nexport function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null) {\n const { data, error, isLoading } = useSWR(\n tokenAddress && holderAddress ? [\"erc20-balance\", tokenAddress, holderAddress] : null,\n ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),\n {\n refreshInterval: 30_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n onError: () => {},\n }\n );\n return { rawBalance: data ?? null, isLoading, error };\n}\n\nexport function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null) {\n const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;\n const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);\n return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAEnB,SAAS,yBAAyB;AAElC,eAAe,kBAAkB,UAA6B,cAAsB,eAAwC;AAC1H,QAAM,SAAS,MAAM,SAAS;AAAA,IAC5B;AAAA,MACE,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ,UAAU,CAAC,aAAa;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,MAAM,OAAO,OAAO,CAAC,CAAC;AAC5B,QAAM,OAAO,OAAO,OAAO,CAAC,CAAC;AAC7B,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,gBAAgB,UAA6B,cAA6B,eAA8B;AACtH,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,gBAAgB,gBAAgB,CAAC,iBAAiB,cAAc,aAAa,IAAI;AAAA,IACjF,CAAC,CAAC,EAAE,MAAM,MAAM,MAAM,kBAAkB,UAAU,MAAM,MAAM;AAAA,IAC9D;AAAA,MACE,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,MAAM;AACtD;AAEO,SAAS,gBAAgB,UAA6B,QAAuB,eAA8B;AAChH,QAAM,QAAQ,SAAS,kBAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;AACtF,QAAM,EAAE,YAAY,WAAW,MAAM,IAAI,gBAAgB,UAAU,OAAO,WAAW,MAAM,aAAa;AACxG,SAAO,EAAE,YAAY,WAAW,OAAO,UAAU,OAAO,YAAY,GAAG;AACzE;","names":[]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var use_tokens_by_owner_exports = {};
31
+ __export(use_tokens_by_owner_exports, {
32
+ useTokensByOwner: () => useTokensByOwner
33
+ });
34
+ module.exports = __toCommonJS(use_tokens_by_owner_exports);
35
+ var import_swr = __toESM(require("swr"), 1);
36
+ var import_query_keys = require("../query-keys.js");
37
+ var import_use_medialane_client = require("../use-medialane-client.js");
38
+ const EMPTY_TOKENS = [];
39
+ function useTokensByOwner(getClient, address, page = 1, limit = 20) {
40
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
41
+ const { data, error, isLoading } = (0, import_swr.default)(
42
+ address ? import_query_keys.queryKeys.tokensOwned(address, page, limit) : null,
43
+ () => client.api.getTokensByOwner(address, page, limit),
44
+ { revalidateOnFocus: false, refreshInterval: 6e4, revalidateOnMount: true }
45
+ );
46
+ return { tokens: data?.data ?? EMPTY_TOKENS, isLoading, error };
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ useTokensByOwner
51
+ });
52
+ //# sourceMappingURL=use-tokens-by-owner.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/use-tokens-by-owner.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { queryKeys } from \"../query-keys.js\";\nimport { useMedialaneClient } from \"../use-medialane-client.js\";\n\nconst EMPTY_TOKENS: ApiToken[] = [];\n\nexport function useTokensByOwner(getClient: () => MedialaneClient, address: string | null, page = 1, limit = 20) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR(\n address ? queryKeys.tokensOwned(address, page, limit) : null,\n () => client.api.getTokensByOwner(address!, page, limit),\n { revalidateOnFocus: false, refreshInterval: 60_000, revalidateOnMount: true }\n );\n return { tokens: data?.data ?? EMPTY_TOKENS, isLoading, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAGnB,wBAA0B;AAC1B,kCAAmC;AAEnC,MAAM,eAA2B,CAAC;AAE3B,SAAS,iBAAiB,WAAkC,SAAwB,OAAO,GAAG,QAAQ,IAAI;AAC/G,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC,UAAU,4BAAU,YAAY,SAAS,MAAM,KAAK,IAAI;AAAA,IACxD,MAAM,OAAO,IAAI,iBAAiB,SAAU,MAAM,KAAK;AAAA,IACvD,EAAE,mBAAmB,OAAO,iBAAiB,KAAQ,mBAAmB,KAAK;AAAA,EAC/E;AACA,SAAO,EAAE,QAAQ,MAAM,QAAQ,cAAc,WAAW,MAAM;AAChE;","names":["useSWR"]}
@@ -0,0 +1,10 @@
1
+ import { ApiToken } from '@medialane/sdk';
2
+ import { MedialaneClient } from '@medialane/sdk/starknet';
3
+
4
+ declare function useTokensByOwner(getClient: () => MedialaneClient, address: string | null, page?: number, limit?: number): {
5
+ tokens: ApiToken[];
6
+ isLoading: boolean;
7
+ error: any;
8
+ };
9
+
10
+ export { useTokensByOwner };
@@ -0,0 +1,10 @@
1
+ import { ApiToken } from '@medialane/sdk';
2
+ import { MedialaneClient } from '@medialane/sdk/starknet';
3
+
4
+ declare function useTokensByOwner(getClient: () => MedialaneClient, address: string | null, page?: number, limit?: number): {
5
+ tokens: ApiToken[];
6
+ isLoading: boolean;
7
+ error: any;
8
+ };
9
+
10
+ export { useTokensByOwner };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import useSWR from "swr";
3
+ import { queryKeys } from "../query-keys.js";
4
+ import { useMedialaneClient } from "../use-medialane-client.js";
5
+ const EMPTY_TOKENS = [];
6
+ function useTokensByOwner(getClient, address, page = 1, limit = 20) {
7
+ const client = useMedialaneClient(getClient);
8
+ const { data, error, isLoading } = useSWR(
9
+ address ? queryKeys.tokensOwned(address, page, limit) : null,
10
+ () => client.api.getTokensByOwner(address, page, limit),
11
+ { revalidateOnFocus: false, refreshInterval: 6e4, revalidateOnMount: true }
12
+ );
13
+ return { tokens: data?.data ?? EMPTY_TOKENS, isLoading, error };
14
+ }
15
+ export {
16
+ useTokensByOwner
17
+ };
18
+ //# sourceMappingURL=use-tokens-by-owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/use-tokens-by-owner.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { queryKeys } from \"../query-keys.js\";\nimport { useMedialaneClient } from \"../use-medialane-client.js\";\n\nconst EMPTY_TOKENS: ApiToken[] = [];\n\nexport function useTokensByOwner(getClient: () => MedialaneClient, address: string | null, page = 1, limit = 20) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR(\n address ? queryKeys.tokensOwned(address, page, limit) : null,\n () => client.api.getTokensByOwner(address!, page, limit),\n { revalidateOnFocus: false, refreshInterval: 60_000, revalidateOnMount: true }\n );\n return { tokens: data?.data ?? EMPTY_TOKENS, isLoading, error };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAGnB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAEnC,MAAM,eAA2B,CAAC;AAE3B,SAAS,iBAAiB,WAAkC,SAAwB,OAAO,GAAG,QAAQ,IAAI;AAC/G,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,UAAU,UAAU,YAAY,SAAS,MAAM,KAAK,IAAI;AAAA,IACxD,MAAM,OAAO,IAAI,iBAAiB,SAAU,MAAM,KAAK;AAAA,IACvD,EAAE,mBAAmB,OAAO,iBAAiB,KAAQ,mBAAmB,KAAK;AAAA,EAC/E;AACA,SAAO,EAAE,QAAQ,MAAM,QAAQ,cAAc,WAAW,MAAM;AAChE;","names":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var wallet_activity_exports = {};
20
+ __export(wallet_activity_exports, {
21
+ walletActivityAmount: () => walletActivityAmount,
22
+ walletActivitySubtitle: () => walletActivitySubtitle,
23
+ walletActivityTitle: () => walletActivityTitle
24
+ });
25
+ module.exports = __toCommonJS(wallet_activity_exports);
26
+ var import_sdk = require("@medialane/sdk");
27
+ var import_wallet_format = require("./wallet-format.js");
28
+ function tokenAmount(tokenAddress, amount) {
29
+ if (!amount) return null;
30
+ const token = tokenAddress ? (0, import_sdk.getTokenByAddress)(tokenAddress) : void 0;
31
+ if (!token) return amount;
32
+ return `${(0, import_wallet_format.fmt)(BigInt(amount), token.decimals)} ${token.symbol}`;
33
+ }
34
+ function walletActivityTitle(a) {
35
+ switch (a.type) {
36
+ case "SEND":
37
+ return "Sent";
38
+ case "RECEIVE":
39
+ return "Received";
40
+ case "SWAP":
41
+ return "Swapped";
42
+ case "DEPLOY":
43
+ return "Account activated";
44
+ case "GUARDIAN_SET":
45
+ return "Guardian added";
46
+ case "GUARDIAN_TRIGGER_ESCAPE":
47
+ return "Recovery started";
48
+ case "GUARDIAN_COMPLETE_ESCAPE":
49
+ return "Recovery completed";
50
+ case "GUARDIAN_CANCEL_ESCAPE":
51
+ return "Recovery canceled";
52
+ default: {
53
+ const exhaustive = a.type;
54
+ throw new Error(`Unhandled WalletActivityType: ${exhaustive}`);
55
+ }
56
+ }
57
+ }
58
+ function walletActivitySubtitle(a) {
59
+ switch (a.type) {
60
+ case "SEND":
61
+ return a.counterparty ? `to ${(0, import_wallet_format.short)(a.counterparty)}` : null;
62
+ case "RECEIVE":
63
+ return a.counterparty ? `from ${(0, import_wallet_format.short)(a.counterparty)}` : null;
64
+ case "SWAP": {
65
+ const from = tokenAmount(a.tokenInAddress, a.amountIn);
66
+ const to = tokenAmount(a.tokenOutAddress, a.amountOut);
67
+ return from && to ? `${from} \u2192 ${to}` : null;
68
+ }
69
+ default:
70
+ return null;
71
+ }
72
+ }
73
+ function walletActivityAmount(a) {
74
+ if (a.type === "SEND" || a.type === "RECEIVE") return tokenAmount(a.tokenAddress, a.amount);
75
+ return null;
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ walletActivityAmount,
80
+ walletActivitySubtitle,
81
+ walletActivityTitle
82
+ });
83
+ //# sourceMappingURL=wallet-activity.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/wallet-activity.ts"],"sourcesContent":["import { getTokenByAddress } from \"@medialane/sdk\";\nimport type { ApiWalletActivity } from \"@medialane/sdk\";\nimport { fmt, short } from \"./wallet-format.js\";\n\nfunction tokenAmount(tokenAddress: string | null, amount: string | null): string | null {\n if (!amount) return null;\n const token = tokenAddress ? getTokenByAddress(tokenAddress) : undefined;\n if (!token) return amount;\n return `${fmt(BigInt(amount), token.decimals)} ${token.symbol}`;\n}\n\nexport function walletActivityTitle(a: ApiWalletActivity): string {\n switch (a.type) {\n case \"SEND\": return \"Sent\";\n case \"RECEIVE\": return \"Received\";\n case \"SWAP\": return \"Swapped\";\n case \"DEPLOY\": return \"Account activated\";\n case \"GUARDIAN_SET\": return \"Guardian added\";\n case \"GUARDIAN_TRIGGER_ESCAPE\": return \"Recovery started\";\n case \"GUARDIAN_COMPLETE_ESCAPE\": return \"Recovery completed\";\n case \"GUARDIAN_CANCEL_ESCAPE\": return \"Recovery canceled\";\n default: {\n const exhaustive: never = a.type;\n throw new Error(`Unhandled WalletActivityType: ${exhaustive}`);\n }\n }\n}\n\nexport function walletActivitySubtitle(a: ApiWalletActivity): string | null {\n switch (a.type) {\n case \"SEND\": return a.counterparty ? `to ${short(a.counterparty)}` : null;\n case \"RECEIVE\": return a.counterparty ? `from ${short(a.counterparty)}` : null;\n case \"SWAP\": {\n const from = tokenAmount(a.tokenInAddress, a.amountIn);\n const to = tokenAmount(a.tokenOutAddress, a.amountOut);\n return from && to ? `${from} → ${to}` : null;\n }\n default: return null;\n }\n}\n\nexport function walletActivityAmount(a: ApiWalletActivity): string | null {\n if (a.type === \"SEND\" || a.type === \"RECEIVE\") return tokenAmount(a.tokenAddress, a.amount);\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkC;AAElC,2BAA2B;AAE3B,SAAS,YAAY,cAA6B,QAAsC;AACtF,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,QAAQ,mBAAe,8BAAkB,YAAY,IAAI;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,OAAG,0BAAI,OAAO,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,MAAM,MAAM;AAC/D;AAEO,SAAS,oBAAoB,GAA8B;AAChE,UAAQ,EAAE,MAAM;AAAA,IACd,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAW,aAAO;AAAA,IACvB,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAgB,aAAO;AAAA,IAC5B,KAAK;AAA2B,aAAO;AAAA,IACvC,KAAK;AAA4B,aAAO;AAAA,IACxC,KAAK;AAA0B,aAAO;AAAA,IACtC,SAAS;AACP,YAAM,aAAoB,EAAE;AAC5B,YAAM,IAAI,MAAM,iCAAiC,UAAU,EAAE;AAAA,IAC/D;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,GAAqC;AAC1E,UAAQ,EAAE,MAAM;AAAA,IACd,KAAK;AAAQ,aAAO,EAAE,eAAe,UAAM,4BAAM,EAAE,YAAY,CAAC,KAAK;AAAA,IACrE,KAAK;AAAW,aAAO,EAAE,eAAe,YAAQ,4BAAM,EAAE,YAAY,CAAC,KAAK;AAAA,IAC1E,KAAK,QAAQ;AACX,YAAM,OAAO,YAAY,EAAE,gBAAgB,EAAE,QAAQ;AACrD,YAAM,KAAK,YAAY,EAAE,iBAAiB,EAAE,SAAS;AACrD,aAAO,QAAQ,KAAK,GAAG,IAAI,WAAM,EAAE,KAAK;AAAA,IAC1C;AAAA,IACA;AAAS,aAAO;AAAA,EAClB;AACF;AAEO,SAAS,qBAAqB,GAAqC;AACxE,MAAI,EAAE,SAAS,UAAU,EAAE,SAAS,UAAW,QAAO,YAAY,EAAE,cAAc,EAAE,MAAM;AAC1F,SAAO;AACT;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { ApiWalletActivity } from '@medialane/sdk';
2
+
3
+ declare function walletActivityTitle(a: ApiWalletActivity): string;
4
+ declare function walletActivitySubtitle(a: ApiWalletActivity): string | null;
5
+ declare function walletActivityAmount(a: ApiWalletActivity): string | null;
6
+
7
+ export { walletActivityAmount, walletActivitySubtitle, walletActivityTitle };
@@ -0,0 +1,7 @@
1
+ import { ApiWalletActivity } from '@medialane/sdk';
2
+
3
+ declare function walletActivityTitle(a: ApiWalletActivity): string;
4
+ declare function walletActivitySubtitle(a: ApiWalletActivity): string | null;
5
+ declare function walletActivityAmount(a: ApiWalletActivity): string | null;
6
+
7
+ export { walletActivityAmount, walletActivitySubtitle, walletActivityTitle };
@@ -0,0 +1,57 @@
1
+ import { getTokenByAddress } from "@medialane/sdk";
2
+ import { fmt, short } from "./wallet-format.js";
3
+ function tokenAmount(tokenAddress, amount) {
4
+ if (!amount) return null;
5
+ const token = tokenAddress ? getTokenByAddress(tokenAddress) : void 0;
6
+ if (!token) return amount;
7
+ return `${fmt(BigInt(amount), token.decimals)} ${token.symbol}`;
8
+ }
9
+ function walletActivityTitle(a) {
10
+ switch (a.type) {
11
+ case "SEND":
12
+ return "Sent";
13
+ case "RECEIVE":
14
+ return "Received";
15
+ case "SWAP":
16
+ return "Swapped";
17
+ case "DEPLOY":
18
+ return "Account activated";
19
+ case "GUARDIAN_SET":
20
+ return "Guardian added";
21
+ case "GUARDIAN_TRIGGER_ESCAPE":
22
+ return "Recovery started";
23
+ case "GUARDIAN_COMPLETE_ESCAPE":
24
+ return "Recovery completed";
25
+ case "GUARDIAN_CANCEL_ESCAPE":
26
+ return "Recovery canceled";
27
+ default: {
28
+ const exhaustive = a.type;
29
+ throw new Error(`Unhandled WalletActivityType: ${exhaustive}`);
30
+ }
31
+ }
32
+ }
33
+ function walletActivitySubtitle(a) {
34
+ switch (a.type) {
35
+ case "SEND":
36
+ return a.counterparty ? `to ${short(a.counterparty)}` : null;
37
+ case "RECEIVE":
38
+ return a.counterparty ? `from ${short(a.counterparty)}` : null;
39
+ case "SWAP": {
40
+ const from = tokenAmount(a.tokenInAddress, a.amountIn);
41
+ const to = tokenAmount(a.tokenOutAddress, a.amountOut);
42
+ return from && to ? `${from} \u2192 ${to}` : null;
43
+ }
44
+ default:
45
+ return null;
46
+ }
47
+ }
48
+ function walletActivityAmount(a) {
49
+ if (a.type === "SEND" || a.type === "RECEIVE") return tokenAmount(a.tokenAddress, a.amount);
50
+ return null;
51
+ }
52
+ export {
53
+ walletActivityAmount,
54
+ walletActivitySubtitle,
55
+ walletActivityTitle
56
+ };
57
+ //# sourceMappingURL=wallet-activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/wallet-activity.ts"],"sourcesContent":["import { getTokenByAddress } from \"@medialane/sdk\";\nimport type { ApiWalletActivity } from \"@medialane/sdk\";\nimport { fmt, short } from \"./wallet-format.js\";\n\nfunction tokenAmount(tokenAddress: string | null, amount: string | null): string | null {\n if (!amount) return null;\n const token = tokenAddress ? getTokenByAddress(tokenAddress) : undefined;\n if (!token) return amount;\n return `${fmt(BigInt(amount), token.decimals)} ${token.symbol}`;\n}\n\nexport function walletActivityTitle(a: ApiWalletActivity): string {\n switch (a.type) {\n case \"SEND\": return \"Sent\";\n case \"RECEIVE\": return \"Received\";\n case \"SWAP\": return \"Swapped\";\n case \"DEPLOY\": return \"Account activated\";\n case \"GUARDIAN_SET\": return \"Guardian added\";\n case \"GUARDIAN_TRIGGER_ESCAPE\": return \"Recovery started\";\n case \"GUARDIAN_COMPLETE_ESCAPE\": return \"Recovery completed\";\n case \"GUARDIAN_CANCEL_ESCAPE\": return \"Recovery canceled\";\n default: {\n const exhaustive: never = a.type;\n throw new Error(`Unhandled WalletActivityType: ${exhaustive}`);\n }\n }\n}\n\nexport function walletActivitySubtitle(a: ApiWalletActivity): string | null {\n switch (a.type) {\n case \"SEND\": return a.counterparty ? `to ${short(a.counterparty)}` : null;\n case \"RECEIVE\": return a.counterparty ? `from ${short(a.counterparty)}` : null;\n case \"SWAP\": {\n const from = tokenAmount(a.tokenInAddress, a.amountIn);\n const to = tokenAmount(a.tokenOutAddress, a.amountOut);\n return from && to ? `${from} → ${to}` : null;\n }\n default: return null;\n }\n}\n\nexport function walletActivityAmount(a: ApiWalletActivity): string | null {\n if (a.type === \"SEND\" || a.type === \"RECEIVE\") return tokenAmount(a.tokenAddress, a.amount);\n return null;\n}\n"],"mappings":"AAAA,SAAS,yBAAyB;AAElC,SAAS,KAAK,aAAa;AAE3B,SAAS,YAAY,cAA6B,QAAsC;AACtF,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,QAAQ,eAAe,kBAAkB,YAAY,IAAI;AAC/D,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,GAAG,IAAI,OAAO,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,MAAM,MAAM;AAC/D;AAEO,SAAS,oBAAoB,GAA8B;AAChE,UAAQ,EAAE,MAAM;AAAA,IACd,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAW,aAAO;AAAA,IACvB,KAAK;AAAQ,aAAO;AAAA,IACpB,KAAK;AAAU,aAAO;AAAA,IACtB,KAAK;AAAgB,aAAO;AAAA,IAC5B,KAAK;AAA2B,aAAO;AAAA,IACvC,KAAK;AAA4B,aAAO;AAAA,IACxC,KAAK;AAA0B,aAAO;AAAA,IACtC,SAAS;AACP,YAAM,aAAoB,EAAE;AAC5B,YAAM,IAAI,MAAM,iCAAiC,UAAU,EAAE;AAAA,IAC/D;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,GAAqC;AAC1E,UAAQ,EAAE,MAAM;AAAA,IACd,KAAK;AAAQ,aAAO,EAAE,eAAe,MAAM,MAAM,EAAE,YAAY,CAAC,KAAK;AAAA,IACrE,KAAK;AAAW,aAAO,EAAE,eAAe,QAAQ,MAAM,EAAE,YAAY,CAAC,KAAK;AAAA,IAC1E,KAAK,QAAQ;AACX,YAAM,OAAO,YAAY,EAAE,gBAAgB,EAAE,QAAQ;AACrD,YAAM,KAAK,YAAY,EAAE,iBAAiB,EAAE,SAAS;AACrD,aAAO,QAAQ,KAAK,GAAG,IAAI,WAAM,EAAE,KAAK;AAAA,IAC1C;AAAA,IACA;AAAS,aAAO;AAAA,EAClB;AACF;AAEO,SAAS,qBAAqB,GAAqC;AACxE,MAAI,EAAE,SAAS,UAAU,EAAE,SAAS,UAAW,QAAO,YAAY,EAAE,cAAc,EAAE,MAAM;AAC1F,SAAO;AACT;","names":[]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var wallet_format_exports = {};
20
+ __export(wallet_format_exports, {
21
+ explorerTokenUrl: () => explorerTokenUrl,
22
+ explorerTxUrl: () => explorerTxUrl,
23
+ fmt: () => fmt,
24
+ fmtUsd: () => fmtUsd,
25
+ rawToNumber: () => rawToNumber,
26
+ short: () => short,
27
+ when: () => when
28
+ });
29
+ module.exports = __toCommonJS(wallet_format_exports);
30
+ var import_sdk = require("@medialane/sdk");
31
+ const short = (a) => a && a.length > 12 ? `${a.slice(0, 6)}\u2026${a.slice(-4)}` : a ?? "";
32
+ const explorerTokenUrl = (explorerUrl, address) => `${explorerUrl}/token/${address}`;
33
+ const explorerTxUrl = (explorerUrl, txHash) => `${explorerUrl}/tx/${txHash}`;
34
+ const rawToNumber = (raw, decimals) => {
35
+ if (raw == null) return 0;
36
+ return Number(raw) / 10 ** decimals;
37
+ };
38
+ const fmt = (raw, decimals = 18, dp = 4) => {
39
+ if (raw == null) return "\u2014";
40
+ const [whole, frac = ""] = (0, import_sdk.formatAmount)(raw.toString(), decimals).split(".");
41
+ const t = frac.slice(0, dp).replace(/0+$/, "");
42
+ return t ? `${whole}.${t}` : whole;
43
+ };
44
+ const fmtUsd = (n) => n > 0 && n < 0.01 ? "<$0.01" : `$${n.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
45
+ const when = (iso) => {
46
+ const d = new Date(iso);
47
+ return Number.isNaN(d.getTime()) ? iso : d.toLocaleDateString(void 0, { month: "short", day: "numeric" });
48
+ };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ explorerTokenUrl,
52
+ explorerTxUrl,
53
+ fmt,
54
+ fmtUsd,
55
+ rawToNumber,
56
+ short,
57
+ when
58
+ });
59
+ //# sourceMappingURL=wallet-format.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/wallet-format.ts"],"sourcesContent":["import { formatAmount } from \"@medialane/sdk\";\n\nexport const short = (a?: string | null): string =>\n a && a.length > 12 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a ?? \"\";\n\nexport const explorerTokenUrl = (explorerUrl: string, address: string): string => `${explorerUrl}/token/${address}`;\nexport const explorerTxUrl = (explorerUrl: string, txHash: string): string => `${explorerUrl}/tx/${txHash}`;\n\nexport const rawToNumber = (raw: bigint | null, decimals: number): number => {\n if (raw == null) return 0;\n return Number(raw) / 10 ** decimals;\n};\n\nexport const fmt = (raw: bigint | null, decimals = 18, dp = 4): string => {\n if (raw == null) return \"—\";\n const [whole, frac = \"\"] = formatAmount(raw.toString(), decimals).split(\".\");\n const t = frac.slice(0, dp).replace(/0+$/, \"\");\n return t ? `${whole}.${t}` : whole;\n};\n\nexport const fmtUsd = (n: number): string =>\n n > 0 && n < 0.01 ? \"<$0.01\" : `$${n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;\n\nexport const when = (iso: string): string => {\n const d = new Date(iso);\n return Number.isNaN(d.getTime())\n ? iso\n : d.toLocaleDateString(undefined, { month: \"short\", day: \"numeric\" });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA6B;AAEtB,MAAM,QAAQ,CAAC,MACpB,KAAK,EAAE,SAAS,KAAK,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,SAAI,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK;AAEzD,MAAM,mBAAmB,CAAC,aAAqB,YAA4B,GAAG,WAAW,UAAU,OAAO;AAC1G,MAAM,gBAAgB,CAAC,aAAqB,WAA2B,GAAG,WAAW,OAAO,MAAM;AAElG,MAAM,cAAc,CAAC,KAAoB,aAA6B;AAC3E,MAAI,OAAO,KAAM,QAAO;AACxB,SAAO,OAAO,GAAG,IAAI,MAAM;AAC7B;AAEO,MAAM,MAAM,CAAC,KAAoB,WAAW,IAAI,KAAK,MAAc;AACxE,MAAI,OAAO,KAAM,QAAO;AACxB,QAAM,CAAC,OAAO,OAAO,EAAE,QAAI,yBAAa,IAAI,SAAS,GAAG,QAAQ,EAAE,MAAM,GAAG;AAC3E,QAAM,IAAI,KAAK,MAAM,GAAG,EAAE,EAAE,QAAQ,OAAO,EAAE;AAC7C,SAAO,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK;AAC/B;AAEO,MAAM,SAAS,CAAC,MACrB,IAAI,KAAK,IAAI,OAAO,WAAW,IAAI,EAAE,eAAe,QAAW,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,CAAC,CAAC;AAEjH,MAAM,OAAO,CAAC,QAAwB;AAC3C,QAAM,IAAI,IAAI,KAAK,GAAG;AACtB,SAAO,OAAO,MAAM,EAAE,QAAQ,CAAC,IAC3B,MACA,EAAE,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,UAAU,CAAC;AACxE;","names":[]}
@@ -0,0 +1,9 @@
1
+ declare const short: (a?: string | null) => string;
2
+ declare const explorerTokenUrl: (explorerUrl: string, address: string) => string;
3
+ declare const explorerTxUrl: (explorerUrl: string, txHash: string) => string;
4
+ declare const rawToNumber: (raw: bigint | null, decimals: number) => number;
5
+ declare const fmt: (raw: bigint | null, decimals?: number, dp?: number) => string;
6
+ declare const fmtUsd: (n: number) => string;
7
+ declare const when: (iso: string) => string;
8
+
9
+ export { explorerTokenUrl, explorerTxUrl, fmt, fmtUsd, rawToNumber, short, when };
@@ -0,0 +1,9 @@
1
+ declare const short: (a?: string | null) => string;
2
+ declare const explorerTokenUrl: (explorerUrl: string, address: string) => string;
3
+ declare const explorerTxUrl: (explorerUrl: string, txHash: string) => string;
4
+ declare const rawToNumber: (raw: bigint | null, decimals: number) => number;
5
+ declare const fmt: (raw: bigint | null, decimals?: number, dp?: number) => string;
6
+ declare const fmtUsd: (n: number) => string;
7
+ declare const when: (iso: string) => string;
8
+
9
+ export { explorerTokenUrl, explorerTxUrl, fmt, fmtUsd, rawToNumber, short, when };
@@ -0,0 +1,29 @@
1
+ import { formatAmount } from "@medialane/sdk";
2
+ const short = (a) => a && a.length > 12 ? `${a.slice(0, 6)}\u2026${a.slice(-4)}` : a ?? "";
3
+ const explorerTokenUrl = (explorerUrl, address) => `${explorerUrl}/token/${address}`;
4
+ const explorerTxUrl = (explorerUrl, txHash) => `${explorerUrl}/tx/${txHash}`;
5
+ const rawToNumber = (raw, decimals) => {
6
+ if (raw == null) return 0;
7
+ return Number(raw) / 10 ** decimals;
8
+ };
9
+ const fmt = (raw, decimals = 18, dp = 4) => {
10
+ if (raw == null) return "\u2014";
11
+ const [whole, frac = ""] = formatAmount(raw.toString(), decimals).split(".");
12
+ const t = frac.slice(0, dp).replace(/0+$/, "");
13
+ return t ? `${whole}.${t}` : whole;
14
+ };
15
+ const fmtUsd = (n) => n > 0 && n < 0.01 ? "<$0.01" : `$${n.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
16
+ const when = (iso) => {
17
+ const d = new Date(iso);
18
+ return Number.isNaN(d.getTime()) ? iso : d.toLocaleDateString(void 0, { month: "short", day: "numeric" });
19
+ };
20
+ export {
21
+ explorerTokenUrl,
22
+ explorerTxUrl,
23
+ fmt,
24
+ fmtUsd,
25
+ rawToNumber,
26
+ short,
27
+ when
28
+ };
29
+ //# sourceMappingURL=wallet-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/wallet-format.ts"],"sourcesContent":["import { formatAmount } from \"@medialane/sdk\";\n\nexport const short = (a?: string | null): string =>\n a && a.length > 12 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a ?? \"\";\n\nexport const explorerTokenUrl = (explorerUrl: string, address: string): string => `${explorerUrl}/token/${address}`;\nexport const explorerTxUrl = (explorerUrl: string, txHash: string): string => `${explorerUrl}/tx/${txHash}`;\n\nexport const rawToNumber = (raw: bigint | null, decimals: number): number => {\n if (raw == null) return 0;\n return Number(raw) / 10 ** decimals;\n};\n\nexport const fmt = (raw: bigint | null, decimals = 18, dp = 4): string => {\n if (raw == null) return \"—\";\n const [whole, frac = \"\"] = formatAmount(raw.toString(), decimals).split(\".\");\n const t = frac.slice(0, dp).replace(/0+$/, \"\");\n return t ? `${whole}.${t}` : whole;\n};\n\nexport const fmtUsd = (n: number): string =>\n n > 0 && n < 0.01 ? \"<$0.01\" : `$${n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;\n\nexport const when = (iso: string): string => {\n const d = new Date(iso);\n return Number.isNaN(d.getTime())\n ? iso\n : d.toLocaleDateString(undefined, { month: \"short\", day: \"numeric\" });\n};\n"],"mappings":"AAAA,SAAS,oBAAoB;AAEtB,MAAM,QAAQ,CAAC,MACpB,KAAK,EAAE,SAAS,KAAK,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,SAAI,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK;AAEzD,MAAM,mBAAmB,CAAC,aAAqB,YAA4B,GAAG,WAAW,UAAU,OAAO;AAC1G,MAAM,gBAAgB,CAAC,aAAqB,WAA2B,GAAG,WAAW,OAAO,MAAM;AAElG,MAAM,cAAc,CAAC,KAAoB,aAA6B;AAC3E,MAAI,OAAO,KAAM,QAAO;AACxB,SAAO,OAAO,GAAG,IAAI,MAAM;AAC7B;AAEO,MAAM,MAAM,CAAC,KAAoB,WAAW,IAAI,KAAK,MAAc;AACxE,MAAI,OAAO,KAAM,QAAO;AACxB,QAAM,CAAC,OAAO,OAAO,EAAE,IAAI,aAAa,IAAI,SAAS,GAAG,QAAQ,EAAE,MAAM,GAAG;AAC3E,QAAM,IAAI,KAAK,MAAM,GAAG,EAAE,EAAE,QAAQ,OAAO,EAAE;AAC7C,SAAO,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK;AAC/B;AAEO,MAAM,SAAS,CAAC,MACrB,IAAI,KAAK,IAAI,OAAO,WAAW,IAAI,EAAE,eAAe,QAAW,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,CAAC,CAAC;AAEjH,MAAM,OAAO,CAAC,QAAwB;AAC3C,QAAM,IAAI,IAAI,KAAK,GAAG;AACtB,SAAO,OAAO,MAAM,EAAE,QAAQ,CAAC,IAC3B,MACA,EAAE,mBAAmB,QAAW,EAAE,OAAO,SAAS,KAAK,UAAU,CAAC;AACxE;","names":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var wallet_tokens_exports = {};
20
+ __export(wallet_tokens_exports, {
21
+ WALLET_TOKENS: () => WALLET_TOKENS
22
+ });
23
+ module.exports = __toCommonJS(wallet_tokens_exports);
24
+ var import_sdk = require("@medialane/sdk");
25
+ const tokenFor = (symbol, name) => {
26
+ const t = (0, import_sdk.getTokenBySymbol)(symbol);
27
+ return { symbol, name, address: t.address, decimals: t.decimals };
28
+ };
29
+ const WALLET_TOKENS = [
30
+ tokenFor("STRK", "Starknet"),
31
+ tokenFor("ETH", "Ethereum"),
32
+ tokenFor("USDC", "USD Coin"),
33
+ tokenFor("WBTC", "Wrapped BTC")
34
+ ];
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ WALLET_TOKENS
38
+ });
39
+ //# sourceMappingURL=wallet-tokens.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/wallet-tokens.ts"],"sourcesContent":["import { getTokenBySymbol } from \"@medialane/sdk\";\n\nexport type WalletTokenSymbol = string;\n\nexport interface WalletToken {\n symbol: WalletTokenSymbol;\n name: string;\n address: string;\n decimals: number;\n}\n\nconst tokenFor = (symbol: WalletTokenSymbol, name: string): WalletToken => {\n const t = getTokenBySymbol(symbol)!;\n return { symbol, name, address: t.address, decimals: t.decimals };\n};\n\nexport const WALLET_TOKENS: WalletToken[] = [\n tokenFor(\"STRK\", \"Starknet\"),\n tokenFor(\"ETH\", \"Ethereum\"),\n tokenFor(\"USDC\", \"USD Coin\"),\n tokenFor(\"WBTC\", \"Wrapped BTC\"),\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiC;AAWjC,MAAM,WAAW,CAAC,QAA2B,SAA8B;AACzE,QAAM,QAAI,6BAAiB,MAAM;AACjC,SAAO,EAAE,QAAQ,MAAM,SAAS,EAAE,SAAS,UAAU,EAAE,SAAS;AAClE;AAEO,MAAM,gBAA+B;AAAA,EAC1C,SAAS,QAAQ,UAAU;AAAA,EAC3B,SAAS,OAAO,UAAU;AAAA,EAC1B,SAAS,QAAQ,UAAU;AAAA,EAC3B,SAAS,QAAQ,aAAa;AAChC;","names":[]}
@@ -0,0 +1,10 @@
1
+ type WalletTokenSymbol = string;
2
+ interface WalletToken {
3
+ symbol: WalletTokenSymbol;
4
+ name: string;
5
+ address: string;
6
+ decimals: number;
7
+ }
8
+ declare const WALLET_TOKENS: WalletToken[];
9
+
10
+ export { WALLET_TOKENS, type WalletToken, type WalletTokenSymbol };
@@ -0,0 +1,10 @@
1
+ type WalletTokenSymbol = string;
2
+ interface WalletToken {
3
+ symbol: WalletTokenSymbol;
4
+ name: string;
5
+ address: string;
6
+ decimals: number;
7
+ }
8
+ declare const WALLET_TOKENS: WalletToken[];
9
+
10
+ export { WALLET_TOKENS, type WalletToken, type WalletTokenSymbol };