@0xobelisk/graphql-client 1.2.0-pre.99 → 2.0.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/LICENSE ADDED
@@ -0,0 +1,92 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Obelisk Labs
11
+
12
+ Licensed Work: Dubhe
13
+ The Licensed Work is (c) 2023 Obelisk Labs
14
+
15
+ -----------------------------------------------------------------------------
16
+
17
+ Terms
18
+
19
+ The Licensor hereby grants you the right to copy, modify, create derivative
20
+ works, redistribute, and make non-production use of the Licensed Work. The
21
+ Licensor may make an Additional Use Grant, above, permitting limited
22
+ production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly
25
+ available distribution of a specific version of the Licensed Work under this
26
+ License, whichever comes first, the Licensor hereby grants you rights under
27
+ the terms of the Change License, and the rights granted in the paragraph
28
+ above terminate.
29
+
30
+ If your use of the Licensed Work does not comply with the requirements
31
+ currently in effect as described in this License, you must purchase a
32
+ commercial license from the Licensor, its affiliated entities, or authorized
33
+ resellers, or you must refrain from using the Licensed Work.
34
+
35
+ All copies of the original and modified Licensed Work, and derivative works
36
+ of the Licensed Work, are subject to this License. This License applies
37
+ separately for each version of the Licensed Work and the Change Date may vary
38
+ for each version of the Licensed Work released by Licensor.
39
+
40
+ You must conspicuously display this License on each original or modified copy
41
+ of the Licensed Work. If you receive the Licensed Work in original or
42
+ modified form from a third party, the terms and conditions set forth in this
43
+ License apply to your use of that work.
44
+
45
+ Any use of the Licensed Work in violation of this License will automatically
46
+ terminate your rights under this License for the current and all other
47
+ versions of the Licensed Work.
48
+
49
+ This License does not grant you any right in any trademark or logo of
50
+ Licensor or its affiliates (provided that you may use a trademark or logo of
51
+ Licensor as expressly required by this License).
52
+
53
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
54
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
55
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
56
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
57
+ TITLE.
58
+
59
+ MariaDB hereby grants you permission to use this License’s text to license
60
+ your works, and to refer to it using the trademark "Business Source License",
61
+ as long as you comply with the Covenants of Licensor below.
62
+
63
+ -----------------------------------------------------------------------------
64
+
65
+ Covenants of Licensor
66
+
67
+ In consideration of the right to use this License’s text and the "Business
68
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
69
+ other recipients of the licensed work to be provided by Licensor:
70
+
71
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
72
+ or a license that is compatible with GPL Version 2.0 or a later version,
73
+ where "compatible" means that software provided under the Change License can
74
+ be included in a program with software provided under GPL Version 2.0 or a
75
+ later version. Licensor may specify additional Change Licenses without
76
+ limitation.
77
+
78
+ 2. To either: (a) specify an additional grant of rights to use that does not
79
+ impose any additional restriction on the right granted in this License, as
80
+ the Additional Use Grant; or (b) insert the text "None".
81
+
82
+ 3. To specify a Change Date.
83
+
84
+ 4. Not to modify this License in any other way.
85
+
86
+ -----------------------------------------------------------------------------
87
+
88
+ Notice
89
+
90
+ The Business Source License (this document, or the "License") is not an Open
91
+ Source license. However, the Licensed Work will eventually be made available
92
+ under an Open Source License, as stated in this License.
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ApolloClient, NormalizedCacheObject, Observable, OperationVariables } from '@apollo/client';
2
- import { DubheClientConfig, Connection, BaseQueryParams, OrderBy, QueryOptions, QueryResult, SubscriptionResult, SubscriptionOptions, StoreTableRow, TypedDocumentNode, MultiTableSubscriptionConfig, MultiTableSubscriptionData, ParsedTableInfo, DubheMetadata } from './types';
2
+ import { DubheClientConfig, Connection, BaseQueryParams, OrderBy, QueryOptions, QueryResult, SubscriptionResult, SubscriptionOptions, StoreTableRow, TypedDocumentNode, MultiTableSubscriptionConfig, MultiTableSubscriptionData, ParsedTableInfo, DubheMetadata, MarketplaceListingRow, DubheSessionRow, DubheUserStorageRow, DubheDappRuntimeStateRow, SceneStorageRow, SceneStorageFieldRow, ObjectStorageRow } from './types';
3
3
  export declare class DubheGraphqlClient {
4
4
  private apolloClient;
5
5
  private subscriptionClient?;
@@ -129,6 +129,84 @@ export declare class DubheGraphqlClient {
129
129
  createRealTimeDataStream<T extends StoreTableRow>(tableName: string, initialQuery?: BaseQueryParams & {
130
130
  filter?: Record<string, any>;
131
131
  }): Observable<Connection<T>>;
132
+ /**
133
+ * Query marketplace listings indexed by the Dubhe indexer.
134
+ * Uses the marketplace_listings PostgreSQL table (exposed as dubheMarketplaceListings in GraphQL).
135
+ * The record_type field is pre-decoded text ("wheat", "corn", …) and status tracks
136
+ * active/sold/cancelled directly — no extra RPC calls needed.
137
+ */
138
+ getMarketplaceListings(options?: {
139
+ dappKey?: string;
140
+ status?: 'listed' | 'sold' | 'cancelled' | 'expired';
141
+ recordType?: string;
142
+ seller?: string;
143
+ first?: number;
144
+ after?: string;
145
+ }): Promise<Connection<MarketplaceListingRow>>;
146
+ /**
147
+ * Query session keys indexed by the Dubhe indexer (dubheSessions in GraphQL).
148
+ */
149
+ getDubheSessions(options?: {
150
+ dappKey?: string;
151
+ canonical?: string;
152
+ active?: boolean;
153
+ first?: number;
154
+ after?: string;
155
+ }): Promise<Connection<DubheSessionRow>>;
156
+ /**
157
+ * Query user storage registrations indexed by the Dubhe indexer (dubheUserStorages in GraphQL).
158
+ */
159
+ getDubheUserStorages(options?: {
160
+ dappKey?: string;
161
+ canonicalOwner?: string;
162
+ first?: number;
163
+ after?: string;
164
+ }): Promise<Connection<DubheUserStorageRow>>;
165
+ /**
166
+ * Query SceneStorage system rows indexed by the Dubhe indexer
167
+ * (scene_storages table, exposed as dubheSceneStorages in GraphQL).
168
+ * Field values live in the companion scene_storage_fields table —
169
+ * see getSceneStorageFields.
170
+ */
171
+ getSceneStorages(options?: {
172
+ dappKey?: string;
173
+ sceneType?: string;
174
+ sceneId?: string;
175
+ isDestroyed?: boolean;
176
+ first?: number;
177
+ after?: string;
178
+ }): Promise<Connection<SceneStorageRow>>;
179
+ /**
180
+ * Query raw field rows of SceneStorages (scene_storage_fields table,
181
+ * exposed as dubheSceneStorageFields in GraphQL). Values are hex-encoded
182
+ * BCS — decode with the decoders exported from this package.
183
+ */
184
+ getSceneStorageFields(options?: {
185
+ dappKey?: string;
186
+ sceneIds?: string[];
187
+ sceneId?: string;
188
+ fieldName?: string;
189
+ isDeleted?: boolean;
190
+ first?: number;
191
+ after?: string;
192
+ }): Promise<Connection<SceneStorageFieldRow>>;
193
+ /**
194
+ * Query ObjectStorage system rows indexed by the Dubhe indexer
195
+ * (object_storages table, exposed as dubheObjectStorages in GraphQL).
196
+ */
197
+ getObjectStorages(options?: {
198
+ dappKey?: string;
199
+ objectType?: string;
200
+ objectId?: string;
201
+ isDestroyed?: boolean;
202
+ first?: number;
203
+ after?: string;
204
+ }): Promise<Connection<ObjectStorageRow>>;
205
+ /**
206
+ * Query DApp runtime state (credit pool, admin, package version, etc.).
207
+ * Exposed as dubheDappRuntimeStates in GraphQL.
208
+ */
209
+ getDubheDappRuntimeState(dappKey: string): Promise<DubheDappRuntimeStateRow | null>;
132
210
  private getFilterTypeName;
133
211
  private getOrderByTypeName;
134
212
  /**
@@ -217,6 +295,48 @@ export declare class DubheGraphqlClient {
217
295
  * Convert table fields to GraphQL query string
218
296
  */
219
297
  private convertTableFields;
298
+ /** Latest DApp fee state snapshot (credit_pool, total_settled, fee rates). */
299
+ getDappFeeState(): Promise<{
300
+ entityId: string;
301
+ baseFeePerWrite: string;
302
+ bytesFeePerByte: string;
303
+ freeCredit: string;
304
+ creditPool: string;
305
+ totalSettled: string;
306
+ updatedAtTimestampMs: string;
307
+ } | null>;
308
+ /** Latest DApp revenue balance (USER_PAYS mode collected revenue). */
309
+ getDappRevenueState(): Promise<{
310
+ entityId: string;
311
+ dappRevenue: string;
312
+ coinType: string;
313
+ updatedAtTimestampMs: string;
314
+ } | null>;
315
+ /** Latest DApp runtime state (admin, settlement mode, last event). */
316
+ getDappRuntimeState(): Promise<{
317
+ dappKey: string;
318
+ admin: string;
319
+ paused: boolean;
320
+ settlementMode: number;
321
+ creditPool: string;
322
+ writeFeeShareBps: number;
323
+ lastRuntimeEvent: string;
324
+ lastRuntimeActor: string;
325
+ lastRuntimeAmount: string;
326
+ } | null>;
327
+ /** Marketplace fee records (one row per listing sold). */
328
+ getDappMarketplaceFees(options?: {
329
+ first?: number;
330
+ after?: string;
331
+ }): Promise<Connection<{
332
+ dappKey: string;
333
+ listingId: string;
334
+ coinType: string;
335
+ totalFee: string;
336
+ treasuryAmount: string;
337
+ dappAmount: string;
338
+ updatedAtCheckpoint: string;
339
+ }>>;
220
340
  }
221
341
  export declare function createDubheGraphqlClient(config: DubheClientConfig): DubheGraphqlClient;
222
342
  export declare const QueryBuilders: {
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Minimal BCS decoders for indexer raw values.
3
+ *
4
+ * The Dubhe indexer stores scene/object field values and marketplace record
5
+ * data as hex-encoded BCS bytes (e.g. "0x0c00000000000000" for u64 12).
6
+ * These helpers decode the primitive types commonly stored in system tables.
7
+ */
8
+ export declare const ZERO_ADDRESS: string;
9
+ export declare function hexToBytes(hex: string): Uint8Array;
10
+ export declare function decodeU8(hex: string): number;
11
+ export declare function decodeU16(hex: string): number;
12
+ export declare function decodeU32(hex: string): number;
13
+ export declare function decodeU64(hex: string): bigint;
14
+ export declare function decodeU128(hex: string): bigint;
15
+ export declare function decodeBool(hex: string): boolean;
16
+ export declare function decodeAddress(hex: string): string;
17
+ export declare function decodeVectorAddress(hex: string): string[];
18
+ /** Decode a BCS ascii/utf8 String (ULEB length prefix + bytes). */
19
+ export declare function decodeString(hex: string): string;
20
+ /**
21
+ * Marketplace recordDataRaw is a JSON array of per-field hex strings
22
+ * (non-key fields, in schema order).
23
+ */
24
+ export declare function parseRecordData(recordDataRaw: string): string[];
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { DubheGraphqlClient, createDubheGraphqlClient, QueryBuilders } from './client';
2
2
  export * from './types';
3
3
  export type * from './types';
4
+ export * from './decoders';