@0xtorch/evm 0.0.30 → 0.0.32

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 (83) hide show
  1. package/_cjs/analyzer/json/components/targetAsset.js +3 -1
  2. package/_cjs/analyzer/json/components/targetAsset.js.map +1 -1
  3. package/_cjs/analyzer/json/schemas/generator.js +1 -0
  4. package/_cjs/analyzer/json/schemas/generator.js.map +1 -1
  5. package/_cjs/decoder/decode.js +1 -1
  6. package/_cjs/decoder/decode.js.map +1 -1
  7. package/_cjs/decoder/parseErc1155TransferSingleLogs.js +1 -1
  8. package/_cjs/decoder/parseErc1155TransferSingleLogs.js.map +1 -1
  9. package/_cjs/decoder/parseErc721TransferLogs.js +1 -1
  10. package/_cjs/decoder/parseErc721TransferLogs.js.map +1 -1
  11. package/_cjs/index.js +5 -2
  12. package/_cjs/index.js.map +1 -1
  13. package/_cjs/utils/create.js +9 -3
  14. package/_cjs/utils/create.js.map +1 -1
  15. package/_cjs/utils/index.js +5 -2
  16. package/_cjs/utils/index.js.map +1 -1
  17. package/_esm/analyzer/json/components/targetAsset.js +4 -2
  18. package/_esm/analyzer/json/components/targetAsset.js.map +1 -1
  19. package/_esm/analyzer/json/schemas/generator.js +1 -0
  20. package/_esm/analyzer/json/schemas/generator.js.map +1 -1
  21. package/_esm/decoder/decode.js +2 -2
  22. package/_esm/decoder/decode.js.map +1 -1
  23. package/_esm/decoder/parseErc1155TransferSingleLogs.js +2 -2
  24. package/_esm/decoder/parseErc1155TransferSingleLogs.js.map +1 -1
  25. package/_esm/decoder/parseErc721TransferLogs.js +2 -2
  26. package/_esm/decoder/parseErc721TransferLogs.js.map +1 -1
  27. package/_esm/index.js +1 -1
  28. package/_esm/index.js.map +1 -1
  29. package/_esm/utils/create.js +4 -1
  30. package/_esm/utils/create.js.map +1 -1
  31. package/_esm/utils/index.js +1 -1
  32. package/_esm/utils/index.js.map +1 -1
  33. package/_types/analyzer/json/components/targetAsset.d.ts.map +1 -1
  34. package/_types/analyzer/json/schemas/generator.d.ts +3 -0
  35. package/_types/analyzer/json/schemas/generator.d.ts.map +1 -1
  36. package/_types/index.d.ts +2 -2
  37. package/_types/index.d.ts.map +1 -1
  38. package/_types/types/erc1155.d.ts +1 -0
  39. package/_types/types/erc1155.d.ts.map +1 -1
  40. package/_types/types/erc721.d.ts +1 -0
  41. package/_types/types/erc721.d.ts.map +1 -1
  42. package/_types/types/index.d.ts +2 -2
  43. package/_types/types/index.d.ts.map +1 -1
  44. package/_types/utils/create.d.ts +10 -3
  45. package/_types/utils/create.d.ts.map +1 -1
  46. package/_types/utils/index.d.ts +1 -1
  47. package/_types/utils/index.d.ts.map +1 -1
  48. package/analyzer/json/components/targetAsset.ts +5 -2
  49. package/analyzer/json/schemas/generator.ts +1 -0
  50. package/decoder/decode.ts +3 -2
  51. package/decoder/parseErc1155TransferSingleLogs.ts +2 -2
  52. package/decoder/parseErc721TransferLogs.ts +2 -2
  53. package/index.ts +6 -9
  54. package/package.json +2 -2
  55. package/types/erc1155.ts +2 -0
  56. package/types/erc721.ts +2 -0
  57. package/types/index.ts +2 -2
  58. package/utils/create.ts +19 -4
  59. package/utils/index.ts +4 -1
  60. package/getAccountsTransactionFulls/getAccountsTransactionFulls.ts +0 -46
  61. package/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.ts +0 -106
  62. package/getAccountsTransactionFulls/getDecodedTransactionsPrices.ts +0 -97
  63. package/getAccountsTransactionFulls/getHashesAndInternalTxs.ts +0 -65
  64. package/getAccountsTransactionFulls/getTransactionDetails.ts +0 -41
  65. package/getAccountsTransactionFulls/getTransactionsApps.ts +0 -42
  66. package/getAccountsTransactionFulls/index.ts +0 -2
  67. package/getAccountsTransactionFulls/types.ts +0 -122
  68. package/getAccountsTransactionFulls/withD.ts +0 -80
  69. package/getAccountsTransactionFulls/withDA.ts +0 -112
  70. package/getAccountsTransactionFulls/withP.ts +0 -120
  71. package/getAccountsTransactionFulls/withPD.ts +0 -141
  72. package/getAccountsTransactionFulls/withPDA.ts +0 -167
  73. package/getAccountsTransactionFulls/withUndefined.ts +0 -88
  74. package/getTransactionFull/getTransactionFull.ts +0 -30
  75. package/getTransactionFull/getTransactionFullCustom.ts +0 -91
  76. package/getTransactionFull/index.ts +0 -2
  77. package/getTransactionFull/types.ts +0 -98
  78. package/getTransactionFull/withD.ts +0 -57
  79. package/getTransactionFull/withDA.ts +0 -78
  80. package/getTransactionFull/withP.ts +0 -69
  81. package/getTransactionFull/withPD.ts +0 -119
  82. package/getTransactionFull/withPDA.ts +0 -147
  83. package/getTransactionFull/withUndefined.ts +0 -39
