@0xtorch/evm 0.0.84 → 0.0.86

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 (40) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/chain/definitions/zora.js +53 -0
  3. package/_cjs/chain/definitions/zora.js.map +1 -0
  4. package/_cjs/chain/index.js +6 -1
  5. package/_cjs/chain/index.js.map +1 -1
  6. package/_cjs/index.js +7 -3
  7. package/_cjs/index.js.map +1 -1
  8. package/_cjs/logic/analyzeTransaction/createActions/json/schema.js +9 -1
  9. package/_cjs/logic/analyzeTransaction/createActions/json/schema.js.map +1 -1
  10. package/_cjs/logic/analyzeTransaction/createActions/json/simpleValue.js +24 -4
  11. package/_cjs/logic/analyzeTransaction/createActions/json/simpleValue.js.map +1 -1
  12. package/_esm/chain/definitions/zora.js +48 -0
  13. package/_esm/chain/definitions/zora.js.map +1 -0
  14. package/_esm/chain/index.js +1 -0
  15. package/_esm/chain/index.js.map +1 -1
  16. package/_esm/index.js +1 -1
  17. package/_esm/index.js.map +1 -1
  18. package/_esm/logic/analyzeTransaction/createActions/json/schema.js +9 -1
  19. package/_esm/logic/analyzeTransaction/createActions/json/schema.js.map +1 -1
  20. package/_esm/logic/analyzeTransaction/createActions/json/simpleValue.js +24 -4
  21. package/_esm/logic/analyzeTransaction/createActions/json/simpleValue.js.map +1 -1
  22. package/_types/chain/definitions/zora.d.ts +14 -0
  23. package/_types/chain/definitions/zora.d.ts.map +1 -0
  24. package/_types/chain/index.d.ts +1 -0
  25. package/_types/chain/index.d.ts.map +1 -1
  26. package/_types/index.d.ts +1 -1
  27. package/_types/index.d.ts.map +1 -1
  28. package/_types/logic/analyzeTransaction/createActions/json/schema.d.ts +11673 -1
  29. package/_types/logic/analyzeTransaction/createActions/json/schema.d.ts.map +1 -1
  30. package/_types/logic/analyzeTransaction/createActions/json/simpleValue.d.ts.map +1 -1
  31. package/analyzer/.DS_Store +0 -0
  32. package/chain/.DS_Store +0 -0
  33. package/chain/definitions/zora.ts +62 -0
  34. package/chain/index.ts +6 -0
  35. package/client/.DS_Store +0 -0
  36. package/explorer/.DS_Store +0 -0
  37. package/index.ts +4 -0
  38. package/logic/analyzeTransaction/createActions/json/schema.ts +12 -2
  39. package/logic/analyzeTransaction/createActions/json/simpleValue.ts +25 -8
  40. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"simpleValue.d.ts","sourceRoot":"","sources":["../../../../../logic/analyzeTransaction/createActions/json/simpleValue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAKV,QAAQ,EACR,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,eAAO,MAAM,cAAc,+CAIxB;IACD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;IAClD,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAA;IACxC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;CACzC,KAAG,MA8VH,CAAA"}
