@0xtorch/evm 0.0.105 → 0.0.106

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 (41) hide show
  1. package/_cjs/chain/definitions/ronin.js +6 -2
  2. package/_cjs/chain/definitions/ronin.js.map +1 -1
  3. package/_cjs/explorer/index.js +7 -5
  4. package/_cjs/explorer/index.js.map +1 -1
  5. package/_cjs/explorer/moralis/client.js +64 -0
  6. package/_cjs/explorer/moralis/client.js.map +1 -0
  7. package/_cjs/explorer/moralis/create.js +146 -0
  8. package/_cjs/explorer/moralis/create.js.map +1 -0
  9. package/_cjs/explorer/moralis/getWalletTransactionHistory.js +65 -0
  10. package/_cjs/explorer/moralis/getWalletTransactionHistory.js.map +1 -0
  11. package/_esm/chain/definitions/ronin.js +7 -3
  12. package/_esm/chain/definitions/ronin.js.map +1 -1
  13. package/_esm/explorer/index.js +1 -0
  14. package/_esm/explorer/index.js.map +1 -1
  15. package/_esm/explorer/moralis/client.js +64 -0
  16. package/_esm/explorer/moralis/client.js.map +1 -0
  17. package/_esm/explorer/moralis/create.js +142 -0
  18. package/_esm/explorer/moralis/create.js.map +1 -0
  19. package/_esm/explorer/moralis/getWalletTransactionHistory.js +141 -0
  20. package/_esm/explorer/moralis/getWalletTransactionHistory.js.map +1 -0
  21. package/_types/chain/definitions/ronin.d.ts +5 -1
  22. package/_types/chain/definitions/ronin.d.ts.map +1 -1
  23. package/_types/explorer/index.d.ts +1 -0
  24. package/_types/explorer/index.d.ts.map +1 -1
  25. package/_types/explorer/moralis/client.d.ts +16 -0
  26. package/_types/explorer/moralis/client.d.ts.map +1 -0
  27. package/_types/explorer/moralis/create.d.ts +12 -0
  28. package/_types/explorer/moralis/create.d.ts.map +1 -0
  29. package/_types/explorer/moralis/getWalletTransactionHistory.d.ts +38 -0
  30. package/_types/explorer/moralis/getWalletTransactionHistory.d.ts.map +1 -0
  31. package/chain/definitions/ronin.ts +15 -3
  32. package/explorer/index.ts +1 -0
  33. package/explorer/moralis/client.ts +114 -0
  34. package/explorer/moralis/create.ts +205 -0
  35. package/explorer/moralis/getWalletTransactionHistory.ts +172 -0
  36. package/package.json +1 -1
  37. package/.DS_Store +0 -0
  38. package/analyzer/.DS_Store +0 -0
  39. package/chain/.DS_Store +0 -0
  40. package/client/.DS_Store +0 -0
  41. package/explorer/.DS_Store +0 -0
