@0xtorch/evm 0.0.7 → 0.0.9

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 (57) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/clients/externals/viem/middleware.js +5 -0
  3. package/_cjs/clients/externals/viem/middleware.js.map +1 -1
  4. package/_cjs/decoder/tests.js +9 -0
  5. package/_cjs/decoder/tests.js.map +1 -1
  6. package/_cjs/explorers/definitions/blockscout.js +97 -0
  7. package/_cjs/explorers/definitions/blockscout.js.map +1 -1
  8. package/_cjs/explorers/definitions/etherscan.js +152 -0
  9. package/_cjs/explorers/definitions/etherscan.js.map +1 -1
  10. package/_cjs/explorers/definitions/roninExplorer.js +70 -0
  11. package/_cjs/explorers/definitions/roninExplorer.js.map +1 -1
  12. package/_cjs/explorers/definitions/routescan.js +12 -0
  13. package/_cjs/explorers/definitions/routescan.js.map +1 -1
  14. package/_esm/clients/externals/viem/middleware.js +5 -0
  15. package/_esm/clients/externals/viem/middleware.js.map +1 -1
  16. package/_esm/decoder/tests.js +9 -0
  17. package/_esm/decoder/tests.js.map +1 -1
  18. package/_esm/explorers/definitions/blockscout.js +99 -1
  19. package/_esm/explorers/definitions/blockscout.js.map +1 -1
  20. package/_esm/explorers/definitions/etherscan.js +155 -0
  21. package/_esm/explorers/definitions/etherscan.js.map +1 -1
  22. package/_esm/explorers/definitions/roninExplorer.js +70 -0
  23. package/_esm/explorers/definitions/roninExplorer.js.map +1 -1
  24. package/_esm/explorers/definitions/routescan.js +15 -0
  25. package/_esm/explorers/definitions/routescan.js.map +1 -1
  26. package/_types/clients/externals/viem/middleware.d.ts.map +1 -1
  27. package/_types/decoder/tests.d.ts.map +1 -1
  28. package/_types/explorers/definitions/blockscout.d.ts +28 -1
  29. package/_types/explorers/definitions/blockscout.d.ts.map +1 -1
  30. package/_types/explorers/definitions/etherscan.d.ts +28 -1
  31. package/_types/explorers/definitions/etherscan.d.ts.map +1 -1
  32. package/_types/explorers/definitions/roninExplorer.d.ts +26 -0
  33. package/_types/explorers/definitions/roninExplorer.d.ts.map +1 -1
  34. package/_types/explorers/definitions/routescan.d.ts +3 -0
  35. package/_types/explorers/definitions/routescan.d.ts.map +1 -1
  36. package/_types/explorers/types.d.ts +30 -0
  37. package/_types/explorers/types.d.ts.map +1 -1
  38. package/clients/externals/viem/middleware.ts +6 -0
  39. package/decoder/tests.ts +9 -0
  40. package/explorers/definitions/blockscout.ts +141 -1
  41. package/explorers/definitions/etherscan.ts +211 -0
  42. package/explorers/definitions/roninExplorer.ts +99 -0
  43. package/explorers/definitions/routescan.ts +15 -0
  44. package/explorers/types.ts +37 -0
  45. package/package.json +2 -2
  46. package/_cjs/.DS_Store +0 -0
  47. package/_cjs/analyzer/.DS_Store +0 -0
  48. package/_cjs/chains/.DS_Store +0 -0
  49. package/_cjs/clients/.DS_Store +0 -0
  50. package/_cjs/explorers/.DS_Store +0 -0
  51. package/_esm/.DS_Store +0 -0
  52. package/_esm/clients/.DS_Store +0 -0
  53. package/_types/.DS_Store +0 -0
  54. package/_types/analyzer/.DS_Store +0 -0
  55. package/_types/chains/.DS_Store +0 -0
  56. package/_types/clients/.DS_Store +0 -0
  57. package/_types/explorers/.DS_Store +0 -0
@@ -1,4 +1,5 @@
1
1
  import type { Hex } from 'viem'
2
+ import type { LowerHex } from '../../types'
2
3
  import {
3
4
  getInternalTransactionByHash,
4
5
  getNormalTransactionsByAddress,
@@ -147,4 +148,102 @@ export const createRoninExplorer = <
147
148
  price: undefined,
148
149
  }))
