-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathtypes.ts
1574 lines (1406 loc) · 45.9 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import {
BlockTag,
EventType,
TransactionReceipt
} from '@ethersproject/abstract-provider';
import { BigNumberish } from '@ethersproject/bignumber';
import { ConnectionInfo } from '@ethersproject/web';
import {
ERC1155Metadata,
NftRefreshState,
NftTokenType,
RawContract
} from './nft-types';
export * from './ethers-types';
// TODO: separate this file into other files.
/**
* Options object used to configure the Alchemy SDK.
*
* @public
*/
export interface AlchemySettings {
/**
* The Alchemy API key that can be found in the Alchemy dashboard.
*
* Defaults to: "demo" (a rate-limited public API key)
*/
apiKey?: string;
/**
* The name of the network. Once configured, the network cannot be changed. To
* use a different network, instantiate a new `Alchemy` instance.
*
* Defaults to: Network.ETH_MAINNET
*/
network?: Network;
/** The maximum number of retries to attempt if a request fails. Defaults to 5. */
maxRetries?: number;
/**
* Optional URL endpoint to use for all requests. Setting this field will
* override the URL generated by the {@link network} and {@link apiKey} fields.
*
* This field is useful for testing or for using a custom node endpoint. Note
* that not all methods will work with custom URLs.
*/
url?: string;
/**
* Alchemy auth token required to use the Notify API. This token can be found
* in the Alchemy Dashboard on the Notify tab.
*/
authToken?: string;
/**
* Optional Request timeout provided in `ms` while using NFT and NOTIFY API.
* Default to 0 (No timeout).
*/
requestTimeout?: number;
/**
* Optional setting that automatically batches and sends json-rpc requests for
* higher throughput and reduced network IO. Defaults to false.
*
* This implementation is based on the `JsonRpcBatchProvider` in ethers.
*/
batchRequests?: boolean;
/**
* Optional overrides on the Ethers `ConnectionInfo` object used to configure
* the underlying JsonRpcProvider. This field is for advanced users who want
* to customize the provider's behavior.
*
* This override is applied last, so it will override any other
* AlchemySettings properties that affect the connection.
*
* Note that modifying the ConnectionInfo may break Alchemy SDK's default
* connection/url logic. It also does not affect `nft` and `notify`
* namespaces.
*
* {@link https://docs.ethers.org/v5/api/utils/web/#ConnectionInfo}
*/
connectionInfoOverrides?: Partial<ConnectionInfo>;
}
/**
* The supported networks by Alchemy. Note that some functions are not available
* on all networks. Please refer to the Alchemy documentation for which APIs are
* available on which networks
* {@link https://docs.alchemy.com/alchemy/apis/feature-support-by-chain}
*
* @public
*/
export enum Network {
ETH_MAINNET = 'eth-mainnet',
/** @deprecated */
ETH_GOERLI = 'eth-goerli',
ETH_SEPOLIA = 'eth-sepolia',
OPT_MAINNET = 'opt-mainnet',
/** @deprecated */
OPT_GOERLI = 'opt-goerli',
OPT_SEPOLIA = 'opt-sepolia',
ARB_MAINNET = 'arb-mainnet',
/** @deprecated */
ARB_GOERLI = 'arb-goerli',
ARB_SEPOLIA = 'arb-sepolia',
MATIC_MAINNET = 'polygon-mainnet',
/** @deprecated */
MATIC_MUMBAI = 'polygon-mumbai',
MATIC_AMOY = 'polygon-amoy',
ASTAR_MAINNET = 'astar-mainnet',
POLYGONZKEVM_MAINNET = 'polygonzkevm-mainnet',
/** @deprecated */
POLYGONZKEVM_TESTNET = 'polygonzkevm-testnet',
POLYGONZKEVM_CARDONA = 'polygonzkevm-cardona',
BASE_MAINNET = 'base-mainnet',
BASE_GOERLI = 'base-goerli',
BASE_SEPOLIA = 'base-sepolia',
ZKSYNC_MAINNET = 'zksync-mainnet',
ZKSYNC_SEPOLIA = 'zksync-sepolia',
SHAPE_MAINNET = 'shape-mainnet',
SHAPE_SEPOLIA = 'shape-sepolia',
LINEA_MAINNET = 'linea-mainnet',
LINEA_SEPOLIA = 'linea-sepolia',
FANTOM_MAINNET = 'fantom-mainnet',
FANTOM_TESTNET = 'fantom-testnet',
ZETACHAIN_MAINNET = 'zetachain-mainnet',
ZETACHAIN_TESTNET = 'zetachain-testnet',
ARBNOVA_MAINNET = 'arbnova-mainnet',
BLAST_MAINNET = 'blast-mainnet',
BLAST_SEPOLIA = 'blast-sepolia',
MANTLE_MAINNET = 'mantle-mainnet',
MANTLE_SEPOLIA = 'mantle-sepolia',
SCROLL_MAINNET = 'scroll-mainnet',
SCROLL_SEPOLIA = 'scroll-sepolia',
GNOSIS_MAINNET = 'gnosis-mainnet',
GNOSIS_CHIADO = 'gnosis-chiado',
BNB_MAINNET = 'bnb-mainnet',
BNB_TESTNET = 'bnb-testnet',
AVAX_MAINNET = 'avax-mainnet',
AVAX_FUJI = 'avax-fuji',
CELO_MAINNET = 'celo-mainnet',
CELO_ALFAJORES = 'celo-alfajores',
METIS_MAINNET = 'metis-mainnet',
OPBNB_MAINNET = 'opbnb-mainnet',
OPBNB_TESTNET = 'opbnb-testnet'
}
/** Token Types for the `getTokenBalances()` endpoint. */
export enum TokenBalanceType {
/**
* Option to fetch the top 100 tokens by 24-hour volume. This option is only
* available on Mainnet in Ethereum, Polygon, and Arbitrum.
*/
DEFAULT_TOKENS = 'DEFAULT_TOKENS',
/**
* Option to fetch the set of ERC-20 tokens that the address as ever held. his
* list is produced by an address's historical transfer activity and includes
* all tokens that the address has ever received.
*/
ERC20 = 'erc20'
}
/**
* Optional params to pass into `getTokenBalances()` to fetch all ERC-20 tokens
* instead of passing in an array of contract addresses to fetch balances for.
*/
export interface TokenBalancesOptionsErc20 {
/** The ERC-20 token type. */
type: TokenBalanceType.ERC20;
/** Optional page key for pagination (only applicable to TokenBalanceType.ERC20) */
pageKey?: string;
}
/**
* Optional params to pass into `getTokenBalances()` to fetch the top 100 tokens
* instead of passing in an array of contract addresses to fetch balances for.
*/
export interface TokenBalancesOptionsDefaultTokens {
/** The top 100 token type. */
type: TokenBalanceType.DEFAULT_TOKENS;
}
/**
* Response object for when the {@link TokenBalancesOptionsErc20} options are
* used. A page key may be returned if the provided address has many transfers.
*/
export interface TokenBalancesResponseErc20 extends TokenBalancesResponse {
/**
* An optional page key to passed into the next request to fetch the next page
* of token balances.
*/
pageKey?: string;
}
/** @public */
export interface TokenBalancesResponse {
address: string;
tokenBalances: TokenBalance[];
}
/** @public */
export type TokenBalance = TokenBalanceSuccess | TokenBalanceFailure;
/** @public */
export interface TokenBalanceSuccess {
contractAddress: string;
tokenBalance: string;
error: null;
}
/** @public */
export interface TokenBalanceFailure {
contractAddress: string;
tokenBalance: null;
error: string;
}
/**
* Optional params to pass into {@link CoreNamespace.getTokensForOwner}.
*/
export interface GetTokensForOwnerOptions {
/**
* List of contract addresses to filter by. If omitted, defaults to
* {@link TokenBalanceType.ERC20}.
*/
contractAddresses?: string[] | TokenBalanceType;
/**
* Optional page key from an existing {@link GetTokensForOwnerResponse} to use for
* pagination.
*/
pageKey?: string;
}
/**
* Response object for {@link CoreNamespace.getTokensForOwner}.
*/
export interface GetTokensForOwnerResponse {
/** Owned tokens for the provided addresses along with relevant metadata. */
tokens: OwnedToken[];
/** Page key for the next page of results, if one exists. */
pageKey?: string;
}
/**
* Represents an owned token on a {@link GetTokensForOwnerResponse}.
*/
export interface OwnedToken {
/** The contract address of the token. */
contractAddress: string;
/**
* The raw value of the balance field as a hex string. This value is undefined
* if the {@link error} field is present.
*/
rawBalance?: string;
/**
* The formatted value of the balance field as a hex string. This value is
* undefined if the {@link error} field is present, or if the `decimals` field=
* is undefined.
*/
balance?: string;
/** */
/**
* The token's name. Is undefined if the name is not defined in the contract and
* not available from other sources.
*/
name?: string;
/**
* The token's symbol. Is undefined if the symbol is not defined in the contract
* and not available from other sources.
*/
symbol?: string;
/**
* The number of decimals of the token. Is undefined if not defined in the
* contract and not available from other sources.
*/
decimals?: number;
/** URL link to the token's logo. Is undefined if the logo is not available. */
logo?: string;
/**
* Error from fetching the token balances. If this field is defined, none of
* the other fields will be defined.
*/
error?: string;
}
/**
* Response object for the {@link CoreNamespace.getTokenMetadata} method.
*
* @public
*/
export interface TokenMetadataResponse {
/**
* The token's name. Is `null` if the name is not defined in the contract and
* not available from other sources.
*/
name: string | null;
/**
* The token's symbol. Is `null` if the symbol is not defined in the contract
* and not available from other sources.
*/
symbol: string | null;
/**
* The number of decimals of the token. Returns `null` if not defined in the
* contract and not available from other sources.
*/
decimals: number | null;
/** URL link to the token's logo. Is `null` if the logo is not available. */
logo: string | null;
}
/**
* Parameters for the {@link CoreNamespace.getAssetTransfers} method.
*
* @public
*/
export interface AssetTransfersParams {
/**
* The starting block to check for transfers. This value is inclusive and
* defaults to `0x0` if omitted.
*/
fromBlock?: string;
/**
* The ending block to check for transfers. This value is inclusive and
* defaults to the latest block if omitted.
*/
toBlock?: string;
/**
* Whether to return results in ascending or descending order by block number.
* Defaults to ascending if omitted.
*/
order?: SortingOrder;
/**
* The from address to filter transfers by. This value defaults to a wildcard
* for all addresses if omitted.
*/
fromAddress?: string;
/**
* The to address to filter transfers by. This value defaults to a wildcard
* for all address if omitted.
*/
toAddress?: string;
/**
* List of contract addresses to filter for - only applies to "erc20",
* "erc721", "erc1155" transfers. Defaults to all address if omitted.
*/
contractAddresses?: string[];
/**
* Whether to exclude transfers with zero value. Note that zero value is
* different than null value. Defaults to `true` if omitted.
*/
excludeZeroValue?: boolean;
/** REQUIRED field. An array of categories to get transfers for. */
category: AssetTransfersCategory[];
/** The maximum number of results to return per page. Defaults to 1000 if omitted. */
maxCount?: number;
/**
* Optional page key from an existing {@link OwnedBaseNftsResponse}
* {@link AssetTransfersResult}to use for pagination.
*/
pageKey?: string;
/**
* Whether to include additional metadata about each transfer event. Defaults
* to `false` if omitted.
*/
withMetadata?: boolean;
}
/**
* Parameters for the {@link CoreNamespace.getAssetTransfers} method that
* includes metadata.
*
* @public
*/
export interface AssetTransfersWithMetadataParams extends AssetTransfersParams {
withMetadata: true;
}
/**
* Categories of transfers to use with the {@link AssetTransfersParams} request
* object when using {@link CoreNamespace.getAssetTransfers}.
*
* @public
*/
export enum AssetTransfersCategory {
/**
* Top level ETH transactions that occur where the `fromAddress` is an
* external user-created address. External addresses have private keys and are
* accessed by users.
*/
EXTERNAL = 'external',
/**
* Top level ETH transactions that occur where the `fromAddress` is an
* internal, smart contract address. For example, a smart contract calling
* another smart contract or sending
*/
INTERNAL = 'internal',
/** ERC20 transfers. */
ERC20 = 'erc20',
/** ERC721 transfers. */
ERC721 = 'erc721',
/** ERC1155 transfers. */
ERC1155 = 'erc1155',
/** Special contracts that don't follow ERC 721/1155, (ex: CryptoKitties). */
SPECIALNFT = 'specialnft'
}
/**
* Response object for the {@link CoreNamespace.getAssetTransfers} method.
*
* @public
*/
export interface AssetTransfersResponse {
transfers: AssetTransfersResult[];
/** Page key for the next page of results, if one exists. */
pageKey?: string;
}
/**
* Response object for the {@link CoreNamespace.getAssetTransfers} method when
* the {@link AssetTransfersWithMetadataParams} are used.
*
* @public
*/
export interface AssetTransfersWithMetadataResponse {
transfers: AssetTransfersWithMetadataResult[];
pageKey?: string;
}
/**
* Represents a transfer event that is returned in a {@link AssetTransfersResponse}.
*
* @public
*/
export interface AssetTransfersResult {
/** The unique ID of the transfer. */
uniqueId: string;
/** The category of the transfer. */
category: AssetTransfersCategory;
/** The block number where the transfer occurred. */
blockNum: string;
/** The from address of the transfer. */
from: string;
/** The to address of the transfer. */
to: string | null;
/**
* Converted asset transfer value as a number (raw value divided by contract
* decimal). `null` if ERC721 transfer or contract decimal not available.
*/
value: number | null;
/**
* The raw ERC721 token id of the transfer as a hex string. `null` if not an
* ERC721 transfer.
*/
erc721TokenId: string | null;
/**
* A list of ERC1155 metadata objects if the asset transferred is an ERC1155
* token. `null` if not an ERC1155 transfer.
*/
erc1155Metadata: ERC1155Metadata[] | null;
/** The token id of the token transferred. */
tokenId: string | null;
/**
* Returns the token's symbol or ETH for other transfers. `null` if the
* information was not available.
*/
asset: string | null;
/** The transaction hash of the transfer transaction. */
hash: string;
/** Information about the raw contract of the asset transferred. */
rawContract: RawContract;
}
/**
* Represents a transfer event that is returned in a
* {@link AssetTransfersResponse} when {@link AssetTransfersWithMetadataParams} are used.
*
* @public
*/
export interface AssetTransfersWithMetadataResult extends AssetTransfersResult {
/** Additional metadata about the transfer event. */
metadata: AssetTransfersMetadata;
}
/**
* The metadata object for a {@link AssetTransfersResult} when the
* {@link AssetTransfersParams.withMetadata} field is set to true.
*
* @public
*/
export interface AssetTransfersMetadata {
/** Timestamp of the block from which the transaction event originated. */
blockTimestamp: string;
}
/**
* The type of transfer for the request. Note that using `TO` will also include
* NFTs that were minted by the owner.
*/
export enum GetTransfersForOwnerTransferType {
'TO' = 'TO',
'FROM' = 'FROM'
}
/**
* Optional parameters object for the {@link NftNamespace.getTransfersForOwner} method.
*/
export interface GetTransfersForOwnerOptions {
/**
* List of NFT contract addresses to filter mints by. If omitted, defaults to
* all contract addresses.
*/
contractAddresses?: string[];
/**
* Filter mints by ERC721 vs ERC1155 contracts. If omitted, defaults to all
* NFTs.
*/
tokenType?: NftTokenType.ERC1155 | NftTokenType.ERC721;
/**
* Optional page key from an existing {@link TransfersNftResponse} to use for
* pagination.
*/
pageKey?: string;
}
/**
* Enum for representing the supported sorting orders of the API.
*
* @public
*/
export enum SortingOrder {
ASCENDING = 'asc',
DESCENDING = 'desc'
}
/** The refresh result response object returned by {@link refreshContract}. */
export interface RefreshContractResult {
/** The NFT contract address that was passed in to be refreshed. */
contractAddress: string;
/** The current state of the refresh request. */
refreshState: NftRefreshState;
/**
* Percentage of tokens currently refreshed, represented as an integer string.
* Field can be null if the refresh has not occurred.
*/
progress: string | null;
}
/**
* The parameter field of {@link TransactionReceiptsParams}.
*
* @public
*/
export interface TransactionReceiptsBlockNumber {
/** The block number to get transaction receipts for. */
blockNumber: string;
}
/**
* The parameter field of {@link TransactionReceiptsParams}.
*
* @public
*/
export interface TransactionReceiptsBlockHash {
/** The block hash to get transaction receipts for. */
blockHash: string;
}
/**
* The parameters to use with the {@link CoreNamespace.getTransactionReceipts} method.
*
* @public
*/
export type TransactionReceiptsParams =
| TransactionReceiptsBlockNumber
| TransactionReceiptsBlockHash;
/**
* Response object for a {@link CoreNamespace.getTransactionReceipts} call.
*
* @public
*/
export interface TransactionReceiptsResponse {
/** A list of transaction receipts for the queried block. */
receipts: TransactionReceipt[] | null;
}
/** An OpenSea collection's approval status. */
export enum OpenSeaSafelistRequestStatus {
/** Verified collection. */
VERIFIED = 'verified',
/** Collections that are approved on open sea and can be found in search results. */
APPROVED = 'approved',
/** Collections that requested safelisting on OpenSea. */
REQUESTED = 'requested',
/** Brand new collections. */
NOT_REQUESTED = 'not_requested'
}
/**
* The response object for the {@link findContractDeployer} function.
*
* @public
*/
export interface DeployResult {
/** The address of the contract deployer, if it is available. */
deployerAddress?: string;
/** The block number the contract was deployed in. */
blockNumber: number;
}
/**
* Method names for Alchemy's custom Subscription API endpoints.
*
* This value is provided in the `method` field when creating an event filter on
* the Websocket Namespace.
*/
export enum AlchemySubscription {
PENDING_TRANSACTIONS = 'alchemy_pendingTransactions',
MINED_TRANSACTIONS = 'alchemy_minedTransactions'
}
/**
* Event filter for the {@link AlchemyWebSocketProvider.on} and
* {@link AlchemyWebSocketProvider.once} methods to use Alchemy's custom
* `alchemy_pendingTransactions` endpoint.
*
* Returns the transaction information for all pending transactions that match a
* given filter. For full documentation, see:
* {@link https://docs.alchemy.com/reference/alchemy-pendingtransactions}
*
* Note that excluding all optional parameters will return transaction
* information for ALL pending transactions that are added to the mempool.
*
* @public
*/
export interface AlchemyPendingTransactionsEventFilter {
method: AlchemySubscription.PENDING_TRANSACTIONS;
/**
* Filter pending transactions sent FROM the provided address or array of
* addresses.
*
* If a {@link AlchemyPendingTransactionsEventFilter.toAddress} is also
* present, then this filter will return transactions sent from the
* `fromAddress` OR transactions received by the `toAddress`.
*/
fromAddress?: string | string[];
/**
* Filter pending transactions sent TO the provided address or array of
* addresses.
*
* If a {@link AlchemyPendingTransactionsEventFilter.fromAddress} is also
* present, then this filter will return transactions sent from the
* `fromAddress` OR transactions received by the `toAddress`.
*/
toAddress?: string | string[];
/**
* Whether to only include transaction hashes and exclude the rest of the
* transaction response for a smaller payload. Defaults to false (by default,
* the entire transaction response is included).
*
* Note that setting only {@link hashesOnly} to true will return the same
* response as subscribing to `newPendingTransactions`.
*/
hashesOnly?: boolean;
}
/**
* Event filter for the {@link AlchemyWebSocketProvider.on} and
* {@link AlchemyWebSocketProvider.once} methods to use Alchemy's custom
* `alchemy_minedTransactions` endpoint.
*
* Returns the transaction information for all mined transactions that match the
* provided filter. For full documentation, see:
* {@link https://docs.alchemy.com/reference/alchemy-minedtransactions}
*
* Note that excluding all optional parameters will return transaction
* information for ALL mined transactions.
*
* @public
*/
export interface AlchemyMinedTransactionsEventFilter {
method: AlchemySubscription.MINED_TRANSACTIONS;
/**
* Address filters to subscribe to. Defaults to all transactions if omitted.
* Limit 100 address filters. Requires a non-empty array.
*/
addresses?: NonEmptyArray<AlchemyMinedTransactionsAddress>;
/**
* Whether to include transactions that were removed from the mempool.
* Defaults to false.
*/
includeRemoved?: boolean;
/**
* Whether to only include transaction hashes and exclude the rest of the
* transaction response for a smaller payload. Defaults to false (by default,
* the entire transaction response is included).
*/
hashesOnly?: boolean;
}
/**
* Address filters for {@link AlchemyMinedTransactionsEventFilter}. Requires at
* least one of the fields to be set.
*/
export type AlchemyMinedTransactionsAddress = RequireAtLeastOne<{
to?: string;
from?: string;
}>;
/**
* Alchemy's event type that extends the default {@link EventType} interface to
* also include Alchemy's Subscription API.
*
* @public
*/
export type AlchemyEventType = EventType | AlchemyEventFilter;
/**
* This type represents the Alchemy's Subscription API endpoints as event
* filters compatible with other ethers events.
*/
export type AlchemyEventFilter =
| AlchemyMinedTransactionsEventFilter
| AlchemyPendingTransactionsEventFilter;
/** Options for the {@link TransactNamespace.sendPrivateTransaction} method. */
export interface SendPrivateTransactionOptions {
/**
* Whether to use fast-mode. Defaults to false. Please note that fast mode
* transactions cannot be cancelled using
* {@link TransactNamespace.cancelPrivateTransaction}. method.
*
* See {@link https://docs.flashbots.net/flashbots-protect/rpc/fast-mode} for
* more details.
*/
fast: boolean;
}
/**
* Asset type returned when calling {@link TransactNamespace.simulateAssetChanges}.
* Allows you to determine if the assets approved or / and transferred are
* native, tokens or NFTs.
*/
export enum SimulateAssetType {
/**
* Native transfers that involve the currency of the chain the simulation is
* run on (ex: ETH for Ethereum, MATIC for Polygon, ETH for Arbitrum).
*/
NATIVE = 'NATIVE',
/** ERC20 approval or transfers. */
ERC20 = 'ERC20',
/** ERC721 approval or transfers. */
ERC721 = 'ERC721',
/** ERC1155 approval or transfers. */
ERC1155 = 'ERC1155',
/**
* Special contracts that don't follow ERC 721/1155.Currently limited to
* CryptoKitties and CryptoPunks.
*/
SPECIAL_NFT = 'SPECIAL_NFT'
}
/**
* Change type returned when calling {@link TransactNamespace.simulateAssetChanges}.
*/
export enum SimulateChangeType {
/**
* Represents a transaction that approved or disapproved permissions for a
* contract.
*
* APPROVE without token ID → approve all tokens
* APPROVE without amount → approve all amount
* APPROVE with zero amount → approval being cleared
*/
APPROVE = 'APPROVE',
/**
* Represents a transaction that transferred tokens from one address to another.
*/
TRANSFER = 'TRANSFER'
}
/**
* The error field returned in a {@link SimulateAssetChangesResponse} if the
* simulation failed.
*/
export interface SimulateAssetChangesError extends Record<string, any> {
/** The error message. */
message: string;
}
/**
* Represents an asset change from a call to
* {@link TransactNamespace.simulateAssetChanges}.
*/
export interface SimulateAssetChangesChange {
/** The type of asset from the transaction. */
assetType: SimulateAssetType;
/** The type of change from the transaction. */
changeType: SimulateChangeType;
/** The from address. */
from: string;
/** The to address. */
to: string;
/**
* The raw amount as an integer string. Only available on TRANSFER changes for
* NATIVE and ERC20 assets, or ERC721/ERC1155 disapprove changes (field set to
* '0').
*/
rawAmount?: string;
/**
* The amount as an integer string. This value is calculated by applying the
* `decimals` field to the `rawAmount` field. Only available on TRANSFER
* changes for NATIVE and ERC20 assets, or ERC721/ERC1155 disapprove changes
* (field set to '0').
*/
amount?: string;
/** The name of the asset transferred, if available. */
name?: string;
/** The symbol of the asset transferred if available. */
symbol?: string;
/**
* The number of decimals used by the ERC20 token. Set to 0 for APPROVE
* changes. Field is undefined if it's not defined in the contract and not
* available from other sources.
*/
decimals?: number;
/**
* The contract address of the asset. Only applicable to ERC20, ERC721,
* ERC1155, NFT and SPECIAL_NFT transactions.
*/
contractAddress?: string;
/**
* URL for the logo of the asset, if available. Only applicable to ERC20 transactions.
*/
logo?: string;
/**
* The token id of the asset transferred. Only applicable to ERC721,
* ERC1155 and SPECIAL_NFT NFTs.
*/
tokenId?: string;
}
/**
* Response object for the {@link TransactNamespace.simulateAssetChanges} method.
*/
export interface SimulateAssetChangesResponse {
/** An array of asset changes that resulted from the transaction. */
changes: SimulateAssetChangesChange[];
/**
* The amount of gas used by the transaction represented as a hex string. The
* field is undefined if an error occurred.
*/
gasUsed?: string;
/** Optional error field that is present if an error occurred. */
error?: SimulateAssetChangesError;
}
/**
* Authority used to decode calls and logs when using the
* {@link TransactNamespace.simulateExecution} method.
*/
export enum DecodingAuthority {
ETHERSCAN = 'ETHERSCAN'
}
/** The input or output parameters from a {@link DecodedDebugCallTrace}. */
export interface DecodedCallParam {
/** Value of the parameter. */
value: string;
/** The name of the parameter. */
name: string;
/** The type of the parameter.*/
type: string;
}
/** The input parameters from a {@link DecodedLog}. */
export interface DecodedLogInput extends DecodedCallParam {
/** Whether the log is marked as indexed in the smart contract. */
indexed: boolean;
}
/**
* Decoded representation of the call trace that is part of a
* {@link SimulationCallTrace}.
*/
export interface DecodedDebugCallTrace {
/** The smart contract method called. */
methodName: string;
/** Method inputs. */
inputs: DecodedCallParam[];
/** Method outputs. */
outputs: DecodedCallParam[];
/** The source used to provide the decoded call trace. */
authority: DecodingAuthority;
}
/** The type of call in a debug call trace. */
export enum DebugCallType {
CREATE = 'CREATE',
CALL = 'CALL',
STATICCALL = 'STATICCALL',
DELEGATECALL = 'DELEGATECALL'
}
/**
* Debug call trace in a {@link SimulateExecutionResponse}.
*/
export interface SimulationCallTrace
extends Omit<DebugCallTrace, 'revertReason' | 'calls'> {
/** The type of call. */
type: DebugCallType;
/** A decoded version of the call. Provided on a best-effort basis. */
decoded?: DecodedDebugCallTrace;
}
/**
* Decoded representation of the debug log that is part of a
* {@link SimulationDebugLog}.
*/
export interface DecodedLog {
/** The decoded name of the log event. */
eventName: string;
/** The decoded inputs to the log. */
inputs: DecodedLogInput[];
/** The source used to provide the decoded log. */
authority: DecodingAuthority;
}
/**
* Debug log in a {@link SimulateExecutionResponse}.
*/
export interface SimulationDebugLog {
/** An array of topics in the log. */
topics: string[];
/** The address of the contract that generated the log. */
address: string;
/** The data included the log. */
data: string;
/** A decoded version of the log. Provided on a best-effort basis. */
decoded?: DecodedLog;