@0xtorch/evm 0.0.126 → 0.0.128

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.
Files changed (244) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/chain/definitions/ethereum.js +2 -2
  3. package/_cjs/chain/definitions/ethereum.js.map +1 -1
  4. package/_cjs/client/create.js +1 -1
  5. package/_cjs/client/create.js.map +1 -1
  6. package/_cjs/explorer/etherscanV2/client.js +94 -0
  7. package/_cjs/explorer/etherscanV2/client.js.map +1 -0
  8. package/_cjs/explorer/etherscanV2/create.js +196 -0
  9. package/_cjs/explorer/etherscanV2/create.js.map +1 -0
  10. package/_cjs/explorer/etherscanV2/getBlockNumberByTimestamp.js +21 -0
  11. package/_cjs/explorer/etherscanV2/getBlockNumberByTimestamp.js.map +1 -0
  12. package/_cjs/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js +34 -0
  13. package/_cjs/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js.map +1 -0
  14. package/_cjs/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js +36 -0
  15. package/_cjs/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js.map +1 -0
  16. package/_cjs/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js +48 -0
  17. package/_cjs/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js.map +1 -0
  18. package/_cjs/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js +64 -0
  19. package/_cjs/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js.map +1 -0
  20. package/_cjs/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js +51 -0
  21. package/_cjs/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js.map +1 -0
  22. package/_cjs/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js +69 -0
  23. package/_cjs/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js.map +1 -0
  24. package/_cjs/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js +47 -0
  25. package/_cjs/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js.map +1 -0
  26. package/_cjs/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js +74 -0
  27. package/_cjs/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js.map +1 -0
  28. package/_cjs/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js +51 -0
  29. package/_cjs/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js.map +1 -0
  30. package/_cjs/explorer/index.js +9 -7
  31. package/_cjs/explorer/index.js.map +1 -1
  32. package/_cjs/index.js +2 -1
  33. package/_cjs/index.js.map +1 -1
  34. package/_esm/chain/definitions/ethereum.js +3 -3
  35. package/_esm/chain/definitions/ethereum.js.map +1 -1
  36. package/_esm/client/create.js +2 -2
  37. package/_esm/client/create.js.map +1 -1
  38. package/_esm/explorer/etherscanV2/client.js +95 -0
  39. package/_esm/explorer/etherscanV2/client.js.map +1 -0
  40. package/_esm/explorer/etherscanV2/create.js +195 -0
  41. package/_esm/explorer/etherscanV2/create.js.map +1 -0
  42. package/_esm/explorer/etherscanV2/getBlockNumberByTimestamp.js +18 -0
  43. package/_esm/explorer/etherscanV2/getBlockNumberByTimestamp.js.map +1 -0
  44. package/_esm/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js +31 -0
  45. package/_esm/explorer/etherscanV2/getContractCreatorAndCreationTxHash.js.map +1 -0
  46. package/_esm/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js +33 -0
  47. package/_esm/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.js.map +1 -0
  48. package/_esm/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js +45 -0
  49. package/_esm/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.js.map +1 -0
  50. package/_esm/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js +61 -0
  51. package/_esm/explorer/etherscanV2/getInternalTransactionsByTransactionHash.js.map +1 -0
  52. package/_esm/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js +48 -0
  53. package/_esm/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.js.map +1 -0
  54. package/_esm/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js +66 -0
  55. package/_esm/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.js.map +1 -0
  56. package/_esm/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js +44 -0
  57. package/_esm/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.js.map +1 -0
  58. package/_esm/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js +71 -0
  59. package/_esm/explorer/etherscanV2/getListOfInternalTransactionsByAddress.js.map +1 -0
  60. package/_esm/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js +48 -0
  61. package/_esm/explorer/etherscanV2/getListOfNormalTransactionsByAddress.js.map +1 -0
  62. package/_esm/explorer/index.js +1 -0
  63. package/_esm/explorer/index.js.map +1 -1
  64. package/_esm/index.js +1 -1
  65. package/_esm/index.js.map +1 -1
  66. package/_types/chain/definitions/arbitrumOne.d.ts.map +1 -1
  67. package/_types/chain/definitions/astar.d.ts.map +1 -1
  68. package/_types/chain/definitions/astarZkEvm.d.ts.map +1 -1
  69. package/_types/chain/definitions/avalancheC.d.ts.map +1 -1
  70. package/_types/chain/definitions/base.d.ts.map +1 -1
  71. package/_types/chain/definitions/blast.d.ts.map +1 -1
  72. package/_types/chain/definitions/bsc.d.ts.map +1 -1
  73. package/_types/chain/definitions/chainVerse.d.ts.map +1 -1
  74. package/_types/chain/definitions/defiVerse.d.ts.map +1 -1
  75. package/_types/chain/definitions/doge.d.ts.map +1 -1
  76. package/_types/chain/definitions/ethereum.d.ts.map +1 -1
  77. package/_types/chain/definitions/fantom.d.ts.map +1 -1
  78. package/_types/chain/definitions/geekVerse.d.ts.map +1 -1
  79. package/_types/chain/definitions/gesoVerse.d.ts.map +1 -1
  80. package/_types/chain/definitions/homeVerse.d.ts.map +1 -1
  81. package/_types/chain/definitions/linea.d.ts.map +1 -1
  82. package/_types/chain/definitions/mantaPacific.d.ts.map +1 -1
  83. package/_types/chain/definitions/mantle.d.ts.map +1 -1
  84. package/_types/chain/definitions/mchVerse.d.ts.map +1 -1
  85. package/_types/chain/definitions/metis.d.ts.map +1 -1
  86. package/_types/chain/definitions/moonbeam.d.ts.map +1 -1
  87. package/_types/chain/definitions/moonriver.d.ts.map +1 -1
  88. package/_types/chain/definitions/oasys.d.ts.map +1 -1
  89. package/_types/chain/definitions/opBnb.d.ts.map +1 -1
  90. package/_types/chain/definitions/optimism.d.ts.map +1 -1
  91. package/_types/chain/definitions/polygonPos.d.ts.map +1 -1
  92. package/_types/chain/definitions/polygonZkEvm.d.ts.map +1 -1
  93. package/_types/chain/definitions/ronin.d.ts.map +1 -1
  94. package/_types/chain/definitions/saakuru.d.ts.map +1 -1
  95. package/_types/chain/definitions/scroll.d.ts.map +1 -1
  96. package/_types/chain/definitions/soneium.d.ts.map +1 -1
  97. package/_types/chain/definitions/sonic.d.ts.map +1 -1
  98. package/_types/chain/definitions/taiko.d.ts.map +1 -1
  99. package/_types/chain/definitions/tcgVerse.d.ts.map +1 -1
  100. package/_types/chain/definitions/yooldoVerse.d.ts.map +1 -1
  101. package/_types/chain/definitions/zkFair.d.ts.map +1 -1
  102. package/_types/chain/definitions/zkSyncEra.d.ts.map +1 -1
  103. package/_types/chain/definitions/zora.d.ts.map +1 -1
  104. package/_types/chain/viemChains/chainVerse.d.ts +4 -5
  105. package/_types/chain/viemChains/chainVerse.d.ts.map +1 -1
  106. package/_types/chain/viemChains/defiVerse.d.ts +4 -5
  107. package/_types/chain/viemChains/defiVerse.d.ts.map +1 -1
  108. package/_types/chain/viemChains/geekVerse.d.ts +4 -5
  109. package/_types/chain/viemChains/geekVerse.d.ts.map +1 -1
  110. package/_types/chain/viemChains/gesoVerse.d.ts +4 -5
  111. package/_types/chain/viemChains/gesoVerse.d.ts.map +1 -1
  112. package/_types/chain/viemChains/homeVerse.d.ts +4 -5
  113. package/_types/chain/viemChains/homeVerse.d.ts.map +1 -1
  114. package/_types/chain/viemChains/mchVerse.d.ts +4 -5
  115. package/_types/chain/viemChains/mchVerse.d.ts.map +1 -1
  116. package/_types/chain/viemChains/saakuru.d.ts +4 -5
  117. package/_types/chain/viemChains/saakuru.d.ts.map +1 -1
  118. package/_types/chain/viemChains/soneium.d.ts +17 -17
  119. package/_types/chain/viemChains/soneium.d.ts.map +1 -1
  120. package/_types/chain/viemChains/sonic.d.ts +1 -1
  121. package/_types/chain/viemChains/tcgVerse.d.ts +4 -5
  122. package/_types/chain/viemChains/tcgVerse.d.ts.map +1 -1
  123. package/_types/client/create.d.ts.map +1 -1
  124. package/_types/explorer/blockscout/client.d.ts.map +1 -1
  125. package/_types/explorer/blockscout/create.d.ts.map +1 -1
  126. package/_types/explorer/blockscout/getBlockNumberByTimestamp.d.ts.map +1 -1
  127. package/_types/explorer/blockscout/getContractCreatorAddressHashAndCreationTransactionHash.d.ts.map +1 -1
  128. package/_types/explorer/blockscout/getContractSourceCodeForAVerifiedContract.d.ts.map +1 -1
  129. package/_types/explorer/blockscout/getEventLogsByAddressAndTopic.d.ts.map +1 -1
  130. package/_types/explorer/blockscout/getInternalTransactionsByAddressHash.d.ts.map +1 -1
  131. package/_types/explorer/blockscout/getInternalTransactionsByTransactionHash.d.ts.map +1 -1
  132. package/_types/explorer/blockscout/getTokenTransferEventsByAddress.d.ts.map +1 -1
  133. package/_types/explorer/blockscout/getTransactionsByAddress.d.ts.map +1 -1
  134. package/_types/explorer/etherscan/client.d.ts.map +1 -1
  135. package/_types/explorer/etherscan/create.d.ts.map +1 -1
  136. package/_types/explorer/etherscan/getBlockNumberByTimestamp.d.ts.map +1 -1
  137. package/_types/explorer/etherscan/getContractCreatorAndCreationTxHash.d.ts.map +1 -1
  138. package/_types/explorer/etherscan/getContractSourceCodeForVerifiedContract.d.ts.map +1 -1
  139. package/_types/explorer/etherscan/getEventLogsByAddressFilteredByTopics.d.ts.map +1 -1
  140. package/_types/explorer/etherscan/getInternalTransactionsByTransactionHash.d.ts.map +1 -1
  141. package/_types/explorer/etherscan/getListOfErc1155TokenTransferEventsByAddress.d.ts.map +1 -1
  142. package/_types/explorer/etherscan/getListOfErc20TokenTransferEventsByAddress.d.ts.map +1 -1
  143. package/_types/explorer/etherscan/getListOfErc721TokenTransferEventsByAddress.d.ts.map +1 -1
  144. package/_types/explorer/etherscan/getListOfInternalTransactionsByAddress.d.ts.map +1 -1
  145. package/_types/explorer/etherscan/getListOfNormalTransactionsByAddress.d.ts.map +1 -1
  146. package/_types/explorer/etherscanV2/client.d.ts +17 -0
  147. package/_types/explorer/etherscanV2/client.d.ts.map +1 -0
  148. package/_types/explorer/etherscanV2/create.d.ts +12 -0
  149. package/_types/explorer/etherscanV2/create.d.ts.map +1 -0
  150. package/_types/explorer/etherscanV2/getBlockNumberByTimestamp.d.ts +12 -0
  151. package/_types/explorer/etherscanV2/getBlockNumberByTimestamp.d.ts.map +1 -0
  152. package/_types/explorer/etherscanV2/getContractCreatorAndCreationTxHash.d.ts +12 -0
  153. package/_types/explorer/etherscanV2/getContractCreatorAndCreationTxHash.d.ts.map +1 -0
  154. package/_types/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.d.ts +12 -0
  155. package/_types/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.d.ts.map +1 -0
  156. package/_types/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.d.ts +16 -0
  157. package/_types/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.d.ts.map +1 -0
  158. package/_types/explorer/etherscanV2/getInternalTransactionsByTransactionHash.d.ts +12 -0
  159. package/_types/explorer/etherscanV2/getInternalTransactionsByTransactionHash.d.ts.map +1 -0
  160. package/_types/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.d.ts +16 -0
  161. package/_types/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.d.ts.map +1 -0
  162. package/_types/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.d.ts +20 -0
  163. package/_types/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.d.ts.map +1 -0
  164. package/_types/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.d.ts +16 -0
  165. package/_types/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.d.ts.map +1 -0
  166. package/_types/explorer/etherscanV2/getListOfInternalTransactionsByAddress.d.ts +17 -0
  167. package/_types/explorer/etherscanV2/getListOfInternalTransactionsByAddress.d.ts.map +1 -0
  168. package/_types/explorer/etherscanV2/getListOfNormalTransactionsByAddress.d.ts +17 -0
  169. package/_types/explorer/etherscanV2/getListOfNormalTransactionsByAddress.d.ts.map +1 -0
  170. package/_types/explorer/index.d.ts +1 -0
  171. package/_types/explorer/index.d.ts.map +1 -1
  172. package/_types/explorer/moralis/client.d.ts.map +1 -1
  173. package/_types/explorer/moralis/create.d.ts.map +1 -1
  174. package/_types/explorer/moralis/getWalletTransactionHistory.d.ts.map +1 -1
  175. package/_types/explorer/noApiExplorer/create.d.ts.map +1 -1
  176. package/_types/index.d.ts +1 -1
  177. package/_types/index.d.ts.map +1 -1
  178. package/_types/logic/analyzeTransaction/createActions/fail.d.ts.map +1 -1
  179. package/_types/logic/analyzeTransaction/createActions/gas.d.ts.map +1 -1
  180. package/_types/logic/analyzeTransaction/createActions/general.d.ts.map +1 -1
  181. package/_types/logic/analyzeTransaction/createActions/index.d.ts.map +1 -1
  182. package/_types/logic/analyzeTransaction/createActions/json/addressIn.d.ts.map +1 -1
  183. package/_types/logic/analyzeTransaction/createActions/json/allValue.d.ts.map +1 -1
  184. package/_types/logic/analyzeTransaction/createActions/json/arrayIn.d.ts.map +1 -1
  185. package/_types/logic/analyzeTransaction/createActions/json/betweenBigInt.d.ts.map +1 -1
  186. package/_types/logic/analyzeTransaction/createActions/json/customTransferGenerator.d.ts.map +1 -1
  187. package/_types/logic/analyzeTransaction/createActions/json/erc1155Pattern.d.ts.map +1 -1
  188. package/_types/logic/analyzeTransaction/createActions/json/erc1155TransferGenerator.d.ts.map +1 -1
  189. package/_types/logic/analyzeTransaction/createActions/json/erc20Pattern.d.ts.map +1 -1
  190. package/_types/logic/analyzeTransaction/createActions/json/erc20TransferGenerator.d.ts.map +1 -1
  191. package/_types/logic/analyzeTransaction/createActions/json/erc721Pattern.d.ts.map +1 -1
  192. package/_types/logic/analyzeTransaction/createActions/json/erc721TransferGenerator.d.ts.map +1 -1
  193. package/_types/logic/analyzeTransaction/createActions/json/generateActions.d.ts.map +1 -1
  194. package/_types/logic/analyzeTransaction/createActions/json/index.d.ts.map +1 -1
  195. package/_types/logic/analyzeTransaction/createActions/json/internalTransferGenerator.d.ts.map +1 -1
  196. package/_types/logic/analyzeTransaction/createActions/json/join.d.ts.map +1 -1
  197. package/_types/logic/analyzeTransaction/createActions/json/math.d.ts.map +1 -1
  198. package/_types/logic/analyzeTransaction/createActions/json/simpleValue.d.ts.map +1 -1
  199. package/_types/logic/analyzeTransaction/createActions/json/slice.d.ts.map +1 -1
  200. package/_types/logic/analyzeTransaction/createActions/json/transferGenerator.d.ts.map +1 -1
  201. package/_types/logic/analyzeTransaction/createActions/json/verifyTxSatisfiesCondition.d.ts.map +1 -1
  202. package/_types/logic/analyzeTransaction/createActions/spam.d.ts.map +1 -1
  203. package/_types/logic/analyzeTransaction/createActions/utils/containsUrlOrDomain.d.ts.map +1 -1
  204. package/_types/logic/analyzeTransaction/createActions/utils/createDirection.d.ts.map +1 -1
  205. package/_types/logic/analyzeTransaction/createActions/utils/createTokenTransfers.d.ts.map +1 -1
  206. package/_types/logic/analyzeTransaction/decodeTransaction/decodeInput.d.ts.map +1 -1
  207. package/_types/logic/analyzeTransaction/decodeTransaction/decodeLog.d.ts.map +1 -1
  208. package/_types/logic/analyzeTransaction/decodeTransaction/index.d.ts.map +1 -1
  209. package/_types/logic/analyzeTransaction/decodeTransaction/parseToErc1155TokenTransfer.d.ts.map +1 -1
  210. package/_types/logic/analyzeTransaction/decodeTransaction/parseToErc20TokenTransfer.d.ts.map +1 -1
  211. package/_types/logic/analyzeTransaction/decodeTransaction/parseToErc721TokenTransfer.d.ts.map +1 -1
  212. package/_types/logic/analyzeTransaction/getDataFromDatasource.d.ts.map +1 -1
  213. package/_types/logic/analyzeTransaction/index.d.ts.map +1 -1
  214. package/_types/logic/getAddressIndexData.d.ts.map +1 -1
  215. package/_types/logic/getTransactionDetail/decodeTokenTransferLogs.d.ts.map +1 -1
  216. package/_types/logic/getTransactionDetail/index.d.ts.map +1 -1
  217. package/_types/types/accountId.d.ts.map +1 -1
  218. package/_types/types/erc1155.d.ts.map +1 -1
  219. package/_types/types/erc20.d.ts.map +1 -1
  220. package/_types/types/erc721.d.ts.map +1 -1
  221. package/_types/types/hex.d.ts.map +1 -1
  222. package/_types/types/source.d.ts.map +1 -1
  223. package/_types/types/transactionDecoded.d.ts.map +1 -1
  224. package/_types/utils/bigint.d.ts.map +1 -1
  225. package/_types/utils/create.d.ts.map +1 -1
  226. package/_types/utils/createInternalTransactionId.d.ts.map +1 -1
  227. package/_types/utils/timeout.d.ts.map +1 -1
  228. package/chain/definitions/ethereum.ts +3 -3
  229. package/client/create.ts +1 -2
  230. package/explorer/etherscanV2/client.ts +154 -0
  231. package/explorer/etherscanV2/create.ts +251 -0
  232. package/explorer/etherscanV2/getBlockNumberByTimestamp.ts +33 -0
  233. package/explorer/etherscanV2/getContractCreatorAndCreationTxHash.ts +46 -0
  234. package/explorer/etherscanV2/getContractSourceCodeForVerifiedContract.ts +54 -0
  235. package/explorer/etherscanV2/getEventLogsByAddressFilteredByTopics.ts +67 -0
  236. package/explorer/etherscanV2/getInternalTransactionsByTransactionHash.ts +76 -0
  237. package/explorer/etherscanV2/getListOfErc1155TokenTransferEventsByAddress.ts +74 -0
  238. package/explorer/etherscanV2/getListOfErc20TokenTransferEventsByAddress.ts +92 -0
  239. package/explorer/etherscanV2/getListOfErc721TokenTransferEventsByAddress.ts +68 -0
  240. package/explorer/etherscanV2/getListOfInternalTransactionsByAddress.ts +100 -0
  241. package/explorer/etherscanV2/getListOfNormalTransactionsByAddress.ts +73 -0
  242. package/explorer/index.ts +1 -0
  243. package/index.ts +1 -0
  244. package/package.json +2 -2
