@evefrontier/dapp-kit 0.1.1 → 0.1.2

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 (153) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/docs/api/assets/search.js +1 -1
  4. package/docs/api/classes/WalletNoAccountSelectedError.html +2 -2
  5. package/docs/api/classes/WalletNotConnectedError.html +2 -2
  6. package/docs/api/classes/WalletSponsoredTransactionNotSupportedError.html +2 -2
  7. package/docs/api/enums/ActionTypes.html +2 -2
  8. package/docs/api/enums/Assemblies.html +2 -2
  9. package/docs/api/enums/QueryParams.html +2 -2
  10. package/docs/api/enums/Severity.html +2 -2
  11. package/docs/api/enums/SponsoredTransactionActions.html +2 -2
  12. package/docs/api/enums/State.html +2 -2
  13. package/docs/api/enums/SupportedWallets.html +2 -2
  14. package/docs/api/enums/TYPEIDS.html +2 -2
  15. package/docs/api/functions/EveFrontierProvider.html +1 -1
  16. package/docs/api/functions/NotificationProvider.html +1 -1
  17. package/docs/api/functions/SmartObjectProvider.html +1 -1
  18. package/docs/api/functions/VaultProvider.html +1 -1
  19. package/docs/api/functions/abbreviateAddress.html +1 -1
  20. package/docs/api/functions/assertAssemblyType.html +1 -1
  21. package/docs/api/functions/clickToCopy.html +1 -1
  22. package/docs/api/functions/executeGraphQLQuery.html +1 -1
  23. package/docs/api/functions/findOwnerByAddress.html +1 -1
  24. package/docs/api/functions/formatDuration.html +1 -1
  25. package/docs/api/functions/formatM3.html +1 -1
  26. package/docs/api/functions/getAssemblyType.html +1 -1
  27. package/docs/api/functions/getAssemblyTypeApiString.html +1 -1
  28. package/docs/api/functions/getAssemblyWithOwner.html +3 -3
  29. package/docs/api/functions/getCharacterOwnerCapType.html +1 -1
  30. package/docs/api/functions/getCommonItems.html +1 -1
  31. package/docs/api/functions/getDappUrl.html +1 -1
  32. package/docs/api/functions/getDatahubGameInfo.html +1 -1
  33. package/docs/api/functions/getEnv.html +1 -1
  34. package/docs/api/functions/getEveWorldPackageId.html +1 -1
  35. package/docs/api/functions/getObjectByAddress.html +1 -1
  36. package/docs/api/functions/getObjectId.html +1 -1
  37. package/docs/api/functions/getObjectOwnerAndOwnedObjectsByType.html +1 -1
  38. package/docs/api/functions/getObjectRegistryType.html +1 -1
  39. package/docs/api/functions/getObjectWithDynamicFields.html +1 -1
  40. package/docs/api/functions/getObjectWithJson.html +1 -1
  41. package/docs/api/functions/getObjectsByType.html +1 -1
  42. package/docs/api/functions/getOwnedObjectsByPackage.html +1 -1
  43. package/docs/api/functions/getOwnedObjectsByType.html +1 -1
  44. package/docs/api/functions/getRegistryAddress.html +1 -1
  45. package/docs/api/functions/getSingletonObjectByType.html +1 -1
  46. package/docs/api/functions/getSponsoredTransactionFeature.html +1 -1
  47. package/docs/api/functions/getSuiGraphqlEndpoint.html +1 -1
  48. package/docs/api/functions/getTxUrl.html +1 -1
  49. package/docs/api/functions/getVolumeM3.html +1 -1
  50. package/docs/api/functions/hasSponsoredTransactionFeature.html +1 -1
  51. package/docs/api/functions/isOwner.html +1 -1
  52. package/docs/api/functions/parseErrorFromMessage.html +1 -1
  53. package/docs/api/functions/parseStatus.html +1 -1
  54. package/docs/api/functions/parseURL.html +1 -1
  55. package/docs/api/functions/removeTrailingZeros.html +1 -1
  56. package/docs/api/functions/transformToAssembly.html +1 -1
  57. package/docs/api/functions/transformToCharacter.html +1 -1
  58. package/docs/api/functions/useConnection.html +1 -1
  59. package/docs/api/functions/useNotification.html +1 -1
  60. package/docs/api/functions/useSmartObject.html +3 -8
  61. package/docs/api/functions/useSponsoredTransaction.html +4 -4
  62. package/docs/api/functions/walletSupportsSponsoredTransaction.html +1 -1
  63. package/docs/api/index.html +1 -3
  64. package/docs/api/interfaces/AddressOwner.html +2 -2
  65. package/docs/api/interfaces/AddressOwnerWithJson.html +2 -2
  66. package/docs/api/interfaces/AssemblyProperties.html +2 -2
  67. package/docs/api/interfaces/CharacterInfo.html +2 -2
  68. package/docs/api/interfaces/DatahubGameInfo.html +14 -14
  69. package/docs/api/interfaces/DetailedAssemblyResponse.html +2 -2
  70. package/docs/api/interfaces/DetailedSmartCharacterResponse.html +2 -2
  71. package/docs/api/interfaces/DynamicFieldNode.html +2 -2
  72. package/docs/api/interfaces/EphemeralInventory.html +2 -2
  73. package/docs/api/interfaces/EveFrontierSponsoredTransactionFeature.html +2 -2
  74. package/docs/api/interfaces/GameTypeResponse.html +2 -2
  75. package/docs/api/interfaces/GateModule.html +2 -2
  76. package/docs/api/interfaces/GetObjectByAddressResponse.html +2 -2
  77. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsResponse.html +2 -2
  78. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsWithJsonResponse.html +2 -2
  79. package/docs/api/interfaces/GetObjectResponse.html +2 -2
  80. package/docs/api/interfaces/GetObjectWithJsonResponse.html +2 -2
  81. package/docs/api/interfaces/GetObjectsByTypeResponse.html +2 -2
  82. package/docs/api/interfaces/GetOwnedObjectsByPackageResponse.html +2 -2
  83. package/docs/api/interfaces/GetOwnedObjectsByTypeResponse.html +2 -2
  84. package/docs/api/interfaces/GetSingletonObjectByTypeResponse.html +2 -2
  85. package/docs/api/interfaces/GraphQLResponse.html +2 -2
  86. package/docs/api/interfaces/InventoryItem.html +2 -2
  87. package/docs/api/interfaces/ManufacturingModule.html +2 -2
  88. package/docs/api/interfaces/MoveObjectContents.html +2 -2
  89. package/docs/api/interfaces/MoveObjectData.html +2 -2
  90. package/docs/api/interfaces/NetworkNodeModule.html +2 -2
  91. package/docs/api/interfaces/NotificationContextType.html +2 -2
  92. package/docs/api/interfaces/NotificationState.html +2 -2
  93. package/docs/api/interfaces/Notify.html +2 -2
  94. package/docs/api/interfaces/ObjectWithContentsNode.html +2 -2
  95. package/docs/api/interfaces/OwnedObjectAddressNode.html +2 -2
  96. package/docs/api/interfaces/OwnedObjectFullNode.html +2 -2
  97. package/docs/api/interfaces/OwnedObjectNode.html +2 -2
  98. package/docs/api/interfaces/OwnedObjectNodeWithJson.html +2 -2
  99. package/docs/api/interfaces/OwnerCapData.html +2 -2
  100. package/docs/api/interfaces/PageInfo.html +2 -2
  101. package/docs/api/interfaces/RawCharacterData.html +2 -2
  102. package/docs/api/interfaces/RawSuiObjectData.html +9 -5
  103. package/docs/api/interfaces/RefineryModule.html +2 -2
  104. package/docs/api/interfaces/SmartAssemblyResponse.html +2 -2
  105. package/docs/api/interfaces/SmartObjectContextType.html +2 -4
  106. package/docs/api/interfaces/SponsoredTransactionInput.html +5 -6
  107. package/docs/api/interfaces/SponsoredTransactionOutput.html +4 -4
  108. package/docs/api/interfaces/StorageModule.html +2 -2
  109. package/docs/api/interfaces/SuiObjectResponse.html +2 -2
  110. package/docs/api/interfaces/TransformOptions.html +5 -3
  111. package/docs/api/interfaces/TurretModule.html +2 -2
  112. package/docs/api/interfaces/VaultContextType.html +2 -2
  113. package/docs/api/types/AssemblyType.html +1 -1
  114. package/docs/api/types/ErrorType.html +2 -2
  115. package/docs/api/types/SendSponsoredTransactionFn.html +1 -1
  116. package/docs/api/types/SponsoredTransactionArgs.html +2 -2
  117. package/docs/api/types/SponsoredTransactionAssemblyType.html +1 -1
  118. package/docs/api/types/SponsoredTransactionMethod.html +1 -1
  119. package/docs/api/types/UseSponsoredTransactionArgs.html +1 -1
  120. package/docs/api/types/UseSponsoredTransactionError.html +2 -2
  121. package/docs/api/types/UseSponsoredTransactionMutationOptions.html +1 -1
  122. package/docs/api/variables/ASSEMBLY_TYPE_API_STRING.html +1 -1
  123. package/docs/api/variables/ERRORS.html +1 -1
  124. package/docs/api/variables/ERROR_MESSAGES.html +1 -1
  125. package/docs/api/variables/EVEFRONTIER_SPONSORED_TRANSACTION.html +1 -1
  126. package/docs/api/variables/EXCLUDED_TYPEIDS.html +1 -1
  127. package/docs/api/variables/GET_OBJECTS_BY_TYPE.html +1 -1
  128. package/docs/api/variables/GET_OBJECT_BY_ADDRESS.html +1 -1
  129. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE.html +1 -1
  130. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON.html +1 -1
  131. package/docs/api/variables/GET_OBJECT_WITH_DYNAMIC_FIELDS.html +1 -1
  132. package/docs/api/variables/GET_OBJECT_WITH_JSON.html +1 -1
  133. package/docs/api/variables/GET_OWNED_OBJECTS_BY_PACKAGE.html +1 -1
  134. package/docs/api/variables/GET_OWNED_OBJECTS_BY_TYPE.html +1 -1
  135. package/docs/api/variables/GET_SINGLETON_OBJECT_BY_TYPE.html +1 -1
  136. package/docs/api/variables/NotificationContext.html +1 -1
  137. package/docs/api/variables/ONE_M3.html +1 -1
  138. package/docs/api/variables/POLLING_INTERVAL.html +1 -1
  139. package/docs/api/variables/STORAGE_KEYS.html +1 -1
  140. package/docs/api/variables/SmartObjectContext.html +1 -1
  141. package/docs/api/variables/VaultContext.html +1 -1
  142. package/docs/api/variables/dAppKit.html +1 -1
  143. package/graphql/client.ts +26 -3
  144. package/graphql/queries.ts +9 -0
  145. package/graphql/types.ts +10 -18
  146. package/hooks/useSmartObject.ts +2 -12
  147. package/hooks/useSponsoredTransaction.ts +60 -9
  148. package/package.json +1 -1
  149. package/providers/SmartObjectProvider.tsx +69 -42
  150. package/types/contexts.ts +0 -2
  151. package/utils/transforms.ts +11 -4
  152. package/vite-env.d.ts +2 -2
  153. package/wallet/features.ts +2 -2
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evefrontier/dapp-kit",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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
41
  character: null,
