@evefrontier/dapp-kit 0.1.8 → 0.2.0-alpha.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 (211) hide show
  1. package/README.md +28 -25
  2. package/dist/config/dapp-kit.d.ts +4 -0
  3. package/dist/config/dapp-kit.d.ts.map +1 -0
  4. package/dist/config/dapp-kit.js +14 -0
  5. package/dist/config/index.d.ts +2 -0
  6. package/dist/config/index.d.ts.map +1 -0
  7. package/dist/config/index.js +1 -0
  8. package/dist/graphql/client.d.ts +277 -0
  9. package/dist/graphql/client.d.ts.map +1 -0
  10. package/dist/graphql/client.js +346 -0
  11. package/dist/graphql/index.d.ts +4 -0
  12. package/dist/graphql/index.d.ts.map +1 -0
  13. package/dist/graphql/index.js +16 -0
  14. package/dist/graphql/queries.d.ts +103 -0
  15. package/dist/graphql/queries.d.ts.map +1 -0
  16. package/{graphql/queries.ts → dist/graphql/queries.js} +113 -223
  17. package/dist/graphql/types.d.ts +396 -0
  18. package/dist/graphql/types.d.ts.map +1 -0
  19. package/dist/graphql/types.js +4 -0
  20. package/dist/hooks/index.d.ts +10 -0
  21. package/dist/hooks/index.d.ts.map +1 -0
  22. package/dist/hooks/index.js +8 -0
  23. package/dist/hooks/useCharacterDirectory.d.ts +16 -0
  24. package/dist/hooks/useCharacterDirectory.d.ts.map +1 -0
  25. package/dist/hooks/useCharacterDirectory.js +23 -0
  26. package/dist/hooks/useCharacterSearch.d.ts +24 -0
  27. package/dist/hooks/useCharacterSearch.d.ts.map +1 -0
  28. package/dist/hooks/useCharacterSearch.js +24 -0
  29. package/dist/hooks/useConnection.d.ts +51 -0
  30. package/dist/hooks/useConnection.d.ts.map +1 -0
  31. package/{hooks/useConnection.ts → dist/hooks/useConnection.js} +8 -10
  32. package/dist/hooks/useEntityRole.d.ts +26 -0
  33. package/dist/hooks/useEntityRole.d.ts.map +1 -0
  34. package/dist/hooks/useEntityRole.js +91 -0
  35. package/dist/hooks/useNotification.d.ts +72 -0
  36. package/dist/hooks/useNotification.d.ts.map +1 -0
  37. package/{hooks/useNotification.ts → dist/hooks/useNotification.js} +8 -12
  38. package/dist/hooks/useSmartObject.d.ts +44 -0
  39. package/dist/hooks/useSmartObject.d.ts.map +1 -0
  40. package/dist/hooks/useSmartObject.js +50 -0
  41. package/dist/hooks/useSponsoredTransaction.d.ts +147 -0
  42. package/dist/hooks/useSponsoredTransaction.d.ts.map +1 -0
  43. package/dist/hooks/useSponsoredTransaction.js +240 -0
  44. package/dist/hooks/useTypeNames.d.ts +11 -0
  45. package/dist/hooks/useTypeNames.d.ts.map +1 -0
  46. package/dist/hooks/useTypeNames.js +24 -0
  47. package/dist/index.d.ts +11 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +29 -0
  50. package/dist/providers/EveFrontierProvider.d.ts +23 -0
  51. package/dist/providers/EveFrontierProvider.d.ts.map +1 -0
  52. package/dist/providers/EveFrontierProvider.js +23 -0
  53. package/dist/providers/NotificationProvider.d.ts +14 -0
  54. package/dist/providers/NotificationProvider.d.ts.map +1 -0
  55. package/dist/providers/NotificationProvider.js +66 -0
  56. package/dist/providers/SmartObjectProvider.d.ts +31 -0
  57. package/dist/providers/SmartObjectProvider.d.ts.map +1 -0
  58. package/dist/providers/SmartObjectProvider.js +80 -0
  59. package/dist/providers/VaultProvider.d.ts +10 -0
  60. package/dist/providers/VaultProvider.d.ts.map +1 -0
  61. package/dist/providers/VaultProvider.js +79 -0
  62. package/dist/providers/index.d.ts +5 -0
  63. package/dist/providers/index.d.ts.map +1 -0
  64. package/dist/providers/index.js +4 -0
  65. package/dist/providers/smartObject/useEntityData.d.ts +29 -0
  66. package/dist/providers/smartObject/useEntityData.d.ts.map +1 -0
  67. package/dist/providers/smartObject/useEntityData.js +135 -0
  68. package/dist/providers/smartObject/useEntitySubscription.d.ts +14 -0
  69. package/dist/providers/smartObject/useEntitySubscription.d.ts.map +1 -0
  70. package/dist/providers/smartObject/useEntitySubscription.js +58 -0
  71. package/dist/providers/smartObject/useObjectSelection.d.ts +11 -0
  72. package/dist/providers/smartObject/useObjectSelection.d.ts.map +1 -0
  73. package/dist/providers/smartObject/useObjectSelection.js +27 -0
  74. package/dist/providers/smartObject/usePollingBackstop.d.ts +18 -0
  75. package/dist/providers/smartObject/usePollingBackstop.d.ts.map +1 -0
  76. package/dist/providers/smartObject/usePollingBackstop.js +38 -0
  77. package/dist/types/character.d.ts +21 -0
  78. package/dist/types/character.d.ts.map +1 -0
  79. package/dist/types/character.js +1 -0
  80. package/dist/types/contexts.d.ts +61 -0
  81. package/dist/types/contexts.d.ts.map +1 -0
  82. package/dist/types/contexts.js +6 -0
  83. package/dist/types/entity.d.ts +245 -0
  84. package/dist/types/entity.d.ts.map +1 -0
  85. package/dist/types/entity.js +6 -0
  86. package/dist/types/index.d.ts +6 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/types/index.js +5 -0
  89. package/dist/types/sponsoredTransaction.d.ts +26 -0
  90. package/dist/types/sponsoredTransaction.d.ts.map +1 -0
  91. package/dist/types/sponsoredTransaction.js +10 -0
  92. package/dist/types/types.d.ts +110 -0
  93. package/dist/types/types.d.ts.map +1 -0
  94. package/dist/types/types.js +41 -0
  95. package/dist/types/worldApiReturnTypes.d.ts +68 -0
  96. package/dist/types/worldApiReturnTypes.d.ts.map +1 -0
  97. package/dist/types/worldApiReturnTypes.js +1 -0
  98. package/{utils/burnRate.ts → dist/utils/burnRate.d.ts} +4 -29
  99. package/dist/utils/burnRate.d.ts.map +1 -0
  100. package/dist/utils/burnRate.js +25 -0
  101. package/dist/utils/characters.d.ts +26 -0
  102. package/dist/utils/characters.d.ts.map +1 -0
  103. package/dist/utils/characters.js +84 -0
  104. package/dist/utils/constants.d.ts +153 -0
  105. package/dist/utils/constants.d.ts.map +1 -0
  106. package/dist/utils/constants.js +190 -0
  107. package/dist/utils/datahub.d.ts +40 -0
  108. package/dist/utils/datahub.d.ts.map +1 -0
  109. package/{utils/datahub.ts → dist/utils/datahub.js} +32 -25
  110. package/dist/utils/entity.d.ts +58 -0
  111. package/dist/utils/entity.d.ts.map +1 -0
  112. package/dist/utils/entity.js +386 -0
  113. package/dist/utils/errors.d.ts +18 -0
  114. package/dist/utils/errors.d.ts.map +1 -0
  115. package/dist/utils/errors.js +128 -0
  116. package/dist/utils/events/entityEvents.d.ts +44 -0
  117. package/dist/utils/events/entityEvents.d.ts.map +1 -0
  118. package/dist/utils/events/entityEvents.js +95 -0
  119. package/dist/utils/events/entitySubscription.d.ts +30 -0
  120. package/dist/utils/events/entitySubscription.d.ts.map +1 -0
  121. package/dist/utils/events/entitySubscription.js +84 -0
  122. package/dist/utils/events/graphqlEventStream.d.ts +90 -0
  123. package/dist/utils/events/graphqlEventStream.d.ts.map +1 -0
  124. package/dist/utils/events/graphqlEventStream.js +198 -0
  125. package/dist/utils/events/refetchScheduler.d.ts +30 -0
  126. package/dist/utils/events/refetchScheduler.d.ts.map +1 -0
  127. package/dist/utils/events/refetchScheduler.js +57 -0
  128. package/dist/utils/events/sseClient.d.ts +42 -0
  129. package/dist/utils/events/sseClient.d.ts.map +1 -0
  130. package/dist/utils/events/sseClient.js +97 -0
  131. package/dist/utils/fuel.d.ts +231 -0
  132. package/dist/utils/fuel.d.ts.map +1 -0
  133. package/dist/utils/fuel.js +652 -0
  134. package/dist/utils/grid.d.ts +115 -0
  135. package/dist/utils/grid.d.ts.map +1 -0
  136. package/dist/utils/grid.js +115 -0
  137. package/dist/utils/index.d.ts +15 -0
  138. package/dist/utils/index.d.ts.map +1 -0
  139. package/dist/utils/index.js +22 -0
  140. package/dist/utils/inventory.d.ts +3 -0
  141. package/dist/utils/inventory.d.ts.map +1 -0
  142. package/dist/utils/inventory.js +12 -0
  143. package/dist/utils/logger.d.ts +25 -0
  144. package/dist/utils/logger.d.ts.map +1 -0
  145. package/dist/utils/logger.js +228 -0
  146. package/dist/utils/mapping.d.ts +30 -0
  147. package/dist/utils/mapping.d.ts.map +1 -0
  148. package/dist/utils/mapping.js +73 -0
  149. package/dist/utils/mvr/worldTypes.d.ts +35 -0
  150. package/dist/utils/mvr/worldTypes.d.ts.map +1 -0
  151. package/dist/utils/mvr/worldTypes.js +54 -0
  152. package/dist/utils/role.d.ts +116 -0
  153. package/dist/utils/role.d.ts.map +1 -0
  154. package/dist/utils/role.js +120 -0
  155. package/dist/utils/smartObject.d.ts +24 -0
  156. package/dist/utils/smartObject.d.ts.map +1 -0
  157. package/dist/utils/smartObject.js +24 -0
  158. package/dist/utils/utils.d.ts +133 -0
  159. package/dist/utils/utils.d.ts.map +1 -0
  160. package/dist/utils/utils.js +213 -0
  161. package/dist/wallet/features.d.ts +28 -0
  162. package/dist/wallet/features.d.ts.map +1 -0
  163. package/dist/wallet/features.js +22 -0
  164. package/dist/wallet/index.d.ts +9 -0
  165. package/dist/wallet/index.d.ts.map +1 -0
  166. package/dist/wallet/index.js +9 -0
  167. package/dist/wallet/utils.d.ts +71 -0
  168. package/dist/wallet/utils.d.ts.map +1 -0
  169. package/dist/wallet/utils.js +79 -0
  170. package/package.json +69 -35
  171. package/config/dapp-kit.ts +0 -20
  172. package/config/index.ts +0 -1
  173. package/graphql/client.ts +0 -578
  174. package/graphql/index.ts +0 -39
  175. package/graphql/types.ts +0 -468
  176. package/hooks/index.ts +0 -15
  177. package/hooks/useSmartObject.ts +0 -66
  178. package/hooks/useSponsoredTransaction.ts +0 -442
  179. package/index.ts +0 -88
  180. package/providers/EveFrontierProvider.tsx +0 -41
  181. package/providers/NotificationProvider.tsx +0 -108
  182. package/providers/SmartObjectProvider.tsx +0 -296
  183. package/providers/VaultProvider.tsx +0 -108
  184. package/providers/index.ts +0 -10
  185. package/types/contexts.ts +0 -67
  186. package/types/global.d.ts +0 -7
  187. package/types/index.ts +0 -4
  188. package/types/sponsoredTransaction.ts +0 -70
  189. package/types/types.ts +0 -198
  190. package/types/worldApiReturnTypes.ts +0 -144
  191. package/utils/__tests__/burnRate.test.ts +0 -121
  192. package/utils/__tests__/character.test.ts +0 -112
  193. package/utils/__tests__/characterOwnedObjects.test.ts +0 -225
  194. package/utils/__tests__/config.test.ts +0 -424
  195. package/utils/__tests__/datahub.test.ts +0 -58
  196. package/utils/__tests__/logger.test.ts +0 -145
  197. package/utils/__tests__/mapping.test.ts +0 -439
  198. package/utils/__tests__/utils.test.ts +0 -299
  199. package/utils/character.ts +0 -46
  200. package/utils/characterOwnedObjects.ts +0 -53
  201. package/utils/config.ts +0 -151
  202. package/utils/constants.ts +0 -254
  203. package/utils/errors.ts +0 -171
  204. package/utils/index.ts +0 -47
  205. package/utils/logger.ts +0 -300
  206. package/utils/mapping.ts +0 -118
  207. package/utils/transforms.ts +0 -263
  208. package/utils/utils.ts +0 -270
  209. package/wallet/features.ts +0 -136
  210. package/wallet/index.ts +0 -26
  211. package/wallet/utils.ts +0 -117
