@effect-blockchain/evm 0.0.0-stage → 0.2.0

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/EvmAddress.d.ts +33 -0
  4. package/dist/EvmAddress.d.ts.map +1 -0
  5. package/dist/EvmAddress.js +43 -0
  6. package/dist/EvmAddress.js.map +1 -0
  7. package/dist/EvmBlock.d.ts +25 -0
  8. package/dist/EvmBlock.d.ts.map +1 -0
  9. package/dist/EvmBlock.js +25 -0
  10. package/dist/EvmBlock.js.map +1 -0
  11. package/dist/EvmHexData.d.ts +19 -0
  12. package/dist/EvmHexData.d.ts.map +1 -0
  13. package/dist/EvmHexData.js +31 -0
  14. package/dist/EvmHexData.js.map +1 -0
  15. package/dist/EvmIndexer.d.ts +115 -0
  16. package/dist/EvmIndexer.d.ts.map +1 -0
  17. package/dist/EvmIndexer.js +153 -0
  18. package/dist/EvmIndexer.js.map +1 -0
  19. package/dist/EvmLog.d.ts +32 -0
  20. package/dist/EvmLog.d.ts.map +1 -0
  21. package/dist/EvmLog.js +34 -0
  22. package/dist/EvmLog.js.map +1 -0
  23. package/dist/EvmNetwork.d.ts +74 -0
  24. package/dist/EvmNetwork.d.ts.map +1 -0
  25. package/dist/EvmNetwork.js +128 -0
  26. package/dist/EvmNetwork.js.map +1 -0
  27. package/dist/EvmRpc.d.ts +154 -0
  28. package/dist/EvmRpc.d.ts.map +1 -0
  29. package/dist/EvmRpc.js +174 -0
  30. package/dist/EvmRpc.js.map +1 -0
  31. package/dist/EvmTransactionHash.d.ts +19 -0
  32. package/dist/EvmTransactionHash.d.ts.map +1 -0
  33. package/dist/EvmTransactionHash.js +29 -0
  34. package/dist/EvmTransactionHash.js.map +1 -0
  35. package/dist/index.d.ts +36 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +37 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/internal/QuantityFromHex.d.ts +2 -0
  40. package/dist/internal/QuantityFromHex.d.ts.map +1 -0
  41. package/dist/internal/QuantityFromHex.js +23 -0
  42. package/dist/internal/QuantityFromHex.js.map +1 -0
  43. package/dist/internal/rpcMethods.d.ts +2 -0
  44. package/dist/internal/rpcMethods.d.ts.map +1 -0
  45. package/dist/internal/rpcMethods.js +46 -0
  46. package/dist/internal/rpcMethods.js.map +1 -0
  47. package/package.json +70 -3
  48. package/src/EvmAddress.ts +53 -0
  49. package/src/EvmBlock.ts +28 -0
  50. package/src/EvmHexData.ts +39 -0
  51. package/src/EvmIndexer.ts +222 -0
  52. package/src/EvmLog.ts +37 -0
  53. package/src/EvmNetwork.ts +176 -0
  54. package/src/EvmRpc.ts +272 -0
  55. package/src/EvmTransactionHash.ts +36 -0
  56. package/src/index.ts +45 -0
  57. package/src/internal/QuantityFromHex.ts +24 -0
  58. package/src/internal/rpcMethods.ts +43 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Spiko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # `@effect-blockchain/evm`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ EVM blockchain toolkit for Effect.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @effect-blockchain/evm effect viem