32
- selectedObjectId: "",
33
42
  loading: true,
34
43
  error: null,
35
- setSelectedObjectId: () => {},
36
44
  refetch: async () => {},
37
45
  });
38
46
 
@@ -56,6 +64,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
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/character 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,17 +90,22 @@ 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
103
  // Fetch both assembly and character data
87
- const { moveObject, character: characterInfo } =
88
- await getAssemblyWithOwner(objectId);
104
+ const {
105
+ moveObject,
106
+ character: characterInfo,
107
+ energySource,
108
+ } = await getAssemblyWithOwner(objectId);
89
109
 
90
110
  if (!moveObject) {
91
111
  console.warn(
@@ -101,6 +121,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
101
121
  const dataHash = JSON.stringify({
102
122
  moveObject,
103
123
  character: characterInfo,
124
+ energySource,
104
125
  });
105
126
 
106
127
  // Only update state if the data changed (optimization for polling)
@@ -132,6 +153,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
132
153
  {
133
154
  character: characterInfo,
134
155
  datahubInfo,
156
+ energySource: energySource,
135
157
  },
136
158
  );
137
159
 
@@ -158,39 +180,40 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
158
180
  [],
159
181
  );
160
182
 
161
- // Initialize the object ID from env or query params
183
+ // Initialize the object ID (env or query params) and tenant (query params).
184
+ // Tenant comes from URL ?tenant= with fallback DEFAULT_TENANT.
162
185
  useEffect(() => {
163
186
  console.log("[DappKit] SmartObjectProvider: Checking for item ID");
164
187
 
188
+ const queryParams = new URLSearchParams(window.location.search);
189
+ const queryTenant =
190
+ queryParams.get(QueryParams.TENANT)?.trim() || DEFAULT_TENANT;
191
+
165
192
  // Check if an object ID exists in the .env file
166
- const envItemId = import.meta.env.VITE_ITEM_ID;
193
+ const envObjectId = import.meta.env.VITE_OBJECT_ID;
167
194
 
168
- if (envItemId) {
195
+ if (envObjectId) {
169
196
  console.log(
170
- "[DappKit] SmartObjectProvider: Using item ID from env:",
171
- envItemId,
197
+ "[DappKit] SmartObjectProvider: Using Sui object ID from env:",
198
+ envObjectId,
172
199
  );
173
- setSelectedObjectId(envItemId);
200
+ setSelectedObjectId(envObjectId);
201
+ setSelectedTenant(queryTenant);
202
+ setIsObjectIdDirect(true);
174
203
  return;
175
204
  }
176
205
 
177
- // Check if an object ID has been passed via query param
178
- const queryParams = new URLSearchParams(window.location.search);
206
+ // Else, derive object ID from item ID and tenant and passed via query param
179
207
  const queryItemId = queryParams.get(QueryParams.ITEM_ID);
180
- const queryTenant = queryParams.get(QueryParams.TENANT);
181
208
 
182
209
  if (queryItemId) {
183
210
  setSelectedObjectId(queryItemId);
211
+ setSelectedTenant(queryTenant);
212
+ setIsObjectIdDirect(false);
184
213
  } else {
185
214
  console.error("[DappKit] SmartObjectProvider: No object ID provided");
186
215
  setLoading(false);
187
216
  }
188
-
189
- if (queryTenant) {
190
- setSelectedTenant(queryTenant);
191
- } else {
192
- console.error("[DappKit] SmartObjectProvider: No tenant provided");
193
- }
194
217
  }, []);
195
218
 
196
219
  // Fetch and poll for object data
@@ -202,12 +225,16 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
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
273
  character,
245
- selectedObjectId,
246
274
  loading,
247
275
  error,
248
- setSelectedObjectId: handleSetSelectedObjectId,
249
276
  refetch: handleRefetch,
250
277
  }}
