@0xtorch/evm 0.0.31 → 0.0.33

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 (221) hide show
  1. package/_cjs/decoder/decode.js +1 -0
  2. package/_cjs/decoder/decode.js.map +1 -1
  3. package/_cjs/index.js +1 -7
  4. package/_cjs/index.js.map +1 -1
  5. package/_esm/decoder/decode.js +1 -0
  6. package/_esm/decoder/decode.js.map +1 -1
  7. package/_esm/index.js +0 -2
  8. package/_esm/index.js.map +1 -1
  9. package/_types/chains/definitions/arbitrumOne.d.ts +1 -0
  10. package/_types/chains/definitions/arbitrumOne.d.ts.map +1 -1
  11. package/_types/chains/definitions/astar.d.ts +1 -0
  12. package/_types/chains/definitions/astar.d.ts.map +1 -1
  13. package/_types/chains/definitions/avalancheC.d.ts +1 -0
  14. package/_types/chains/definitions/avalancheC.d.ts.map +1 -1
  15. package/_types/chains/definitions/base.d.ts +1 -0
  16. package/_types/chains/definitions/base.d.ts.map +1 -1
  17. package/_types/chains/definitions/bsc.d.ts +1 -0
  18. package/_types/chains/definitions/bsc.d.ts.map +1 -1
  19. package/_types/chains/definitions/ethereum.d.ts +1 -0
  20. package/_types/chains/definitions/ethereum.d.ts.map +1 -1
  21. package/_types/chains/definitions/fantom.d.ts +1 -0
  22. package/_types/chains/definitions/fantom.d.ts.map +1 -1
  23. package/_types/chains/definitions/linea.d.ts +1 -0
  24. package/_types/chains/definitions/linea.d.ts.map +1 -1
  25. package/_types/chains/definitions/mantle.d.ts +1 -0
  26. package/_types/chains/definitions/mantle.d.ts.map +1 -1
  27. package/_types/chains/definitions/metis.d.ts +1 -0
  28. package/_types/chains/definitions/metis.d.ts.map +1 -1
  29. package/_types/chains/definitions/moonbeam.d.ts +1 -0
  30. package/_types/chains/definitions/moonbeam.d.ts.map +1 -1
  31. package/_types/chains/definitions/moonriver.d.ts +1 -0
  32. package/_types/chains/definitions/moonriver.d.ts.map +1 -1
  33. package/_types/chains/definitions/oasys.d.ts +1 -0
  34. package/_types/chains/definitions/oasys.d.ts.map +1 -1
  35. package/_types/chains/definitions/optimism.d.ts +1 -0
  36. package/_types/chains/definitions/optimism.d.ts.map +1 -1
  37. package/_types/chains/definitions/polygonPos.d.ts +1 -0
  38. package/_types/chains/definitions/polygonPos.d.ts.map +1 -1
  39. package/_types/chains/definitions/ronin.d.ts +1 -0
  40. package/_types/chains/definitions/ronin.d.ts.map +1 -1
  41. package/_types/decoder/tests.d.ts +1 -0
  42. package/_types/decoder/tests.d.ts.map +1 -1
  43. package/_types/explorers/definitions/blockscout.d.ts +4 -0
  44. package/_types/explorers/definitions/blockscout.d.ts.map +1 -1
  45. package/_types/explorers/definitions/etherscan.d.ts +4 -0
  46. package/_types/explorers/definitions/etherscan.d.ts.map +1 -1
  47. package/_types/explorers/definitions/roninExplorer.d.ts +4 -0
  48. package/_types/explorers/definitions/roninExplorer.d.ts.map +1 -1
  49. package/_types/index.d.ts +0 -2
  50. package/_types/index.d.ts.map +1 -1
  51. package/decoder/decode.ts +1 -0
  52. package/index.ts +0 -8
  53. package/package.json +2 -2
  54. package/_cjs/getAccountsTransactionFulls/getAccountsTransactionFulls.js +0 -22
  55. package/_cjs/getAccountsTransactionFulls/getAccountsTransactionFulls.js.map +0 -1
  56. package/_cjs/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.js +0 -52
  57. package/_cjs/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.js.map +0 -1
  58. package/_cjs/getAccountsTransactionFulls/getDecodedTransactionsPrices.js +0 -55
  59. package/_cjs/getAccountsTransactionFulls/getDecodedTransactionsPrices.js.map +0 -1
  60. package/_cjs/getAccountsTransactionFulls/getHashesAndInternalTxs.js +0 -49
  61. package/_cjs/getAccountsTransactionFulls/getHashesAndInternalTxs.js.map +0 -1
  62. package/_cjs/getAccountsTransactionFulls/getTransactionDetails.js +0 -28
  63. package/_cjs/getAccountsTransactionFulls/getTransactionDetails.js.map +0 -1
  64. package/_cjs/getAccountsTransactionFulls/getTransactionsApps.js +0 -24
  65. package/_cjs/getAccountsTransactionFulls/getTransactionsApps.js.map +0 -1
  66. package/_cjs/getAccountsTransactionFulls/index.js +0 -8
  67. package/_cjs/getAccountsTransactionFulls/index.js.map +0 -1
  68. package/_cjs/getAccountsTransactionFulls/types.js +0 -3
  69. package/_cjs/getAccountsTransactionFulls/types.js.map +0 -1
  70. package/_cjs/getAccountsTransactionFulls/withD.js +0 -41
  71. package/_cjs/getAccountsTransactionFulls/withD.js.map +0 -1
  72. package/_cjs/getAccountsTransactionFulls/withDA.js +0 -59
  73. package/_cjs/getAccountsTransactionFulls/withDA.js.map +0 -1
  74. package/_cjs/getAccountsTransactionFulls/withP.js +0 -61
  75. package/_cjs/getAccountsTransactionFulls/withP.js.map +0 -1
  76. package/_cjs/getAccountsTransactionFulls/withPD.js +0 -73
  77. package/_cjs/getAccountsTransactionFulls/withPD.js.map +0 -1
  78. package/_cjs/getAccountsTransactionFulls/withPDA.js +0 -89
  79. package/_cjs/getAccountsTransactionFulls/withPDA.js.map +0 -1
  80. package/_cjs/getAccountsTransactionFulls/withUndefined.js +0 -46
  81. package/_cjs/getAccountsTransactionFulls/withUndefined.js.map +0 -1
  82. package/_cjs/getTransactionFull/getTransactionFull.js +0 -18
  83. package/_cjs/getTransactionFull/getTransactionFull.js.map +0 -1
  84. package/_cjs/getTransactionFull/getTransactionFullCustom.js +0 -52
  85. package/_cjs/getTransactionFull/getTransactionFullCustom.js.map +0 -1
  86. package/_cjs/getTransactionFull/index.js +0 -8
  87. package/_cjs/getTransactionFull/index.js.map +0 -1
  88. package/_cjs/getTransactionFull/types.js +0 -3
  89. package/_cjs/getTransactionFull/types.js.map +0 -1
  90. package/_cjs/getTransactionFull/withD.js +0 -34
  91. package/_cjs/getTransactionFull/withD.js.map +0 -1
  92. package/_cjs/getTransactionFull/withDA.js +0 -48
  93. package/_cjs/getTransactionFull/withDA.js.map +0 -1
  94. package/_cjs/getTransactionFull/withP.js +0 -46
  95. package/_cjs/getTransactionFull/withP.js.map +0 -1
  96. package/_cjs/getTransactionFull/withPD.js +0 -78
  97. package/_cjs/getTransactionFull/withPD.js.map +0 -1
  98. package/_cjs/getTransactionFull/withPDA.js +0 -92
  99. package/_cjs/getTransactionFull/withPDA.js.map +0 -1
  100. package/_cjs/getTransactionFull/withUndefined.js +0 -29
  101. package/_cjs/getTransactionFull/withUndefined.js.map +0 -1
  102. package/_esm/getAccountsTransactionFulls/getAccountsTransactionFulls.js +0 -18
  103. package/_esm/getAccountsTransactionFulls/getAccountsTransactionFulls.js.map +0 -1
  104. package/_esm/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.js +0 -48
  105. package/_esm/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.js.map +0 -1
  106. package/_esm/getAccountsTransactionFulls/getDecodedTransactionsPrices.js +0 -55
  107. package/_esm/getAccountsTransactionFulls/getDecodedTransactionsPrices.js.map +0 -1
  108. package/_esm/getAccountsTransactionFulls/getHashesAndInternalTxs.js +0 -45
  109. package/_esm/getAccountsTransactionFulls/getHashesAndInternalTxs.js.map +0 -1
  110. package/_esm/getAccountsTransactionFulls/getTransactionDetails.js +0 -24
  111. package/_esm/getAccountsTransactionFulls/getTransactionDetails.js.map +0 -1
  112. package/_esm/getAccountsTransactionFulls/getTransactionsApps.js +0 -21
  113. package/_esm/getAccountsTransactionFulls/getTransactionsApps.js.map +0 -1
  114. package/_esm/getAccountsTransactionFulls/index.js +0 -3
  115. package/_esm/getAccountsTransactionFulls/index.js.map +0 -1
  116. package/_esm/getAccountsTransactionFulls/types.js +0 -2
  117. package/_esm/getAccountsTransactionFulls/types.js.map +0 -1
  118. package/_esm/getAccountsTransactionFulls/withD.js +0 -41
  119. package/_esm/getAccountsTransactionFulls/withD.js.map +0 -1
  120. package/_esm/getAccountsTransactionFulls/withDA.js +0 -60
  121. package/_esm/getAccountsTransactionFulls/withDA.js.map +0 -1
  122. package/_esm/getAccountsTransactionFulls/withP.js +0 -62
  123. package/_esm/getAccountsTransactionFulls/withP.js.map +0 -1
  124. package/_esm/getAccountsTransactionFulls/withPD.js +0 -74
  125. package/_esm/getAccountsTransactionFulls/withPD.js.map +0 -1
  126. package/_esm/getAccountsTransactionFulls/withPDA.js +0 -91
  127. package/_esm/getAccountsTransactionFulls/withPDA.js.map +0 -1
  128. package/_esm/getAccountsTransactionFulls/withUndefined.js +0 -45
  129. package/_esm/getAccountsTransactionFulls/withUndefined.js.map +0 -1
  130. package/_esm/getTransactionFull/getTransactionFull.js +0 -14
  131. package/_esm/getTransactionFull/getTransactionFull.js.map +0 -1
  132. package/_esm/getTransactionFull/getTransactionFullCustom.js +0 -48
  133. package/_esm/getTransactionFull/getTransactionFullCustom.js.map +0 -1
  134. package/_esm/getTransactionFull/index.js +0 -3
  135. package/_esm/getTransactionFull/index.js.map +0 -1
  136. package/_esm/getTransactionFull/types.js +0 -2
  137. package/_esm/getTransactionFull/types.js.map +0 -1
  138. package/_esm/getTransactionFull/withD.js +0 -33
  139. package/_esm/getTransactionFull/withD.js.map +0 -1
  140. package/_esm/getTransactionFull/withDA.js +0 -48
  141. package/_esm/getTransactionFull/withDA.js.map +0 -1
  142. package/_esm/getTransactionFull/withP.js +0 -45
  143. package/_esm/getTransactionFull/withP.js.map +0 -1
  144. package/_esm/getTransactionFull/withPD.js +0 -78
  145. package/_esm/getTransactionFull/withPD.js.map +0 -1
  146. package/_esm/getTransactionFull/withPDA.js +0 -94
  147. package/_esm/getTransactionFull/withPDA.js.map +0 -1
  148. package/_esm/getTransactionFull/withUndefined.js +0 -25
  149. package/_esm/getTransactionFull/withUndefined.js.map +0 -1
  150. package/_types/getAccountsTransactionFulls/getAccountsTransactionFulls.d.ts +0 -23
  151. package/_types/getAccountsTransactionFulls/getAccountsTransactionFulls.d.ts.map +0 -1
  152. package/_types/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.d.ts +0 -4
  153. package/_types/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.d.ts.map +0 -1
  154. package/_types/getAccountsTransactionFulls/getDecodedTransactionsPrices.d.ts +0 -5
  155. package/_types/getAccountsTransactionFulls/getDecodedTransactionsPrices.d.ts.map +0 -1
  156. package/_types/getAccountsTransactionFulls/getHashesAndInternalTxs.d.ts +0 -8
  157. package/_types/getAccountsTransactionFulls/getHashesAndInternalTxs.d.ts.map +0 -1
  158. package/_types/getAccountsTransactionFulls/getTransactionDetails.d.ts +0 -5
  159. package/_types/getAccountsTransactionFulls/getTransactionDetails.d.ts.map +0 -1
  160. package/_types/getAccountsTransactionFulls/getTransactionsApps.d.ts +0 -8
  161. package/_types/getAccountsTransactionFulls/getTransactionsApps.d.ts.map +0 -1
  162. package/_types/getAccountsTransactionFulls/index.d.ts +0 -3
  163. package/_types/getAccountsTransactionFulls/index.d.ts.map +0 -1
  164. package/_types/getAccountsTransactionFulls/types.d.ts +0 -87
  165. package/_types/getAccountsTransactionFulls/types.d.ts.map +0 -1
  166. package/_types/getAccountsTransactionFulls/withD.d.ts +0 -4
  167. package/_types/getAccountsTransactionFulls/withD.d.ts.map +0 -1
  168. package/_types/getAccountsTransactionFulls/withDA.d.ts +0 -4
  169. package/_types/getAccountsTransactionFulls/withDA.d.ts.map +0 -1
  170. package/_types/getAccountsTransactionFulls/withP.d.ts +0 -4
  171. package/_types/getAccountsTransactionFulls/withP.d.ts.map +0 -1
  172. package/_types/getAccountsTransactionFulls/withPD.d.ts +0 -4
  173. package/_types/getAccountsTransactionFulls/withPD.d.ts.map +0 -1
  174. package/_types/getAccountsTransactionFulls/withPDA.d.ts +0 -4
  175. package/_types/getAccountsTransactionFulls/withPDA.d.ts.map +0 -1
  176. package/_types/getAccountsTransactionFulls/withUndefined.d.ts +0 -4
  177. package/_types/getAccountsTransactionFulls/withUndefined.d.ts.map +0 -1
  178. package/_types/getTransactionFull/getTransactionFull.d.ts +0 -19
  179. package/_types/getTransactionFull/getTransactionFull.d.ts.map +0 -1
  180. package/_types/getTransactionFull/getTransactionFullCustom.d.ts +0 -4
  181. package/_types/getTransactionFull/getTransactionFullCustom.d.ts.map +0 -1
  182. package/_types/getTransactionFull/index.d.ts +0 -3
  183. package/_types/getTransactionFull/index.d.ts.map +0 -1
  184. package/_types/getTransactionFull/types.d.ts +0 -63
  185. package/_types/getTransactionFull/types.d.ts.map +0 -1
  186. package/_types/getTransactionFull/withD.d.ts +0 -4
  187. package/_types/getTransactionFull/withD.d.ts.map +0 -1
  188. package/_types/getTransactionFull/withDA.d.ts +0 -4
  189. package/_types/getTransactionFull/withDA.d.ts.map +0 -1
  190. package/_types/getTransactionFull/withP.d.ts +0 -4
  191. package/_types/getTransactionFull/withP.d.ts.map +0 -1
  192. package/_types/getTransactionFull/withPD.d.ts +0 -4
  193. package/_types/getTransactionFull/withPD.d.ts.map +0 -1
  194. package/_types/getTransactionFull/withPDA.d.ts +0 -4
  195. package/_types/getTransactionFull/withPDA.d.ts.map +0 -1
  196. package/_types/getTransactionFull/withUndefined.d.ts +0 -4
  197. package/_types/getTransactionFull/withUndefined.d.ts.map +0 -1
  198. package/getAccountsTransactionFulls/getAccountsTransactionFulls.ts +0 -46
  199. package/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.ts +0 -106
  200. package/getAccountsTransactionFulls/getDecodedTransactionsPrices.ts +0 -97
  201. package/getAccountsTransactionFulls/getHashesAndInternalTxs.ts +0 -65
  202. package/getAccountsTransactionFulls/getTransactionDetails.ts +0 -41
  203. package/getAccountsTransactionFulls/getTransactionsApps.ts +0 -42
  204. package/getAccountsTransactionFulls/index.ts +0 -2
  205. package/getAccountsTransactionFulls/types.ts +0 -122
  206. package/getAccountsTransactionFulls/withD.ts +0 -80
  207. package/getAccountsTransactionFulls/withDA.ts +0 -112
  208. package/getAccountsTransactionFulls/withP.ts +0 -120
  209. package/getAccountsTransactionFulls/withPD.ts +0 -141
  210. package/getAccountsTransactionFulls/withPDA.ts +0 -167
  211. package/getAccountsTransactionFulls/withUndefined.ts +0 -88
  212. package/getTransactionFull/getTransactionFull.ts +0 -30
  213. package/getTransactionFull/getTransactionFullCustom.ts +0 -91
  214. package/getTransactionFull/index.ts +0 -2
  215. package/getTransactionFull/types.ts +0 -98
  216. package/getTransactionFull/withD.ts +0 -57
  217. package/getTransactionFull/withDA.ts +0 -78
  218. package/getTransactionFull/withP.ts +0 -69
  219. package/getTransactionFull/withPD.ts +0 -119
  220. package/getTransactionFull/withPDA.ts +0 -147
  221. package/getTransactionFull/withUndefined.ts +0 -39
