@evefrontier/dapp-kit 0.1.9 → 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
@@ -0,0 +1,346 @@
1
+ import { GRAPHQL_CLIENT_ID, getSuiGraphqlEndpoint } from '../utils/constants.js';
2
+ import { GET_ENTITY, GET_EVENTS_BY_TYPE, GET_OBJECT_BY_ADDRESS, GET_OBJECT_LATEST_VERSION, GET_OBJECT_OWNER, GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE, GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON, GET_OBJECT_WITH_DYNAMIC_FIELDS, GET_OBJECT_WITH_JSON, GET_OBJECTS_BY_TYPE, GET_OWNED_OBJECTS_BY_PACKAGE, GET_OWNED_OBJECTS_BY_TYPE, GET_SINGLETON_OBJECT_BY_TYPE, GET_TABLE_ENTRIES, } from './queries.js';
3
+ /**
4
+ * Execute a GraphQL query against the Sui blockchain endpoint.
5
+ *
6
+ * This is the low-level function used by all other GraphQL helper functions.
7
+ * Use this when you need to execute custom queries not covered by the helper functions.
8
+ *
9
+ * @category GraphQL Client
10
+ * @typeParam T - The expected response data type
11
+ * @param query - The GraphQL query string
12
+ * @param variables - Variables to pass to the query
13
+ * @returns Promise resolving to the GraphQL response
14
+ * @throws {Error} If the HTTP request fails
15
+ *
16
+ * @example Custom query
17
+ * ```typescript
18
+ * const result = await executeGraphQLQuery<MyResponseType>(
19
+ * `query GetObject($address: SuiAddress!) {
20
+ * object(address: $address) {
21
+ * asMoveObject { contents { json } }
22
+ * }
23
+ * }`,
24
+ * { address: "0x123..." }
25
+ * );
26
+ * console.log(result.data?.object?.asMoveObject?.contents?.json);
27
+ * ```
28
+ */
29
+ export async function executeGraphQLQuery(query, variables) {
30
+ const response = await fetch(getSuiGraphqlEndpoint(), {
31
+ method: 'POST',
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ 'X-Client-ID': GRAPHQL_CLIENT_ID,
35
+ },
36
+ body: JSON.stringify({
37
+ query,
38
+ variables,
39
+ }),
40
+ });
41
+ if (!response.ok) {
42
+ throw new Error(`HTTP error! status: ${response.status}`);
43
+ }
44
+ return response.json();
45
+ }
46
+ // ============================================================================
47
+ // Helper Functions for Common Queries
48
+ // ============================================================================
49
+ /**
50
+ * Fetch a Sui object by its address with BCS-encoded contents.
51
+ *
52
+ * Use this for low-level object access when you need raw BCS data.
53
+ * For JSON-decoded data, use {@link getObjectWithJson} instead.
54
+ *
55
+ * @category GraphQL Client
56
+ * @param address - The Sui object address (0x...)
57
+ * @returns Promise resolving to object with BCS contents
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const result = await getObjectByAddress("0x123...");
62
+ * const bcsData = result.data?.object?.asMoveObject?.contents?.bcs;
63
+ * ```
64
+ */
65
+ export async function getObjectByAddress(address) {
66
+ return executeGraphQLQuery(GET_OBJECT_BY_ADDRESS, { address });
67
+ }
68
+ /**
69
+ * Fetch a Sui object with its dynamic fields in JSON format.
70
+ *
71
+ * Retrieves the object's contents and all associated dynamic fields,
72
+ * which is useful for assemblies that store data in dynamic fields
73
+ * (e.g., inventory items, configuration).
74
+ *
75
+ * @category GraphQL Client
76
+ * @param objectId - The Sui object ID
77
+ * @returns Promise resolving to object with dynamic fields
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const result = await getObjectWithDynamicFields("0x123...");
82
+ * const dynamicFields = result.data?.object?.asMoveObject?.dynamicFields?.nodes;
83
+ * dynamicFields?.forEach(field => {
84
+ * console.log(field.name.json, field.contents.json);
85
+ * });
86
+ * ```
87
+ */
88
+ export async function getObjectWithDynamicFields(objectId) {
89
+ return executeGraphQLQuery(GET_OBJECT_WITH_DYNAMIC_FIELDS, { objectId });
90
+ }
91
+ /**
92
+ * Fetch a world entity: latest version, contents, and a page of its dynamic
93
+ * fields (components and action maps).
94
+ *
95
+ * Layout sections and inventory item tables nested in component values are
96
+ * resolved inline, up to `tableFirst` entries each. Page the rest with
97
+ * {@link getTableEntries} using the table id from the component JSON.
98
+ *
99
+ * @category GraphQL Client
100
+ * @param address - The entity's Sui object ID
101
+ * @param options - Pagination options
102
+ * @param options.cursor - Cursor for the next page of the entity's dynamicFields
103
+ * @param options.tableFirst - Max entries per nested table (default: 50)
104
+ * @returns Promise resolving to the entity's version, contents and dynamic fields
105
+ */
106
+ export async function getEntity(address, options) {
107
+ return executeGraphQLQuery(GET_ENTITY, {
108
+ address,
109
+ cursor: options?.cursor ?? null,
110
+ table_first: options?.tableFirst ?? 50,
111
+ });
112
+ }
113
+ /**
114
+ * Fetch one page of a Move table's entries by the table's UID.
115
+ *
116
+ * @category GraphQL Client
117
+ * @param tableId - The table's UID (e.g. a Layout's `inner.sections.id`)
118
+ * @param options - Pagination options
119
+ * @param options.first - Number of entries per page (default: 50)
120
+ * @param options.after - Cursor for the next page
121
+ * @returns Promise resolving to a page of table entries
122
+ */
123
+ export async function getTableEntries(tableId, options) {
124
+ return executeGraphQLQuery(GET_TABLE_ENTRIES, {
125
+ address: tableId,
126
+ first: options?.first ?? 50,
127
+ after: options?.after ?? null,
128
+ });
129
+ }
130
+ /**
131
+ * Fetch only an object's latest version, to detect changes cheaply.
132
+ *
133
+ * @category GraphQL Client
134
+ * @param address - The Sui object ID
135
+ * @returns Promise resolving to the latest version node
136
+ */
137
+ export async function getObjectLatestVersion(address) {
138
+ return executeGraphQLQuery(GET_OBJECT_LATEST_VERSION, { address });
139
+ }
140
+ /**
141
+ * Fetch an object's owner.
142
+ *
143
+ * @category GraphQL Client
144
+ * @param address - The Sui object ID
145
+ * @returns Promise resolving to the owner (`__typename` plus address when owned)
146
+ */
147
+ export async function getObjectOwner(address) {
148
+ return executeGraphQLQuery(GET_OBJECT_OWNER, {
149
+ address,
150
+ });
151
+ }
152
+ /**
153
+ * Fetch a Sui object with JSON-decoded contents.
154
+ *
155
+ * This is the most common way to fetch object data when you need
156
+ * to read the object's fields as JavaScript objects.
157
+ *
158
+ * @category GraphQL Client
159
+ * @param address - The Sui object address
160
+ * @returns Promise resolving to object with JSON contents
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * const result = await getObjectWithJson("0x123...");
165
+ * const json = result.data?.object?.asMoveObject?.contents?.json;
166
+ * console.log(json); // { id: "...", name: "...", ... }
167
+ * ```
168
+ */
169
+ export async function getObjectWithJson(address) {
170
+ return executeGraphQLQuery(GET_OBJECT_WITH_JSON, {
171
+ address,
172
+ });
173
+ }
174
+ /**
175
+ * Get an object's owner and their owned objects of a specific type.
176
+ *
177
+ * Useful for traversing ownership chains, e.g., finding all assemblies
178
+ * owned by a specific character.
179
+ *
180
+ * @category GraphQL Client
181
+ * @param objectAddress - The Sui object address to query owner of
182
+ * @param ownedObjectType - Optional type filter for owned objects
183
+ * @returns Promise resolving to owner info and owned objects (BCS format)
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const result = await getObjectOwnerAndOwnedObjectsByType(
188
+ * "0x123...",
189
+ * "0xpackage::module::MyType"
190
+ * );
191
+ * const ownerAddress = result.data?.object?.owner?.address?.address;
192
+ * ```
193
+ * @deprecated Walks `object.owner`, which is empty for shared `Entity` objects. Find a wallet's entities with {@link getOwnedObjectsByType} on the `AccessCap` type instead.
194
+ */
195
+ export async function getObjectOwnerAndOwnedObjectsByType(objectAddress, ownedObjectType) {
196
+ return executeGraphQLQuery(GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE, {
197
+ object: objectAddress,
198
+ owned_object_type: ownedObjectType,
199
+ });
200
+ }
201
+ /**
202
+ * Get an object's owner and their owned objects with JSON data.
203
+ *
204
+ * Similar to {@link getObjectOwnerAndOwnedObjectsByType} but returns
205
+ * JSON-decoded contents for easier consumption.
206
+ *
207
+ * @category GraphQL Client
208
+ * @param objectAddress - The Sui object address
209
+ * @param ownedObjectType - Optional type filter for owned objects
210
+ * @returns Promise resolving to owner info and owned objects (JSON format)
211
+ * @deprecated Walks `object.owner`, which is empty for shared `Entity` objects. Find a wallet's entities with {@link getOwnedObjectsByType} on the `AccessCap` type instead.
212
+ */
213
+ export async function getObjectOwnerAndOwnedObjectsWithJson(objectAddress, ownedObjectType) {
214
+ return executeGraphQLQuery(GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON, {
215
+ object: objectAddress,
216
+ owned_object_type: ownedObjectType,
217
+ });
218
+ }
219
+ /**
220
+ * Get all objects of a specific type owned by an address.
221
+ *
222
+ * Returns only object addresses (lightweight). Use this when you need
223
+ * to find objects and will fetch their details separately.
224
+ *
225
+ * @category GraphQL Client
226
+ * @param owner - The owner's Sui address
227
+ * @param objectType - Optional Move type filter (e.g., "0xpkg::module::Type")
228
+ * @returns Promise resolving to list of owned object addresses
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * const result = await getOwnedObjectsByType(
233
+ * "0xowner...",
234
+ * "0xworld::smart_storage_unit::SmartStorageUnit"
235
+ * );
236
+ * const addresses = result.data?.address?.objects?.nodes.map(n => n.address);
237
+ * ```
238
+ */
239
+ export async function getOwnedObjectsByType(owner, objectType) {
240
+ return executeGraphQLQuery(GET_OWNED_OBJECTS_BY_TYPE, {
241
+ owner,
242
+ object_type: objectType,
243
+ });
244
+ }
245
+ /**
246
+ * Get all objects owned by an address filtered by package.
247
+ *
248
+ * Returns full object data with dynamic fields. Use this when you need
249
+ * all objects from a specific package (e.g., all EVE Frontier objects).
250
+ *
251
+ * @category GraphQL Client
252
+ * @param owner - The owner's Sui address
253
+ * @param packageId - The Move package ID to filter by
254
+ * @returns Promise resolving to full object data including dynamic fields
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * const result = await getOwnedObjectsByPackage(
259
+ * "0xowner...",
260
+ * "0xworld_package_id..."
261
+ * );
262
+ * const objects = result.data?.objects?.nodes;
263
+ * ```
264
+ */
265
+ export async function getOwnedObjectsByPackage(owner, packageId) {
266
+ return executeGraphQLQuery(GET_OWNED_OBJECTS_BY_PACKAGE, {
267
+ owner,
268
+ packageId,
269
+ });
270
+ }
271
+ /**
272
+ * Get a singleton object by its Move type.
273
+ *
274
+ * Useful for global/singleton objects where there's only one instance
275
+ * of a particular type on-chain.
276
+ *
277
+ * @category GraphQL Client
278
+ * @param objectType - The full Move type string
279
+ * @returns Promise resolving to the singleton object address
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * const result = await getSingletonObjectByType("0xpkg::config::GlobalConfig");
284
+ * const address = result.data?.objects?.nodes[0]?.address;
285
+ * ```
286
+ */
287
+ export async function getSingletonObjectByType(objectType) {
288
+ return executeGraphQLQuery(GET_SINGLETON_OBJECT_BY_TYPE, {
289
+ object_type: objectType,
290
+ });
291
+ }
292
+ /**
293
+ * Get all objects of a specific type with pagination.
294
+ *
295
+ * Use with caution as this may return many results. Supports cursor-based
296
+ * pagination for iterating through large result sets.
297
+ *
298
+ * @category GraphQL Client
299
+ * @param objectType - The full Move type string
300
+ * @param options - Pagination options
301
+ * @param options.first - Number of results per page (default: 50)
302
+ * @param options.after - Cursor for next page
303
+ * @returns Promise resolving to paginated object list
304
+ *
305
+ * @example Paginated fetch
306
+ * ```typescript
307
+ * let cursor: string | undefined;
308
+ * do {
309
+ * const result = await getObjectsByType("0xpkg::module::Type", {
310
+ * first: 50,
311
+ * after: cursor
312
+ * });
313
+ * const objects = result.data?.objects?.nodes;
314
+ * cursor = result.data?.objects?.pageInfo?.hasNextPage
315
+ * ? result.data?.objects?.pageInfo?.endCursor
316
+ * : undefined;
317
+ * } while (cursor);
318
+ * ```
319
+ */
320
+ export async function getObjectsByType(objectType, options) {
321
+ return executeGraphQLQuery(GET_OBJECTS_BY_TYPE, {
322
+ object_type: objectType,
323
+ first: options?.first ?? 50,
324
+ after: options?.after,
325
+ });
326
+ }
327
+ /**
328
+ * Get events of a Move event type with pagination, oldest first.
329
+ *
330
+ * Use with caution as this may return many results. Event fields cannot be
331
+ * filtered on, so callers page through every event of the type.
332
+ *
333
+ * @category GraphQL Client
334
+ * @param eventType - The full Move event type string
335
+ * @param options - Pagination options
336
+ * @param options.first - Number of results per page (default: 50)
337
+ * @param options.after - Cursor for next page
338
+ * @returns Promise resolving to paginated event list
339
+ */
340
+ export async function getEventsByType(eventType, options) {
341
+ return executeGraphQLQuery(GET_EVENTS_BY_TYPE, {
342
+ event_type: eventType,
343
+ first: options?.first ?? 50,
344
+ after: options?.after,
345
+ });
346
+ }
@@ -0,0 +1,4 @@
1
+ export { executeGraphQLQuery, getEntity, getEventsByType, getObjectByAddress, getObjectLatestVersion, getObjectOwner, getObjectOwnerAndOwnedObjectsByType, getObjectOwnerAndOwnedObjectsWithJson, getObjectsByType, getObjectWithDynamicFields, getObjectWithJson, getOwnedObjectsByPackage, getOwnedObjectsByType, getSingletonObjectByType, getTableEntries, } from './client.js';
2
+ export { GET_ENTITY, GET_EVENTS_BY_TYPE, GET_OBJECT_BY_ADDRESS, GET_OBJECT_LATEST_VERSION, GET_OBJECT_OWNER, GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE, GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON, GET_OBJECT_WITH_DYNAMIC_FIELDS, GET_OBJECT_WITH_JSON, GET_OBJECTS_BY_TYPE, GET_OWNED_OBJECTS_BY_PACKAGE, GET_OWNED_OBJECTS_BY_TYPE, GET_SINGLETON_OBJECT_BY_TYPE, GET_TABLE_ENTRIES, } from './queries.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../graphql/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,mCAAmC,EACnC,qCAAqC,EACrC,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,GAChB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAEL,UAAU,EAEV,kBAAkB,EAElB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAEhB,0CAA0C,EAC1C,4CAA4C,EAC5C,8BAA8B,EAC9B,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EAEzB,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,WAAW,CAAA;AAGlB,cAAc,SAAS,CAAA"}
@@ -0,0 +1,16 @@
1
+ // Client & Query Execution
2
+ export { executeGraphQLQuery, getEntity, getEventsByType, getObjectByAddress, getObjectLatestVersion, getObjectOwner, getObjectOwnerAndOwnedObjectsByType, getObjectOwnerAndOwnedObjectsWithJson, getObjectsByType, getObjectWithDynamicFields, getObjectWithJson, getOwnedObjectsByPackage, getOwnedObjectsByType, getSingletonObjectByType, getTableEntries, } from './client.js';
3
+ // Query Strings
4
+ export {
5
+ // Entity queries
6
+ GET_ENTITY,
7
+ // Event queries
8
+ GET_EVENTS_BY_TYPE,
9
+ // Core object queries
10
+ GET_OBJECT_BY_ADDRESS, GET_OBJECT_LATEST_VERSION, GET_OBJECT_OWNER,
11
+ // Owner & ownership queries
12
+ GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE, GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON, GET_OBJECT_WITH_DYNAMIC_FIELDS, GET_OBJECT_WITH_JSON, GET_OBJECTS_BY_TYPE, GET_OWNED_OBJECTS_BY_PACKAGE, GET_OWNED_OBJECTS_BY_TYPE,
13
+ // Singleton & type-based queries
14
+ GET_SINGLETON_OBJECT_BY_TYPE, GET_TABLE_ENTRIES, } from './queries.js';
15
+ // Types
16
+ export * from './types.js';
@@ -0,0 +1,103 @@
1
+ /**
2
+ * GraphQL queries for fetching Sui objects
3
+ */
4
+ /**
5
+ * Query for fetching a specific object by address with BCS-encoded contents
6
+ * Use this for low-level object access with raw BCS data
7
+ *
8
+ * @category GraphQL Queries
9
+ */
10
+ export declare const GET_OBJECT_BY_ADDRESS = "\n query GetObjectByAddress($address: SuiAddress!) {\n object(address: $address) {\n address\n version\n digest\n asMoveObject {\n contents {\n type {\n repr\n }\n bcs\n }\n }\n }\n }\n";
11
+ /**
12
+ * Object by address with JSON contents and dynamic fields (nodes).
13
+ *
14
+ * @category GraphQL Queries
15
+ */
16
+ export declare const GET_OBJECT_WITH_DYNAMIC_FIELDS = "\n query GetObjectWithDynamicFields($objectId: SuiAddress!) {\n object(address: $objectId) {\n asMoveObject {\n contents {\n json\n }\n dynamicFields {\n nodes {\n contents {\n json\n type {\n layout\n }\n }\n name {\n json\n type {\n repr\n }\n }\n }\n }\n }\n }\n }\n";
17
+ /**
18
+ * World entity: latest version, contents, and a page of its dynamic fields
19
+ * (components and action maps). Layout sections and inventory item tables
20
+ * nested in component values are resolved inline; `null` for other components.
21
+ *
22
+ * @category GraphQL Queries
23
+ */
24
+ export declare const GET_ENTITY = "\n query GetEntity($address: SuiAddress!, $cursor: String, $table_first: Int!) {\n latestVersion: objectVersions(last: 1, address: $address) {\n nodes { version }\n }\n object(address: $address) {\n asMoveObject {\n contents { type { repr } json }\n }\n dynamicFields(after: $cursor) {\n pageInfo { hasNextPage endCursor }\n nodes {\n contents {\n name: extract(path: \"name\") { type { repr } json }\n value: extract(path: \"value\") {\n type { repr }\n json\n sections: extract(path: \"inner.sections.id\") {\n asAddress {\n addressAt {\n dynamicFields(first: $table_first) {\n pageInfo { hasNextPage endCursor }\n nodes {\n name { type { repr } json }\n value { ... on MoveValue { type { repr } json } }\n }\n }\n }\n }\n }\n items: extract(path: \"inner.items.balances.id\") {\n asAddress {\n addressAt {\n dynamicFields(first: $table_first) {\n pageInfo { hasNextPage endCursor }\n nodes {\n name { type { repr } json }\n value { ... on MoveValue { type { repr } json } }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
25
+ /**
26
+ * One page of a Move table's entries (the dynamic fields of its UID).
27
+ *
28
+ * @category GraphQL Queries
29
+ */
30
+ export declare const GET_TABLE_ENTRIES = "\n query GetTableEntries($address: SuiAddress!, $first: Int!, $after: String) {\n address(address: $address) {\n dynamicFields(first: $first, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes {\n name { type { repr } json }\n value { ... on MoveValue { type { repr } json } }\n }\n }\n }\n }\n";
31
+ /**
32
+ * Latest version of an object; a cheap change check before a full fetch.
33
+ *
34
+ * @category GraphQL Queries
35
+ */
36
+ export declare const GET_OBJECT_LATEST_VERSION = "\n query GetObjectLatestVersion($address: SuiAddress!) {\n latestVersion: objectVersions(last: 1, address: $address) {\n nodes { version }\n }\n }\n";
37
+ /**
38
+ * Owner of an object. Objects transferred to another object's id (e.g. an
39
+ * AccessCap parked on a Character) report an AddressOwner of that object's id.
40
+ *
41
+ * @category GraphQL Queries
42
+ */
43
+ export declare const GET_OBJECT_OWNER = "\n query GetObjectOwner($address: SuiAddress!) {\n object(address: $address) {\n owner {\n __typename\n ... on AddressOwner { address { address } }\n ... on ObjectOwner { address { address } }\n }\n }\n }\n";
44
+ /**
45
+ * Query to get an object's owner and their owned objects of a specific type
46
+ * Useful for finding related objects (e.g., getting a character's assemblies)
47
+ * Returns BCS-encoded data only
48
+ *
49
+ * @category GraphQL Queries
50
+ * @deprecated Walks `object.owner`, which is empty for shared `Entity` objects. Find a wallet's entities with `getOwnedObjectsByType` on the `AccessCap` type instead.
51
+ */
52
+ export declare const GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE = "\n query GetObjectOwnerAndOwnedObjectByType($object: SuiAddress!, $owned_object_type: String) {\n object(address: $object) {\n owner {\n ... on AddressOwner {\n address {\n address\n objects(\n filter: {\n type: $owned_object_type\n }\n ) {\n nodes {\n contents {\n bcs\n }\n previousTransaction {\n effects {\n timestamp\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
53
+ /**
54
+ * Query to get an object's owner and their owned objects of a specific type
55
+ * Returns both BCS and JSON-decoded data for easier consumption
56
+ *
57
+ * @category GraphQL Queries
58
+ * @deprecated Walks `object.owner`, which is empty for shared `Entity` objects. Find a wallet's entities with `getOwnedObjectsByType` on the `AccessCap` type instead.
59
+ */
60
+ export declare const GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON = "\n query GetObjectOwnerAndOwnedObjectWithJson($object: SuiAddress!, $owned_object_type: String) {\n object(address: $object) {\n owner {\n ... on AddressOwner {\n address {\n address\n objects(\n filter: {\n type: $owned_object_type\n }\n ) {\n nodes {\n address\n contents {\n json\n bcs\n }\n previousTransaction {\n effects {\n timestamp\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
61
+ /**
62
+ * Query to get full object details with JSON contents
63
+ * Used to fetch character details after getting the character ID from OwnerCap
64
+ *
65
+ * @category GraphQL Queries
66
+ */
67
+ export declare const GET_OBJECT_WITH_JSON = "\n query GetObjectWithJson($address: SuiAddress!) {\n object(address: $address) {\n address\n version\n digest\n asMoveObject {\n contents {\n type {\n repr\n }\n json\n bcs\n }\n }\n }\n }\n";
68
+ /**
69
+ * Query to get all objects of a specific type owned by an address
70
+ * Returns object addresses only (lightweight)
71
+ *
72
+ * @category GraphQL Queries
73
+ */
74
+ export declare const GET_OWNED_OBJECTS_BY_TYPE = "\n query GetOwnedObjectsByType($owner: SuiAddress!, $object_type: String) {\n address(address: $owner) {\n objects(\n filter: {\n type: $object_type\n }\n ) {\n nodes {\n address\n }\n }\n }\n }\n";
75
+ /**
76
+ * Query for fetching objects owned by an address filtered by package
77
+ * Returns full object data with dynamic fields
78
+ *
79
+ * @category GraphQL Queries
80
+ */
81
+ export declare const GET_OWNED_OBJECTS_BY_PACKAGE = "\n query GetOwnedObjectsByPackage($owner: SuiAddress!, $packageId: SuiAddress!) {\n objects(\n filter: {\n owner: $owner\n type: { package: $packageId }\n }\n ) {\n nodes {\n address\n version\n asMoveObject {\n contents {\n json\n }\n dynamicFields {\n nodes {\n contents {\n json\n type {\n layout\n }\n }\n name {\n json\n type {\n repr\n }\n }\n }\n }\n }\n }\n }\n }\n";
82
+ /**
83
+ * Query to get events of a Move event type, oldest first.
84
+ * Use with caution - may return many results
85
+ *
86
+ * @category GraphQL Queries
87
+ */
88
+ export declare const GET_EVENTS_BY_TYPE = "\n query GetEventsByType($event_type: String, $first: Int, $after: String) {\n events(\n filter: {\n type: $event_type\n }\n first: $first\n after: $after\n ) {\n nodes {\n sequenceNumber\n timestamp\n contents {\n json\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n";
89
+ /**
90
+ * Query to get a singleton object by its type
91
+ * Returns the first object of the specified type (useful for global/singleton objects)
92
+ *
93
+ * @category GraphQL Queries
94
+ */
95
+ export declare const GET_SINGLETON_OBJECT_BY_TYPE = "\n query GetSingletonObjectByType($object_type: String) {\n objects(\n filter: {\n type: $object_type\n }\n first: 1\n ) {\n nodes {\n address\n }\n }\n }\n";
96
+ /**
97
+ * Query to get all objects of a specific type (global search)
98
+ * Use with caution - may return many results
99
+ *
100
+ * @category GraphQL Queries
101
+ */
102
+ export declare const GET_OBJECTS_BY_TYPE = "\n query GetObjectsByType($object_type: String, $first: Int, $after: String) {\n objects(\n filter: {\n type: $object_type\n }\n first: $first\n after: $after\n ) {\n nodes {\n address\n version\n asMoveObject {\n contents {\n json\n type {\n repr\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n";
103
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../graphql/queries.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,mRAgBjC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,mfA0B1C,CAAA;AAMD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,6mDAiDtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,+WAY7B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,sKAMrC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,0PAU5B,CAAA;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,0CAA0C,+oBA4BtD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4CAA4C,ksBA8BxD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,kSAiBhC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,8QAcrC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,wrBAmCxC,CAAA;AAMD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,0YAsB9B,CAAA;AAMD;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,mNAaxC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,qeA2B/B,CAAA"}