@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.
- package/_cjs/analyzer/json/components/targetAsset.js +3 -1
- package/_cjs/analyzer/json/components/targetAsset.js.map +1 -1
- package/_cjs/analyzer/json/schemas/generator.js +1 -0
- package/_cjs/analyzer/json/schemas/generator.js.map +1 -1
- package/_cjs/decoder/decode.js +1 -1
- package/_cjs/decoder/decode.js.map +1 -1
- package/_cjs/decoder/parseErc1155TransferSingleLogs.js +1 -1
- package/_cjs/decoder/parseErc1155TransferSingleLogs.js.map +1 -1
- package/_cjs/decoder/parseErc721TransferLogs.js +1 -1
- package/_cjs/decoder/parseErc721TransferLogs.js.map +1 -1
- package/_cjs/index.js +5 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/create.js +9 -3
- package/_cjs/utils/create.js.map +1 -1
- package/_cjs/utils/index.js +5 -2
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/analyzer/json/components/targetAsset.js +4 -2
- package/_esm/analyzer/json/components/targetAsset.js.map +1 -1
- package/_esm/analyzer/json/schemas/generator.js +1 -0
- package/_esm/analyzer/json/schemas/generator.js.map +1 -1
- package/_esm/decoder/decode.js +2 -2
- package/_esm/decoder/decode.js.map +1 -1
- package/_esm/decoder/parseErc1155TransferSingleLogs.js +2 -2
- package/_esm/decoder/parseErc1155TransferSingleLogs.js.map +1 -1
- package/_esm/decoder/parseErc721TransferLogs.js +2 -2
- package/_esm/decoder/parseErc721TransferLogs.js.map +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/utils/create.js +4 -1
- package/_esm/utils/create.js.map +1 -1
- package/_esm/utils/index.js +1 -1
- package/_esm/utils/index.js.map +1 -1
- package/_types/analyzer/json/components/targetAsset.d.ts.map +1 -1
- package/_types/analyzer/json/schemas/generator.d.ts +3 -0
- package/_types/analyzer/json/schemas/generator.d.ts.map +1 -1
- package/_types/index.d.ts +2 -2
- package/_types/index.d.ts.map +1 -1
- package/_types/types/erc1155.d.ts +1 -0
- package/_types/types/erc1155.d.ts.map +1 -1
- package/_types/types/erc721.d.ts +1 -0
- package/_types/types/erc721.d.ts.map +1 -1
- package/_types/types/index.d.ts +2 -2
- package/_types/types/index.d.ts.map +1 -1
- package/_types/utils/create.d.ts +10 -3
- package/_types/utils/create.d.ts.map +1 -1
- package/_types/utils/index.d.ts +1 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/analyzer/json/components/targetAsset.ts +5 -2
- package/analyzer/json/schemas/generator.ts +1 -0
- package/decoder/decode.ts +3 -2
- package/decoder/parseErc1155TransferSingleLogs.ts +2 -2
- package/decoder/parseErc721TransferLogs.ts +2 -2
- package/index.ts +6 -9
- package/package.json +2 -2
- package/types/erc1155.ts +2 -0
- package/types/erc721.ts +2 -0
- package/types/index.ts +2 -2
- package/utils/create.ts +19 -4
- package/utils/index.ts +4 -1
- package/getAccountsTransactionFulls/getAccountsTransactionFulls.ts +0 -46
- package/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.ts +0 -106
- package/getAccountsTransactionFulls/getDecodedTransactionsPrices.ts +0 -97
- package/getAccountsTransactionFulls/getHashesAndInternalTxs.ts +0 -65
- package/getAccountsTransactionFulls/getTransactionDetails.ts +0 -41
- package/getAccountsTransactionFulls/getTransactionsApps.ts +0 -42
- package/getAccountsTransactionFulls/index.ts +0 -2
- package/getAccountsTransactionFulls/types.ts +0 -122
- package/getAccountsTransactionFulls/withD.ts +0 -80
- package/getAccountsTransactionFulls/withDA.ts +0 -112
- package/getAccountsTransactionFulls/withP.ts +0 -120
- package/getAccountsTransactionFulls/withPD.ts +0 -141
- package/getAccountsTransactionFulls/withPDA.ts +0 -167
- package/getAccountsTransactionFulls/withUndefined.ts +0 -88
- package/getTransactionFull/getTransactionFull.ts +0 -30
- package/getTransactionFull/getTransactionFullCustom.ts +0 -91
- package/getTransactionFull/index.ts +0 -2
- package/getTransactionFull/types.ts +0 -98
- package/getTransactionFull/withD.ts +0 -57
- package/getTransactionFull/withDA.ts +0 -78
- package/getTransactionFull/withP.ts +0 -69
- package/getTransactionFull/withPD.ts +0 -119
- package/getTransactionFull/withPDA.ts +0 -147
- package/getTransactionFull/withUndefined.ts +0 -39
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/* eslint-disable unicorn/filename-case */
|
|
2
|
-
import type { Config, CryptoCurrency, CryptoCurrencyPrice } from '@0xtorch/core'
|
|
3
|
-
import { getTransactionDetail } from '../getTransactionDetail'
|
|
4
|
-
import { toLowerHex } from '../types'
|
|
5
|
-
import type {
|
|
6
|
-
GetTransactionFullCustomParametersPD,
|
|
7
|
-
GetTransactionFullCustomReturnType,
|
|
8
|
-
} from './types'
|
|
9
|
-
|
|
10
|
-
export const getTransactionFullCustomWithPD = async (
|
|
11
|
-
parameters: GetTransactionFullCustomParametersPD,
|
|
12
|
-
config?: Config,
|
|
13
|
-
): Promise<
|
|
14
|
-
GetTransactionFullCustomReturnType<GetTransactionFullCustomParametersPD>
|
|
15
|
-
> => {
|
|
16
|
-
const timeoutTimestamp =
|
|
17
|
-
Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
|
|
18
|
-
|
|
19
|
-
const { chain, hash, appDataSource, priceDataSource, fiat, decoder } =
|
|
20
|
-
parameters
|
|
21
|
-
|
|
22
|
-
// get transaction detail
|
|
23
|
-
const transactionDetail = await getTransactionDetail({ chain, hash }, config)
|
|
24
|
-
if (transactionDetail === undefined) {
|
|
25
|
-
return undefined
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// decode
|
|
29
|
-
const decodedData = await decoder.decode(
|
|
30
|
-
{
|
|
31
|
-
chain,
|
|
32
|
-
transactions: [transactionDetail],
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
timeout: timeoutTimestamp - Date.now(),
|
|
36
|
-
logger: config?.logger,
|
|
37
|
-
},
|
|
38
|
-
)
|
|
39
|
-
const transactionDecoded = decodedData.transactions[0]
|
|
40
|
-
|
|
41
|
-
const mut_currencies: CryptoCurrency[] = [chain.nativeToken.currency]
|
|
42
|
-
for (const { token } of transactionDecoded.erc20Transfers) {
|
|
43
|
-
if (token.currency.market.coingeckoId === undefined) {
|
|
44
|
-
continue
|
|
45
|
-
}
|
|
46
|
-
if (mut_currencies.some((currency) => currency.id === token.currency.id)) {
|
|
47
|
-
continue
|
|
48
|
-
}
|
|
49
|
-
mut_currencies.push(token.currency)
|
|
50
|
-
}
|
|
51
|
-
const currencies = mut_currencies
|
|
52
|
-
|
|
53
|
-
const timestampMs = Number(transactionDecoded.block.timestamp) * 1000
|
|
54
|
-
const from = timestampMs - 1000 * 60 * 60
|
|
55
|
-
const to = timestampMs + 1000 * 60 * 60
|
|
56
|
-
|
|
57
|
-
const timeoutForDataSources = timeoutTimestamp - Date.now()
|
|
58
|
-
const [app, prices] = await Promise.all([
|
|
59
|
-
// get app
|
|
60
|
-
appDataSource === undefined || transactionDecoded.to === null
|
|
61
|
-
? undefined
|
|
62
|
-
: appDataSource.getApp(chain.id, toLowerHex(transactionDecoded.to), {
|
|
63
|
-
timeout: timeoutForDataSources,
|
|
64
|
-
logger: config?.logger,
|
|
65
|
-
}),
|
|
66
|
-
// get native token prices
|
|
67
|
-
priceDataSource.getHistoricalPrices(
|
|
68
|
-
{
|
|
69
|
-
targetCurrencies: currencies,
|
|
70
|
-
vsCurrency: fiat,
|
|
71
|
-
from,
|
|
72
|
-
to,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
timeout: timeoutForDataSources,
|
|
76
|
-
logger: config?.logger,
|
|
77
|
-
},
|
|
78
|
-
),
|
|
79
|
-
])
|
|
80
|
-
|
|
81
|
-
const closestPrices = currencies.map((currency) =>
|
|
82
|
-
prices
|
|
83
|
-
.filter((price) => price.cryptoCurrencyId === currency.id)
|
|
84
|
-
.reduce(
|
|
85
|
-
(closestPrice: CryptoCurrencyPrice | undefined, price) =>
|
|
86
|
-
closestPrice === undefined ||
|
|
87
|
-
Math.abs(price.timestamp - timestampMs) <
|
|
88
|
-
Math.abs(closestPrice.timestamp - timestampMs)
|
|
89
|
-
? price
|
|
90
|
-
: closestPrice,
|
|
91
|
-
undefined,
|
|
92
|
-
),
|
|
93
|
-
)
|
|
94
|
-
const nativeTokenPrice = closestPrices.find(
|
|
95
|
-
(price) =>
|
|
96
|
-
price !== undefined &&
|
|
97
|
-
price.cryptoCurrencyId === chain.nativeToken.currency.id,
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
...transactionDecoded,
|
|
102
|
-
app,
|
|
103
|
-
nativeTokenPrice,
|
|
104
|
-
internalTransactions: transactionDecoded.internalTransactions.map(
|
|
105
|
-
(internalTransaction) => ({
|
|
106
|
-
...internalTransaction,
|
|
107
|
-
price: nativeTokenPrice,
|
|
108
|
-
}),
|
|
109
|
-
),
|
|
110
|
-
erc20Transfers: transactionDecoded.erc20Transfers.map((transfer) => ({
|
|
111
|
-
...transfer,
|
|
112
|
-
price: closestPrices.find(
|
|
113
|
-
(price) =>
|
|
114
|
-
price !== undefined &&
|
|
115
|
-
price.cryptoCurrencyId === transfer.token.currency.id,
|
|
116
|
-
),
|
|
117
|
-
})),
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/* eslint-disable unicorn/filename-case */
|
|
2
|
-
import type { Config, CryptoCurrency, CryptoCurrencyPrice } from '@0xtorch/core'
|
|
3
|
-
import { getTransactionDetail } from '../getTransactionDetail'
|
|
4
|
-
import { toLowerHex } from '../types'
|
|
5
|
-
import type {
|
|
6
|
-
GetTransactionFullCustomParametersPDA,
|
|
7
|
-
GetTransactionFullCustomReturnType,
|
|
8
|
-
} from './types'
|
|
9
|
-
|
|
10
|
-
export const getTransactionFullCustomWithPDA = async (
|
|
11
|
-
parameters: GetTransactionFullCustomParametersPDA,
|
|
12
|
-
config?: Config,
|
|
13
|
-
): Promise<
|
|
14
|
-
GetTransactionFullCustomReturnType<GetTransactionFullCustomParametersPDA>
|
|
15
|
-
> => {
|
|
16
|
-
const timeoutTimestamp =
|
|
17
|
-
Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
chain,
|
|
21
|
-
hash,
|
|
22
|
-
appDataSource,
|
|
23
|
-
priceDataSource,
|
|
24
|
-
fiat,
|
|
25
|
-
decoder,
|
|
26
|
-
analyzer,
|
|
27
|
-
} = parameters
|
|
28
|
-
|
|
29
|
-
// get transaction detail
|
|
30
|
-
const transactionDetail = await getTransactionDetail({ chain, hash }, config)
|
|
31
|
-
if (transactionDetail === undefined) {
|
|
32
|
-
return undefined
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// decode
|
|
36
|
-
const decodedData = await decoder.decode(
|
|
37
|
-
{
|
|
38
|
-
chain,
|
|
39
|
-
transactions: [transactionDetail],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
timeout: timeoutTimestamp - Date.now(),
|
|
43
|
-
logger: config?.logger,
|
|
44
|
-
},
|
|
45
|
-
)
|
|
46
|
-
const transactionDecoded = decodedData.transactions[0]
|
|
47
|
-
|
|
48
|
-
// get data from datasources
|
|
49
|
-
const mut_currencies: CryptoCurrency[] = [chain.nativeToken.currency]
|
|
50
|
-
for (const { token } of transactionDecoded.erc20Transfers) {
|
|
51
|
-
if (token.currency.market.coingeckoId === undefined) {
|
|
52
|
-
continue
|
|
53
|
-
}
|
|
54
|
-
if (mut_currencies.some((currency) => currency.id === token.currency.id)) {
|
|
55
|
-
continue
|
|
56
|
-
}
|
|
57
|
-
mut_currencies.push(token.currency)
|
|
58
|
-
}
|
|
59
|
-
const currencies = mut_currencies
|
|
60
|
-
|
|
61
|
-
const timestampMs = Number(transactionDecoded.block.timestamp) * 1000
|
|
62
|
-
const from = timestampMs - 1000 * 60 * 60
|
|
63
|
-
const to = timestampMs + 1000 * 60 * 60
|
|
64
|
-
|
|
65
|
-
const timeoutForDataSources = timeoutTimestamp - Date.now()
|
|
66
|
-
const [app, prices] = await Promise.all([
|
|
67
|
-
// get app
|
|
68
|
-
appDataSource === undefined || transactionDecoded.to === null
|
|
69
|
-
? undefined
|
|
70
|
-
: appDataSource.getApp(chain.id, toLowerHex(transactionDecoded.to), {
|
|
71
|
-
timeout: timeoutForDataSources,
|
|
72
|
-
logger: config?.logger,
|
|
73
|
-
}),
|
|
74
|
-
// get native token prices
|
|
75
|
-
priceDataSource.getHistoricalPrices(
|
|
76
|
-
{
|
|
77
|
-
targetCurrencies: currencies,
|
|
78
|
-
vsCurrency: fiat,
|
|
79
|
-
from,
|
|
80
|
-
to,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
timeout: timeoutForDataSources,
|
|
84
|
-
logger: config?.logger,
|
|
85
|
-
},
|
|
86
|
-
),
|
|
87
|
-
])
|
|
88
|
-
|
|
89
|
-
const closestPrices = currencies.map((currency) =>
|
|
90
|
-
prices
|
|
91
|
-
.filter((price) => price.cryptoCurrencyId === currency.id)
|
|
92
|
-
.reduce(
|
|
93
|
-
(closestPrice: CryptoCurrencyPrice | undefined, price) =>
|
|
94
|
-
closestPrice === undefined ||
|
|
95
|
-
Math.abs(price.timestamp - timestampMs) <
|
|
96
|
-
Math.abs(closestPrice.timestamp - timestampMs)
|
|
97
|
-
? price
|
|
98
|
-
: closestPrice,
|
|
99
|
-
undefined,
|
|
100
|
-
),
|
|
101
|
-
)
|
|
102
|
-
const nativeTokenPrice = closestPrices.find(
|
|
103
|
-
(price) =>
|
|
104
|
-
price !== undefined &&
|
|
105
|
-
price.cryptoCurrencyId === chain.nativeToken.currency.id,
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
const transactionForAnalyzer = {
|
|
109
|
-
...transactionDecoded,
|
|
110
|
-
app,
|
|
111
|
-
nativeTokenPrice,
|
|
112
|
-
internalTransactions: transactionDecoded.internalTransactions.map(
|
|
113
|
-
(internalTransaction) => ({
|
|
114
|
-
...internalTransaction,
|
|
115
|
-
price: nativeTokenPrice,
|
|
116
|
-
}),
|
|
117
|
-
),
|
|
118
|
-
erc20Transfers: transactionDecoded.erc20Transfers.map((transfer) => ({
|
|
119
|
-
...transfer,
|
|
120
|
-
price: closestPrices.find(
|
|
121
|
-
(price) =>
|
|
122
|
-
price !== undefined &&
|
|
123
|
-
price.cryptoCurrencyId === transfer.token.currency.id,
|
|
124
|
-
),
|
|
125
|
-
})),
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// analyze
|
|
129
|
-
const { actions, accountActions } = await analyzer.analyze(
|
|
130
|
-
{
|
|
131
|
-
chain,
|
|
132
|
-
transaction: transactionForAnalyzer,
|
|
133
|
-
accountAddresses: [],
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
timeout: timeoutTimestamp - Date.now(),
|
|
137
|
-
logger: config?.logger,
|
|
138
|
-
},
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
...transactionForAnalyzer,
|
|
143
|
-
accountAddresses: [],
|
|
144
|
-
actions,
|
|
145
|
-
accountActions,
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Config } from '@0xtorch/core'
|
|
2
|
-
import { getTransactionDetail } from '../getTransactionDetail'
|
|
3
|
-
import { toLowerHex } from '../types'
|
|
4
|
-
import type {
|
|
5
|
-
GetTransactionFullCustomParametersAllUndefined,
|
|
6
|
-
GetTransactionFullCustomReturnType,
|
|
7
|
-
} from './types'
|
|
8
|
-
|
|
9
|
-
export const getTransactionFullCustomWithAllUndefined = async (
|
|
10
|
-
parameters: GetTransactionFullCustomParametersAllUndefined,
|
|
11
|
-
config?: Config,
|
|
12
|
-
): Promise<
|
|
13
|
-
GetTransactionFullCustomReturnType<GetTransactionFullCustomParametersAllUndefined>
|
|
14
|
-
> => {
|
|
15
|
-
const timeoutTimestamp =
|
|
16
|
-
Date.now() + (config?.timeout === undefined ? 60_000 : config.timeout)
|
|
17
|
-
|
|
18
|
-
const { chain, hash, appDataSource } = parameters
|
|
19
|
-
const transactionDetail = await getTransactionDetail({ chain, hash }, config)
|
|
20
|
-
if (transactionDetail === undefined) {
|
|
21
|
-
return undefined
|
|
22
|
-
}
|
|
23
|
-
const app =
|
|
24
|
-
appDataSource === undefined || transactionDetail.to === null
|
|
25
|
-
? undefined
|
|
26
|
-
: await appDataSource.getApp(chain.id, toLowerHex(transactionDetail.to), {
|
|
27
|
-
timeout: timeoutTimestamp - Date.now(),
|
|
28
|
-
logger: config?.logger,
|
|
29
|
-
})
|
|
30
|
-
if (transactionDetail === undefined) {
|
|
31
|
-
return undefined
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...transactionDetail,
|
|
36
|
-
app,
|
|
37
|
-
nativeTokenPrice: undefined,
|
|
38
|
-
}
|
|
39
|
-
}
|