251
278
  >
package/types/contexts.ts CHANGED
@@ -29,10 +29,8 @@ export enum SupportedWallets {
29
29
  export interface SmartObjectContextType {
30
30
  assembly: AssemblyType<Assemblies> | null;
31
31
  character: DetailedSmartCharacterResponse | null;
32
- selectedObjectId: string;
33
32
  loading: boolean;
34
33
  error: string | null;
35
- setSelectedObjectId: (id: string) => void;
36
34
  refetch: () => Promise<void>;
37
35
  }
38
36
 
@@ -41,6 +41,8 @@ export interface TransformOptions {
41
41
  character?: CharacterInfo | null;
42
42
  /** Pre-fetched datahub game info (name, description, image) */
43
43
  datahubInfo?: DatahubGameInfo | null;
44
+ /** Energy source information */
45
+ energySource?: RawSuiObjectData | null;
44
46
  }
45
47
 
46
48
  /**
@@ -86,6 +88,9 @@ export async function transformToAssembly(
86
88
 
87
89
  // Use pre-fetched datahub info for defaults
88
90
  const datahubInfo = options?.datahubInfo;
91
+ const energySource = options?.energySource;
92
+
93
+ const parentState = parseStatus(energySource?.status?.status?.["@variant"]);
89
94
 
90
95
  const baseAssembly = {
91
96
  id: rawData.id || objectId,
@@ -94,6 +99,7 @@ export async function transformToAssembly(
94
99
  name: rawData.metadata?.name || "",
95
100
  description: rawData.metadata?.description || "",
96
101
  dappURL: rawData.metadata?.url || "",
102
+ energySourceId: energySource?.id || rawData.energy_source_id || "", // Parent network node ID
97
103
  state,
98
104
  typeId: parseInt(typeId, 10) || 0,
99
105
  energyUsage: 0,
@@ -107,6 +113,7 @@ export async function transformToAssembly(
107
113
  character: options?.character || undefined,
108
114
  // Include raw data for debugging/extension
109
115
  _raw: moveObject,
116
+ _options: options,
110
117
  };
111
118
 
112
119
  // Add module-specific data based on assembly type
@@ -141,7 +148,7 @@ export async function transformToAssembly(
141
148
  items: inventoryItems,
142
149
  },
143
150
  ephemeralInventories: [],
144
- isParentNodeOnline: state === State.ONLINE,
151
+ isParentNodeOnline: parentState === State.ONLINE,
145
152
  },
146
153
  } as AssemblyType<Assemblies.SmartStorageUnit>;
147
154
 
@@ -149,7 +156,7 @@ export async function transformToAssembly(
149
156
  return {
150
157
  ...baseAssembly,
151
158
  turret: {
152
- isParentNodeOnline: state === State.ONLINE,
159
+ isParentNodeOnline: parentState === State.ONLINE,
153
160
  },
154
161
  } as AssemblyType<Assemblies.SmartTurret>;
155
162
 
@@ -158,9 +165,9 @@ export async function transformToAssembly(
158
165
  ...baseAssembly,
159
166
  gate: {
160
167
  linked: false,
161
- destinationId: undefined,
168
+ destinationId: rawData.linked_gate_id,
162
169
  inRange: [],
163
- isParentNodeOnline: state === State.ONLINE,
170
+ isParentNodeOnline: parentState === State.ONLINE,
164
171
  },
165
172
  } as AssemblyType<Assemblies.SmartGate>;
166
173
 
package/vite-env.d.ts CHANGED
@@ -5,8 +5,8 @@ interface ImportMetaEnv {
5
5
  readonly VITE_SUI_GRAPHQL_ENDPOINT: string;
6
6
  /** EVE World package ID on Sui (required) */
7
7
  readonly VITE_EVE_WORLD_PACKAGE_ID: string;
8
- /** Optional smart assembly item ID override */
9
- readonly VITE_ITEM_ID?: string;
8
+ /** Optional smart assembly Sui object ID override */
9
+ readonly VITE_OBJECT_ID?: string;
10
10
  }
11
11
 
12
12
  interface ImportMeta {
@@ -42,8 +42,6 @@ export interface SponsoredTransactionInput {
42
42
  assemblyType: SponsoredTransactionAssemblyType;
43
43
  /** The Sui chain to execute on (e.g., "sui:testnet", "sui:mainnet") */
44
44
  chain: `sui:${string}`;
45
- /** Additional properties */
46
- [key: string]: unknown;
47
45
  }
48
46
 
49
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. */
@@ -54,6 +52,8 @@ export type SponsoredTransactionArgs = Omit<
54
52
  assembly: AssemblyType<Assemblies>;
55
53
  account?: string;
56
54
  tenant?: string;
55
+ txAction: SponsoredTransactionActions;
56
+ chain: `sui:${string}`;
57
57
  };
58
58
 
59
59
  /**