149
150
  },
151
+ getAddressTransactionHashesWithTimestamp: async ({
152
+ address,
153
+ startBlock,
154
+ endBlock,
155
+ logger,
156
+ }) => {
157
+ const mut_hashesWithTimestamp: {
158
+ readonly hash: LowerHex
159
+ readonly timestamp: number
160
+ }[] = []
161
+ let mut_from = 0
162
+ while (mut_from >= 0) {
163
+ const { total, transactions } = await getNormalTransactionsByAddress({
164
+ apiEndpoint: explorerApiUrl,
165
+ address,
166
+ size: 100,
167
+ from: mut_from,
168
+ logger,
169
+ })
170
+ for (const transaction of transactions) {
171
+ if (
172
+ startBlock !== undefined &&
173
+ BigInt(transaction.block_number) < startBlock
174
+ ) {
175
+ return mut_hashesWithTimestamp
176
+ }
177
+ if (
178
+ (endBlock === undefined ||
179
+ BigInt(transaction.block_number) <= endBlock) &&
180
+ mut_hashesWithTimestamp.every(
181
+ ({ hash }) => hash !== transaction.hash,
182
+ )
183
+ ) {
184
+ mut_hashesWithTimestamp.push({
185
+ hash: transaction.hash,
186
+ timestamp: transaction.timestamp,
187
+ })
188
+ }
189
+ }
190
+ mut_from += transactions.length
191
+ if (mut_from + transactions.length >= total) {
192
+ break
193
+ }
194
+ }
195
+ return mut_hashesWithTimestamp
196
+ },
197
+ getAddressInternalTransactionsWithTimestamp: ({ logger }) => {
198
+ if (logger !== undefined) {
199
+ logger.info('getAddressInternalTransactions is not implemented')
200
+ }
201
+ return Promise.resolve([])
202
+ },
203
+ getAddressTokenTransferHashesWithTimestamp: async ({
204
+ address,
205
+ startBlock,
206
+ endBlock,
207
+ logger,
208
+ }) => {
209
+ const mut_hashesWithTimestamp: {
210
+ readonly hash: LowerHex
211
+ readonly timestamp: number
212
+ }[] = []
213
+ let mut_from = 0
214
+ while (mut_from >= 0) {
215
+ const { total, transfers } = await getTokenTransfersByAddress({
216
+ apiEndpoint: explorerApiUrl,
217
+ address,
218
+ size: 100,
219
+ from: mut_from,
220
+ logger,
221
+ })
222
+ for (const transfer of transfers) {
223
+ if (
224
+ startBlock !== undefined &&
225
+ BigInt(transfer.block_number) < startBlock
226
+ ) {
227
+ return mut_hashesWithTimestamp
228
+ }
229
+ if (
230
+ (endBlock === undefined ||
231
+ BigInt(transfer.block_number) <= endBlock) &&
232
+ mut_hashesWithTimestamp.every(
233
+ ({ hash }) => hash !== transfer.tx_hash,
234
+ )
235
+ ) {
236
+ mut_hashesWithTimestamp.push({
237
+ hash: transfer.tx_hash,
238
+ timestamp: transfer.timestamp,
239
+ })
240
+ }
241
+ }
242
+ mut_from += transfers.length
243
+ if (mut_from + transfers.length >= total) {
244
+ break
245
+ }
246
+ }
247
+ return mut_hashesWithTimestamp
248
+ },
150
249
  })
@@ -54,4 +54,19 @@ export const createRoutescan = <
54
54
  await new Promise((resolve) => setTimeout(resolve))
55
55
  throw new Error('not implemented')
56
56
  },
57
+ getAddressTransactionHashesWithTimestamp: async () => {
58
+ // TODO implement
59
+ await new Promise((resolve) => setTimeout(resolve))
60
+ throw new Error('not implemented')
61
+ },
62
+ getAddressInternalTransactionsWithTimestamp: async () => {
63
+ // TODO implement
64
+ await new Promise((resolve) => setTimeout(resolve))
65
+ throw new Error('not implemented')
66
+ },
67
+ getAddressTokenTransferHashesWithTimestamp: async () => {
68
+ // TODO implement
69
+ await new Promise((resolve) => setTimeout(resolve))
70
+ throw new Error('not implemented')
71
+ },
57
72
  })
