@jaw.id/ui 0.0.1

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 (170) hide show
  1. package/.babelrc +12 -0
  2. package/README.md +55 -0
  3. package/components.json +22 -0
  4. package/dist/ccip-Cdkx99iZ.js +147 -0
  5. package/dist/components/ConnectDialog/index.d.ts +4 -0
  6. package/dist/components/ConnectDialog/index.d.ts.map +1 -0
  7. package/dist/components/ConnectDialog/types.d.ts +20 -0
  8. package/dist/components/ConnectDialog/types.d.ts.map +1 -0
  9. package/dist/components/DefaultDialog/index.d.ts +14 -0
  10. package/dist/components/DefaultDialog/index.d.ts.map +1 -0
  11. package/dist/components/Eip712Dialog/index.d.ts +4 -0
  12. package/dist/components/Eip712Dialog/index.d.ts.map +1 -0
  13. package/dist/components/Eip712Dialog/types.d.ts +19 -0
  14. package/dist/components/Eip712Dialog/types.d.ts.map +1 -0
  15. package/dist/components/FeeTokenSelector/index.d.ts +26 -0
  16. package/dist/components/FeeTokenSelector/index.d.ts.map +1 -0
  17. package/dist/components/OnboardingDialog/index.d.ts +4 -0
  18. package/dist/components/OnboardingDialog/index.d.ts.map +1 -0
  19. package/dist/components/OnboardingDialog/types.d.ts +36 -0
  20. package/dist/components/OnboardingDialog/types.d.ts.map +1 -0
  21. package/dist/components/OrSeparator/index.d.ts +2 -0
  22. package/dist/components/OrSeparator/index.d.ts.map +1 -0
  23. package/dist/components/PermissionDialog/index.d.ts +4 -0
  24. package/dist/components/PermissionDialog/index.d.ts.map +1 -0
  25. package/dist/components/PermissionDialog/types.d.ts +49 -0
  26. package/dist/components/PermissionDialog/types.d.ts.map +1 -0
  27. package/dist/components/SignatureDialog/index.d.ts +4 -0
  28. package/dist/components/SignatureDialog/index.d.ts.map +1 -0
  29. package/dist/components/SignatureDialog/types.d.ts +19 -0
  30. package/dist/components/SignatureDialog/types.d.ts.map +1 -0
  31. package/dist/components/SiweDialog/index.d.ts +4 -0
  32. package/dist/components/SiweDialog/index.d.ts.map +1 -0
  33. package/dist/components/SiweDialog/types.d.ts +22 -0
  34. package/dist/components/SiweDialog/types.d.ts.map +1 -0
  35. package/dist/components/TransactionDialog/DecodedCalldata.d.ts +9 -0
  36. package/dist/components/TransactionDialog/DecodedCalldata.d.ts.map +1 -0
  37. package/dist/components/TransactionDialog/index.d.ts +4 -0
  38. package/dist/components/TransactionDialog/index.d.ts.map +1 -0
  39. package/dist/components/TransactionDialog/types.d.ts +34 -0
  40. package/dist/components/TransactionDialog/types.d.ts.map +1 -0
  41. package/dist/components/ui/accordion.d.ts +8 -0
  42. package/dist/components/ui/accordion.d.ts.map +1 -0
  43. package/dist/components/ui/avatar.d.ts +7 -0
  44. package/dist/components/ui/avatar.d.ts.map +1 -0
  45. package/dist/components/ui/button.d.ts +11 -0
  46. package/dist/components/ui/button.d.ts.map +1 -0
  47. package/dist/components/ui/card.d.ts +10 -0
  48. package/dist/components/ui/card.d.ts.map +1 -0
  49. package/dist/components/ui/checkbox.d.ts +5 -0
  50. package/dist/components/ui/checkbox.d.ts.map +1 -0
  51. package/dist/components/ui/dialog.d.ts +18 -0
  52. package/dist/components/ui/dialog.d.ts.map +1 -0
  53. package/dist/components/ui/dropdown-menu.d.ts +26 -0
  54. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  55. package/dist/components/ui/form.d.ts +25 -0
  56. package/dist/components/ui/form.d.ts.map +1 -0
  57. package/dist/components/ui/input.d.ts +8 -0
  58. package/dist/components/ui/input.d.ts.map +1 -0
  59. package/dist/components/ui/label.d.ts +5 -0
  60. package/dist/components/ui/label.d.ts.map +1 -0
  61. package/dist/components/ui/popover.d.ts +8 -0
  62. package/dist/components/ui/popover.d.ts.map +1 -0
  63. package/dist/components/ui/scroll-area.d.ts +6 -0
  64. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  65. package/dist/components/ui/select.d.ts +14 -0
  66. package/dist/components/ui/select.d.ts.map +1 -0
  67. package/dist/components/ui/separator.d.ts +5 -0
  68. package/dist/components/ui/separator.d.ts.map +1 -0
  69. package/dist/components/ui/sheet.d.ts +14 -0
  70. package/dist/components/ui/sheet.d.ts.map +1 -0
  71. package/dist/components/ui/spinner.d.ts +3 -0
  72. package/dist/components/ui/spinner.d.ts.map +1 -0
  73. package/dist/components/ui/tabs.d.ts +8 -0
  74. package/dist/components/ui/tabs.d.ts.map +1 -0
  75. package/dist/components/ui/tooltip.d.ts +8 -0
  76. package/dist/components/ui/tooltip.d.ts.map +1 -0
  77. package/dist/hooks/index.d.ts +6 -0
  78. package/dist/hooks/index.d.ts.map +1 -0
  79. package/dist/hooks/useChainIconURI.d.ts +12 -0
  80. package/dist/hooks/useChainIconURI.d.ts.map +1 -0
  81. package/dist/hooks/useDecodedCalldata.d.ts +15 -0
  82. package/dist/hooks/useDecodedCalldata.d.ts.map +1 -0
  83. package/dist/hooks/useFeeTokenPrice.d.ts +8 -0
  84. package/dist/hooks/useFeeTokenPrice.d.ts.map +1 -0
  85. package/dist/hooks/useGasEstimation.d.ts +77 -0
  86. package/dist/hooks/useGasEstimation.d.ts.map +1 -0
  87. package/dist/hooks/useIsMobile.d.ts +2 -0
  88. package/dist/hooks/useIsMobile.d.ts.map +1 -0
  89. package/dist/icons/index.d.ts +12 -0
  90. package/dist/icons/index.d.ts.map +1 -0
  91. package/dist/index-DlfjdYW4.js +83119 -0
  92. package/dist/index.css +1 -0
  93. package/dist/index.d.ts +16 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +38 -0
  96. package/dist/lib/utils.d.ts +3 -0
  97. package/dist/lib/utils.d.ts.map +1 -0
  98. package/dist/react/ReactUIHandler.d.ts +35 -0
  99. package/dist/react/ReactUIHandler.d.ts.map +1 -0
  100. package/dist/react/index.d.ts +2 -0
  101. package/dist/react/index.d.ts.map +1 -0
  102. package/dist/utils/formatAddress.d.ts +18 -0
  103. package/dist/utils/formatAddress.d.ts.map +1 -0
  104. package/dist/utils/index.d.ts +5 -0
  105. package/dist/utils/index.d.ts.map +1 -0
  106. package/dist/utils/justaNameInstance.d.ts +7 -0
  107. package/dist/utils/justaNameInstance.d.ts.map +1 -0
  108. package/dist/utils/tokenBalance.d.ts +10 -0
  109. package/dist/utils/tokenBalance.d.ts.map +1 -0
  110. package/dist/utils/tokenPrice.d.ts +12 -0
  111. package/dist/utils/tokenPrice.d.ts.map +1 -0
  112. package/package.json +67 -0
  113. package/postcss.config.cjs +6 -0
  114. package/src/components/ConnectDialog/index.tsx +270 -0
  115. package/src/components/ConnectDialog/types.ts +34 -0
  116. package/src/components/DefaultDialog/index.tsx +99 -0
  117. package/src/components/Eip712Dialog/index.tsx +525 -0
  118. package/src/components/Eip712Dialog/types.ts +27 -0
  119. package/src/components/FeeTokenSelector/index.tsx +308 -0
  120. package/src/components/OnboardingDialog/index.tsx +317 -0
  121. package/src/components/OnboardingDialog/types.ts +43 -0
  122. package/src/components/OrSeparator/index.tsx +13 -0
  123. package/src/components/PermissionDialog/index.tsx +598 -0
  124. package/src/components/PermissionDialog/types.ts +77 -0
  125. package/src/components/SignatureDialog/index.tsx +180 -0
  126. package/src/components/SignatureDialog/types.ts +27 -0
  127. package/src/components/SiweDialog/index.tsx +231 -0
  128. package/src/components/SiweDialog/types.ts +34 -0
  129. package/src/components/TransactionDialog/DecodedCalldata.tsx +79 -0
  130. package/src/components/TransactionDialog/index.tsx +663 -0
  131. package/src/components/TransactionDialog/types.ts +54 -0
  132. package/src/components/ui/accordion.tsx +66 -0
  133. package/src/components/ui/avatar.tsx +53 -0
  134. package/src/components/ui/button.tsx +59 -0
  135. package/src/components/ui/card.tsx +92 -0
  136. package/src/components/ui/checkbox.tsx +32 -0
  137. package/src/components/ui/dialog.tsx +183 -0
  138. package/src/components/ui/dropdown-menu.tsx +258 -0
  139. package/src/components/ui/form.tsx +167 -0
  140. package/src/components/ui/input.tsx +60 -0
  141. package/src/components/ui/label.tsx +24 -0
  142. package/src/components/ui/popover.tsx +48 -0
  143. package/src/components/ui/scroll-area.tsx +58 -0
  144. package/src/components/ui/select.tsx +160 -0
  145. package/src/components/ui/separator.tsx +28 -0
  146. package/src/components/ui/sheet.tsx +169 -0
  147. package/src/components/ui/spinner.tsx +18 -0
  148. package/src/components/ui/tabs.tsx +69 -0
  149. package/src/components/ui/tooltip.tsx +61 -0
  150. package/src/hooks/index.ts +5 -0
  151. package/src/hooks/useChainIconURI.tsx +117 -0
  152. package/src/hooks/useDecodedCalldata.ts +128 -0
  153. package/src/hooks/useFeeTokenPrice.tsx +36 -0
  154. package/src/hooks/useGasEstimation.ts +474 -0
  155. package/src/hooks/useIsMobile.ts +36 -0
  156. package/src/icons/index.tsx +114 -0
  157. package/src/index.ts +19 -0
  158. package/src/lib/utils.ts +6 -0
  159. package/src/react/ReactUIHandler.tsx +3004 -0
  160. package/src/react/index.ts +2 -0
  161. package/src/styles.css +210 -0
  162. package/src/utils/formatAddress.ts +24 -0
  163. package/src/utils/index.ts +4 -0
  164. package/src/utils/justaNameInstance.ts +25 -0
  165. package/src/utils/tokenBalance.ts +41 -0
  166. package/src/utils/tokenPrice.ts +58 -0
  167. package/tailwind.config.js +130 -0
  168. package/tsconfig.json +19 -0
  169. package/tsconfig.lib.json +43 -0
  170. package/vite.config.ts +45 -0
