@evefrontier/dapp-kit 0.1.0 → 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 (169) hide show
  1. package/CHANGELOG.md +13 -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 +2 -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 +3 -0
  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 +2 -2
  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/getAssemblyType.html +2 -2
  29. package/docs/api/functions/getAssemblyTypeApiString.html +2 -2
  30. package/docs/api/functions/getAssemblyWithOwner.html +3 -3
  31. package/docs/api/functions/getCharacterOwnerCapType.html +2 -2
  32. package/docs/api/functions/getCommonItems.html +1 -1
  33. package/docs/api/functions/getDappUrl.html +2 -2
  34. package/docs/api/functions/getDatahubGameInfo.html +2 -2
  35. package/docs/api/functions/getEnv.html +1 -1
  36. package/docs/api/functions/getEveWorldPackageId.html +2 -2
  37. package/docs/api/functions/getObjectByAddress.html +2 -2
  38. package/docs/api/functions/getObjectId.html +2 -2
  39. package/docs/api/functions/getObjectOwnerAndOwnedObjectsByType.html +2 -2
  40. package/docs/api/functions/getObjectRegistryType.html +2 -2
  41. package/docs/api/functions/getObjectWithDynamicFields.html +2 -2
  42. package/docs/api/functions/getObjectWithJson.html +2 -2
  43. package/docs/api/functions/getObjectsByType.html +2 -2
  44. package/docs/api/functions/getOwnedObjectsByPackage.html +2 -2
  45. package/docs/api/functions/getOwnedObjectsByType.html +2 -2
  46. package/docs/api/functions/getRegistryAddress.html +2 -2
  47. package/docs/api/functions/getSingletonObjectByType.html +2 -2
  48. package/docs/api/functions/getSponsoredTransactionFeature.html +2 -2
  49. package/docs/api/functions/getSuiGraphqlEndpoint.html +2 -2
  50. package/docs/api/functions/getTxUrl.html +2 -2
  51. package/docs/api/functions/getVolumeM3.html +2 -2
  52. package/docs/api/functions/hasSponsoredTransactionFeature.html +2 -2
  53. package/docs/api/functions/isOwner.html +2 -2
  54. package/docs/api/functions/parseErrorFromMessage.html +1 -1
  55. package/docs/api/functions/parseStatus.html +2 -2
  56. package/docs/api/functions/parseURL.html +1 -1
  57. package/docs/api/functions/removeTrailingZeros.html +1 -1
  58. package/docs/api/functions/transformToAssembly.html +2 -2
  59. package/docs/api/functions/transformToCharacter.html +2 -2
  60. package/docs/api/functions/useConnection.html +2 -2
  61. package/docs/api/functions/useNotification.html +2 -2
  62. package/docs/api/functions/useSmartObject.html +4 -9
  63. package/docs/api/functions/useSponsoredTransaction.html +9 -9
  64. package/docs/api/functions/walletSupportsSponsoredTransaction.html +2 -2
  65. package/docs/api/hierarchy.html +1 -1
  66. package/docs/api/index.html +3 -5
  67. package/docs/api/interfaces/AddressOwner.html +2 -2
  68. package/docs/api/interfaces/AddressOwnerWithJson.html +2 -2
  69. package/docs/api/interfaces/AssemblyProperties.html +2 -2
  70. package/docs/api/interfaces/CharacterInfo.html +3 -3
  71. package/docs/api/interfaces/DatahubGameInfo.html +15 -15
  72. package/docs/api/interfaces/DetailedAssemblyResponse.html +2 -2
  73. package/docs/api/interfaces/DetailedSmartCharacterResponse.html +2 -2
  74. package/docs/api/interfaces/DynamicFieldNode.html +2 -2
  75. package/docs/api/interfaces/EphemeralInventory.html +2 -2
  76. package/docs/api/interfaces/EveFrontierSponsoredTransactionFeature.html +3 -3
  77. package/docs/api/interfaces/GameTypeResponse.html +2 -2
  78. package/docs/api/interfaces/GateModule.html +2 -2
  79. package/docs/api/interfaces/GetObjectByAddressResponse.html +2 -2
  80. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsResponse.html +2 -2
  81. package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsWithJsonResponse.html +2 -2
  82. package/docs/api/interfaces/GetObjectResponse.html +2 -2
  83. package/docs/api/interfaces/GetObjectWithJsonResponse.html +2 -2
  84. package/docs/api/interfaces/GetObjectsByTypeResponse.html +2 -2
  85. package/docs/api/interfaces/GetOwnedObjectsByPackageResponse.html +2 -2
  86. package/docs/api/interfaces/GetOwnedObjectsByTypeResponse.html +2 -2
  87. package/docs/api/interfaces/GetSingletonObjectByTypeResponse.html +2 -2
  88. package/docs/api/interfaces/GraphQLResponse.html +2 -2
  89. package/docs/api/interfaces/InventoryItem.html +2 -2
  90. package/docs/api/interfaces/ManufacturingModule.html +2 -2
  91. package/docs/api/interfaces/MoveObjectContents.html +2 -2
  92. package/docs/api/interfaces/MoveObjectData.html +2 -2
  93. package/docs/api/interfaces/NetworkNodeModule.html +2 -3
  94. package/docs/api/interfaces/NotificationContextType.html +2 -2
  95. package/docs/api/interfaces/NotificationState.html +2 -2
  96. package/docs/api/interfaces/Notify.html +2 -2
  97. package/docs/api/interfaces/ObjectWithContentsNode.html +2 -2
  98. package/docs/api/interfaces/OwnedObjectAddressNode.html +2 -2
  99. package/docs/api/interfaces/OwnedObjectFullNode.html +2 -2
  100. package/docs/api/interfaces/OwnedObjectNode.html +2 -2
  101. package/docs/api/interfaces/OwnedObjectNodeWithJson.html +2 -2
  102. package/docs/api/interfaces/OwnerCapData.html +3 -3
  103. package/docs/api/interfaces/PageInfo.html +2 -2
  104. package/docs/api/interfaces/RawCharacterData.html +3 -3
  105. package/docs/api/interfaces/RawSuiObjectData.html +10 -6
  106. package/docs/api/interfaces/RefineryModule.html +2 -2
  107. package/docs/api/interfaces/SmartAssemblyResponse.html +2 -2
  108. package/docs/api/interfaces/SmartObjectContextType.html +3 -4
  109. package/docs/api/interfaces/SponsoredTransactionInput.html +7 -8
  110. package/docs/api/interfaces/SponsoredTransactionOutput.html +5 -5
  111. package/docs/api/interfaces/StorageModule.html +2 -2
  112. package/docs/api/interfaces/SuiObjectResponse.html +2 -2
  113. package/docs/api/interfaces/TransformOptions.html +6 -4
  114. package/docs/api/interfaces/TurretModule.html +2 -2
  115. package/docs/api/interfaces/VaultContextType.html +3 -2
  116. package/docs/api/modules.html +1 -1
  117. package/docs/api/types/AssemblyType.html +1 -1
  118. package/docs/api/types/ErrorType.html +2 -2
  119. package/docs/api/types/SendSponsoredTransactionFn.html +1 -1
  120. package/docs/api/types/SponsoredTransactionArgs.html +2 -2
  121. package/docs/api/types/SponsoredTransactionAssemblyType.html +2 -2
  122. package/docs/api/types/SponsoredTransactionMethod.html +2 -2
  123. package/docs/api/types/UseSponsoredTransactionArgs.html +2 -2
  124. package/docs/api/types/UseSponsoredTransactionError.html +2 -2
  125. package/docs/api/types/UseSponsoredTransactionMutationOptions.html +2 -2
  126. package/docs/api/variables/ASSEMBLY_TYPE_API_STRING.html +2 -0
  127. package/docs/api/variables/ERRORS.html +1 -1
  128. package/docs/api/variables/ERROR_MESSAGES.html +1 -1
  129. package/docs/api/variables/EVEFRONTIER_SPONSORED_TRANSACTION.html +2 -2
  130. package/docs/api/variables/EXCLUDED_TYPEIDS.html +1 -1
  131. package/docs/api/variables/GET_OBJECTS_BY_TYPE.html +2 -2
  132. package/docs/api/variables/GET_OBJECT_BY_ADDRESS.html +2 -2
  133. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE.html +2 -2
  134. package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON.html +2 -2
  135. package/docs/api/variables/GET_OBJECT_WITH_DYNAMIC_FIELDS.html +2 -2
  136. package/docs/api/variables/GET_OBJECT_WITH_JSON.html +2 -2
  137. package/docs/api/variables/GET_OWNED_OBJECTS_BY_PACKAGE.html +2 -2
  138. package/docs/api/variables/GET_OWNED_OBJECTS_BY_TYPE.html +2 -2
  139. package/docs/api/variables/GET_SINGLETON_OBJECT_BY_TYPE.html +2 -2
  140. package/docs/api/variables/NotificationContext.html +1 -1
  141. package/docs/api/variables/ONE_M3.html +2 -2
  142. package/docs/api/variables/POLLING_INTERVAL.html +2 -2
  143. package/docs/api/variables/STORAGE_KEYS.html +2 -2
  144. package/docs/api/variables/SmartObjectContext.html +1 -1
  145. package/docs/api/variables/VaultContext.html +1 -1
  146. package/docs/api/variables/dAppKit.html +2 -2
  147. package/graphql/client.ts +26 -3
  148. package/graphql/queries.ts +9 -0
  149. package/graphql/types.ts +10 -18
  150. package/hooks/useConnection.ts +2 -1
  151. package/hooks/useNotification.ts +5 -3
  152. package/hooks/useSmartObject.ts +4 -16
  153. package/hooks/useSponsoredTransaction.ts +85 -16
  154. package/index.ts +0 -10
  155. package/package.json +1 -1
  156. package/providers/NotificationProvider.tsx +1 -20
  157. package/providers/SmartObjectProvider.tsx +69 -67
  158. package/providers/VaultProvider.tsx +6 -14
  159. package/providers/index.ts +1 -8
  160. package/types/contexts.ts +55 -0
  161. package/types/index.ts +1 -1
  162. package/types/sponsoredTransaction.ts +35 -0
  163. package/types/worldApiReturnTypes.ts +6 -4
  164. package/utils/transforms.ts +18 -12
  165. package/utils/utils.ts +1 -1
  166. package/vite-env.d.ts +2 -4
  167. package/wallet/features.ts +9 -38
  168. package/wallet/index.ts +0 -2
  169. package/wallet/utils.ts +1 -1
