@evefrontier/dapp-kit 0.1.9 → 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
package/utils/utils.ts DELETED
@@ -1,270 +0,0 @@
1
- import { SuiChain } from "@mysten/wallet-standard";
2
- import {
3
- Assemblies,
4
- DetailedAssemblyResponse,
5
- SmartAssemblyResponse,
6
- AssemblyType,
7
- } from "../types";
8
-
9
- /**
10
- * Abbreviate a Sui address or hex string for display.
11
- *
12
- * Shortens long addresses to show only the beginning and end characters
13
- * with ellipsis in the middle.
14
- *
15
- * @category Utilities - Formatting
16
- * @param string - The address or hex string to abbreviate
17
- * @param precision - Number of characters to show on each end (default: 5)
18
- * @param expanded - If true, returns the full string without abbreviation
19
- * @returns The abbreviated string (e.g., "0x123...abc")
20
- *
21
- * @example
22
- * ```typescript
23
- * abbreviateAddress("0x1234567890abcdef1234567890abcdef"); // "0x123...cdef"
24
- * abbreviateAddress("0x1234567890abcdef", 3); // "0x1...def"
25
- * abbreviateAddress("0x1234567890abcdef", 5, true); // Full address
26
- * ```
27
- */
28
- export const abbreviateAddress = (
29
- string?: `0x${string}` | string,
30
- precision = 5,
31
- expanded = false,
32
- ): string => {
33
- if (!string) return "";
34
- if (expanded) return string;
35
- if (string.length <= precision * 2) return string;
36
- return `${string.slice(0, precision)}...${string.slice(-precision)}`;
37
- };
38
-
39
- /**
40
- * Check if an account is the owner of a smart assembly.
41
- *
42
- * Compares the assembly's owner address with the provided account address
43
- * to determine ownership.
44
- *
45
- * @category Utilities - Assembly
46
- * @param assembly - The assembly object to check ownership of
47
- * @param account - The account address to check against
48
- * @returns True if the account owns the assembly, false otherwise
49
- *
50
- * @example
51
- * ```typescript
52
- * const { assembly } = useSmartObject();
53
- * const { currentAccount } = useConnection();
54
- *
55
- * if (isOwner(assembly, currentAccount?.address)) {
56
- * // Show owner-only actions
57
- * }
58
- * ```
59
- */
60
- export const isOwner = (
61
- assembly: DetailedAssemblyResponse | SmartAssemblyResponse | null,
62
- account?: `0x${string}` | string,
63
- ): boolean => {
64
- if (!assembly?.character?.address || account == "0x") return false;
65
- return assembly.character.address === (account ?? "");
66
- };
67
-
68
- /**
69
- * Generate a Suiscan transaction URL for a given transaction hash.
70
- *
71
- * @category Utilities - Assembly
72
- * @param suiChain - The Sui chain identifier (e.g., "sui:testnet", "sui:mainnet")
73
- * @param txHash - The transaction digest hash
74
- * @returns Full Suiscan URL to view the transaction
75
- *
76
- * @example
77
- * ```typescript
78
- * const url = getTxUrl("sui:testnet", "ABC123...");
79
- * // Returns: "https://suiscan.xyz/testnet/tx/ABC123..."
80
- * ```
81
- */
82
- export const getTxUrl = (suiChain: SuiChain, txHash: string): string => {
83
- const network = suiChain.split(":")[1];
84
-
85
- return `https://suiscan.xyz/${network}/tx/${txHash}`;
86
- };
87
-
88
- /** Strips protocol (e.g. https://) from a URL and returns the rest. @category Utilities - Formatting */
89
- export const parseURL = (string: string): string => {
90
- if (string.includes("://")) {
91
- return string.split("://")[1];
92
- }
93
- return string;
94
- };
95
-
96
- /** Copies the given string to the clipboard. @category Utilities - Formatting */
97
- export const clickToCopy = (string: string) => {
98
- return navigator.clipboard.writeText(string);
99
- };
100
-
101
- /** Returns elements that appear in both arrays. @category Utilities - Formatting */
102
- export const getCommonItems = (array1: any[], array2: any[]) => {
103
- const commonItems: any[] = [];
104
- const set: Set<any> = new Set([]);
105
-
106
- for (let i = 0; i < array1.length; i++) {
107
- const value = array1[i];
108
- if (!set.has(value)) set.add(value);
109
- }
110
- for (let i = 0; i < array2.length; i++) {
111
- const value = array2[i];
112
- if (set.has(value)) commonItems.push(value);
113
- }
114
- return commonItems;
115
- };
116
-
117
- /** Removes trailing zeros after the last significant decimal. @category Utilities - Formatting */
118
- export const removeTrailingZeros = (number: string) => {
119
- return number.replace(/(\.\d*?[1-9])0+$|\.0*$/, "$1");
120
- };
121
-
122
- /** Returns the env value or fallback if empty. @category Utilities - Config */
123
- export const getEnv = (env: string, fallback: string): string => {
124
- if (!env) return fallback;
125
- return env;
126
- };
127
-
128
- /**
129
- * Volume in m³ from unit quantity and volume per unit (litres, 10^3).
130
- * @param quantity - Unit quantity of the item
131
- * @param volume - Volume per unit in litres (10^3)
132
- * @returns Volume in m³
133
- * @category Utilities - Formatting
134
- */
135
- export const getVolumeM3 = (quantity: bigint, volume: bigint): number => {
136
- const totalVolume = Number(quantity) * Number(volume);
137
- return totalVolume;
138
- };
139
-
140
- /**
141
- * Format from cubic decimeters/litres (dm³\l) to cubic meters (m³).
142
- *
143
- * @category Utilities - Formatting
144
- * @param quantity - The raw volume value as string or bigint in cubic decimeters/litres (dm³/l)
145
- * @returns Volume in cubic meters
146
- *
147
- * @example
148
- * ```typescript
149
- * const m3 = formatM3(BigInt("1000")); // 1.0 m³
150
- * ```
151
- */
152
- export const formatM3 = (quantity: string | bigint): number => {
153
- return Number(quantity) / 1000;
154
- };
155
-
156
- /**
157
- * Get the dApp URL for an assembly, ensuring it has a protocol prefix.
158
- *
159
- * @category Utilities - Assembly
160
- * @param assembly - The assembly object
161
- * @returns The full dApp URL with https:// prefix if needed
162
- *
163
- * @example
164
- * ```typescript
165
- * const { assembly } = useSmartObject();
166
- * const dappUrl = getDappUrl(assembly);
167
- * if (dappUrl) {
168
- * window.open(dappUrl, '_blank');
169
- * }
170
- * ```
171
- */
172
- export const getDappUrl = (assembly: AssemblyType<Assemblies>): string => {
173
- if (!assembly?.dappURL) return "";
174
-
175
- let url = assembly.dappURL.trim();
176
- const hasProtocol = /^((http|https|ftp):\/\/)/i.test(url);
177
- if (!hasProtocol) {
178
- url = "https://" + url;
179
- }
180
-
181
- return url;
182
- };
183
-
184
- /**
185
- * Check if two addresses match.
186
- *
187
- * @category Utilities - Assembly
188
- * @param address1 - First address to compare
189
- * @param address2 - Second address to compare
190
- * @returns True if addresses match, false otherwise
191
- */
192
- export const findOwnerByAddress = (
193
- address1: string | undefined,
194
- address2: string | undefined,
195
- ): boolean => {
196
- if (!address2 || !address1 || address1 == "" || address2 == "") return false;
197
- return address1 === address2;
198
- };
199
-
200
- /**
201
- * Type guard to check if an assembly is of a specific type.
202
- *
203
- * Use this to narrow the type of an assembly for type-safe property access.
204
- *
205
- * @category Utilities - Assembly
206
- * @param assembly - The assembly to check
207
- * @param assemblyType - The expected assembly type
208
- * @returns True if assembly matches the specified type
209
- *
210
- * @example
211
- * ```typescript
212
- * const { assembly } = useSmartObject();
213
- *
214
- * if (assertAssemblyType(assembly, Assemblies.SmartStorageUnit)) {
215
- * // TypeScript knows assembly is SmartStorageUnit here
216
- * console.log(assembly.storage.mainInventory);
217
- * }
218
- * ```
219
- */
220
- export const assertAssemblyType = (
221
- assembly: AssemblyType<Assemblies> | null,
222
- assemblyType: Assemblies,
223
- ): assembly is AssemblyType<Assemblies> => {
224
- if (typeof assembly?.type === "string") {
225
- return assembly.type === assemblyType;
226
- }
227
- return false;
228
- };
229
-
230
- /**
231
- * Format a duration in seconds to a human-readable string.
232
- *
233
- * Displays the duration in days, hours, minutes, and seconds as appropriate.
234
- *
235
- * @category Utilities - Formatting
236
- * @param seconds - Duration in seconds
237
- * @returns Formatted duration string (e.g., "02d 05h 30m 15s")
238
- *
239
- * @example
240
- * ```typescript
241
- * formatDuration(3665); // "01h 01m 05s"
242
- * formatDuration(90061); // "01d 01h 01m 01s"
243
- * formatDuration(45); // "45s"
244
- * ```
245
- */
246
- export const formatDuration = (seconds: number): string => {
247
- if (seconds === 0) return "0m 0s";
248
-
249
- const days = Math.floor(seconds / (24 * 3600));
250
- seconds %= 24 * 3600;
251
- const hours = Math.floor(seconds / 3600);
252
- seconds %= 3600;
253
- const minutes = Math.floor(seconds / 60);
254
- const remainingSeconds = seconds % 60;
255
-
256
- const formattedDays = String(days).padStart(2, "0");
257
- const formattedHours = String(hours).padStart(2, "0");
258
- const formattedMinutes = String(minutes).padStart(2, "0");
259
- const formattedSeconds = String(remainingSeconds.toFixed(0)).padStart(2, "0");
260
-
261
- if (days > 0) {
262
- return `${formattedDays}d ${formattedHours}h ${formattedMinutes}m ${formattedSeconds}s`;
263
- } else if (hours > 0) {
264
- return `${formattedHours}h ${formattedMinutes}m ${formattedSeconds}s`;
265
- } else if (minutes > 0) {
266
- return `${formattedMinutes}m ${formattedSeconds}s`;
267
- } else {
268
- return `${formattedSeconds}s`;
269
- }
270
- };
@@ -1,136 +0,0 @@
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
-
8
- import {
9
- Assemblies,
10
- ASSEMBLY_TYPE_API_STRING,
11
- AssemblyType,
12
- EVEFRONTIER_SPONSORED_TRANSACTION,
13
- SponsoredTransactionActions,
14
- SponsoredTransactionAssemblyType,
15
- SponsoredTransactionMetadata,
16
- } from "../types";
17
-
18
- /**
19
- * Maps an assembly type enum to the API string expected by the sponsored transaction backend.
20
- *
21
- * @category Wallet
22
- */
23
- export function getAssemblyTypeApiString(
24
- type: Assemblies,
25
- ): SponsoredTransactionAssemblyType {
26
- return ASSEMBLY_TYPE_API_STRING[type];
27
- }
28
-
29
- /**
30
- * Input for a sponsored transaction request
31
- * Takes the transformed item_id and assembly type values of the assembly object
32
- * Normalization from assembly object to this flat shape is done in the hook by design;
33
- * callers may pass either the full assembly or pre-flattened values.
34
- * @category Types
35
- */
36
- export interface SponsoredTransactionInput {
37
- /** The transaction to be sponsored and executed */
38
- txAction: SponsoredTransactionActions;
39
- /** Assembly ID */
40
- assembly: AssemblyType<Assemblies>["item_id"];
41
- tenant: string;
42
- /** The assembly type to be sponsored and executed */
43
- assemblyType: SponsoredTransactionAssemblyType;
44
- metadata?: SponsoredTransactionMetadata;
45
- }
46
-
47
- /** Sponsored tx args with assembly object; id and assemblyType are derived. Tenant is optional; the hook resolves it from args, URL query param, or default. */
48
- export type SponsoredTransactionArgs = Omit<
49
- SponsoredTransactionInput,
50
- "assembly" | "assemblyType" | "account" | "tenant"
51
- > & {
52
- assembly: AssemblyType<Assemblies>;
53
- account?: string;
54
- tenant?: string;
55
- txAction: SponsoredTransactionActions;
56
- metadata?: SponsoredTransactionMetadata;
57
- };
58
-
59
- /**
60
- * Output from a successful sponsored transaction
61
- *
62
- * @category Types
63
- */
64
- export interface SponsoredTransactionOutput {
65
- /** The transaction digest */
66
- digest: string;
67
- /** The transaction effects (BCS encoded) */
68
- effects?: string;
69
- /** Raw effects bytes (if available) */
70
- rawEffects?: number[];
71
- }
72
-
73
- /**
74
- * The sponsored transaction method signature
75
- *
76
- * @category Wallet
77
- */
78
- export type SponsoredTransactionMethod = (
79
- input: SponsoredTransactionInput,
80
- ) => Promise<SponsoredTransactionOutput>;
81
-
82
- /**
83
- * Feature interface for sponsored transactions.
84
- * Wallets that support this feature should implement this interface
85
- * in their `features` object.
86
- *
87
- * @category Wallet
88
- */
89
- export interface EveFrontierSponsoredTransactionFeature {
90
- readonly [EVEFRONTIER_SPONSORED_TRANSACTION]: {
91
- /** Feature version for compatibility checking */
92
- readonly version: "1.0.0";
93
- /** Execute a gas-sponsored transaction */
94
- signSponsoredTransaction: SponsoredTransactionMethod;
95
- };
96
- }
97
-
98
- // ============================================================================
99
- // Type Guards
100
- // ============================================================================
101
-
102
- /**
103
- * Type guard to check if an object has the sponsored transaction feature
104
- * (object form with implementation).
105
- *
106
- * @category Wallet
107
- */
108
- export function hasSponsoredTransactionFeature(
109
- features: Record<string, unknown>,
110
- ): features is Record<string, unknown> &
111
- EveFrontierSponsoredTransactionFeature {
112
- const featureValue = features[EVEFRONTIER_SPONSORED_TRANSACTION];
113
- return (
114
- EVEFRONTIER_SPONSORED_TRANSACTION in features &&
115
- typeof featureValue === "object" &&
116
- featureValue !== null &&
117
- "signSponsoredTransaction" in (featureValue as object)
118
- );
119
- }
120
-
121
- /**
122
- * Check if a wallet supports the sponsored transaction feature.
123
- * Supports both legacy object-shaped features and v2 array-shaped features
124
- * (list of feature names).
125
- *
126
- * @category Wallet
127
- */
128
- export function supportsSponsoredTransaction(features: unknown): boolean {
129
- if (Array.isArray(features)) {
130
- return (features as string[]).includes(EVEFRONTIER_SPONSORED_TRANSACTION);
131
- }
132
- if (typeof features === "object" && features !== null) {
133
- return hasSponsoredTransactionFeature(features as Record<string, unknown>);
134
- }
135
- return false;
136
- }
package/wallet/index.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * EVE Frontier Wallet Standard Extensions
3
- *
4
- * Provides custom wallet sponsored transaction features.
5
- */
6
-
7
- // Feature definitions and types
8
- export {
9
- getAssemblyTypeApiString,
10
- hasSponsoredTransactionFeature,
11
- supportsSponsoredTransaction,
12
- } from "./features";
13
- export type {
14
- EveFrontierSponsoredTransactionFeature,
15
- SponsoredTransactionArgs,
16
- SponsoredTransactionInput,
17
- SponsoredTransactionMethod,
18
- SponsoredTransactionOutput,
19
- } from "./features";
20
-
21
- // Utility functions
22
- export {
23
- walletSupportsSponsoredTransaction,
24
- getSponsoredTransactionFeature,
25
- getSponsoredTransactionMethod,
26
- } from "./utils";
package/wallet/utils.ts DELETED
@@ -1,117 +0,0 @@
1
- import type { Wallet } from "@mysten/wallet-standard";
2
- import {
3
- hasSponsoredTransactionFeature,
4
- supportsSponsoredTransaction,
5
- type EveFrontierSponsoredTransactionFeature,
6
- type SponsoredTransactionMethod,
7
- } from "./features";
8
- import { EVEFRONTIER_SPONSORED_TRANSACTION } from "../types";
9
-
10
- /**
11
- * Check if a wallet supports the EVE Frontier sponsored transaction feature.
12
- *
13
- * Use this to filter available wallets to only those that can execute
14
- * sponsored (gasless) transactions. Currently, only EVE Vault implements
15
- * this feature.
16
- *
17
- * @category Wallet
18
- * @param wallet - The wallet object from wallet-standard
19
- * @returns True if the wallet implements the `evefrontier:sponsoredTransaction` feature
20
- *
21
- * @example Filter supported wallets
22
- * ```tsx
23
- * import { useWallets } from "@mysten/dapp-kit-react";
24
- * import { walletSupportsSponsoredTransaction } from "@evefrontier/dapp-kit";
25
- *
26
- * const wallets = useWallets();
27
- * const supportedWallets = wallets.filter(walletSupportsSponsoredTransaction);
28
- *
29
- * console.log(`${supportedWallets.length} wallets support sponsored transactions`);
30
- * ```
31
- *
32
- * @example Check single wallet
33
- * ```tsx
34
- * const { currentWallet } = useCurrentWallet();
35
- *
36
- * if (currentWallet && walletSupportsSponsoredTransaction(currentWallet)) {
37
- * // Wallet supports gasless transactions
38
- * }
39
- * ```
40
- */
41
- export function walletSupportsSponsoredTransaction(wallet: Wallet): boolean {
42
- return supportsSponsoredTransaction(wallet.features);
43
- }
44
-
45
- /**
46
- * Get the sponsored transaction method from a wallet if supported.
47
- *
48
- * Returns the raw `signSponsoredTransaction` method from the wallet's features.
49
- * For most use cases, prefer using the {@link useSponsoredTransaction} hook instead,
50
- * which provides React Query integration and automatic error handling.
51
- *
52
- * @category Wallet
53
- * @param wallet - The wallet object from wallet-standard
54
- * @returns The sponsored transaction method, or undefined if not supported
55
- *
56
- * @example Direct wallet feature access
57
- * ```tsx
58
- * const { currentWallet } = useCurrentWallet();
59
- *
60
- * if (currentWallet) {
61
- * const sponsoredTx = getSponsoredTransactionFeature(currentWallet);
62
- * if (sponsoredTx) {
63
- * const result = await sponsoredTx({
64
- * txAction: "online",
65
- * chain: "sui:testnet",
66
- * assembly: "0x123..."
67
- * });
68
- * console.log("Transaction digest:", result.digest);
69
- * }
70
- * }
71
- * ```
72
- *
73
- * @see {@link useSponsoredTransaction} for the recommended React hook approach
74
- */
75
- export function getSponsoredTransactionFeature(
76
- wallet: Wallet,
77
- ): SponsoredTransactionMethod | undefined {
78
- if (
79
- !hasSponsoredTransactionFeature(wallet.features as Record<string, unknown>)
80
- ) {
81
- return undefined;
82
- }
83
-
84
- const feature = (wallet.features as Record<string, unknown>)[
85
- EVEFRONTIER_SPONSORED_TRANSACTION
86
- ] as EveFrontierSponsoredTransactionFeature[typeof EVEFRONTIER_SPONSORED_TRANSACTION];
87
-
88
- return feature.signSponsoredTransaction;
89
- }
90
-
91
- /**
92
- * Get the sponsored transaction method from a wallet, supporting both
93
- * object-shaped features (legacy) and array-shaped features (v2).
94
- * When features is an array, tries the wallet object for a top-level
95
- * feature implementation (e.g. wallet['evefrontier:sponsoredTransaction']).
96
- */
97
- export function getSponsoredTransactionMethod(
98
- wallet: Wallet | { features: unknown; name?: string; version?: string },
99
- ): SponsoredTransactionMethod | undefined {
100
- const fromFeatures = getSponsoredTransactionFeature(wallet as Wallet);
101
- if (fromFeatures) return fromFeatures;
102
-
103
- if (!supportsSponsoredTransaction(wallet.features)) return undefined;
104
-
105
- const w = wallet as Record<string, unknown>;
106
- const feature = w[EVEFRONTIER_SPONSORED_TRANSACTION];
107
- if (
108
- feature !== null &&
109
- typeof feature === "object" &&
110
- typeof (feature as { signSponsoredTransaction?: unknown })
111
- .signSponsoredTransaction === "function"
112
- ) {
113
- return (feature as { signSponsoredTransaction: SponsoredTransactionMethod })
114
- .signSponsoredTransaction;
115
- }
116
- return undefined;
117
- }