@@ -6,8 +6,11 @@ export type Explorer = {
6
6
  readonly url: string
7
7
  readonly apiUrl: string
8
8
  readonly getAddressTransactionHashes: FunctionGetAddressTransactionHashes
9
+ readonly getAddressTransactionHashesWithTimestamp: FunctionGetAddressTransactionHashesWithTimestamp
9
10
  readonly getAddressInternalTransactions: FunctionGetAddressInternalTransactions
11
+ readonly getAddressInternalTransactionsWithTimestamp: FunctionGetAddressInternalTransactionsWithTimestamp
10
12
  readonly getAddressTokenTransferHashes: FunctionGetAddressTokenTransferHashes
13
+ readonly getAddressTokenTransferHashesWithTimestamp: FunctionGetAddressTokenTransferHashesWithTimestamp
11
14
  readonly getBlockNumberOfTimestamp: (
12
15
  timestamp: number,
13
16
  logger?: Logger,
@@ -23,6 +26,18 @@ type FunctionGetAddressTransactionHashes = (parameters: {
23
26
  readonly logger?: Logger
24
27
  }) => Promise<readonly Hex[]>
25
28
 
29
+ type FunctionGetAddressTransactionHashesWithTimestamp = (parameters: {
30
+ readonly address: Hex
31
+ readonly startBlock?: bigint
32
+ readonly endBlock?: bigint
33
+ readonly logger?: Logger
34
+ }) => Promise<
35
+ readonly {
36
+ readonly hash: Hex
37
+ readonly timestamp: number
38
+ }[]
39
+ >
40
+
26
41
  type FunctionGetAddressInternalTransactions = (parameters: {
27
42
  readonly address: Hex
28
43
  readonly startBlock?: bigint
@@ -31,6 +46,16 @@ type FunctionGetAddressInternalTransactions = (parameters: {
31
46
  readonly logger?: Logger
32
47
  }) => Promise<readonly InternalTransaction<undefined>[]>
33
48
 
49
+ type FunctionGetAddressInternalTransactionsWithTimestamp = (parameters: {
50
+ readonly address: Hex
51
+ readonly startBlock?: bigint
52
+ readonly endBlock?: bigint
53
+ readonly nativeCurrency: CryptoCurrency
54
+ readonly logger?: Logger
55
+ }) => Promise<
56
+ readonly (InternalTransaction<undefined> & { readonly timestamp: number })[]
57
+ >
58
+
34
59
  type FunctionGetAddressTokenTransferHashes = (parameters: {
35
60
  readonly address: Hex
36
61
  readonly startBlock?: bigint
@@ -38,6 +63,18 @@ type FunctionGetAddressTokenTransferHashes = (parameters: {
38
63
  readonly logger?: Logger
39
64
  }) => Promise<readonly Hex[]>
40
65
 
66
+ type FunctionGetAddressTokenTransferHashesWithTimestamp = (parameters: {
67
+ readonly address: Hex
68
+ readonly startBlock?: bigint
69
+ readonly endBlock?: bigint
70
+ readonly logger?: Logger
71
+ }) => Promise<
72
+ readonly {
73
+ readonly hash: Hex
74
+ readonly timestamp: number
75
+ }[]
76
+ >
77
+
41
78
  type FunctionGetContract = (
42
79
  address: Hex,
43
80
  logger?: Logger,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/evm",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Cryptorch EVM extension",
5
5
  "keywords": [
6
6
  "cryptorch",
@@ -37,7 +37,7 @@
37
37
  "!tsconfig.build.json"
38
38
  ],
39
39
  "dependencies": {
40
- "@0xtorch/big-decimal": "^0.0.8",
40
+ "@0xtorch/big-decimal": "^0.0.9",
41
41
  "@0xtorch/core": "^0.0.2",
42
42
  "@supercharge/promise-pool": "^3.1.1",
43
43
  "viem": "^2.8.9",
package/_cjs/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
package/_esm/.DS_Store DELETED
Binary file
Binary file
package/_types/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file