@@ -0,0 +1,213 @@
1
+ import {} from '../types/index.js';
2
+ /**
3
+ * Abbreviate a Sui address or hex string for display.
4
+ *
5
+ * Shortens long addresses to show only the beginning and end characters
6
+ * with ellipsis in the middle.
7
+ *
8
+ * @category Utilities - Formatting
9
+ * @param string - The address or hex string to abbreviate
10
+ * @param precision - Number of characters to show on each end (default: 5)
11
+ * @param expanded - If true, returns the full string without abbreviation
12
+ * @returns The abbreviated string (e.g., "0x123...abc")
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * abbreviateAddress("0x1234567890abcdef1234567890abcdef"); // "0x123...cdef"
17
+ * abbreviateAddress("0x1234567890abcdef", 3); // "0x1...def"
18
+ * abbreviateAddress("0x1234567890abcdef", 5, true); // Full address
19
+ * ```
20
+ */
21
+ export const abbreviateAddress = (string, precision = 5, expanded = false) => {
22
+ if (!string)
23
+ return '';
24
+ if (expanded)
25
+ return string;
26
+ if (string.length <= precision * 2)
27
+ return string;
28
+ return `${string.slice(0, precision)}...${string.slice(-precision)}`;
29
+ };
30
+ /**
31
+ * Check if an account is the owner of a smart assembly.
32
+ *
33
+ * Compares the assembly's owner address with the provided account address
34
+ * to determine ownership.
35
+ *
36
+ * @category Utilities - Assembly
37
+ * @param assembly - The assembly object to check ownership of
38
+ * @param account - The account address to check against
39
+ * @returns True if the account owns the assembly, false otherwise
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // assembly is a DetailedAssemblyResponse from the World API
44
+ * if (isOwner(assembly, currentAccount?.address)) {
45
+ * // Show owner-only actions
46
+ * }
47
+ * ```
48
+ */
49
+ export const isOwner = (assembly, account) => {
50
+ if (!assembly?.character?.address || account == '0x')
51
+ return false;
52
+ return assembly.character.address === (account ?? '');
53
+ };
54
+ /**
55
+ * Generate a Suiscan transaction URL for a given transaction hash.
56
+ *
57
+ * @category Utilities - Assembly
58
+ * @param suiChain - The Sui chain identifier (e.g., "sui:testnet", "sui:mainnet")
59
+ * @param txHash - The transaction digest hash
60
+ * @returns Full Suiscan URL to view the transaction
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const url = getTxUrl("sui:testnet", "ABC123...");
65
+ * // Returns: "https://suiscan.xyz/testnet/tx/ABC123..."
66
+ * ```
67
+ */
68
+ export const getTxUrl = (suiChain, txHash) => {
69
+ const network = suiChain.split(':')[1] ?? suiChain;
70
+ return `https://suiscan.xyz/${network}/tx/${txHash}`;
71
+ };
72
+ /** Strips protocol (e.g. https://) from a URL and returns the rest. @category Utilities - Formatting */
73
+ export const parseURL = (string) => {
74
+ if (string.includes('://')) {
75
+ return string.split('://')[1] ?? string;
76
+ }
77
+ return string;
78
+ };
79
+ /** Copies the given string to the clipboard. @category Utilities - Formatting */
80
+ export const clickToCopy = (string) => {
81
+ return navigator.clipboard.writeText(string);
82
+ };
83
+ /** Returns elements that appear in both arrays. @category Utilities - Formatting */
84
+ export const getCommonItems = (array1, array2) => {
85
+ const commonItems = [];
86
+ const set = new Set([]);
87
+ for (let i = 0; i < array1.length; i++) {
88
+ const value = array1[i];
89
+ if (!set.has(value))
90
+ set.add(value);
91
+ }
92
+ for (let i = 0; i < array2.length; i++) {
93
+ const value = array2[i];
94
+ if (set.has(value))
95
+ commonItems.push(value);
96
+ }
97
+ return commonItems;
98
+ };
99
+ /** Removes trailing zeros after the last significant decimal. @category Utilities - Formatting */
100
+ export const removeTrailingZeros = (number) => {
101
+ return number.replace(/(\.\d*?[1-9])0+$|\.0*$/, '$1');
102
+ };
103
+ /** Returns the env value or fallback if empty. @category Utilities - Config */
104
+ export const getEnv = (env, fallback) => {
105
+ if (!env)
106
+ return fallback;
107
+ return env;
108
+ };
109
+ /**
110
+ * Volume in m³ from unit quantity and volume per unit (litres, 10^3).
111
+ * @param quantity - Unit quantity of the item
112
+ * @param volume - Volume per unit in litres (10^3)
113
+ * @returns Volume in m³
114
+ * @category Utilities - Formatting
115
+ */
116
+ export const getVolumeM3 = (quantity, volume) => {
117
+ const totalVolume = Number(quantity) * Number(volume);
118
+ return totalVolume;
119
+ };
120
+ /**
121
+ * Format from cubic decimeters/litres (dm³\l) to cubic meters (m³).
122
+ *
123
+ * @category Utilities - Formatting
124
+ * @param quantity - The raw volume value as string or bigint in cubic decimeters/litres (dm³/l)
125
+ * @returns Volume in cubic meters
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const m3 = formatM3(BigInt("1000")); // 1.0 m³
130
+ * ```
131
+ */
132
+ export const formatM3 = (quantity) => {
133
+ return Number(quantity) / 1000;
134
+ };
135
+ /**
136
+ * Get the dApp URL for an assembly, ensuring it has a protocol prefix.
137
+ *
138
+ * @category Utilities - Assembly
139
+ * @param assembly - The assembly object
140
+ * @param fallbackUrl - Used when the assembly has no `dappURL` of its own.
141
+ * @returns The full dApp URL with https:// prefix if needed
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * // assembly is a DetailedAssemblyResponse from the World API
146
+ * const dappUrl = getDappUrl(assembly);
147
+ * if (dappUrl) {
148
+ * window.open(dappUrl, '_blank');
149
+ * }
150
+ * ```
151
+ */
152
+ export const getDappUrl = (assembly, fallbackUrl) => {
153
+ const url = assembly?.dappURL?.trim() || fallbackUrl?.trim();
154
+ if (!url)
155
+ return '';
156
+ const hasProtocol = /^((http|https|ftp):\/\/)/i.test(url);
157
+ return hasProtocol ? url : 'https://' + url;
158
+ };
159
+ /**
160
+ * Check if two addresses match.
161
+ *
162
+ * @category Utilities - Assembly
163
+ * @param address1 - First address to compare
164
+ * @param address2 - Second address to compare
165
+ * @returns True if addresses match, false otherwise
166
+ */
167
+ export const findOwnerByAddress = (address1, address2) => {
168
+ if (!address2 || !address1 || address1 == '' || address2 == '')
169
+ return false;
170
+ return address1 === address2;
171
+ };
172
+ /**
173
+ * Format a duration in seconds to a human-readable string.
174
+ *
175
+ * Displays the duration in days, hours, minutes, and seconds as appropriate.
176
+ *
177
+ * @category Utilities - Formatting
178
+ * @param seconds - Duration in seconds
179
+ * @returns Formatted duration string (e.g., "02d 05h 30m 15s")
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * formatDuration(3665); // "01h 01m 05s"
184
+ * formatDuration(90061); // "01d 01h 01m 01s"
185
+ * formatDuration(45); // "45s"
186
+ * ```
187
+ */
188
+ export const formatDuration = (seconds) => {
189
+ if (seconds === 0)
190
+ return '0m 0s';
191
+ const days = Math.floor(seconds / (24 * 3600));
192
+ seconds %= 24 * 3600;
193
+ const hours = Math.floor(seconds / 3600);
194
+ seconds %= 3600;
195
+ const minutes = Math.floor(seconds / 60);
196
+ const remainingSeconds = seconds % 60;
197
+ const formattedDays = String(days).padStart(2, '0');
198
+ const formattedHours = String(hours).padStart(2, '0');
199
+ const formattedMinutes = String(minutes).padStart(2, '0');
200
+ const formattedSeconds = String(remainingSeconds.toFixed(0)).padStart(2, '0');
201
+ if (days > 0) {
202
+ return `${formattedDays}d ${formattedHours}h ${formattedMinutes}m ${formattedSeconds}s`;
203
+ }
204
+ else if (hours > 0) {
205
+ return `${formattedHours}h ${formattedMinutes}m ${formattedSeconds}s`;
206
+ }
207
+ else if (minutes > 0) {
208
+ return `${formattedMinutes}m ${formattedSeconds}s`;
209
+ }
210
+ else {
211
+ return `${formattedSeconds}s`;
212
+ }
213
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * EVE Frontier Wallet Standard Feature Extensions
3
+ *
4
+ * Custom wallet features for EVE Frontier dApps that extend the
5
+ * standard Sui wallet capabilities.
6
+ */
7
+ import type { SponsoredTransactionInput as WalletCoreSponsoredTransactionInput } from '@evefrontier/wallet-core/sponsored-transaction';
8
+ /**
9
+ * Input for a sponsored transaction request.
10
+ *
11
+ * @category Types
12
+ */
13
+ export type SponsoredTransactionInput = WalletCoreSponsoredTransactionInput;
14
+ /** Sponsored tx args; `account` and `tenant` are resolved by the hook and not sent to the wallet. */
15
+ export type SponsoredTransactionArgs = SponsoredTransactionInput & {
16
+ account?: string;
17
+ tenant?: string;
18
+ };
19
+ export type { SponsoredTransactionMethod, SponsoredTransactionOutput, } from '@evefrontier/wallet-core/sponsored-transaction';
20
+ export type { EveVaultWalletFeatures as EveFrontierSponsoredTransactionFeature } from '@evefrontier/wallet-core/wallet-features';
21
+ /**
22
+ * Check if a wallet supports the sponsored transaction feature.
23
+ * Supports array-shaped features like UIWallet object shape (list of feature names).
24
+ *
25
+ * @category Wallet
26
+ */
27
+ export declare function supportsSponsoredTransaction(features: unknown): boolean;
28
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../wallet/features.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,yBAAyB,IAAI,mCAAmC,EAAE,MAAM,gDAAgD,CAAA;AAGtI;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,mCAAmC,CAAA;AAE3E,qGAAqG;AACrG,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,GAAG;IACjE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAKD,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AACvD,YAAY,EAAE,sBAAsB,IAAI,sCAAsC,EAAE,MAAM,0CAA0C,CAAA;AAMhI;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAKvE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * EVE Frontier Wallet Standard Feature Extensions
3
+ *
4
+ * Custom wallet features for EVE Frontier dApps that extend the
5
+ * standard Sui wallet capabilities.
6
+ */
7
+ import { EVEFRONTIER_SPONSORED_TRANSACTION } from '../types/index.js';
8
+ // ============================================================================
9
+ // Type Guards
10
+ // ============================================================================
11
+ /**
12
+ * Check if a wallet supports the sponsored transaction feature.
13
+ * Supports array-shaped features like UIWallet object shape (list of feature names).
14
+ *
15
+ * @category Wallet
16
+ */
17
+ export function supportsSponsoredTransaction(features) {
18
+ if (Array.isArray(features)) {
19
+ return features.includes(EVEFRONTIER_SPONSORED_TRANSACTION);
20
+ }
21
+ return false;
22
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * EVE Frontier Wallet Standard Extensions
3
+ *
4
+ * Provides custom wallet sponsored transaction features.
5
+ */
6
+ export type { EveFrontierSponsoredTransactionFeature, SponsoredTransactionArgs, SponsoredTransactionInput, SponsoredTransactionMethod, SponsoredTransactionOutput, } from './features.js';
7
+ export { supportsSponsoredTransaction } from './features.js';
8
+ export { getSponsoredTransactionFeature, walletSupportsSponsoredTransaction, } from './utils.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../wallet/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,sCAAsC,EACtC,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAGzD,OAAO,EACL,8BAA8B,EAC9B,kCAAkC,GACnC,MAAM,SAAS,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * EVE Frontier Wallet Standard Extensions
3
+ *
4
+ * Provides custom wallet sponsored transaction features.
5
+ */
6
+ // Feature definitions and types
7
+ export { supportsSponsoredTransaction } from './features.js';
8
+ // Utility functions
9
+ export { getSponsoredTransactionFeature, walletSupportsSponsoredTransaction, } from './utils.js';
@@ -0,0 +1,71 @@
1
+ import { type SponsoredTransactionMethod } from './features.js';
2
+ /**
3
+ * Check if a wallet supports the EVE Frontier sponsored transaction feature.
4
+ *
5
+ * Use this to filter available wallets to only those that can execute
6
+ * sponsored (gasless) transactions. Currently, only EVE Vault implements
7
+ * this feature.
8
+ *
9
+ * @category Wallet
10
+ * @param wallet - The UiWallet object from dapp-kit
11
+ * @returns True if the wallet's feature list includes `evefrontier:sponsoredTransaction`
12
+ *
13
+ * @example Filter supported wallets
14
+ * ```tsx
15
+ * import { useWallets } from "@mysten/dapp-kit-react";
16
+ * import { walletSupportsSponsoredTransaction } from "@evefrontier/dapp-kit";
17
+ *
18
+ * const wallets = useWallets();
19
+ * const supportedWallets = wallets.filter(walletSupportsSponsoredTransaction);
20
+ *
21
+ * console.log(`${supportedWallets.length} wallets support sponsored transactions`);
22
+ * ```
23
+ *
24
+ * @example Check single wallet
25
+ * ```tsx
26
+ * const { currentWallet } = useCurrentWallet();
27
+ *
28
+ * if (currentWallet && walletSupportsSponsoredTransaction(currentWallet)) {
29
+ * // Wallet supports gasless transactions
30
+ * }
31
+ * ```
32
+ */
33
+ export declare function walletSupportsSponsoredTransaction(wallet: {
34
+ features: unknown;
35
+ }): boolean;
36
+ /**
37
+ * Get the sponsored transaction method from a wallet if supported.
38
+ *
39
+ * Returns the raw `signSponsoredTransaction` method from the wallet's features.
40
+ * For most use cases, prefer using the {@link useSponsoredTransaction} hook instead,
41
+ * which provides React Query integration and automatic error handling.
42
+ *
43
+ * @category Wallet
44
+ * @param wallet - The UiWallet object from dapp-kit
45
+ * @returns The sponsored transaction method, or undefined if not supported
46
+ *
47
+ * @example Direct wallet feature access
48
+ * ```tsx
49
+ * const { currentWallet } = useCurrentWallet();
50
+ *
51
+ * if (currentWallet) {
52
+ * const sponsoredTx = getSponsoredTransactionFeature(currentWallet);
53
+ * if (sponsoredTx) {
54
+ * const result = await sponsoredTx({
55
+ * txAction: "set-power-grid",
56
+ * entityId: "42",
57
+ * on: true,
58
+ * });
59
+ * console.log("Transaction digest:", result.digest);
60
+ * }
61
+ * }
62
+ * ```
63
+ *
64
+ * @see {@link useSponsoredTransaction} for the recommended React hook approach
65
+ */
66
+ export declare function getSponsoredTransactionFeature(wallet: {
67
+ features: unknown;
68
+ name?: string;
69
+ version?: string;
70
+ }): SponsoredTransactionMethod | undefined;
71
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../wallet/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,0BAA0B,EAEhC,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE;IACzD,QAAQ,EAAE,OAAO,CAAA;CAClB,GAAG,OAAO,CAEV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,0BAA0B,GAAG,SAAS,CAczC"}
@@ -0,0 +1,79 @@
1
+ import { getWalletFeature } from '@wallet-standard/ui';
2
+ import { EVEFRONTIER_SPONSORED_TRANSACTION } from '../types/index.js';
3
+ import { supportsSponsoredTransaction, } from './features.js';
4
+ /**
5
+ * Check if a wallet supports the EVE Frontier sponsored transaction feature.
6
+ *
7
+ * Use this to filter available wallets to only those that can execute
8
+ * sponsored (gasless) transactions. Currently, only EVE Vault implements
9
+ * this feature.
10
+ *
11
+ * @category Wallet
12
+ * @param wallet - The UiWallet object from dapp-kit
13
+ * @returns True if the wallet's feature list includes `evefrontier:sponsoredTransaction`
14
+ *
15
+ * @example Filter supported wallets
16
+ * ```tsx
17
+ * import { useWallets } from "@mysten/dapp-kit-react";
18
+ * import { walletSupportsSponsoredTransaction } from "@evefrontier/dapp-kit";
19
+ *
20
+ * const wallets = useWallets();
21
+ * const supportedWallets = wallets.filter(walletSupportsSponsoredTransaction);
22
+ *
23
+ * console.log(`${supportedWallets.length} wallets support sponsored transactions`);
24
+ * ```
25
+ *
26
+ * @example Check single wallet
27
+ * ```tsx
28
+ * const { currentWallet } = useCurrentWallet();
29
+ *
30
+ * if (currentWallet && walletSupportsSponsoredTransaction(currentWallet)) {
31
+ * // Wallet supports gasless transactions
32
+ * }
33
+ * ```
34
+ */
35
+ export function walletSupportsSponsoredTransaction(wallet) {
36
+ return supportsSponsoredTransaction(wallet.features);
37
+ }
38
+ /**
39
+ * Get the sponsored transaction method from a wallet if supported.
40
+ *
41
+ * Returns the raw `signSponsoredTransaction` method from the wallet's features.
42
+ * For most use cases, prefer using the {@link useSponsoredTransaction} hook instead,
43
+ * which provides React Query integration and automatic error handling.
44
+ *
45
+ * @category Wallet
46
+ * @param wallet - The UiWallet object from dapp-kit
47
+ * @returns The sponsored transaction method, or undefined if not supported
48
+ *
49
+ * @example Direct wallet feature access
50
+ * ```tsx
51
+ * const { currentWallet } = useCurrentWallet();
52
+ *
53
+ * if (currentWallet) {
54
+ * const sponsoredTx = getSponsoredTransactionFeature(currentWallet);
55
+ * if (sponsoredTx) {
56
+ * const result = await sponsoredTx({
57
+ * txAction: "set-power-grid",
58
+ * entityId: "42",
59
+ * on: true,
60
+ * });
61
+ * console.log("Transaction digest:", result.digest);
62
+ * }
63
+ * }
64
+ * ```
65
+ *
66
+ * @see {@link useSponsoredTransaction} for the recommended React hook approach
67
+ */
68
+ export function getSponsoredTransactionFeature(wallet) {
69
+ if (!supportsSponsoredTransaction(wallet.features)) {
70
+ return undefined;
71
+ }
72
+ try {
73
+ const feature = getWalletFeature(wallet, EVEFRONTIER_SPONSORED_TRANSACTION);
74
+ return feature.signSponsoredTransaction;
75
+ }
76
+ catch {
77
+ return undefined;
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,59 +1,93 @@
1
1
  {
2
2
  "name": "@evefrontier/dapp-kit",
3
- "version": "0.1.8",
3
+ "version": "0.2.0-alpha.1",
4
4
  "description": "React SDK for EVE Frontier dApps on Sui",
5
- "main": "index.ts",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
6
7
  "author": "",
7
8
  "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/evefrontier/dapps.git",
12
+ "directory": "packages/libs/dapp-kit"
13
+ },
8
14
  "type": "module",
9
15
  "files": [
10
- "index.ts",
11
- "config",
12
- "graphql",
13
- "hooks",
14
- "providers",
15
- "types",
16
- "utils",
17
- "wallet"
16
+ "dist"
18
17
  ],
19
18
  "exports": {
20
- ".": "./index.ts",
21
- "./types": "./types/index.ts",
22
- "./utils": "./utils/index.ts",
23
- "./graphql": "./graphql/index.ts",
24
- "./providers": "./providers/index.ts",
25
- "./hooks": "./hooks/index.ts",
26
- "./config": "./config/index.ts"
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./types": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "import": "./dist/types/index.js"
26
+ },
27
+ "./utils": {
28
+ "types": "./dist/utils/index.d.ts",
29
+ "import": "./dist/utils/index.js"
30
+ },
31
+ "./graphql": {
32
+ "types": "./dist/graphql/index.d.ts",
33
+ "import": "./dist/graphql/index.js"
34
+ },
35
+ "./providers": {
36
+ "types": "./dist/providers/index.d.ts",
37
+ "import": "./dist/providers/index.js"
38
+ },
39
+ "./hooks": {
40
+ "types": "./dist/hooks/index.d.ts",
41
+ "import": "./dist/hooks/index.js"
42
+ },
43
+ "./config": {
44
+ "types": "./dist/config/index.d.ts",
45
+ "import": "./dist/config/index.js"
46
+ }
27
47
  },
28
48
  "dependencies": {
29
- "@mysten/dapp-kit-core": "^1.2.2",
30
- "@mysten/dapp-kit-react": "^2.0.1",
31
- "@mysten/sui": "^2.14.1",
32
- "@mysten/wallet-standard": "^0.20.1",
33
- "@tanstack/react-query": "^5.96.2",
34
- "react": "^19.2.4"
49
+ "@evefrontier/wallet-core": "0.2.1-alpha.0",
50
+ "@mysten/dapp-kit-core": "^2.0.1",
51
+ "@mysten/dapp-kit-react": "^3.0.1",
52
+ "@mysten/sui": "^3.0.1",
53
+ "@mysten/wallet-standard": "^0.22.1",
54
+ "@tanstack/react-query": "^5.108.4",
55
+ "graphql-sse": "^2.6.4",
56
+ "react": "^19.3.1"
35
57
  },
36
58
  "devDependencies": {
37
- "@vitest/ui": "^4.1.3",
38
- "@types/react": "^19.2.14",
39
- "@vitejs/plugin-react-swc": "^4.3.0",
40
- "typedoc": "^0.28.18",
41
- "typedoc-plugin-markdown": "^4.11.0",
42
- "typescript": "^6.0.2",
43
- "vite": "^8.0.5",
59
+ "@types/node": "^25.9.12",
60
+ "@types/react": "^19.3.3",
61
+ "@vitejs/plugin-react-swc": "^4.3.3",
62
+ "@vitest/coverage-v8": "4.1.3",
63
+ "@vitest/ui": "4.1.12",
64
+ "typedoc": "^0.28.20",
65
+ "typedoc-plugin-markdown": "^4.14.1",
66
+ "typescript": "^7.0.2",
67
+ "vite": "^8.4.0",
44
68
  "vite-plugin-svgr": "^5.2.0",
45
- "vitest": "^4.1.3"
69
+ "vitest": "^4.1.12"
70
+ },
71
+ "peerDependencies": {
72
+ "@wallet-standard/ui": "^1.0.3"
73
+ },
74
+ "publishConfig": {
75
+ "access": "public",
76
+ "registry": "https://registry.npmjs.org"
46
77
  },
47
78
  "scripts": {
48
- "build": "tsc --noEmit",
79
+ "build": "tsc -p tsconfig.build.json && node scripts/fix-esm-extensions.cjs",
80
+ "prepack": "npm run build",
81
+ "typecheck": "tsc --noEmit",
49
82
  "ts:clean": "tsc --build --clean",
50
83
  "docs": "typedoc",
51
84
  "docs:md": "typedoc --plugin typedoc-plugin-markdown --out docs/markdown",
52
- "docs:serve": "typedoc && npx serve docs/api",
53
- "lint": "prettier . --check && eslint --report-unused-disable-directives --max-warnings 0",
54
- "lint:fix": "prettier . --write && eslint --fix --report-unused-disable-directives --max-warnings 0",
85
+ "docs:serve": "typedoc && bunx serve docs/api",
86
+ "lint": "biome check .",
87
+ "lint:fix": "biome check --write .",
55
88
  "test": "vitest",
56
89
  "test:ui": "vitest --ui",
90
+ "test:coverage": "vitest run --config vitest.config.ts --coverage",
57
91
  "test:run": "vitest run"
58
92
  }
59
93
  }
@@ -1,20 +0,0 @@
1
- import { createDAppKit } from "@mysten/dapp-kit-react";
2
- import { SuiGrpcClient } from "@mysten/sui/grpc";
3
- const GRPC_URLS = {
4
- testnet: "https://fullnode.testnet.sui.io:443",
5
- devnet: "https://fullnode.devnet.sui.io:443",
6
- };
7
-
8
- type SupportedNetwork = keyof typeof GRPC_URLS;
9
- const SUPPORTED_NETWORKS = Object.keys(GRPC_URLS) as SupportedNetwork[];
10
-
11
- /** DApp Kit instance for Sui wallet and network. @category Config */
12
- export const dAppKit = createDAppKit({
13
- networks: SUPPORTED_NETWORKS,
14
- createClient(network) {
15
- return new SuiGrpcClient({
16
- network,
17
- baseUrl: GRPC_URLS[network as keyof typeof GRPC_URLS],
18
- });
19
- },
20
- });
package/config/index.ts DELETED
@@ -1 +0,0 @@
1
- export { dAppKit } from "./dapp-kit";