@0xtorch/evm 0.0.157 → 0.0.158
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/_cjs/explorer/blockscout/create.js +49 -24
- package/_cjs/explorer/blockscout/create.js.map +1 -1
- package/_cjs/explorer/etherscan/create.js +53 -26
- package/_cjs/explorer/etherscan/create.js.map +1 -1
- package/_cjs/explorer/etherscanV2/create.js +53 -26
- package/_cjs/explorer/etherscanV2/create.js.map +1 -1
- package/_cjs/explorer/moralis/create.js +15 -3
- package/_cjs/explorer/moralis/create.js.map +1 -1
- package/_esm/explorer/blockscout/create.js +53 -24
- package/_esm/explorer/blockscout/create.js.map +1 -1
- package/_esm/explorer/etherscan/create.js +57 -26
- package/_esm/explorer/etherscan/create.js.map +1 -1
- package/_esm/explorer/etherscanV2/create.js +57 -26
- package/_esm/explorer/etherscanV2/create.js.map +1 -1
- package/_esm/explorer/moralis/create.js +19 -3
- package/_esm/explorer/moralis/create.js.map +1 -1
- package/_types/explorer/blockscout/create.d.ts.map +1 -1
- package/_types/explorer/etherscan/create.d.ts.map +1 -1
- package/_types/explorer/etherscanV2/create.d.ts.map +1 -1
- package/_types/explorer/index.d.ts +1 -1
- package/_types/explorer/index.d.ts.map +1 -1
- package/_types/explorer/moralis/create.d.ts.map +1 -1
- package/_types/explorer/types.d.ts +9 -8
- package/_types/explorer/types.d.ts.map +1 -1
- package/explorer/blockscout/create.ts +49 -21
- package/explorer/etherscan/create.ts +56 -23
- package/explorer/etherscanV2/create.ts +56 -23
- package/explorer/index.ts +1 -1
- package/explorer/moralis/create.ts +23 -4
- package/explorer/types.ts +13 -8
- package/package.json +1 -1
|
@@ -2,6 +2,19 @@ import { toLowerHex, } from '../../types';
|
|
|
2
2
|
import { createInternalTransactionId } from '../../utils/createInternalTransactionId';
|
|
3
3
|
import { createMoralisClient } from './client';
|
|
4
4
|
import { getWalletTransactionHistory } from './getWalletTransactionHistory';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves headers from either a static object or a function that returns headers.
|
|
7
|
+
* This allows for dynamic header generation (e.g., refreshing auth tokens).
|
|
8
|
+
*/
|
|
9
|
+
const resolveHeaders = async (headers) => {
|
|
10
|
+
if (headers === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
if (typeof headers === 'function') {
|
|
14
|
+
return await headers();
|
|
15
|
+
}
|
|
16
|
+
return headers;
|
|
17
|
+
};
|
|
5
18
|
const maxRequestCount = 100;
|
|
6
19
|
const limit = 100;
|
|
7
20
|
export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl, }) => {
|
|
@@ -19,6 +32,7 @@ export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl,
|
|
|
19
32
|
let cursor = undefined;
|
|
20
33
|
while (count < maxRequestCount) {
|
|
21
34
|
count += 1;
|
|
35
|
+
const resolvedHeaders = await resolveHeaders(headers);
|
|
22
36
|
const result = await getWalletTransactionHistory({
|
|
23
37
|
client,
|
|
24
38
|
address: lowerAddress,
|
|
@@ -26,7 +40,7 @@ export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl,
|
|
|
26
40
|
fromBlock,
|
|
27
41
|
toBlock,
|
|
28
42
|
cursor,
|
|
29
|
-
headers,
|
|
43
|
+
headers: resolvedHeaders,
|
|
30
44
|
});
|
|
31
45
|
cursor = result.cursor ?? undefined;
|
|
32
46
|
for (const transaction of result.result) {
|
|
@@ -64,6 +78,7 @@ export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl,
|
|
|
64
78
|
let cursor = undefined;
|
|
65
79
|
while (count < maxRequestCount) {
|
|
66
80
|
count += 1;
|
|
81
|
+
const resolvedHeaders = await resolveHeaders(headers);
|
|
67
82
|
const result = await getWalletTransactionHistory({
|
|
68
83
|
client,
|
|
69
84
|
address: lowerAddress,
|
|
@@ -71,7 +86,7 @@ export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl,
|
|
|
71
86
|
fromBlock,
|
|
72
87
|
toBlock,
|
|
73
88
|
cursor,
|
|
74
|
-
headers,
|
|
89
|
+
headers: resolvedHeaders,
|
|
75
90
|
});
|
|
76
91
|
cursor = result.cursor ?? undefined;
|
|
77
92
|
for (const transaction of result.result) {
|
|
@@ -99,6 +114,7 @@ export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl,
|
|
|
99
114
|
let cursor = undefined;
|
|
100
115
|
while (count < maxRequestCount) {
|
|
101
116
|
count += 1;
|
|
117
|
+
const resolvedHeaders = await resolveHeaders(headers);
|
|
102
118
|
const result = await getWalletTransactionHistory({
|
|
103
119
|
client,
|
|
104
120
|
address: lowerAddress,
|
|
@@ -106,7 +122,7 @@ export const createMoralisExplorer = ({ name, baseUrl, chain, apiKey, proxyUrl,
|
|
|
106
122
|
fromBlock,
|
|
107
123
|
toBlock,
|
|
108
124
|
cursor,
|
|
109
|
-
headers,
|
|
125
|
+
headers: resolvedHeaders,
|
|
110
126
|
});
|
|
111
127
|
cursor = result.cursor ?? undefined;
|
|
112
128
|
for (const transaction of result.result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../explorer/moralis/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAA;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../explorer/moralis/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAA;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,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,CAAC;gBAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;oBACjC,MAAK;gBACP,CAAC;YACH,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC9B,cAAc;aACf,CAAA;QACH,CAAC;QACD,yBAAyB,EAAE,GAAoB,EAAE;YAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QACD,WAAW,EAAE,GAAG,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QACD,oBAAoB,EAAE,GAAG,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QACD,mCAAmC,EAAE,GAAG,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/blockscout/create.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/blockscout/create.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAoC,MAAM,UAAU,CAAA;AA2B1E,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,0CAK9B,0BAA0B,KAAG,QAiL/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/etherscan/create.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/etherscan/create.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAoC,MAAM,UAAU,CAAA;AA6B1E,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,4DAO7B,yBAAyB,KAAG,QA0O9B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/etherscanV2/create.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/etherscanV2/create.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAoC,MAAM,UAAU,CAAA;AA6B1E,KAAK,2BAA2B,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,yDAO/B,2BAA2B,KAAG,QA0OhC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createEtherscan } from './etherscan/create';
|
|
2
2
|
export { createEtherscanV2 } from './etherscanV2/create';
|
|
3
|
-
export type { Explorer } from './types';
|
|
3
|
+
export type { Explorer, HeadersInput } from './types';
|
|
4
4
|
export { createMoralisExplorer } from './moralis/create';
|
|
5
5
|
export { createNoApiExplorer } from './noApiExplorer/create';
|
|
6
6
|
export { createBlockscout } from './blockscout/create';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../explorer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../explorer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/moralis/create.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../explorer/moralis/create.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,UAAU,CAAA;AAoBtD,KAAK,+BAA+B,GAAG;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAKD,eAAO,MAAM,qBAAqB,GAAI,6CAMnC,+BAA+B,KAAG,QA2LpC,CAAA"}
|
|
@@ -14,6 +14,7 @@ export type ContractCreation = {
|
|
|
14
14
|
export type LogWithBlockNumber = Log & {
|
|
15
15
|
blockNumber: number;
|
|
16
16
|
};
|
|
17
|
+
export type HeadersInput = Record<string, string> | (() => Promise<Record<string, string> | undefined>) | undefined;
|
|
17
18
|
export type Explorer = {
|
|
18
19
|
readonly name: string;
|
|
19
20
|
readonly baseUrl: string;
|
|
@@ -30,19 +31,19 @@ type FunctionGetAddressInternalTransactions = (parameters: {
|
|
|
30
31
|
address: Hex;
|
|
31
32
|
fromBlock?: number;
|
|
32
33
|
toBlock?: number;
|
|
33
|
-
headers?:
|
|
34
|
+
headers?: HeadersInput;
|
|
34
35
|
}) => Promise<InternalTransactionWithIndex[]>;
|
|
35
36
|
type FunctionGetAddressTransactionIndexes = (parameters: {
|
|
36
37
|
address: Hex;
|
|
37
38
|
fromBlock?: number;
|
|
38
39
|
toBlock?: number;
|
|
39
|
-
headers?:
|
|
40
|
+
headers?: HeadersInput;
|
|
40
41
|
}) => Promise<TransactionIndex[]>;
|
|
41
42
|
type FunctionGetAddressTokenTransferIndexes = (parameters: {
|
|
42
43
|
address: Hex;
|
|
43
44
|
fromBlock?: number;
|
|
44
45
|
toBlock?: number;
|
|
45
|
-
headers?:
|
|
46
|
+
headers?: HeadersInput;
|
|
46
47
|
}) => Promise<{
|
|
47
48
|
indexes: TransactionIndex[];
|
|
48
49
|
erc20Transfers: Erc20Transfer[];
|
|
@@ -50,26 +51,26 @@ type FunctionGetAddressTokenTransferIndexes = (parameters: {
|
|
|
50
51
|
type FunctionGetBlockNumberOfTimestamp = (parameters: {
|
|
51
52
|
/** Unix timestamp in milliseconds */
|
|
52
53
|
timestamp: number;
|
|
53
|
-
headers?:
|
|
54
|
+
headers?: HeadersInput;
|
|
54
55
|
}) => Promise<number>;
|
|
55
56
|
type FunctionGetContract = (parameters: {
|
|
56
57
|
address: Hex;
|
|
57
|
-
headers?:
|
|
58
|
+
headers?: HeadersInput;
|
|
58
59
|
}) => Promise<Contract | undefined>;
|
|
59
60
|
type FunctionGetContractCreations = (parameters: {
|
|
60
61
|
addresses: Hex[];
|
|
61
|
-
headers?:
|
|
62
|
+
headers?: HeadersInput;
|
|
62
63
|
}) => Promise<ContractCreation[]>;
|
|
63
64
|
type FunctionGetEventLogs = (parameters: {
|
|
64
65
|
address: Hex;
|
|
65
66
|
topic0: LowerHex;
|
|
66
67
|
fromBlock?: number;
|
|
67
68
|
toBlock?: number;
|
|
68
|
-
headers?:
|
|
69
|
+
headers?: HeadersInput;
|
|
69
70
|
}) => Promise<LogWithBlockNumber[]>;
|
|
70
71
|
type FunctionGetInternalTransactionOfTransaction = (parameters: {
|
|
71
72
|
hash: LowerHex;
|
|
72
|
-
headers?:
|
|
73
|
+
headers?: HeadersInput;
|
|
73
74
|
}) => Promise<InternalTransactionWithIndex[]>;
|
|
74
75
|
export {};
|
|
75
76
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../explorer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAEjE,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MA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AA;IAChB,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAA;AAEnC,KAAK,2CAA2C,GAAG,CAAC,UAAU,EAAE;IAC9D,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,KAAK,OAAO,CAAC,4BAA4B,EAAE,CAAC,CAAA"}
|
|
@@ -2,7 +2,7 @@ import type { Erc20Transfer, LowerHex } from '../../types'
|
|
|
2
2
|
import type { InternalTransactionWithIndex } from '../../types/internalTransaction'
|
|
3
3
|
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
4
4
|
import { createInternalTransactionId } from '../../utils/createInternalTransactionId'
|
|
5
|
-
import type { Explorer, LogWithBlockNumber } from '../types'
|
|
5
|
+
import type { Explorer, HeadersInput, LogWithBlockNumber } from '../types'
|
|
6
6
|
import { createBlockscoutClient } from './client'
|
|
7
7
|
import { getBlockNumberByTimestamp } from './getBlockNumberByTimestamp'
|
|
8
8
|
import { getContractCreatorAddressHashAndCreationTransactionHash } from './getContractCreatorAddressHashAndCreationTransactionHash'
|
|
@@ -13,6 +13,22 @@ import { getInternalTransactionsByTransactionHash } from './getInternalTransacti
|
|
|
13
13
|
import { getTokenTransferEventsByAddress } from './getTokenTransferEventsByAddress'
|
|
14
14
|
import { getTransactionsByAddress } from './getTransactionsByAddress'
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Resolves headers from either a static object or a function that returns headers.
|
|
18
|
+
* This allows for dynamic header generation (e.g., refreshing auth tokens).
|
|
19
|
+
*/
|
|
20
|
+
const resolveHeaders = async (
|
|
21
|
+
headers: HeadersInput,
|
|
22
|
+
): Promise<Record<string, string> | undefined> => {
|
|
23
|
+
if (headers === undefined) {
|
|
24
|
+
return undefined
|
|
25
|
+
}
|
|
26
|
+
if (typeof headers === 'function') {
|
|
27
|
+
return await headers()
|
|
28
|
+
}
|
|
29
|
+
return headers
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
type CreateBlockscoutParameters = {
|
|
17
33
|
name: string
|
|
18
34
|
baseUrl: string
|
|
@@ -45,12 +61,13 @@ export const createBlockscout = ({
|
|
|
45
61
|
const endblock = toBlock
|
|
46
62
|
const maxPageSize = 10_000
|
|
47
63
|
while (true) {
|
|
64
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
48
65
|
const result = await getInternalTransactionsByAddressHash({
|
|
49
66
|
client,
|
|
50
67
|
address,
|
|
51
68
|
startblock,
|
|
52
69
|
endblock,
|
|
53
|
-
headers,
|
|
70
|
+
headers: resolvedHeaders,
|
|
54
71
|
})
|
|
55
72
|
for (const transaction of result) {
|
|
56
73
|
const id = createInternalTransactionId(transaction)
|
|
@@ -77,12 +94,13 @@ export const createBlockscout = ({
|
|
|
77
94
|
const endblock = toBlock
|
|
78
95
|
const maxPageSize = 10_000
|
|
79
96
|
while (true) {
|
|
97
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
80
98
|
const result = await getTransactionsByAddress({
|
|
81
99
|
client,
|
|
82
100
|
address,
|
|
83
101
|
startblock,
|
|
84
102
|
endblock,
|
|
85
|
-
headers,
|
|
103
|
+
headers: resolvedHeaders,
|
|
86
104
|
})
|
|
87
105
|
for (const index of result) {
|
|
88
106
|
if (!indexes.has(index.hash)) {
|
|
@@ -109,13 +127,14 @@ export const createBlockscout = ({
|
|
|
109
127
|
const endblock = toBlock
|
|
110
128
|
const maxPageSize = 10_000
|
|
111
129
|
while (true) {
|
|
130
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
112
131
|
const { indexes: resultIndexes, erc20Transfers: resultErc20Transfers } =
|
|
113
132
|
await getTokenTransferEventsByAddress({
|
|
114
133
|
client,
|
|
115
134
|
address,
|
|
116
135
|
startblock,
|
|
117
136
|
endblock,
|
|
118
|
-
headers,
|
|
137
|
+
headers: resolvedHeaders,
|
|
119
138
|
})
|
|
120
139
|
for (const index of resultIndexes) {
|
|
121
140
|
if (!indexes.has(index.hash)) {
|
|
@@ -136,24 +155,30 @@ export const createBlockscout = ({
|
|
|
136
155
|
erc20Transfers,
|
|
137
156
|
}
|
|
138
157
|
},
|
|
139
|
-
getBlockNumberOfTimestamp: ({ timestamp, headers }) =>
|
|
140
|
-
|
|
158
|
+
getBlockNumberOfTimestamp: async ({ timestamp, headers }) => {
|
|
159
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
160
|
+
return getBlockNumberByTimestamp({
|
|
141
161
|
client,
|
|
142
162
|
timestamp: Math.floor(timestamp / 1000),
|
|
143
|
-
headers,
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
163
|
+
headers: resolvedHeaders,
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
getContract: async ({ address, headers }) => {
|
|
167
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
168
|
+
return getContractSourceCodeForAVerifiedContract({
|
|
147
169
|
client,
|
|
148
170
|
address,
|
|
149
|
-
headers,
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
|
|
171
|
+
headers: resolvedHeaders,
|
|
172
|
+
})
|
|
173
|
+
},
|
|
174
|
+
getContractCreations: async ({ addresses, headers }) => {
|
|
175
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
176
|
+
return getContractCreatorAddressHashAndCreationTransactionHash({
|
|
153
177
|
client,
|
|
154
178
|
contractaddresses: addresses,
|
|
155
|
-
headers,
|
|
156
|
-
})
|
|
179
|
+
headers: resolvedHeaders,
|
|
180
|
+
})
|
|
181
|
+
},
|
|
157
182
|
getEventLogs: async ({
|
|
158
183
|
address,
|
|
159
184
|
topic0,
|
|
@@ -166,13 +191,14 @@ export const createBlockscout = ({
|
|
|
166
191
|
const toBlock = toBlockParam ?? 'latest'
|
|
167
192
|
const maxPageSize = 10_000
|
|
168
193
|
while (true) {
|
|
194
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
169
195
|
const result = await getEventLogsByAddressAndTopic({
|
|
170
196
|
client,
|
|
171
197
|
address,
|
|
172
198
|
topic0,
|
|
173
199
|
fromBlock,
|
|
174
200
|
toBlock,
|
|
175
|
-
headers,
|
|
201
|
+
headers: resolvedHeaders,
|
|
176
202
|
})
|
|
177
203
|
logs.push(...result)
|
|
178
204
|
if (result.length < maxPageSize) {
|
|
@@ -183,11 +209,13 @@ export const createBlockscout = ({
|
|
|
183
209
|
}
|
|
184
210
|
return logs
|
|
185
211
|
},
|
|
186
|
-
getInternalTransactionOfTransaction: ({ hash, headers }) =>
|
|
187
|
-
|
|
212
|
+
getInternalTransactionOfTransaction: async ({ hash, headers }) => {
|
|
213
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
214
|
+
return getInternalTransactionsByTransactionHash({
|
|
188
215
|
client,
|
|
189
216
|
txhash: hash,
|
|
190
|
-
headers,
|
|
191
|
-
})
|
|
217
|
+
headers: resolvedHeaders,
|
|
218
|
+
})
|
|
219
|
+
},
|
|
192
220
|
}
|
|
193
221
|
}
|
|
@@ -2,7 +2,7 @@ import type { Erc20Transfer, LowerHex } from '../../types'
|
|
|
2
2
|
import type { InternalTransactionWithIndex } from '../../types/internalTransaction'
|
|
3
3
|
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
4
4
|
import { createInternalTransactionId } from '../../utils/createInternalTransactionId'
|
|
5
|
-
import type { Explorer, LogWithBlockNumber } from '../types'
|
|
5
|
+
import type { Explorer, HeadersInput, LogWithBlockNumber } from '../types'
|
|
6
6
|
import { createEtherscanClient } from './client'
|
|
7
7
|
import { getBlockNumberByTimestamp } from './getBlockNumberByTimestamp'
|
|
8
8
|
import { getContractCreatorAndCreationTxHash } from './getContractCreatorAndCreationTxHash'
|
|
@@ -15,6 +15,22 @@ import { getListOfErc1155TokenTransferEventsByAddress } from './getListOfErc1155
|
|
|
15
15
|
import { getListOfInternalTransactionsByAddress } from './getListOfInternalTransactionsByAddress'
|
|
16
16
|
import { getListOfNormalTransactionsByAddress } from './getListOfNormalTransactionsByAddress'
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Resolves headers from either a static object or a function that returns headers.
|
|
20
|
+
* This allows for dynamic header generation (e.g., refreshing auth tokens).
|
|
21
|
+
*/
|
|
22
|
+
const resolveHeaders = async (
|
|
23
|
+
headers: HeadersInput,
|
|
24
|
+
): Promise<Record<string, string> | undefined> => {
|
|
25
|
+
if (headers === undefined) {
|
|
26
|
+
return undefined
|
|
27
|
+
}
|
|
28
|
+
if (typeof headers === 'function') {
|
|
29
|
+
return await headers()
|
|
30
|
+
}
|
|
31
|
+
return headers
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
type CreateEtherscanParameters = {
|
|
19
35
|
name: string
|
|
20
36
|
baseUrl: string
|
|
@@ -54,13 +70,14 @@ export const createEtherscan = ({
|
|
|
54
70
|
let startblock = fromBlock
|
|
55
71
|
const endblock = toBlock
|
|
56
72
|
while (true) {
|
|
73
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
57
74
|
const result = await getListOfInternalTransactionsByAddress({
|
|
58
75
|
client,
|
|
59
76
|
address,
|
|
60
77
|
startblock,
|
|
61
78
|
endblock,
|
|
62
79
|
offset: pageSize,
|
|
63
|
-
headers,
|
|
80
|
+
headers: resolvedHeaders,
|
|
64
81
|
})
|
|
65
82
|
for (const transaction of result) {
|
|
66
83
|
const id = createInternalTransactionId(transaction)
|
|
@@ -86,13 +103,14 @@ export const createEtherscan = ({
|
|
|
86
103
|
let startblock = fromBlock
|
|
87
104
|
const endblock = toBlock
|
|
88
105
|
while (true) {
|
|
106
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
89
107
|
const result = await getListOfNormalTransactionsByAddress({
|
|
90
108
|
client,
|
|
91
109
|
address,
|
|
92
110
|
startblock,
|
|
93
111
|
endblock,
|
|
94
112
|
offset: pageSize,
|
|
95
|
-
headers,
|
|
113
|
+
headers: resolvedHeaders,
|
|
96
114
|
})
|
|
97
115
|
for (const index of result) {
|
|
98
116
|
if (!indexes.has(index.hash)) {
|
|
@@ -120,6 +138,7 @@ export const createEtherscan = ({
|
|
|
120
138
|
// ERC20
|
|
121
139
|
let startblock = fromBlock
|
|
122
140
|
while (true) {
|
|
141
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
123
142
|
const { indexes: resultIndexes, erc20Transfers: resultErc20Transfers } =
|
|
124
143
|
await getListOfErc20TokenTransferEventsByAddress({
|
|
125
144
|
client,
|
|
@@ -127,7 +146,7 @@ export const createEtherscan = ({
|
|
|
127
146
|
startblock,
|
|
128
147
|
endblock,
|
|
129
148
|
offset: pageSize,
|
|
130
|
-
headers,
|
|
149
|
+
headers: resolvedHeaders,
|
|
131
150
|
})
|
|
132
151
|
for (const index of resultIndexes) {
|
|
133
152
|
if (!indexes.has(index.hash)) {
|
|
@@ -147,13 +166,14 @@ export const createEtherscan = ({
|
|
|
147
166
|
// ERC721
|
|
148
167
|
startblock = fromBlock
|
|
149
168
|
while (true) {
|
|
169
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
150
170
|
const result = await getListOfErc721TokenTransferEventsByAddress({
|
|
151
171
|
client,
|
|
152
172
|
address,
|
|
153
173
|
startblock,
|
|
154
174
|
endblock,
|
|
155
175
|
offset: pageSize,
|
|
156
|
-
headers,
|
|
176
|
+
headers: resolvedHeaders,
|
|
157
177
|
})
|
|
158
178
|
for (const index of result) {
|
|
159
179
|
if (!indexes.has(index.hash)) {
|
|
@@ -170,13 +190,14 @@ export const createEtherscan = ({
|
|
|
170
190
|
// ERC1155
|
|
171
191
|
startblock = fromBlock
|
|
172
192
|
while (true) {
|
|
193
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
173
194
|
const result = await getListOfErc1155TokenTransferEventsByAddress({
|
|
174
195
|
client,
|
|
175
196
|
address,
|
|
176
197
|
startblock,
|
|
177
198
|
endblock,
|
|
178
199
|
offset: pageSize,
|
|
179
|
-
headers,
|
|
200
|
+
headers: resolvedHeaders,
|
|
180
201
|
})
|
|
181
202
|
for (const index of result) {
|
|
182
203
|
if (!indexes.has(index.hash)) {
|
|
@@ -195,24 +216,33 @@ export const createEtherscan = ({
|
|
|
195
216
|
erc20Transfers,
|
|
196
217
|
}
|
|
197
218
|
},
|
|
198
|
-
getBlockNumberOfTimestamp: ({
|
|
199
|
-
|
|
219
|
+
getBlockNumberOfTimestamp: async ({
|
|
220
|
+
timestamp,
|
|
221
|
+
headers,
|
|
222
|
+
}): Promise<number> => {
|
|
223
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
224
|
+
return getBlockNumberByTimestamp({
|
|
200
225
|
client,
|
|
201
226
|
timestamp: Math.floor(timestamp / 1000),
|
|
202
|
-
headers,
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
|
|
227
|
+
headers: resolvedHeaders,
|
|
228
|
+
})
|
|
229
|
+
},
|
|
230
|
+
getContract: async ({ address, headers }) => {
|
|
231
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
232
|
+
return getContractSourceCodeForVerifiedContract({
|
|
206
233
|
client,
|
|
207
234
|
address,
|
|
208
|
-
headers,
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
|
|
235
|
+
headers: resolvedHeaders,
|
|
236
|
+
})
|
|
237
|
+
},
|
|
238
|
+
getContractCreations: async ({ addresses, headers }) => {
|
|
239
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
240
|
+
return getContractCreatorAndCreationTxHash({
|
|
212
241
|
client,
|
|
213
242
|
contractaddresses: addresses,
|
|
214
|
-
headers,
|
|
215
|
-
})
|
|
243
|
+
headers: resolvedHeaders,
|
|
244
|
+
})
|
|
245
|
+
},
|
|
216
246
|
getEventLogs: async ({
|
|
217
247
|
address,
|
|
218
248
|
topic0,
|
|
@@ -224,13 +254,14 @@ export const createEtherscan = ({
|
|
|
224
254
|
let fromBlock = fromBlockParam ?? 0
|
|
225
255
|
const maxPageSize = 10_000
|
|
226
256
|
while (true) {
|
|
257
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
227
258
|
const result = await getEventLogsByAddressFilteredByTopics({
|
|
228
259
|
client,
|
|
229
260
|
address,
|
|
230
261
|
topic0,
|
|
231
262
|
fromBlock,
|
|
232
263
|
toBlock,
|
|
233
|
-
headers,
|
|
264
|
+
headers: resolvedHeaders,
|
|
234
265
|
})
|
|
235
266
|
logs.push(...result)
|
|
236
267
|
if (result.length < maxPageSize) {
|
|
@@ -241,11 +272,13 @@ export const createEtherscan = ({
|
|
|
241
272
|
}
|
|
242
273
|
return logs
|
|
243
274
|
},
|
|
244
|
-
getInternalTransactionOfTransaction: ({ hash, headers }) =>
|
|
245
|
-
|
|
275
|
+
getInternalTransactionOfTransaction: async ({ hash, headers }) => {
|
|
276
|
+
const resolvedHeaders = await resolveHeaders(headers)
|
|
277
|
+
return getInternalTransactionsByTransactionHash({
|
|
246
278
|
client,
|
|
247
279
|
txhash: hash,
|
|
248
|
-
headers,
|
|
249
|
-
})
|
|
280
|
+
headers: resolvedHeaders,
|
|
281
|
+
})
|
|
282
|
+
},
|
|
250
283
|
}
|
|
251
284
|
}
|