@@ -0,0 +1,172 @@
1
+ import { z } from 'zod'
2
+ import { bigintTextSchema, lowerHexSchema } from '../../types/primitive'
3
+ import type { MoralisClient } from './client'
4
+
5
+ const transactionSchema = z.object({
6
+ // "hash": "0x43a8a6f44f4e5b9cc9fa7e76a2b818fc76222384eb8a2fb4e3ab854523c1fb94",
7
+ hash: lowerHexSchema,
8
+ // "nonce": "1",
9
+ // "transaction_index": "27",
10
+ // "from_address_entity": null,
11
+ // "from_address_entity_logo": null,
12
+ // "from_address": "0xecdb93a95cab09b5a259ebac8fd48d3239a5589a",
13
+ from_address: lowerHexSchema,
14
+ // "from_address_label": null,
15
+ // "to_address_entity": null,
16
+ // "to_address_entity_logo": null,
17
+ // "to_address": "0x213073989821f738a7ba3520c3d31a1f9ad31bbd",
18
+ to_address: lowerHexSchema,
19
+ // "to_address_label": null,
20
+ // "value": "0",
21
+ value: bigintTextSchema,
22
+ // "gas": "392194",
23
+ // "gas_price": "0",
24
+ // "receipt_cumulative_gas_used": "4678646",
25
+ // "receipt_gas_used": "169711",
26
+ // "receipt_contract_address": null,
27
+ // "receipt_status": "1",
28
+ // "block_timestamp": "2021-07-28T15:28:09.000Z",
29
+ block_timestamp: z.string().transform((x) => new Date(x).getTime()),
30
+ // "block_number": "5304713",
31
+ block_number: z.string().regex(/^\d+$/).transform(Number),
32
+ // "block_hash": "0xb87e4ea5f85e16461ab3242413577b0e18c50d10f6f22454d3f8da850b4135d9",
33
+ // "transaction_fee": "0",
34
+ // "method_label": "settleAuction",
35
+ // "summary": "Received 0.8 WETH from 0xe3...6b4b",
36
+ // "possible_spam": false,
37
+ // "category": "token receive",
38
+ // "nft_transfers": [],
39
+ nft_transfers: z.array(
40
+ z.object({
41
+ // "log_index": 132,
42
+ // "value": "0",
43
+ // "contract_type": "ERC721",
44
+ // "transaction_type": "Single",
45
+ // "token_address": "0x32950db2a7164ae833121501c797d79e7b79d74c",
46
+ // "token_id": "2273287",
47
+ // "from_address_entity": null,
48
+ // "from_address_entity_logo": null,
49
+ // "from_address": "0xecdb93a95cab09b5a259ebac8fd48d3239a5589a",
50
+ from_address: lowerHexSchema,
51
+ // "from_address_label": null,
52
+ // "to_address_entity": null,
53
+ // "to_address_entity_logo": null,
54
+ // "to_address": "0x36b9b408da80783a360ba847303b015d7e0e59f8",
55
+ to_address: lowerHexSchema,
56
+ // "to_address_label": null,
57
+ // "amount": "1",
58
+ amount: bigintTextSchema,
59
+ // "operator": null,
60
+ // "possible_spam": false,
61
+ // "verified_collection": false,
62
+ // "direction": "send"
63
+ }),
64
+ ),
65
+ // "erc20_transfers": [],
66
+ erc20_transfers: z.array(
67
+ z.object({
68
+ // "token_name": "Ronin Wrapped Ether",
69
+ // "token_symbol": "WETH",
70
+ // "token_logo": null,
71
+ // "token_decimals": "18",
72
+ // "from_address_entity": null,
73
+ // "from_address_entity_logo": null,
74
+ // "from_address": "0xecdb93a95cab09b5a259ebac8fd48d3239a5589a",
75
+ from_address: lowerHexSchema,
76
+ // "from_address_label": null,
77
+ // "to_address_entity": null,
78
+ // "to_address_entity_logo": null,
79
+ // "to_address": "0xa99cacd1427f493a95b585a5c7989a08c86a616b",
80
+ to_address: lowerHexSchema,
81
+ // "to_address_label": null,
82
+ // "address": "0xc99a6a985ed2cac1ef41640596c5a5f9f4e19ef5",
83
+ // "log_index": 37,
84
+ // "value": "6851147569444444",
85
+ value: bigintTextSchema,
86
+ // "possible_spam": false,
87
+ // "verified_contract": false,
88
+ // "security_score": null,
89
+ // "direction": "send",
90
+ // "value_formatted": "0.006851147569444444"
91
+ }),
92
+ ),
93
+ // "native_transfers": [],
94
+ // "internal_transactions": [],
95
+ internal_transactions: z.array(
96
+ z.object({
97
+ // "transaction_hash": "0x4f3c9722734098328c9c3b1fcddb9712f4dc6724c50ee2d3614aff6362eab175",
98
+ // "block_number": 21021408,
99
+ // "block_hash": "0x971595149658a4d5c2d0a2219f5019958e1a7ff2f72d7d098e144104a2a5b6a0",
100
+ // "type": "CALL",
101
+ // "from": "0x0000000000000068f116a894984e2db1123eb395",
102
+ from: lowerHexSchema,
103
+ // "to": "0x0000a26b00c1f0df003000390027140000faa719",
104
+ to: lowerHexSchema,
105
+ // "value": "1180000000000000",
106
+ value: bigintTextSchema,
107
+ // "gas": "68677",
108
+ gas: bigintTextSchema,
109
+ // "gas_used": "85",
110
+ // "input": "0x",
111
+ // "output": "0x"
112
+ }),
113
+ ),
114
+ })
115
+
116
+ const resultSchema = z.object({
117
+ cursor: z.string(),
118
+ result: z.array(transactionSchema),
119
+ })
120
+
121
+ type Result = z.infer<typeof resultSchema>
122
+
123
+ const cache = new Map<string, Result>()
124
+
125
+ type GetWalletTransactionHistoryParameters = {
126
+ client: MoralisClient
127
+ address: string
128
+ chain: string
129
+ fromBlock?: number
130
+ toBlock?: number
131
+ cursor?: string
132
+ }
133
+
134
+ export const getWalletTransactionHistory = async ({
135
+ client,
136
+ address,
137
+ chain,
138
+ fromBlock = 0,
139
+ toBlock,
140
+ cursor,
141
+ }: GetWalletTransactionHistoryParameters) => {
142
+ const path = `/api/v2.2/wallets/${address}/history`
143
+ const query: Record<string, string> = {
144
+ chain,
145
+ from_block: fromBlock.toString(),
146
+ include_internal_transactions: 'true',
147
+ order: 'ASC',
148
+ }
149
+ if (toBlock !== undefined) {
150
+ query.to_block = toBlock.toString()
151
+ }
152
+ if (cursor !== undefined) {
153
+ query.cursor = cursor
154
+ }
155
+
156
+ const cacheKey = `${path}?${Object.entries(query)
157
+ .map(([k, v]) => `${k}=${v}`)
158
+ .join('&')}`
159
+ const cached = cache.get(cacheKey)
160
+ if (cached !== undefined) {
161
+ return cached
162
+ }
163
+
164
+ const result = await client.get({
165
+ path,
166
+ query,
167
+ resultSchema,
168
+ })
169
+ cache.set(cacheKey, result)
170
+
171
+ return result
172
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/evm",
3
- "version": "0.0.105",
3
+ "version": "0.0.106",
4
4
  "description": "Cryptorch EVM extension",
5
5
  "keywords": [
6
6
  "cryptorch",
package/.DS_Store DELETED
Binary file
Binary file
package/chain/.DS_Store DELETED
Binary file
package/client/.DS_Store DELETED
Binary file
Binary file