@evefrontier/dapp-kit 0.1.0
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.
- package/README.md +53 -0
- package/config/dapp-kit.ts +20 -0
- package/config/index.ts +1 -0
- package/docs/api/.nojekyll +1 -0
- package/docs/api/assets/hierarchy.js +1 -0
- package/docs/api/assets/highlight.css +120 -0
- package/docs/api/assets/icons.js +18 -0
- package/docs/api/assets/icons.svg +1 -0
- package/docs/api/assets/main.js +60 -0
- package/docs/api/assets/navigation.js +1 -0
- package/docs/api/assets/search.js +1 -0
- package/docs/api/assets/style.css +1633 -0
- package/docs/api/classes/WalletNoAccountSelectedError.html +3 -0
- package/docs/api/classes/WalletNotConnectedError.html +3 -0
- package/docs/api/classes/WalletSponsoredTransactionNotSupportedError.html +5 -0
- package/docs/api/enums/ActionTypes.html +6 -0
- package/docs/api/enums/Assemblies.html +7 -0
- package/docs/api/enums/QueryParams.html +3 -0
- package/docs/api/enums/Severity.html +5 -0
- package/docs/api/enums/SponsoredTransactionActions.html +7 -0
- package/docs/api/enums/State.html +6 -0
- package/docs/api/enums/TYPEIDS.html +15 -0
- package/docs/api/functions/EveFrontierProvider.html +11 -0
- package/docs/api/functions/NotificationProvider.html +2 -0
- package/docs/api/functions/SmartObjectProvider.html +10 -0
- package/docs/api/functions/VaultProvider.html +1 -0
- package/docs/api/functions/abbreviateAddress.html +11 -0
- package/docs/api/functions/assertAssemblyType.html +9 -0
- package/docs/api/functions/clickToCopy.html +1 -0
- package/docs/api/functions/executeGraphQLQuery.html +12 -0
- package/docs/api/functions/findOwnerByAddress.html +5 -0
- package/docs/api/functions/formatDuration.html +8 -0
- package/docs/api/functions/formatM3.html +8 -0
- package/docs/api/functions/getAssemblyType.html +4 -0
- package/docs/api/functions/getAssemblyTypeApiString.html +2 -0
- package/docs/api/functions/getAssemblyWithOwner.html +18 -0
- package/docs/api/functions/getCharacterOwnerCapType.html +3 -0
- package/docs/api/functions/getCommonItems.html +1 -0
- package/docs/api/functions/getDappUrl.html +7 -0
- package/docs/api/functions/getDatahubGameInfo.html +13 -0
- package/docs/api/functions/getEnv.html +1 -0
- package/docs/api/functions/getEveWorldPackageId.html +4 -0
- package/docs/api/functions/getObjectByAddress.html +9 -0
- package/docs/api/functions/getObjectId.html +4 -0
- package/docs/api/functions/getObjectOwnerAndOwnedObjectsByType.html +10 -0
- package/docs/api/functions/getObjectRegistryType.html +3 -0
- package/docs/api/functions/getObjectWithDynamicFields.html +10 -0
- package/docs/api/functions/getObjectWithJson.html +9 -0
- package/docs/api/functions/getObjectsByType.html +12 -0
- package/docs/api/functions/getOwnedObjectsByPackage.html +10 -0
- package/docs/api/functions/getOwnedObjectsByType.html +10 -0
- package/docs/api/functions/getRegistryAddress.html +3 -0
- package/docs/api/functions/getSingletonObjectByType.html +9 -0
- package/docs/api/functions/getSponsoredTransactionFeature.html +11 -0
- package/docs/api/functions/getSuiGraphqlEndpoint.html +4 -0
- package/docs/api/functions/getTxUrl.html +8 -0
- package/docs/api/functions/getVolumeM3.html +5 -0
- package/docs/api/functions/hasSponsoredTransactionFeature.html +3 -0
- package/docs/api/functions/isOwner.html +10 -0
- package/docs/api/functions/parseErrorFromMessage.html +1 -0
- package/docs/api/functions/parseStatus.html +2 -0
- package/docs/api/functions/parseURL.html +1 -0
- package/docs/api/functions/removeTrailingZeros.html +1 -0
- package/docs/api/functions/transformToAssembly.html +5 -0
- package/docs/api/functions/transformToCharacter.html +2 -0
- package/docs/api/functions/useConnection.html +21 -0
- package/docs/api/functions/useNotification.html +28 -0
- package/docs/api/functions/useSmartObject.html +26 -0
- package/docs/api/functions/useSponsoredTransaction.html +50 -0
- package/docs/api/functions/walletSupportsSponsoredTransaction.html +13 -0
- package/docs/api/hierarchy.html +1 -0
- package/docs/api/index.html +26 -0
- package/docs/api/interfaces/AddressOwner.html +2 -0
- package/docs/api/interfaces/AddressOwnerWithJson.html +2 -0
- package/docs/api/interfaces/AssemblyProperties.html +14 -0
- package/docs/api/interfaces/CharacterInfo.html +8 -0
- package/docs/api/interfaces/DatahubGameInfo.html +30 -0
- package/docs/api/interfaces/DetailedAssemblyResponse.html +14 -0
- package/docs/api/interfaces/DetailedSmartCharacterResponse.html +7 -0
- package/docs/api/interfaces/DynamicFieldNode.html +3 -0
- package/docs/api/interfaces/EphemeralInventory.html +6 -0
- package/docs/api/interfaces/EveFrontierSponsoredTransactionFeature.html +7 -0
- package/docs/api/interfaces/GameTypeResponse.html +13 -0
- package/docs/api/interfaces/GateModule.html +5 -0
- package/docs/api/interfaces/GetObjectByAddressResponse.html +2 -0
- package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsResponse.html +2 -0
- package/docs/api/interfaces/GetObjectOwnerAndOwnedObjectsWithJsonResponse.html +2 -0
- package/docs/api/interfaces/GetObjectResponse.html +2 -0
- package/docs/api/interfaces/GetObjectWithJsonResponse.html +2 -0
- package/docs/api/interfaces/GetObjectsByTypeResponse.html +2 -0
- package/docs/api/interfaces/GetOwnedObjectsByPackageResponse.html +2 -0
- package/docs/api/interfaces/GetOwnedObjectsByTypeResponse.html +2 -0
- package/docs/api/interfaces/GetSingletonObjectByTypeResponse.html +2 -0
- package/docs/api/interfaces/GraphQLResponse.html +3 -0
- package/docs/api/interfaces/InventoryItem.html +8 -0
- package/docs/api/interfaces/ManufacturingModule.html +2 -0
- package/docs/api/interfaces/MoveObjectContents.html +4 -0
- package/docs/api/interfaces/MoveObjectData.html +3 -0
- package/docs/api/interfaces/NetworkNodeModule.html +7 -0
- package/docs/api/interfaces/NotificationContextType.html +4 -0
- package/docs/api/interfaces/NotificationState.html +6 -0
- package/docs/api/interfaces/Notify.html +6 -0
- package/docs/api/interfaces/ObjectWithContentsNode.html +4 -0
- package/docs/api/interfaces/OwnedObjectAddressNode.html +2 -0
- package/docs/api/interfaces/OwnedObjectFullNode.html +4 -0
- package/docs/api/interfaces/OwnedObjectNode.html +3 -0
- package/docs/api/interfaces/OwnedObjectNodeWithJson.html +4 -0
- package/docs/api/interfaces/OwnerCapData.html +5 -0
- package/docs/api/interfaces/PageInfo.html +3 -0
- package/docs/api/interfaces/RawCharacterData.html +8 -0
- package/docs/api/interfaces/RawSuiObjectData.html +17 -0
- package/docs/api/interfaces/RefineryModule.html +2 -0
- package/docs/api/interfaces/SmartAssemblyResponse.html +11 -0
- package/docs/api/interfaces/SmartObjectContextType.html +8 -0
- package/docs/api/interfaces/SponsoredTransactionInput.html +15 -0
- package/docs/api/interfaces/SponsoredTransactionOutput.html +8 -0
- package/docs/api/interfaces/StorageModule.html +4 -0
- package/docs/api/interfaces/SuiObjectResponse.html +5 -0
- package/docs/api/interfaces/TransformOptions.html +6 -0
- package/docs/api/interfaces/TurretModule.html +2 -0
- package/docs/api/interfaces/VaultContextType.html +7 -0
- package/docs/api/modules.html +1 -0
- package/docs/api/types/AssemblyType.html +1 -0
- package/docs/api/types/ErrorType.html +5 -0
- package/docs/api/types/SendSponsoredTransactionFn.html +1 -0
- package/docs/api/types/SponsoredTransactionArgs.html +2 -0
- package/docs/api/types/SponsoredTransactionAssemblyType.html +2 -0
- package/docs/api/types/SponsoredTransactionMethod.html +2 -0
- package/docs/api/types/UseSponsoredTransactionArgs.html +3 -0
- package/docs/api/types/UseSponsoredTransactionError.html +2 -0
- package/docs/api/types/UseSponsoredTransactionMutationOptions.html +2 -0
- package/docs/api/variables/ERRORS.html +1 -0
- package/docs/api/variables/ERROR_MESSAGES.html +1 -0
- package/docs/api/variables/EVEFRONTIER_SPONSORED_TRANSACTION.html +4 -0
- package/docs/api/variables/EXCLUDED_TYPEIDS.html +1 -0
- package/docs/api/variables/GET_OBJECTS_BY_TYPE.html +3 -0
- package/docs/api/variables/GET_OBJECT_BY_ADDRESS.html +3 -0
- package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_BY_TYPE.html +4 -0
- package/docs/api/variables/GET_OBJECT_OWNER_AND_OWNED_OBJECTS_WITH_JSON.html +3 -0
- package/docs/api/variables/GET_OBJECT_WITH_DYNAMIC_FIELDS.html +4 -0
- package/docs/api/variables/GET_OBJECT_WITH_JSON.html +3 -0
- package/docs/api/variables/GET_OWNED_OBJECTS_BY_PACKAGE.html +3 -0
- package/docs/api/variables/GET_OWNED_OBJECTS_BY_TYPE.html +3 -0
- package/docs/api/variables/GET_SINGLETON_OBJECT_BY_TYPE.html +3 -0
- package/docs/api/variables/NotificationContext.html +1 -0
- package/docs/api/variables/ONE_M3.html +2 -0
- package/docs/api/variables/POLLING_INTERVAL.html +2 -0
- package/docs/api/variables/STORAGE_KEYS.html +2 -0
- package/docs/api/variables/SmartObjectContext.html +1 -0
- package/docs/api/variables/VaultContext.html +1 -0
- package/docs/api/variables/dAppKit.html +2 -0
- package/graphql/client.ts +480 -0
- package/graphql/index.ts +73 -0
- package/graphql/queries.ts +371 -0
- package/graphql/types.ts +443 -0
- package/hooks/index.ts +14 -0
- package/hooks/useConnection.ts +58 -0
- package/hooks/useNotification.ts +80 -0
- package/hooks/useSmartObject.ts +78 -0
- package/hooks/useSponsoredTransaction.ts +323 -0
- package/index.ts +162 -0
- package/package.json +48 -0
- package/providers/EveFrontierProvider.tsx +41 -0
- package/providers/NotificationProvider.tsx +115 -0
- package/providers/SmartObjectProvider.tsx +282 -0
- package/providers/VaultProvider.tsx +114 -0
- package/providers/index.ts +17 -0
- package/tsconfig.json +22 -0
- package/typedoc.json +38 -0
- package/types/global.d.ts +7 -0
- package/types/index.ts +4 -0
- package/types/sponsoredTransaction.ts +26 -0
- package/types/types.ts +113 -0
- package/types/worldApiReturnTypes.ts +166 -0
- package/utils/__tests__/mapping.test.ts +441 -0
- package/utils/constants.ts +96 -0
- package/utils/datahub.ts +76 -0
- package/utils/errors.ts +171 -0
- package/utils/index.ts +38 -0
- package/utils/mapping.ts +115 -0
- package/utils/transforms.ts +258 -0
- package/utils/utils.ts +270 -0
- package/vite-env.d.ts +16 -0
- package/wallet/features.ts +165 -0
- package/wallet/index.ts +28 -0
- package/wallet/utils.ts +117 -0
package/graphql/types.ts
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL response types for Sui object queries
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Base GraphQL Types
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
/** @category GraphQL */
|
|
10
|
+
export interface GraphQLResponse<T = unknown> {
|
|
11
|
+
data?: T;
|
|
12
|
+
errors?: Array<{
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @category GraphQL */
|
|
18
|
+
export interface PageInfo {
|
|
19
|
+
hasNextPage: boolean;
|
|
20
|
+
endCursor: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Move Object Types
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
27
|
+
/** @category GraphQL */
|
|
28
|
+
export interface MoveObjectContents {
|
|
29
|
+
json?: Record<string, unknown>;
|
|
30
|
+
bcs?: string;
|
|
31
|
+
type?: {
|
|
32
|
+
repr: string;
|
|
33
|
+
layout?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @category GraphQL */
|
|
38
|
+
export interface DynamicFieldNode {
|
|
39
|
+
contents: {
|
|
40
|
+
json: Record<string, unknown>;
|
|
41
|
+
type: {
|
|
42
|
+
layout: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
name: {
|
|
46
|
+
json: unknown;
|
|
47
|
+
type: {
|
|
48
|
+
repr: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @category GraphQL */
|
|
54
|
+
export interface MoveObjectData {
|
|
55
|
+
contents: MoveObjectContents;
|
|
56
|
+
dynamicFields?: {
|
|
57
|
+
nodes: DynamicFieldNode[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Object Response Types
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
/** @category GraphQL */
|
|
66
|
+
export interface SuiObjectResponse {
|
|
67
|
+
address?: string;
|
|
68
|
+
version?: number;
|
|
69
|
+
digest?: string;
|
|
70
|
+
asMoveObject: MoveObjectData | null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @category GraphQL */
|
|
74
|
+
export interface GetObjectResponse {
|
|
75
|
+
object?: SuiObjectResponse;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// GetObjectByAddress Response Types
|
|
80
|
+
// ============================================================================
|
|
81
|
+
|
|
82
|
+
/** @category GraphQL */
|
|
83
|
+
export interface GetObjectByAddressResponse {
|
|
84
|
+
object?: {
|
|
85
|
+
address: string;
|
|
86
|
+
version: number;
|
|
87
|
+
digest: string;
|
|
88
|
+
asMoveObject: {
|
|
89
|
+
contents: {
|
|
90
|
+
type: {
|
|
91
|
+
repr: string;
|
|
92
|
+
};
|
|
93
|
+
bcs: string;
|
|
94
|
+
};
|
|
95
|
+
} | null;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// Owner & Owned Objects Response Types
|
|
101
|
+
// ============================================================================
|
|
102
|
+
|
|
103
|
+
/** @category GraphQL */
|
|
104
|
+
export interface OwnedObjectNode {
|
|
105
|
+
contents: {
|
|
106
|
+
bcs: string;
|
|
107
|
+
};
|
|
108
|
+
previousTransaction?: {
|
|
109
|
+
effects?: {
|
|
110
|
+
timestamp?: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** @category GraphQL */
|
|
116
|
+
export interface AddressOwner {
|
|
117
|
+
address: {
|
|
118
|
+
address: string;
|
|
119
|
+
objects: {
|
|
120
|
+
nodes: OwnedObjectNode[];
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** @category GraphQL */
|
|
126
|
+
export interface GetObjectOwnerAndOwnedObjectsResponse {
|
|
127
|
+
object?: {
|
|
128
|
+
owner?: {
|
|
129
|
+
address?: AddressOwner["address"];
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Owner & Owned Objects with JSON Response Types
|
|
136
|
+
// ============================================================================
|
|
137
|
+
|
|
138
|
+
/** @category GraphQL */
|
|
139
|
+
export interface OwnedObjectNodeWithJson {
|
|
140
|
+
address: string;
|
|
141
|
+
contents: {
|
|
142
|
+
json: Record<string, unknown>;
|
|
143
|
+
bcs: string;
|
|
144
|
+
};
|
|
145
|
+
previousTransaction?: {
|
|
146
|
+
effects?: {
|
|
147
|
+
timestamp?: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** @category GraphQL */
|
|
153
|
+
export interface AddressOwnerWithJson {
|
|
154
|
+
address: {
|
|
155
|
+
address: string;
|
|
156
|
+
objects: {
|
|
157
|
+
nodes: OwnedObjectNodeWithJson[];
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** @category GraphQL */
|
|
163
|
+
export interface GetObjectOwnerAndOwnedObjectsWithJsonResponse {
|
|
164
|
+
object?: {
|
|
165
|
+
owner?: {
|
|
166
|
+
address?: AddressOwnerWithJson["address"];
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** @category GraphQL */
|
|
172
|
+
export interface GetObjectAndCharacterOwnerResponse {
|
|
173
|
+
object: {
|
|
174
|
+
asMoveObject: {
|
|
175
|
+
contents: {
|
|
176
|
+
json: Record<string, unknown>;
|
|
177
|
+
bcs: string;
|
|
178
|
+
type: {
|
|
179
|
+
repr: string;
|
|
180
|
+
};
|
|
181
|
+
extract?: {
|
|
182
|
+
asAddress?: {
|
|
183
|
+
asObject?: {
|
|
184
|
+
asMoveObject?: {
|
|
185
|
+
owner: {
|
|
186
|
+
address: {
|
|
187
|
+
objects: {
|
|
188
|
+
nodes: [
|
|
189
|
+
{
|
|
190
|
+
contents: {
|
|
191
|
+
authorizedObj: {
|
|
192
|
+
asAddress: {
|
|
193
|
+
asObject: {
|
|
194
|
+
asMoveObject: {
|
|
195
|
+
contents: {
|
|
196
|
+
json: RawCharacterData;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
contents?: {
|
|
209
|
+
json: Record<string, unknown>;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
} | null;
|
|
215
|
+
owner?: {
|
|
216
|
+
address?: {
|
|
217
|
+
address: string;
|
|
218
|
+
objects: {
|
|
219
|
+
nodes: Array<{
|
|
220
|
+
contents: {
|
|
221
|
+
json: Record<string, unknown>;
|
|
222
|
+
extract?: {
|
|
223
|
+
asAddress?: {
|
|
224
|
+
asObject?: {
|
|
225
|
+
asMoveObject?: {
|
|
226
|
+
contents?: {
|
|
227
|
+
json: Record<string, unknown>;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
}>;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
dynamicFields?: {
|
|
240
|
+
nodes: DynamicFieldNode[];
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ============================================================================
|
|
247
|
+
// GetObjectWithJson Response Types
|
|
248
|
+
// ============================================================================
|
|
249
|
+
|
|
250
|
+
/** @category GraphQL */
|
|
251
|
+
export interface GetObjectWithJsonResponse {
|
|
252
|
+
object?: {
|
|
253
|
+
address: string;
|
|
254
|
+
version: number;
|
|
255
|
+
digest: string;
|
|
256
|
+
asMoveObject: {
|
|
257
|
+
contents: {
|
|
258
|
+
type: {
|
|
259
|
+
repr: string;
|
|
260
|
+
};
|
|
261
|
+
json: Record<string, unknown>;
|
|
262
|
+
bcs: string;
|
|
263
|
+
};
|
|
264
|
+
} | null;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ============================================================================
|
|
269
|
+
// GetOwnedObjectsByType Response Types
|
|
270
|
+
// ============================================================================
|
|
271
|
+
|
|
272
|
+
/** @category GraphQL */
|
|
273
|
+
export interface OwnedObjectAddressNode {
|
|
274
|
+
address: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** @category GraphQL */
|
|
278
|
+
export interface GetOwnedObjectsByTypeResponse {
|
|
279
|
+
address?: {
|
|
280
|
+
objects: {
|
|
281
|
+
nodes: OwnedObjectAddressNode[];
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ============================================================================
|
|
287
|
+
// GetOwnedObjectsByPackage Response Types
|
|
288
|
+
// ============================================================================
|
|
289
|
+
|
|
290
|
+
/** @category GraphQL */
|
|
291
|
+
export interface OwnedObjectFullNode {
|
|
292
|
+
address: string;
|
|
293
|
+
version: number;
|
|
294
|
+
asMoveObject: MoveObjectData | null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** @category GraphQL */
|
|
298
|
+
export interface GetOwnedObjectsByPackageResponse {
|
|
299
|
+
objects: {
|
|
300
|
+
nodes: OwnedObjectFullNode[];
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// ============================================================================
|
|
305
|
+
// Singleton & Type-based Query Response Types
|
|
306
|
+
// ============================================================================
|
|
307
|
+
|
|
308
|
+
/** @category GraphQL */
|
|
309
|
+
export interface GetSingletonObjectByTypeResponse {
|
|
310
|
+
objects: {
|
|
311
|
+
nodes: OwnedObjectAddressNode[];
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** @category GraphQL */
|
|
316
|
+
export interface ObjectWithContentsNode {
|
|
317
|
+
address: string;
|
|
318
|
+
version: number;
|
|
319
|
+
asMoveObject: {
|
|
320
|
+
contents: {
|
|
321
|
+
json: Record<string, unknown>;
|
|
322
|
+
type: {
|
|
323
|
+
repr: string;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
} | null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** @category GraphQL */
|
|
330
|
+
export interface GetObjectsByTypeResponse {
|
|
331
|
+
objects: {
|
|
332
|
+
nodes: ObjectWithContentsNode[];
|
|
333
|
+
pageInfo: PageInfo;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ============================================================================
|
|
338
|
+
// EVE Frontier Specific Types
|
|
339
|
+
// ============================================================================
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Raw Sui object data structure returned from the EVE Frontier package
|
|
343
|
+
*
|
|
344
|
+
* @category GraphQL
|
|
345
|
+
*/
|
|
346
|
+
export interface RawSuiObjectData {
|
|
347
|
+
id: string;
|
|
348
|
+
type_id: string;
|
|
349
|
+
extension: unknown;
|
|
350
|
+
inventory_keys?: string[];
|
|
351
|
+
key?: {
|
|
352
|
+
item_id: string;
|
|
353
|
+
tenant: string;
|
|
354
|
+
};
|
|
355
|
+
location?: {
|
|
356
|
+
location_hash: string;
|
|
357
|
+
structure_id: string;
|
|
358
|
+
};
|
|
359
|
+
metadata?: {
|
|
360
|
+
assembly_id: string;
|
|
361
|
+
description: string;
|
|
362
|
+
name: string;
|
|
363
|
+
url: string;
|
|
364
|
+
};
|
|
365
|
+
owner_cap_id?: string;
|
|
366
|
+
status?: {
|
|
367
|
+
assembly_id?: string;
|
|
368
|
+
item_id?: string;
|
|
369
|
+
status: {
|
|
370
|
+
"@variant": string;
|
|
371
|
+
};
|
|
372
|
+
type_id?: string;
|
|
373
|
+
};
|
|
374
|
+
/** Fuel data for Network Nodes */
|
|
375
|
+
fuel?: {
|
|
376
|
+
max_capacity: string;
|
|
377
|
+
burn_rate_in_ms: string;
|
|
378
|
+
type_id: string;
|
|
379
|
+
unit_volume: string;
|
|
380
|
+
quantity: string;
|
|
381
|
+
is_burning: boolean;
|
|
382
|
+
previous_cycle_elapsed_time: string;
|
|
383
|
+
burn_start_time: string;
|
|
384
|
+
last_updated: string;
|
|
385
|
+
};
|
|
386
|
+
/** Energy source data for Network Nodes */
|
|
387
|
+
energy_source?: {
|
|
388
|
+
max_energy_production: string;
|
|
389
|
+
current_energy_production: string;
|
|
390
|
+
total_reserved_energy: string;
|
|
391
|
+
};
|
|
392
|
+
/** Connected assembly IDs for Network Nodes */
|
|
393
|
+
connected_assembly_ids?: string[];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* OwnerCap JSON structure - returned from Character OwnerCap query
|
|
398
|
+
* Contains the authorized_object_id which is the Character ID
|
|
399
|
+
*
|
|
400
|
+
* @category GraphQL
|
|
401
|
+
*/
|
|
402
|
+
export interface OwnerCapData {
|
|
403
|
+
authorized_object_id: string;
|
|
404
|
+
id: string;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Raw Character data structure from the EVE Frontier package
|
|
409
|
+
*
|
|
410
|
+
* @category GraphQL
|
|
411
|
+
*/
|
|
412
|
+
export interface RawCharacterData {
|
|
413
|
+
id: `0x${string}`;
|
|
414
|
+
key: {
|
|
415
|
+
item_id: string;
|
|
416
|
+
tenant: string;
|
|
417
|
+
};
|
|
418
|
+
tribe_id: number;
|
|
419
|
+
character_address: `0x${string}`;
|
|
420
|
+
metadata: {
|
|
421
|
+
assembly_id: `0x${string}`;
|
|
422
|
+
name: string;
|
|
423
|
+
description: string;
|
|
424
|
+
url: string;
|
|
425
|
+
};
|
|
426
|
+
owner_cap_id: `0x${string}`;
|
|
427
|
+
// Additional fields that may be present
|
|
428
|
+
[key: string]: unknown;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Processed character/owner information
|
|
433
|
+
*
|
|
434
|
+
* @category GraphQL
|
|
435
|
+
*/
|
|
436
|
+
export interface CharacterInfo {
|
|
437
|
+
id: string;
|
|
438
|
+
address: string;
|
|
439
|
+
name: string;
|
|
440
|
+
tribeId: number;
|
|
441
|
+
characterId: number;
|
|
442
|
+
_raw?: RawCharacterData;
|
|
443
|
+
}
|
package/hooks/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { useConnection } from "./useConnection";
|
|
2
|
+
export { useSmartObject } from "./useSmartObject";
|
|
3
|
+
export { useNotification } from "./useNotification";
|
|
4
|
+
export {
|
|
5
|
+
useSponsoredTransaction,
|
|
6
|
+
WalletSponsoredTransactionNotSupportedError,
|
|
7
|
+
WalletNotConnectedError,
|
|
8
|
+
WalletNoAccountSelectedError,
|
|
9
|
+
} from "./useSponsoredTransaction";
|
|
10
|
+
export type {
|
|
11
|
+
UseSponsoredTransactionError,
|
|
12
|
+
UseSponsoredTransactionArgs,
|
|
13
|
+
UseSponsoredTransactionMutationOptions,
|
|
14
|
+
} from "./useSponsoredTransaction";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { VaultContext, VaultContextType } from "../providers/VaultProvider";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hook for managing wallet connection state in EVE Frontier dApps.
|
|
6
|
+
*
|
|
7
|
+
* Provides access to wallet connection status, current account information,
|
|
8
|
+
* and methods to connect/disconnect wallets. Automatically detects EVE Vault
|
|
9
|
+
* wallet availability.
|
|
10
|
+
*
|
|
11
|
+
* @category Hooks
|
|
12
|
+
* @returns Object containing wallet state and connection methods:
|
|
13
|
+
* - `currentAccount` - The currently connected wallet account (or null)
|
|
14
|
+
* - `walletAddress` - The connected wallet's address string
|
|
15
|
+
* - `isConnected` - Boolean indicating connection status
|
|
16
|
+
* - `hasEveVault` - Boolean indicating if EVE Vault wallet is available
|
|
17
|
+
* - `handleConnect` - Function to initiate wallet connection
|
|
18
|
+
* - `handleDisconnect` - Function to disconnect the wallet
|
|
19
|
+
* @throws {Error} If used outside of `EveFrontierProvider`
|
|
20
|
+
*
|
|
21
|
+
* @example Basic usage
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { useConnection } from '@evefrontier/dapp-kit';
|
|
24
|
+
*
|
|
25
|
+
* const WalletButton = () => {
|
|
26
|
+
* const { isConnected, walletAddress, handleConnect, handleDisconnect } = useConnection();
|
|
27
|
+
*
|
|
28
|
+
* if (isConnected) {
|
|
29
|
+
* return (
|
|
30
|
+
* <div>
|
|
31
|
+
* <p>Connected: {walletAddress}</p>
|
|
32
|
+
* <button onClick={handleDisconnect}>Disconnect</button>
|
|
33
|
+
* </div>
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* return <button onClick={handleConnect}>Connect Wallet</button>;
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Check for EVE Vault
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const { hasEveVault, handleConnect } = useConnection();
|
|
44
|
+
*
|
|
45
|
+
* return (
|
|
46
|
+
* <button onClick={handleConnect} disabled={!hasEveVault}>
|
|
47
|
+
* {hasEveVault ? 'Connect EVE Vault' : 'Please install EVE Vault'}
|
|
48
|
+
* </button>
|
|
49
|
+
* );
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function useConnection(): VaultContextType {
|
|
53
|
+
const context = useContext(VaultContext);
|
|
54
|
+
if (!context) {
|
|
55
|
+
throw new Error("useConnection must be used within an EveFrontierProvider");
|
|
56
|
+
}
|
|
57
|
+
return context;
|
|
58
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { NotificationContext, NotificationContextType } from "../providers/NotificationProvider";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hook for displaying user notifications in EVE Frontier dApps.
|
|
6
|
+
*
|
|
7
|
+
* Provides a simple notification system for displaying success, error, warning,
|
|
8
|
+
* and info messages to users. Commonly used after transaction completions
|
|
9
|
+
* or to display important status updates.
|
|
10
|
+
*
|
|
11
|
+
* @category Hooks
|
|
12
|
+
* @returns Object containing notification state and methods:
|
|
13
|
+
* - `notify` - Function to trigger a notification
|
|
14
|
+
* - `notification` - Current notification state object with:
|
|
15
|
+
* - `isOpen` - Whether notification is visible
|
|
16
|
+
* - `message` - The notification message
|
|
17
|
+
* - `severity` - The notification type (success, error, warning, info)
|
|
18
|
+
* - `txHash` - Optional transaction hash for linking
|
|
19
|
+
* - `handleClose` - Function to close the notification
|
|
20
|
+
* @throws {Error} If used outside of `EveFrontierProvider`
|
|
21
|
+
*
|
|
22
|
+
* @example Basic notification
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { useNotification, Severity } from '@evefrontier/dapp-kit';
|
|
25
|
+
*
|
|
26
|
+
* const MyComponent = () => {
|
|
27
|
+
* const { notify } = useNotification();
|
|
28
|
+
*
|
|
29
|
+
* const showSuccess = () => {
|
|
30
|
+
* notify({ type: Severity.Success, message: 'Operation completed!' });
|
|
31
|
+
* };
|
|
32
|
+
*
|
|
33
|
+
* return <button onClick={showSuccess}>Complete</button>;
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Transaction notification with hash
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const { notify } = useNotification();
|
|
40
|
+
*
|
|
41
|
+
* const handleTransaction = async () => {
|
|
42
|
+
* try {
|
|
43
|
+
* const result = await sendTransaction();
|
|
44
|
+
* notify({
|
|
45
|
+
* type: Severity.Success,
|
|
46
|
+
* message: 'Transaction successful!',
|
|
47
|
+
* txHash: result.digest
|
|
48
|
+
* });
|
|
49
|
+
* } catch (error) {
|
|
50
|
+
* notify({
|
|
51
|
+
* type: Severity.Error,
|
|
52
|
+
* message: 'Transaction failed'
|
|
53
|
+
* });
|
|
54
|
+
* }
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Displaying notification UI
|
|
59
|
+
* ```tsx
|
|
60
|
+
* const { notification } = useNotification();
|
|
61
|
+
*
|
|
62
|
+
* return (
|
|
63
|
+
* <>
|
|
64
|
+
* {notification.isOpen && (
|
|
65
|
+
* <Alert severity={notification.severity} onClose={notification.handleClose}>
|
|
66
|
+
* {notification.message}
|
|
67
|
+
* </Alert>
|
|
68
|
+
* )}
|
|
69
|
+
* </>
|
|
70
|
+
* );
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function useNotification(): NotificationContextType {
|
|
74
|
+
const context = useContext(NotificationContext);
|
|
75
|
+
if (!context) {
|
|
76
|
+
throw new Error("useNotification must be used within an EveFrontierProvider");
|
|
77
|
+
}
|
|
78
|
+
return context;
|
|
79
|
+
}
|
|
80
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
SmartObjectContext,
|
|
4
|
+
SmartObjectContextType,
|
|
5
|
+
} from "../providers/SmartObjectProvider";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook for accessing smart assembly data from the Sui GraphQL Indexer.
|
|
9
|
+
*
|
|
10
|
+
* Provides reactive access to the currently selected smart assembly (Smart Storage Unit,
|
|
11
|
+
* Smart Turret, Smart Gate, Network Node, etc.) with automatic polling for updates.
|
|
12
|
+
* The assembly ID is determined from environment variables (`VITE_ITEM_ID`)
|
|
13
|
+
* or URL query parameters (`?itemId=` and `?tenant=`).
|
|
14
|
+
*
|
|
15
|
+
* @category Hooks
|
|
16
|
+
* @returns Object containing assembly state and methods:
|
|
17
|
+
* - `assembly` - The transformed assembly data (or null if not loaded)
|
|
18
|
+
* - `character` - The owner character information (or null)
|
|
19
|
+
* - `selectedObjectId` - The current assembly's Sui object ID
|
|
20
|
+
* - `loading` - Boolean indicating if data is being fetched
|
|
21
|
+
* - `error` - Error message string (or null)
|
|
22
|
+
* - `setSelectedObjectId` - Function to change the selected assembly
|
|
23
|
+
* - `refetch` - Function to manually refresh assembly data
|
|
24
|
+
* @throws {Error} If used outside of `EveFrontierProvider`
|
|
25
|
+
*
|
|
26
|
+
* @example Basic usage
|
|
27
|
+
* ```tsx
|
|
28
|
+
* import { useSmartObject } from '@evefrontier/dapp-kit';
|
|
29
|
+
*
|
|
30
|
+
* const AssemblyInfo = () => {
|
|
31
|
+
* const { assembly, loading, error, refetch } = useSmartObject();
|
|
32
|
+
*
|
|
33
|
+
* if (loading) return <div>Loading...</div>;
|
|
34
|
+
* if (error) return <div>Error: {error}</div>;
|
|
35
|
+
* if (!assembly) return <div>No assembly found</div>;
|
|
36
|
+
*
|
|
37
|
+
* return (
|
|
38
|
+
* <div>
|
|
39
|
+
* <h1>{assembly.name}</h1>
|
|
40
|
+
* <p>Type: {assembly.type}</p>
|
|
41
|
+
* <p>State: {assembly.state}</p>
|
|
42
|
+
* <p>ID: {assembly.id}</p>
|
|
43
|
+
* <button onClick={refetch}>Refresh</button>
|
|
44
|
+
* </div>
|
|
45
|
+
* );
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Accessing owner character
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const { assembly, character } = useSmartObject();
|
|
52
|
+
*
|
|
53
|
+
* return (
|
|
54
|
+
* <div>
|
|
55
|
+
* <p>Assembly: {assembly?.name}</p>
|
|
56
|
+
* <p>Owner: {character?.name || 'Unknown'}</p>
|
|
57
|
+
* </div>
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example Changing the selected assembly
|
|
62
|
+
* ```tsx
|
|
63
|
+
* const { setSelectedObjectId } = useSmartObject();
|
|
64
|
+
*
|
|
65
|
+
* const handleSelectAssembly = (newId: string) => {
|
|
66
|
+
* setSelectedObjectId(newId);
|
|
67
|
+
* };
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export function useSmartObject(): SmartObjectContextType {
|
|
71
|
+
const context = useContext(SmartObjectContext);
|
|
72
|
+
if (!context) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"useSmartObject must be used within an EveFrontierProvider",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return context;
|
|
78
|
+
}
|