9
+ ```
10
+
11
+ ## License
12
+
13
+ MIT
@@ -0,0 +1,33 @@
1
+ /**
2
+ * EVM account and contract addresses.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ /**
8
+ * An EVM address, decoded from any casing (including EIP-55 checksummed) and stored lowercase.
9
+ *
10
+ * @since 0.1.0
11
+ * @category schemas
12
+ */
13
+ export declare const EvmAddress: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmAddress">;
14
+ /**
15
+ * @since 0.1.0
16
+ * @category models
17
+ */
18
+ export type EvmAddress = typeof EvmAddress.Type;
19
+ /**
20
+ * The zero address `0x0000000000000000000000000000000000000000`, used as the mint source and burn target of tokens.
21
+ *
22
+ * @since 0.1.0
23
+ * @category constants
24
+ */
25
+ export declare const NULL_ADDRESS: EvmAddress;
26
+ /**
27
+ * Returns the EIP-55 mixed-case checksum form of an address, e.g. for display.
28
+ *
29
+ * @since 0.1.0
30
+ * @category conversions
31
+ */
32
+ export declare const toEip55: (address: EvmAddress) => string;
33
+ //# sourceMappingURL=EvmAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmAddress.d.ts","sourceRoot":"","sources":["../src/EvmAddress.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAMvC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,uHAatB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,UAA0E,CAAA;AAErG;;;;;GAKG;AACH,eAAO,MAAM,OAAO,YAAa,UAAU,KAAG,MAA6B,CAAA"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * EVM account and contract addresses.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import * as SchemaTransformation from "effect/SchemaTransformation";
8
+ import { getAddress, isAddress } from "viem";
9
+ const evmAddressRegex = /^0x[a-f0-9]{40}$/;
10
+ /**
11
+ * An EVM address, decoded from any casing (including EIP-55 checksummed) and stored lowercase.
12
+ *
13
+ * @since 0.1.0
14
+ * @category schemas
15
+ */
16
+ export const EvmAddress = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.decodeTo(/*#__PURE__*/Schema.String.check(/*#__PURE__*/Schema.isLowercased()), /*#__PURE__*/SchemaTransformation.toLowerCase()), /*#__PURE__*/Schema.refine(address => isAddress(address), {
17
+ expected: "a valid EVM address",
18
+ arbitraryConstraint: {
19
+ patterns: [{
20
+ source: evmAddressRegex.source,
21
+ flags: ""
22
+ }]
23
+ }
24
+ }), /*#__PURE__*/Schema.brand("EvmAddress"), /*#__PURE__*/Schema.annotate({
25
+ identifier: "EvmAddress",
26
+ title: "EVM address",
27
+ description: "a valid EVM address, starting with 0x and followed by 40 hexadecimal characters e.g. \"0xb794f5ea0ba39494ce839613fffba74279579268\""
28
+ }));
29
+ /**
30
+ * The zero address `0x0000000000000000000000000000000000000000`, used as the mint source and burn target of tokens.
31
+ *
32
+ * @since 0.1.0
33
+ * @category constants
34
+ */
35
+ export const NULL_ADDRESS = /*#__PURE__*/EvmAddress.make("0x0000000000000000000000000000000000000000");
36
+ /**
37
+ * Returns the EIP-55 mixed-case checksum form of an address, e.g. for display.
38
+ *
39
+ * @since 0.1.0
40
+ * @category conversions
41
+ */
42
+ export const toEip55 = address => getAddress(address);
43
+ //# sourceMappingURL=EvmAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmAddress.js","names":[],"sources":["../src/EvmAddress.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAKA,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,oBAAoB,MAAM,6BAA6B;AACnE,SAAS,UAAU,EAAE,SAAS,QAAQ,MAAM;AAE5C,MAAM,eAAe,GAAG,kBAAkB;AAE1C;;;;;;AAMA,OAAO,MAAM,UAAU,gBAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAC1C,MAAM,CAAC,QAAQ,cAAC,MAAM,CAAC,MAAM,CAAC,KAAK,cAAC,MAAM,CAAC,YAAY,EAAE,CAAC,eAAE,oBAAoB,CAAC,WAAW,EAAE,CAAC,eAC/F,MAAM,CAAC,MAAM,CAAE,OAAe,IAA+B,SAAS,CAAC,OAAO,CAAC,EAAE;EAC/E,QAAQ,EAAE,qBAAqB;EAC/B,mBAAmB,EAAE;IAAE,QAAQ,EAAE,CAAC;MAAE,MAAM,EAAE,eAAe,CAAC,MAAM;MAAE,KAAK,EAAE;IAAE,CAAE;EAAC;CACjF,CAAC,eACF,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,eAC1B,MAAM,CAAC,QAAQ,CAAC;EACd,UAAU,EAAE,YAAY;EACxB,KAAK,EAAE,aAAa;EACpB,WAAW,EACT;CACH,CAAC,CACH;AAQD;;;;;;AAMA,OAAO,MAAM,YAAY,gBAAe,UAAU,CAAC,IAAI,CAAC,4CAA4C,CAAC;AAErG;;;;;;AAMA,OAAO,MAAM,OAAO,GAAI,OAAmB,IAAa,UAAU,CAAC,OAAO,CAAC","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * EVM block headers, as returned by `eth_getBlockByNumber`.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ /**
8
+ * The header fields of a mined block, decoded from the raw JSON-RPC block with hex quantities (`"0x10"`) as `bigint`.
9
+ * Every other field is ignored. `timestamp` is in Unix seconds.
10
+ *
11
+ * @since 0.1.0
12
+ * @category schemas
13
+ */
14
+ export declare const EvmBlock: Schema.Struct<{
15
+ readonly number: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
16
+ readonly hash: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmHexData">;
17
+ readonly parentHash: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmHexData">;
18
+ readonly timestamp: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
19
+ }>;
20
+ /**
21
+ * @since 0.1.0
22
+ * @category models
23
+ */
24
+ export type EvmBlock = typeof EvmBlock.Type;
25
+ //# sourceMappingURL=EvmBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmBlock.d.ts","sourceRoot":"","sources":["../src/EvmBlock.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ;;;;;EAKsC,CAAA;AAE3D;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * EVM block headers, as returned by `eth_getBlockByNumber`.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import { EvmHexData } from "./EvmHexData.js";
8
+ import { QuantityFromHex } from "./internal/QuantityFromHex.js";
9
+ /**
10
+ * The header fields of a mined block, decoded from the raw JSON-RPC block with hex quantities (`"0x10"`) as `bigint`.
11
+ * Every other field is ignored. `timestamp` is in Unix seconds.
12
+ *
13
+ * @since 0.1.0
14
+ * @category schemas
15
+ */
16
+ export const EvmBlock = /*#__PURE__*/Schema.Struct({
17
+ number: QuantityFromHex,
18
+ hash: EvmHexData,
19
+ parentHash: EvmHexData,
20
+ timestamp: QuantityFromHex
21
+ }).annotate({
22
+ identifier: "EvmBlock",
23
+ title: "EVM block"
24
+ });
25
+ //# sourceMappingURL=EvmBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmBlock.js","names":[],"sources":["../src/EvmBlock.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAKA,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,UAAU,QAAQ,iBAAiB;AAC5C,SAAS,eAAe,QAAQ,+BAA+B;AAE/D;;;;;;;AAOA,OAAO,MAAM,QAAQ,gBAAG,MAAM,CAAC,MAAM,CAAC;EACpC,MAAM,EAAE,eAAe;EACvB,IAAI,EAAE,UAAU;EAChB,UAAU,EAAE,UAAU;EACtB,SAAS,EAAE;CACZ,CAAC,CAAC,QAAQ,CAAC;EAAE,UAAU,EAAE,UAAU;EAAE,KAAK,EAAE;AAAW,CAAE,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Raw EVM hex data such as calldata, return data or event payloads.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ /**
8
+ * An even-length 0x-prefixed hex string (`0x` alone is the empty payload), stored lowercase.
9
+ *
10
+ * @since 0.1.0
11
+ * @category schemas
12
+ */
13
+ export declare const EvmHexData: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmHexData">;
14
+ /**
15
+ * @since 0.1.0
16
+ * @category models
17
+ */
18
+ export type EvmHexData = typeof EvmHexData.Type;
19
+ //# sourceMappingURL=EvmHexData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmHexData.d.ts","sourceRoot":"","sources":["../src/EvmHexData.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAMvC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,uHAetB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Raw EVM hex data such as calldata, return data or event payloads.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import * as SchemaTransformation from "effect/SchemaTransformation";
8
+ import { isHex } from "viem";
9
+ const evmHexDataRegex = /^0x(?:[a-f0-9]{2})*$/;
10
+ /**
11
+ * An even-length 0x-prefixed hex string (`0x` alone is the empty payload), stored lowercase.
12
+ *
13
+ * @since 0.1.0
14
+ * @category schemas
15
+ */
16
+ export const EvmHexData = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.decodeTo(/*#__PURE__*/Schema.String.check(/*#__PURE__*/Schema.isLowercased()), /*#__PURE__*/SchemaTransformation.toLowerCase()), /*#__PURE__*/Schema.refine(value => isHex(value, {
17
+ strict: true
18
+ }) && value.length % 2 === 0, {
19
+ expected: "an even-length 0x-prefixed hex string",
20
+ arbitraryConstraint: {
21
+ patterns: [{
22
+ source: evmHexDataRegex.source,
23
+ flags: ""
24
+ }]
25
+ }
26
+ }), /*#__PURE__*/Schema.brand("EvmHexData"), /*#__PURE__*/Schema.annotate({
27
+ identifier: "EvmHexData",
28
+ title: "EVM hex data",
29
+ description: "an even-length 0x-prefixed hex string e.g. \"0xa9059cbb\""
30
+ }));
31
+ //# sourceMappingURL=EvmHexData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmHexData.js","names":[],"sources":["../src/EvmHexData.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAKA,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,oBAAoB,MAAM,6BAA6B;AACnE,SAAS,KAAK,QAAQ,MAAM;AAE5B,MAAM,eAAe,GAAG,sBAAsB;AAE9C;;;;;;AAMA,OAAO,MAAM,UAAU,gBAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAC1C,MAAM,CAAC,QAAQ,cAAC,MAAM,CAAC,MAAM,CAAC,KAAK,cAAC,MAAM,CAAC,YAAY,EAAE,CAAC,eAAE,oBAAoB,CAAC,WAAW,EAAE,CAAC,eAC/F,MAAM,CAAC,MAAM,CACV,KAAa,IAA6B,KAAK,CAAC,KAAK,EAAE;EAAE,MAAM,EAAE;AAAI,CAAE,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EACnG;EACE,QAAQ,EAAE,uCAAuC;EACjD,mBAAmB,EAAE;IAAE,QAAQ,EAAE,CAAC;MAAE,MAAM,EAAE,eAAe,CAAC,MAAM;MAAE,KAAK,EAAE;IAAE,CAAE;EAAC;CACjF,CACF,eACD,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,eAC1B,MAAM,CAAC,QAAQ,CAAC;EACd,UAAU,EAAE,YAAY;EACxB,KAAK,EAAE,cAAc;EACrB,WAAW,EAAE;CACd,CAAC,CACH","ignoreList":[]}
@@ -0,0 +1,115 @@
1
+ import * as Config from "effect/Config";
2
+ import * as Context from "effect/Context";
3
+ import * as Duration from "effect/Duration";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Schedule from "effect/Schedule";
7
+ import * as Stream from "effect/Stream";
8
+ import type { EvmLog } from "./EvmLog.ts";
9
+ import * as EvmRpc from "./EvmRpc.ts";
10
+ /**
11
+ * A {@link EvmIndexer} `fetchLogs` filter: an `eth_getLogs` filter over the inclusive block range
12
+ * `[fromBlock, toBlock]`.
13
+ *
14
+ * @since 0.1.0
15
+ * @category models
16
+ */
17
+ export type EvmIndexerFilter = EvmRpc.EvmLogsFilter;
18
+ /**
19
+ * The logs of `[fromBlock, toBlock]` (both inclusive), in chain order, emitted by
20
+ * {@link EvmIndexer.Service.streamLogs}.
21
+ *
22
+ * A batch is emitted for every range, even without logs. Delivery is at-least-once: save `batch.toBlock` once the
23
+ * batch is handled and resume from `toBlock + 1`.
24
+ *
25
+ * @since 0.1.0
26
+ * @category models
27
+ */
28
+ export interface EvmIndexerBatch {
29
+ readonly fromBlock: bigint;
30
+ readonly toBlock: bigint;
31
+ readonly logs: ReadonlyArray<EvmLog>;
32
+ }
33
+ /**
34
+ * The {@link EvmIndexer.Service.streamLogs} options.
35
+ *
36
+ * @since 0.1.0
37
+ * @category models
38
+ */
39
+ export interface EvmIndexerStreamOptions {
40
+ readonly filter: Omit<EvmIndexerFilter, "fromBlock" | "toBlock">;
41
+ readonly fromBlock: bigint;
42
+ /** The stream ends after the batch reaching it, and is empty when `fromBlock > toBlock`. */
43
+ readonly toBlock?: bigint | undefined;
44
+ /**
45
+ * When to read the head again once caught up, `Schedule.spaced(DEFAULT_POLL_INTERVAL)` by default. It restarts after
46
+ * each batch, and its end ends the stream: `Schedule.recurs(0)` drains to the head and stops.
47
+ */
48
+ readonly poll?: Schedule.Schedule<unknown> | undefined;
49
+ /** Retries a step failing with a transient reason ({@link JsonRpc.isTransient}) at the same block. Off by default. */
50
+ readonly retry?: Schedule.Schedule<unknown, EvmRpc.EvmRpcError> | undefined;
51
+ }
52
+ declare const EvmIndexer_base: Context.ServiceClass<EvmIndexer, "@effect-blockchain/evm/EvmIndexer", {
53
+ /** The head block number minus the confirmations, never below 0. */
54
+ readonly lastConfirmedBlock: Effect.Effect<bigint, EvmRpc.EvmRpcError>;
55
+ /**
56
+ * The logs matching `filter` between `fromBlock` and `toBlock` (both inclusive), in chain order: sorted by block
57
+ * then log index. `fromBlock > toBlock` returns `[]`. A `toBlock` above {@link lastConfirmedBlock} is accepted.
58
+ */
59
+ readonly fetchLogs: (filter: EvmIndexerFilter) => Effect.Effect<ReadonlyArray<EvmLog>, EvmRpc.EvmRpcError>;
60
+ /**
61
+ * The logs matching `filter` from `fromBlock` on, in batches of at most `maxBlockRange` confirmed blocks, following
62
+ * the confirmed head.
63
+ */
64
+ readonly streamLogs: (options: EvmIndexerStreamOptions) => Stream.Stream<EvmIndexerBatch, EvmRpc.EvmRpcError>;
65
+ }>;
66
+ /**
67
+ * @since 0.1.0
68
+ * @category services
69
+ */
70
+ export declare class EvmIndexer extends EvmIndexer_base {
71
+ }
72
+ /**
73
+ * The default `maxBlockRange`: most RPC providers accept `eth_getLogs` over 1000 blocks, lower it for stricter ones.
74
+ *
75
+ * @since 0.1.0
76
+ * @category constants
77
+ */
78
+ export declare const DEFAULT_MAX_BLOCK_RANGE = 1000;
79
+ /**
80
+ * The default `poll` spacing of {@link EvmIndexer.Service.streamLogs}: 10 seconds.
81
+ *
82
+ * @since 0.1.0
83
+ * @category constants
84
+ */
85
+ export declare const DEFAULT_POLL_INTERVAL: Duration.Duration;
86
+ /**
87
+ * Builds an {@link EvmIndexer} reading through the provided {@link EvmRpc.EvmRpc}.
88
+ *
89
+ * - `confirmations` overrides {@link EvmNetwork.defaultConfirmations} for the RPC's network.
90
+ * - `maxBlockRange`, a positive integer, defaults to {@link DEFAULT_MAX_BLOCK_RANGE}.
91
+ *
92
+ * @since 0.1.0
93
+ * @category layers
94
+ */
95
+ export declare const layer: (options?: {
96
+ readonly confirmations?: number | undefined;
97
+ readonly maxBlockRange?: number | undefined;
98
+ }) => Layer.Layer<EvmIndexer, never, EvmRpc.EvmRpc>;
99
+ /**
100
+ * Builds an {@link EvmIndexer} like {@link layer}, reading the options from `Config`.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import * as EvmIndexer from "@effect-blockchain/evm/EvmIndexer"
105
+ * import * as Config from "effect/Config"
106
+ *
107
+ * const IndexerLive = EvmIndexer.layerConfig({ confirmations: Config.Int("ETHEREUM_CONFIRMATIONS") })
108
+ * ```
109
+ *
110
+ * @since 0.1.0
111
+ * @category layers
112
+ */
113
+ export declare const layerConfig: (options: Config.Wrap<NonNullable<Parameters<typeof layer>[0]>>) => Layer.Layer<EvmIndexer, Config.ConfigError, EvmRpc.EvmRpc>;
114
+ export {};
115
+ //# sourceMappingURL=EvmIndexer.d.ts.map
@@ -0,0 +1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AC,GAAG,SAAS,CAAA;CAC5E;;IAOC,oEAAoE;iCACvC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;IACtE;;;OAGG;wBACiB,CAAC,MAAM,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC1G;;;OAGG;yBACkB,CAAC,OAAO,EAAE,uBAAuB,KAAK,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC;;AAhB/G;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAaS;CAAG;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,QAA+B,CAAA;AAQ5E;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK,aAAa;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5C,KAAQ,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CA2DlD,CAAA;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,YACb,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAC7D,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAA4D,CAAA"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * EVM log indexing on top of {@link EvmRpc.EvmRpc}: the last confirmed block, the logs of a set of contracts over a
3
+ * block range, and a stream of them following the confirmed head.
4
+ *
5
+ * A range is split into ranges of at most `maxBlockRange` blocks, one `eth_getLogs` after another. A failing range
6
+ * fails the whole call and drops the logs already read: the caller retries the same range.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import type { EvmIndexerFilter } from "@effect-blockchain/evm/EvmIndexer"
11
+ * import { EvmIndexer } from "@effect-blockchain/evm/EvmIndexer"
12
+ * import * as Effect from "effect/Effect"
13
+ * import * as Schedule from "effect/Schedule"
14
+ * import * as Stream from "effect/Stream"
15
+ *
16
+ * declare const filter: Omit<EvmIndexerFilter, "fromBlock" | "toBlock">
17
+ * declare const cursor: bigint
18
+ * declare const save: (block: bigint) => Effect.Effect<void>
19
+ *
20
+ * const program = Effect.gen(function*() {
21
+ * const indexer = yield* EvmIndexer
22
+ * // once caught up, read the head after 1 s, 2 s, 4 s... at most every minute
23
+ * const poll = Schedule.min([Schedule.exponential("1 second"), Schedule.spaced("1 minute")])
24
+ * yield* indexer.streamLogs({ filter, fromBlock: cursor + BigInt(1), poll }).pipe(
25
+ * Stream.runForEach((batch) => save(batch.toBlock))
26
+ * )
27
+ * })
28
+ * ```
29
+ *
30
+ * @since 0.1.0
31
+ */
32
+ import * as JsonRpc from "@effect-blockchain/core/JsonRpc";
33
+ import * as Arr from "effect/Array";
34
+ import * as BigInt_ from "effect/BigInt";
35
+ import * as Config from "effect/Config";
36
+ import * as Context from "effect/Context";
37
+ import * as Duration from "effect/Duration";
38
+ import * as Effect from "effect/Effect";
39
+ import * as Layer from "effect/Layer";
40
+ import * as Option from "effect/Option";
41
+ import * as Schedule from "effect/Schedule";
42
+ import * as Stream from "effect/Stream";
43
+ import * as EvmNetwork from "./EvmNetwork.js";
44
+ import * as EvmRpc from "./EvmRpc.js";
45
+ /**
46
+ * @since 0.1.0
47
+ * @category services
48
+ */
49
+ export class EvmIndexer extends /*#__PURE__*/Context.Service()("@effect-blockchain/evm/EvmIndexer") {}
50
+ /**
51
+ * The default `maxBlockRange`: most RPC providers accept `eth_getLogs` over 1000 blocks, lower it for stricter ones.
52
+ *
53
+ * @since 0.1.0
54
+ * @category constants
55
+ */
56
+ export const DEFAULT_MAX_BLOCK_RANGE = 1000;
57
+ /**
58
+ * The default `poll` spacing of {@link EvmIndexer.Service.streamLogs}: 10 seconds.
59
+ *
60
+ * @since 0.1.0
61
+ * @category constants
62
+ */
63
+ export const DEFAULT_POLL_INTERVAL = /*#__PURE__*/Duration.seconds(10);
64
+ /**
65
+ * Builds an {@link EvmIndexer} reading through the provided {@link EvmRpc.EvmRpc}.
66
+ *
67
+ * - `confirmations` overrides {@link EvmNetwork.defaultConfirmations} for the RPC's network.
68
+ * - `maxBlockRange`, a positive integer, defaults to {@link DEFAULT_MAX_BLOCK_RANGE}.
69
+ *
70
+ * @since 0.1.0
71
+ * @category layers
72
+ */
73
+ export const layer = (options = {}) => Layer.effect(EvmIndexer, Effect.gen(function* () {
74
+ const rpc = yield* EvmRpc.EvmRpc;
75
+ const maxBlockRange = options.maxBlockRange ?? DEFAULT_MAX_BLOCK_RANGE;
76
+ if (!Number.isSafeInteger(maxBlockRange) || maxBlockRange < 1) {
77
+ return yield* Effect.die(new RangeError(`maxBlockRange must be a positive integer, got ${maxBlockRange}`));
78
+ }
79
+ const confirmations = BigInt(options.confirmations ?? EvmNetwork.defaultConfirmations(rpc.network));
80
+ const size = BigInt(maxBlockRange);
81
+ const lastConfirmedBlock = rpc.blockNumber.pipe(Effect.map(head => BigInt_.max(head - confirmations, BigInt(0))), Effect.withSpan("EvmIndexer.lastConfirmedBlock"));
82
+ const fetchLogs = Effect.fn("EvmIndexer.fetchLogs")(filter => {
83
+ if (filter.fromBlock > filter.toBlock) return Effect.succeed([]);
84
+ const count = Number((filter.toBlock - filter.fromBlock) / size) + 1;
85
+ return Effect.forEach(Arr.makeBy(count, i => filter.fromBlock + BigInt(i) * size), fromBlock => rpc.getLogs({
86
+ ...filter,
87
+ fromBlock,
88
+ toBlock: BigInt_.min(fromBlock + size - BigInt(1), filter.toBlock)
89
+ })).pipe(Effect.map(Arr.flatten));
90
+ });
91
+ return EvmIndexer.of({
92
+ lastConfirmedBlock,
93
+ fetchLogs,
94
+ streamLogs: ({
95
+ filter,
96
+ fromBlock,
97
+ poll = Schedule.spaced(DEFAULT_POLL_INTERVAL),
98
+ retry,
99
+ toBlock
100
+ }) => {
101
+ if (toBlock !== undefined && fromBlock > toBlock) return Stream.empty;
102
+ // the head last read is reused while it covers `next` (the confirmed head only moves forward), else polled
103
+ const step = ({
104
+ head,
105
+ next
106
+ }) => (next <= head ? Effect.succeed(head) : lastConfirmedBlock.pipe(Effect.repeat({
107
+ schedule: poll,
108
+ until: confirmed => confirmed >= next
109
+ }))).pipe(Effect.flatMap(confirmed => {
110
+ const cap = toBlock === undefined ? confirmed : BigInt_.min(confirmed, toBlock);
111
+ if (next > cap) return Effect.succeed([[], Option.none()]);
112
+ const end = BigInt_.min(next + size - BigInt(1), cap);
113
+ return fetchLogs({
114
+ ...filter,
115
+ fromBlock: next,
116
+ toBlock: end
117
+ }).pipe(Effect.map(logs => [[{
118
+ fromBlock: next,
119
+ toBlock: end,
120
+ logs
121
+ }], end === toBlock ? Option.none() : Option.some({
122
+ next: end + BigInt(1),
123
+ head: confirmed
124
+ })]));
125
+ }));
126
+ return Stream.paginate(
127
+ // a head below `fromBlock`: the first step reads it
128
+ {
129
+ next: fromBlock,
130
+ head: fromBlock - BigInt(1)
131
+ }, retry === undefined ? step : remaining => Effect.retry(step(remaining), {
132
+ schedule: retry,
133
+ while: error => JsonRpc.isTransient(error.reason)
134
+ }));
135
+ }
136
+ });
137
+ }));
138
+ /**
139
+ * Builds an {@link EvmIndexer} like {@link layer}, reading the options from `Config`.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import * as EvmIndexer from "@effect-blockchain/evm/EvmIndexer"
144
+ * import * as Config from "effect/Config"
145
+ *
146
+ * const IndexerLive = EvmIndexer.layerConfig({ confirmations: Config.Int("ETHEREUM_CONFIRMATIONS") })
147
+ * ```
148
+ *
149
+ * @since 0.1.0
150
+ * @category layers
151
+ */
152
+ export const layerConfig = options => Layer.unwrap(Effect.map(Config.unwrap(options), layer));
153
+ //# sourceMappingURL=EvmIndexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmIndexer.js","names":[],"sources":["../src/EvmIndexer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,OAAO,KAAK,OAAO,MAAM,iCAAiC;AAC1D,OAAO,KAAK,GAAG,MAAM,cAAc;AACnC,OAAO,KAAK,OAAO,MAAM,eAAe;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAC7C,OAAO,KAAK,MAAM,MAAM,aAAa;AA+CrC;;;;AAIA,OAAM,MAAO,UAAW,sBAAQ,OAAO,CAAC,OAAO,EAa3C,CAAC,mCAAmC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAM,uBAAuB,GAAG,IAAI;AAE3C;;;;;;AAMA,OAAO,MAAM,qBAAqB,gBAAsB,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;AAQ5E;;;;;;;;;AASA,OAAO,MAAM,KAAK,GAAG,CAAC,OAAO,GAGzB,EAAE,KACJ,KAAK,CAAC,MAAM,CACV,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,aAAS;EAClB,MAAM,GAAG,GAAG,OAAO,MAAM,CAAC,MAAM;EAChC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,uBAAuB;EACtE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,aAAa,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AAI,CAAE,CAAC,EACzC,GAAG,KAAK,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;UAAE,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;UAAE,IAAI,EAAE;QAAS,CAAE,CAAC,CAC1F,CAAC,CAAC;MACL,CAAC,CAAC,CAAC;MACP,OAAO,MAAM,CAAC,QAAQ;MACpB;MACA;QAAE,IAAI,EAAE,SAAS;QAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,CAAC;MAAC,CAAE,EAChD,KAAK,KAAK,SAAS,GACf,IAAI,GACH,SAAS,IACV,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,KAAK;QAAE,KAAK,EAAG,KAAK,IAAK,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM;MAAC,CAAE,CAAC,CAC5G;IACH;GACD,CAAC;AACJ,CAAC,CAAC,CACH;AAEH;;;;;;;;;;;;;;AAcA,OAAO,MAAM,WAAW,GACtB,OAA8D,IACC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * EVM event logs, as returned by `eth_getLogs`.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ /**
8
+ * A log emitted by a contract in a mined block, decoded from the raw JSON-RPC log: quantities are hex strings on the
9
+ * encoded side (`"0x10"`) and `bigint` / `number` on the decoded side.
10
+ *
11
+ * A pending log (null block or transaction fields) does not decode. `logIndex` is the position of the log in its
12
+ * block (EVM log indexes are per block, not per transaction).
13
+ *
14
+ * @since 0.1.0
15
+ * @category schemas
16
+ */
17
+ export declare const EvmLog: Schema.Struct<{
18
+ readonly address: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmAddress">;
19
+ readonly topics: Schema.$Array<Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmHexData">>;
20
+ readonly data: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmHexData">;
21
+ readonly blockNumber: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
22
+ readonly blockHash: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmHexData">;
23
+ readonly transactionHash: Schema.brand<Schema.refine<`0x${string}`, Schema.decodeTo<Schema.String, Schema.String, never, never>>, "EvmTransactionHash">;
24
+ readonly transactionIndex: Schema.decodeTo<Schema.Int, Schema.String, never, never>;
25
+ readonly logIndex: Schema.decodeTo<Schema.Int, Schema.String, never, never>;
26
+ }>;
27
+ /**
28
+ * @since 0.1.0
29
+ * @category models
30
+ */
31
+ export type EvmLog = typeof EvmLog.Type;
32
+ //# sourceMappingURL=EvmLog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmLog.d.ts","sourceRoot":"","sources":["../src/EvmLog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAMvC;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM;;;;;;;;;EASoC,CAAA;AAEvD;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA"}
package/dist/EvmLog.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * EVM event logs, as returned by `eth_getLogs`.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import { EvmAddress } from "./EvmAddress.js";
8
+ import { EvmHexData } from "./EvmHexData.js";
9
+ import { EvmTransactionHash } from "./EvmTransactionHash.js";
10
+ import { IntFromHex, QuantityFromHex } from "./internal/QuantityFromHex.js";
11
+ /**
12
+ * A log emitted by a contract in a mined block, decoded from the raw JSON-RPC log: quantities are hex strings on the
13
+ * encoded side (`"0x10"`) and `bigint` / `number` on the decoded side.
14
+ *
15
+ * A pending log (null block or transaction fields) does not decode. `logIndex` is the position of the log in its
16
+ * block (EVM log indexes are per block, not per transaction).
17
+ *
18
+ * @since 0.1.0
19
+ * @category schemas
20
+ */
21
+ export const EvmLog = /*#__PURE__*/Schema.Struct({
22
+ address: EvmAddress,
23
+ topics: Schema.Array(EvmHexData),
24
+ data: EvmHexData,
25
+ blockNumber: QuantityFromHex,
26
+ blockHash: EvmHexData,
27
+ transactionHash: EvmTransactionHash,
28
+ transactionIndex: IntFromHex,
29
+ logIndex: IntFromHex
30
+ }).annotate({
31
+ identifier: "EvmLog",
32
+ title: "EVM log"
33
+ });
34
+ //# sourceMappingURL=EvmLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EvmLog.js","names":[],"sources":["../src/EvmLog.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAKA,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,UAAU,QAAQ,iBAAiB;AAC5C,SAAS,UAAU,QAAQ,iBAAiB;AAC5C,SAAS,kBAAkB,QAAQ,yBAAyB;AAC5D,SAAS,UAAU,EAAE,eAAe,QAAQ,+BAA+B;AAE3E;;;;;;;;;;AAUA,OAAO,MAAM,MAAM,gBAAG,MAAM,CAAC,MAAM,CAAC;EAClC,OAAO,EAAE,UAAU;EACnB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;EAChC,IAAI,EAAE,UAAU;EAChB,WAAW,EAAE,eAAe;EAC5B,SAAS,EAAE,UAAU;EACrB,eAAe,EAAE,kBAAkB;EACnC,gBAAgB,EAAE,UAAU;EAC5B,QAAQ,EAAE;CACX,CAAC,CAAC,QAAQ,CAAC;EAAE,UAAU,EAAE,QAAQ;EAAE,KAAK,EAAE;AAAS,CAAE,CAAC","ignoreList":[]}