@0xtorch/evm 0.0.45 → 0.0.47

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 (81) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/clients/definitions/viemClient.js +2 -0
  3. package/_cjs/clients/definitions/viemClient.js.map +1 -1
  4. package/_cjs/decoder/tests.js +6 -0
  5. package/_cjs/decoder/tests.js.map +1 -1
  6. package/_cjs/explorers/definitions/blockscout.js +8 -0
  7. package/_cjs/explorers/definitions/blockscout.js.map +1 -1
  8. package/_cjs/explorers/definitions/etherscan.js +9 -0
  9. package/_cjs/explorers/definitions/etherscan.js.map +1 -1
  10. package/_cjs/explorers/definitions/roninExplorer.js +6 -0
  11. package/_cjs/explorers/definitions/roninExplorer.js.map +1 -1
  12. package/_cjs/explorers/definitions/routescan.js +4 -0
  13. package/_cjs/explorers/definitions/routescan.js.map +1 -1
  14. package/_cjs/explorers/externals/blockscout/getContractCreations.js +64 -0
  15. package/_cjs/explorers/externals/blockscout/getContractCreations.js.map +1 -0
  16. package/_cjs/explorers/externals/blockscout/index.js +3 -1
  17. package/_cjs/explorers/externals/blockscout/index.js.map +1 -1
  18. package/_cjs/explorers/externals/etherscan/getContractCreations.js +56 -0
  19. package/_cjs/explorers/externals/etherscan/getContractCreations.js.map +1 -0
  20. package/_cjs/explorers/externals/etherscan/index.js +3 -1
  21. package/_cjs/explorers/externals/etherscan/index.js.map +1 -1
  22. package/_esm/clients/definitions/viemClient.js +2 -0
  23. package/_esm/clients/definitions/viemClient.js.map +1 -1
  24. package/_esm/decoder/tests.js +6 -0
  25. package/_esm/decoder/tests.js.map +1 -1
  26. package/_esm/explorers/definitions/blockscout.js +9 -1
  27. package/_esm/explorers/definitions/blockscout.js.map +1 -1
  28. package/_esm/explorers/definitions/etherscan.js +10 -1
  29. package/_esm/explorers/definitions/etherscan.js.map +1 -1
  30. package/_esm/explorers/definitions/roninExplorer.js +6 -0
  31. package/_esm/explorers/definitions/roninExplorer.js.map +1 -1
  32. package/_esm/explorers/definitions/routescan.js +5 -0
  33. package/_esm/explorers/definitions/routescan.js.map +1 -1
  34. package/_esm/explorers/externals/blockscout/getContractCreations.js +61 -0
  35. package/_esm/explorers/externals/blockscout/getContractCreations.js.map +1 -0
  36. package/_esm/explorers/externals/blockscout/index.js +1 -0
  37. package/_esm/explorers/externals/blockscout/index.js.map +1 -1
  38. package/_esm/explorers/externals/etherscan/getContractCreations.js +53 -0
  39. package/_esm/explorers/externals/etherscan/getContractCreations.js.map +1 -0
  40. package/_esm/explorers/externals/etherscan/index.js +1 -0
  41. package/_esm/explorers/externals/etherscan/index.js.map +1 -1
  42. package/_types/clients/definitions/viemClient.d.ts +5 -1
  43. package/_types/clients/definitions/viemClient.d.ts.map +1 -1
  44. package/_types/clients/types.d.ts +7 -1
  45. package/_types/clients/types.d.ts.map +1 -1
  46. package/_types/decoder/tests.d.ts.map +1 -1
  47. package/_types/explorers/definitions/blockscout.d.ts +5 -0
  48. package/_types/explorers/definitions/blockscout.d.ts.map +1 -1
  49. package/_types/explorers/definitions/etherscan.d.ts +5 -0
  50. package/_types/explorers/definitions/etherscan.d.ts.map +1 -1
  51. package/_types/explorers/definitions/roninExplorer.d.ts +10 -8
  52. package/_types/explorers/definitions/roninExplorer.d.ts.map +1 -1
  53. package/_types/explorers/definitions/routescan.d.ts +1 -0
  54. package/_types/explorers/definitions/routescan.d.ts.map +1 -1
  55. package/_types/explorers/externals/blockscout/getContractCreations.d.ts +27 -0
  56. package/_types/explorers/externals/blockscout/getContractCreations.d.ts.map +1 -0
  57. package/_types/explorers/externals/blockscout/index.d.ts +1 -0
  58. package/_types/explorers/externals/blockscout/index.d.ts.map +1 -1
  59. package/_types/explorers/externals/etherscan/getContractCreations.d.ts +28 -0
  60. package/_types/explorers/externals/etherscan/getContractCreations.d.ts.map +1 -0
  61. package/_types/explorers/externals/etherscan/index.d.ts +1 -0
  62. package/_types/explorers/externals/etherscan/index.d.ts.map +1 -1
  63. package/_types/explorers/types.d.ts +6 -0
  64. package/_types/explorers/types.d.ts.map +1 -1
  65. package/analyzer/.DS_Store +0 -0
  66. package/chains/.DS_Store +0 -0
  67. package/clients/.DS_Store +0 -0
  68. package/clients/definitions/viemClient.ts +17 -0
  69. package/clients/types.ts +12 -1
  70. package/decoder/tests.ts +6 -0
  71. package/explorers/.DS_Store +0 -0
  72. package/explorers/definitions/blockscout.ts +9 -0
  73. package/explorers/definitions/etherscan.ts +10 -0
  74. package/explorers/definitions/roninExplorer.ts +7 -0
  75. package/explorers/definitions/routescan.ts +5 -0
  76. package/explorers/externals/blockscout/getContractCreations.ts +85 -0
  77. package/explorers/externals/blockscout/index.ts +1 -0
  78. package/explorers/externals/etherscan/getContractCreations.ts +80 -0
  79. package/explorers/externals/etherscan/index.ts +1 -0
  80. package/explorers/types.ts +12 -0
  81. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ import type { Logger } from '@0xtorch/core';