@@ -65,7 +65,6 @@ export interface GateModule {
65
65
  /** @category Types */
66
66
  export interface NetworkNodeModule {
67
67
  fuel: FuelResponse;
68
- burn: BurnResponse;
69
68
  energyProduction: number;
70
69
  energyMaxCapacity: number;
71
70
  totalReservedEnergy: number;
@@ -78,9 +77,13 @@ export interface NetworkNodeModule {
78
77
 
79
78
  /** @category Types @internal */
80
79
  export interface FuelResponse {
81
- amount: number;
80
+ quantity: number;
82
81
  burnRateInMs: number;
83
- efficiency: number;
82
+ burnStartTime: number;
83
+ isBurning: boolean;
84
+ lastUpdated: number;
85
+ maxCapacity: number;
86
+ previousCycleElapsedTime: number;
84
87
  unitVolume: number;
85
88
  typeId: number;
86
89
  }
@@ -89,7 +92,6 @@ export interface FuelResponse {
89
92
  export interface BurnResponse {
90
93
  isBurning: boolean;
91
94
  startTime: string;
92
- previousCycleElapsedTimeInSec: number;
93
95
  }
94
96
 
95
97
  // =========================================
@@ -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
 
@@ -194,19 +201,18 @@ export async function transformToAssembly(
194
201
  ...baseAssembly,
195
202
  networkNode: {
196
203
  fuel: {
197
- amount: parseInt(rawData.fuel?.quantity || "0", 10),
198
204
  burnRateInMs: parseInt(rawData.fuel?.burn_rate_in_ms || "0", 10),
199
- efficiency: 0,
200
- unitVolume: parseInt(rawData.fuel?.unit_volume || "0", 10),
201
- typeId: parseInt(rawData.fuel?.type_id || "0", 10),
202
- },
203
- burn: {
205
+ burnStartTime: parseInt(rawData.fuel?.burn_start_time || "0", 10),
204
206
  isBurning: rawData.fuel?.is_burning || false,
205
- startTime: rawData.fuel?.burn_start_time || "",
206
- previousCycleElapsedTimeInSec: parseInt(
207
+ lastUpdated: parseInt(rawData.fuel?.last_updated || "0", 10),
208
+ maxCapacity: parseInt(rawData.fuel?.max_capacity || "0", 10),
209
+ previousCycleElapsedTime: parseInt(
207
210
  rawData.fuel?.previous_cycle_elapsed_time || "0",
208
211
  10,
209
212
  ),
213
+ quantity: parseInt(rawData.fuel?.quantity || "0", 10),
214
+ typeId: parseInt(rawData.fuel?.type_id || "0", 10),
215
+ unitVolume: parseInt(rawData.fuel?.unit_volume || "0", 10),
210
216
  },
211
217
  energyProduction: parseInt(
212
218
  rawData.energy_source?.current_energy_production || "0",
package/utils/utils.ts CHANGED
@@ -256,7 +256,7 @@ export const formatDuration = (seconds: number): string => {
256
256
  const formattedDays = String(days).padStart(2, "0");
257
257
  const formattedHours = String(hours).padStart(2, "0");
258
258
  const formattedMinutes = String(minutes).padStart(2, "0");
259
- const formattedSeconds = String(remainingSeconds).padStart(2, "0");
259
+ const formattedSeconds = String(remainingSeconds.toFixed(0)).padStart(2, "0");
260
260
 
261
261
  if (days > 0) {
262
262
  return `${formattedDays}d ${formattedHours}h ${formattedMinutes}m ${formattedSeconds}s`;
package/vite-env.d.ts CHANGED
@@ -5,10 +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;
10
- /** Tenant identifier (required when VITE_ITEM_ID is set) */
11
- readonly VITE_EVE_WORLD_TENANT?: string;
8
+ /** Optional smart assembly Sui object ID override */
9
+ readonly VITE_OBJECT_ID?: string;
12
10
  }
13
11
 
14
12
  interface ImportMeta {
@@ -7,44 +7,13 @@
7
7
 
8
8
  import {
9
9
  Assemblies,
10
+ ASSEMBLY_TYPE_API_STRING,
10
11
  AssemblyType,
12
+ EVEFRONTIER_SPONSORED_TRANSACTION,
11
13
  SponsoredTransactionActions,
14
+ SponsoredTransactionAssemblyType,
12
15
  } from "../types";
13
16
 
14
- // ============================================================================
15
- // Feature Identifiers
16
- // ============================================================================
17
-
18
- /**
19
- * Feature identifier for sponsored transactions.
20
- * Wallets implementing this feature can request gas sponsorship from
21
- * the EVE Frontier sponsored-transaction backend service.
22
- *
23
- * @category Wallet
24
- */
25
- export const EVEFRONTIER_SPONSORED_TRANSACTION =
26
- "evefrontier:sponsoredTransaction" as const;
27
-
28
- // ============================================================================
29
- // Sponsored Transaction Types
30
- // ============================================================================
31
-
32
- /**
33
- * Map assembly types to API strings
34
- */
35
- const ASSEMBLY_TYPE_API_STRING: Record<Assemblies, string> = {
36
- [Assemblies.SmartStorageUnit]: "storage-units",
37
- [Assemblies.SmartTurret]: "turrets",
38
- [Assemblies.SmartGate]: "gates",
39
- [Assemblies.NetworkNode]: "network-nodes",
40
- [Assemblies.Manufacturing]: "manufacturing",
41
- [Assemblies.Refinery]: "refineries",
42
- } as const;
43
-
44
- /** API slug for assembly type in sponsored transaction payloads (e.g. "storage-units"). */
45
- export type SponsoredTransactionAssemblyType =
46
- (typeof ASSEMBLY_TYPE_API_STRING)[Assemblies];
47
-
48
17
  /**
49
18
  * Maps an assembly type enum to the API string expected by the sponsored transaction backend.
50
19
  *
@@ -68,21 +37,23 @@ export interface SponsoredTransactionInput {
68
37
  txAction: SponsoredTransactionActions;
69
38
  /** Assembly ID */
70
39
  assembly: AssemblyType<Assemblies>["item_id"];
40
+ tenant: string;
71
41
  /** The assembly type to be sponsored and executed */
72
42
  assemblyType: SponsoredTransactionAssemblyType;
73
43
  /** The Sui chain to execute on (e.g., "sui:testnet", "sui:mainnet") */
74
44
  chain: `sui:${string}`;
75
- /** Optional destination for gate linking */
76
- destination?: AssemblyType<Assemblies>["item_id"];
77
45
  }
78
46
 
79
- /** Sponsored tx args with assembly object; id and assemblyType are derived. */
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. */
80
48
  export type SponsoredTransactionArgs = Omit<
81
49
  SponsoredTransactionInput,
82
- "assembly" | "assemblyType" | "account"
50
+ "assembly" | "assemblyType" | "account" | "tenant"
83
51
  > & {
84
52
  assembly: AssemblyType<Assemblies>;
85
53
  account?: string;
54
+ tenant?: string;
55
+ txAction: SponsoredTransactionActions;
56
+ chain: `sui:${string}`;
86
57
  };
87
58
 
88
59
  /**
package/wallet/index.ts CHANGED
@@ -6,7 +6,6 @@
6
6
 
7
7
  // Feature definitions and types
8
8
  export {
9
- EVEFRONTIER_SPONSORED_TRANSACTION,
10
9
  getAssemblyTypeApiString,
11
10
  hasSponsoredTransactionFeature,
12
11
  supportsSponsoredTransaction,
@@ -14,7 +13,6 @@ export {
14
13
  export type {
15
14
  EveFrontierSponsoredTransactionFeature,
16
15
  SponsoredTransactionArgs,
17
- SponsoredTransactionAssemblyType,
18
16
  SponsoredTransactionInput,
19
17
  SponsoredTransactionMethod,
20
18
  SponsoredTransactionOutput,
package/wallet/utils.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { Wallet } from "@mysten/wallet-standard";
2
2
  import {
3
- EVEFRONTIER_SPONSORED_TRANSACTION,
4
3
  hasSponsoredTransactionFeature,
5
4
  supportsSponsoredTransaction,
6
5
  type EveFrontierSponsoredTransactionFeature,
7
6
  type SponsoredTransactionMethod,
8
7
  } from "./features";
8
+ import { EVEFRONTIER_SPONSORED_TRANSACTION } from "../types";
9
9
 
10
10
  /**
11
11
  * Check if a wallet supports the EVE Frontier sponsored transaction feature.