@0xtorch/evm 0.0.95 → 0.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_cjs/chain/definitions/arbitrumOne.js +2 -1
- package/_cjs/chain/definitions/arbitrumOne.js.map +1 -1
- package/_cjs/chain/definitions/astar.js +3 -1
- package/_cjs/chain/definitions/astar.js.map +1 -1
- package/_cjs/chain/definitions/astarZkEvm.js +3 -1
- package/_cjs/chain/definitions/astarZkEvm.js.map +1 -1
- package/_cjs/chain/definitions/avalancheC.js +2 -1
- package/_cjs/chain/definitions/avalancheC.js.map +1 -1
- package/_cjs/chain/definitions/base.js +2 -1
- package/_cjs/chain/definitions/base.js.map +1 -1
- package/_cjs/chain/definitions/blast.js +2 -1
- package/_cjs/chain/definitions/blast.js.map +1 -1
- package/_cjs/chain/definitions/bsc.js +2 -1
- package/_cjs/chain/definitions/bsc.js.map +1 -1
- package/_cjs/chain/definitions/ethereum.js +2 -1
- package/_cjs/chain/definitions/ethereum.js.map +1 -1
- package/_cjs/chain/definitions/fantom.js +2 -1
- package/_cjs/chain/definitions/fantom.js.map +1 -1
- package/_cjs/chain/definitions/linea.js +2 -1
- package/_cjs/chain/definitions/linea.js.map +1 -1
- package/_cjs/chain/definitions/mantaPacific.js +3 -1
- package/_cjs/chain/definitions/mantaPacific.js.map +1 -1
- package/_cjs/chain/definitions/mantle.js +2 -1
- package/_cjs/chain/definitions/mantle.js.map +1 -1
- package/_cjs/chain/definitions/metis.js +3 -1
- package/_cjs/chain/definitions/metis.js.map +1 -1
- package/_cjs/chain/definitions/moonbeam.js +2 -1
- package/_cjs/chain/definitions/moonbeam.js.map +1 -1
- package/_cjs/chain/definitions/moonriver.js +2 -1
- package/_cjs/chain/definitions/moonriver.js.map +1 -1
- package/_cjs/chain/definitions/oasys.js +3 -1
- package/_cjs/chain/definitions/oasys.js.map +1 -1
- package/_cjs/chain/definitions/optimism.js +2 -1
- package/_cjs/chain/definitions/optimism.js.map +1 -1
- package/_cjs/chain/definitions/polygonPos.js +2 -1
- package/_cjs/chain/definitions/polygonPos.js.map +1 -1
- package/_cjs/chain/definitions/scroll.js +2 -1
- package/_cjs/chain/definitions/scroll.js.map +1 -1
- package/_cjs/chain/definitions/zkFair.js +3 -1
- package/_cjs/chain/definitions/zkFair.js.map +1 -1
- package/_cjs/chain/definitions/zkSyncEra.js +2 -1
- package/_cjs/chain/definitions/zkSyncEra.js.map +1 -1
- package/_cjs/chain/definitions/zora.js +3 -1
- package/_cjs/chain/definitions/zora.js.map +1 -1
- package/_cjs/explorer/blockscout/client.js +9 -2
- package/_cjs/explorer/blockscout/client.js.map +1 -1
- package/_cjs/explorer/blockscout/create.js +2 -2
- package/_cjs/explorer/blockscout/create.js.map +1 -1
- package/_cjs/explorer/etherscan/create.js +11 -9
- package/_cjs/explorer/etherscan/create.js.map +1 -1
- package/_cjs/logic/analyzeTransaction/decodeTransaction/index.js +9 -1
- package/_cjs/logic/analyzeTransaction/decodeTransaction/index.js.map +1 -1
- package/_esm/chain/definitions/arbitrumOne.js +2 -1
- package/_esm/chain/definitions/arbitrumOne.js.map +1 -1
- package/_esm/chain/definitions/astar.js +3 -1
- package/_esm/chain/definitions/astar.js.map +1 -1
- package/_esm/chain/definitions/astarZkEvm.js +3 -1
- package/_esm/chain/definitions/astarZkEvm.js.map +1 -1
- package/_esm/chain/definitions/avalancheC.js +2 -1
- package/_esm/chain/definitions/avalancheC.js.map +1 -1
- package/_esm/chain/definitions/base.js +2 -1
- package/_esm/chain/definitions/base.js.map +1 -1
- package/_esm/chain/definitions/blast.js +2 -1
- package/_esm/chain/definitions/blast.js.map +1 -1
- package/_esm/chain/definitions/bsc.js +2 -1
- package/_esm/chain/definitions/bsc.js.map +1 -1
- package/_esm/chain/definitions/ethereum.js +2 -1
- package/_esm/chain/definitions/ethereum.js.map +1 -1
- package/_esm/chain/definitions/fantom.js +2 -1
- package/_esm/chain/definitions/fantom.js.map +1 -1
- package/_esm/chain/definitions/linea.js +2 -1
- package/_esm/chain/definitions/linea.js.map +1 -1
- package/_esm/chain/definitions/mantaPacific.js +3 -1
- package/_esm/chain/definitions/mantaPacific.js.map +1 -1
- package/_esm/chain/definitions/mantle.js +2 -1
- package/_esm/chain/definitions/mantle.js.map +1 -1
- package/_esm/chain/definitions/metis.js +3 -1
- package/_esm/chain/definitions/metis.js.map +1 -1
- package/_esm/chain/definitions/moonbeam.js +2 -1
- package/_esm/chain/definitions/moonbeam.js.map +1 -1
- package/_esm/chain/definitions/moonriver.js +2 -1
- package/_esm/chain/definitions/moonriver.js.map +1 -1
- package/_esm/chain/definitions/oasys.js +3 -1
- package/_esm/chain/definitions/oasys.js.map +1 -1
- package/_esm/chain/definitions/optimism.js +2 -1
- package/_esm/chain/definitions/optimism.js.map +1 -1
- package/_esm/chain/definitions/polygonPos.js +2 -1
- package/_esm/chain/definitions/polygonPos.js.map +1 -1
- package/_esm/chain/definitions/scroll.js +2 -1
- package/_esm/chain/definitions/scroll.js.map +1 -1
- package/_esm/chain/definitions/zkFair.js +3 -1
- package/_esm/chain/definitions/zkFair.js.map +1 -1
- package/_esm/chain/definitions/zkSyncEra.js +2 -1
- package/_esm/chain/definitions/zkSyncEra.js.map +1 -1
- package/_esm/chain/definitions/zora.js +3 -1
- package/_esm/chain/definitions/zora.js.map +1 -1
- package/_esm/explorer/blockscout/client.js +9 -2
- package/_esm/explorer/blockscout/client.js.map +1 -1
- package/_esm/explorer/blockscout/create.js +2 -2
- package/_esm/explorer/blockscout/create.js.map +1 -1
- package/_esm/explorer/etherscan/create.js +11 -9
- package/_esm/explorer/etherscan/create.js.map +1 -1
- package/_esm/logic/analyzeTransaction/decodeTransaction/index.js +11 -1
- package/_esm/logic/analyzeTransaction/decodeTransaction/index.js.map +1 -1
- package/_types/chain/definitions/arbitrumOne.d.ts +2 -1
- package/_types/chain/definitions/arbitrumOne.d.ts.map +1 -1
- package/_types/chain/definitions/astar.d.ts +4 -1
- package/_types/chain/definitions/astar.d.ts.map +1 -1
- package/_types/chain/definitions/astarZkEvm.d.ts +4 -1
- package/_types/chain/definitions/astarZkEvm.d.ts.map +1 -1
- package/_types/chain/definitions/avalancheC.d.ts +2 -1
- package/_types/chain/definitions/avalancheC.d.ts.map +1 -1
- package/_types/chain/definitions/base.d.ts +2 -1
- package/_types/chain/definitions/base.d.ts.map +1 -1
- package/_types/chain/definitions/blast.d.ts +2 -1
- package/_types/chain/definitions/blast.d.ts.map +1 -1
- package/_types/chain/definitions/bsc.d.ts +2 -1
- package/_types/chain/definitions/bsc.d.ts.map +1 -1
- package/_types/chain/definitions/ethereum.d.ts +2 -1
- package/_types/chain/definitions/ethereum.d.ts.map +1 -1
- package/_types/chain/definitions/fantom.d.ts +2 -1
- package/_types/chain/definitions/fantom.d.ts.map +1 -1
- package/_types/chain/definitions/linea.d.ts +2 -1
- package/_types/chain/definitions/linea.d.ts.map +1 -1
- package/_types/chain/definitions/mantaPacific.d.ts +4 -1
- package/_types/chain/definitions/mantaPacific.d.ts.map +1 -1
- package/_types/chain/definitions/mantle.d.ts +2 -1
- package/_types/chain/definitions/mantle.d.ts.map +1 -1
- package/_types/chain/definitions/metis.d.ts +4 -1
- package/_types/chain/definitions/metis.d.ts.map +1 -1
- package/_types/chain/definitions/moonbeam.d.ts +2 -1
- package/_types/chain/definitions/moonbeam.d.ts.map +1 -1
- package/_types/chain/definitions/moonriver.d.ts +2 -1
- package/_types/chain/definitions/moonriver.d.ts.map +1 -1
- package/_types/chain/definitions/oasys.d.ts +4 -1
- package/_types/chain/definitions/oasys.d.ts.map +1 -1
- package/_types/chain/definitions/optimism.d.ts +2 -1
- package/_types/chain/definitions/optimism.d.ts.map +1 -1
- package/_types/chain/definitions/polygonPos.d.ts +2 -1
- package/_types/chain/definitions/polygonPos.d.ts.map +1 -1
- package/_types/chain/definitions/scroll.d.ts +2 -1
- package/_types/chain/definitions/scroll.d.ts.map +1 -1
- package/_types/chain/definitions/zkFair.d.ts +4 -1
- package/_types/chain/definitions/zkFair.d.ts.map +1 -1
- package/_types/chain/definitions/zkSyncEra.d.ts +2 -1
- package/_types/chain/definitions/zkSyncEra.d.ts.map +1 -1
- package/_types/chain/definitions/zora.d.ts +4 -1
- package/_types/chain/definitions/zora.d.ts.map +1 -1
- package/_types/explorer/blockscout/client.d.ts +7 -1
- package/_types/explorer/blockscout/client.d.ts.map +1 -1
- package/_types/explorer/blockscout/create.d.ts +3 -1
- package/_types/explorer/blockscout/create.d.ts.map +1 -1
- package/_types/explorer/etherscan/create.d.ts +2 -1
- package/_types/explorer/etherscan/create.d.ts.map +1 -1
- package/_types/logic/analyzeTransaction/decodeTransaction/index.d.ts.map +1 -1
- package/chain/definitions/arbitrumOne.ts +3 -0
- package/chain/definitions/astar.ts +9 -1
- package/chain/definitions/astarZkEvm.ts +9 -1
- package/chain/definitions/avalancheC.ts +3 -0
- package/chain/definitions/base.ts +3 -0
- package/chain/definitions/blast.ts +3 -0
- package/chain/definitions/bsc.ts +3 -0
- package/chain/definitions/ethereum.ts +3 -0
- package/chain/definitions/fantom.ts +3 -0
- package/chain/definitions/linea.ts +3 -0
- package/chain/definitions/mantaPacific.ts +9 -1
- package/chain/definitions/mantle.ts +3 -0
- package/chain/definitions/metis.ts +9 -1
- package/chain/definitions/moonbeam.ts +3 -0
- package/chain/definitions/moonriver.ts +3 -0
- package/chain/definitions/oasys.ts +9 -1
- package/chain/definitions/optimism.ts +3 -0
- package/chain/definitions/polygonPos.ts +3 -0
- package/chain/definitions/scroll.ts +3 -0
- package/chain/definitions/zkFair.ts +9 -1
- package/chain/definitions/zkSyncEra.ts +3 -0
- package/chain/definitions/zora.ts +9 -1
- package/explorer/blockscout/client.ts +24 -7
- package/explorer/blockscout/create.ts +5 -1
- package/explorer/etherscan/create.ts +12 -8
- package/logic/analyzeTransaction/decodeTransaction/index.ts +18 -2
- package/package.json +1 -1
|
@@ -13,9 +13,17 @@ export type BlockscoutClient = {
|
|
|
13
13
|
}) => Promise<Output>
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
apiBaseUrl: string
|
|
18
|
-
|
|
16
|
+
type CreateBlockscoutClientParameters = {
|
|
17
|
+
apiBaseUrl: string
|
|
18
|
+
proxyUrl?: string
|
|
19
|
+
headers?: Record<string, string>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const createBlockscoutClient = ({
|
|
23
|
+
apiBaseUrl,
|
|
24
|
+
proxyUrl,
|
|
25
|
+
headers,
|
|
26
|
+
}: CreateBlockscoutClientParameters): BlockscoutClient => {
|
|
19
27
|
const rateLimitPerSecond = 5
|
|
20
28
|
const requestTimestamps: number[] = []
|
|
21
29
|
|
|
@@ -73,9 +81,19 @@ export const createBlockscoutClient = (
|
|
|
73
81
|
url.searchParams.append(key, value)
|
|
74
82
|
}
|
|
75
83
|
console.debug(`[GET] ${url.toString()}`)
|
|
76
|
-
const { status, message, result } = await rest(
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
const { status, message, result } = await rest(
|
|
85
|
+
proxyUrl === undefined
|
|
86
|
+
? url.toString()
|
|
87
|
+
: `${proxyUrl}${encodeURIComponent(url.toString())}`,
|
|
88
|
+
{
|
|
89
|
+
schema: responseSchema,
|
|
90
|
+
fetchOptions: {
|
|
91
|
+
headers: {
|
|
92
|
+
...headers,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
)
|
|
79
97
|
if (status !== '1') {
|
|
80
98
|
throw typeof result === 'string'
|
|
81
99
|
? new Error(result)
|
|
@@ -98,7 +116,6 @@ export const createBlockscoutClient = (
|
|
|
98
116
|
await new Promise((resolve) => setTimeout(resolve, 5000))
|
|
99
117
|
return await get({ path, query, resultSchema }, repeat + 1)
|
|
100
118
|
}
|
|
101
|
-
|
|
102
119
|
throw error
|
|
103
120
|
}
|
|
104
121
|
}
|
|
@@ -17,14 +17,18 @@ type CreateBlockscoutParameters = {
|
|
|
17
17
|
name: string
|
|
18
18
|
baseUrl: string
|
|
19
19
|
apiBaseUrl: string
|
|
20
|
+
proxyUrl?: string
|
|
21
|
+
headers?: Record<string, string>
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export const createBlockscout = ({
|
|
23
25
|
name,
|
|
24
26
|
baseUrl,
|
|
25
27
|
apiBaseUrl,
|
|
28
|
+
proxyUrl,
|
|
29
|
+
headers,
|
|
26
30
|
}: CreateBlockscoutParameters): Explorer => {
|
|
27
|
-
const client = createBlockscoutClient(apiBaseUrl)
|
|
31
|
+
const client = createBlockscoutClient({ apiBaseUrl, proxyUrl, headers })
|
|
28
32
|
|
|
29
33
|
return {
|
|
30
34
|
name,
|
|
@@ -22,6 +22,7 @@ type CreateEtherscanParameters = {
|
|
|
22
22
|
apiKey?: string
|
|
23
23
|
proxyUrl?: string
|
|
24
24
|
headers?: Record<string, string>
|
|
25
|
+
pageSize?: number
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export const createEtherscan = ({
|
|
@@ -31,6 +32,7 @@ export const createEtherscan = ({
|
|
|
31
32
|
apiKey,
|
|
32
33
|
proxyUrl,
|
|
33
34
|
headers,
|
|
35
|
+
pageSize = 10_000,
|
|
34
36
|
}: CreateEtherscanParameters): Explorer => {
|
|
35
37
|
const client = createEtherscanClient({
|
|
36
38
|
apiBaseUrl,
|
|
@@ -49,13 +51,13 @@ export const createEtherscan = ({
|
|
|
49
51
|
>()
|
|
50
52
|
let startblock = fromBlock
|
|
51
53
|
const endblock = toBlock
|
|
52
|
-
const maxPageSize = 10_000
|
|
53
54
|
while (true) {
|
|
54
55
|
const result = await getListOfInternalTransactionsByAddress({
|
|
55
56
|
client,
|
|
56
57
|
address,
|
|
57
58
|
startblock,
|
|
58
59
|
endblock,
|
|
60
|
+
offset: pageSize,
|
|
59
61
|
})
|
|
60
62
|
for (const transaction of result) {
|
|
61
63
|
const id = createInternalTransactionId(transaction)
|
|
@@ -63,7 +65,7 @@ export const createEtherscan = ({
|
|
|
63
65
|
internalTransactions.set(id, transaction)
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
if (result.length <
|
|
68
|
+
if (result.length < pageSize) {
|
|
67
69
|
break
|
|
68
70
|
}
|
|
69
71
|
const maxBlockNumber = Math.max(...result.map((x) => x.blockNumber))
|
|
@@ -75,20 +77,20 @@ export const createEtherscan = ({
|
|
|
75
77
|
const indexes = new Map<LowerHex, TransactionIndex>()
|
|
76
78
|
let startblock = fromBlock
|
|
77
79
|
const endblock = toBlock
|
|
78
|
-
const maxPageSize = 10_000
|
|
79
80
|
while (true) {
|
|
80
81
|
const result = await getListOfNormalTransactionsByAddress({
|
|
81
82
|
client,
|
|
82
83
|
address,
|
|
83
84
|
startblock,
|
|
84
85
|
endblock,
|
|
86
|
+
offset: pageSize,
|
|
85
87
|
})
|
|
86
88
|
for (const index of result) {
|
|
87
89
|
if (!indexes.has(index.hash)) {
|
|
88
90
|
indexes.set(index.hash, index)
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
if (result.length <
|
|
93
|
+
if (result.length < pageSize) {
|
|
92
94
|
break
|
|
93
95
|
}
|
|
94
96
|
const maxBlockNumber = Math.max(...result.map((x) => x.blockNumber))
|
|
@@ -98,7 +100,6 @@ export const createEtherscan = ({
|
|
|
98
100
|
},
|
|
99
101
|
getAddressTokenTransferIndexes: async ({ address, fromBlock, toBlock }) => {
|
|
100
102
|
const indexes = new Map<LowerHex, TransactionIndex>()
|
|
101
|
-
const maxPageSize = 10_000
|
|
102
103
|
const endblock = toBlock
|
|
103
104
|
|
|
104
105
|
// ERC20
|
|
@@ -109,13 +110,14 @@ export const createEtherscan = ({
|
|
|
109
110
|
address,
|
|
110
111
|
startblock,
|
|
111
112
|
endblock,
|
|
113
|
+
offset: pageSize,
|
|
112
114
|
})
|
|
113
115
|
for (const index of result) {
|
|
114
116
|
if (!indexes.has(index.hash)) {
|
|
115
117
|
indexes.set(index.hash, index)
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
if (result.length <
|
|
120
|
+
if (result.length < pageSize) {
|
|
119
121
|
break
|
|
120
122
|
}
|
|
121
123
|
const maxBlockNumber = Math.max(...result.map((x) => x.blockNumber))
|
|
@@ -130,13 +132,14 @@ export const createEtherscan = ({
|
|
|
130
132
|
address,
|
|
131
133
|
startblock,
|
|
132
134
|
endblock,
|
|
135
|
+
offset: pageSize,
|
|
133
136
|
})
|
|
134
137
|
for (const index of result) {
|
|
135
138
|
if (!indexes.has(index.hash)) {
|
|
136
139
|
indexes.set(index.hash, index)
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
if (result.length <
|
|
142
|
+
if (result.length < pageSize) {
|
|
140
143
|
break
|
|
141
144
|
}
|
|
142
145
|
const maxBlockNumber = Math.max(...result.map((x) => x.blockNumber))
|
|
@@ -151,13 +154,14 @@ export const createEtherscan = ({
|
|
|
151
154
|
address,
|
|
152
155
|
startblock,
|
|
153
156
|
endblock,
|
|
157
|
+
offset: pageSize,
|
|
154
158
|
})
|
|
155
159
|
for (const index of result) {
|
|
156
160
|
if (!indexes.has(index.hash)) {
|
|
157
161
|
indexes.set(index.hash, index)
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
|
-
if (result.length <
|
|
164
|
+
if (result.length < pageSize) {
|
|
161
165
|
break
|
|
162
166
|
}
|
|
163
167
|
const maxBlockNumber = Math.max(...result.map((x) => x.blockNumber))
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Nft } from '@0xtorch/core'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
Erc20Token,
|
|
4
|
+
Erc20TokenTransfer,
|
|
5
|
+
InternalTransaction,
|
|
6
|
+
LowerHex,
|
|
7
|
+
} from '../../../types'
|
|
3
8
|
import type { EvmAddress } from '../../../types/address'
|
|
4
9
|
import type { TransactionDecoded } from '../../../types/transactionDecoded'
|
|
5
10
|
import type { TransactionDetail } from '../../../types/transactionDetail'
|
|
@@ -9,6 +14,8 @@ import { parseToErc20TokenTransfer } from './parseToErc20TokenTransfer'
|
|
|
9
14
|
import { parseToErc721TokenTransfer } from './parseToErc721TokenTransfer'
|
|
10
15
|
import { parseToErc1155TokenTransfer } from './parseToErc1155TokenTransfer'
|
|
11
16
|
|
|
17
|
+
const zkSyncEraChainId = 324
|
|
18
|
+
|
|
12
19
|
type DecodeTransactionParameters = {
|
|
13
20
|
transaction: TransactionDetail
|
|
14
21
|
addresses: readonly EvmAddress[]
|
|
@@ -95,7 +102,6 @@ export const decodeTransaction = ({
|
|
|
95
102
|
|
|
96
103
|
// chain 毎固有の条件に応じて ERC20 transfer をフィルタリング
|
|
97
104
|
const filteredErc20Transfers: Erc20TokenTransfer[] = []
|
|
98
|
-
const zkSyncEraChainId = 324
|
|
99
105
|
// zkSync でのトランザクションの場合、fee 関連の transfer を除外・native transfer と同様の transfer を除外
|
|
100
106
|
if (transaction.chainId === zkSyncEraChainId) {
|
|
101
107
|
const feeAddress = '0x0000000000000000000000000000000000008001'
|
|
@@ -119,9 +125,19 @@ export const decodeTransaction = ({
|
|
|
119
125
|
filteredErc20Transfers.push(...erc20Transfers)
|
|
120
126
|
}
|
|
121
127
|
|
|
128
|
+
// chain 毎固有の条件に応じて internal transaction をフィルタリング
|
|
129
|
+
let filteredInternalTransactions: InternalTransaction[]
|
|
130
|
+
if (transaction.chainId === zkSyncEraChainId) {
|
|
131
|
+
// zkSync の場合 internal transaction は除外する
|
|
132
|
+
filteredInternalTransactions = []
|
|
133
|
+
} else {
|
|
134
|
+
filteredInternalTransactions = transaction.internalTransactions
|
|
135
|
+
}
|
|
136
|
+
|
|
122
137
|
// データを統合して TransactionDecoded に変形
|
|
123
138
|
return {
|
|
124
139
|
...transaction,
|
|
140
|
+
internalTransactions: filteredInternalTransactions,
|
|
125
141
|
erc20Transfers: filteredErc20Transfers,
|
|
126
142
|
erc721Transfers,
|
|
127
143
|
erc1155Transfers,
|