@effect-blockchain/evm 0.3.0 → 0.4.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.
- package/README.md +79 -1
- package/dist/EvmIndexer.d.ts +3 -9
- package/dist/EvmIndexer.d.ts.map +1 -1
- package/dist/EvmIndexer.js +27 -33
- package/dist/EvmIndexer.js.map +1 -1
- package/dist/EvmNetwork.d.ts.map +1 -1
- package/dist/EvmNetwork.js +8 -6
- package/dist/EvmNetwork.js.map +1 -1
- package/dist/EvmRelayer.d.ts +76 -20
- package/dist/EvmRelayer.d.ts.map +1 -1
- package/dist/EvmRelayer.js +96 -47
- package/dist/EvmRelayer.js.map +1 -1
- package/dist/EvmRpc.d.ts +5 -9
- package/dist/EvmRpc.d.ts.map +1 -1
- package/dist/EvmRpc.js +5 -9
- package/dist/EvmRpc.js.map +1 -1
- package/dist/EvmSigner.d.ts +6 -6
- package/dist/EvmSigner.d.ts.map +1 -1
- package/dist/EvmSigner.js +5 -7
- package/dist/EvmSigner.js.map +1 -1
- package/dist/internal/rpcMethods.js +11 -12
- package/dist/internal/rpcMethods.js.map +1 -1
- package/package.json +2 -2
- package/src/EvmIndexer.ts +31 -41
- package/src/EvmNetwork.ts +8 -6
- package/src/EvmRelayer.ts +132 -68
- package/src/EvmRpc.ts +5 -9
- package/src/EvmSigner.ts +7 -7
- package/src/internal/rpcMethods.ts +11 -13
- package/dist/internal/confirmations.d.ts +0 -2
- package/dist/internal/confirmations.d.ts.map +0 -1
- package/dist/internal/confirmations.js +0 -13
- package/dist/internal/confirmations.js.map +0 -1
- package/src/internal/confirmations.ts +0 -17
|
@@ -9,8 +9,6 @@ import { EvmTransaction, EvmTransactionReceipt } from "../EvmTransaction.ts"
|
|
|
9
9
|
import { EvmTransactionHash } from "../EvmTransactionHash.ts"
|
|
10
10
|
import { IntFromHex, QuantityFromHex } from "./QuantityFromHex.ts"
|
|
11
11
|
|
|
12
|
-
const make = <Params, Result>(method: JsonRpc.Method<Params, Result>): JsonRpc.Method<Params, Result> => method
|
|
13
|
-
|
|
14
12
|
const NoParams = Schema.Tuple([])
|
|
15
13
|
|
|
16
14
|
const Topics = Schema.Array(Schema.NullOr(Schema.Union([EvmHexData, Schema.Array(EvmHexData)])))
|
|
@@ -18,13 +16,13 @@ const Topics = Schema.Array(Schema.NullOr(Schema.Union([EvmHexData, Schema.Array
|
|
|
18
16
|
const BlockTag = Schema.Literals(["latest", "pending"])
|
|
19
17
|
|
|
20
18
|
/** @internal */
|
|
21
|
-
export const chainId =
|
|
19
|
+
export const chainId = JsonRpc.method({ name: "eth_chainId", params: NoParams, result: IntFromHex })
|
|
22
20
|
|
|
23
21
|
/** @internal */
|
|
24
|
-
export const blockNumber =
|
|
22
|
+
export const blockNumber = JsonRpc.method({ name: "eth_blockNumber", params: NoParams, result: QuantityFromHex })
|
|
25
23
|
|
|
26
24
|
/** @internal */
|
|
27
|
-
export const getBlockByNumber =
|
|
25
|
+
export const getBlockByNumber = JsonRpc.method({
|
|
28
26
|
name: "eth_getBlockByNumber",
|
|
29
27
|
// `false`: transaction hashes only, never the full transactions
|
|
30
28
|
params: Schema.Tuple([QuantityFromHex, Schema.Literal(false)]),
|
|
@@ -33,14 +31,14 @@ export const getBlockByNumber = make({
|
|
|
33
31
|
})
|
|
34
32
|
|
|
35
33
|
/** @internal */
|
|
36
|
-
export const getBalance =
|
|
34
|
+
export const getBalance = JsonRpc.method({
|
|
37
35
|
name: "eth_getBalance",
|
|
38
36
|
params: Schema.Tuple([EvmAddress, QuantityFromHex]),
|
|
39
37
|
result: QuantityFromHex
|
|
40
38
|
})
|
|
41
39
|
|
|
42
40
|
/** @internal */
|
|
43
|
-
export const getLogs =
|
|
41
|
+
export const getLogs = JsonRpc.method({
|
|
44
42
|
name: "eth_getLogs",
|
|
45
43
|
params: Schema.Tuple([
|
|
46
44
|
Schema.Struct({
|
|
@@ -55,7 +53,7 @@ export const getLogs = make({
|
|
|
55
53
|
})
|
|
56
54
|
|
|
57
55
|
/** @internal */
|
|
58
|
-
export const getTransactionByHash =
|
|
56
|
+
export const getTransactionByHash = JsonRpc.method({
|
|
59
57
|
name: "eth_getTransactionByHash",
|
|
60
58
|
params: Schema.Tuple([EvmTransactionHash]),
|
|
61
59
|
// `null` when the node does not know the transaction
|
|
@@ -63,7 +61,7 @@ export const getTransactionByHash = make({
|
|
|
63
61
|
})
|
|
64
62
|
|
|
65
63
|
/** @internal */
|
|
66
|
-
export const getTransactionReceipt =
|
|
64
|
+
export const getTransactionReceipt = JsonRpc.method({
|
|
67
65
|
name: "eth_getTransactionReceipt",
|
|
68
66
|
params: Schema.Tuple([EvmTransactionHash]),
|
|
69
67
|
// `null` until the transaction is in a block
|
|
@@ -71,21 +69,21 @@ export const getTransactionReceipt = make({
|
|
|
71
69
|
})
|
|
72
70
|
|
|
73
71
|
/** @internal */
|
|
74
|
-
export const sendRawTransaction =
|
|
72
|
+
export const sendRawTransaction = JsonRpc.method({
|
|
75
73
|
name: "eth_sendRawTransaction",
|
|
76
74
|
params: Schema.Tuple([EvmHexData]),
|
|
77
75
|
result: EvmTransactionHash
|
|
78
76
|
})
|
|
79
77
|
|
|
80
78
|
/** @internal */
|
|
81
|
-
export const getTransactionCount =
|
|
79
|
+
export const getTransactionCount = JsonRpc.method({
|
|
82
80
|
name: "eth_getTransactionCount",
|
|
83
81
|
params: Schema.Tuple([EvmAddress, BlockTag]),
|
|
84
82
|
result: QuantityFromHex
|
|
85
83
|
})
|
|
86
84
|
|
|
87
85
|
/** @internal */
|
|
88
|
-
export const estimateGas =
|
|
86
|
+
export const estimateGas = JsonRpc.method({
|
|
89
87
|
name: "eth_estimateGas",
|
|
90
88
|
params: Schema.Tuple([
|
|
91
89
|
Schema.Struct({
|
|
@@ -99,7 +97,7 @@ export const estimateGas = make({
|
|
|
99
97
|
})
|
|
100
98
|
|
|
101
99
|
/** @internal */
|
|
102
|
-
export const feeHistory =
|
|
100
|
+
export const feeHistory = JsonRpc.method({
|
|
103
101
|
name: "eth_feeHistory",
|
|
104
102
|
params: Schema.Tuple([IntFromHex, BlockTag, Schema.Array(Schema.Number)]),
|
|
105
103
|
result: EvmFeeHistory
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"confirmations.d.ts","sourceRoot":"","sources":["../../src/internal/confirmations.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as BigInt_ from "effect/BigInt";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as EvmNetwork from "../EvmNetwork.js";
|
|
4
|
-
/**
|
|
5
|
-
* The head block number minus `confirmations` (the network's default when unset), never below 0.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export const lastConfirmedBlock = (rpc, confirmations) => {
|
|
10
|
-
const depth = BigInt(confirmations ?? EvmNetwork.defaultConfirmations(rpc.network));
|
|
11
|
-
return Effect.map(rpc.blockNumber, head => BigInt_.max(head - depth, BigInt(0)));
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=confirmations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"confirmations.js","names":[],"sources":["../../src/internal/confirmations.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,UAAU,MAAM,kBAAkB;AAG9C;;;;;AAKA,OAAO,MAAM,kBAAkB,GAAG,CAChC,GAA6B,EAC7B,aAAiC,KACY;EAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,IAAI,UAAU,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;EACnF,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAG,IAAI,IAAK,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as BigInt_ from "effect/BigInt"
|
|
2
|
-
import * as Effect from "effect/Effect"
|
|
3
|
-
import * as EvmNetwork from "../EvmNetwork.ts"
|
|
4
|
-
import type * as EvmRpc from "../EvmRpc.ts"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The head block number minus `confirmations` (the network's default when unset), never below 0.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export const lastConfirmedBlock = (
|
|
12
|
-
rpc: EvmRpc.EvmRpc["Service"],
|
|
13
|
-
confirmations: number | undefined
|
|
14
|
-
): Effect.Effect<bigint, EvmRpc.EvmRpcError> => {
|
|
15
|
-
const depth = BigInt(confirmations ?? EvmNetwork.defaultConfirmations(rpc.network))
|
|
16
|
-
return Effect.map(rpc.blockNumber, (head) => BigInt_.max(head - depth, BigInt(0)))
|
|
17
|
-
}
|