@evefrontier/dapp-kit 0.1.1 → 0.1.3

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 (215) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/docs/api/assets/hierarchy.js +1 -1
  4. package/docs/api/assets/navigation.js +1 -1
  5. package/docs/api/assets/search.js +1 -1
  6. package/docs/api/classes/WalletNoAccountSelectedError.html +3 -3
  7. package/docs/api/classes/WalletNotConnectedError.html +3 -3
  8. package/docs/api/classes/WalletSponsoredTransactionNotSupportedError.html +3 -3
  9. package/docs/api/enums/ActionTypes.html +2 -2
  10. package/docs/api/enums/Assemblies.html +3 -2
  11. package/docs/api/enums/QueryParams.html +2 -2
  12. package/docs/api/enums/Severity.html +2 -2
  13. package/docs/api/enums/SponsoredTransactionActions.html +3 -3
  14. package/docs/api/enums/State.html +2 -2
  15. package/docs/api/enums/SupportedWallets.html +2 -2
  16. package/docs/api/enums/TYPEIDS.html +3 -3
  17. package/docs/api/functions/EveFrontierProvider.html +2 -2
  18. package/docs/api/functions/NotificationProvider.html +2 -2
  19. package/docs/api/functions/SmartObjectProvider.html +4 -4
  20. package/docs/api/functions/VaultProvider.html +1 -1
  21. package/docs/api/functions/abbreviateAddress.html +2 -2
  22. package/docs/api/functions/assertAssemblyType.html +2 -2
  23. package/docs/api/functions/clickToCopy.html +1 -1
  24. package/docs/api/functions/executeGraphQLQuery.html +2 -2
  25. package/docs/api/functions/findOwnerByAddress.html +2 -2
  26. package/docs/api/functions/formatDuration.html +2 -2
  27. package/docs/api/functions/formatM3.html +2 -2
  28. package/docs/api/functions/getAdjustedBurnRate.html +6 -0
  29. package/docs/api/functions/getAssemblyType.html +2 -2
  30. package/docs/api/functions/getAssemblyTypeApiString.html +2 -2
  31. package/docs/api/functions/getAssemblyWithOwner.html +3 -3
  32. package/docs/api/functions/getCharacterAndOwnedObjects.html +3 -0
  33. package/docs/api/functions/getCharacterOwnedObjects.html +5 -0
  34. package/docs/api/functions/getCharacterOwnedObjectsJson.html +5 -0
  35. package/docs/api/functions/getCharacterOwnerCapType.html +2 -2
  36. package/docs/api/functions/getCharacterPlayerProfileType.html +3 -0
  37. package/docs/api/functions/getCommonItems.html +1 -1
  38. package/docs/api/functions/getDappUrl.html +2 -2
  39. package/docs/api/functions/getDatahubGameInfo.html +2 -2
  40. package/docs/api/functions/getEnergyConfig.html +4 -0
  41. package/docs/api/functions/getEnergyConfigType.html +3 -0
  42. package/docs/api/functions/getEnergyUsageForType.html +5 -0
  43. package/docs/api/functions/getEnv.html +1 -1
  44. package/docs/api/functions/getEveWorldPackageId.html +2 -2
  45. package/docs/api/functions/getFuelEfficiencyConfig.html +4 -0
  46. package/docs/api/functions/getFuelEfficiencyConfigType.html +3 -0
  47. package/docs/api/functions/getFuelEfficiencyForType.html +5 -0
  48. package/docs/api/functions/getObjectByAddress.html +2 -2
  49. package/docs/api/functions/getObjectId.html +2 -2
  50. package/docs/api/functions/getObjectOwnerAndOwnedObjectsByType.html +2 -2
  51. package/docs/api/functions/getObjectOwnerAndOwnedObjectsWithJson.html +7 -0
  52. package/docs/api/functions/getObjectRegistryType.html +2 -2
  53. package/docs/api/functions/getObjectWithDynamicFields.html +2 -2
  54. package/docs/api/functions/getObjectWithJson.html +2 -2
  55. package/docs/api/functions/getObjectsByType.html +2 -2
  56. package/docs/api/functions/getOwnedObjectsByPackage.html +2 -2
  57. package/docs/api/functions/getOwnedObjectsByType.html +2 -2
  58. package/docs/api/functions/getRegistryAddress.html +2 -2
  59. package/docs/api/functions/getSingletonObjectByType.html +2 -2
  60. package/docs/api/functions/getSponsoredTransactionFeature.html +2 -2
  61. package/docs/api/functions/getSuiGraphqlEndpoint.html +2 -2
  62. package/docs/api/functions/getTxUrl.html +2 -2
  63. package/docs/api/functions/getVolumeM3.html +2 -2
  64. package/docs/api/functions/getWalletCharacters.html +3 -0
  65. package/docs/api/functions/hasSponsoredTransactionFeature.html +2 -2
  66. package/docs/api/functions/isOwner.html +3 -3
  67. package/docs/api/functions/parseCharacterFromJson.html +5 -0
  68. package/docs/api/functions/parseErrorFromMessage.html +1 -1
  69. package/docs/api/functions/parseStatus.html +2 -2
  70. package/docs/api/functions/parseURL.html +1 -1
  71. package/docs/api/functions/removeTrailingZeros.html +1 -1
  72. package/docs/api/functions/transformToAssembly.html +2 -2
  73. package/docs/api/functions/transformToCharacter.html +2 -2
  74. package/docs/api/functions/useConnection.html +2 -2
  75. package/docs/api/functions/useNotification.html +2 -2
  76. package/docs/api/functions/useSmartObject.html +4 -9
  77. package/docs/api/functions/useSponsoredTransaction.html +5 -5
  78. package/docs/api/functions/walletSupportsSponsoredTransaction.html +2 -2
  79. package/docs/api/hierarchy.html +1 -1
  80. package/docs/api/index.html +3 -5
  81. package/docs/api/interfaces/AddressOwner.html +2 -2
  82. package/docs/api/interfaces/AddressOwnerWithJson.html +2 -2
  83. package/docs/api/interfaces/AddressWithObjects.html +3 -0
  84. package/docs/api/interfaces/AdjustedBurnRate.html +8 -0
  85. package/docs/api/interfaces/AsMoveObjectRef.html +3 -0
  86. package/docs/api/interfaces/AssemblyProperties.html +6 -3
  87. package/docs/api/interfaces/CharacterAndOwnedObjectsNode.html +2 -0
  88. package/docs/api/interfaces/CharacterInfo.html +3 -3
  89. package/docs/api/interfaces/CharacterOwnerNode.html +3 -0
  90. package/docs/api/interfaces/ConfigExtractDynamicFieldNode.html +3 -0
  91. package/docs/api/interfaces/ContentsBcs.html +2 -0
  92. package/docs/api/interfaces/ContentsJsonAndBcs.html +3 -0
  93. package/docs/api/interfaces/ContentsJsonOnly.html +3 -0
  94. package/docs/api/interfaces/ContentsTypeAndBcs.html +3 -0
  95. package/docs/api/interfaces/ContentsTypeJsonAndBcs.html +4 -0
  96. package/docs/api/interfaces/DatahubGameInfo.html +14 -16
  97. package/docs/api/interfaces/DetailedAssemblyResponse.html +6 -3
  98. package/docs/api/interfaces/DetailedSmartCharacterResponse.html +2 -2
  99. package/docs/api/interfaces/DynamicFieldNode.html +2 -2
  100. package/docs/api/interfaces/EphemeralInventory.html +2 -2
  101. package/docs/api/interfaces/EveFrontierSponsoredTransactionFeature.html +3 -3
  102. package/docs/api/interfaces/ExtractAsMoveObjectNode.html +4 -0
  103. package/docs/api/interfaces/GateModule.html +2 -5
  104. package/docs/api/interfaces/GetCharacterAndOwnedObjectsResponse.html +2 -0
  105. package/docs/api/interfaces/GetObjectAndCharacterOwnerResponse.html +2 -0
  106. package/docs/api/interfaces/GetObjectByAddressResponse.html +2 -2
  107. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsResponse.html +2 -2
  108. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsWithJsonResponse.html +2 -2
  109. package/docs/api/interfaces/GetObjectResponse.html +2 -2
  110. package/docs/api/interfaces/GetObjectWithJsonResponse.html +2 -2
  111. package/docs/api/interfaces/GetObjectsByTypeResponse.html +2 -2
  112. package/docs/api/interfaces/GetOwnedObjectsByPackageResponse.html +2 -2
  113. package/docs/api/interfaces/GetOwnedObjectsByTypeResponse.html +2 -2
  114. package/docs/api/interfaces/GetSingletonConfigObjectByTypeResponse.html +2 -0
  115. package/docs/api/interfaces/GetSingletonObjectByTypeResponse.html +2 -2
  116. package/docs/api/interfaces/GetWalletCharactersResponse.html +2 -0
  117. package/docs/api/interfaces/GraphQLResponse.html +2 -2
  118. package/docs/api/interfaces/InventoryItem.html +2 -2
  119. package/docs/api/interfaces/ManufacturingModule.html +1 -2
  120. package/docs/api/interfaces/MoveObjectContents.html +2 -2
  121. package/docs/api/interfaces/MoveObjectData.html +2 -2
  122. package/docs/api/interfaces/NetworkNodeModule.html +2 -2
  123. package/docs/api/interfaces/NotificationContextType.html +2 -2
  124. package/docs/api/interfaces/NotificationState.html +2 -2
  125. package/docs/api/interfaces/Notify.html +2 -2
  126. package/docs/api/interfaces/ObjectNodes.html +2 -0
  127. package/docs/api/interfaces/ObjectWithContentsNode.html +2 -2
  128. package/docs/api/interfaces/OwnedObjectAddressNode.html +2 -2
  129. package/docs/api/interfaces/OwnedObjectFullNode.html +2 -2
  130. package/docs/api/interfaces/OwnedObjectNode.html +2 -2
  131. package/docs/api/interfaces/OwnedObjectNodeWithJson.html +2 -2
  132. package/docs/api/interfaces/OwnerCapData.html +3 -3
  133. package/docs/api/interfaces/PageInfo.html +2 -2
  134. package/docs/api/interfaces/PreviousTransaction.html +2 -0
  135. package/docs/api/interfaces/RawCharacterData.html +3 -3
  136. package/docs/api/interfaces/RawSuiObjectData.html +10 -6
  137. package/docs/api/interfaces/RefineryModule.html +1 -2
  138. package/docs/api/interfaces/SmartAssemblyResponse.html +6 -2
  139. package/docs/api/interfaces/SmartObjectContextType.html +4 -6
  140. package/docs/api/interfaces/SponsoredTransactionInput.html +6 -7
  141. package/docs/api/interfaces/SponsoredTransactionOutput.html +5 -5
  142. package/docs/api/interfaces/StorageModule.html +2 -3
  143. package/docs/api/interfaces/SuiObjectResponse.html +2 -2
  144. package/docs/api/interfaces/TransformOptions.html +8 -4
  145. package/docs/api/interfaces/TurretModule.html +1 -2
  146. package/docs/api/interfaces/TypeRepr.html +2 -0
  147. package/docs/api/interfaces/TypeReprWithLayout.html +3 -0
  148. package/docs/api/interfaces/VaultContextType.html +3 -3
  149. package/docs/api/modules.html +1 -1
  150. package/docs/api/types/AssemblyType.html +1 -1
  151. package/docs/api/types/ContentsTypeAndJson.html +2 -0
  152. package/docs/api/types/ErrorType.html +2 -2
  153. package/docs/api/types/MoveObjectRefWithJson.html +2 -0
  154. package/docs/api/types/SendSponsoredTransactionFn.html +1 -1
  155. package/docs/api/types/SponsoredTransactionArgs.html +2 -2
  156. package/docs/api/types/SponsoredTransactionAssemblyType.html +2 -2
  157. package/docs/api/types/SponsoredTransactionMethod.html +2 -2
  158. package/docs/api/types/UseSponsoredTransactionArgs.html +2 -2
  159. package/docs/api/types/UseSponsoredTransactionError.html +2 -2
  160. package/docs/api/types/UseSponsoredTransactionMutationOptions.html +2 -2
  161. package/docs/api/variables/ASSEMBLY_TYPE_API_STRING.html +2 -2
  162. package/docs/api/variables/ERRORS.html +1 -1
  163. package/docs/api/variables/ERROR_MESSAGES.html +1 -1
  164. package/docs/api/variables/EVEFRONTIER_SPONSORED_TRANSACTION.html +2 -2
  165. package/docs/api/variables/EXCLUDED_TYPEIDS.html +1 -1
  166. package/docs/api/variables/GET_OBJECTS_BY_TYPE.html +2 -2
  167. package/docs/api/variables/GET_OBJECT_BY_ADDRESS.html +2 -2
  168. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE.html +2 -2
  169. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON.html +2 -2
  170. package/docs/api/variables/GET_OBJECT_WITH_DYNAMIC_FIELDS.html +2 -2
  171. package/docs/api/variables/GET_OBJECT_WITH_JSON.html +2 -2
  172. package/docs/api/variables/GET_OWNED_OBJECTS_BY_PACKAGE.html +2 -2
  173. package/docs/api/variables/GET_OWNED_OBJECTS_BY_TYPE.html +2 -2
  174. package/docs/api/variables/GET_SINGLETON_CONFIG_OBJECT_BY_TYPE.html +2 -0
  175. package/docs/api/variables/GET_SINGLETON_OBJECT_BY_TYPE.html +2 -2
  176. package/docs/api/variables/GET_WALLET_CHARACTERS.html +3 -0
  177. package/docs/api/variables/NotificationContext.html +1 -1
  178. package/docs/api/variables/ONE_M3.html +2 -2
  179. package/docs/api/variables/POLLING_INTERVAL.html +2 -2
  180. package/docs/api/variables/STORAGE_KEYS.html +2 -2
  181. package/docs/api/variables/SmartObjectContext.html +1 -1
  182. package/docs/api/variables/VaultContext.html +1 -1
  183. package/docs/api/variables/dAppKit.html +2 -2
  184. package/graphql/client.ts +119 -24
  185. package/graphql/index.ts +5 -39
  186. package/graphql/queries.ts +166 -1
  187. package/graphql/types.ts +192 -167
  188. package/hooks/index.ts +1 -0
  189. package/hooks/useSmartObject.ts +2 -12
  190. package/hooks/useSponsoredTransaction.ts +60 -9
  191. package/index.ts +7 -71
  192. package/package.json +1 -1
  193. package/providers/SmartObjectProvider.tsx +84 -57
  194. package/types/contexts.ts +1 -3
  195. package/types/sponsoredTransaction.ts +1 -0
  196. package/types/types.ts +52 -10
  197. package/types/worldApiReturnTypes.ts +13 -37
  198. package/utils/__tests__/burnRate.test.ts +121 -0
  199. package/utils/__tests__/character.test.ts +112 -0
  200. package/utils/__tests__/characterOwnedObjects.test.ts +222 -0
  201. package/utils/__tests__/config.test.ts +424 -0
  202. package/utils/__tests__/mapping.test.ts +2 -2
  203. package/utils/burnRate.ts +46 -0
  204. package/utils/character.ts +46 -0
  205. package/utils/characterOwnedObjects.ts +52 -0
  206. package/utils/config.ts +151 -0
  207. package/utils/constants.ts +39 -5
  208. package/utils/datahub.ts +3 -41
  209. package/utils/errors.ts +1 -1
  210. package/utils/index.ts +10 -1
  211. package/utils/mapping.ts +5 -2
  212. package/utils/transforms.ts +34 -31
  213. package/vite-env.d.ts +2 -2
  214. package/wallet/features.ts +7 -2
  215. package/docs/api/interfaces/GameTypeResponse.html +0 -13