@@ -0,0 +1,16 @@
1
+ export * from './components/DefaultDialog';
2
+ export * from './components/OrSeparator';
3
+ export * from './components/OnboardingDialog';
4
+ export * from './components/TransactionDialog';
5
+ export * from './components/SignatureDialog';
6
+ export * from './components/SiweDialog';
7
+ export * from './components/ConnectDialog';
8
+ export * from './components/Eip712Dialog';
9
+ export * from './components/PermissionDialog';
10
+ export * from './components/FeeTokenSelector';
11
+ export * from './lib/utils';
12
+ export * from './icons';
13
+ export * from './hooks';
14
+ export * from './utils';
15
+ export * from './react';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ import { q as e, m as o, C as n, o as c, n as i, D as t, E as l, r, p as I, F as d, G as g, L as D, h as k, O as u, P as T, R as C, S as p, j as h, T as m, U as f, t as E, W as P, I as S, k as U, N as y, A, J as F, K as G, z as N, M as O, v as R, y as b, w as v, x as w, u as x } from "./index-DlfjdYW4.js";
2
+ export {
3
+ e as BadgeDollarIcon,
4
+ o as CloseIcon,
5
+ n as ConnectDialog,
6
+ c as CopiedIcon,
7
+ i as CopyIcon,
8
+ t as DefaultDialog,
9
+ l as Eip712Dialog,
10
+ r as EthIcon,
11
+ I as EyeIcon,
12
+ d as FeeTokenSelector,
13
+ g as GenericTokenIcon,
14
+ D as LockIcon,
15
+ k as OnboardingDialog,
16
+ u as OrSeparator,
17
+ T as PermissionDialog,
18
+ C as ReactUIHandler,
19
+ p as SignatureDialog,
20
+ h as SiweDialog,
21
+ m as TransactionDialog,
22
+ f as UsdcIcon,
23
+ E as UsdtIcon,
24
+ P as WalletIcon,
25
+ S as clearTokenPriceCache,
26
+ U as cn,
27
+ y as fetchTokenBalance,
28
+ A as fetchTokenPrice,
29
+ F as formatAddress,
30
+ G as getDisplayAddress,
31
+ N as getJustaNameInstance,
32
+ O as isNativeToken,
33
+ R as useChainIconURI,
34
+ b as useDecodedCalldata,
35
+ v as useFeeTokenPrice,
36
+ w as useGasEstimation,
37
+ x as useIsMobile
38
+ };
@@ -0,0 +1,3 @@
1
+ import { ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
@@ -0,0 +1,35 @@
1
+ import { UIHandler, UIHandlerConfig, UIRequest, UIResponse } from '../../../core/src/index.ts';
2
+ /**
3
+ * React UI handler for app-specific mode
4
+ *
5
+ * This handler is automatically initialized by the SDK with the necessary configuration.
6
+ * Simply pass a new instance to JAW.create() and the SDK will call init() with the config.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { JAW, Mode } from '@jaw.id/core';
11
+ * import { ReactUIHandler } from '@jaw.id/ui';
12
+ *
13
+ * const jaw = JAW.create({
14
+ * apiKey: 'your-api-key',
15
+ * defaultChainId: 1,
16
+ * preference: {
17
+ * mode: Mode.AppSpecific,
18
+ * uiHandler: new ReactUIHandler(),
19
+ * },
20
+ * });
21
+ * ```
22
+ */
23
+ export declare class ReactUIHandler implements UIHandler {
24
+ private config;
25
+ /**
26
+ * Initialize the handler with SDK configuration
27
+ * Called automatically by the SDK - do not call directly
28
+ */
29
+ init(config: UIHandlerConfig): void;
30
+ request<T = unknown>(request: UIRequest): Promise<UIResponse<T>>;
31
+ canHandle(request: UIRequest): boolean;
32
+ cleanup(): Promise<void>;
33
+ private renderDialog;
34
+ }
35
+ //# sourceMappingURL=ReactUIHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactUIHandler.d.ts","sourceRoot":"","sources":["../../src/react/ReactUIHandler.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACT,eAAe,EACf,SAAS,EACT,UAAU,EA0BX,MAAM,cAAc,CAAC;AAyGtB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC9C,OAAO,CAAC,MAAM,CAA0C;IAExD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAI7B,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAuDtE,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO;IAahC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,OAAO,CAAC,YAAY;CAuMrB"}
@@ -0,0 +1,2 @@
1
+ export { ReactUIHandler } from './ReactUIHandler';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Truncates an Ethereum address for display
3
+ * Shows first 6 characters + ... + last 4 characters
4
+ *
5
+ * @example
6
+ * formatAddress('0x1234567890abcdef1234567890abcdef12345678')
7
+ * // Returns: '0x1234...5678'
8
+ */
9
+ export declare const formatAddress: (address: string) => string;
10
+ /**
11
+ * Returns the display string for an address - either the resolved name or formatted address
12
+ *
13
+ * @param resolvedName - The resolved ENS/subname (if any)
14
+ * @param address - The raw Ethereum address
15
+ * @returns The resolved name if available, otherwise the formatted address
16
+ */
17
+ export declare const getDisplayAddress: (resolvedName: string | null | undefined, address: string) => string;
18
+ //# sourceMappingURL=formatAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatAddress.d.ts","sourceRoot":"","sources":["../../src/utils/formatAddress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,MAG/C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,cAAc,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,MAAM,KAAG,MAG5F,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './justaNameInstance';
2
+ export * from './tokenPrice';
3
+ export * from './formatAddress';
4
+ export * from './tokenBalance';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { JustaName } from '@justaname.id/sdk';
2
+ /**
3
+ * Get or create the singleton JustaName SDK instance
4
+ * @param providerUrl - The Ethereum mainnet RPC URL for ENS resolution
5
+ */
6
+ export declare function getJustaNameInstance(providerUrl: string): JustaName;
7
+ //# sourceMappingURL=justaNameInstance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"justaNameInstance.d.ts","sourceRoot":"","sources":["../../src/utils/justaNameInstance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK9C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,aAcvD"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks if a token address represents the native token (ETH)
3
+ */
4
+ export declare function isNativeToken(tokenAddress: string): boolean;
5
+ /**
6
+ * Fetches the balance of a token for a given wallet address.
7
+ * Supports both native ETH (address = 0x0...0 or 0xeee...eee) and ERC-20 tokens.
8
+ */
9
+ export declare function fetchTokenBalance(tokenAddress: string, walletAddress: string, rpcUrl: string): Promise<bigint>;
10
+ //# sourceMappingURL=tokenBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenBalance.d.ts","sourceRoot":"","sources":["../../src/utils/tokenBalance.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Fetches the current price in USD for a token by its symbol from CryptoCompare API
3
+ * Results are cached for 5 minutes per symbol to reduce API calls
4
+ * @param symbol - The token symbol (ETH, AVAX, BNB, USDC, etc.)
5
+ * @returns Promise<number> - The token price in USD, or 0 if fetch fails
6
+ */
7
+ export declare function fetchTokenPrice(symbol: string): Promise<number>;
8
+ /**
9
+ * Clears all token price caches (useful for testing or forcing refresh)
10
+ */
11
+ export declare function clearTokenPriceCache(): void;
12
+ //# sourceMappingURL=tokenPrice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenPrice.d.ts","sourceRoot":"","sources":["../../src/utils/tokenPrice.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@jaw.id/ui",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "sideEffects": [
6
+ "**/*.css",
7
+ "./src/styles.css",
8
+ "./dist/index.css"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/JustaName-id/jaw-mono.git",
13
+ "directory": "packages/ui"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "main": "./dist/index.js",
19
+ "module": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "@jaw-mono/source": "./src/index.ts",
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.js"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "react": ">=18.0.0",
32
+ "react-dom": ">=18.0.0"
33
+ },
34
+ "dependencies": {
35
+ "@jaw.id/core": "0.0.1",
36
+ "@hookform/resolvers": "^5.2.2",
37
+ "@justaname.id/sdk": "^0.2.204",
38
+ "@radix-ui/react-accordion": "^1.2.12",
39
+ "@radix-ui/react-avatar": "^1.1.10",
40
+ "@radix-ui/react-checkbox": "^1.3.3",
41
+ "@radix-ui/react-dialog": "^1.1.15",
42
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
43
+ "@radix-ui/react-label": "^2.1.7",
44
+ "@radix-ui/react-popover": "^1.1.15",
45
+ "@radix-ui/react-scroll-area": "^1.2.10",
46
+ "@radix-ui/react-select": "^2.2.6",
47
+ "@radix-ui/react-separator": "^1.1.7",
48
+ "@radix-ui/react-slot": "^1.2.3",
49
+ "@radix-ui/react-tabs": "^1.1.9",
50
+ "@radix-ui/react-tooltip": "^1.2.8",
51
+ "class-variance-authority": "^0.7.1",
52
+ "clsx": "^2.1.1",
53
+ "lucide-react": "^0.545.0",
54
+ "react-hook-form": "^7.65.0",
55
+ "tailwind-merge": "^3.3.1",
56
+ "tailwindcss-animate": "^1.0.7",
57
+ "@shazow/whatsabi": "^0.26.0",
58
+ "viem": "^2.38.2",
59
+ "zod": "^4.1.12"
60
+ },
61
+ "devDependencies": {
62
+ "autoprefixer": "^10.4.21",
63
+ "postcss": "^8.5.6",
64
+ "tailwindcss": "3",
65
+ "vite-plugin-lib-inject-css": "^2.2.2"
66
+ }
67
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,270 @@
1
+ 'use client'
2
+
3
+ import { useState, useEffect } from "react";
4
+ import { BadgeDollarIcon, EyeIcon, CopyIcon, CopiedIcon } from "../../icons";
5
+ import { useIsMobile } from "../../hooks";
6
+ import { DefaultDialog } from "../DefaultDialog";
7
+ import { Button } from "../ui/button";
8
+ import { ConnectDialogProps } from "./types";
9
+ import { getJustaNameInstance } from "../../utils/justaNameInstance";
10
+
11
+ export const ConnectDialog = ({
12
+ open,
13
+ onOpenChange,
14
+ appName,
15
+ appLogoUrl,
16
+ origin,
17
+ timestamp,
18
+ accountName,
19
+ walletAddress,
20
+ chainName,
21
+ chainId,
22
+ chainIcon,
23
+ mainnetRpcUrl,
24
+ onConnect,
25
+ onCancel,
26
+ showPermissions = true,
27
+ isProcessing,
28
+ }: ConnectDialogProps) => {
29
+ const isMobile = useIsMobile();
30
+ const [resolvedAddress, setResolvedAddress] = useState<string | null>(null);
31
+ const [isAddressCopied, setIsAddressCopied] = useState(false);
32
+
33
+ // Resolve wallet address to human-readable name
34
+ useEffect(() => {
35
+ if (walletAddress && chainId) {
36
+ const justaName = getJustaNameInstance(mainnetRpcUrl);
37
+ justaName.subnames.reverseResolve({
38
+ address: walletAddress as `0x${string}`,
39
+ chainId: chainId,
40
+ }).then((result) => {
41
+ if (result) {
42
+ setResolvedAddress(result);
43
+ }
44
+ }).catch(() => {
45
+ // Silently fail if resolution fails
46
+ });
47
+ }
48
+ }, [walletAddress, chainId]);
49
+
50
+ // Use resolved address, then accountName prop, then truncated address
51
+ const displayName = resolvedAddress || accountName;
52
+
53
+ // Format origin to display only domain (remove protocol)
54
+ const formatOrigin = (url: string) => {
55
+ try {
56
+ const urlObj = new URL(url.startsWith('http') ? url : `https://${url}`);
57
+ return urlObj.hostname.replace('www.', '');
58
+ } catch {
59
+ return origin;
60
+ }
61
+ };
62
+
63
+ const copyToClipboard = (text: string) => {
64
+ if (typeof window !== 'undefined' && navigator?.clipboard) {
65
+ navigator.clipboard.writeText(text);
66
+ setIsAddressCopied(true);
67
+ setTimeout(() => setIsAddressCopied(false), 3000);
68
+ }
69
+ };
70
+
71
+ // Format wallet address for display
72
+ const formatAddress = (address: string) => {
73
+ if (!address || address.length < 10) return address;
74
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
75
+ };
76
+
77
+ return (
78
+ <DefaultDialog
79
+ open={open}
80
+ handleClose={onCancel}
81
+ onOpenChange={!isProcessing ? onOpenChange : undefined}
82
+ header={
83
+ <div className="flex flex-col gap-2.5 p-3.5">
84
+ <p className="text-xs font-bold text-muted-foreground leading-[100%]">
85
+ {timestamp.toLocaleDateString('en-US', {
86
+ weekday: 'long',
87
+ day: 'numeric',
88
+ month: 'long'
89
+ })} at {timestamp.toLocaleTimeString('en-US', {
90
+ hour: '2-digit',
91
+ minute: '2-digit',
92
+ second: '2-digit',
93
+ timeZoneName: 'short'
94
+ })}
95
+ </p>
96
+ <div className="flex flex-col gap-1">
97
+ <div className="flex flex-row items-center gap-1">
98
+ <p className="text-sm leading-none text-muted-foreground">
99
+ Sign in as {displayName || formatAddress(walletAddress)}
100
+ </p>
101
+ {!displayName && (
102
+ isAddressCopied ? (
103
+ <CopiedIcon width={10} height={10} className="flex-shrink-0" />
104
+ ) : (
105
+ <CopyIcon
106
+ width={10}
107
+ height={10}
108
+ onClick={() => copyToClipboard(walletAddress)}
109
+ className="cursor-pointer flex-shrink-0"
110
+ />
111
+ )
112
+ )}
113
+ </div>
114
+ {displayName && (
115
+ <div className="flex flex-row items-center gap-1">
116
+ <p className="text-sm leading-none text-muted-foreground">
117
+ {formatAddress(walletAddress)}
118
+ </p>
119
+ {isAddressCopied ? (
120
+ <CopiedIcon width={10} height={10} className="flex-shrink-0" />
121
+ ) : (
122
+ <CopyIcon
123
+ width={10}
124
+ height={10}
125
+ onClick={() => copyToClipboard(walletAddress)}
126
+ className="cursor-pointer flex-shrink-0"
127
+ />
128
+ )}
129
+ </div>
130
+ )}
131
+ </div>
132
+ </div>
133
+ }
134
+ contentStyle={isMobile ? {
135
+ width: '100%',
136
+ height: '100%',
137
+ maxWidth: 'none',
138
+ maxHeight: 'none',
139
+ } : {
140
+ width: 'fit-content',
141
+ maxWidth: '500px',
142
+ }}
143
+ >
144
+ <div className="flex flex-col h-full gap-3 overflow-y-auto min-h-0">
145
+ {/* App Logo and Title */}
146
+ <div className="flex flex-1 flex-col p-3.5 items-center justify-center">
147
+ {appLogoUrl && (
148
+ <img
149
+ src={appLogoUrl}
150
+ alt={`${appName} logo`}
151
+ className="w-[72px] h-[72px] rounded-full mb-3"
152
+ />
153
+ )}
154
+ <div className="flex flex-col items-center gap-1 text-foreground">
155
+ <p className="text-2xl font-normal leading-[133%]">
156
+ Connect to {appName}
157
+ </p>
158
+ <p className="text-base leading-[150%] text-muted-foreground">
159
+ This app wants to connect to your wallet
160
+ </p>
161
+ </div>
162
+ </div>
163
+
164
+ {/* Account Details Card */}
165
+ {/* <div className="flex-1 p-3.5 bg-secondary border border-border rounded-[6px]">
166
+ <div className="flex flex-col gap-2">
167
+ <div className="flex justify-between items-center">
168
+ <span className="text-xs font-bold text-foreground">Account</span>
169
+ <span className="text-sm font-medium text-foreground">
170
+ {accountName || 'Wallet'}
171
+ </span>
172
+ </div>
173
+ <div className="flex justify-between items-center">
174
+ <span className="text-xs font-bold text-foreground">Address</span>
175
+ <span className="text-sm font-mono font-medium text-foreground">
176
+ {formatAddress(walletAddress)}
177
+ </span>
178
+ </div>
179
+ {supportedChains && supportedChains.length > 0 && (
180
+ <div className="flex justify-between items-center">
181
+ <span className="text-xs font-bold text-foreground">Chains</span>
182
+ <span className="text-sm font-medium text-foreground">
183
+ {supportedChains.length} {supportedChains.length === 1 ? 'chain' : 'chains'}
184
+ </span>
185
+ </div>
186
+ )}
187
+ </div>
188
+ </div> */}
189
+
190
+ {/* Permissions Section */}
191
+ {showPermissions && (
192
+ <div className="flex flex-col gap-2">
193
+ <div className="flex items-center flex-row gap-2.5 p-3.5 border border-border rounded-[6px]">
194
+ <EyeIcon className="w-4 h-4 flex-shrink-0" />
195
+ <p className="text-foreground text-xs font-normal leading-[150%]">
196
+ Allow the app to see your addresses
197
+ </p>
198
+ </div>
199
+ <div className="flex items-center flex-row gap-2.5 p-3.5 border border-border rounded-[6px]">
200
+ <BadgeDollarIcon className="w-4 h-4 flex-shrink-0" />
201
+ <p className="text-foreground text-xs font-normal leading-[150%]">
202
+ Allow the app to propose transactions
203
+ </p>
204
+ </div>
205
+ <div className="flex items-center flex-row gap-2.5 p-3.5 border border-border rounded-[6px]">
206
+ <BadgeDollarIcon className="w-4 h-4 flex-shrink-0" />
207
+ <p className="text-foreground text-xs font-normal leading-[150%]">
208
+ The app cannot move funds without your permission
209
+ </p>
210
+ </div>
211
+ </div>
212
+ )}
213
+
214
+ {/* Network and URL Information */}
215
+ <div className="flex flex-row gap-4 border border-border rounded-[6px] p-2">
216
+ {/* Network Column */}
217
+ {chainName && (
218
+ <>
219
+ <div className="flex flex-col gap-1 flex-1">
220
+ <p className="text-xs font-bold text-foreground">Network</p>
221
+ <div className="flex flex-row items-center gap-2">
222
+ {chainIcon && (
223
+ <div className="w-6 h-6 min-w-4 flex items-center justify-center flex-shrink-0">
224
+ {chainIcon}
225
+ </div>
226
+ )}
227
+ <p className="text-sm font-normal text-foreground">
228
+ {chainName}
229
+ </p>
230
+ </div>
231
+ </div>
232
+ {/* Vertical Separator */}
233
+ <div className="w-[1px] bg-border min-h-[40px]"></div>
234
+ </>
235
+ )}
236
+ {/* URL Column */}
237
+ <div className="flex flex-col gap-1 flex-1">
238
+ <p className="text-xs font-bold text-foreground">URL</p>
239
+ <p className="text-sm font-normal text-foreground">
240
+ {formatOrigin(origin)}
241
+ </p>
242
+ </div>
243
+ </div>
244
+
245
+ {/* Action Buttons Section */}
246
+ <div className="flex mt-3 flex-shrink-0">
247
+ <div className="flex gap-2 w-full justify-between">
248
+ <Button
249
+ variant="outline"
250
+ onClick={onCancel}
251
+ disabled={isProcessing}
252
+ className="flex-1"
253
+ >
254
+ Cancel
255
+ </Button>
256
+ <Button
257
+ onClick={onConnect}
258
+ disabled={isProcessing}
259
+ className="flex-1"
260
+ >
261
+ {isProcessing ? 'Connecting...' : 'Connect'}
262
+ </Button>
263
+ </div>
264
+ </div>
265
+ </div>
266
+ </DefaultDialog>
267
+ )
268
+ }
269
+
270
+ export * from './types';
@@ -0,0 +1,34 @@
1
+ import { JSX } from "react";
2
+
3
+ export interface ConnectDialogProps {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+
7
+ // App information
8
+ appName: string;
9
+ appLogoUrl?: string;
10
+ origin: string;
11
+ timestamp: Date;
12
+
13
+ // User account information
14
+ accountName?: string;
15
+ walletAddress: string;
16
+
17
+ // Chain information
18
+ chainName?: string;
19
+ chainId?: number;
20
+ chainIcon?: JSX.Element;
21
+
22
+ // RPC configuration
23
+ mainnetRpcUrl: string;
24
+
25
+ // Actions
26
+ onConnect: () => Promise<void>;
27
+ onCancel: () => void;
28
+
29
+ // Whether to show the permission info messages (default: true)
30
+ showPermissions?: boolean;
31
+
32
+ // Status
33
+ isProcessing: boolean;
34
+ }