2
+ import { z } from 'zod';
3
+ import type { Hex } from '../../../types';
4
+ type GetContractCreationsParameters = {
5
+ readonly apiEndpoint: string;
6
+ readonly apiKey: string;
7
+ readonly addresses: readonly Hex[];
8
+ readonly logger?: Logger;
9
+ };
10
+ declare const contractCreationSchema: z.ZodObject<{
11
+ contractAddress: z.ZodEffects<z.ZodString, `0x${Lowercase<string>}`, string>;
12
+ contractCreator: z.ZodEffects<z.ZodString, `0x${Lowercase<string>}`, string>;
13
+ txHash: z.ZodEffects<z.ZodString, `0x${Lowercase<string>}`, string>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ contractAddress: `0x${Lowercase<string>}`;
16
+ contractCreator: `0x${Lowercase<string>}`;
17
+ txHash: `0x${Lowercase<string>}`;
18
+ }, {
19
+ contractAddress: string;
20
+ contractCreator: string;
21
+ txHash: string;
22
+ }>;
23
+ type ContractCreation = Readonly<z.infer<typeof contractCreationSchema>>;
24
+ type ReturnType = readonly ContractCreation[];
25
+ /** {@link https://docs.etherscan.io/api-endpoints/contracts#get-contract-creator-and-creation-tx-hash} */
26
+ export declare const getContractCreations: ({ apiEndpoint, apiKey, addresses, logger, }: GetContractCreationsParameters) => Promise<ReturnType>;
27
+ export {};
28
+ //# sourceMappingURL=getContractCreations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContractCreations.d.ts","sourceRoot":"","sources":["../../../../explorers/externals/etherscan/getContractCreations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAIzC,KAAK,8BAA8B,GAAG;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,EAAE,CAAA;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,QAAA,MAAM,sBAAsB;;;;;;;;;;;;EAa1B,CAAA;AAQF,KAAK,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAA;AACxE,KAAK,UAAU,GAAG,SAAS,gBAAgB,EAAE,CAAA;AAE7C,0GAA0G;AAC1G,eAAO,MAAM,oBAAoB,gDAK9B,8BAA8B,KAAG,QAAQ,UAAU,CAoCrD,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export { getBlockNumberOfTimestamp } from './getBlockNumberOfTimestamp';
2
2
  export { getContractByAddress } from './getContractByAddress';
3
+ export { getContractCreations } from './getContractCreations';
3
4
  export { getErc1155TokenTransfersByAddress } from './getErc1155TokenTransfersByAddress';
4
5
  export { getErc20TokenTransfersByAddress } from './getErc20TokenTransfersByAddress';
5
6
  export { getErc721TokenTransfersByAddress } from './getErc721TokenTransfersByAddress';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../explorers/externals/etherscan/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAA;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AACrF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AACrF,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAA;AACrG,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../explorers/externals/etherscan/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAA;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AACrF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAA;AACrF,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAA;AACrG,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAA"}