@@ -7,17 +7,15 @@ import { SmartObjectContextType } from "../types";
7
7
  *
8
8
  * Provides reactive access to the currently selected smart assembly (Smart Storage Unit,
9
9
  * Smart Turret, Smart Gate, Network Node, etc.) with automatic polling for updates.
10
- * The assembly ID is determined from environment variables (`VITE_ITEM_ID`)
11
- * or URL query parameters (`?itemId=` and `?tenant=`).
10
+ * The assembly ID is determined from URL query parameters (`?itemId=` and `?tenant=`)
11
+ * or environment variables as a Sui object ID (`VITE_OBJECT_ID`).
12
12
  *
13
13
  * @category Hooks
14
14
  * @returns Object containing assembly state and methods:
15
15
  * - `assembly` - The transformed assembly data (or null if not loaded)
16
16
  * - `character` - The owner character information (or null)
17
- * - `selectedObjectId` - The current assembly's Sui object ID
18
17
  * - `loading` - Boolean indicating if data is being fetched
19
18
  * - `error` - Error message string (or null)
20
- * - `setSelectedObjectId` - Function to change the selected assembly
21
19
  * - `refetch` - Function to manually refresh assembly data
22
20
  * @throws {Error} If used outside of `EveFrontierProvider`
23
21
  *