1
+ {"version":3,"file":"simpleValue.d.ts","sourceRoot":"","sources":["../../../../../logic/analyzeTransaction/createActions/json/simpleValue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAKV,QAAQ,EACR,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,eAAO,MAAM,cAAc,+CAIxB;IACD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;IAClD,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAA;IACxC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;CACzC,KAAG,MA+WH,CAAA"}
Binary file
Binary file
@@ -0,0 +1,62 @@
1
+ import { ethereum } from '@0xtorch/core'
2
+ import { zora } from 'viem/chains'
3
+ import { type Client, createClient } from '../../client'
4
+ import { type Explorer, createBlockscout } from '../../explorer'
5
+ import type { Chain } from '../types/chain'
6
+ import type { HttpRpc } from '../types/rpc'
7
+
8
+ export const createZoraChain = () =>
9
+ createZoraChainCustom({
10
+ client: createClient({
11
+ chain: zora,
12
+ httpRpcs: zoraHttpRpcs,
13
+ }),
14
+ explorer: createBlockscout({
15
+ name: 'Zora Mainnet explorer',
16
+ baseUrl: 'https://explorer.zora.energy/',
17
+ apiBaseUrl: 'https://explorer.zora.energy/api',
18
+ }),
19
+ })
20
+
21
+ type CreateZoraChainParameters = {
22
+ client: Client
23
+ explorer: Explorer
24
+ }
25
+
26
+ export const createZoraChainCustom = ({
27
+ client,
28
+ explorer,
29
+ }: CreateZoraChainParameters): Chain => ({
30
+ id: 7777777,
31
+ network: 'zora',
32
+ name: 'Zora',
33
+ nativeToken: {
34
+ name: 'Ethereum',
35
+ symbol: 'ETH',
36
+ decimals: 18,
37
+ currency: ethereum,
38
+ },
39
+ wrappedTokenAddresses: new Set([
40
+ '0x4200000000000000000000000000000000000006',
41
+ ]),
42
+ explorer,
43
+ client,
44
+ blockTime: 2000,
45
+ coingeckoId: 'zora-network',
46
+ defillamaId: 'zora',
47
+ })
48
+
49
+ export const zoraHttpRpcs: HttpRpc[] = [
50
+ {
51
+ url: 'https://rpc.zora.energy',
52
+ getLogsIsUsable: true,
53
+ getLogsMaxBlockRange: 10_000n,
54
+ },
55
+ {
56
+ url: 'https://zora.drpc.org',
57
+ getLogsIsUsable: true,
58
+ getLogsMaxBlockRange: 20_000n,
59
+ },
60
+ ]
61
+
62
+ export const zoraWebsocketRpcUrls: readonly string[] = ['wss://zora.drpc.org']
package/chain/index.ts CHANGED
@@ -100,5 +100,11 @@ export {
100
100
  roninHttpRpcs,
101
101
  roninWebsocketRpcUrls,
102
102
  } from './definitions/ronin'
103
+ export {
104
+ createZoraChain,
105
+ createZoraChainCustom,
106
+ zoraHttpRpcs,
107
+ zoraWebsocketRpcUrls,
108
+ } from './definitions/zora'
103
109
  export type { Chain } from './types/chain'
104
110
  export type { HttpRpc } from './types/rpc'
Binary file
Binary file
package/index.ts CHANGED
@@ -44,6 +44,8 @@ export {
44
44
  createPolygonPosChainCustom,
45
45
  createRoninChain,
46
46
  createRoninChainCustom,
47
+ createZoraChain,
48
+ createZoraChainCustom,
47
49
  ethereumHttpRpcs,
48
50
  ethereumWebsocketRpcUrls,
49
51
  fantomHttpRpcs,
@@ -68,6 +70,8 @@ export {
68
70
  polygonPosWebsocketRpcUrls,
69
71
  roninHttpRpcs,
70
72
  roninWebsocketRpcUrls,
73
+ zoraHttpRpcs,
74
+ zoraWebsocketRpcUrls,
71
75
  } from './chain'
72
76
  export type { Chain } from './chain'
73
77
  export { createClient } from './client'
@@ -55,6 +55,10 @@ const valueValueSchema = z.object({
55
55
  const functionValueSchema = z.object({
56
56
  type: z.literal('function'),
57
57
  index: indexSchema,
58
+ paramKeys: z
59
+ .array(z.union([z.number(), z.string()]))
60
+ .min(1)
61
+ .optional(),
58
62
  })
59
63
 
60
64
  const logValueSchema = z.object({
@@ -73,6 +77,10 @@ const logValueSchema = z.object({
73
77
  .optional(),
74
78
  index: indexSchema,
75
79
  value: z.union([z.literal('address'), indexSchema]),
80
+ paramKeys: z
81
+ .array(z.union([z.number(), z.string()]))
82
+ .min(1)
83
+ .optional(),
76
84
  })
77
85
 
78
86
  const erc20ValueSchema = z.object({
@@ -549,11 +557,13 @@ const exampleSchema = z.object({
549
557
  })
550
558
 
551
559
  export const analyzerSchema: z.ZodObject<{
552
- example: z.ZodOptional<typeof exampleSchema>
560
+ example: z.ZodOptional<
561
+ z.ZodUnion<[typeof exampleSchema, z.ZodArray<typeof exampleSchema>]>
562
+ >
553
563
  condition: typeof conditionSchema
554
564
  generators: z.ZodArray<typeof generatorSchema>
555
565
  }> = z.object({
556
- example: exampleSchema.optional(),
566
+ example: z.union([exampleSchema, z.array(exampleSchema)]).optional(),
557
567
  condition: conditionSchema,
558
568
  generators: z.array(generatorSchema).min(1),
559
569
  })
@@ -40,11 +40,18 @@ export const getSimpleValue = ({
40
40
  return transaction.value.toString()
41
41
  }
42
42
  case 'function': {
43
- return (
44
- stringify(
45
- transaction.function?.args[schema.index].value,
46
- ).toLowerCase() ?? ''
47
- )
43
+ const arg = transaction.function?.args[schema.index].value
44
+ if (schema.paramKeys === undefined) {
45
+ return stringify(arg).toLowerCase()
46
+ }
47
+ let value = arg
48
+ for (const key of schema.paramKeys) {
49
+ if (typeof key === 'number') {
50
+ value = (value as unknown[])[key]
51
+ }
52
+ value = (value as Record<string, unknown>)[key]
53
+ }
54
+ return stringify(value).toLowerCase()
48
55
  }
49
56
  case 'log': {
50
57
  const targetLogs: Log[] = []
@@ -116,9 +123,19 @@ export const getSimpleValue = ({
116
123
  if (schema.value === 'address') {
117
124
  return log.address
118
125
  }
119
- return log.args === undefined
120
- ? ''
121
- : stringify(log.args[schema.value].value).toLowerCase()
126
+ const arg =
127
+ log.args === undefined ? undefined : log.args[schema.value].value
128
+ if (schema.paramKeys === undefined) {
129
+ return stringify(arg).toLowerCase()
130
+ }
131
+ let value = arg
132
+ for (const key of schema.paramKeys) {
133
+ if (typeof key === 'number') {
134
+ value = (value as unknown[])[key]
135
+ }
136
+ value = (value as Record<string, unknown>)[key]
137
+ }
138
+ return stringify(value).toLowerCase()
122
139
  }
123
140
  case 'erc20': {
124
141
  const targetTransfers: Erc20TokenTransfer[] = []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/evm",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
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.11",
41
- "@0xtorch/core": "^0.0.48",
41
+ "@0xtorch/core": "^0.0.49",
42
42
  "abitype": "^1.0.6",
43
43
  "viem": "2.21.18",
44
44
  "zod": "^3.23.8"