@0xtorch/evm 0.0.125 → 0.0.127
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/chain/definitions/ethereum.js +2 -2
- package/_cjs/chain/definitions/ethereum.js.map +1 -1
- package/_cjs/chain/index.js +17 -1
- package/_cjs/chain/index.js.map +1 -1
- package/_cjs/explorer/etherscanV2/client.js +94 -0
- package/_cjs/explorer/etherscanV2/client.js.map +1 -0
- package/_cjs/explorer/etherscanV2/create.js +196 -0
- package/_cjs/explorer/etherscanV2/create.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getBlockNumberByTimestamp.js +21 -0
- package/_cjs/explorer/etherscanV2/getBlockNumberByTimestamp.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js +34 -0
- package/_cjs/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js +36 -0
- package/_cjs/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js +48 -0
- package/_cjs/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js +64 -0
- package/_cjs/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js +51 -0
- package/_cjs/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js +69 -0
- package/_cjs/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js +47 -0
- package/_cjs/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js +74 -0
- package/_cjs/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js.map +1 -0
- package/_cjs/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js +51 -0
- package/_cjs/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js.map +1 -0
- package/_cjs/explorer/index.js +9 -7
- package/_cjs/explorer/index.js.map +1 -1
- package/_cjs/index.js +16 -3
- package/_cjs/index.js.map +1 -1
- package/_esm/chain/definitions/ethereum.js +3 -3
- package/_esm/chain/definitions/ethereum.js.map +1 -1
- package/_esm/chain/index.js +3 -0
- package/_esm/chain/index.js.map +1 -1
- package/_esm/explorer/etherscanV2/client.js +95 -0
- package/_esm/explorer/etherscanV2/client.js.map +1 -0
- package/_esm/explorer/etherscanV2/create.js +195 -0
- package/_esm/explorer/etherscanV2/create.js.map +1 -0
- package/_esm/explorer/etherscanV2/getBlockNumberByTimestamp.js +18 -0
- package/_esm/explorer/etherscanV2/getBlockNumberByTimestamp.js.map +1 -0
- package/_esm/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js +31 -0
- package/_esm/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js.map +1 -0
- package/_esm/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js +33 -0
- package/_esm/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js.map +1 -0
- package/_esm/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js +45 -0
- package/_esm/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js.map +1 -0
- package/_esm/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js +61 -0
- package/_esm/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js.map +1 -0
- package/_esm/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js +48 -0
- package/_esm/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js.map +1 -0
- package/_esm/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js +66 -0
- package/_esm/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js.map +1 -0
- package/_esm/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js +44 -0
- package/_esm/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js.map +1 -0
- package/_esm/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js +71 -0
- package/_esm/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js.map +1 -0
- package/_esm/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js +48 -0
- package/_esm/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js.map +1 -0
- package/_esm/explorer/index.js +1 -0
- package/_esm/explorer/index.js.map +1 -1
- package/_esm/index.js +2 -2
- package/_esm/index.js.map +1 -1
- package/_types/chain/index.d.ts +3 -0
- package/_types/chain/index.d.ts.map +1 -1
- package/_types/explorer/etherscanV2/client.d.ts +17 -0
- package/_types/explorer/etherscanV2/client.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/create.d.ts +12 -0
- package/_types/explorer/etherscanV2/create.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getBlockNumberByTimestamp.d.ts +12 -0
- package/_types/explorer/etherscanV2/getBlockNumberByTimestamp.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getContractCreatorAndCreationTxHash.d.ts +12 -0
- package/_types/explorer/etherscanV2/getContractCreatorAndCreationTxHash.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.d.ts +12 -0
- package/_types/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.d.ts +16 -0
- package/_types/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getInternalTransactionsByTransactionHash.d.ts +12 -0
- package/_types/explorer/etherscanV2/getInternalTransactionsByTransactionHash.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.d.ts +16 -0
- package/_types/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.d.ts +20 -0
- package/_types/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.d.ts +16 -0
- package/_types/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getListOfInternalTransactionsByAddress.d.ts +17 -0
- package/_types/explorer/etherscanV2/getListOfInternalTransactionsByAddress.d.ts.map +1 -0
- package/_types/explorer/etherscanV2/getListOfNormalTransactionsByAddress.d.ts +17 -0
- package/_types/explorer/etherscanV2/getListOfNormalTransactionsByAddress.d.ts.map +1 -0
- package/_types/explorer/index.d.ts +1 -0
- package/_types/explorer/index.d.ts.map +1 -1
- package/_types/index.d.ts +2 -2
- package/_types/index.d.ts.map +1 -1
- package/chain/definitions/ethereum.ts +3 -3
- package/chain/index.ts +18 -0
- package/explorer/etherscanV2/client.ts +154 -0
- package/explorer/etherscanV2/create.ts +251 -0
- package/explorer/etherscanV2/getBlockNumberByTimestamp.ts +33 -0
- package/explorer/etherscanV2/getContractCreatorAndCreationTxHash.ts +46 -0
- package/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.ts +54 -0
- package/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.ts +67 -0
- package/explorer/etherscanV2/getInternalTransactionsByTransactionHash.ts +76 -0
- package/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.ts +74 -0
- package/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.ts +92 -0
- package/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.ts +68 -0
- package/explorer/etherscanV2/getListOfInternalTransactionsByAddress.ts +100 -0
- package/explorer/etherscanV2/getListOfNormalTransactionsByAddress.ts +73 -0
- package/explorer/index.ts +1 -0
- package/index.ts +13 -0
- package/package.json +1 -1
- package/analyzer/.DS_Store +0 -0
- package/chain/.DS_Store +0 -0
- package/client/.DS_Store +0 -0
- package/explorer/.DS_Store +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { lowerHexSchema } from '../../types/primitive'
|
|
3
|
+
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
4
|
+
import type { EtherscanV2Client } from './client'
|
|
5
|
+
|
|
6
|
+
type GetListOfErc1155TokenTransferEventsByAddressParameters = {
|
|
7
|
+
client: EtherscanV2Client
|
|
8
|
+
address: string
|
|
9
|
+
startblock?: number
|
|
10
|
+
endblock?: number
|
|
11
|
+
page?: number
|
|
12
|
+
offset?: number
|
|
13
|
+
sort?: 'asc' | 'desc'
|
|
14
|
+
headers?: Record<string, string>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const transferSchema = z.object({
|
|
18
|
+
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
19
|
+
hash: lowerHexSchema,
|
|
20
|
+
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
21
|
+
})
|
|
22
|
+
const resultSchema = z.array(transferSchema)
|
|
23
|
+
|
|
24
|
+
/** {@link https://docs.etherscan.io/etherscan-v2/api-endpoints/accounts#get-a-list-of-erc1155-token-transfer-events-by-address} */
|
|
25
|
+
export const getListOfErc1155TokenTransferEventsByAddress = async ({
|
|
26
|
+
client,
|
|
27
|
+
address,
|
|
28
|
+
startblock = 0,
|
|
29
|
+
endblock,
|
|
30
|
+
page = 1,
|
|
31
|
+
offset = 10_000,
|
|
32
|
+
sort = 'asc',
|
|
33
|
+
headers,
|
|
34
|
+
}: GetListOfErc1155TokenTransferEventsByAddressParameters): Promise<
|
|
35
|
+
TransactionIndex[]
|
|
36
|
+
> => {
|
|
37
|
+
try {
|
|
38
|
+
const result = await client.get({
|
|
39
|
+
path: '',
|
|
40
|
+
query: {
|
|
41
|
+
module: 'account',
|
|
42
|
+
action: 'token1155tx',
|
|
43
|
+
address,
|
|
44
|
+
startblock: startblock.toString(),
|
|
45
|
+
...(endblock === undefined
|
|
46
|
+
? {}
|
|
47
|
+
: {
|
|
48
|
+
endblock: endblock.toString(),
|
|
49
|
+
}),
|
|
50
|
+
page: page.toString(),
|
|
51
|
+
offset: offset.toString(),
|
|
52
|
+
sort,
|
|
53
|
+
},
|
|
54
|
+
resultSchema,
|
|
55
|
+
headers,
|
|
56
|
+
})
|
|
57
|
+
return result.map((v) => ({
|
|
58
|
+
blockNumber: v.blockNumber,
|
|
59
|
+
hash: v.hash,
|
|
60
|
+
timestamp: v.timeStamp * 1000,
|
|
61
|
+
}))
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (
|
|
64
|
+
error instanceof Error &&
|
|
65
|
+
(error.message === 'No transactions found' ||
|
|
66
|
+
error.message === 'Error! Missing Or invalid Action name' ||
|
|
67
|
+
error.message ===
|
|
68
|
+
'Query Timeout occured. Please select a smaller result dataset')
|
|
69
|
+
) {
|
|
70
|
+
return []
|
|
71
|
+
}
|
|
72
|
+
throw error
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { Erc20Transfer } from '../../types'
|
|
3
|
+
import { bigintTextSchema, lowerHexSchema } from '../../types/primitive'
|
|
4
|
+
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
5
|
+
import type { EtherscanV2Client } from './client'
|
|
6
|
+
|
|
7
|
+
type GetListOfErc20TokenTransferEventsByAddressParameters = {
|
|
8
|
+
client: EtherscanV2Client
|
|
9
|
+
address: string
|
|
10
|
+
startblock?: number
|
|
11
|
+
endblock?: number
|
|
12
|
+
page?: number
|
|
13
|
+
offset?: number
|
|
14
|
+
sort?: 'asc' | 'desc'
|
|
15
|
+
headers?: Record<string, string>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const transferSchema = z.object({
|
|
19
|
+
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
20
|
+
hash: lowerHexSchema,
|
|
21
|
+
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
22
|
+
contractAddress: lowerHexSchema,
|
|
23
|
+
from: lowerHexSchema,
|
|
24
|
+
to: lowerHexSchema,
|
|
25
|
+
value: bigintTextSchema,
|
|
26
|
+
})
|
|
27
|
+
const resultSchema = z.array(transferSchema)
|
|
28
|
+
|
|
29
|
+
/** {@link https://docs.etherscan.io/etherscan-v2/api-endpoints/accounts#get-a-list-of-erc20-token-transfer-events-by-address} */
|
|
30
|
+
export const getListOfErc20TokenTransferEventsByAddress = async ({
|
|
31
|
+
client,
|
|
32
|
+
address,
|
|
33
|
+
startblock = 0,
|
|
34
|
+
endblock,
|
|
35
|
+
page = 1,
|
|
36
|
+
offset = 10_000,
|
|
37
|
+
sort = 'asc',
|
|
38
|
+
headers,
|
|
39
|
+
}: GetListOfErc20TokenTransferEventsByAddressParameters): Promise<{
|
|
40
|
+
indexes: readonly TransactionIndex[]
|
|
41
|
+
erc20Transfers: readonly Erc20Transfer[]
|
|
42
|
+
}> => {
|
|
43
|
+
try {
|
|
44
|
+
const result = await client.get({
|
|
45
|
+
path: '',
|
|
46
|
+
query: {
|
|
47
|
+
module: 'account',
|
|
48
|
+
action: 'tokentx',
|
|
49
|
+
address,
|
|
50
|
+
startblock: startblock.toString(),
|
|
51
|
+
...(endblock === undefined
|
|
52
|
+
? {}
|
|
53
|
+
: {
|
|
54
|
+
endblock: endblock.toString(),
|
|
55
|
+
}),
|
|
56
|
+
page: page.toString(),
|
|
57
|
+
offset: offset.toString(),
|
|
58
|
+
sort,
|
|
59
|
+
},
|
|
60
|
+
resultSchema,
|
|
61
|
+
headers,
|
|
62
|
+
})
|
|
63
|
+
const indexes: TransactionIndex[] = []
|
|
64
|
+
const transfers: Erc20Transfer[] = []
|
|
65
|
+
for (const data of result) {
|
|
66
|
+
indexes.push({
|
|
67
|
+
blockNumber: data.blockNumber,
|
|
68
|
+
hash: data.hash,
|
|
69
|
+
timestamp: data.timeStamp * 1000,
|
|
70
|
+
})
|
|
71
|
+
transfers.push({
|
|
72
|
+
address: data.contractAddress,
|
|
73
|
+
from: data.from,
|
|
74
|
+
logIndex: 0,
|
|
75
|
+
to: data.to,
|
|
76
|
+
value: data.value,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
indexes,
|
|
81
|
+
erc20Transfers: transfers,
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (error instanceof Error && error.message === 'No transactions found') {
|
|
85
|
+
return {
|
|
86
|
+
indexes: [],
|
|
87
|
+
erc20Transfers: [],
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
throw error
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { lowerHexSchema } from '../../types/primitive'
|
|
3
|
+
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
4
|
+
import type { EtherscanV2Client } from './client'
|
|
5
|
+
|
|
6
|
+
type GetListOfErc721TokenTransferEventsByAddressParameters = {
|
|
7
|
+
client: EtherscanV2Client
|
|
8
|
+
address: string
|
|
9
|
+
startblock?: number
|
|
10
|
+
endblock?: number
|
|
11
|
+
page?: number
|
|
12
|
+
offset?: number
|
|
13
|
+
sort?: 'asc' | 'desc'
|
|
14
|
+
headers?: Record<string, string>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const transferSchema = z.object({
|
|
18
|
+
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
19
|
+
hash: lowerHexSchema,
|
|
20
|
+
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
21
|
+
})
|
|
22
|
+
const resultSchema = z.array(transferSchema)
|
|
23
|
+
|
|
24
|
+
/** {@link https://docs.etherscan.io/etherscan-v2/api-endpoints/accounts#get-a-list-of-erc721-token-transfer-events-by-address} */
|
|
25
|
+
export const getListOfErc721TokenTransferEventsByAddress = async ({
|
|
26
|
+
client,
|
|
27
|
+
address,
|
|
28
|
+
startblock = 0,
|
|
29
|
+
endblock,
|
|
30
|
+
page = 1,
|
|
31
|
+
offset = 10_000,
|
|
32
|
+
sort = 'asc',
|
|
33
|
+
headers,
|
|
34
|
+
}: GetListOfErc721TokenTransferEventsByAddressParameters): Promise<
|
|
35
|
+
TransactionIndex[]
|
|
36
|
+
> => {
|
|
37
|
+
try {
|
|
38
|
+
const result = await client.get({
|
|
39
|
+
path: '',
|
|
40
|
+
query: {
|
|
41
|
+
module: 'account',
|
|
42
|
+
action: 'tokennfttx',
|
|
43
|
+
address,
|
|
44
|
+
startblock: startblock.toString(),
|
|
45
|
+
...(endblock === undefined
|
|
46
|
+
? {}
|
|
47
|
+
: {
|
|
48
|
+
endblock: endblock.toString(),
|
|
49
|
+
}),
|
|
50
|
+
page: page.toString(),
|
|
51
|
+
offset: offset.toString(),
|
|
52
|
+
sort,
|
|
53
|
+
},
|
|
54
|
+
resultSchema,
|
|
55
|
+
headers,
|
|
56
|
+
})
|
|
57
|
+
return result.map((v) => ({
|
|
58
|
+
blockNumber: v.blockNumber,
|
|
59
|
+
hash: v.hash,
|
|
60
|
+
timestamp: v.timeStamp * 1000,
|
|
61
|
+
}))
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (error instanceof Error && error.message === 'No transactions found') {
|
|
64
|
+
return []
|
|
65
|
+
}
|
|
66
|
+
throw error
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { Hex } from '../../types'
|
|
3
|
+
import type { InternalTransactionWithIndex } from '../../types/internalTransaction'
|
|
4
|
+
import {
|
|
5
|
+
addressPrimitiveSchema,
|
|
6
|
+
bigintTextSchema,
|
|
7
|
+
lowerHexSchema,
|
|
8
|
+
} from '../../types/primitive'
|
|
9
|
+
import type { EtherscanV2Client } from './client'
|
|
10
|
+
|
|
11
|
+
type GetListOfInternalTransactionsByAddressParameters = {
|
|
12
|
+
client: EtherscanV2Client
|
|
13
|
+
address: Hex
|
|
14
|
+
startblock?: number
|
|
15
|
+
endblock?: number
|
|
16
|
+
page?: number
|
|
17
|
+
offset?: number
|
|
18
|
+
sort?: 'asc' | 'desc'
|
|
19
|
+
headers?: Record<string, string>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const internalTransactionSchema = z.object({
|
|
23
|
+
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
24
|
+
contractAddress: z.union([
|
|
25
|
+
addressPrimitiveSchema,
|
|
26
|
+
z
|
|
27
|
+
.literal('')
|
|
28
|
+
.nullable()
|
|
29
|
+
.transform(() => undefined),
|
|
30
|
+
]),
|
|
31
|
+
from: addressPrimitiveSchema,
|
|
32
|
+
gas: bigintTextSchema,
|
|
33
|
+
hash: lowerHexSchema,
|
|
34
|
+
isError: z
|
|
35
|
+
.string()
|
|
36
|
+
.regex(/^\d+$/)
|
|
37
|
+
.transform((x) => x === '1'),
|
|
38
|
+
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
39
|
+
to: z.union([
|
|
40
|
+
addressPrimitiveSchema,
|
|
41
|
+
z
|
|
42
|
+
.literal('')
|
|
43
|
+
.nullable()
|
|
44
|
+
.transform(() => undefined),
|
|
45
|
+
]),
|
|
46
|
+
value: bigintTextSchema,
|
|
47
|
+
})
|
|
48
|
+
const resultSchema = z.array(internalTransactionSchema)
|
|
49
|
+
|
|
50
|
+
/** {@link https://docs.etherscan.io/etherscan-v2/api-endpoints/accounts#get-a-list-of-internal-transactions-by-address} */
|
|
51
|
+
export const getListOfInternalTransactionsByAddress = async ({
|
|
52
|
+
client,
|
|
53
|
+
address,
|
|
54
|
+
startblock = 0,
|
|
55
|
+
endblock,
|
|
56
|
+
page = 1,
|
|
57
|
+
offset = 10_000,
|
|
58
|
+
sort = 'asc',
|
|
59
|
+
headers,
|
|
60
|
+
}: GetListOfInternalTransactionsByAddressParameters): Promise<
|
|
61
|
+
InternalTransactionWithIndex[]
|
|
62
|
+
> => {
|
|
63
|
+
try {
|
|
64
|
+
const result = await client.get({
|
|
65
|
+
path: '',
|
|
66
|
+
query: {
|
|
67
|
+
module: 'account',
|
|
68
|
+
action: 'txlistinternal',
|
|
69
|
+
address,
|
|
70
|
+
startblock: startblock.toString(),
|
|
71
|
+
...(endblock === undefined
|
|
72
|
+
? {}
|
|
73
|
+
: {
|
|
74
|
+
endblock: endblock.toString(),
|
|
75
|
+
}),
|
|
76
|
+
page: page.toString(),
|
|
77
|
+
offset: offset.toString(),
|
|
78
|
+
sort,
|
|
79
|
+
},
|
|
80
|
+
resultSchema,
|
|
81
|
+
headers,
|
|
82
|
+
})
|
|
83
|
+
return result.map((v) => ({
|
|
84
|
+
blockNumber: v.blockNumber,
|
|
85
|
+
contractAddress: v.contractAddress,
|
|
86
|
+
from: v.from,
|
|
87
|
+
gas: v.gas,
|
|
88
|
+
isError: v.isError,
|
|
89
|
+
timestamp: v.timeStamp * 1000,
|
|
90
|
+
to: v.to,
|
|
91
|
+
txHash: v.hash,
|
|
92
|
+
value: v.value,
|
|
93
|
+
}))
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof Error && error.message === 'No transactions found') {
|
|
96
|
+
return []
|
|
97
|
+
}
|
|
98
|
+
throw error
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { Hex } from '../../types'
|
|
3
|
+
import { bigintTextSchema, lowerHexSchema } from '../../types/primitive'
|
|
4
|
+
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
5
|
+
import type { EtherscanV2Client } from './client'
|
|
6
|
+
|
|
7
|
+
type GetListOfNormalTransactionsByAddressParameters = {
|
|
8
|
+
client: EtherscanV2Client
|
|
9
|
+
address: Hex
|
|
10
|
+
startblock?: number
|
|
11
|
+
endblock?: number
|
|
12
|
+
page?: number
|
|
13
|
+
offset?: number
|
|
14
|
+
sort?: 'asc' | 'desc'
|
|
15
|
+
headers?: Record<string, string>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const transactionSchema = z.object({
|
|
19
|
+
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
20
|
+
hash: lowerHexSchema,
|
|
21
|
+
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
22
|
+
input: lowerHexSchema,
|
|
23
|
+
value: bigintTextSchema,
|
|
24
|
+
})
|
|
25
|
+
const resultSchema = z.array(transactionSchema)
|
|
26
|
+
|
|
27
|
+
/** {@link https://docs.etherscan.io/etherscan-v2/api-endpoints/accounts#get-a-list-of-normal-transactions-by-address} */
|
|
28
|
+
export const getListOfNormalTransactionsByAddress = async ({
|
|
29
|
+
client,
|
|
30
|
+
address,
|
|
31
|
+
startblock = 0,
|
|
32
|
+
endblock,
|
|
33
|
+
page = 1,
|
|
34
|
+
offset = 10_000,
|
|
35
|
+
sort = 'asc',
|
|
36
|
+
headers,
|
|
37
|
+
}: GetListOfNormalTransactionsByAddressParameters): Promise<
|
|
38
|
+
TransactionIndex[]
|
|
39
|
+
> => {
|
|
40
|
+
try {
|
|
41
|
+
const result = await client.get({
|
|
42
|
+
path: '',
|
|
43
|
+
query: {
|
|
44
|
+
module: 'account',
|
|
45
|
+
action: 'txlist',
|
|
46
|
+
address,
|
|
47
|
+
startblock: startblock.toString(),
|
|
48
|
+
...(endblock === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: {
|
|
51
|
+
endblock: endblock.toString(),
|
|
52
|
+
}),
|
|
53
|
+
page: page.toString(),
|
|
54
|
+
offset: offset.toString(),
|
|
55
|
+
sort,
|
|
56
|
+
},
|
|
57
|
+
resultSchema,
|
|
58
|
+
headers,
|
|
59
|
+
})
|
|
60
|
+
return result.map((v) => ({
|
|
61
|
+
blockNumber: v.blockNumber,
|
|
62
|
+
hash: v.hash,
|
|
63
|
+
timestamp: v.timeStamp * 1000,
|
|
64
|
+
input: v.input,
|
|
65
|
+
value: v.value,
|
|
66
|
+
}))
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error instanceof Error && error.message === 'No transactions found') {
|
|
69
|
+
return []
|
|
70
|
+
}
|
|
71
|
+
throw error
|
|
72
|
+
}
|
|
73
|
+
}
|
package/explorer/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createEtherscan } from './etherscan/create'
|
|
2
|
+
export { createEtherscanV2 } from './etherscanV2/create'
|
|
2
3
|
export type { Explorer } from './types'
|
|
3
4
|
export { createMoralisExplorer } from './moralis/create'
|
|
4
5
|
export { createNoApiExplorer } from './noApiExplorer/create'
|
package/index.ts
CHANGED
|
@@ -76,6 +76,12 @@ export {
|
|
|
76
76
|
createSaakuruChainCustom,
|
|
77
77
|
createScrollChain,
|
|
78
78
|
createScrollChainCustom,
|
|
79
|
+
createSoneiumChain,
|
|
80
|
+
createSoneiumChainCustom,
|
|
81
|
+
createSonicChain,
|
|
82
|
+
createSonicChainCustom,
|
|
83
|
+
createTaikoChain,
|
|
84
|
+
createTaikoChainCustom,
|
|
79
85
|
createTcgVerseChain,
|
|
80
86
|
createTcgVerseChainCustom,
|
|
81
87
|
createYooldoVerseChain,
|
|
@@ -130,6 +136,12 @@ export {
|
|
|
130
136
|
saakuruWebsocketRpcUrls,
|
|
131
137
|
scrollHttpRpcs,
|
|
132
138
|
scrollWebsocketRpcUrls,
|
|
139
|
+
soneiumHttpRpcs,
|
|
140
|
+
soneiumWebsocketRpcUrls,
|
|
141
|
+
sonicHttpRpcs,
|
|
142
|
+
sonicWebsocketRpcUrls,
|
|
143
|
+
taikoHttpRpcs,
|
|
144
|
+
taikoWebsocketRpcUrls,
|
|
133
145
|
tcgVerseHttpRpcs,
|
|
134
146
|
tcgVerseWebsocketRpcUrls,
|
|
135
147
|
yooldoVerseHttpRpcs,
|
|
@@ -146,6 +158,7 @@ export { createClient } from './client'
|
|
|
146
158
|
export {
|
|
147
159
|
createBlockscout,
|
|
148
160
|
createEtherscan,
|
|
161
|
+
createEtherscanV2,
|
|
149
162
|
createNoApiExplorer,
|
|
150
163
|
} from './explorer'
|
|
151
164
|
export type { Explorer } from './explorer'
|
package/package.json
CHANGED
package/analyzer/.DS_Store
DELETED
|
Binary file
|
package/chain/.DS_Store
DELETED
|
Binary file
|
package/client/.DS_Store
DELETED
|
Binary file
|
package/explorer/.DS_Store
DELETED
|
Binary file
|