@@ -56,14 +54,6 @@ import { SmartObjectContextType } from "../types";
56
54
  * );
57
55
  * ```
58
56
  *
59
- * @example Changing the selected assembly
60
- * ```tsx
61
- * const { setSelectedObjectId } = useSmartObject();
62
- *
63
- * const handleSelectAssembly = (newId: string) => {
64
- * setSelectedObjectId(newId);
65
- * };
66
- * ```
67
57
  */
68
58
  export function useSmartObject(): SmartObjectContextType {
69
59
  const context = useContext(SmartObjectContext);
@@ -74,6 +74,58 @@ export class WalletNoAccountSelectedError extends Error {
74
74
  }
75
75
  }
76
76
 
77
+ /**
78
+ * Error thrown when assembly ID cannot be resolved or is invalid.
79
+ * Assembly ID must come from the assembly object (item_id) or the URL query param (itemId), and must be a valid non-negative integer.
80
+ *
81
+ * @category Errors
82
+ */
83
+ export class AssemblyIdRequiredError extends Error {
84
+ constructor(reason?: string) {
85
+ super(
86
+ reason ??
87
+ "Assembly ID is required: pass an assembly object with item_id or set the itemId query param to a valid non-negative integer",
88
+ );
89
+ this.name = "AssemblyIdRequiredError";
90
+ }
91
+ }
92
+
93
+ // ============================================================================
94
+ // Assembly ID resolution
95
+ // ============================================================================
96
+
97
+ /**
98
+ * Resolves assembly ID to a non-negative integer from the assembly object or query param.
99
+ * Fails fast with {@link AssemblyIdRequiredError} if neither source provides a valid id.
100
+ */
101
+ function resolveAssemblyId(
102
+ assemblyItemId: number | undefined,
103
+ queryItemId: string | null,
104
+ ): number {
105
+ const fromAssembly =
106
+ typeof assemblyItemId === "number" &&
107
+ Number.isInteger(assemblyItemId) &&
108
+ assemblyItemId >= 0
109
+ ? assemblyItemId
110
+ : undefined;
111
+
112
+ if (fromAssembly !== undefined) {
113
+ return fromAssembly;
114
+ }
115
+
116
+ if (queryItemId != null && queryItemId.trim() !== "") {
117
+ const parsed = parseInt(queryItemId.trim(), 10);
118
+ if (Number.isNaN(parsed) || parsed < 0) {
119
+ throw new AssemblyIdRequiredError(
120
+ `Query param itemId must be a non-negative integer; got "${queryItemId}"`,
121
+ );
122
+ }
123
+ return parsed;
124
+ }
125
+
126
+ throw new AssemblyIdRequiredError();
127
+ }
128
+
77
129
  // ============================================================================
78
130
  // Hook Types
79
131
  // ============================================================================
@@ -87,6 +139,7 @@ export type UseSponsoredTransactionError =
87
139
  | WalletSponsoredTransactionNotSupportedError
88
140
  | WalletNotConnectedError
89
141
  | WalletNoAccountSelectedError
142
+ | AssemblyIdRequiredError
90
143
  | Error;
91
144
 
92
145
  /**
@@ -129,10 +182,9 @@ export type UseSponsoredTransactionMutationOptions = Omit<
129
182
  * **Input** (passed to `mutate` / `mutateAsync`):
130
183
  * - `txAction` (required) – The sponsored action to run (e.g. BRING_ONLINE, BRING_OFFLINE).
131
184
  * - `chain` (required) – Sui chain id, e.g. `"sui:testnet"` or `"sui:mainnet"`.
132
- * - `assembly` (required) – Full assembly object (`AssemblyType<Assemblies>`). Must include `type` and `item_id`; `item_id` falls back to the URL query param (e.g. `item_id`) when present.
185
+ * - `assembly` (required) – Full assembly object (`AssemblyType<Assemblies>`). Must include `type` and `item_id` (number). If `item_id` is missing or invalid, the hook falls back to the URL query param `itemId` (parsed as a non-negative integer). Fails with {@link AssemblyIdRequiredError} if neither source provides a valid id.
133
186
  * - `tenant` (optional) – Tenant ID. When omitted, the hook resolves it from the URL query param (e.g. `tenant`) with fallback to `"testevenet"`. Pass explicitly to override.
134
187
  * - `account` (optional) – Signer address. If omitted, the currently connected wallet account is used.
135
- * - `destination` (optional) – Additional destination payload when required by the action.
136
188
  *
137
189
  * **Output** (on success, in `data` or resolved from `mutateAsync`):
138
190
  * - `digest` (required) – Transaction digest.
@@ -152,6 +204,7 @@ export type UseSponsoredTransactionMutationOptions = Omit<
152
204
  * @throws {WalletNotConnectedError} If no wallet is connected
153
205
  * @throws {WalletNoAccountSelectedError} If no account is selected
154
206
  * @throws {WalletSponsoredTransactionNotSupportedError} If wallet doesn't support sponsored transactions
207
+ * @throws {AssemblyIdRequiredError} If assembly ID is missing or invalid (neither assembly.item_id nor itemId query param is a valid non-negative integer)
155
208
  *
156
209
  * @example Basic bring online transaction
157
210
  * ```tsx
