@evefrontier/dapp-kit 0.1.8 → 0.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +28 -25
  2. package/dist/config/dapp-kit.d.ts +4 -0
  3. package/dist/config/dapp-kit.d.ts.map +1 -0
  4. package/dist/config/dapp-kit.js +14 -0
  5. package/dist/config/index.d.ts +2 -0
  6. package/dist/config/index.d.ts.map +1 -0
  7. package/dist/config/index.js +1 -0
  8. package/dist/graphql/client.d.ts +277 -0
  9. package/dist/graphql/client.d.ts.map +1 -0
  10. package/dist/graphql/client.js +346 -0
  11. package/dist/graphql/index.d.ts +4 -0
  12. package/dist/graphql/index.d.ts.map +1 -0
  13. package/dist/graphql/index.js +16 -0
  14. package/dist/graphql/queries.d.ts +103 -0
  15. package/dist/graphql/queries.d.ts.map +1 -0
  16. package/{graphql/queries.ts → dist/graphql/queries.js} +113 -223
  17. package/dist/graphql/types.d.ts +396 -0
  18. package/dist/graphql/types.d.ts.map +1 -0
  19. package/dist/graphql/types.js +4 -0
  20. package/dist/hooks/index.d.ts +10 -0
  21. package/dist/hooks/index.d.ts.map +1 -0
  22. package/dist/hooks/index.js +8 -0
  23. package/dist/hooks/useCharacterDirectory.d.ts +16 -0
  24. package/dist/hooks/useCharacterDirectory.d.ts.map +1 -0
  25. package/dist/hooks/useCharacterDirectory.js +23 -0
  26. package/dist/hooks/useCharacterSearch.d.ts +24 -0
  27. package/dist/hooks/useCharacterSearch.d.ts.map +1 -0
  28. package/dist/hooks/useCharacterSearch.js +24 -0
  29. package/dist/hooks/useConnection.d.ts +51 -0
  30. package/dist/hooks/useConnection.d.ts.map +1 -0
  31. package/{hooks/useConnection.ts → dist/hooks/useConnection.js} +8 -10
  32. package/dist/hooks/useEntityRole.d.ts +26 -0
  33. package/dist/hooks/useEntityRole.d.ts.map +1 -0
  34. package/dist/hooks/useEntityRole.js +91 -0
  35. package/dist/hooks/useNotification.d.ts +72 -0
  36. package/dist/hooks/useNotification.d.ts.map +1 -0
  37. package/{hooks/useNotification.ts → dist/hooks/useNotification.js} +8 -12
  38. package/dist/hooks/useSmartObject.d.ts +44 -0
  39. package/dist/hooks/useSmartObject.d.ts.map +1 -0
  40. package/dist/hooks/useSmartObject.js +50 -0
  41. package/dist/hooks/useSponsoredTransaction.d.ts +147 -0
  42. package/dist/hooks/useSponsoredTransaction.d.ts.map +1 -0
  43. package/dist/hooks/useSponsoredTransaction.js +240 -0
  44. package/dist/hooks/useTypeNames.d.ts +11 -0
  45. package/dist/hooks/useTypeNames.d.ts.map +1 -0
  46. package/dist/hooks/useTypeNames.js +24 -0
  47. package/dist/index.d.ts +11 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +29 -0
  50. package/dist/providers/EveFrontierProvider.d.ts +23 -0
  51. package/dist/providers/EveFrontierProvider.d.ts.map +1 -0
  52. package/dist/providers/EveFrontierProvider.js +23 -0
  53. package/dist/providers/NotificationProvider.d.ts +14 -0
  54. package/dist/providers/NotificationProvider.d.ts.map +1 -0
  55. package/dist/providers/NotificationProvider.js +66 -0
  56. package/dist/providers/SmartObjectProvider.d.ts +31 -0
  57. package/dist/providers/SmartObjectProvider.d.ts.map +1 -0
  58. package/dist/providers/SmartObjectProvider.js +80 -0
  59. package/dist/providers/VaultProvider.d.ts +10 -0
  60. package/dist/providers/VaultProvider.d.ts.map +1 -0
  61. package/dist/providers/VaultProvider.js +79 -0
  62. package/dist/providers/index.d.ts +5 -0
  63. package/dist/providers/index.d.ts.map +1 -0
  64. package/dist/providers/index.js +4 -0
  65. package/dist/providers/smartObject/useEntityData.d.ts +29 -0
  66. package/dist/providers/smartObject/useEntityData.d.ts.map +1 -0
  67. package/dist/providers/smartObject/useEntityData.js +135 -0
  68. package/dist/providers/smartObject/useEntitySubscription.d.ts +14 -0
  69. package/dist/providers/smartObject/useEntitySubscription.d.ts.map +1 -0
  70. package/dist/providers/smartObject/useEntitySubscription.js +58 -0
  71. package/dist/providers/smartObject/useObjectSelection.d.ts +11 -0
  72. package/dist/providers/smartObject/useObjectSelection.d.ts.map +1 -0
  73. package/dist/providers/smartObject/useObjectSelection.js +27 -0
  74. package/dist/providers/smartObject/usePollingBackstop.d.ts +18 -0
  75. package/dist/providers/smartObject/usePollingBackstop.d.ts.map +1 -0
  76. package/dist/providers/smartObject/usePollingBackstop.js +38 -0
  77. package/dist/types/character.d.ts +21 -0
  78. package/dist/types/character.d.ts.map +1 -0
  79. package/dist/types/character.js +1 -0
  80. package/dist/types/contexts.d.ts +61 -0
  81. package/dist/types/contexts.d.ts.map +1 -0
  82. package/dist/types/contexts.js +6 -0
  83. package/dist/types/entity.d.ts +245 -0
  84. package/dist/types/entity.d.ts.map +1 -0
  85. package/dist/types/entity.js +6 -0
  86. package/dist/types/index.d.ts +6 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/types/index.js +5 -0
  89. package/dist/types/sponsoredTransaction.d.ts +26 -0
  90. package/dist/types/sponsoredTransaction.d.ts.map +1 -0
  91. package/dist/types/sponsoredTransaction.js +10 -0
  92. package/dist/types/types.d.ts +110 -0
  93. package/dist/types/types.d.ts.map +1 -0
  94. package/dist/types/types.js +41 -0
  95. package/dist/types/worldApiReturnTypes.d.ts +68 -0
  96. package/dist/types/worldApiReturnTypes.d.ts.map +1 -0
  97. package/dist/types/worldApiReturnTypes.js +1 -0
  98. package/{utils/burnRate.ts → dist/utils/burnRate.d.ts} +4 -29
  99. package/dist/utils/burnRate.d.ts.map +1 -0
  100. package/dist/utils/burnRate.js +25 -0
  101. package/dist/utils/characters.d.ts +26 -0
  102. package/dist/utils/characters.d.ts.map +1 -0
  103. package/dist/utils/characters.js +84 -0
  104. package/dist/utils/constants.d.ts +153 -0
  105. package/dist/utils/constants.d.ts.map +1 -0
  106. package/dist/utils/constants.js +190 -0
  107. package/dist/utils/datahub.d.ts +40 -0
  108. package/dist/utils/datahub.d.ts.map +1 -0
  109. package/{utils/datahub.ts → dist/utils/datahub.js} +32 -25
  110. package/dist/utils/entity.d.ts +58 -0
  111. package/dist/utils/entity.d.ts.map +1 -0
  112. package/dist/utils/entity.js +386 -0
  113. package/dist/utils/errors.d.ts +18 -0
  114. package/dist/utils/errors.d.ts.map +1 -0
  115. package/dist/utils/errors.js +128 -0
  116. package/dist/utils/events/entityEvents.d.ts +44 -0
  117. package/dist/utils/events/entityEvents.d.ts.map +1 -0
  118. package/dist/utils/events/entityEvents.js +95 -0
  119. package/dist/utils/events/entitySubscription.d.ts +30 -0
  120. package/dist/utils/events/entitySubscription.d.ts.map +1 -0
  121. package/dist/utils/events/entitySubscription.js +84 -0
  122. package/dist/utils/events/graphqlEventStream.d.ts +90 -0
  123. package/dist/utils/events/graphqlEventStream.d.ts.map +1 -0
  124. package/dist/utils/events/graphqlEventStream.js +198 -0
  125. package/dist/utils/events/refetchScheduler.d.ts +30 -0
  126. package/dist/utils/events/refetchScheduler.d.ts.map +1 -0
  127. package/dist/utils/events/refetchScheduler.js +57 -0
  128. package/dist/utils/events/sseClient.d.ts +42 -0
  129. package/dist/utils/events/sseClient.d.ts.map +1 -0
  130. package/dist/utils/events/sseClient.js +97 -0
  131. package/dist/utils/fuel.d.ts +231 -0
  132. package/dist/utils/fuel.d.ts.map +1 -0
  133. package/dist/utils/fuel.js +652 -0
  134. package/dist/utils/grid.d.ts +115 -0
  135. package/dist/utils/grid.d.ts.map +1 -0
  136. package/dist/utils/grid.js +115 -0
  137. package/dist/utils/index.d.ts +15 -0
  138. package/dist/utils/index.d.ts.map +1 -0
  139. package/dist/utils/index.js +22 -0
  140. package/dist/utils/inventory.d.ts +3 -0
  141. package/dist/utils/inventory.d.ts.map +1 -0
  142. package/dist/utils/inventory.js +12 -0
  143. package/dist/utils/logger.d.ts +25 -0
  144. package/dist/utils/logger.d.ts.map +1 -0
  145. package/dist/utils/logger.js +228 -0
  146. package/dist/utils/mapping.d.ts +30 -0
  147. package/dist/utils/mapping.d.ts.map +1 -0
  148. package/dist/utils/mapping.js +73 -0
  149. package/dist/utils/mvr/worldTypes.d.ts +35 -0
  150. package/dist/utils/mvr/worldTypes.d.ts.map +1 -0
  151. package/dist/utils/mvr/worldTypes.js +54 -0
  152. package/dist/utils/role.d.ts +116 -0
  153. package/dist/utils/role.d.ts.map +1 -0
  154. package/dist/utils/role.js +120 -0
  155. package/dist/utils/smartObject.d.ts +24 -0
  156. package/dist/utils/smartObject.d.ts.map +1 -0
  157. package/dist/utils/smartObject.js +24 -0
  158. package/dist/utils/utils.d.ts +133 -0
  159. package/dist/utils/utils.d.ts.map +1 -0
  160. package/dist/utils/utils.js +213 -0
  161. package/dist/wallet/features.d.ts +28 -0
  162. package/dist/wallet/features.d.ts.map +1 -0
  163. package/dist/wallet/features.js +22 -0
  164. package/dist/wallet/index.d.ts +9 -0
  165. package/dist/wallet/index.d.ts.map +1 -0
  166. package/dist/wallet/index.js +9 -0
  167. package/dist/wallet/utils.d.ts +71 -0
  168. package/dist/wallet/utils.d.ts.map +1 -0
  169. package/dist/wallet/utils.js +79 -0
  170. package/package.json +69 -35
  171. package/config/dapp-kit.ts +0 -20
  172. package/config/index.ts +0 -1
  173. package/graphql/client.ts +0 -578
  174. package/graphql/index.ts +0 -39
  175. package/graphql/types.ts +0 -468
  176. package/hooks/index.ts +0 -15
  177. package/hooks/useSmartObject.ts +0 -66
  178. package/hooks/useSponsoredTransaction.ts +0 -442
  179. package/index.ts +0 -88
  180. package/providers/EveFrontierProvider.tsx +0 -41
  181. package/providers/NotificationProvider.tsx +0 -108
  182. package/providers/SmartObjectProvider.tsx +0 -296
  183. package/providers/VaultProvider.tsx +0 -108
  184. package/providers/index.ts +0 -10
  185. package/types/contexts.ts +0 -67
  186. package/types/global.d.ts +0 -7
  187. package/types/index.ts +0 -4
  188. package/types/sponsoredTransaction.ts +0 -70
  189. package/types/types.ts +0 -198
  190. package/types/worldApiReturnTypes.ts +0 -144
  191. package/utils/__tests__/burnRate.test.ts +0 -121
  192. package/utils/__tests__/character.test.ts +0 -112
  193. package/utils/__tests__/characterOwnedObjects.test.ts +0 -225
  194. package/utils/__tests__/config.test.ts +0 -424
  195. package/utils/__tests__/datahub.test.ts +0 -58
  196. package/utils/__tests__/logger.test.ts +0 -145
  197. package/utils/__tests__/mapping.test.ts +0 -439
  198. package/utils/__tests__/utils.test.ts +0 -299
  199. package/utils/character.ts +0 -46
  200. package/utils/characterOwnedObjects.ts +0 -53
  201. package/utils/config.ts +0 -151
  202. package/utils/constants.ts +0 -254
  203. package/utils/errors.ts +0 -171
  204. package/utils/index.ts +0 -47
  205. package/utils/logger.ts +0 -300
  206. package/utils/mapping.ts +0 -118
  207. package/utils/transforms.ts +0 -263
  208. package/utils/utils.ts +0 -270
  209. package/wallet/features.ts +0 -136
  210. package/wallet/index.ts +0 -26
  211. package/wallet/utils.ts +0 -117
