@evefrontier/dapp-kit 0.1.2 → 0.1.5

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 (184) hide show
  1. package/README.md +13 -0
  2. package/graphql/client.ts +96 -24
  3. package/graphql/index.ts +5 -39
  4. package/graphql/queries.ts +157 -1
  5. package/graphql/types.ts +188 -155
  6. package/hooks/index.ts +1 -0
  7. package/hooks/useSponsoredTransaction.ts +11 -4
  8. package/index.ts +7 -71
  9. package/package.json +11 -1
  10. package/providers/SmartObjectProvider.tsx +17 -17
  11. package/types/contexts.ts +1 -1
  12. package/types/sponsoredTransaction.ts +9 -0
  13. package/types/types.ts +52 -10
  14. package/types/worldApiReturnTypes.ts +13 -37
  15. package/utils/__tests__/burnRate.test.ts +121 -0
  16. package/utils/__tests__/character.test.ts +112 -0
  17. package/utils/__tests__/characterOwnedObjects.test.ts +222 -0
  18. package/utils/__tests__/config.test.ts +424 -0
  19. package/utils/__tests__/mapping.test.ts +2 -2
  20. package/utils/burnRate.ts +46 -0
  21. package/utils/character.ts +46 -0
  22. package/utils/characterOwnedObjects.ts +52 -0
  23. package/utils/config.ts +151 -0
  24. package/utils/constants.ts +39 -5
  25. package/utils/datahub.ts +3 -41
  26. package/utils/errors.ts +1 -1
  27. package/utils/index.ts +10 -1
  28. package/utils/mapping.ts +5 -2
  29. package/utils/transforms.ts +27 -31
  30. package/wallet/features.ts +5 -5
  31. package/CHANGELOG.md +0 -13
  32. package/docs/api/.nojekyll +0 -1
  33. package/docs/api/assets/hierarchy.js +0 -1
  34. package/docs/api/assets/highlight.css +0 -120
  35. package/docs/api/assets/icons.js +0 -18
  36. package/docs/api/assets/icons.svg +0 -1
  37. package/docs/api/assets/main.js +0 -60
  38. package/docs/api/assets/navigation.js +0 -1
  39. package/docs/api/assets/search.js +0 -1
  40. package/docs/api/assets/style.css +0 -1633
  41. package/docs/api/classes/WalletNoAccountSelectedError.html +0 -3
  42. package/docs/api/classes/WalletNotConnectedError.html +0 -3
  43. package/docs/api/classes/WalletSponsoredTransactionNotSupportedError.html +0 -5
  44. package/docs/api/enums/ActionTypes.html +0 -6
  45. package/docs/api/enums/Assemblies.html +0 -7
  46. package/docs/api/enums/QueryParams.html +0 -3
  47. package/docs/api/enums/Severity.html +0 -5
  48. package/docs/api/enums/SponsoredTransactionActions.html +0 -7
  49. package/docs/api/enums/State.html +0 -6
  50. package/docs/api/enums/SupportedWallets.html +0 -3
  51. package/docs/api/enums/TYPEIDS.html +0 -15
  52. package/docs/api/functions/EveFrontierProvider.html +0 -11
  53. package/docs/api/functions/NotificationProvider.html +0 -2
  54. package/docs/api/functions/SmartObjectProvider.html +0 -10
  55. package/docs/api/functions/VaultProvider.html +0 -1
  56. package/docs/api/functions/abbreviateAddress.html +0 -11
  57. package/docs/api/functions/assertAssemblyType.html +0 -9
  58. package/docs/api/functions/clickToCopy.html +0 -1
  59. package/docs/api/functions/executeGraphQLQuery.html +0 -12
  60. package/docs/api/functions/findOwnerByAddress.html +0 -5
  61. package/docs/api/functions/formatDuration.html +0 -8
  62. package/docs/api/functions/formatM3.html +0 -8
  63. package/docs/api/functions/getAssemblyType.html +0 -4
  64. package/docs/api/functions/getAssemblyTypeApiString.html +0 -2
  65. package/docs/api/functions/getAssemblyWithOwner.html +0 -18
  66. package/docs/api/functions/getCharacterOwnerCapType.html +0 -3
  67. package/docs/api/functions/getCommonItems.html +0 -1
  68. package/docs/api/functions/getDappUrl.html +0 -7
  69. package/docs/api/functions/getDatahubGameInfo.html +0 -13
  70. package/docs/api/functions/getEnv.html +0 -1
  71. package/docs/api/functions/getEveWorldPackageId.html +0 -4
  72. package/docs/api/functions/getObjectByAddress.html +0 -9
  73. package/docs/api/functions/getObjectId.html +0 -4
  74. package/docs/api/functions/getObjectOwnerAndOwnedObjectsByType.html +0 -10
  75. package/docs/api/functions/getObjectRegistryType.html +0 -3
  76. package/docs/api/functions/getObjectWithDynamicFields.html +0 -10
  77. package/docs/api/functions/getObjectWithJson.html +0 -9
  78. package/docs/api/functions/getObjectsByType.html +0 -12
  79. package/docs/api/functions/getOwnedObjectsByPackage.html +0 -10
  80. package/docs/api/functions/getOwnedObjectsByType.html +0 -10
  81. package/docs/api/functions/getRegistryAddress.html +0 -3
  82. package/docs/api/functions/getSingletonObjectByType.html +0 -9
  83. package/docs/api/functions/getSponsoredTransactionFeature.html +0 -11
  84. package/docs/api/functions/getSuiGraphqlEndpoint.html +0 -4
  85. package/docs/api/functions/getTxUrl.html +0 -8
  86. package/docs/api/functions/getVolumeM3.html +0 -5
  87. package/docs/api/functions/hasSponsoredTransactionFeature.html +0 -3
  88. package/docs/api/functions/isOwner.html +0 -10
  89. package/docs/api/functions/parseErrorFromMessage.html +0 -1
  90. package/docs/api/functions/parseStatus.html +0 -2
  91. package/docs/api/functions/parseURL.html +0 -1
  92. package/docs/api/functions/removeTrailingZeros.html +0 -1
  93. package/docs/api/functions/transformToAssembly.html +0 -5
  94. package/docs/api/functions/transformToCharacter.html +0 -2
  95. package/docs/api/functions/useConnection.html +0 -21
  96. package/docs/api/functions/useNotification.html +0 -28
  97. package/docs/api/functions/useSmartObject.html +0 -21
  98. package/docs/api/functions/useSponsoredTransaction.html +0 -50
  99. package/docs/api/functions/walletSupportsSponsoredTransaction.html +0 -13
  100. package/docs/api/hierarchy.html +0 -1
  101. package/docs/api/index.html +0 -24
  102. package/docs/api/interfaces/AddressOwner.html +0 -2
  103. package/docs/api/interfaces/AddressOwnerWithJson.html +0 -2
  104. package/docs/api/interfaces/AssemblyProperties.html +0 -14
  105. package/docs/api/interfaces/CharacterInfo.html +0 -8
  106. package/docs/api/interfaces/DatahubGameInfo.html +0 -30
  107. package/docs/api/interfaces/DetailedAssemblyResponse.html +0 -14
  108. package/docs/api/interfaces/DetailedSmartCharacterResponse.html +0 -7
  109. package/docs/api/interfaces/DynamicFieldNode.html +0 -3
  110. package/docs/api/interfaces/EphemeralInventory.html +0 -6
  111. package/docs/api/interfaces/EveFrontierSponsoredTransactionFeature.html +0 -7
  112. package/docs/api/interfaces/GameTypeResponse.html +0 -13
  113. package/docs/api/interfaces/GateModule.html +0 -5
  114. package/docs/api/interfaces/GetObjectByAddressResponse.html +0 -2
  115. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsResponse.html +0 -2
  116. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsWithJsonResponse.html +0 -2
  117. package/docs/api/interfaces/GetObjectResponse.html +0 -2
  118. package/docs/api/interfaces/GetObjectWithJsonResponse.html +0 -2
  119. package/docs/api/interfaces/GetObjectsByTypeResponse.html +0 -2
  120. package/docs/api/interfaces/GetOwnedObjectsByPackageResponse.html +0 -2
  121. package/docs/api/interfaces/GetOwnedObjectsByTypeResponse.html +0 -2
  122. package/docs/api/interfaces/GetSingletonObjectByTypeResponse.html +0 -2
  123. package/docs/api/interfaces/GraphQLResponse.html +0 -3
  124. package/docs/api/interfaces/InventoryItem.html +0 -8
  125. package/docs/api/interfaces/ManufacturingModule.html +0 -2
  126. package/docs/api/interfaces/MoveObjectContents.html +0 -4
  127. package/docs/api/interfaces/MoveObjectData.html +0 -3
  128. package/docs/api/interfaces/NetworkNodeModule.html +0 -6
  129. package/docs/api/interfaces/NotificationContextType.html +0 -4
  130. package/docs/api/interfaces/NotificationState.html +0 -6
  131. package/docs/api/interfaces/Notify.html +0 -6
  132. package/docs/api/interfaces/ObjectWithContentsNode.html +0 -4
  133. package/docs/api/interfaces/OwnedObjectAddressNode.html +0 -2
  134. package/docs/api/interfaces/OwnedObjectFullNode.html +0 -4
  135. package/docs/api/interfaces/OwnedObjectNode.html +0 -3
  136. package/docs/api/interfaces/OwnedObjectNodeWithJson.html +0 -4
  137. package/docs/api/interfaces/OwnerCapData.html +0 -5
  138. package/docs/api/interfaces/PageInfo.html +0 -3
  139. package/docs/api/interfaces/RawCharacterData.html +0 -8
  140. package/docs/api/interfaces/RawSuiObjectData.html +0 -21
  141. package/docs/api/interfaces/RefineryModule.html +0 -2
  142. package/docs/api/interfaces/SmartAssemblyResponse.html +0 -11
  143. package/docs/api/interfaces/SmartObjectContextType.html +0 -7
  144. package/docs/api/interfaces/SponsoredTransactionInput.html +0 -14
  145. package/docs/api/interfaces/SponsoredTransactionOutput.html +0 -8
  146. package/docs/api/interfaces/StorageModule.html +0 -4
  147. package/docs/api/interfaces/SuiObjectResponse.html +0 -5
  148. package/docs/api/interfaces/TransformOptions.html +0 -8
  149. package/docs/api/interfaces/TurretModule.html +0 -2
  150. package/docs/api/interfaces/VaultContextType.html +0 -8
  151. package/docs/api/modules.html +0 -1
  152. package/docs/api/types/AssemblyType.html +0 -1
  153. package/docs/api/types/ErrorType.html +0 -5
  154. package/docs/api/types/SendSponsoredTransactionFn.html +0 -1
  155. package/docs/api/types/SponsoredTransactionArgs.html +0 -2
  156. package/docs/api/types/SponsoredTransactionAssemblyType.html +0 -2
  157. package/docs/api/types/SponsoredTransactionMethod.html +0 -2
  158. package/docs/api/types/UseSponsoredTransactionArgs.html +0 -3
  159. package/docs/api/types/UseSponsoredTransactionError.html +0 -2
  160. package/docs/api/types/UseSponsoredTransactionMutationOptions.html +0 -2
  161. package/docs/api/variables/ASSEMBLY_TYPE_API_STRING.html +0 -2
  162. package/docs/api/variables/ERRORS.html +0 -1
  163. package/docs/api/variables/ERROR_MESSAGES.html +0 -1
  164. package/docs/api/variables/EVEFRONTIER_SPONSORED_TRANSACTION.html +0 -4
  165. package/docs/api/variables/EXCLUDED_TYPEIDS.html +0 -1
  166. package/docs/api/variables/GET_OBJECTS_BY_TYPE.html +0 -3
  167. package/docs/api/variables/GET_OBJECT_BY_ADDRESS.html +0 -3
  168. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE.html +0 -4
  169. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON.html +0 -3
  170. package/docs/api/variables/GET_OBJECT_WITH_DYNAMIC_FIELDS.html +0 -4
  171. package/docs/api/variables/GET_OBJECT_WITH_JSON.html +0 -3
  172. package/docs/api/variables/GET_OWNED_OBJECTS_BY_PACKAGE.html +0 -3
  173. package/docs/api/variables/GET_OWNED_OBJECTS_BY_TYPE.html +0 -3
  174. package/docs/api/variables/GET_SINGLETON_OBJECT_BY_TYPE.html +0 -3
  175. package/docs/api/variables/NotificationContext.html +0 -1
  176. package/docs/api/variables/ONE_M3.html +0 -2
  177. package/docs/api/variables/POLLING_INTERVAL.html +0 -2
  178. package/docs/api/variables/STORAGE_KEYS.html +0 -2
  179. package/docs/api/variables/SmartObjectContext.html +0 -1
  180. package/docs/api/variables/VaultContext.html +0 -1
  181. package/docs/api/variables/dAppKit.html +0 -2
  182. package/tsconfig.json +0 -22
  183. package/typedoc.json +0 -38
  184. package/vite-env.d.ts +0 -14