@@ -235,9 +288,6 @@ export function useSponsoredTransaction({
235
288
  const queryItemId = queryParams.get(QueryParams.ITEM_ID);
236
289
  const queryTenant = queryParams.get(QueryParams.TENANT);
237
290
 
238
- console.log("queryItemId", queryItemId);
239
- console.log("queryTenant", queryTenant);
240
-
241
291
  return useMutation({
242
292
  mutationKey: [
243
293
  "evefrontier",
@@ -323,13 +373,14 @@ export function useSponsoredTransaction({
323
373
  );
324
374
  }
325
375
 
376
+ const assemblyId = resolveAssemblyId(args.assembly.item_id, queryItemId);
377
+
326
378
  const payload: SponsoredTransactionInput = {
327
- txAction: args.txAction as SponsoredTransactionActions,
328
- assembly: args.assembly.item_id ?? queryItemId,
379
+ txAction: args.txAction,
380
+ assembly: assemblyId,
329
381
  assemblyType: getAssemblyTypeApiString(args.assembly.type),
330
- chain: args.chain as `sui:${string}`,
382
+ chain: args.chain,
331
383
  tenant,
332
- ...(args.destination != null ? { destination: args.destination } : {}),
333
384
  };
334
385
 
335
386
  console.log("payload", payload);
package/index.ts CHANGED
@@ -44,82 +44,18 @@ export * from "./utils";
44
44
  // =========================================
45
45
  // GraphQL - Query execution & helper functions
46
46
  // =========================================
47
- export {
48
- executeGraphQLQuery,
49
- getObjectByAddress,
50
- getObjectWithDynamicFields,
51
- getObjectWithJson,
52
- getObjectOwnerAndOwnedObjectsByType,
53
- getObjectAndCharacterOwner,
54
- getOwnedObjectsByType,
55
- getOwnedObjectsByPackage,
56
- getSingletonObjectByType,
57
- getObjectsByType,
58
- // Character/owner resolution
59
- getAssemblyWithOwner,
60
- } from "./graphql";
61
-
62
- // GraphQL - Query strings
63
- export {
64
- // Core object queries
65
- GET_OBJECT_BY_ADDRESS,
66
- GET_OBJECT_WITH_DYNAMIC_FIELDS,
67
- GET_OBJECT_WITH_JSON,
68
- // Owner & ownership queries
69
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE,
70
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON,
71
- GET_OWNED_OBJECTS_BY_TYPE,
72
- GET_OWNED_OBJECTS_BY_PACKAGE,
73
- // Singleton & type-based queries
74
- GET_SINGLETON_OBJECT_BY_TYPE,
75
- GET_OBJECTS_BY_TYPE,
76
- } from "./graphql";
77
-
78
- // GraphQL - Types
79
- export type {
80
- // Base types
81
- GraphQLResponse,
82
- PageInfo,
83
- // Move object types
84
- MoveObjectContents,
85
- DynamicFieldNode,
86
- MoveObjectData,
87
- // Object response types
88
- SuiObjectResponse,
89
- GetObjectResponse,
90
- // GetObjectByAddress types
91
- GetObjectByAddressResponse,
92
- // GetObjectWithJson types
93
- GetObjectWithJsonResponse,
94
- // Owner & owned objects types
95
- OwnedObjectNode,
96
- AddressOwner,
97
- GetObjectOwnerAndOwnedObjectsResponse,
98
- // Owner & owned objects with JSON types
99
- OwnedObjectNodeWithJson,
100
- AddressOwnerWithJson,
101
- GetObjectOwnerAndOwnedObjectsWithJsonResponse,
102
- // GetOwnedObjectsByType types
103
- OwnedObjectAddressNode,
104
- GetOwnedObjectsByTypeResponse,
105
- // GetOwnedObjectsByPackage types
106
- OwnedObjectFullNode,
107
- GetOwnedObjectsByPackageResponse,
108
- // Singleton & type-based types
109
- GetSingletonObjectByTypeResponse,
110
- ObjectWithContentsNode,
111
- GetObjectsByTypeResponse,
112
- // EVE Frontier specific types
113
- RawSuiObjectData,
114
- OwnerCapData,
115
- RawCharacterData,
116
- CharacterInfo,
117
- } from "./graphql";
47
+ export * from "./graphql";
118
48
 
119
49
  // =========================================
120
50
  // Config
121
51
  // =========================================
122
52
  export { dAppKit } from "./config/dapp-kit";
53
+ export {
54
+ getEnergyConfig,
55
+ getFuelEfficiencyConfig,
56
+ getFuelEfficiencyForType,
57
+ getEnergyUsageForType,
58
+ } from "./utils/config";
123
59
 
124
60
  // =========================================
125
61
  // Constants & Configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evefrontier/dapp-kit",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "React SDK for EVE Frontier dApps on Sui",
5
5
  "main": "index.ts",
6
6
  "author": "",
@@ -25,14 +25,22 @@ import { getDatahubGameInfo } from "../utils/datahub";
25
25
  import { useConnection } from "../hooks/useConnection";
26
26
  import { SmartObjectContextType } from "../types";
27
27
 
28
+ /** Tenant when not provided via URL ?tenant= (e.g. dev/default chain). */
29
+ const DEFAULT_TENANT = "testevenet";
30
+
31
+ /** Input for fetching object data: either itemId + tenant (derive object ID) or a Sui object ID directly.
32
+ * @category Types
33
+ */
34
+ export type FetchObjectDataInput =
35
+ | { itemId: string; selectedTenant: string }
36
+ | { objectId: string };
37
+
28
38
  /** @category Providers */
29
39
  export const SmartObjectContext = createContext<SmartObjectContextType>({
30
40
  assembly: null,
31
- character: null,
32
- selectedObjectId: "",
41
+ assemblyOwner: null,
33
42
  loading: true,
34
43
  error: null,
35
- setSelectedObjectId: () => {},
36
44
  refetch: async () => {},
37
45
  });
38
46
 
@@ -41,10 +49,10 @@ export const SmartObjectContext = createContext<SmartObjectContextType>({
41
49
  * It uses GraphQL queries to fetch objects on the Sui blockchain
42
50
  * from the EVE Frontier package, with optional polling for updates.
43
51
  *
44
- * The provider fetches both the assembly data and its owner (character) information:
52
+ * The provider fetches both the assembly data and its owner (assemblyOwner) information:
45
53
  * 1. Fetches assembly data with dynamic fields
46
54
  * 2. Uses owner_cap_id to resolve the Character OwnerCap
47
- * 3. Fetches full character data from the Character ID
55
+ * 3. Fetches full assemblyOwner data from the Character ID
48
56
  *
49
57
  * @category Providers
50
58
  */
@@ -52,10 +60,11 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
52
60
  const [assembly, setAssembly] = useState<AssemblyType<Assemblies> | null>(
53
61
  null,
54
62
  );
55
- const [character, setCharacter] =
63
+ const [assemblyOwner, setAssemblyOwner] =
56
64
  useState<DetailedSmartCharacterResponse | null>(null);
57
65
  const [selectedObjectId, setSelectedObjectId] = useState<string>("");
58
66
  const [selectedTenant, setSelectedTenant] = useState<string>("");
67
+ const [isObjectIdDirect, setIsObjectIdDirect] = useState<boolean>(false); // Whether selectedObjectId is a Sui object ID or derived from itemId + tenant.
59
68
  const [loading, setLoading] = useState<boolean>(true);
60
69
  const [error, setError] = useState<string | null>(null);
61
70
 
@@ -64,10 +73,16 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
64
73
 
65
74
  const { isConnected } = useConnection();
66
75
 
67
- // Fetch object data with owner/character info
76
+ // Fetch object data with owner/assemblyOwner info.
77
+ // Accepts either { itemId, selectedTenant } (derive Sui object ID) or { objectId } (use directly).
68
78
  const fetchObjectData = useCallback(
69
- async (itemId: string, selectedTenant: string, isInitialFetch = false) => {
70
- if (!itemId || !selectedTenant) return;
79
+ async (input: FetchObjectDataInput, isInitialFetch = false) => {
80
+ const hasItemId = "itemId" in input && "selectedTenant" in input;
81
+ if (hasItemId) {
82
+ if (!input.itemId || !input.selectedTenant) return;
83
+ } else {
84
+ if (!input.objectId) return;
85
+ }
71
86
 
72
87
  if (isInitialFetch) {
73
88
  setLoading(true);
@@ -75,24 +90,30 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
75
90
  setError(null);
76
91
 
77
92
  try {
93
+ const objectId = hasItemId
94
+ ? await getObjectId(input.itemId, input.selectedTenant)
95
+ : input.objectId;
78
96
  console.log(
79
- "[DappKit] SmartObjectProvider: Fetching object with item ID and tenant:",
80
- itemId,
81
- selectedTenant,
97
+ "[DappKit] SmartObjectProvider: Fetching object:",
98
+ hasItemId
99
+ ? { itemId: input.itemId, selectedTenant: input.selectedTenant }
100
+ : { objectId },
82
101
  );
83
102
 
84
- const objectId = await getObjectId(itemId, selectedTenant);
85
-
86
- // Fetch both assembly and character data
87
- const { moveObject, character: characterInfo } =
88
- await getAssemblyWithOwner(objectId);
103
+ // Fetch both assembly and assemblyOwner data
104
+ const {
105
+ moveObject,
106
+ assemblyOwner: characterInfo,
107
+ energySource,
108
+ destinationGate,
109
+ } = await getAssemblyWithOwner(objectId);
89
110
 
90
111
  if (!moveObject) {
91
112
  console.warn(
92
113
  "[DappKit] SmartObjectProvider: Object not found or not a Move object",
93
114
  );
94
115
  setAssembly(null);
95
- setCharacter(null);
116
+ setAssemblyOwner(null);
96
117
  setError("Object not found or not a Move object");
97
118
  return;
98
119
  }
@@ -100,7 +121,8 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
100
121
  // Create a hash of the data to check for changes
101
122
  const dataHash = JSON.stringify({
102
123
  moveObject,
103
- character: characterInfo,
124
+ assemblyOwner: characterInfo,
125
+ energySource,
104
126
  });
105
127
 
106
128
  // Only update state if the data changed (optimization for polling)
@@ -125,24 +147,26 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
125
147
  );
126
148
  }
127
149
 
128
- // Transform assembly with character and datahub info
150
+ // Transform assembly with assemblyOwner and datahub info
129
151
  const transformed = await transformToAssembly(
130
152
  objectId,
131
153
  moveObject as MoveObjectData,
132
154
  {
133
155
  character: characterInfo,
134
156
  datahubInfo,
157
+ energySource: energySource,
158
+ destinationGate: destinationGate,
135
159
  },
136
160
  );
137
161
 
138
162
  setAssembly(transformed);
139
163
 
140
- // Transform and set character
164
+ // Transform and set assemblyOwner: owner of the assembly
141
165
  if (characterInfo) {
142
166
  const transformedCharacter = transformToCharacter(characterInfo);
143
- setCharacter(transformedCharacter);
167
+ setAssemblyOwner(transformedCharacter);
144
168
  } else {
145
- setCharacter(null);
169
+ setAssemblyOwner(null);
146
170
  }
147
171
  }
148
172
  setError(null);
@@ -158,56 +182,59 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
158
182
  [],
159
183
  );
160
184
 
161
- // Initialize the object ID from env or query params
185
+ // Initialize the object ID (env or query params) and tenant (query params).
186
+ // Tenant comes from URL ?tenant= with fallback DEFAULT_TENANT.
162
187
  useEffect(() => {
163
188
  console.log("[DappKit] SmartObjectProvider: Checking for item ID");
164
189
 
190
+ const queryParams = new URLSearchParams(window.location.search);
191
+ const queryTenant =
192
+ queryParams.get(QueryParams.TENANT)?.trim() || DEFAULT_TENANT;
193
+
165
194
  // Check if an object ID exists in the .env file
166
- const envItemId = import.meta.env.VITE_ITEM_ID;
195
+ const envObjectId = import.meta.env.VITE_OBJECT_ID;
167
196
 
168
- if (envItemId) {
197
+ if (envObjectId) {
169
198
  console.log(
170
- "[DappKit] SmartObjectProvider: Using item ID from env:",
171
- envItemId,
199
+ "[DappKit] SmartObjectProvider: Using Sui object ID from env:",
200
+ envObjectId,
172
201
  );
173
- setSelectedObjectId(envItemId);
202
+ setSelectedObjectId(envObjectId);
203
+ setSelectedTenant(queryTenant);
204
+ setIsObjectIdDirect(true);
174
205
  return;
175
206
  }
176
207
 
177
- // Check if an object ID has been passed via query param
178
- const queryParams = new URLSearchParams(window.location.search);
208
+ // Else, derive object ID from item ID and tenant and passed via query param
179
209
  const queryItemId = queryParams.get(QueryParams.ITEM_ID);
180
- const queryTenant = queryParams.get(QueryParams.TENANT);
181
210
 
182
211
  if (queryItemId) {
183
212
  setSelectedObjectId(queryItemId);
213
+ setSelectedTenant(queryTenant);
214
+ setIsObjectIdDirect(false);
184
215
  } else {
185
216
  console.error("[DappKit] SmartObjectProvider: No object ID provided");
186
217
  setLoading(false);
187
218
  }
188
-
189
- if (queryTenant) {
190
- setSelectedTenant(queryTenant);
191
- } else {
192
- console.error("[DappKit] SmartObjectProvider: No tenant provided");
193
- }
194
219
  }, []);
195
220
 
196
221
  // Fetch and poll for object data
197
222
  useEffect(() => {
198
223
  if (!selectedObjectId || !isConnected) {
199
- if (!selectedObjectId) {
200
- setLoading(false);
201
- }
224
+ setLoading(false);
202
225
  return;
203
226
  }
204
227
 
228
+ const input: FetchObjectDataInput = isObjectIdDirect
229
+ ? { objectId: selectedObjectId }
230
+ : { itemId: selectedObjectId, selectedTenant };
231
+
205
232
  // Initial fetch
206
- fetchObjectData(selectedObjectId, selectedTenant, true);
233
+ fetchObjectData(input, true);
207
234
 
208
235
  // Set up polling
209
236
  pollingRef.current = setInterval(() => {
210
- fetchObjectData(selectedObjectId, selectedTenant, false);
237
+ fetchObjectData(input, false);
211
238
  }, POLLING_INTERVAL);
212
239
 
213
240
  console.log(
@@ -223,29 +250,29 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
223
250
  }
224
251
  lastDataHashRef.current = null;
225
252
  };
226
- }, [selectedObjectId, isConnected, fetchObjectData]);
227
-
228
- const handleSetSelectedObjectId = useCallback((id: string) => {
229
- console.log("[DappKit] SmartObjectProvider: Setting new object ID:", id);
230
- lastDataHashRef.current = null;
231
- setSelectedObjectId(id);
232
- }, []);
253
+ }, [
254
+ selectedObjectId,
255
+ selectedTenant,
256
+ isObjectIdDirect,
257
+ isConnected,
258
+ fetchObjectData,
259
+ ]);
233
260
 
234
261
  const handleRefetch = useCallback(async () => {
235
- if (selectedObjectId) {
236
- await fetchObjectData(selectedObjectId, selectedTenant, true);
237
- }
238
- }, [selectedObjectId, selectedTenant, fetchObjectData]);
262
+ if (!selectedObjectId) return;
263
+ const input: FetchObjectDataInput = isObjectIdDirect
264
+ ? { objectId: selectedObjectId }
265
+ : { itemId: selectedObjectId, selectedTenant };
266
+ await fetchObjectData(input, true);
267
+ }, [selectedObjectId, selectedTenant, isObjectIdDirect, fetchObjectData]);
239
268
 
240
269
  return (
241
270
  <SmartObjectContext.Provider
242
271
  value={{
243
272
  assembly,
244
- character,
245
- selectedObjectId,
273
+ assemblyOwner,
246
274
  loading,
247
275
  error,
248
- setSelectedObjectId: handleSetSelectedObjectId,
249
276
  refetch: handleRefetch,
250
277
  }}
251
278
  >
package/types/contexts.ts CHANGED
@@ -28,11 +28,9 @@ export enum SupportedWallets {
28
28
  * @category Types */
29
29
  export interface SmartObjectContextType {
30
30
  assembly: AssemblyType<Assemblies> | null;
31
- character: DetailedSmartCharacterResponse | null;
32
- selectedObjectId: string;
31
+ assemblyOwner: DetailedSmartCharacterResponse | null;
33
32
  loading: boolean;
34
33
  error: string | null;
35
- setSelectedObjectId: (id: string) => void;
36
34
  refetch: () => Promise<void>;
37
35
  }
38
36
 
@@ -54,6 +54,7 @@ export const ASSEMBLY_TYPE_API_STRING: Record<Assemblies, string> = {
54
54
  [Assemblies.NetworkNode]: "network-nodes",
55
55
  [Assemblies.Manufacturing]: "manufacturing",
56
56
  [Assemblies.Refinery]: "refineries",
57
+ [Assemblies.Assembly]: "assemblies",
57
58
  } as const;
58
59
 
59
60
  /** API slug for assembly type in sponsored transaction payloads (e.g. "storage-units"). */
package/types/types.ts CHANGED
@@ -73,6 +73,7 @@ export enum Assemblies {
73
73
  NetworkNode = "NetworkNode",
74
74
  Manufacturing = "Manufacturing",
75
75
  Refinery = "Refinery",
76
+ Assembly = "Assembly",
76
77
  }
77
78
 
78
79
  /** @category Types */
@@ -86,16 +87,18 @@ export type AssemblyType<T extends Assemblies> = {
86
87
  [K in T]: K extends Assemblies.SmartStorageUnit
87
88
  ? AssemblyProperties<K> & { storage: StorageModule }
88
89
  : K extends Assemblies.SmartTurret
89
- ? AssemblyProperties<K> & { turret: TurretModule }
90
- : K extends Assemblies.SmartGate
91
- ? AssemblyProperties<K> & { gate: GateModule }
92
- : K extends Assemblies.NetworkNode
93
- ? AssemblyProperties<K> & { networkNode: NetworkNodeModule }
94
- : K extends Assemblies.Refinery
95
- ? AssemblyProperties<K> & { refinery: RefineryModule }
96
- : K extends Assemblies.Manufacturing
97
- ? AssemblyProperties<K> & { manufacturing: ManufacturingModule }
98
- : never;
90
+ ? AssemblyProperties<K> & { turret: TurretModule }
91
+ : K extends Assemblies.SmartGate
92
+ ? AssemblyProperties<K> & { gate: GateModule }
93
+ : K extends Assemblies.NetworkNode
94
+ ? AssemblyProperties<K> & { networkNode: NetworkNodeModule }
95
+ : K extends Assemblies.Refinery
96
+ ? AssemblyProperties<K> & { refinery: RefineryModule }
97
+ : K extends Assemblies.Manufacturing
98
+ ? AssemblyProperties<K> & { manufacturing: ManufacturingModule }
99
+ : K extends Assemblies.Assembly
100
+ ? AssemblyProperties<K>
101
+ : never;
99
102
  }[T];
100
103
 
101
104
  // =========================================
@@ -111,3 +114,42 @@ export interface DetailedSmartCharacterResponse {
111
114
  smartAssemblies: Assemblies[];
112
115
  portrait: string;
113
116
  }
117
+
118
+ // =========================================
119
+ // Datahub Game Info
120
+ // =========================================
121
+
122
+ /**
123
+ * Game item/type information from the EVE Frontier Datahub API.
124
+ *
125
+ * Contains metadata about items, assemblies, and other game objects
126
+ * including display names, descriptions, icons, and physical properties.
127
+ *
128
+ * @category Types
129
+ */
130
+ export interface DatahubGameInfo {
131
+ /** The type ID (matches on-chain type_id) */
132
+ id: number;
133
+ /** Display name of the item/type */
134
+ name: string;
135
+ /** Description text */
136
+ description: string;
137
+ /** Mass in kg */
138
+ mass: number;
139
+ /** Radius in meters */
140
+ radius: number;
141
+ /** Volume in cubic meters */
142
+ volume: number;
143
+ /** Portion size for stacking */
144
+ portionSize: number;
145
+ /** Category group name (e.g., "Structures") */
146
+ groupName: string;
147
+ /** Category group ID */
148
+ groupId: number;
149
+ /** Top-level category name */
150
+ categoryName: string;
151
+ /** Top-level category ID */
152
+ categoryId: number;
153
+ /** URL to the item's icon image */
154
+ iconUrl: string;
155
+ }