package/graphql/client.ts DELETED
@@ -1,578 +0,0 @@
1
- import {
2
- getCharacterOwnerCapType,
3
- getCharacterPlayerProfileType,
4
- getSuiGraphqlEndpoint,
5
- } from "../utils/constants";
6
- import type {
7
- GraphQLResponse,
8
- GetObjectByAddressResponse,
9
- GetObjectOwnerAndOwnedObjectsResponse,
10
- GetObjectOwnerAndOwnedObjectsWithJsonResponse,
11
- GetOwnedObjectsByTypeResponse,
12
- GetOwnedObjectsByPackageResponse,
13
- GetSingletonObjectByTypeResponse,
14
- GetObjectsByTypeResponse,
15
- GetObjectResponse,
16
- GetObjectWithJsonResponse,
17
- CharacterInfo,
18
- GetObjectAndCharacterOwnerResponse,
19
- DynamicFieldNode,
20
- RawSuiObjectData,
21
- GetSingletonConfigObjectByTypeResponse,
22
- GetWalletCharactersResponse,
23
- GetCharacterAndOwnedObjectsResponse,
24
- } from "./types";
25
- import { parseCharacterFromJson } from "../utils/character";
26
- import {
27
- GET_OBJECT_BY_ADDRESS,
28
- GET_OBJECT_WITH_DYNAMIC_FIELDS,
29
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE,
30
- GET_OBJECT_DYNAMICFIELD_CHARACTER_WITH_JSON,
31
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON,
32
- GET_OWNED_OBJECTS_BY_TYPE,
33
- GET_OWNED_OBJECTS_BY_PACKAGE,
34
- GET_WALLET_CHARACTERS,
35
- GET_CHARACTER_AND_OWNED_OBJECTS,
36
- GET_SINGLETON_OBJECT_BY_TYPE,
37
- GET_OBJECTS_BY_TYPE,
38
- GET_OBJECT_WITH_JSON,
39
- GET_SINGLETON_CONFIG_OBJECT_BY_TYPE,
40
- } from "./queries";
41
- import { createLogger } from "../utils";
42
-
43
- const log = createLogger();
44
-
45
- /**
46
- * Execute a GraphQL query against the Sui blockchain endpoint.
47
- *
48
- * This is the low-level function used by all other GraphQL helper functions.
49
- * Use this when you need to execute custom queries not covered by the helper functions.
50
- *
51
- * @category GraphQL Client
52
- * @typeParam T - The expected response data type
53
- * @param query - The GraphQL query string
54
- * @param variables - Variables to pass to the query
55
- * @returns Promise resolving to the GraphQL response
56
- * @throws {Error} If the HTTP request fails
57
- *
58
- * @example Custom query
59
- * ```typescript
60
- * const result = await executeGraphQLQuery<MyResponseType>(
61
- * `query GetObject($address: SuiAddress!) {
62
- * object(address: $address) {
63
- * asMoveObject { contents { json } }
64
- * }
65
- * }`,
66
- * { address: "0x123..." }
67
- * );
68
- * console.log(result.data?.object?.asMoveObject?.contents?.json);
69
- * ```
70
- */
71
- export async function executeGraphQLQuery<T = unknown>(
72
- query: string,
73
- variables: Record<string, unknown>,
74
- ): Promise<GraphQLResponse<T>> {
75
- const response = await fetch(getSuiGraphqlEndpoint(), {
76
- method: "POST",
77
- headers: {
78
- "Content-Type": "application/json",
79
- },
80
- body: JSON.stringify({
81
- query,
82
- variables,
83
- }),
84
- });
85
-
86
- if (!response.ok) {
87
- throw new Error(`HTTP error! status: ${response.status}`);
88
- }
89
-
90
- return response.json();
91
- }
92
-
93
- // ============================================================================
94
- // Helper Functions for Common Queries
95
- // ============================================================================
96
-
97
- /**
98
- * Fetch a Sui object by its address with BCS-encoded contents.
99
- *
100
- * Use this for low-level object access when you need raw BCS data.
101
- * For JSON-decoded data, use {@link getObjectWithJson} instead.
102
- *
103
- * @category GraphQL Client
104
- * @param address - The Sui object address (0x...)
105
- * @returns Promise resolving to object with BCS contents
106
- *
107
- * @example
108
- * ```typescript
109
- * const result = await getObjectByAddress("0x123...");
110
- * const bcsData = result.data?.object?.asMoveObject?.contents?.bcs;
111
- * ```
112
- */
113
- export async function getObjectByAddress(address: string) {
114
- return executeGraphQLQuery<GetObjectByAddressResponse>(
115
- GET_OBJECT_BY_ADDRESS,
116
- { address },
117
- );
118
- }
119
-
120
- /**
121
- * Fetch a Sui object with its dynamic fields in JSON format.
122
- *
123
- * Retrieves the object's contents and all associated dynamic fields,
124
- * which is useful for assemblies that store data in dynamic fields
125
- * (e.g., inventory items, configuration).
126
- *
127
- * @category GraphQL Client
128
- * @param objectId - The Sui object ID
129
- * @returns Promise resolving to object with dynamic fields
130
- *
131
- * @example
132
- * ```typescript
133
- * const result = await getObjectWithDynamicFields("0x123...");
134
- * const dynamicFields = result.data?.object?.asMoveObject?.dynamicFields?.nodes;
135
- * dynamicFields?.forEach(field => {
136
- * console.log(field.name.json, field.contents.json);
137
- * });
138
- * ```
139
- */
140
- export async function getObjectWithDynamicFields(objectId: string) {
141
- return executeGraphQLQuery<GetObjectResponse>(
142
- GET_OBJECT_WITH_DYNAMIC_FIELDS,
143
- { objectId },
144
- );
145
- }
146
-
147
- /**
148
- * Fetch a Sui object with JSON-decoded contents.
149
- *
150
- * This is the most common way to fetch object data when you need
151
- * to read the object's fields as JavaScript objects.
152
- *
153
- * @category GraphQL Client
154
- * @param address - The Sui object address
155
- * @returns Promise resolving to object with JSON contents
156
- *
157
- * @example
158
- * ```typescript
159
- * const result = await getObjectWithJson("0x123...");
160
- * const json = result.data?.object?.asMoveObject?.contents?.json;
161
- * console.log(json); // { id: "...", name: "...", ... }
162
- * ```
163
- */
164
- export async function getObjectWithJson(address: string) {
165
- return executeGraphQLQuery<GetObjectWithJsonResponse>(GET_OBJECT_WITH_JSON, {
166
- address,
167
- });
168
- }
169
-
170
- /**
171
- * Get an object's owner and their owned objects of a specific type.
172
- *
173
- * Useful for traversing ownership chains, e.g., finding all assemblies
174
- * owned by a specific character.
175
- *
176
- * @category GraphQL Client
177
- * @param objectAddress - The Sui object address to query owner of
178
- * @param ownedObjectType - Optional type filter for owned objects
179
- * @returns Promise resolving to owner info and owned objects (BCS format)
180
- *
181
- * @example
182
- * ```typescript
183
- * const result = await getObjectOwnerAndOwnedObjectsByType(
184
- * "0x123...",
185
- * "0xpackage::module::MyType"
186
- * );
187
- * const ownerAddress = result.data?.object?.owner?.address?.address;
188
- * ```
189
- */
190
- export async function getObjectOwnerAndOwnedObjectsByType(
191
- objectAddress: string,
192
- ownedObjectType?: string,
193
- ) {
194
- return executeGraphQLQuery<GetObjectOwnerAndOwnedObjectsResponse>(
195
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE,
196
- {
197
- object: objectAddress,
198
- owned_object_type: ownedObjectType,
199
- },
200
- );
201
- }
202
-
203
- /**
204
- * Get an object's owner and their owned objects with JSON data.
205
- *
206
- * Similar to {@link getObjectOwnerAndOwnedObjectsByType} but returns
207
- * JSON-decoded contents for easier consumption.
208
- *
209
- * @category GraphQL Client
210
- * @param objectAddress - The Sui object address
211
- * @param ownedObjectType - Optional type filter for owned objects
212
- * @returns Promise resolving to owner info and owned objects (JSON format)
213
- */
214
- export async function getObjectOwnerAndOwnedObjectsWithJson(
215
- objectAddress: string,
216
- ownedObjectType?: string,
217
- ) {
218
- return executeGraphQLQuery<GetObjectOwnerAndOwnedObjectsWithJsonResponse>(
219
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON,
220
- {
221
- object: objectAddress,
222
- owned_object_type: ownedObjectType,
223
- },
224
- );
225
- }
226
-
227
- /**
228
- * Get an assembly object and resolve its owner character.
229
- *
230
- * This is a specialized query for EVE Frontier assemblies that
231
- * follows the owner_cap_id to resolve the owning character.
232
- *
233
- * @category GraphQL Client
234
- * @param objectAddress - The assembly object address
235
- * @returns Promise resolving to assembly and character data
236
- * @internal
237
- */
238
- export async function getObjectAndCharacterOwner(objectAddress: string) {
239
- return executeGraphQLQuery<GetObjectAndCharacterOwnerResponse>(
240
- GET_OBJECT_DYNAMICFIELD_CHARACTER_WITH_JSON,
241
- {
242
- objectId: objectAddress,
243
- characterOwnerType: getCharacterOwnerCapType(),
244
- },
245
- );
246
- }
247
-
248
- /**
249
- * Get all objects of a specific type owned by an address.
250
- *
251
- * Returns only object addresses (lightweight). Use this when you need
252
- * to find objects and will fetch their details separately.
253
- *
254
- * @category GraphQL Client
255
- * @param owner - The owner's Sui address
256
- * @param objectType - Optional Move type filter (e.g., "0xpkg::module::Type")
257
- * @returns Promise resolving to list of owned object addresses
258
- *
259
- * @example
260
- * ```typescript
261
- * const result = await getOwnedObjectsByType(
262
- * "0xowner...",
263
- * "0xworld::smart_storage_unit::SmartStorageUnit"
264
- * );
265
- * const addresses = result.data?.address?.objects?.nodes.map(n => n.address);
266
- * ```
267
- */
268
- export async function getOwnedObjectsByType(
269
- owner: string,
270
- objectType?: string,
271
- ) {
272
- return executeGraphQLQuery<GetOwnedObjectsByTypeResponse>(
273
- GET_OWNED_OBJECTS_BY_TYPE,
274
- {
275
- owner,
276
- object_type: objectType,
277
- },
278
- );
279
- }
280
-
281
- /**
282
- * Get all objects owned by an address filtered by package.
283
- *
284
- * Returns full object data with dynamic fields. Use this when you need
285
- * all objects from a specific package (e.g., all EVE Frontier objects).
286
- *
287
- * @category GraphQL Client
288
- * @param owner - The owner's Sui address
289
- * @param packageId - The Move package ID to filter by
290
- * @returns Promise resolving to full object data including dynamic fields
291
- *
292
- * @example
293
- * ```typescript
294
- * const result = await getOwnedObjectsByPackage(
295
- * "0xowner...",
296
- * "0xworld_package_id..."
297
- * );
298
- * const objects = result.data?.objects?.nodes;
299
- * ```
300
- */
301
- export async function getOwnedObjectsByPackage(
302
- owner: string,
303
- packageId: string,
304
- ) {
305
- return executeGraphQLQuery<GetOwnedObjectsByPackageResponse>(
306
- GET_OWNED_OBJECTS_BY_PACKAGE,
307
- {
308
- owner,
309
- packageId,
310
- },
311
- );
312
- }
313
-
314
- /**
315
- * Get all characters owned by a wallet
316
- * Returns the most recent character owned by the wallet
317
- *
318
- * @category GraphQL Client
319
- */
320
- export async function getWalletCharacters(wallet: string) {
321
- return executeGraphQLQuery<GetWalletCharactersResponse>(
322
- GET_WALLET_CHARACTERS,
323
- {
324
- owner: wallet,
325
- characterPlayerProfileType: getCharacterPlayerProfileType(),
326
- },
327
- );
328
- }
329
-
330
- /**
331
- * Get all characters owned by a wallet
332
- * Returns the characters owned by the wallet
333
- *
334
- * @category GraphQL Client
335
- */
336
- export async function getCharacterAndOwnedObjects(wallet: string) {
337
- return executeGraphQLQuery<GetCharacterAndOwnedObjectsResponse>(
338
- GET_CHARACTER_AND_OWNED_OBJECTS,
339
- {
340
- owner: wallet,
341
- characterPlayerProfileType: getCharacterPlayerProfileType(),
342
- },
343
- );
344
- }
345
-
346
- /**
347
- * Get a singleton object by its Move type.
348
- *
349
- * Useful for global/singleton objects where there's only one instance
350
- * of a particular type on-chain.
351
- *
352
- * @category GraphQL Client
353
- * @param objectType - The full Move type string
354
- * @returns Promise resolving to the singleton object address
355
- *
356
- * @example
357
- * ```typescript
358
- * const result = await getSingletonObjectByType("0xpkg::config::GlobalConfig");
359
- * const address = result.data?.objects?.nodes[0]?.address;
360
- * ```
361
- */
362
- export async function getSingletonObjectByType(objectType: string) {
363
- return executeGraphQLQuery<GetSingletonObjectByTypeResponse>(
364
- GET_SINGLETON_OBJECT_BY_TYPE,
365
- {
366
- object_type: objectType,
367
- },
368
- );
369
- }
370
-
371
- /**
372
- * Get a singleton config object by its Move type and table name, with dynamic fields.
373
- *
374
- * Used for on-chain config singletons (e.g. EnergyConfig, FuelConfig) that expose
375
- * a table of key/value entries via dynamic fields. Returns the first object's full
376
- * response including contents.extract...addressAt.dynamicFields.nodes.
377
- *
378
- * @category GraphQL Client
379
- * @param objectType - The full Move type string (e.g. from getEnergyConfigType())
380
- * @param tableName - The table path for extract (e.g. "assembly_energy", "fuel_efficiency")
381
- * @returns Promise resolving to the GraphQL response with objects.nodes[0] and dynamicFields.nodes
382
- *
383
- * @example
384
- * ```typescript
385
- * const result = await getSingletonConfigObjectByType(getEnergyConfigType(), "assembly_energy");
386
- * const nodes = result.data?.objects?.nodes[0]?.asMoveObject?.contents?.extract?.extract?.asAddress?.addressAt?.dynamicFields?.nodes;
387
- * ```
388
- */
389
- export async function getSingletonConfigObjectByType(
390
- objectType: string,
391
- tableName: string,
392
- ) {
393
- return executeGraphQLQuery<GetSingletonConfigObjectByTypeResponse>(
394
- GET_SINGLETON_CONFIG_OBJECT_BY_TYPE,
395
- {
396
- object_type: objectType,
397
- table_name: tableName,
398
- },
399
- );
400
- }
401
-
402
- /**
403
- * Get all objects of a specific type with pagination.
404
- *
405
- * Use with caution as this may return many results. Supports cursor-based
406
- * pagination for iterating through large result sets.
407
- *
408
- * @category GraphQL Client
409
- * @param objectType - The full Move type string
410
- * @param options - Pagination options
411
- * @param options.first - Number of results per page (default: 50)
412
- * @param options.after - Cursor for next page
413
- * @returns Promise resolving to paginated object list
414
- *
415
- * @example Paginated fetch
416
- * ```typescript
417
- * let cursor: string | undefined;
418
- * do {
419
- * const result = await getObjectsByType("0xpkg::module::Type", {
420
- * first: 50,
421
- * after: cursor
422
- * });
423
- * const objects = result.data?.objects?.nodes;
424
- * cursor = result.data?.objects?.pageInfo?.hasNextPage
425
- * ? result.data?.objects?.pageInfo?.endCursor
426
- * : undefined;
427
- * } while (cursor);
428
- * ```
429
- */
430
- export async function getObjectsByType(
431
- objectType: string,
432
- options?: { first?: number; after?: string },
433
- ) {
434
- return executeGraphQLQuery<GetObjectsByTypeResponse>(GET_OBJECTS_BY_TYPE, {
435
- object_type: objectType,
436
- first: options?.first ?? 50,
437
- after: options?.after,
438
- });
439
- }
440
-
441
- /**
442
- * Fetch an EVE Frontier assembly and its owner character in one call.
443
- *
444
- * This is the primary function for loading assembly data in dApps.
445
- * It fetches the assembly's Move object data, dynamic fields, and
446
- * resolves the owner character through the ownership chain.
447
- *
448
- * @category GraphQL Client
449
- * @param assemblyId - The assembly's Sui object ID
450
- * @returns Promise resolving to:
451
- * - `moveObject` - The assembly's Move object data with JSON contents and dynamic fields
452
- * - `character` - The owner character info (id, name, address, tribeId, characterId)
453
- *
454
- * @example Basic usage
455
- * ```typescript
456
- * const { moveObject, character } = await getAssemblyWithOwner("0x123...");
457
- *
458
- * if (moveObject) {
459
- * console.log("Assembly data:", moveObject.contents.json);
460
- * console.log("Dynamic fields:", moveObject.dynamicFields?.nodes);
461
- * }
462
- *
463
- * if (character) {
464
- * console.log("Owner:", character.name);
465
- * }
466
- * ```
467
- *
468
- * @example Transform to typed Assembly
469
- * ```typescript
470
- * import { transformToAssembly } from '@evefrontier/dapp-kit';
471
- *
472
- * const { moveObject, character } = await getAssemblyWithOwner(assemblyId);
473
- * const assembly = await transformToAssembly(assemblyId, moveObject, { character });
474
- * console.log(assembly.name, assembly.type, assembly.state);
475
- * ```
476
- *
477
- * @see {@link transformToAssembly} for converting raw data to typed Assembly
478
- */
479
- export async function getAssemblyWithOwner(assemblyId: string): Promise<{
480
- moveObject: {
481
- contents: {
482
- json: Record<string, unknown>;
483
- type?: { repr: string };
484
- };
485
- dynamicFields?: {
486
- nodes: DynamicFieldNode[];
487
- };
488
- } | null;
489
- assemblyOwner: CharacterInfo | null;
490
- energySource: RawSuiObjectData | null;
491
- destinationGate: RawSuiObjectData | null;
492
- }> {
493
- try {
494
- const result = await getObjectAndCharacterOwner(assemblyId);
495
-
496
- if (!result.data?.object?.asMoveObject) {
497
- log.warn("[DappKit] getAssemblyWithOwner: Assembly not found");
498
- return {
499
- moveObject: null,
500
- assemblyOwner: null,
501
- energySource: null,
502
- destinationGate: null,
503
- };
504
- }
505
-
506
- const moveObject = result.data.object.asMoveObject;
507
-
508
- const dynamicFields = moveObject.dynamicFields;
509
-
510
- // Extract character info from the owner chain
511
- let characterInfo: CharacterInfo | null = null;
512
-
513
- const characterMoveObject =
514
- moveObject.contents.extract?.asAddress?.asObject?.asMoveObject?.owner
515
- ?.address?.objects?.nodes[0]?.contents?.authorizedObj?.asAddress
516
- ?.asObject?.asMoveObject;
517
-
518
- if (!characterMoveObject?.contents?.json) {
519
- log.warn("[DappKit] getAssemblyWithOwner: Character not found");
520
- return {
521
- moveObject: result.data?.object?.asMoveObject,
522
- assemblyOwner: null,
523
- energySource: null,
524
- destinationGate: null,
525
- };
526
- }
527
-
528
- const characterJson = characterMoveObject?.contents.json;
529
- characterInfo = parseCharacterFromJson(characterJson);
530
- if (!characterInfo) {
531
- log.warn(
532
- "[DappKit] getAssemblyWithOwner: Could not extract character JSON from owner chain",
533
- );
534
- }
535
-
536
- const energySourceMoveObject =
537
- moveObject.contents.energySource?.asAddress?.asObject?.asMoveObject;
538
-
539
- if (!energySourceMoveObject?.contents?.json) {
540
- log.warn("[DappKit] getAssemblyWithOwner: Energy source not found");
541
- }
542
-
543
- const destinationGateMoveObject =
544
- moveObject.contents.destinationGate?.asAddress?.asObject?.asMoveObject;
545
-
546
- const energySourceJson = energySourceMoveObject?.contents
547
- ?.json as unknown as RawSuiObjectData | null;
548
- const destinationGateJson = destinationGateMoveObject?.contents
549
- ?.json as unknown as RawSuiObjectData | null;
550
-
551
- if (!energySourceJson) {
552
- log.warn(
553
- "[DappKit] getAssemblyWithOwner: Energy source not found. Object might be a network node.",
554
- );
555
- }
556
-
557
- return {
558
- moveObject: {
559
- contents: {
560
- json: moveObject.contents.json,
561
- type: moveObject.contents.type,
562
- },
563
- dynamicFields: dynamicFields || undefined,
564
- },
565
- assemblyOwner: characterInfo,
566
- energySource: energySourceJson ?? null,
567
- destinationGate: destinationGateJson ?? null,
568
- };
569
- } catch (error) {
570
- log.error("[DappKit] getAssemblyWithOwner error:", error);
571
- return {
572
- moveObject: null,
573
- assemblyOwner: null,
574
- energySource: null,
575
- destinationGate: null,
576
- };
577
- }
578
- }
package/graphql/index.ts DELETED
@@ -1,39 +0,0 @@
1
- // Client & Query Execution
2
- export {
3
- executeGraphQLQuery,
4
- getObjectByAddress,
5
- getObjectWithDynamicFields,
6
- getObjectWithJson,
7
- getObjectOwnerAndOwnedObjectsByType,
8
- getObjectOwnerAndOwnedObjectsWithJson,
9
- getObjectAndCharacterOwner,
10
- getOwnedObjectsByType,
11
- getOwnedObjectsByPackage,
12
- getSingletonObjectByType,
13
- getObjectsByType,
14
- // Character/owner resolution
15
- getWalletCharacters,
16
- getAssemblyWithOwner,
17
- getCharacterAndOwnedObjects,
18
- } from "./client";
19
-
20
- // Query Strings
21
- export {
22
- // Core object queries
23
- GET_OBJECT_BY_ADDRESS,
24
- GET_OBJECT_WITH_DYNAMIC_FIELDS,
25
- GET_OBJECT_WITH_JSON,
26
- // Owner & ownership queries
27
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE,
28
- GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON,
29
- GET_OWNED_OBJECTS_BY_TYPE,
30
- GET_OWNED_OBJECTS_BY_PACKAGE,
31
- GET_WALLET_CHARACTERS,
32
- // Singleton & type-based queries
33
- GET_SINGLETON_OBJECT_BY_TYPE,
34
- GET_SINGLETON_CONFIG_OBJECT_BY_TYPE,
35
- GET_OBJECTS_BY_TYPE,
36
- } from "./queries";
37
-
38
- // Types
39
- export * from "./types";