@fleet-sdk/blockchain-providers 0.5.0 → 0.6.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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +124 -33
- package/dist/index.d.ts +124 -33
- package/dist/index.js +241 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +241 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/ergo-graphql/ergoGraphQLProvider.ts +256 -86
- package/src/ergo-graphql/queries.ts +14 -5
- package/src/types/blockchainProvider.ts +101 -18
- package/src/utils/_tests.ts +6 -10
- package/src/utils/graphql.ts +54 -62
- package/src/utils/networking.ts +84 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @fleet-sdk/blockchain-providers
|
2
2
|
|
3
|
+
## 0.6.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 6ef2c1b: Add custom `BigInt` mapping support
|
8
|
+
- 9cdf4dd: Add transaction fetching
|
9
|
+
|
10
|
+
### Patch Changes
|
11
|
+
|
12
|
+
- 62b881b: Add exponential delay retrying strategy
|
13
|
+
- 9ed3499: Add GraphQL operation URL override
|
14
|
+
|
3
15
|
## 0.5.0
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BoxId, HexString, Base58String, TokenId, Box, BlockHeader, SignedTransaction, UnsignedTransaction,
|
1
|
+
import { BoxId, HexString, Base58String, TokenId, TransactionId, Box, DataInput, BlockHeader, SignedTransaction, UnsignedTransaction, ProverResult } from '@fleet-sdk/common';
|
2
2
|
import { ErgoAddress } from '@fleet-sdk/core';
|
3
3
|
|
4
4
|
declare global {
|
@@ -153,6 +153,18 @@ type RequireAtLeastOne<
|
|
153
153
|
Except<ObjectType, KeysType>;
|
154
154
|
|
155
155
|
type BoxSource = "blockchain" | "mempool" | "blockchain+mempool";
|
156
|
+
type BoxWhere = {
|
157
|
+
/** Base16-encoded BoxId */
|
158
|
+
boxId?: BoxId;
|
159
|
+
/** Base16-encoded ErgoTree */
|
160
|
+
ergoTree?: HexString;
|
161
|
+
/** Base58-encoded address */
|
162
|
+
address?: ErgoAddress | Base58String;
|
163
|
+
/** Base16-encoded contract template hash */
|
164
|
+
templateHash?: HexString;
|
165
|
+
/** Base16-encoded TokenId */
|
166
|
+
tokenId?: TokenId;
|
167
|
+
};
|
156
168
|
type BoxQuery<W extends BoxWhere> = {
|
157
169
|
/** The query to filter boxes. */
|
158
170
|
where: RequireAtLeastOne<W>;
|
@@ -162,23 +174,59 @@ type BoxQuery<W extends BoxWhere> = {
|
|
162
174
|
*/
|
163
175
|
from?: BoxSource;
|
164
176
|
};
|
165
|
-
type
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
boxId?: BoxId;
|
177
|
+
type UnconfirmedTransactionWhere = {
|
178
|
+
/** Base16-encoded TransactionId */
|
179
|
+
transactionId?: TransactionId;
|
180
|
+
/** Base58-encoded address */
|
181
|
+
address?: ErgoAddress | Base58String;
|
171
182
|
/** Base16-encoded ErgoTree */
|
172
183
|
ergoTree?: HexString;
|
184
|
+
};
|
185
|
+
type ConfirmedTransactionWhere = {
|
186
|
+
/** Base16-encoded TransactionId */
|
187
|
+
transactionId?: TransactionId;
|
188
|
+
/** Base16-encoded HeaderID */
|
189
|
+
headerId?: HexString;
|
173
190
|
/** Base58-encoded address */
|
174
191
|
address?: ErgoAddress | Base58String;
|
175
|
-
/** Base16-encoded
|
176
|
-
|
177
|
-
/**
|
178
|
-
|
192
|
+
/** Base16-encoded ErgoTree */
|
193
|
+
ergoTree?: HexString;
|
194
|
+
/** Min blockchain height */
|
195
|
+
minHeight?: number;
|
196
|
+
/** Only returns relevant outputs for the selected filter params */
|
197
|
+
onlyRelevantOutputs?: boolean;
|
198
|
+
};
|
199
|
+
type TransactionQuery<W extends ConfirmedTransactionWhere> = {
|
200
|
+
/** The query to filter boxes. */
|
201
|
+
where: RequireAtLeastOne<W, keyof Omit<W, "minHeight" | "onlyRelevantOutputs">>;
|
202
|
+
};
|
203
|
+
type HeaderQuery = {
|
204
|
+
take: number;
|
205
|
+
};
|
206
|
+
type ChainProviderBox<T> = Omit<Box, "value" | "assets"> & {
|
207
|
+
value: T;
|
208
|
+
assets: {
|
209
|
+
tokenId: TokenId;
|
210
|
+
amount: T;
|
211
|
+
}[];
|
212
|
+
confirmed: boolean;
|
179
213
|
};
|
180
|
-
type
|
214
|
+
type TransactionOutput<T> = Omit<ChainProviderBox<T>, "confirmed">;
|
215
|
+
type TransactionInput<T> = TransactionOutput<T> & {
|
216
|
+
spendingProof: ProverResult;
|
217
|
+
};
|
218
|
+
type ChainProviderUnconfirmedTransaction<T> = {
|
219
|
+
transactionId: TransactionId;
|
220
|
+
inputs: TransactionInput<T>[];
|
221
|
+
dataInputs: DataInput[];
|
222
|
+
outputs: TransactionOutput<T>[];
|
181
223
|
confirmed: boolean;
|
224
|
+
timestamp: number;
|
225
|
+
};
|
226
|
+
type ChainProviderConfirmedTransaction<T> = ChainProviderUnconfirmedTransaction<T> & {
|
227
|
+
height: number;
|
228
|
+
index: number;
|
229
|
+
headerId: HexString;
|
182
230
|
};
|
183
231
|
type TransactionEvaluationError = {
|
184
232
|
success: false;
|
@@ -198,15 +246,31 @@ type TransactionReductionResult = TransactionEvaluationError | TransactionReduct
|
|
198
246
|
* Represents a blockchain provider that can interact with the blockchain.
|
199
247
|
* @template B The type of the box query used by the provider.
|
200
248
|
*/
|
201
|
-
interface IBlockchainProvider<
|
249
|
+
interface IBlockchainProvider<I> {
|
202
250
|
/**
|
203
251
|
* Get boxes.
|
204
252
|
*/
|
205
|
-
getBoxes(query: BoxQuery<
|
253
|
+
getBoxes(query: BoxQuery<BoxWhere>): Promise<ChainProviderBox<I>[]>;
|
206
254
|
/**
|
207
255
|
* Stream boxes.
|
208
256
|
*/
|
209
|
-
streamBoxes(query: BoxQuery<
|
257
|
+
streamBoxes(query: BoxQuery<BoxWhere>): AsyncIterable<ChainProviderBox<I>[]>;
|
258
|
+
/**
|
259
|
+
* Stream unconfirmed transactions
|
260
|
+
*/
|
261
|
+
streamUnconfirmedTransactions(query: TransactionQuery<UnconfirmedTransactionWhere>): AsyncIterable<ChainProviderUnconfirmedTransaction<I>[]>;
|
262
|
+
/**
|
263
|
+
* Get unconfirmed transactions
|
264
|
+
*/
|
265
|
+
getUnconfirmedTransactions(query: TransactionQuery<UnconfirmedTransactionWhere>): Promise<ChainProviderUnconfirmedTransaction<I>[]>;
|
266
|
+
/**
|
267
|
+
* Stream confirmed transactions
|
268
|
+
*/
|
269
|
+
streamConfirmedTransactions(query: TransactionQuery<ConfirmedTransactionWhere>): AsyncIterable<ChainProviderConfirmedTransaction<I>[]>;
|
270
|
+
/**
|
271
|
+
* Get confirmed transactions
|
272
|
+
*/
|
273
|
+
getConfirmedTransactions(query: TransactionQuery<ConfirmedTransactionWhere>): Promise<ChainProviderConfirmedTransaction<I>[]>;
|
210
274
|
/**
|
211
275
|
* Get headers.
|
212
276
|
*/
|
@@ -225,9 +289,24 @@ interface IBlockchainProvider<B extends BoxWhere> {
|
|
225
289
|
reduceTransaction(transaction: UnsignedTransaction): Promise<TransactionReductionResult>;
|
226
290
|
}
|
227
291
|
|
228
|
-
|
229
|
-
|
230
|
-
|
292
|
+
interface ParserLike {
|
293
|
+
parse<T>(text: string): T;
|
294
|
+
stringify<T>(value: T): string;
|
295
|
+
}
|
296
|
+
type Route = {
|
297
|
+
base: string;
|
298
|
+
path: string;
|
299
|
+
query?: Record<string, unknown>;
|
300
|
+
};
|
301
|
+
type URLLike = string | Route;
|
302
|
+
type FallbackRetryOptions = {
|
303
|
+
fallbacks?: URLLike[];
|
304
|
+
} & RetryOptions;
|
305
|
+
type RetryOptions = {
|
306
|
+
attempts: number;
|
307
|
+
delay: number;
|
308
|
+
};
|
309
|
+
|
231
310
|
type GraphQLVariables = Record<string, unknown> | null;
|
232
311
|
interface GraphQLError {
|
233
312
|
message: string;
|
@@ -241,20 +320,16 @@ interface GraphQLErrorResponse {
|
|
241
320
|
errors: GraphQLError[];
|
242
321
|
}
|
243
322
|
type GraphQLResponse<T = unknown> = GraphQLSuccessResponse<T> | GraphQLErrorResponse;
|
244
|
-
type GraphQLOperation<R extends GraphQLResponse, V extends GraphQLVariables> = (variables?: V) => Promise<R>;
|
245
|
-
interface ResponseParser {
|
246
|
-
parse<T>(text: string): T;
|
247
|
-
stringify<T>(value: T): string;
|
248
|
-
}
|
323
|
+
type GraphQLOperation<R extends GraphQLResponse, V extends GraphQLVariables> = (variables?: V, url?: string) => Promise<R>;
|
249
324
|
interface GraphQLRequestOptions {
|
250
|
-
url
|
251
|
-
|
252
|
-
|
253
|
-
fetcher?: Fetcher;
|
254
|
-
credentials?: Credentials;
|
325
|
+
url?: string;
|
326
|
+
parser?: ParserLike;
|
327
|
+
retry?: FallbackRetryOptions;
|
255
328
|
throwOnNonNetworkErrors?: boolean;
|
329
|
+
httpOptions?: Omit<RequestInit, "body" | "method">;
|
256
330
|
}
|
257
331
|
|
332
|
+
type BiMapper<T> = (value: string) => T;
|
258
333
|
type GraphQLBoxWhere = BoxWhere & {
|
259
334
|
/** Base16-encoded BoxIds */
|
260
335
|
boxIds?: HexString[];
|
@@ -263,14 +338,30 @@ type GraphQLBoxWhere = BoxWhere & {
|
|
263
338
|
/** Base58-encoded addresses or `ErgoAddress` objects */
|
264
339
|
addresses?: (Base58String | ErgoAddress)[];
|
265
340
|
};
|
341
|
+
type GraphQLConfirmedTransactionWhere = ConfirmedTransactionWhere & {
|
342
|
+
transactionIds?: HexString[];
|
343
|
+
addresses?: (Base58String | ErgoAddress)[];
|
344
|
+
ergoTrees?: HexString[];
|
345
|
+
};
|
346
|
+
type GraphQLUnconfirmedTransactionWhere = UnconfirmedTransactionWhere & {
|
347
|
+
transactionIds?: HexString[];
|
348
|
+
addresses?: (Base58String | ErgoAddress)[];
|
349
|
+
ergoTrees?: HexString[];
|
350
|
+
};
|
266
351
|
type GraphQLBoxQuery = BoxQuery<GraphQLBoxWhere>;
|
267
352
|
type ErgoGraphQLRequestOptions = Omit<GraphQLRequestOptions, "throwOnNonNetworkError">;
|
268
|
-
declare class ErgoGraphQLProvider implements IBlockchainProvider<
|
353
|
+
declare class ErgoGraphQLProvider<I = bigint> implements IBlockchainProvider<I> {
|
269
354
|
#private;
|
270
|
-
constructor(url: string
|
355
|
+
constructor(url: string);
|
271
356
|
constructor(url: ErgoGraphQLRequestOptions);
|
272
|
-
|
273
|
-
|
357
|
+
setUrl(url: string): ErgoGraphQLProvider<I>;
|
358
|
+
setBigIntMapper<M>(mapper: BiMapper<M>): ErgoGraphQLProvider<M>;
|
359
|
+
streamBoxes(query: GraphQLBoxQuery): AsyncGenerator<ChainProviderBox<I>[]>;
|
360
|
+
getBoxes(query: GraphQLBoxQuery): Promise<ChainProviderBox<I>[]>;
|
361
|
+
streamUnconfirmedTransactions(query: TransactionQuery<GraphQLUnconfirmedTransactionWhere>): AsyncIterable<ChainProviderUnconfirmedTransaction<I>[]>;
|
362
|
+
getUnconfirmedTransactions(query: TransactionQuery<GraphQLUnconfirmedTransactionWhere>): Promise<ChainProviderUnconfirmedTransaction<I>[]>;
|
363
|
+
streamConfirmedTransactions(query: TransactionQuery<GraphQLConfirmedTransactionWhere>): AsyncIterable<ChainProviderConfirmedTransaction<I>[]>;
|
364
|
+
getConfirmedTransactions(query: TransactionQuery<GraphQLConfirmedTransactionWhere>): Promise<ChainProviderConfirmedTransaction<I>[]>;
|
274
365
|
getHeaders(query: HeaderQuery): Promise<BlockHeader[]>;
|
275
366
|
createOperation<R, V extends GraphQLVariables = GraphQLVariables>(query: string, options?: Partial<ErgoGraphQLRequestOptions>): GraphQLOperation<GraphQLSuccessResponse<R>, V>;
|
276
367
|
checkTransaction(signedTransaction: SignedTransaction): Promise<TransactionEvaluationResult>;
|
@@ -278,4 +369,4 @@ declare class ErgoGraphQLProvider implements IBlockchainProvider<BoxWhere> {
|
|
278
369
|
reduceTransaction(): Promise<TransactionReductionResult>;
|
279
370
|
}
|
280
371
|
|
281
|
-
export { ErgoGraphQLProvider, type ErgoGraphQLRequestOptions, type GraphQLBoxQuery, type GraphQLBoxWhere };
|
372
|
+
export { ErgoGraphQLProvider, type ErgoGraphQLRequestOptions, type GraphQLBoxQuery, type GraphQLBoxWhere, type GraphQLConfirmedTransactionWhere, type GraphQLUnconfirmedTransactionWhere };
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BoxId, HexString, Base58String, TokenId, Box, BlockHeader, SignedTransaction, UnsignedTransaction,
|
1
|
+
import { BoxId, HexString, Base58String, TokenId, TransactionId, Box, DataInput, BlockHeader, SignedTransaction, UnsignedTransaction, ProverResult } from '@fleet-sdk/common';
|
2
2
|
import { ErgoAddress } from '@fleet-sdk/core';
|
3
3
|
|
4
4
|
declare global {
|
@@ -153,6 +153,18 @@ type RequireAtLeastOne<
|
|
153
153
|
Except<ObjectType, KeysType>;
|
154
154
|
|
155
155
|
type BoxSource = "blockchain" | "mempool" | "blockchain+mempool";
|
156
|
+
type BoxWhere = {
|
157
|
+
/** Base16-encoded BoxId */
|
158
|
+
boxId?: BoxId;
|
159
|
+
/** Base16-encoded ErgoTree */
|
160
|
+
ergoTree?: HexString;
|
161
|
+
/** Base58-encoded address */
|
162
|
+
address?: ErgoAddress | Base58String;
|
163
|
+
/** Base16-encoded contract template hash */
|
164
|
+
templateHash?: HexString;
|
165
|
+
/** Base16-encoded TokenId */
|
166
|
+
tokenId?: TokenId;
|
167
|
+
};
|
156
168
|
type BoxQuery<W extends BoxWhere> = {
|
157
169
|
/** The query to filter boxes. */
|
158
170
|
where: RequireAtLeastOne<W>;
|
@@ -162,23 +174,59 @@ type BoxQuery<W extends BoxWhere> = {
|
|
162
174
|
*/
|
163
175
|
from?: BoxSource;
|
164
176
|
};
|
165
|
-
type
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
boxId?: BoxId;
|
177
|
+
type UnconfirmedTransactionWhere = {
|
178
|
+
/** Base16-encoded TransactionId */
|
179
|
+
transactionId?: TransactionId;
|
180
|
+
/** Base58-encoded address */
|
181
|
+
address?: ErgoAddress | Base58String;
|
171
182
|
/** Base16-encoded ErgoTree */
|
172
183
|
ergoTree?: HexString;
|
184
|
+
};
|
185
|
+
type ConfirmedTransactionWhere = {
|
186
|
+
/** Base16-encoded TransactionId */
|
187
|
+
transactionId?: TransactionId;
|
188
|
+
/** Base16-encoded HeaderID */
|
189
|
+
headerId?: HexString;
|
173
190
|
/** Base58-encoded address */
|
174
191
|
address?: ErgoAddress | Base58String;
|
175
|
-
/** Base16-encoded
|
176
|
-
|
177
|
-
/**
|
178
|
-
|
192
|
+
/** Base16-encoded ErgoTree */
|
193
|
+
ergoTree?: HexString;
|
194
|
+
/** Min blockchain height */
|
195
|
+
minHeight?: number;
|
196
|
+
/** Only returns relevant outputs for the selected filter params */
|
197
|
+
onlyRelevantOutputs?: boolean;
|
198
|
+
};
|
199
|
+
type TransactionQuery<W extends ConfirmedTransactionWhere> = {
|
200
|
+
/** The query to filter boxes. */
|
201
|
+
where: RequireAtLeastOne<W, keyof Omit<W, "minHeight" | "onlyRelevantOutputs">>;
|
202
|
+
};
|
203
|
+
type HeaderQuery = {
|
204
|
+
take: number;
|
205
|
+
};
|
206
|
+
type ChainProviderBox<T> = Omit<Box, "value" | "assets"> & {
|
207
|
+
value: T;
|
208
|
+
assets: {
|
209
|
+
tokenId: TokenId;
|
210
|
+
amount: T;
|
211
|
+
}[];
|
212
|
+
confirmed: boolean;
|
179
213
|
};
|
180
|
-
type
|
214
|
+
type TransactionOutput<T> = Omit<ChainProviderBox<T>, "confirmed">;
|
215
|
+
type TransactionInput<T> = TransactionOutput<T> & {
|
216
|
+
spendingProof: ProverResult;
|
217
|
+
};
|
218
|
+
type ChainProviderUnconfirmedTransaction<T> = {
|
219
|
+
transactionId: TransactionId;
|
220
|
+
inputs: TransactionInput<T>[];
|
221
|
+
dataInputs: DataInput[];
|
222
|
+
outputs: TransactionOutput<T>[];
|
181
223
|
confirmed: boolean;
|
224
|
+
timestamp: number;
|
225
|
+
};
|
226
|
+
type ChainProviderConfirmedTransaction<T> = ChainProviderUnconfirmedTransaction<T> & {
|
227
|
+
height: number;
|
228
|
+
index: number;
|
229
|
+
headerId: HexString;
|
182
230
|
};
|
183
231
|
type TransactionEvaluationError = {
|
184
232
|
success: false;
|
@@ -198,15 +246,31 @@ type TransactionReductionResult = TransactionEvaluationError | TransactionReduct
|
|
198
246
|
* Represents a blockchain provider that can interact with the blockchain.
|
199
247
|
* @template B The type of the box query used by the provider.
|
200
248
|
*/
|
201
|
-
interface IBlockchainProvider<
|
249
|
+
interface IBlockchainProvider<I> {
|
202
250
|
/**
|
203
251
|
* Get boxes.
|
204
252
|
*/
|
205
|
-
getBoxes(query: BoxQuery<
|
253
|
+
getBoxes(query: BoxQuery<BoxWhere>): Promise<ChainProviderBox<I>[]>;
|
206
254
|
/**
|
207
255
|
* Stream boxes.
|
208
256
|
*/
|
209
|
-
streamBoxes(query: BoxQuery<
|
257
|
+
streamBoxes(query: BoxQuery<BoxWhere>): AsyncIterable<ChainProviderBox<I>[]>;
|
258
|
+
/**
|
259
|
+
* Stream unconfirmed transactions
|
260
|
+
*/
|
261
|
+
streamUnconfirmedTransactions(query: TransactionQuery<UnconfirmedTransactionWhere>): AsyncIterable<ChainProviderUnconfirmedTransaction<I>[]>;
|
262
|
+
/**
|
263
|
+
* Get unconfirmed transactions
|
264
|
+
*/
|
265
|
+
getUnconfirmedTransactions(query: TransactionQuery<UnconfirmedTransactionWhere>): Promise<ChainProviderUnconfirmedTransaction<I>[]>;
|
266
|
+
/**
|
267
|
+
* Stream confirmed transactions
|
268
|
+
*/
|
269
|
+
streamConfirmedTransactions(query: TransactionQuery<ConfirmedTransactionWhere>): AsyncIterable<ChainProviderConfirmedTransaction<I>[]>;
|
270
|
+
/**
|
271
|
+
* Get confirmed transactions
|
272
|
+
*/
|
273
|
+
getConfirmedTransactions(query: TransactionQuery<ConfirmedTransactionWhere>): Promise<ChainProviderConfirmedTransaction<I>[]>;
|
210
274
|
/**
|
211
275
|
* Get headers.
|
212
276
|
*/
|
@@ -225,9 +289,24 @@ interface IBlockchainProvider<B extends BoxWhere> {
|
|
225
289
|
reduceTransaction(transaction: UnsignedTransaction): Promise<TransactionReductionResult>;
|
226
290
|
}
|
227
291
|
|
228
|
-
|
229
|
-
|
230
|
-
|
292
|
+
interface ParserLike {
|
293
|
+
parse<T>(text: string): T;
|
294
|
+
stringify<T>(value: T): string;
|
295
|
+
}
|
296
|
+
type Route = {
|
297
|
+
base: string;
|
298
|
+
path: string;
|
299
|
+
query?: Record<string, unknown>;
|
300
|
+
};
|
301
|
+
type URLLike = string | Route;
|
302
|
+
type FallbackRetryOptions = {
|
303
|
+
fallbacks?: URLLike[];
|
304
|
+
} & RetryOptions;
|
305
|
+
type RetryOptions = {
|
306
|
+
attempts: number;
|
307
|
+
delay: number;
|
308
|
+
};
|
309
|
+
|
231
310
|
type GraphQLVariables = Record<string, unknown> | null;
|
232
311
|
interface GraphQLError {
|
233
312
|
message: string;
|
@@ -241,20 +320,16 @@ interface GraphQLErrorResponse {
|
|
241
320
|
errors: GraphQLError[];
|
242
321
|
}
|
243
322
|
type GraphQLResponse<T = unknown> = GraphQLSuccessResponse<T> | GraphQLErrorResponse;
|
244
|
-
type GraphQLOperation<R extends GraphQLResponse, V extends GraphQLVariables> = (variables?: V) => Promise<R>;
|
245
|
-
interface ResponseParser {
|
246
|
-
parse<T>(text: string): T;
|
247
|
-
stringify<T>(value: T): string;
|
248
|
-
}
|
323
|
+
type GraphQLOperation<R extends GraphQLResponse, V extends GraphQLVariables> = (variables?: V, url?: string) => Promise<R>;
|
249
324
|
interface GraphQLRequestOptions {
|
250
|
-
url
|
251
|
-
|
252
|
-
|
253
|
-
fetcher?: Fetcher;
|
254
|
-
credentials?: Credentials;
|
325
|
+
url?: string;
|
326
|
+
parser?: ParserLike;
|
327
|
+
retry?: FallbackRetryOptions;
|
255
328
|
throwOnNonNetworkErrors?: boolean;
|
329
|
+
httpOptions?: Omit<RequestInit, "body" | "method">;
|
256
330
|
}
|
257
331
|
|
332
|
+
type BiMapper<T> = (value: string) => T;
|
258
333
|
type GraphQLBoxWhere = BoxWhere & {
|
259
334
|
/** Base16-encoded BoxIds */
|
260
335
|
boxIds?: HexString[];
|
@@ -263,14 +338,30 @@ type GraphQLBoxWhere = BoxWhere & {
|
|
263
338
|
/** Base58-encoded addresses or `ErgoAddress` objects */
|
264
339
|
addresses?: (Base58String | ErgoAddress)[];
|
265
340
|
};
|
341
|
+
type GraphQLConfirmedTransactionWhere = ConfirmedTransactionWhere & {
|
342
|
+
transactionIds?: HexString[];
|
343
|
+
addresses?: (Base58String | ErgoAddress)[];
|
344
|
+
ergoTrees?: HexString[];
|
345
|
+
};
|
346
|
+
type GraphQLUnconfirmedTransactionWhere = UnconfirmedTransactionWhere & {
|
347
|
+
transactionIds?: HexString[];
|
348
|
+
addresses?: (Base58String | ErgoAddress)[];
|
349
|
+
ergoTrees?: HexString[];
|
350
|
+
};
|
266
351
|
type GraphQLBoxQuery = BoxQuery<GraphQLBoxWhere>;
|
267
352
|
type ErgoGraphQLRequestOptions = Omit<GraphQLRequestOptions, "throwOnNonNetworkError">;
|
268
|
-
declare class ErgoGraphQLProvider implements IBlockchainProvider<
|
353
|
+
declare class ErgoGraphQLProvider<I = bigint> implements IBlockchainProvider<I> {
|
269
354
|
#private;
|
270
|
-
constructor(url: string
|
355
|
+
constructor(url: string);
|
271
356
|
constructor(url: ErgoGraphQLRequestOptions);
|
272
|
-
|
273
|
-
|
357
|
+
setUrl(url: string): ErgoGraphQLProvider<I>;
|
358
|
+
setBigIntMapper<M>(mapper: BiMapper<M>): ErgoGraphQLProvider<M>;
|
359
|
+
streamBoxes(query: GraphQLBoxQuery): AsyncGenerator<ChainProviderBox<I>[]>;
|
360
|
+
getBoxes(query: GraphQLBoxQuery): Promise<ChainProviderBox<I>[]>;
|
361
|
+
streamUnconfirmedTransactions(query: TransactionQuery<GraphQLUnconfirmedTransactionWhere>): AsyncIterable<ChainProviderUnconfirmedTransaction<I>[]>;
|
362
|
+
getUnconfirmedTransactions(query: TransactionQuery<GraphQLUnconfirmedTransactionWhere>): Promise<ChainProviderUnconfirmedTransaction<I>[]>;
|
363
|
+
streamConfirmedTransactions(query: TransactionQuery<GraphQLConfirmedTransactionWhere>): AsyncIterable<ChainProviderConfirmedTransaction<I>[]>;
|
364
|
+
getConfirmedTransactions(query: TransactionQuery<GraphQLConfirmedTransactionWhere>): Promise<ChainProviderConfirmedTransaction<I>[]>;
|
274
365
|
getHeaders(query: HeaderQuery): Promise<BlockHeader[]>;
|
275
366
|
createOperation<R, V extends GraphQLVariables = GraphQLVariables>(query: string, options?: Partial<ErgoGraphQLRequestOptions>): GraphQLOperation<GraphQLSuccessResponse<R>, V>;
|
276
367
|
checkTransaction(signedTransaction: SignedTransaction): Promise<TransactionEvaluationResult>;
|
@@ -278,4 +369,4 @@ declare class ErgoGraphQLProvider implements IBlockchainProvider<BoxWhere> {
|
|
278
369
|
reduceTransaction(): Promise<TransactionReductionResult>;
|
279
370
|
}
|
280
371
|
|
281
|
-
export { ErgoGraphQLProvider, type ErgoGraphQLRequestOptions, type GraphQLBoxQuery, type GraphQLBoxWhere };
|
372
|
+
export { ErgoGraphQLProvider, type ErgoGraphQLRequestOptions, type GraphQLBoxQuery, type GraphQLBoxWhere, type GraphQLConfirmedTransactionWhere, type GraphQLUnconfirmedTransactionWhere };
|