@@ -38,7 +38,7 @@ export type FetchObjectDataInput =
38
38
  /** @category Providers */
39
39
  export const SmartObjectContext = createContext<SmartObjectContextType>({
40
40
  assembly: null,
41
- character: null,
41
+ assemblyOwner: null,
42
42
  loading: true,
43
43
  error: null,
44
44
  refetch: async () => {},
@@ -49,10 +49,10 @@ export const SmartObjectContext = createContext<SmartObjectContextType>({
49
49
  * It uses GraphQL queries to fetch objects on the Sui blockchain
50
50
  * from the EVE Frontier package, with optional polling for updates.
51
51
  *
52
- * 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:
53
53
  * 1. Fetches assembly data with dynamic fields
54
54
  * 2. Uses owner_cap_id to resolve the Character OwnerCap
55
- * 3. Fetches full character data from the Character ID
55
+ * 3. Fetches full assemblyOwner data from the Character ID
56
56
  *
57
57
  * @category Providers
58
58
  */
@@ -60,7 +60,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
60
60
  const [assembly, setAssembly] = useState<AssemblyType<Assemblies> | null>(
61
61
  null,
62
62
  );
63
- const [character, setCharacter] =
63
+ const [assemblyOwner, setAssemblyOwner] =
64
64
  useState<DetailedSmartCharacterResponse | null>(null);
65
65
  const [selectedObjectId, setSelectedObjectId] = useState<string>("");
66
66
  const [selectedTenant, setSelectedTenant] = useState<string>("");
@@ -73,7 +73,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
73
73
 
74
74
  const { isConnected } = useConnection();
75
75
 
76
- // Fetch object data with owner/character info.
76
+ // Fetch object data with owner/assemblyOwner info.
77
77
  // Accepts either { itemId, selectedTenant } (derive Sui object ID) or { objectId } (use directly).
78
78
  const fetchObjectData = useCallback(
79
79
  async (input: FetchObjectDataInput, isInitialFetch = false) => {
@@ -100,11 +100,12 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
100
100
  : { objectId },
101
101
  );
102
102
 
103
- // Fetch both assembly and character data
103
+ // Fetch both assembly and assemblyOwner data
104
104
  const {
105
105
  moveObject,
106
- character: characterInfo,
106
+ assemblyOwner: characterInfo,
107
107
  energySource,
108
+ destinationGate,
108
109
  } = await getAssemblyWithOwner(objectId);
109
110
 
110
111
  if (!moveObject) {
@@ -112,7 +113,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
112
113
  "[DappKit] SmartObjectProvider: Object not found or not a Move object",
113
114
  );
114
115
  setAssembly(null);
115
- setCharacter(null);
116
+ setAssemblyOwner(null);
116
117
  setError("Object not found or not a Move object");
117
118
  return;
118
119
  }
@@ -120,7 +121,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
120
121
  // Create a hash of the data to check for changes
121
122
  const dataHash = JSON.stringify({
122
123
  moveObject,
123
- character: characterInfo,
124
+ assemblyOwner: characterInfo,
124
125
  energySource,
125
126
  });
126
127
 
@@ -146,7 +147,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
146
147
  );
147
148
  }
148
149
 
149
- // Transform assembly with character and datahub info
150
+ // Transform assembly with assemblyOwner and datahub info
150
151
  const transformed = await transformToAssembly(
151
152
  objectId,
152
153
  moveObject as MoveObjectData,
@@ -154,17 +155,18 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
154
155
  character: characterInfo,
155
156
  datahubInfo,
156
157
  energySource: energySource,
158
+ destinationGate: destinationGate,
157
159
  },
158
160
  );
159
161
 
160
162
  setAssembly(transformed);
161
163
 
162
- // Transform and set character
164
+ // Transform and set assemblyOwner: owner of the assembly
163
165
  if (characterInfo) {
164
166
  const transformedCharacter = transformToCharacter(characterInfo);
165
- setCharacter(transformedCharacter);
167
+ setAssemblyOwner(transformedCharacter);
166
168
  } else {
167
- setCharacter(null);
169
+ setAssemblyOwner(null);
168
170
  }
169
171
  }