@@ -1,112 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- import type { Config } from '@0xtorch/core'
3
- import { toLowerHex } from '../types'
4
- import { getHashesAndInternalTxs } from './getHashesAndInternalTxs'
5
- import { getTransactionDetails } from './getTransactionDetails'
6
- import { getTransactionsApps } from './getTransactionsApps'
7
- import type {
8
- GetAccountsTransactionFullsCustomParametersDA,
9
- GetAccountsTransactionFullsCustomReturnType,
10
- } from './types'
11
-
12
- export const getAccountsTransactionFullsCustomWithDA = async (
13
- {
14
- chain,
15
- addresses,
16
- fromBlock,
17
- toBlock,
18
- appDataSource,
19
- decoder,
20
- analyzer,
21
- onFetchHashes,
22
- onFetchTransaction,
23
- }: GetAccountsTransactionFullsCustomParametersDA,
24
- config?: Config,
25
- ): Promise<
26
- GetAccountsTransactionFullsCustomReturnType<GetAccountsTransactionFullsCustomParametersDA>
27
- > => {
28
- const timeoutTimestamp =
29
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
30
-
31
- // get transaction hash & internal transaction by explorer
32
- const { hashes, internalTransactions } = await getHashesAndInternalTxs(
33
- chain,
34
- addresses,
35
- fromBlock,
36
- toBlock,
37
- config,
38
- )
39
- if (hashes.length === 0) {
40
- return []
41
- }
42
- if (onFetchHashes !== undefined) {
43
- onFetchHashes(hashes.map((hash) => toLowerHex(hash)))
44
- }
45
-
46
- // get transaction detail of hashes
47
- const timeoutForGetTransactionDetail = timeoutTimestamp - Date.now()
48
- const transactionDetails = await getTransactionDetails(
49
- chain,
50
- hashes,
51
- internalTransactions,
52
- onFetchTransaction,
53
- {
54
- timeout: timeoutForGetTransactionDetail,
55
- logger: config?.logger,
56
- },
57
- )
58
-
59
- // decode
60
- const { transactions: transactionsDecoded } = await decoder.decode(
61
- {
62
- chain,
63
- transactions: transactionDetails,
64
- },
65
- {
66
- timeout: timeoutTimestamp - Date.now(),
67
- logger: config?.logger,
68
- },
69
- )
70
-
71
- // get apps
72
- const apps = await getTransactionsApps(appDataSource, transactionDetails, {
73
- timeout: timeoutTimestamp - Date.now(),
74
- logger: config?.logger,
75
- })
76
-
77
- const transactionsForAnalyzer = transactionsDecoded.map((transaction) => {
78
- const lowerTo =
79
- transaction.to === null ? undefined : toLowerHex(transaction.to)
80
- const app = apps.find(({ address }) => address === lowerTo)?.app
81
- return {
82
- ...transaction,
83
- app,
84
- nativeTokenPrice: undefined,
85
- }
86
- })
87
-
88
- // analyze
89
- const timeoutForAnalyze = timeoutTimestamp - Date.now()
90
- const analyzedDatas = await Promise.all(
91
- transactionsForAnalyzer.map((transactionForAnalyzer) =>
92
- analyzer.analyze(
93
- {
94
- chain,
95
- transaction: transactionForAnalyzer,
96
- accountAddresses: addresses,
97
- },
98
- {
99
- timeout: timeoutForAnalyze,
100
- logger: config?.logger,
101
- },
102
- ),
103
- ),
104
- )
105
-
106
- return transactionsForAnalyzer.map((transactionForAnalyzer, index) => ({
107
- ...transactionForAnalyzer,
108
- accountAddresses: addresses,
109
- actions: analyzedDatas[index].actions,
110
- accountActions: analyzedDatas[index].accountActions,
111
- }))
112
- }
@@ -1,120 +0,0 @@
1
- import type { Config, CryptoCurrencyPrice } from '@0xtorch/core'
2
- import { toLowerHex } from '../types'
3
- import { getHashesAndInternalTxs } from './getHashesAndInternalTxs'
4
- import { getTransactionDetails } from './getTransactionDetails'
5
- import { getTransactionsApps } from './getTransactionsApps'
6
- import type {
7
- GetAccountsTransactionFullsCustomParametersP,
8
- GetAccountsTransactionFullsCustomReturnType,
9
- } from './types'
10
-
11
- export const getAccountsTransactionFullsCustomWithP = async (
12
- {
13
- chain,
14
- addresses,
15
- fromBlock,
16
- toBlock,
17
- appDataSource,
18
- priceDataSource,
19
- fiat,
20
- onFetchHashes,
21
- onFetchTransaction,
22
- }: GetAccountsTransactionFullsCustomParametersP,
23
- config?: Config,
24
- ): Promise<
25
- GetAccountsTransactionFullsCustomReturnType<GetAccountsTransactionFullsCustomParametersP>
26
- > => {
27
- const timeoutTimestamp =
28
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
29
-
30
- // get transaction hash & internal transaction by explorer
31
- const { hashes, internalTransactions } = await getHashesAndInternalTxs(
32
- chain,
33
- addresses,
34
- fromBlock,
35
- toBlock,
36
- config,
37
- )
38
- if (hashes.length === 0) {
39
- return []
40
- }
41
- if (onFetchHashes !== undefined) {
42
- onFetchHashes(hashes.map((hash) => toLowerHex(hash)))
43
- }
44
-
45
- // get transaction detail of hashes
46
- const timeoutForGetTransactionDetail = timeoutTimestamp - Date.now()
47
- const transactionDetails = await getTransactionDetails(
48
- chain,
49
- hashes,
50
- internalTransactions,
51
- onFetchTransaction,
52
- {
53
- timeout: timeoutForGetTransactionDetail,
54
- logger: config?.logger,
55
- },
56
- )
57
-
58
- // native token price timestamp range
59
- const minTimestamp = transactionDetails.reduce(
60
- (minTimestamp, { block }) =>
61
- Math.min(minTimestamp, Number(block.timestamp)),
62
- Number.MAX_SAFE_INTEGER,
63
- )
64
- const maxTimestamp = transactionDetails.reduce(
65
- (maxTimestamp, { block }) =>
66
- Math.max(maxTimestamp, Number(block.timestamp)),
67
- 0,
68
- )
69
- const from = minTimestamp * 1000 - 1000 * 60 * 60
70
- const to = maxTimestamp * 1000 + 1000 * 60 * 60
71
-
72
- const timeoutForDataSource = timeoutTimestamp - Date.now()
73
- const [apps, prices] = await Promise.all([
74
- // get apps
75
- getTransactionsApps(appDataSource, transactionDetails, {
76
- timeout: timeoutForDataSource,
77
- logger: config?.logger,
78
- }),
79
- // get native token prices
80
- priceDataSource.getHistoricalPrices(
81
- {
82
- targetCurrencies: [chain.nativeToken.currency],
83
- vsCurrency: fiat,
84
- from,
85
- to,
86
- },
87
- {
88
- timeout: timeoutForDataSource,
89
- logger: config?.logger,
90
- },
91
- ),
92
- ])
93
-
94
- return transactionDetails.map((transactionDetail) => {
95
- const lowerTo =
96
- transactionDetail.to === null
97
- ? undefined
98
- : toLowerHex(transactionDetail.to)
99
- const app = apps.find(({ address }) => address === lowerTo)?.app
100
- const price = prices.reduce(
101
- (closestPrice: CryptoCurrencyPrice | undefined, price) =>
102
- closestPrice === undefined ||
103
- Math.abs(
104
- price.timestamp - Number(transactionDetail.block.timestamp) * 1000,
105
- ) <
106
- Math.abs(
107
- closestPrice.timestamp -
108
- Number(transactionDetail.block.timestamp) * 1000,
109
- )
110
- ? price
111
- : closestPrice,
112
- undefined,
113
- )
114
- return {
115
- ...transactionDetail,
116
- app,
117
- nativeTokenPrice: price,
118
- }
119
- })
120
- }
@@ -1,141 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- import type { Config, CryptoCurrencyPrice } from '@0xtorch/core'
3
- import { toLowerHex } from '../types'
4
- import { getDecodedTransactionsPrices } from './getDecodedTransactionsPrices'
5
- import { getHashesAndInternalTxs } from './getHashesAndInternalTxs'
6
- import { getTransactionDetails } from './getTransactionDetails'
7
- import { getTransactionsApps } from './getTransactionsApps'
8
- import type {
9
- GetAccountsTransactionFullsCustomParametersPD,
10
- GetAccountsTransactionFullsCustomReturnType,
11
- } from './types'
12
-
13
- export const getAccountsTransactionFullsCustomWithPD = async (
14
- {
15
- chain,
16
- addresses,
17
- fromBlock,
18
- toBlock,
19
- appDataSource,
20
- priceDataSource,
21
- fiat,
22
- decoder,
23
- onFetchHashes,
24
- onFetchTransaction,
25
- }: GetAccountsTransactionFullsCustomParametersPD,
26
- config?: Config,
27
- ): Promise<
28
- GetAccountsTransactionFullsCustomReturnType<GetAccountsTransactionFullsCustomParametersPD>
29
- > => {
30
- const timeoutTimestamp =
31
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
32
-
33
- // get transaction hash & internal transaction by explorer
34
- const { hashes, internalTransactions } = await getHashesAndInternalTxs(
35
- chain,
36
- addresses,
37
- fromBlock,
38
- toBlock,
39
- config,
40
- )
41
- if (hashes.length === 0) {
42
- return []
43
- }
44
- if (onFetchHashes !== undefined) {
45
- onFetchHashes(hashes.map((hash) => toLowerHex(hash)))
46
- }
47
-
48
- // get transaction detail of hashes
49
- const timeoutForGetTransactionDetail = timeoutTimestamp - Date.now()
50
- const transactionDetails = await getTransactionDetails(
51
- chain,
52
- hashes,
53
- internalTransactions,
54
- onFetchTransaction,
55
- {
56
- timeout: timeoutForGetTransactionDetail,
57
- logger: config?.logger,
58
- },
59
- )
60
-
61
- // decode
62
- const { transactions: transactionsDecoded } = await decoder.decode(
63
- {
64
- chain,
65
- transactions: transactionDetails,
66
- },
67
- {
68
- timeout: timeoutTimestamp - Date.now(),
69
- logger: config?.logger,
70
- },
71
- )
72
-
73
- const timeoutForDataSources = timeoutTimestamp - Date.now()
74
- const [apps, prices] = await Promise.all([
75
- // get apps
76
- getTransactionsApps(appDataSource, transactionDetails, {
77
- timeout: timeoutForDataSources,
78
- logger: config?.logger,
79
- }),
80
- // get prices
81
- getDecodedTransactionsPrices(
82
- chain,
83
- priceDataSource,
84
- fiat,
85
- transactionsDecoded,
86
- {
87
- timeout: timeoutForDataSources,
88
- logger: config?.logger,
89
- },
90
- ),
91
- ])
92
-
93
- return transactionsDecoded.map((transaction) => {
94
- const lowerTo =
95
- transaction.to === null ? undefined : toLowerHex(transaction.to)
96
- const app = apps.find(({ address }) => address === lowerTo)?.app
97
-
98
- const timestampMs = Number(transaction.block.timestamp) * 1000
99
-
100
- const nativeTokenPrice = prices
101
- .filter(
102
- ({ cryptoCurrencyId }) =>
103
- cryptoCurrencyId === chain.nativeToken.currency.id,
104
- )
105
- .reduce((closestPrice, price) =>
106
- Math.abs(price.timestamp - timestampMs) <
107
- Math.abs(closestPrice.timestamp - timestampMs)
108
- ? price
109
- : closestPrice,
110
- )
111
-
112
- return {
113
- ...transaction,
114
- app,
115
- nativeTokenPrice,
116
- internalTransactions: transaction.internalTransactions.map(
117
- (internalTransaction) => ({
118
- ...internalTransaction,
119
- price: nativeTokenPrice,
120
- }),
121
- ),
122
- erc20Transfers: transaction.erc20Transfers.map((transfer) => ({
123
- ...transfer,
124
- price: prices
125
- .filter(
126
- ({ cryptoCurrencyId }) =>
127
- cryptoCurrencyId === transfer.token.currency.id,
128
- )
129
- .reduce(
130
- (closestPrice: CryptoCurrencyPrice | undefined, price) =>
131
- closestPrice === undefined ||
132
- Math.abs(price.timestamp - timestampMs) <
133
- Math.abs(closestPrice.timestamp - timestampMs)
134
- ? price
135
- : closestPrice,
136
- undefined,
137
- ),
138
- })),
139
- }
140
- })
141
- }
@@ -1,167 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- import type { Config, CryptoCurrencyPrice } from '@0xtorch/core'
3
- import { toLowerHex } from '../types'
4
- import { getDecodedTransactionsPrices } from './getDecodedTransactionsPrices'
5
- import { getHashesAndInternalTxs } from './getHashesAndInternalTxs'
6
- import { getTransactionDetails } from './getTransactionDetails'
7
- import { getTransactionsApps } from './getTransactionsApps'
8
- import type {
9
- GetAccountsTransactionFullsCustomParametersPDA,
10
- GetAccountsTransactionFullsCustomReturnType,
11
- } from './types'
12
-
13
- export const getAccountsTransactionFullsCustomWithPDA = async (
14
- {
15
- chain,
16
- addresses,
17
- fromBlock,
18
- toBlock,
19
- appDataSource,
20
- priceDataSource,
21
- fiat,
22
- decoder,
23
- analyzer,
24
- onFetchHashes,
25
- onFetchTransaction,
26
- }: GetAccountsTransactionFullsCustomParametersPDA,
27
- config?: Config,
28
- ): Promise<
29
- GetAccountsTransactionFullsCustomReturnType<GetAccountsTransactionFullsCustomParametersPDA>
30
- > => {
31
- const timeoutTimestamp =
32
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
33
-
34
- // get transaction hash & internal transaction by explorer
35
- const { hashes, internalTransactions } = await getHashesAndInternalTxs(
36
- chain,
37
- addresses,
38
- fromBlock,
39
- toBlock,
40
- config,
41
- )
42
- if (hashes.length === 0) {
43
- return []
44
- }
45
- if (onFetchHashes !== undefined) {
46
- onFetchHashes(hashes.map((hash) => toLowerHex(hash)))
47
- }
48
-
49
- // get transaction detail of hashes
50
- const timeoutForGetTransactionDetail = timeoutTimestamp - Date.now()
51
- const transactionDetails = await getTransactionDetails(
52
- chain,
53
- hashes,
54
- internalTransactions,
55
- onFetchTransaction,
56
- {
57
- timeout: timeoutForGetTransactionDetail,
58
- logger: config?.logger,
59
- },
60
- )
61
-
62
- // decode
63
- const { transactions: transactionsDecoded } = await decoder.decode(
64
- {
65
- chain,
66
- transactions: transactionDetails,
67
- },
68
- {
69
- timeout: timeoutTimestamp - Date.now(),
70
- logger: config?.logger,
71
- },
72
- )
73
-
74
- const timeoutForDataSources = timeoutTimestamp - Date.now()
75
- const [apps, prices] = await Promise.all([
76
- // get apps
77
- getTransactionsApps(appDataSource, transactionDetails, {
78
- timeout: timeoutForDataSources,
79
- logger: config?.logger,
80
- }),
81
- // get prices
82
- getDecodedTransactionsPrices(
83
- chain,
84
- priceDataSource,
85
- fiat,
86
- transactionsDecoded,
87
- {
88
- timeout: timeoutForDataSources,
89
- logger: config?.logger,
90
- },
91
- ),
92
- ])
93
-
94
- const transactionsForAnalyzer = transactionsDecoded.map((transaction) => {
95
- const lowerTo =
96
- transaction.to === null ? undefined : toLowerHex(transaction.to)
97
- const app = apps.find(({ address }) => address === lowerTo)?.app
98
- const timestampMs = Number(transaction.block.timestamp) * 1000
99
- const nativeTokenPrice = prices
100
- .filter(
101
- ({ cryptoCurrencyId }) =>
102
- cryptoCurrencyId === chain.nativeToken.currency.id,
103
- )
104
- .reduce(
105
- (closestPrice: CryptoCurrencyPrice | undefined, price) =>
106
- closestPrice === undefined ||
107
- Math.abs(price.timestamp - timestampMs) <
108
- Math.abs(closestPrice.timestamp - timestampMs)
109
- ? price
110
- : closestPrice,
111
- undefined,
112
- )
113
- return {
114
- ...transaction,
115
- app,
116
- nativeTokenPrice,
117
- internalTransactions: transaction.internalTransactions.map(
118
- (internalTransaction) => ({
119
- ...internalTransaction,
120
- price: nativeTokenPrice,
121
- }),
122
- ),
123
- erc20Transfers: transaction.erc20Transfers.map((transfer) => ({
124
- ...transfer,
125
- price: prices
126
- .filter(
127
- ({ cryptoCurrencyId }) =>
128
- cryptoCurrencyId === transfer.token.currency.id,
129
- )
130
- .reduce(
131
- (closestPrice: CryptoCurrencyPrice | undefined, price) =>
132
- closestPrice === undefined ||
133
- Math.abs(price.timestamp - timestampMs) <
134
- Math.abs(closestPrice.timestamp - timestampMs)
135
- ? price
136
- : closestPrice,
137
- undefined,
138
- ),
139
- })),
140
- }
141
- })
142
-
143
- // analyze
144
- const timeoutForAnalyzer = timeoutTimestamp - Date.now()
145
- const analyzedDatas = await Promise.all(
146
- transactionsForAnalyzer.map((transactionForAnalyzer) =>
147
- analyzer.analyze(
148
- {
149
- chain,
150
- transaction: transactionForAnalyzer,
151
- accountAddresses: addresses,
152
- },
153
- {
154
- timeout: timeoutForAnalyzer,
155
- logger: config?.logger,
156
- },
157
- ),
158
- ),
159
- )
160
-
161
- return transactionsForAnalyzer.map((transactionForAnalyzer, index) => ({
162
- ...transactionForAnalyzer,
163
- accountAddresses: addresses,
164
- actions: analyzedDatas[index].actions,
165
- accountActions: analyzedDatas[index].accountActions,
166
- }))
167
- }
@@ -1,88 +0,0 @@
1
- import type { Config } from '@0xtorch/core'
2
- import type { LowerHex } from '../types'
3
- import { toLowerHex } from '../types'
4
- import { getHashesAndInternalTxs } from './getHashesAndInternalTxs'
5
- import { getTransactionDetails } from './getTransactionDetails'
6
- import type {
7
- GetAccountsTransactionFullsCustomParametersAllUndefined,
8
- GetAccountsTransactionFullsCustomReturnType,
9
- } from './types'
10
-
11
- export const getAccountsTransactionFullsCustomWithAllUndefined = async (
12
- {
13
- chain,
14
- addresses,
15
- fromBlock,
16
- toBlock,
17
- appDataSource,
18
- onFetchHashes,
19
- onFetchTransaction,
20
- }: GetAccountsTransactionFullsCustomParametersAllUndefined,
21
- config?: Config,
22
- ): Promise<
23
- GetAccountsTransactionFullsCustomReturnType<GetAccountsTransactionFullsCustomParametersAllUndefined>
24
- > => {
25
- const timeoutTimestamp =
26
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
27
-
28
- // get transaction hash & internal transaction by explorer
29
- const { hashes, internalTransactions } = await getHashesAndInternalTxs(
30
- chain,
31
- addresses,
32
- fromBlock,
33
- toBlock,
34
- config,
35
- )
36
- if (hashes.length === 0) {
37
- return []
38
- }
39
- if (onFetchHashes !== undefined) {
40
- onFetchHashes(hashes.map((hash) => toLowerHex(hash)))
41
- }
42
-
43
- // get transaction detail of hashes
44
- const timeoutForGetTransactionDetail = timeoutTimestamp - Date.now()
45
- const transactionDetails = await getTransactionDetails(
46
- chain,
47
- hashes,
48
- internalTransactions,
49
- onFetchTransaction,
50
- {
51
- timeout: timeoutForGetTransactionDetail,
52
- logger: config?.logger,
53
- },
54
- )
55
-
56
- // get app of to address
57
- const toAddresses = [
58
- ...new Set(
59
- transactionDetails
60
- .map(({ to }) => (to === null ? undefined : toLowerHex(to)))
61
- .filter((toAddress): toAddress is LowerHex => toAddress !== undefined),
62
- ),
63
- ]
64
- const timeoutForGetApps = timeoutTimestamp - Date.now()
65
- const apps = await Promise.all(
66
- toAddresses.map((toAddress) =>
67
- appDataSource === undefined
68
- ? undefined
69
- : appDataSource.getApp(chain.id, toAddress, {
70
- timeout: timeoutForGetApps,
71
- logger: config?.logger,
72
- }),
73
- ),
74
- )
75
-
76
- return transactionDetails.map((transactionDetail) => {
77
- const appIndex =
78
- transactionDetail.to === null
79
- ? -1
80
- : toAddresses.indexOf(toLowerHex(transactionDetail.to))
81
- const app = appIndex < 0 ? undefined : apps[appIndex]
82
- return {
83
- ...transactionDetail,
84
- app,
85
- nativeTokenPrice: undefined,
86
- }
87
- })
88
- }
@@ -1,30 +0,0 @@
1
- import type { Config, FiatCurrency } from '@0xtorch/core'
2
- import { coingeckoCryptoCurrencyDataSource, usd } from '@0xtorch/core'
3
- import { analyzer } from '../analyzer'
4
- import type { Chain } from '../chains'
5
- import { decoder } from '../decoder'
6
- import type { Hex } from '../types'
7
- import { getTransactionFullCustom } from './getTransactionFullCustom'
8
-
9
- type GetTransactionFullParameters = {
10
- readonly chain: Chain
11
- readonly hash: Hex
12
- readonly fiat?: FiatCurrency
13
- }
14
-
15
- export const getTransactionFull = async (
16
- { chain, hash, fiat = usd }: GetTransactionFullParameters,
17
- config?: Config,
18
- ) =>
19
- await getTransactionFullCustom(
20
- {
21
- chain,
22
- hash,
23
- appDataSource: undefined,
24
- priceDataSource: coingeckoCryptoCurrencyDataSource,
25
- fiat,
26
- decoder,
27
- analyzer,
28
- },
29
- config,
30
- )