package/decoder/decode.ts CHANGED
@@ -23,7 +23,7 @@ import type {
23
23
  TransactionDecoded,
24
24
  } from '../types'
25
25
  import { parsedLogSchema, toLowerHex } from '../types'
26
- import { checkTimeout, createEvmCurrencyId, createEvmNftId } from '../utils'
26
+ import { checkTimeout, createErc1155NftId, createEvmCurrencyId } from '../utils'
27
27
  import { parseErc1155TransferSingleLogs } from './parseErc1155TransferSingleLogs'
28
28
  import { parseErc20TransferLogs } from './parseErc20TransferLogs'
29
29
  import { parseErc721TransferLogs } from './parseErc721TransferLogs'
@@ -279,7 +279,7 @@ const getErcTransfers = (
279
279
  value: log.args.values[index],
280
280
  nft: {
281
281
  type: 'Nft',
282
- id: createEvmNftId({
282
+ id: createErc1155NftId({
283
283
  chainId: chain.id,
284
284
  address: toLowerHex(log.address),
285
285
  tokenId: id,
@@ -537,6 +537,7 @@ const getErc20Token = async (
537
537
  coingeckoId: coin?.id,
538
538
  marketCapUsd: undefined,
539
539
  },
540
+ priceDatasourceId: undefined,
540
541
  updatedAt: Date.now(),
541
542
  },
542
543
  }
@@ -1,7 +1,7 @@
1
1
  import type { Log } from 'viem'
2
2
  import type { Erc1155Transfer } from '../types'
3
3
  import { toLowerHex } from '../types'
4
- import { createEvmNftId } from '../utils'
4
+ import { createErc1155NftId } from '../utils'
5
5
 
6
6
  const transferSingleSignature =
7
7
  '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62'
@@ -35,7 +35,7 @@ export const parseErc1155TransferSingleLogs = (
35
35
  value: BigInt(`0x${log.data.slice(66, 130)}`),
36
36
  nft: {
37
37
  type: 'Nft',
38
- id: createEvmNftId({
38
+ id: createErc1155NftId({
39
39
  chainId,
40
40
  address: toLowerHex(log.address),
41
41
  tokenId: id,
@@ -1,7 +1,7 @@
1
1
  import type { Log } from 'viem'
2
2
  import type { Erc721Transfer, LowerHex } from '../types'
3
3
  import { toLowerHex } from '../types'
4
- import { createEvmNftId } from '../utils'
4
+ import { createErc721NftId } from '../utils'
5
5
 
6
6
  const signature =
7
7
  '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
@@ -35,7 +35,7 @@ export const parseErc721TransferLogs = (
35
35
  tokenId,
36
36
  nft: {
37
37
  type: 'Nft',
38
- id: createEvmNftId({
38
+ id: createErc721NftId({
39
39
  chainId,
40
40
  address: toLowerHex(log.address),
41
41
  tokenId,
package/index.ts CHANGED
@@ -92,21 +92,15 @@ export {
92
92
  createRoninExplorer,
93
93
  } from './explorers'
94
94
  export type { Explorer } from './explorers'
95
- export {
96
- getAccountsTransactionFulls,
97
- getAccountsTransactionFullsCustom,
98
- } from './getAccountsTransactionFulls'
99
95
  export { getTransactionDetail } from './getTransactionDetail'
100
- export {
101
- getTransactionFull,
102
- getTransactionFullCustom,
103
- } from './getTransactionFull'
104
96
  export { isHex, parsedLogSchema, toLowerHex } from './types'
105
97
  export type {
98
+ Erc1155NftId,
106
99
  Erc1155Token,
107
100
  Erc1155Transfer,
108
101
  Erc20Token,
109
102
  Erc20Transfer,
103
+ Erc721NftId,
110
104
  Erc721Token,
111
105
  Erc721Transfer,
112
106
  EvmAccount,
@@ -121,8 +115,11 @@ export type {
121
115
  TransactionSource,
122
116
  } from './types'
123
117
  export {
118
+ createErc1155NftId,
119
+ createErc721NftId,
124
120
  createEvmActionSource,
125
121
  createEvmAddressId,
126
122
  createEvmCurrencyId,
127
- createEvmNftId,
123
+ isErc1155NftId,
124
+ isErc721NftId,
128
125
  } from './utils'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/evm",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "Cryptorch EVM extension",
5
5
  "keywords": [
6
6
  "cryptorch",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@0xtorch/big-decimal": "^0.0.10",
41
- "@0xtorch/core": "^0.0.28",
41
+ "@0xtorch/core": "^0.0.29",
42
42
  "@supercharge/promise-pool": "^3.1.1",
43
43
  "viem": "^2.9.16",
44
44
  "zod": "^3.22.4"
package/types/erc1155.ts CHANGED
@@ -15,3 +15,5 @@ export type Erc1155Transfer = {
15
15
  readonly value: bigint
16
16
  readonly nft: Nft
17
17
  }
18
+
19
+ export type Erc1155NftId = `evm_1155_${number}_${LowerHex}_${bigint}`
package/types/erc721.ts CHANGED
@@ -17,3 +17,5 @@ export type Erc721Transfer = {
17
17
  readonly tokenId: bigint
18
18
  readonly nft: Nft
19
19
  }
20
+
21
+ export type Erc721NftId = `evm_721_${number}_${LowerHex}_${bigint}`
package/types/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type { Erc1155Token, Erc1155Transfer } from './erc1155'
1
+ export type { Erc1155NftId, Erc1155Token, Erc1155Transfer } from './erc1155'
2
2
  export type { Erc20Token, Erc20Transfer } from './erc20'
3
- export type { Erc721Token, Erc721Transfer } from './erc721'
3
+ export type { Erc721NftId, Erc721Token, Erc721Transfer } from './erc721'
4
4
  export type { EvmAccount } from './evmAccount'
5
5
  export { isHex, toLowerHex } from './hex'
6
6
  export type { Hex, LowerHex } from './hex'
package/utils/create.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Hex, LowerHex } from '../types'
1
+ import type { Erc1155NftId, Erc721NftId, Hex, LowerHex } from '../types'
2
2
  import { isHex, toLowerHex } from '../types'
3
3
 
4
4
  type CreateEvmAddressIdParameters = {
@@ -35,7 +35,7 @@ export const createEvmCurrencyId = ({
35
35
  readonly address: LowerHex
36
36
  }): `evm_${number}_0x${Lowercase<string>}` => `evm_${chainId}_${address}`
37
37
 
38
- export const createEvmNftId = ({
38
+ export const createErc721NftId = ({
39
39
  chainId,
40
40
  address,
41
41
  tokenId,
@@ -43,8 +43,23 @@ export const createEvmNftId = ({
43
43
  readonly chainId: number
44
44
  readonly address: LowerHex
45
45
  tokenId: bigint
46
- }): `evm_${number}_0x${Lowercase<string>}_${bigint}` =>
47
- `evm_${chainId}_${address}_${tokenId}`
46
+ }): Erc721NftId => `evm_721_${chainId}_${address}_${tokenId}`
47
+
48
+ export const isErc721NftId = (value: string): value is Erc721NftId =>
49
+ /^evm_721_\d+_0x[\dA-Fa-f]{40}_\d+$/.test(value)
50
+
51
+ export const createErc1155NftId = ({
52
+ chainId,
53
+ address,
54
+ tokenId,
55
+ }: {
56
+ readonly chainId: number
57
+ readonly address: LowerHex
58
+ tokenId: bigint
59
+ }): Erc1155NftId => `evm_1155_${chainId}_${address}_${tokenId}`
60
+
61
+ export const isErc1155NftId = (value: string): value is Erc1155NftId =>
62
+ /^evm_1155_\d+_0x[\dA-Fa-f]{40}_\d+$/.test(value)
48
63
 
49
64
  export const getEvmAddressDataOfEvmAddressId = (
50
65
  id: string,
package/utils/index.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  export { bigIntMax, bigIntMin } from './bigint'
2
2
  export {
3
+ createErc1155NftId,
4
+ createErc721NftId,
3
5
  createEvmActionSource,
4
6
  createEvmAddressId,
5
7
  createEvmCurrencyId,
6
- createEvmNftId,
8
+ isErc1155NftId,
9
+ isErc721NftId,
7
10
  } from './create'
8
11
  export { checkTimeout } from './timeout'
9
12
  export type { Prettify } from './types'
@@ -1,46 +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 { LowerHex } from '../types'
7
- import { getAccountsTransactionFullsCustom } from './getAccountsTransactionFullsCustom'
8
-
9
- type GetAccountsTransactionFullsParameters = {
10
- readonly chain: Chain
11
- readonly addresses: readonly LowerHex[]
12
- readonly fromBlock: bigint
13
- readonly toBlock: bigint
14
- readonly fiat?: FiatCurrency
15
- readonly onFetchHashes?: (hashes: readonly LowerHex[]) => void
16
- readonly onFetchTransaction?: (hash: LowerHex) => void
17
- }
18
-
19
- export const getAccountsTransactionFulls = async (
20
- {
21
- chain,
22
- addresses,
23
- fromBlock,
24
- toBlock,
25
- fiat = usd,
26
- onFetchHashes,
27
- onFetchTransaction,
28
- }: GetAccountsTransactionFullsParameters,
29
- config?: Config,
30
- ) =>
31
- await getAccountsTransactionFullsCustom(
32
- {
33
- chain,
34
- addresses,
35
- fromBlock,
36
- toBlock,
37
- appDataSource: undefined,
38
- priceDataSource: coingeckoCryptoCurrencyDataSource,
39
- fiat,
40
- decoder,
41
- analyzer,
42
- onFetchHashes,
43
- onFetchTransaction,
44
- },
45
- config,
46
- )
@@ -1,106 +0,0 @@
1
- import type { Config } from '@0xtorch/core'
2
- import type {
3
- GetAccountsTransactionFullsCustomParameters,
4
- GetAccountsTransactionFullsCustomParametersAllUndefined,
5
- GetAccountsTransactionFullsCustomParametersD,
6
- GetAccountsTransactionFullsCustomParametersDA,
7
- GetAccountsTransactionFullsCustomParametersP,
8
- GetAccountsTransactionFullsCustomParametersPD,
9
- GetAccountsTransactionFullsCustomParametersPDA,
10
- GetAccountsTransactionFullsCustomReturnType,
11
- } from './types'
12
- import { getAccountsTransactionFullsCustomWithD } from './withD'
13
- import { getAccountsTransactionFullsCustomWithDA } from './withDA'
14
- import { getAccountsTransactionFullsCustomWithP } from './withP'
15
- import { getAccountsTransactionFullsCustomWithPD } from './withPD'
16
- import { getAccountsTransactionFullsCustomWithPDA } from './withPDA'
17
- import { getAccountsTransactionFullsCustomWithAllUndefined } from './withUndefined'
18
-
19
- export const getAccountsTransactionFullsCustom = async <
20
- T extends GetAccountsTransactionFullsCustomParameters,
21
- >(
22
- parameters: T,
23
- config?: Config,
24
- ): Promise<GetAccountsTransactionFullsCustomReturnType<T>> => {
25
- if (isParametersAllUndefined(parameters)) {
26
- const data = await getAccountsTransactionFullsCustomWithAllUndefined(
27
- parameters,
28
- config,
29
- )
30
- return data as GetAccountsTransactionFullsCustomReturnType<T>
31
- }
32
- if (isParametersP(parameters)) {
33
- const data = await getAccountsTransactionFullsCustomWithP(
34
- parameters,
35
- config,
36
- )
37
- return data as GetAccountsTransactionFullsCustomReturnType<T>
38
- }
39
- if (isParametersPD(parameters)) {
40
- const data = await getAccountsTransactionFullsCustomWithPD(
41
- parameters,
42
- config,
43
- )
44
- return data as GetAccountsTransactionFullsCustomReturnType<T>
45
- }
46
- if (isParametersPDA(parameters)) {
47
- const data = await getAccountsTransactionFullsCustomWithPDA(
48
- parameters,
49
- config,
50
- )
51
- return data as GetAccountsTransactionFullsCustomReturnType<T>
52
- }
53
- if (isParametersD(parameters)) {
54
- const data = await getAccountsTransactionFullsCustomWithD(
55
- parameters,
56
- config,
57
- )
58
- return data as GetAccountsTransactionFullsCustomReturnType<T>
59
- }
60
- if (isParametersDA(parameters)) {
61
- const data = await getAccountsTransactionFullsCustomWithDA(
62
- parameters,
63
- config,
64
- )
65
- return data as GetAccountsTransactionFullsCustomReturnType<T>
66
- }
67
- throw new Error('not implemented')
68
- }
69
-
70
- const isParametersAllUndefined = (
71
- parameters: GetAccountsTransactionFullsCustomParameters,
72
- ): parameters is GetAccountsTransactionFullsCustomParametersAllUndefined =>
73
- parameters.priceDataSource === undefined && parameters.decoder === undefined
74
-
75
- const isParametersP = (
76
- parameters: GetAccountsTransactionFullsCustomParameters,
77
- ): parameters is GetAccountsTransactionFullsCustomParametersP =>
78
- parameters.priceDataSource !== undefined && parameters.decoder === undefined
79
-
80
- const isParametersPD = (
81
- parameters: GetAccountsTransactionFullsCustomParameters,
82
- ): parameters is GetAccountsTransactionFullsCustomParametersPD =>
83
- parameters.priceDataSource !== undefined &&
84
- parameters.decoder !== undefined &&
85
- parameters.analyzer === undefined
86
-
87
- const isParametersPDA = (
88
- parameters: GetAccountsTransactionFullsCustomParameters,
89
- ): parameters is GetAccountsTransactionFullsCustomParametersPDA =>
90
- parameters.priceDataSource !== undefined &&
91
- parameters.decoder !== undefined &&
92
- parameters.analyzer !== undefined
93
-
94
- const isParametersD = (
95
- parameters: GetAccountsTransactionFullsCustomParameters,
96
- ): parameters is GetAccountsTransactionFullsCustomParametersD =>
97
- parameters.priceDataSource === undefined &&
98
- parameters.decoder !== undefined &&
99
- parameters.analyzer === undefined
100
-
101
- const isParametersDA = (
102
- parameters: GetAccountsTransactionFullsCustomParameters,
103
- ): parameters is GetAccountsTransactionFullsCustomParametersDA =>
104
- parameters.priceDataSource === undefined &&
105
- parameters.decoder !== undefined &&
106
- parameters.analyzer !== undefined
@@ -1,97 +0,0 @@
1
- import type {
2
- Config,
3
- CryptoCurrency,
4
- CryptoCurrencyDataSource,
5
- CryptoCurrencyPrice,
6
- FiatCurrency,
7
- } from '@0xtorch/core'
8
- import type { Chain } from '../chains'
9
- import type { TransactionDecoded } from '../types'
10
-
11
- export const getDecodedTransactionsPrices = async (
12
- chain: Chain,
13
- priceDataSource: CryptoCurrencyDataSource,
14
- fiat: FiatCurrency,
15
- transactions: readonly TransactionDecoded<undefined>[],
16
- config?: Config,
17
- ): Promise<readonly CryptoCurrencyPrice[]> => {
18
- const timeoutTimestamp =
19
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
20
-
21
- // create currency timestamp range
22
- const mut_currencyTimestamps: {
23
- readonly currency: CryptoCurrency
24
- minTimestamp: number
25
- maxTimestamp: number
26
- }[] = []
27
- for (const transaction of transactions) {
28
- const timestampMs = Number(transaction.block.timestamp) * 1000
29
-
30
- // native token currency
31
- const mut_nativeCurrency = mut_currencyTimestamps.find(
32
- ({ currency }) => currency.id === chain.nativeToken.currency.id,
33
- )
34
- if (mut_nativeCurrency === undefined) {
35
- mut_currencyTimestamps.push({
36
- currency: chain.nativeToken.currency,
37
- minTimestamp: timestampMs,
38
- maxTimestamp: timestampMs,
39
- })
40
- } else {
41
- mut_nativeCurrency.minTimestamp = Math.min(
42
- mut_nativeCurrency.minTimestamp,
43
- timestampMs,
44
- )
45
- mut_nativeCurrency.maxTimestamp = Math.max(
46
- mut_nativeCurrency.maxTimestamp,
47
- timestampMs,
48
- )
49
- }
50
-
51
- // erc20 token currency
52
- for (const { token } of transaction.erc20Transfers) {
53
- if (token.currency.market.coingeckoId === undefined) {
54
- continue
55
- }
56
- const mut_currency = mut_currencyTimestamps.find(
57
- ({ currency }) => currency.id === token.currency.id,
58
- )
59
- if (mut_currency === undefined) {
60
- mut_currencyTimestamps.push({
61
- currency: token.currency,
62
- minTimestamp: timestampMs,
63
- maxTimestamp: timestampMs,
64
- })
65
- } else {
66
- mut_currency.minTimestamp = Math.min(
67
- mut_currency.minTimestamp,
68
- timestampMs,
69
- )
70
- mut_currency.maxTimestamp = Math.max(
71
- mut_currency.maxTimestamp,
72
- timestampMs,
73
- )
74
- }
75
- }
76
- }
77
-
78
- // get token price
79
- const mut_prices: CryptoCurrencyPrice[] = []
80
- for (const currencyTimestamp of mut_currencyTimestamps) {
81
- const prices = await priceDataSource.getHistoricalPrices(
82
- {
83
- targetCurrencies: [currencyTimestamp.currency],
84
- vsCurrency: fiat,
85
- from: currencyTimestamp.minTimestamp - 1000 * 60 * 60,
86
- to: currencyTimestamp.maxTimestamp + 1000 * 60 * 60,
87
- },
88
- {
89
- timeout: timeoutTimestamp - Date.now(),
90
- logger: config?.logger,
91
- },
92
- )
93
- mut_prices.push(...prices)
94
- }
95
-
96
- return mut_prices
97
- }
@@ -1,65 +0,0 @@
1
- import type { Config } from '@0xtorch/core'
2
- import type { Chain } from '../chains'
3
- import type { Hex, InternalTransaction, LowerHex } from '../types'
4
- import { checkTimeout } from '../utils'
5
-
6
- export const getHashesAndInternalTxs = async (
7
- chain: Chain,
8
- addresses: readonly LowerHex[],
9
- fromBlock: bigint,
10
- toBlock: bigint,
11
- config?: Config,
12
- ): Promise<{
13
- readonly hashes: readonly Hex[]
14
- readonly internalTransactions: readonly InternalTransaction<undefined>[]
15
- }> => {
16
- const timeoutTimestamp =
17
- Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
18
-
19
- const mut_internalTransactions: InternalTransaction<undefined>[] = []
20
- const hashSet = new Set<Hex>()
21
- for (const address of addresses) {
22
- const normalTxHashes = await chain.explorer.getAddressTransactionHashes({
23
- address,
24
- startBlock: fromBlock,
25
- endBlock: toBlock,
26
- logger: config?.logger,
27
- })
28
- checkTimeout(timeoutTimestamp)
29
-
30
- for (const hash of normalTxHashes) {
31
- hashSet.add(hash)
32
- }
33
- const transferTxHashes = await chain.explorer.getAddressTokenTransferHashes(
34
- {
35
- address,
36
- startBlock: fromBlock,
37
- endBlock: toBlock,
38
- logger: config?.logger,
39
- },
40
- )
41
- checkTimeout(timeoutTimestamp)
42
-
43
- for (const hash of transferTxHashes) {
44
- hashSet.add(hash)
45
- }
46
- const internalTransactions =
47
- await chain.explorer.getAddressInternalTransactions({
48
- address,
49
- startBlock: fromBlock,
50
- endBlock: toBlock,
51
- nativeCurrency: chain.nativeToken.currency,
52
- logger: config?.logger,
53
- })
54
- checkTimeout(timeoutTimestamp)
55
-
56
- for (const internalTransaction of internalTransactions) {
57
- mut_internalTransactions.push(internalTransaction)
58
- hashSet.add(internalTransaction.transactionHash)
59
- }
60
- }
61
- return {
62
- hashes: [...hashSet],
63
- internalTransactions: mut_internalTransactions,
64
- }
65
- }
@@ -1,41 +0,0 @@
1
- import type { Config } from '@0xtorch/core'
2
- import { PromisePool } from '@supercharge/promise-pool'
3
- import type { Chain } from '../chains'
4
- import { getTransactionDetail } from '../getTransactionDetail'
5
- import type { Hex, InternalTransaction, TransactionDetail } from '../types'
6
- import { toLowerHex } from '../types'
7
-
8
- export const getTransactionDetails = async (
9
- chain: Chain,
10
- hashes: readonly Hex[],
11
- internalTransactions: readonly InternalTransaction<undefined>[],
12
- onFetchTransaction: ((hash: `0x${Lowercase<string>}`) => void) | undefined,
13
- config?: Config,
14
- ): Promise<readonly TransactionDetail[]> => {
15
- const mut_transactions: TransactionDetail[] = []
16
-
17
- const { errors } = await PromisePool.for(hashes)
18
- .withConcurrency(chain.client.httpRpcCount)
19
- .process(async (hash) => {
20
- const transactionDetail = await getTransactionDetail(
21
- {
22
- chain,
23
- hash,
24
- internalTransactions: internalTransactions.filter(
25
- ({ transactionHash }) => transactionHash === hash,
26
- ),
27
- },
28
- config,
29
- )
30
- if (onFetchTransaction !== undefined) {
31
- onFetchTransaction(toLowerHex(hash))
32
- }
33
- mut_transactions.push(transactionDetail)
34
- })
35
-
36
- if (errors.length > 0) {
37
- throw errors[0]
38
- }
39
-
40
- return mut_transactions
41
- }
@@ -1,42 +0,0 @@
1
- import type { App, Config } from '@0xtorch/core'
2
- import type { AppDataSource } from '../apps'
3
- import type { LowerHex, TransactionDetail } from '../types'
4
- import { toLowerHex } from '../types'
5
-
6
- export const getTransactionsApps = async (
7
- appDataSource: AppDataSource | undefined,
8
- transactionos: readonly TransactionDetail[],
9
- config?: Config,
10
- ): Promise<
11
- {
12
- readonly address: LowerHex
13
- readonly app: App | undefined
14
- }[]
15
- > => {
16
- if (transactionos.length === 0) {
17
- return []
18
- }
19
- const { chainId } = transactionos[0]
20
-
21
- // to addresses
22
- const toAddresses = [
23
- ...new Set(
24
- transactionos
25
- .map(({ to }) => (to === null ? undefined : toLowerHex(to)))
26
- .filter((toAddress): toAddress is LowerHex => toAddress !== undefined),
27
- ),
28
- ]
29
-
30
- const apps = await Promise.all(
31
- toAddresses.map((toAddress) =>
32
- appDataSource === undefined
33
- ? undefined
34
- : appDataSource.getApp(chainId, toAddress, config),
35
- ),
36
- )
37
-
38
- return toAddresses.map((address, index) => ({
39
- address,
40
- app: apps[index],
41
- }))
42
- }
@@ -1,2 +0,0 @@
1
- export { getAccountsTransactionFulls } from './getAccountsTransactionFulls'
2
- export { getAccountsTransactionFullsCustom } from './getAccountsTransactionFullsCustom'