@@ -0,0 +1,76 @@
1
+ import { z } from 'zod'
2
+ import type { LowerHex } from '../../types'
3
+ import type { InternalTransactionWithIndex } from '../../types/internalTransaction'
4
+ import { addressPrimitiveSchema, bigintTextSchema } from '../../types/primitive'
5
+ import type { EtherscanV2Client } from './client'
6
+
7
+ type GetInternalTransactionsByTransactionHashParameters = {
8
+ client: EtherscanV2Client
9
+ txhash: LowerHex
10
+ headers?: Record<string, string>
11
+ }
12
+
13
+ const internalTransactionSchema = z.object({
14
+ blockNumber: z.string().regex(/^\d+$/).transform(Number),
15
+ contractAddress: z.union([
16
+ addressPrimitiveSchema,
17
+ z
18
+ .literal('')
19
+ .nullable()
20
+ .transform(() => undefined),
21
+ ]),
22
+ from: addressPrimitiveSchema,
23
+ gas: bigintTextSchema,
24
+ isError: z
25
+ .string()
26
+ .regex(/^\d+$/)
27
+ .transform((x) => x === '1'),
28
+ timeStamp: z.string().regex(/^\d+$/).transform(Number),
29
+ to: z.union([
30
+ addressPrimitiveSchema,
31
+ z
32
+ .literal('')
33
+ .nullable()
34
+ .transform(() => undefined),
35
+ ]),
36
+ value: bigintTextSchema,
37
+ })
38
+ const resultSchema = z.array(internalTransactionSchema)
39
+
40
+ /** {@link https://docs.etherscan.io/etherscan-v2/api-endpoints/accounts#get-internal-transactions-by-transaction-hash} */
41
+ export const getInternalTransactionsByTransactionHash = async ({
42
+ client,
43
+ txhash,
44
+ headers,
45
+ }: GetInternalTransactionsByTransactionHashParameters): Promise<
46
+ InternalTransactionWithIndex[]
47
+ > => {
48
+ try {
49
+ const result = await client.get({
50
+ path: '',
51
+ query: {
52
+ module: 'account',
53
+ action: 'txlistinternal',
54
+ txhash,
55
+ },
56
+ resultSchema,
57
+ headers,
58
+ })
59
+ return result.map((v) => ({
60
+ blockNumber: v.blockNumber,
61
+ contractAddress: v.contractAddress,
62
+ from: v.from,
63
+ gas: v.gas,
64
+ isError: v.isError,
65
+ timestamp: v.timeStamp * 1000,
66
+ to: v.to,
67
+ txHash: txhash,
68
+ value: v.value,
69
+ }))
70
+ } catch (error) {
71
+ if (error instanceof Error && error.message === 'No transactions found') {
72
+ return []
73
+ }
74
+ throw error
75
+ }
76
+ }
@@ -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
@@ -158,6 +158,7 @@ export { createClient } from './client'
158
158
  export {
159
159
  createBlockscout,
160
160
  createEtherscan,
161
+ createEtherscanV2,
161
162
  createNoApiExplorer,
162
163
  } from './explorer'
163
164
  export type { Explorer } from './explorer'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/evm",
3
- "version": "0.0.126",
3
+ "version": "0.0.128",
4
4
  "description": "Cryptorch EVM extension",
5
5
  "keywords": [
6
6
  "cryptorch",
@@ -41,6 +41,6 @@
41
41
  "@0xtorch/core": "^0.0.60",
42
42
  "abitype": "^1.0.6",
43
43
  "viem": "2.21.18",
44
- "zod": "^3.23.8"
44
+ "zod": "3.23.8"
45
45
  }
46
46
  }