170
172
  setError(null);
@@ -219,9 +221,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
219
221
  // Fetch and poll for object data
220
222
  useEffect(() => {
221
223
  if (!selectedObjectId || !isConnected) {
222
- if (!selectedObjectId) {
223
- setLoading(false);
224
- }
224
+ setLoading(false);
225
225
  return;
226
226
  }
227
227
 
@@ -270,7 +270,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
270
270
  <SmartObjectContext.Provider
271
271
  value={{
272
272
  assembly,
273
- character,
273
+ assemblyOwner,
274
274
  loading,
275
275
  error,
276
276
  refetch: handleRefetch,
package/types/contexts.ts CHANGED
@@ -28,7 +28,7 @@ export enum SupportedWallets {
28
28
  * @category Types */
29
29
  export interface SmartObjectContextType {
30
30
  assembly: AssemblyType<Assemblies> | null;
31
- character: DetailedSmartCharacterResponse | null;
31
+ assemblyOwner: DetailedSmartCharacterResponse | null;
32
32
  loading: boolean;
33
33
  error: string | null;
34
34
  refetch: () => Promise<void>;
@@ -12,7 +12,9 @@ import { Assemblies } from "./types";
12
12
  export enum SponsoredTransactionActions {
13
13
  BRING_ONLINE = "online",
14
14
  BRING_OFFLINE = "offline",
15
+ /** @deprecated Use UPDATE_METADATA instead */
15
16
  EDIT_UNIT = "edit-unit",
17
+ UPDATE_METADATA = "update-metadata",
16
18
  LINK_SMART_GATE = "link-smart-gate",
17
19
  UNLINK_SMART_GATE = "unlink-smart-gate",
18
20
  }
@@ -54,8 +56,15 @@ export const ASSEMBLY_TYPE_API_STRING: Record<Assemblies, string> = {
54
56
  [Assemblies.NetworkNode]: "network-nodes",
55
57
  [Assemblies.Manufacturing]: "manufacturing",
56
58
  [Assemblies.Refinery]: "refineries",
59
+ [Assemblies.Assembly]: "assemblies",
57
60
  } as const;
58
61
 
59
62
  /** API slug for assembly type in sponsored transaction payloads (e.g. "storage-units"). */
60
63
  export type SponsoredTransactionAssemblyType =
61
64
  (typeof ASSEMBLY_TYPE_API_STRING)[Assemblies];
65
+
66
+ export interface SponsoredTransactionMetadata {
67
+ name?: string;
68
+ description?: string;
69
+ url?: string;
70
+ }
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
+ }
@@ -1,4 +1,6 @@
1
- import { State, AssemblyType, Assemblies } from "./types";
1
+ import { MoveObjectData, RawSuiObjectData } from "../graphql/types";
2
+ import { TransformOptions } from "../utils";
3
+ import { State, Assemblies, type DatahubGameInfo } from "./types";
2
4
 
3
5
  // =========================================
4
6
  // Inventory Related Types
@@ -36,30 +38,21 @@ export interface StorageModule {
36
38
  items: InventoryItem[];
37
39
  };
38
40
  ephemeralInventories: EphemeralInventory[];
39
- isParentNodeOnline: boolean;
40
41
  }
41
42
 
42
43
  /** @category Types */
43
- export interface TurretModule {
44
- isParentNodeOnline: boolean;
45
- }
44
+ export interface TurretModule {}
46
45
 
47
46
  /** @category Types */
48
- export interface ManufacturingModule {
49
- isParentNodeOnline: boolean;
50
- }
47
+ export interface ManufacturingModule {}
51
48
 
52
49
  /** @category Types */
53
- export interface RefineryModule {
54
- isParentNodeOnline: boolean;
55
- }
50
+ export interface RefineryModule {}
56
51
 
57
52
  /** @category Types */
58
53
  export interface GateModule {
59
- linked: boolean;
60
54
  destinationId: string | undefined;
61
- inRange: AssemblyType<Assemblies.SmartGate>[];
62
- isParentNodeOnline: boolean;
55
+ destinationGate: RawSuiObjectData | null;
63
56
  }
64
57
 
65
58
  /** @category Types */
@@ -78,7 +71,7 @@ export interface NetworkNodeModule {
78
71
  /** @category Types @internal */
79
72
  export interface FuelResponse {
80
73
  quantity: number;
81
- burnRateInMs: number;
74
+ burnTimeInMs: number;
82
75
  burnStartTime: number;
83
76
  isBurning: boolean;
84
77
  lastUpdated: number;
@@ -131,38 +124,21 @@ export interface SmartAssemblyResponse {
131
124
  id: string;
132
125
  item_id: number;
133
126
  type: Assemblies;
134
- typeDetails?: GameTypeResponse;
127
+ typeDetails?: DatahubGameInfo;
135
128
  name: string;
136
129
  state: State;
137
130
  character?: SmartCharacterResponse;
138
131
  solarSystem?: SolarSystem;
132
+ isParentNodeOnline?: boolean;
133
+ energySourceId?: string;
139
134
  energyUsage: number;
140
135
  typeId: number;
136
+ _raw?: MoveObjectData;
137
+ _options?: TransformOptions;
141
138
  }
142
139
 
143
140
  /** @category Types */
144
141
  export interface DetailedAssemblyResponse extends SmartAssemblyResponse {
145
- location: {
146
- x: number;
147
- y: number;
148
- z: number;
149
- };
150
142
  description: string;
151
143
  dappURL: string;
152
144
  }
153
-
154
- /** @category Types */
155
- export interface GameTypeResponse {
156
- categoryId: number;
157
- categoryName: string;
158
- description: string;
159
- groupId: number;
160
- groupName: string;
161
- iconUrl: string;
162
- id: number;
163
- mass: number;
164
- name: string;
165
- portionSize: number;
166
- radius: number;
167
- volume: number;
168
- }
@@ -0,0 +1,121 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { getAdjustedBurnRate } from "../burnRate";
3
+
4
+ describe("getAdjustedBurnRate", () => {
5
+ const MS_PER_HOUR = 3600000;
6
+
7
+ it("returns ~1.11 units/hour when raw is 1h and efficiency is 90%", () => {
8
+ const raw = MS_PER_HOUR;
9
+ const result = getAdjustedBurnRate(raw, 90);
10
+ expect(result.burnTimePerUnitMs).toBe(3240000); // 3600000 * 0.9
11
+ expect(result.unitsPerHour).toBeCloseTo(1.111111, 4);
12
+ });
13
+
14
+ it("returns burnTimePerUnitMs = raw and 1 unit/hour when efficiency is 100% and raw is 1h", () => {
15
+ const raw = MS_PER_HOUR;
16
+ const result = getAdjustedBurnRate(raw, 100);
17
+ expect(result.burnTimePerUnitMs).toBe(raw);
18
+ expect(result.unitsPerHour).toBe(1);
19
+ });
20
+
21
+ it("returns 2.5 units/hour when raw is 1h and efficiency is 40%", () => {
22
+ const raw = MS_PER_HOUR;
23
+ const result = getAdjustedBurnRate(raw, 40);
24
+ expect(result.burnTimePerUnitMs).toBe(1440000); // 3600000 * 0.4
25
+ expect(result.unitsPerHour).toBe(2.5);
26
+ });
27
+
28
+ it("returns 1.25 units/hour when raw is 1h and efficiency is 80%", () => {
29
+ const raw = MS_PER_HOUR;
30
+ const result = getAdjustedBurnRate(raw, 80);
31
+ expect(result.burnTimePerUnitMs).toBe(2880000); // 3600000 * 0.8
32
+ expect(result.unitsPerHour).toBe(1.25);
33
+ });
34
+
35
+ it("returns ~6.67 units/hour when raw is 1h and efficiency is 15%", () => {
36
+ const raw = MS_PER_HOUR;
37
+ const result = getAdjustedBurnRate(raw, 15);
38
+ expect(result.burnTimePerUnitMs).toBe(540000); // 3600000 * 0.15
39
+ expect(result.unitsPerHour).toBeCloseTo(6.666667, 4);
40
+ });
41
+
42
+ it("returns 10 units/hour when raw is 1h and efficiency is 10%", () => {
43
+ const raw = MS_PER_HOUR;
44
+ const result = getAdjustedBurnRate(raw, 10);
45
+ expect(result.burnTimePerUnitMs).toBe(360000); // 3600000 * 0.1
46
+ expect(result.unitsPerHour).toBe(10);
47
+ });
48
+
49
+ it("uses raw as burn time and derives unitsPerHour when efficiency is null", () => {
50
+ const raw = MS_PER_HOUR;
51
+ const result = getAdjustedBurnRate(raw, null);
52
+ expect(result.burnTimePerUnitMs).toBe(raw);
53
+ expect(result.unitsPerHour).toBe(1);
54
+ });
55
+
56
+ it("uses raw as burn time when efficiency is undefined", () => {
57
+ const raw = 1800000;
58
+ const result = getAdjustedBurnRate(raw, undefined);
59
+ expect(result.burnTimePerUnitMs).toBe(raw);
60
+ expect(result.unitsPerHour).toBe(2);
61
+ });
62
+
63
+ it("uses raw as burn time when efficiency is 0", () => {
64
+ const raw = MS_PER_HOUR;
65
+ const result = getAdjustedBurnRate(raw, 0);
66
+ expect(result.burnTimePerUnitMs).toBe(raw);
67
+ expect(result.unitsPerHour).toBe(1);
68
+ });
69
+
70
+ it("returns unitsPerHour 0 when raw is 0", () => {
71
+ const result = getAdjustedBurnRate(0, 90);
72
+ expect(result.burnTimePerUnitMs).toBe(0);
73
+ expect(result.unitsPerHour).toBe(0);
74
+ });
75
+
76
+ it("normalizes invalid raw (NaN) to 0 and returns (0, 0)", () => {
77
+ const result = getAdjustedBurnRate(Number.NaN, 90);
78
+ expect(result.burnTimePerUnitMs).toBe(0);
79
+ expect(result.unitsPerHour).toBe(0);
80
+ });
81
+
82
+ it("normalizes invalid raw (Infinity) to 0 and returns (0, 0)", () => {
83
+ const result = getAdjustedBurnRate(Number.POSITIVE_INFINITY, 90);
84
+ expect(result.burnTimePerUnitMs).toBe(0);
85
+ expect(result.unitsPerHour).toBe(0);
86
+ });
87
+
88
+ it("normalizes invalid raw (negative) to 0 and returns (0, 0)", () => {
89
+ const result = getAdjustedBurnRate(-1000, 90);
90
+ expect(result.burnTimePerUnitMs).toBe(0);
91
+ expect(result.unitsPerHour).toBe(0);
92
+ });
93
+
94
+ it("handles negative efficiency by using raw (fallback)", () => {
95
+ const raw = MS_PER_HOUR;
96
+ const result = getAdjustedBurnRate(raw, -10);
97
+ expect(result.burnTimePerUnitMs).toBe(raw);
98
+ expect(result.unitsPerHour).toBe(1);
99
+ });
100
+
101
+ it("handles NaN efficiency by using raw", () => {
102
+ const raw = MS_PER_HOUR;
103
+ const result = getAdjustedBurnRate(raw, Number.NaN);
104
+ expect(result.burnTimePerUnitMs).toBe(raw);
105
+ expect(result.unitsPerHour).toBe(1);
106
+ });
107
+
108
+ it("treats efficiency > 100 as invalid and uses raw (fallback)", () => {
109
+ const raw = MS_PER_HOUR;
110
+ const result = getAdjustedBurnRate(raw, 250);
111
+ expect(result.burnTimePerUnitMs).toBe(raw);
112
+ expect(result.unitsPerHour).toBe(1);
113
+ });
114
+
115
+ it("computes correct unitsPerHour for 10 units/hour (6 min per unit)", () => {
116
+ const sixMinutesMs = 6 * 60 * 1000;
117
+ const result = getAdjustedBurnRate(sixMinutesMs, 100);
118
+ expect(result.burnTimePerUnitMs).toBe(sixMinutesMs);
119
+ expect(result.unitsPerHour).toBe(10);
120
+ });
121
+ });
@@ -0,0 +1,112 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { parseCharacterFromJson } from "../character";
3
+
4
+ describe("parseCharacterFromJson", () => {
5
+ const validCharacterJson = {
6
+ id: "0x65916b0c872aa5e29b0e9ec66a29fa18cd5f85b188d48914d4437d42abc4f800",
7
+ character_address: "0x82da5c79037b5cb544ed89725f61a577d17c55a14941ea992a8d18cc476893d7",
8
+ tribe_id: 17,
9
+ key: { item_id: "12345", tenant: "default" },
10
+ metadata: {
11
+ name: "Test Character",
12
+ description: "",
13
+ url: "",
14
+ assembly_id: "0xassembly",
15
+ },
16
+ };
17
+
18
+ it("returns null when json is null", () => {
19
+ expect(parseCharacterFromJson(null)).toBeNull();
20
+ });
21
+
22
+ it("returns null when json is undefined", () => {
23
+ expect(parseCharacterFromJson(undefined)).toBeNull();
24
+ });
25
+
26
+ it("returns null when json is a string", () => {
27
+ expect(parseCharacterFromJson("not an object")).toBeNull();
28
+ });
29
+
30
+ it("returns null when json is an array", () => {
31
+ expect(parseCharacterFromJson([])).toBeNull();
32
+ });
33
+
34
+ it("returns CharacterInfo with all fields when given valid object", () => {
35
+ const result = parseCharacterFromJson(validCharacterJson);
36
+ expect(result).not.toBeNull();
37
+ expect(result!.id).toBe(validCharacterJson.id);
38
+ expect(result!.address).toBe(validCharacterJson.character_address);
39
+ expect(result!.name).toBe(validCharacterJson.metadata.name);
40
+ expect(result!.tribeId).toBe(17);
41
+ expect(result!.characterId).toBe(12345);
42
+ expect(result!._raw).toBe(validCharacterJson);
43
+ });
44
+
45
+ it("parses tribe_id when it is a string", () => {
46
+ const result = parseCharacterFromJson({
47
+ ...validCharacterJson,
48
+ tribe_id: "42",
49
+ });
50
+ expect(result).not.toBeNull();
51
+ expect(result!.tribeId).toBe(42);
52
+ });
53
+
54
+ it("parses key.item_id when it is a string", () => {
55
+ const result = parseCharacterFromJson({
56
+ ...validCharacterJson,
57
+ key: { item_id: "999", tenant: "x" },
58
+ });
59
+ expect(result).not.toBeNull();
60
+ expect(result!.characterId).toBe(999);
61
+ });
62
+
63
+ it("returns 0 for tribeId when tribe_id is missing", () => {
64
+ const { tribe_id: _, ...withoutTribe } = validCharacterJson;
65
+ const result = parseCharacterFromJson(withoutTribe);
66
+ expect(result).not.toBeNull();
67
+ expect(result!.tribeId).toBe(0);
68
+ });
69
+
70
+ it("returns 0 for characterId when key is missing", () => {
71
+ const { key: _, ...withoutKey } = validCharacterJson;
72
+ const result = parseCharacterFromJson(withoutKey);
73
+ expect(result).not.toBeNull();
74
+ expect(result!.characterId).toBe(0);
75
+ });
76
+
77
+ it("returns empty string for name when metadata is not an object", () => {
78
+ const result = parseCharacterFromJson({
79
+ ...validCharacterJson,
80
+ metadata: "invalid",
81
+ });
82
+ expect(result).not.toBeNull();
83
+ expect(result!.name).toBe("");
84
+ });
85
+
86
+ it("returns empty string for name when metadata.name is missing", () => {
87
+ const result = parseCharacterFromJson({
88
+ ...validCharacterJson,
89
+ metadata: { description: "", url: "", assembly_id: "0x" },
90
+ });
91
+ expect(result).not.toBeNull();
92
+ expect(result!.name).toBe("");
93
+ });
94
+
95
+ it("returns empty strings for id and address when missing or wrong type", () => {
96
+ const result = parseCharacterFromJson({
97
+ tribe_id: 0,
98
+ key: {},
99
+ metadata: {},
100
+ });
101
+ expect(result).not.toBeNull();
102
+ expect(result!.id).toBe("");
103
+ expect(result!.address).toBe("");
104
+ expect(result!.name).toBe("");
105
+ });
106
+
107
+ it("stores original json as _raw", () => {
108
+ const input = { ...validCharacterJson };
109
+ const result = parseCharacterFromJson(input);
110
+ expect(result!._raw).toBe(input);
111
+ });
112
+ });