@0xtorch/evm 0.0.109 → 0.0.111
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 +0 -15
- package/_cjs/chain/definitions/ethereum.js.map +1 -1
- package/_cjs/explorer/blockscout/create.js +10 -5
- package/_cjs/explorer/blockscout/create.js.map +1 -1
- package/_cjs/explorer/blockscout/getTokenTransferEventsByAddress.js +44 -6
- package/_cjs/explorer/blockscout/getTokenTransferEventsByAddress.js.map +1 -1
- package/_cjs/explorer/blockscout/getTransactionsByAddress.js +4 -0
- package/_cjs/explorer/blockscout/getTransactionsByAddress.js.map +1 -1
- package/_cjs/explorer/etherscan/client.js +2 -1
- package/_cjs/explorer/etherscan/client.js.map +1 -1
- package/_cjs/explorer/etherscan/create.js +10 -5
- package/_cjs/explorer/etherscan/create.js.map +1 -1
- package/_cjs/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.js +28 -6
- package/_cjs/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.js.map +1 -1
- package/_cjs/explorer/etherscan/getListOfNormalTransactionsByAddress.js +4 -0
- package/_cjs/explorer/etherscan/getListOfNormalTransactionsByAddress.js.map +1 -1
- package/_cjs/explorer/moralis/create.js +16 -1
- package/_cjs/explorer/moralis/create.js.map +1 -1
- package/_cjs/explorer/moralis/getWalletTransactionHistory.js +2 -0
- package/_cjs/explorer/moralis/getWalletTransactionHistory.js.map +1 -1
- package/_cjs/logic/getAddressIndexData.js +2 -1
- package/_cjs/logic/getAddressIndexData.js.map +1 -1
- package/_cjs/logic/getTransactionDetail/index.js +10 -5
- package/_cjs/logic/getTransactionDetail/index.js.map +1 -1
- package/_cjs/types/transactionIndex.js +7 -1
- package/_cjs/types/transactionIndex.js.map +1 -1
- package/_esm/chain/definitions/ethereum.js +18 -15
- package/_esm/chain/definitions/ethereum.js.map +1 -1
- package/_esm/explorer/blockscout/create.js +10 -5
- package/_esm/explorer/blockscout/create.js.map +1 -1
- package/_esm/explorer/blockscout/getTokenTransferEventsByAddress.js +45 -7
- package/_esm/explorer/blockscout/getTokenTransferEventsByAddress.js.map +1 -1
- package/_esm/explorer/blockscout/getTransactionsByAddress.js +5 -1
- package/_esm/explorer/blockscout/getTransactionsByAddress.js.map +1 -1
- package/_esm/explorer/etherscan/client.js +2 -1
- package/_esm/explorer/etherscan/client.js.map +1 -1
- package/_esm/explorer/etherscan/create.js +10 -5
- package/_esm/explorer/etherscan/create.js.map +1 -1
- package/_esm/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.js +29 -7
- package/_esm/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.js.map +1 -1
- package/_esm/explorer/etherscan/getListOfNormalTransactionsByAddress.js +5 -1
- package/_esm/explorer/etherscan/getListOfNormalTransactionsByAddress.js.map +1 -1
- package/_esm/explorer/moralis/create.js +16 -1
- package/_esm/explorer/moralis/create.js.map +1 -1
- package/_esm/explorer/moralis/getWalletTransactionHistory.js +2 -0
- package/_esm/explorer/moralis/getWalletTransactionHistory.js.map +1 -1
- package/_esm/logic/getAddressIndexData.js +2 -1
- package/_esm/logic/getAddressIndexData.js.map +1 -1
- package/_esm/logic/getTransactionDetail/index.js +10 -5
- package/_esm/logic/getTransactionDetail/index.js.map +1 -1
- package/_esm/types/transactionIndex.js +7 -1
- package/_esm/types/transactionIndex.js.map +1 -1
- package/_types/chain/definitions/ethereum.d.ts.map +1 -1
- package/_types/explorer/blockscout/create.d.ts.map +1 -1
- package/_types/explorer/blockscout/getTokenTransferEventsByAddress.d.ts +5 -1
- package/_types/explorer/blockscout/getTokenTransferEventsByAddress.d.ts.map +1 -1
- package/_types/explorer/blockscout/getTransactionsByAddress.d.ts.map +1 -1
- package/_types/explorer/etherscan/client.d.ts.map +1 -1
- package/_types/explorer/etherscan/create.d.ts.map +1 -1
- package/_types/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.d.ts +5 -1
- package/_types/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.d.ts.map +1 -1
- package/_types/explorer/etherscan/getListOfNormalTransactionsByAddress.d.ts.map +1 -1
- package/_types/explorer/moralis/create.d.ts.map +1 -1
- package/_types/explorer/moralis/getWalletTransactionHistory.d.ts +2 -0
- package/_types/explorer/moralis/getWalletTransactionHistory.d.ts.map +1 -1
- package/_types/explorer/types.d.ts +5 -2
- package/_types/explorer/types.d.ts.map +1 -1
- package/_types/logic/getAddressIndexData.d.ts +4 -2
- package/_types/logic/getAddressIndexData.d.ts.map +1 -1
- package/_types/logic/getTransactionDetail/index.d.ts +3 -1
- package/_types/logic/getTransactionDetail/index.d.ts.map +1 -1
- package/_types/types/transactionIndex.d.ts +9 -2
- package/_types/types/transactionIndex.d.ts.map +1 -1
- package/chain/definitions/ethereum.ts +18 -15
- package/explorer/blockscout/create.ts +20 -12
- package/explorer/blockscout/getTokenTransferEventsByAddress.ts +52 -10
- package/explorer/blockscout/getTransactionsByAddress.ts +5 -1
- package/explorer/etherscan/client.ts +6 -1
- package/explorer/etherscan/create.ts +21 -13
- package/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.ts +34 -10
- package/explorer/etherscan/getListOfNormalTransactionsByAddress.ts +5 -1
- package/explorer/moralis/create.ts +19 -2
- package/explorer/moralis/getWalletTransactionHistory.ts +2 -0
- package/explorer/types.ts +5 -2
- package/logic/getAddressIndexData.ts +26 -20
- package/logic/getTransactionDetail/index.ts +13 -4
- package/package.json +1 -1
- package/types/transactionIndex.ts +11 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
-
import {
|
|
2
|
+
import type { Erc20Transfer } from '../../types'
|
|
3
|
+
import { bigintTextSchema, lowerHexSchema } from '../../types/primitive'
|
|
3
4
|
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
4
5
|
import type { EtherscanClient } from './client'
|
|
5
6
|
|
|
@@ -18,6 +19,10 @@ const transferSchema = z.object({
|
|
|
18
19
|
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
19
20
|
hash: lowerHexSchema,
|
|
20
21
|
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
22
|
+
contractAddress: lowerHexSchema,
|
|
23
|
+
from: lowerHexSchema,
|
|
24
|
+
to: lowerHexSchema,
|
|
25
|
+
value: bigintTextSchema,
|
|
21
26
|
})
|
|
22
27
|
const resultSchema = z.array(transferSchema)
|
|
23
28
|
|
|
@@ -31,9 +36,10 @@ export const getListOfErc20TokenTransferEventsByAddress = async ({
|
|
|
31
36
|
offset = 10_000,
|
|
32
37
|
sort = 'asc',
|
|
33
38
|
headers,
|
|
34
|
-
}: GetListOfErc20TokenTransferEventsByAddressParameters): Promise<
|
|
35
|
-
TransactionIndex[]
|
|
36
|
-
|
|
39
|
+
}: GetListOfErc20TokenTransferEventsByAddressParameters): Promise<{
|
|
40
|
+
indexes: readonly TransactionIndex[]
|
|
41
|
+
erc20Transfers: readonly Erc20Transfer[]
|
|
42
|
+
}> => {
|
|
37
43
|
try {
|
|
38
44
|
const result = await client.get({
|
|
39
45
|
path: '',
|
|
@@ -54,14 +60,32 @@ export const getListOfErc20TokenTransferEventsByAddress = async ({
|
|
|
54
60
|
resultSchema,
|
|
55
61
|
headers,
|
|
56
62
|
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
}
|
|
62
83
|
} catch (error) {
|
|
63
84
|
if (error instanceof Error && error.message === 'No transactions found') {
|
|
64
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
indexes: [],
|
|
87
|
+
erc20Transfers: [],
|
|
88
|
+
}
|
|
65
89
|
}
|
|
66
90
|
throw error
|
|
67
91
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import type { Hex } from '../../types'
|
|
3
|
-
import { lowerHexSchema } from '../../types/primitive'
|
|
3
|
+
import { bigintTextSchema, lowerHexSchema } from '../../types/primitive'
|
|
4
4
|
import type { TransactionIndex } from '../../types/transactionIndex'
|
|
5
5
|
import type { EtherscanClient } from './client'
|
|
6
6
|
|
|
@@ -19,6 +19,8 @@ const transactionSchema = z.object({
|
|
|
19
19
|
blockNumber: z.string().regex(/^\d+$/).transform(Number),
|
|
20
20
|
hash: lowerHexSchema,
|
|
21
21
|
timeStamp: z.string().regex(/^\d+$/).transform(Number),
|
|
22
|
+
input: lowerHexSchema,
|
|
23
|
+
value: bigintTextSchema,
|
|
22
24
|
})
|
|
23
25
|
const resultSchema = z.array(transactionSchema)
|
|
24
26
|
|
|
@@ -59,6 +61,8 @@ export const getListOfNormalTransactionsByAddress = async ({
|
|
|
59
61
|
blockNumber: v.blockNumber,
|
|
60
62
|
hash: v.hash,
|
|
61
63
|
timestamp: v.timeStamp * 1000,
|
|
64
|
+
input: v.input,
|
|
65
|
+
value: v.value,
|
|
62
66
|
}))
|
|
63
67
|
} catch (error) {
|
|
64
68
|
if (error instanceof Error && error.message === 'No transactions found') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type Erc20Transfer,
|
|
2
3
|
type InternalTransactionWithIndex,
|
|
3
4
|
type LowerHex,
|
|
4
5
|
type TransactionIndex,
|
|
@@ -123,6 +124,7 @@ export const createMoralisExplorer = ({
|
|
|
123
124
|
hash: transaction.hash,
|
|
124
125
|
blockNumber: transaction.block_number,
|
|
125
126
|
timestamp: transaction.block_timestamp,
|
|
127
|
+
value: transaction.value,
|
|
126
128
|
}
|
|
127
129
|
indexes.set(data.hash, data)
|
|
128
130
|
}
|
|
@@ -140,9 +142,10 @@ export const createMoralisExplorer = ({
|
|
|
140
142
|
fromBlock,
|
|
141
143
|
toBlock,
|
|
142
144
|
headers,
|
|
143
|
-
})
|
|
145
|
+
}) => {
|
|
144
146
|
const lowerAddress = toLowerHex(address)
|
|
145
147
|
const indexes = new Map<LowerHex, TransactionIndex>()
|
|
148
|
+
const erc20Transfers: Erc20Transfer[] = []
|
|
146
149
|
|
|
147
150
|
let count = 0
|
|
148
151
|
let cursor: string | undefined = undefined
|
|
@@ -165,9 +168,20 @@ export const createMoralisExplorer = ({
|
|
|
165
168
|
hash: transaction.hash,
|
|
166
169
|
blockNumber: transaction.block_number,
|
|
167
170
|
timestamp: transaction.block_timestamp,
|
|
171
|
+
value: transaction.value,
|
|
168
172
|
}
|
|
169
173
|
indexes.set(data.hash, data)
|
|
170
174
|
}
|
|
175
|
+
|
|
176
|
+
for (const transfer of transaction.erc20_transfers) {
|
|
177
|
+
erc20Transfers.push({
|
|
178
|
+
address: transfer.address,
|
|
179
|
+
from: transfer.from_address,
|
|
180
|
+
logIndex: transfer.log_index,
|
|
181
|
+
to: transfer.to_address,
|
|
182
|
+
value: transfer.value,
|
|
183
|
+
})
|
|
184
|
+
}
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
if (result.result.length < limit) {
|
|
@@ -175,7 +189,10 @@ export const createMoralisExplorer = ({
|
|
|
175
189
|
}
|
|
176
190
|
}
|
|
177
191
|
|
|
178
|
-
return
|
|
192
|
+
return {
|
|
193
|
+
indexes: [...indexes.values()],
|
|
194
|
+
erc20Transfers,
|
|
195
|
+
}
|
|
179
196
|
},
|
|
180
197
|
getBlockNumberOfTimestamp: (): Promise<number> => {
|
|
181
198
|
throw new Error('Function not implemented.')
|
|
@@ -80,7 +80,9 @@ const transactionSchema = z.object({
|
|
|
80
80
|
to_address: lowerHexSchema,
|
|
81
81
|
// "to_address_label": null,
|
|
82
82
|
// "address": "0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5",
|
|
83
|
+
address: lowerHexSchema,
|
|
83
84
|
// "log_index": 37,
|
|
85
|
+
log_index: z.number().int(),
|
|
84
86
|
// "value": "6851147569444444",
|
|
85
87
|
value: bigintTextSchema,
|
|
86
88
|
// "possible_spam": false,
|
package/explorer/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Hex, LowerHex } from '../types'
|
|
1
|
+
import type { Erc20Transfer, Hex, LowerHex } from '../types'
|
|
2
2
|
import type { InternalTransactionWithIndex } from '../types/internalTransaction'
|
|
3
3
|
import type { Log } from '../types/log'
|
|
4
4
|
import type { TransactionIndex } from '../types/transactionIndex'
|
|
@@ -50,7 +50,10 @@ type FunctionGetAddressTokenTransferIndexes = (parameters: {
|
|
|
50
50
|
fromBlock?: number
|
|
51
51
|
toBlock?: number
|
|
52
52
|
headers?: Record<string, string>
|
|
53
|
-
}) => Promise<
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
indexes: TransactionIndex[]
|
|
55
|
+
erc20Transfers: Erc20Transfer[]
|
|
56
|
+
}>
|
|
54
57
|
|
|
55
58
|
type FunctionGetBlockNumberOfTimestamp = (parameters: {
|
|
56
59
|
/** Unix timestamp in milliseconds */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Chain } from '../chain'
|
|
2
|
+
import type { Erc20Transfer } from '../types'
|
|
2
3
|
import type { LowerHex } from '../types/hex'
|
|
3
4
|
import type { InternalTransaction } from '../types/internalTransaction'
|
|
4
5
|
import type { TransactionIndex } from '../types/transactionIndex'
|
|
@@ -11,8 +12,9 @@ type GetAddressIndexDataParameters = {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
type GetAddressIndexDataReturnTypes = {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
transactionIndexes: readonly TransactionIndex[]
|
|
16
|
+
internalTransactions: readonly InternalTransaction[]
|
|
17
|
+
erc20Transfers: readonly Erc20Transfer[]
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const getAddressIndexData = async ({
|
|
@@ -21,24 +23,27 @@ export const getAddressIndexData = async ({
|
|
|
21
23
|
fromBlock,
|
|
22
24
|
toBlock,
|
|
23
25
|
}: GetAddressIndexDataParameters): Promise<GetAddressIndexDataReturnTypes> => {
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
const [
|
|
27
|
+
transactionIndexes,
|
|
28
|
+
{ indexes: transferIndexes, erc20Transfers },
|
|
29
|
+
internalTransactions,
|
|
30
|
+
] = await Promise.all([
|
|
31
|
+
chain.explorer.getAddressTransactionIndexes({
|
|
32
|
+
address,
|
|
33
|
+
fromBlock,
|
|
34
|
+
toBlock,
|
|
35
|
+
}),
|
|
36
|
+
chain.explorer.getAddressTokenTransferIndexes({
|
|
37
|
+
address,
|
|
38
|
+
fromBlock,
|
|
39
|
+
toBlock,
|
|
40
|
+
}),
|
|
41
|
+
chain.explorer.getAddressInternalTransactions({
|
|
42
|
+
address,
|
|
43
|
+
fromBlock,
|
|
44
|
+
toBlock,
|
|
45
|
+
}),
|
|
46
|
+
])
|
|
42
47
|
|
|
43
48
|
const indexes = new Map<LowerHex, TransactionIndex>()
|
|
44
49
|
for (const index of transactionIndexes) {
|
|
@@ -64,5 +69,6 @@ export const getAddressIndexData = async ({
|
|
|
64
69
|
return {
|
|
65
70
|
transactionIndexes: [...indexes.values()],
|
|
66
71
|
internalTransactions,
|
|
72
|
+
erc20Transfers,
|
|
67
73
|
}
|
|
68
74
|
}
|
|
@@ -13,6 +13,8 @@ type GetTransactionDetailParameters = {
|
|
|
13
13
|
timestamp?: number
|
|
14
14
|
internalTransactions?: readonly InternalTransaction[]
|
|
15
15
|
timeout?: number
|
|
16
|
+
input?: LowerHex
|
|
17
|
+
value?: bigint
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const getTransactionDetail = async ({
|
|
@@ -21,12 +23,19 @@ export const getTransactionDetail = async ({
|
|
|
21
23
|
timestamp: optionalTimestamp,
|
|
22
24
|
internalTransactions = [],
|
|
23
25
|
timeout,
|
|
26
|
+
input,
|
|
27
|
+
value,
|
|
24
28
|
}: GetTransactionDetailParameters): Promise<TransactionDetail> => {
|
|
25
29
|
const [transaction, receipt] = await Promise.all([
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
input === undefined || value === undefined
|
|
31
|
+
? chain.client.call({
|
|
32
|
+
clientCall: (client) => client.getTransaction({ hash }),
|
|
33
|
+
timeout,
|
|
34
|
+
})
|
|
35
|
+
: {
|
|
36
|
+
input,
|
|
37
|
+
value,
|
|
38
|
+
},
|
|
30
39
|
chain.client.call({
|
|
31
40
|
clientCall: (client) => client.getTransactionReceipt({ hash }),
|
|
32
41
|
timeout,
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { z } from 'zod'
|
|
2
|
+
import { bigintTextSchema, lowerHexSchema } from './primitive'
|
|
2
3
|
import { transactionDetailSchema } from './transactionDetail'
|
|
3
4
|
|
|
4
|
-
const transactionIndexSchema = transactionDetailSchema
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const transactionIndexSchema = transactionDetailSchema
|
|
6
|
+
.pick({
|
|
7
|
+
hash: true,
|
|
8
|
+
blockNumber: true,
|
|
9
|
+
timestamp: true,
|
|
10
|
+
})
|
|
11
|
+
.extend({
|
|
12
|
+
input: lowerHexSchema.optional(),
|
|
13
|
+
value: bigintTextSchema.optional(),
|
|
14
|
+
})
|
|
9
15
|
|
|
10
16
|
export type TransactionIndex = z.infer<typeof transactionIndexSchema>
|