@@ -12,6 +12,7 @@ export type Explorer = {
12
12
  readonly getAddressTokenTransferHashesWithTimestamp: FunctionGetAddressTokenTransferHashesWithTimestamp;
13
13
  readonly getBlockNumberOfTimestamp: (timestamp: number, logger?: Logger) => Promise<bigint>;
14
14
  readonly getContract: FunctionGetContract;
15
+ readonly getContractCreations: FunctionGetContractCreations;
15
16
  readonly getInternalTransactionOfTransaction: FunctionGetInternalTransactionOfTransaction;
16
17
  };
17
18
  type FunctionGetAddressTransactionHashes = (parameters: {
@@ -64,6 +65,11 @@ type FunctionGetContract = (address: Hex, logger?: Logger) => Promise<{
64
65
  readonly name: string;
65
66
  readonly abi: string;
66
67
  } | undefined>;
68
+ type FunctionGetContractCreations = (addresses: readonly Hex[], logger?: Logger) => Promise<readonly {
69
+ readonly contractAddress: Hex;
70
+ readonly contractCreator: Hex;
71
+ readonly txHash: Hex;
72
+ }[]>;
67
73
  type FunctionGetInternalTransactionOfTransaction = (parameters: {
68
74
  readonly hash: Hex;
69
75
  readonly nativeCurrency: CryptoCurrency;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../explorers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAExD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,2BAA2B,EAAE,mCAAmC,CAAA;IACzE,QAAQ,CAAC,wCAAwC,EAAE,gDAAgD,CAAA;IACnG,QAAQ,CAAC,8BAA8B,EAAE,sCAAsC,CAAA;IAC/E,QAAQ,CAAC,2CAA2C,EAAE,mDAAmD,CAAA;IACzG,QAAQ,CAAC,6BAA6B,EAAE,qCAAqC,CAAA;IAC7E,QAAQ,CAAC,0CAA0C,EAAE,kDAAkD,CAAA;IACvG,QAAQ,CAAC,yBAAyB,EAAE,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,CAA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Ae,EAAE,GAAG,CAAA;IAC7B,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAA;CACrB,EAAE,CACJ,CAAA;AAED,KAAK,2CAA2C,GAAG,CAAC,UAAU,EAAE;IAC9D,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAA;IAClB,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB,KAAK,OAAO,CAAC,SAAS,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA"}
Binary file
Binary file
Binary file
@@ -3,6 +3,7 @@ import type { AbiEvent } from 'abitype'
3
3
  import type {
4
4
  Abi,
5
5
  ContractFunctionName,
6
+ createPublicClient,
6
7
  GetLogsReturnType,
7
8
  MulticallParameters,
8
9
  MulticallReturnType,
@@ -24,6 +25,7 @@ import {
24
25
  multicall,
25
26
  readContract,
26
27
  } from '../externals/viem'
28
+ import { createViemClient as createViemMiddleware } from '../externals/viem/middleware'
27
29
  import { defineClient } from './defineClient'
28
30
 
29
31
  type CreateViemClientParameters<TChain extends ViemChain> = {
@@ -37,6 +39,21 @@ export const createViemClient = <TChain extends ViemChain>({
37
39
  }: CreateViemClientParameters<TChain>) =>
38
40
  defineClient({
39
41
  httpRpcCount: httpRpcs.length,
42
+ call: async <T>(
43
+ caller: (client: ReturnType<typeof createPublicClient>) => Promise<T>,
44
+ config:
45
+ | {
46
+ readonly timeout?: number
47
+ readonly logger?: Logger
48
+ }
49
+ | undefined,
50
+ ) =>
51
+ createViemMiddleware(chain, httpRpcs).wrapper<T>(
52
+ caller,
53
+ undefined,
54
+ config?.timeout,
55
+ config?.logger,
56
+ ),
40
57
  estimateFeesPerGas: async (type, config) =>
41
58
  estimateFeesPerGas({ chain, httpRpcs, type }, config),
42
59
  getBalance: async (address, config) =>
package/clients/types.ts CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  Abi,
5
5
  Block,
6
6
  ContractFunctionName,
7
+ createPublicClient,
7
8
  FeeValues,
8
9
  GetLogsReturnType,
9
10
  MulticallParameters,
@@ -17,7 +18,7 @@ import type { Hex, LowerHex } from '../types'
17
18
 
18
19
  export type Client = {
19
20
  readonly httpRpcCount: number
20
- // TODO 主要関数を定義する
21
+ readonly call: FunctionCall
21
22
  readonly estimateFeesPerGas: FunctionEstimateFeesPerGas
22
23
  readonly getBalance: FunctionGetBalance
23
24
  readonly getBlock: FunctionGetBlock
@@ -30,6 +31,16 @@ export type Client = {
30
31
  readonly readContract: FunctionReadContract
31
32
  }
32
33
 
34
+ type PublicClient = ReturnType<typeof createPublicClient>
35
+
36
+ type FunctionCall = <T>(
37
+ caller: (client: PublicClient) => Promise<T>,
38
+ config?: {
39
+ readonly timeout?: number
40
+ readonly logger?: Logger
41
+ },
42
+ ) => Promise<T>
43
+
33
44
  type FunctionEstimateFeesPerGas = (
34
45
  type?: 'legacy' | 'eip1559',
35
46
  config?: {
package/decoder/tests.ts CHANGED
@@ -6,6 +6,9 @@ import { toLowerHex } from '../types'
6
6
 
7
7
  const dummyClient: Client = {
8
8
  httpRpcCount: 0,
9
+ call: () => {
10
+ throw new Error('Not implemented')
11
+ },
9
12
  estimateFeesPerGas: () => {
10
13
  throw new Error('Not implemented')
11
14
  },
@@ -70,6 +73,9 @@ const testExplorer: Explorer = {
70
73
  await new Promise((resolve) => setTimeout(resolve))
71
74
  return undefined
72
75
  },
76
+ getContractCreations: () => {
77
+ throw new Error('Not implemented')
78
+ },
73
79
  getInternalTransactionOfTransaction: () => {
74
80
  throw new Error('Not implemented')
75
81
  },
Binary file
@@ -1,6 +1,7 @@
1
1
  import type { Logger } from '@0xtorch/core'
2
2
  import type { InternalTransaction, LowerHex } from '../../types'
3
3
  import {
4
+ getContractCreations as apiGetContractCreations,
4
5
  getBlockNumberOfTimestamp,
5
6
  getContractByAddress,
6
7
  getInternalTransactionsByAddress,
@@ -181,6 +182,14 @@ export const createBlockscout = <
181
182
  abi: contract.ABI,
182
183
  }
183
184
  },
185
+ getContractCreations: async (addresses, logger?: Logger) => {
186
+ const creations = await apiGetContractCreations({
187
+ apiEndpoint: apiUrl,
188
+ addresses,
189
+ logger,
190
+ })
191
+ return creations
192
+ },
184
193
  getInternalTransactionOfTransaction: async ({
185
194
  hash,
186
195
  nativeCurrency,
@@ -1,6 +1,7 @@
1
1
  import type { Logger } from '@0xtorch/core'
2
2
  import type { InternalTransaction, LowerHex } from '../../types'
3
3
  import {
4
+ getContractCreations as apiGetContractCreations,
4
5
  getBlockNumberOfTimestamp,
5
6
  getContractByAddress,
6
7
  getErc1155TokenTransfersByAddress,
@@ -254,6 +255,15 @@ export const createEtherscan = <
254
255
  abi: contract.ABI,
255
256
  }
256
257
  },
258
+ getContractCreations: async (addresses, logger?: Logger) => {
259
+ const creations = await apiGetContractCreations({
260
+ apiEndpoint: apiUrl,
261
+ apiKey,
262
+ addresses,
263
+ logger,
264
+ })
265
+ return creations
266
+ },
257
267
  getInternalTransactionOfTransaction: async ({
258
268
  hash,
259
269
  nativeCurrency,
@@ -1,3 +1,4 @@
1
+ import type { Logger } from '@0xtorch/core'
1
2
  import type { Hex } from 'viem'
2
3
  import type { LowerHex } from '../../types'
3
4
  import {
@@ -123,6 +124,12 @@ export const createRoninExplorer = <
123
124
  }
124
125
  return Promise.resolve(undefined)
125
126
  },
127
+ getContractCreations: (_, logger?: Logger) => {
128
+ if (logger !== undefined) {
129
+ logger.info('getContractCreations is not supported on Ronin Explorer')
130
+ }
131
+ throw new Error('Not supported')
132
+ },
126
133
  getInternalTransactionOfTransaction: async ({
127
134
  hash,
128
135
  nativeCurrency,
@@ -49,6 +49,11 @@ export const createRoutescan = <
49
49
  await new Promise((resolve) => setTimeout(resolve))
50
50
  throw new Error('not implemented')
51
51
  },
52
+ getContractCreations: async () => {
53
+ // TODO implement
54
+ await new Promise((resolve) => setTimeout(resolve))
55
+ throw new Error('not implemented')
56
+ },
52
57
  getInternalTransactionOfTransaction: async () => {
53
58
  // TODO implement
54
59
  await new Promise((resolve) => setTimeout(resolve))
@@ -0,0 +1,85 @@
1
+ import type { Logger } from '@0xtorch/core'
2
+ import { z } from 'zod'
3
+ import type { Hex } from '../../../types'
4
+ import { isHex, toLowerHex } from '../../../types'
5
+ import { createBlockscoutClient } from './middleware'
6
+
7
+ type GetContractCreationsParameters = {
8
+ readonly apiEndpoint: string
9
+ readonly addresses: readonly Hex[]
10
+ readonly logger?: Logger
11
+ }
12
+
13
+ const contractCreationSchema = z.object({
14
+ contractAddress: z
15
+ .string()
16
+ .regex(/^0x[\da-f]{40}$/)
17
+ .transform((x) => (isHex(x) ? toLowerHex(x) : '0x')),
18
+ contractCreator: z
19
+ .string()
20
+ .regex(/^0x[\da-f]{40}$/)
21
+ .transform((x) => (isHex(x) ? toLowerHex(x) : '0x')),
22
+ txHash: z
23
+ .string()
24
+ .regex(/^0x[\da-f]{64}$/)
25
+ .transform((x) => (isHex(x) ? toLowerHex(x) : '0x')),
26
+ })
27
+
28
+ const responseSchema = z.object({
29
+ status: z.string(),
30
+ message: z.string(),
31
+ result: z
32
+ .union([
33
+ z.array(contractCreationSchema),
34
+ z.array(z.object({})).transform(() => undefined),
35
+ z.string(),
36
+ ])
37
+ .nullable(),
38
+ })
39
+
40
+ type ContractCreation = Readonly<z.infer<typeof contractCreationSchema>>
41
+ type ReturnType = readonly ContractCreation[]
42
+
43
+ /** {@link https://docs.blockscout.com/developer-support/api/rpc-endpoints/contract#get-contract-creator-address-hash-and-creation-transaction-hash} */
44
+ export const getContractCreations = async ({
45
+ apiEndpoint,
46
+ addresses,
47
+ logger,
48
+ }: GetContractCreationsParameters): Promise<ReturnType> => {
49
+ try {
50
+ const { status, message, result } = await createBlockscoutClient(
51
+ apiEndpoint,
52
+ ).get(
53
+ '',
54
+ {
55
+ module: 'contract',
56
+ action: 'getcontractcreation',
57
+ contractaddresses: addresses.join(','),
58
+ },
59
+ responseSchema,
60
+ logger,
61
+ )
62
+ if (status !== '1' || result === null) {
63
+ const error =
64
+ typeof result === 'string' ? new Error(result) : new Error(message)
65
+ throw error
66
+ }
67
+ if (typeof result === 'string') {
68
+ throw new TypeError(result)
69
+ }
70
+ if (result === undefined) {
71
+ return []
72
+ }
73
+ return result
74
+ } catch (error) {
75
+ if (error instanceof Error && error.message === 'Max rate limit reached') {
76
+ await new Promise((resolve) => setTimeout(resolve, 1000))
77
+ return await getContractCreations({
78
+ apiEndpoint,
79
+ addresses,
80
+ logger,
81
+ })
82
+ }
83
+ throw error
84
+ }
85
+ }
@@ -1,5 +1,6 @@
1
1
  export { getBlockNumberOfTimestamp } from './getBlockNumberOfTimestamp'
2
2
  export { getContractByAddress } from './getContractByAddress'
3
+ export { getContractCreations } from './getContractCreations'
3
4
  export { getInternalTransactionsByAddress } from './getInternalTransactionsByAddress'
4
5
  export { getInternalTransactionsByTransactionHash } from './getInternalTransactionsByTransactionHash'
5
6
  export { getNormalTransactionsByAddress } from './getNormalTransactionsByAddress'
@@ -0,0 +1,80 @@
1
+ import type { Logger } from '@0xtorch/core'
2
+ import { z } from 'zod'
3
+ import type { Hex } from '../../../types'
4
+ import { isHex, toLowerHex } from '../../../types'
5
+ import { createEtherscanClient } from './middleware'
6
+
7
+ type GetContractCreationsParameters = {
8
+ readonly apiEndpoint: string
9
+ readonly apiKey: string
10
+ readonly addresses: readonly Hex[]
11
+ readonly logger?: Logger
12
+ }
13
+
14
+ const contractCreationSchema = z.object({
15
+ contractAddress: z
16
+ .string()
17
+ .regex(/^0x[\da-f]{40}$/)
18
+ .transform((x) => (isHex(x) ? toLowerHex(x) : '0x')),
19
+ contractCreator: z
20
+ .string()
21
+ .regex(/^0x[\da-f]{40}$/)
22
+ .transform((x) => (isHex(x) ? toLowerHex(x) : '0x')),
23
+ txHash: z
24
+ .string()
25
+ .regex(/^0x[\da-f]{64}$/)
26
+ .transform((x) => (isHex(x) ? toLowerHex(x) : '0x')),
27
+ })
28
+
29
+ const responseSchema = z.object({
30
+ status: z.string(),
31
+ message: z.string(),
32
+ result: z.union([z.array(contractCreationSchema), z.string()]).nullable(),
33
+ })
34
+
35
+ type ContractCreation = Readonly<z.infer<typeof contractCreationSchema>>
36
+ type ReturnType = readonly ContractCreation[]
37
+
38
+ /** {@link https://docs.etherscan.io/api-endpoints/contracts#get-contract-creator-and-creation-tx-hash} */
39
+ export const getContractCreations = async ({
40
+ apiEndpoint,
41
+ apiKey,
42
+ addresses,
43
+ logger,
44
+ }: GetContractCreationsParameters): Promise<ReturnType> => {
45
+ try {
46
+ const { status, message, result } = await createEtherscanClient(
47
+ apiEndpoint,
48
+ apiKey,
49
+ ).get(
50
+ '',
51
+ {
52
+ module: 'contract',
53
+ action: 'getcontractcreation',
54
+ contractaddresses: addresses.join(','),
55
+ },
56
+ responseSchema,
57
+ logger,
58
+ )
59
+ if (status !== '1' || result === null) {
60
+ const error =
61
+ typeof result === 'string' ? new Error(result) : new Error(message)
62
+ throw error
63
+ }
64
+ if (typeof result === 'string') {
65
+ throw new TypeError(result)
66
+ }
67
+ return result
68
+ } catch (error) {
69
+ if (error instanceof Error && error.message === 'Max rate limit reached') {
70
+ await new Promise((resolve) => setTimeout(resolve, 1000))
71
+ return await getContractCreations({
72
+ apiEndpoint,
73
+ apiKey,
74
+ addresses,
75
+ logger,
76
+ })
77
+ }
78
+ throw error
79
+ }
80
+ }
@@ -1,5 +1,6 @@
1
1
  export { getBlockNumberOfTimestamp } from './getBlockNumberOfTimestamp'
2
2
  export { getContractByAddress } from './getContractByAddress'
3
+ export { getContractCreations } from './getContractCreations'
3
4
  export { getErc1155TokenTransfersByAddress } from './getErc1155TokenTransfersByAddress'
4
5
  export { getErc20TokenTransfersByAddress } from './getErc20TokenTransfersByAddress'
5
6
  export { getErc721TokenTransfersByAddress } from './getErc721TokenTransfersByAddress'
@@ -16,6 +16,7 @@ export type Explorer = {
16
16
  logger?: Logger,
17
17
  ) => Promise<bigint>
18
18
  readonly getContract: FunctionGetContract
19
+ readonly getContractCreations: FunctionGetContractCreations
19
20
  readonly getInternalTransactionOfTransaction: FunctionGetInternalTransactionOfTransaction
20
21
  }
21
22
 
@@ -86,6 +87,17 @@ type FunctionGetContract = (
86
87
  | undefined
87
88
  >
88
89
 
90
+ type FunctionGetContractCreations = (
91
+ addresses: readonly Hex[],
92
+ logger?: Logger,
93
+ ) => Promise<
94
+ readonly {
95
+ readonly contractAddress: Hex
96
+ readonly contractCreator: Hex
97
+ readonly txHash: Hex
98
+ }[]
99
+ >
100
+
89
101
  type FunctionGetInternalTransactionOfTransaction = (parameters: {
90
102
  readonly hash: Hex
91
103
  readonly nativeCurrency: CryptoCurrency
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xtorch/evm",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "Cryptorch EVM extension",
5
5
  "keywords": [
6
6
  "cryptorch",