@webevm/devnode 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +219 -2
- package/dist/accounts.d.ts +82 -0
- package/dist/accounts.d.ts.map +1 -0
- package/dist/accounts.js +129 -0
- package/dist/accounts.js.map +1 -0
- package/dist/allocs.d.ts +26 -0
- package/dist/allocs.d.ts.map +1 -0
- package/dist/allocs.js +99 -0
- package/dist/allocs.js.map +1 -0
- package/dist/dev-node.d.ts +63 -0
- package/dist/dev-node.d.ts.map +1 -0
- package/dist/dev-node.js +166 -0
- package/dist/dev-node.js.map +1 -0
- package/dist/eip712.d.ts +23 -0
- package/dist/eip712.d.ts.map +1 -0
- package/dist/eip712.js +333 -0
- package/dist/eip712.js.map +1 -0
- package/dist/impersonation.d.ts +20 -0
- package/dist/impersonation.d.ts.map +1 -0
- package/dist/impersonation.js +95 -0
- package/dist/impersonation.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/send.d.ts +20 -0
- package/dist/send.d.ts.map +1 -0
- package/dist/send.js +385 -0
- package/dist/send.js.map +1 -0
- package/dist/sign.d.ts +14 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign.js +155 -0
- package/dist/sign.js.map +1 -0
- package/dist/worker-host.d.ts +87 -0
- package/dist/worker-host.d.ts.map +1 -0
- package/dist/worker-host.js +112 -0
- package/dist/worker-host.js.map +1 -0
- package/package.json +81 -13
- package/src/accounts.ts +218 -0
- package/src/allocs.ts +134 -0
- package/src/dev-node.ts +220 -0
- package/src/eip712.ts +390 -0
- package/src/impersonation.ts +119 -0
- package/src/index.ts +25 -0
- package/src/send.ts +469 -0
- package/src/sign.ts +199 -0
- package/src/worker-host.ts +151 -0
- package/.npm-publish.log +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* impersonation.ts: IMPERSONATION, opt-in, over webevm's trusted-sender
|
|
3
|
+
* primitive (ADR 0002, ADR 0017). `hardhat_impersonateAccount` /
|
|
4
|
+
* `hardhat_stopImpersonatingAccount` and their `anvil_` names maintain a set of
|
|
5
|
+
* impersonated addresses; `eth_sendTransaction` from one (./send.ts) is filled
|
|
6
|
+
* as a dev account's is, given a FABRICATED signature, and sent through
|
|
7
|
+
* `evm_sendRawTransactionAs(raw, from)`, which is why the node must be
|
|
8
|
+
* `senderMode: 'trusted'`.
|
|
9
|
+
*
|
|
10
|
+
* THE FABRICATED SIGNATURE IS UNIQUE PER SENDER, as ADR 0002's caller contract
|
|
11
|
+
* requires: `from` is not part of a transaction, so its hash comes from the
|
|
12
|
+
* bytes alone, and two impersonated senders sending otherwise identical
|
|
13
|
+
* transactions would collide under one dummy signature (anvil's bug, foundry
|
|
14
|
+
* #4210). So `r` is `keccak256(address) mod n` (secp256k1's group order) and
|
|
15
|
+
* `s` is fixed at 1, which is low (EIP-2), with y-parity 0. It is a signature
|
|
16
|
+
* of NOTHING: a `'recover'` node recovers some unrelated address from it, or
|
|
17
|
+
* none, so a dump holding such transactions is not replayable chain history.
|
|
18
|
+
*
|
|
19
|
+
* NO SIGNATURE THAT IS NOT ONE. The fabricated signature only ever reaches the
|
|
20
|
+
* node inside a transaction it is told the sender of; no signing method
|
|
21
|
+
* returns one (./sign.ts and `eth_signTransaction` refuse an impersonated
|
|
22
|
+
* address with {@link impersonatedNoKeyMessage}).
|
|
23
|
+
*
|
|
24
|
+
* DECISIONS made here (task `devnode-impersonation`), each user-visible and
|
|
25
|
+
* reversible before 1.0:
|
|
26
|
+
*
|
|
27
|
+
* - THE METHODS RETURN `null` UNDER BOTH NAME SETS, as anvil answers them
|
|
28
|
+
* (Hardhat answers `true`). This follows the core's rule for the `hardhat_`
|
|
29
|
+
* state-cheat aliases (`hardhat-and-anvil-names-for-the-state-cheats`: "what
|
|
30
|
+
* anvil returns under both names"); viem's `impersonateAccount` and rocketh
|
|
31
|
+
* ignore the result. Alternative: `true` for `hardhat_`, `null` for `anvil_`.
|
|
32
|
+
* - STOPPING AN ADDRESS THAT IS NOT IMPERSONATED IS NO ERROR, as on anvil and
|
|
33
|
+
* Hardhat. A malformed address is `-32602`.
|
|
34
|
+
* - WHILE THE OPTION IS OFF, the four methods are answered HERE with `-32601`
|
|
35
|
+
* naming the option, rather than forwarded to the core's generic `-32601`:
|
|
36
|
+
* rocketh swallows this error, so its text is the only place a user learns
|
|
37
|
+
* what to switch on.
|
|
38
|
+
* - THE METHODS RUN ON THE SEND QUEUE (./send.ts), so a send issued before a
|
|
39
|
+
* `stopImpersonatingAccount` is decided by the set as it was when the send
|
|
40
|
+
* was issued, not when it reached the front of the queue.
|
|
41
|
+
* - THE SET IS LAYER STATE, not chain state: it is not in `dumpState`, and
|
|
42
|
+
* `loadState` (which reaches the node, not this layer) leaves it as it is.
|
|
43
|
+
*/
|
|
44
|
+
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
45
|
+
import { RpcError } from 'webevm';
|
|
46
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
47
|
+
/** secp256k1's group order: a signature's `r` and `s` lie in [1, n). */
|
|
48
|
+
const SECP256K1_N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
|
|
49
|
+
/** The fabricated signature's scalars for `address` (lowercase 0x hex). */
|
|
50
|
+
export function fabricatedSignature(address) {
|
|
51
|
+
const bytes = new Uint8Array(20);
|
|
52
|
+
for (let i = 0; i < 20; i++)
|
|
53
|
+
bytes[i] = parseInt(address.slice(2 + 2 * i, 4 + 2 * i), 16);
|
|
54
|
+
let hash = 0n;
|
|
55
|
+
for (const b of keccak_256(bytes))
|
|
56
|
+
hash = (hash << 8n) | BigInt(b);
|
|
57
|
+
// `r = 0` is no signature at all; keccak lands on a multiple of n with
|
|
58
|
+
// negligible probability, and 1 keeps the scalar valid if it ever does.
|
|
59
|
+
return { r: hash % SECP256K1_N || 1n, s: 1n };
|
|
60
|
+
}
|
|
61
|
+
/** The message of a `4100` refusal to SIGN for an impersonated address. */
|
|
62
|
+
export function impersonatedNoKeyMessage(method, address) {
|
|
63
|
+
return (`${method}: ${address} is impersonated, and @webevm/devnode holds no key for it: ` +
|
|
64
|
+
`an impersonated address can send (eth_sendTransaction), but nothing is ever signed for it, ` +
|
|
65
|
+
`since any signature would be fabricated. Configure its private key in the dev node's \`accounts\` option to sign with it.`);
|
|
66
|
+
}
|
|
67
|
+
/** The impersonation methods, under both name sets. */
|
|
68
|
+
export const IMPERSONATION_METHODS = new Set([
|
|
69
|
+
'hardhat_impersonateAccount',
|
|
70
|
+
'anvil_impersonateAccount',
|
|
71
|
+
'hardhat_stopImpersonatingAccount',
|
|
72
|
+
'anvil_stopImpersonatingAccount',
|
|
73
|
+
]);
|
|
74
|
+
export function createImpersonation(enabled) {
|
|
75
|
+
const addresses = new Set();
|
|
76
|
+
return {
|
|
77
|
+
enabled,
|
|
78
|
+
addresses,
|
|
79
|
+
request(method, params) {
|
|
80
|
+
if (!enabled)
|
|
81
|
+
throw new RpcError(-32601, `${method}: impersonation is off on this dev node. Turn on the \`impersonation\` option: ` +
|
|
82
|
+
`createDevNode({impersonation: true}), or wrapDevNode(node, {impersonation: true}) on a node created with senderMode: 'trusted'.`);
|
|
83
|
+
const address = Array.isArray(params) ? params[0] : undefined;
|
|
84
|
+
if (typeof address !== 'string' || !ADDRESS.test(address))
|
|
85
|
+
throw new RpcError(-32602, `${method}: expected [address], a 20-byte hex address (received ${JSON.stringify(address ?? null)}).`);
|
|
86
|
+
const lower = address.toLowerCase();
|
|
87
|
+
if (method.endsWith('_impersonateAccount'))
|
|
88
|
+
addresses.add(lower);
|
|
89
|
+
else
|
|
90
|
+
addresses.delete(lower);
|
|
91
|
+
return null;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=impersonation.js.map
|
|
@@ -0,0 +1 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,IAAI,GAAG,CAAC;IAC5C,4BAA4B;IAC5B,0BAA0B;IAC1B,kCAAkC;IAClC,gCAAgC;CAChC,CAAC,CAAC;AAYH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IACnD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,OAAO;QACN,OAAO;QACP,SAAS;QACT,OAAO,CAAC,MAAM,EAAE,MAAM;YACrB,IAAI,CAAC,OAAO;gBACX,MAAM,IAAI,QAAQ,CACjB,CAAC,KAAK,EACN,GAAG,MAAM,iFAAiF;oBACzF,iIAAiI,CAClI,CAAC;YACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC9D,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;gBACxD,MAAM,IAAI,QAAQ,CACjB,CAAC,KAAK,EACN,GAAG,MAAM,yDAAyD,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CACrG,CAAC;YACH,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YACpC,IAAI,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC;gBAAE,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;;gBAC5D,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @webevm/devnode: dev accounts for webevm, as a `SlimNode` decorator funded at
|
|
3
|
+
* genesis. See `docs/adr/0017-dev-accounts-live-in-webevm-devnode-a-slimnode-decorator-funded-at-genesis.md`.
|
|
4
|
+
*/
|
|
5
|
+
export { createDevNode, wrapDevNode } from './dev-node.js';
|
|
6
|
+
export type { DevNodeOptions, ImpersonationOptions, WrapDevNodeOptions, } from './dev-node.js';
|
|
7
|
+
export { toAllocs } from './allocs.js';
|
|
8
|
+
export type { AllocAccount, Allocs } from './allocs.js';
|
|
9
|
+
export { devAccountBalances, DEFAULT_ACCOUNT_COUNT, DEFAULT_BALANCE, DEFAULT_DERIVATION_PATH, DEFAULT_MNEMONIC, } from './accounts.js';
|
|
10
|
+
export type { DevAccountsConfig, DevAccountsOptions, DevFundingOptions, MnemonicAccounts, } from './accounts.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACzD,YAAY,EACX,cAAc,EACd,oBAAoB,EACpB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,YAAY,EAAC,YAAY,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AACtD,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EACX,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @webevm/devnode: dev accounts for webevm, as a `SlimNode` decorator funded at
|
|
3
|
+
* genesis. See `docs/adr/0017-dev-accounts-live-in-webevm-devnode-a-slimnode-decorator-funded-at-genesis.md`.
|
|
4
|
+
*/
|
|
5
|
+
export { createDevNode, wrapDevNode } from './dev-node.js';
|
|
6
|
+
export { toAllocs } from './allocs.js';
|
|
7
|
+
export { devAccountBalances, DEFAULT_ACCOUNT_COUNT, DEFAULT_BALANCE, DEFAULT_DERIVATION_PATH, DEFAULT_MNEMONIC, } from './accounts.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAMzD,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAErC,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,eAAe,CAAC"}
|
package/dist/send.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SlimNode } from 'webevm';
|
|
2
|
+
import type { DevAccount } from './accounts.js';
|
|
3
|
+
import type { Impersonation } from './impersonation.js';
|
|
4
|
+
/** The two transaction methods of the layer, sharing one queue. */
|
|
5
|
+
export interface TransactionMethods {
|
|
6
|
+
/** `eth_sendTransaction`: fill, sign, submit; resolves to the hash. */
|
|
7
|
+
sendTransaction(params: unknown): Promise<string>;
|
|
8
|
+
/** `eth_signTransaction`: fill and sign as `eth_sendTransaction` does; resolves to the raw signed transaction, unsent. */
|
|
9
|
+
signTransaction(params: unknown): Promise<string>;
|
|
10
|
+
/** Run `job` on the same queue, after every send and sign issued before it. */
|
|
11
|
+
inOrder<T>(job: () => T): Promise<T>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The layer's `eth_sendTransaction` and `eth_signTransaction`: functions of the
|
|
15
|
+
* request's params, which run every send and every sign on ONE queue, signing
|
|
16
|
+
* with the given accounts' keys, or, for an address `impersonation` holds, a
|
|
17
|
+
* fabricated signature.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createTransactionMethods(node: SlimNode, accounts: readonly DevAccount[], impersonation: Impersonation): TransactionMethods;
|
|
20
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../src/send.ts"],"names":[],"mappings":"AAsFA,OAAO,EAAW,KAAK,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAkJtD,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IAClC,uEAAuE;IACvE,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,0HAA0H;IAC1H,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,+EAA+E;IAC/E,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACrC;AAID;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,aAAa,EAAE,aAAa,GAC1B,kBAAkB,CAoNpB"}
|
package/dist/send.js
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* send.ts: `eth_sendTransaction` from a DEV ACCOUNT. Fill exactly what the
|
|
3
|
+
* request leaves out, sign with the account's key, submit, return the hash.
|
|
4
|
+
*
|
|
5
|
+
* THE FILLING matches the node's own `eth_fillTransaction`
|
|
6
|
+
* (`packages/webevm/src/node.ts`), through the node's PUBLIC methods only:
|
|
7
|
+
*
|
|
8
|
+
* - `nonce`: the PENDING nonce (`eth_getTransactionCount` at `pending`), so a
|
|
9
|
+
* send queued behind an unmined one (manual or interval mining) does not reuse
|
|
10
|
+
* its nonce;
|
|
11
|
+
* - `gas`: `eth_estimateGas` on the same request (its access list and
|
|
12
|
+
* authorization list included, which the node charges and applies);
|
|
13
|
+
* - fees: legacy `gasPrice` from `eth_gasPrice`; the EIP-1559 pair from the
|
|
14
|
+
* node's own `eth_fillTransaction`, because the base fee it adds to the
|
|
15
|
+
* priority fee is a node option no other public method reports as such (a
|
|
16
|
+
* block's `baseFeePerGas` can differ under a `blockEnv`). So the two cannot
|
|
17
|
+
* drift apart.
|
|
18
|
+
*
|
|
19
|
+
* UNLIKE `eth_fillTransaction`, NOTHING THE REQUEST NAMES IS DROPPED. The
|
|
20
|
+
* envelope follows the fields: type 4 for an `authorizationList`, type 0 for a
|
|
21
|
+
* `gasPrice` (type 1 with an `accessList` too), type 2 otherwise (carrying any
|
|
22
|
+
* `accessList`). An explicit `type` is honoured.
|
|
23
|
+
*
|
|
24
|
+
* THE SEND PATH follows the node's sender mode (ADR 0017): on `'trusted'`,
|
|
25
|
+
* `evm_sendRawTransactionAs(raw, from)` with the REAL signature, so no ecrecover
|
|
26
|
+
* runs and the chain's transactions still replay on any node (ADR 0002's
|
|
27
|
+
* portability caveat is about fabricated signatures only); on `'recover'`,
|
|
28
|
+
* `eth_sendRawTransaction(raw)`.
|
|
29
|
+
*
|
|
30
|
+
* ONE OPERATION, ONE QUEUE. Fill, sign and submit run as a single job on a
|
|
31
|
+
* queue per layer: two concurrent sends from one account would otherwise both
|
|
32
|
+
* read the same pending nonce before either is submitted. The node serialises
|
|
33
|
+
* its own requests (ADR 0012), not a sequence of them, so the layer orders its
|
|
34
|
+
* own sequences.
|
|
35
|
+
*
|
|
36
|
+
* DECISIONS made here (task `devnode-eth-send-transaction-from-dev-accounts`),
|
|
37
|
+
* each user-visible and reversible before 1.0:
|
|
38
|
+
*
|
|
39
|
+
* - AN UNKNOWN `from` IS REFUSED WITH `4100`, EIP-1193's "Unauthorized" ("the
|
|
40
|
+
* requested method and/or account has not been authorized"), the code wallets
|
|
41
|
+
* use for an account they hold no key for, and viem maps it to
|
|
42
|
+
* `UnauthorizedProviderError`. A missing or malformed `from` is `-32602`.
|
|
43
|
+
* Alternatives: `-32000` (a generic server error), or `-32602` for both, which
|
|
44
|
+
* would read as a malformed request when the request is well formed. The
|
|
45
|
+
* impersonation task extends the message, not the code: it names
|
|
46
|
+
* `hardhat_impersonateAccount` (or `anvil_impersonateAccount`) while the
|
|
47
|
+
* `impersonation` option is on, and the option itself while it is off.
|
|
48
|
+
* - A REQUEST THAT CANNOT BE SENT AS NAMED IS REFUSED WITH `-32602`, never
|
|
49
|
+
* trimmed into one that can: fields its type cannot carry (a `gasPrice` with
|
|
50
|
+
* EIP-1559 fees or with an `authorizationList`, an `accessList` on type 0, an
|
|
51
|
+
* `authorizationList` on anything but type 4), blob fields or type 3 (which
|
|
52
|
+
* this layer does not build), a `type` other than 0, 1, 2 or 4, `data` and
|
|
53
|
+
* `input` both present and different (as geth refuses them), and a `chainId`
|
|
54
|
+
* that is not the node's. `eth_fillTransaction` drops some of these instead;
|
|
55
|
+
* that is its documented difference, and the reason this does not reuse it.
|
|
56
|
+
* - SIGNING IS DETERMINISTIC (RFC 6979, no extra entropy), so the same request
|
|
57
|
+
* on the same state signs to the same bytes and the same hash.
|
|
58
|
+
* - THE SIGNING `Common` is the node's chain ID on Prague, the fork with every
|
|
59
|
+
* type this layer builds. The NODE's fork decides what is accepted: a type 4
|
|
60
|
+
* on Cancun is refused by the node in its own words, not by the signer.
|
|
61
|
+
*
|
|
62
|
+
* `eth_signTransaction` (task `devnode-signing-methods-and-eip-712`) is the
|
|
63
|
+
* same fill, the same types and the same refusals (each `-32602` and `4100`
|
|
64
|
+
* names `eth_signTransaction`), stopping before the submit. Its DECISIONS, each
|
|
65
|
+
* user-visible and reversible before 1.0:
|
|
66
|
+
*
|
|
67
|
+
* - IT RETURNS THE RAW SIGNED TRANSACTION AS A HEX STRING, as anvil does and as
|
|
68
|
+
* viem's `signTransaction` over a JSON-RPC account reads it. Alternative:
|
|
69
|
+
* geth's `{raw, tx}` object, which viem would hand back as an object.
|
|
70
|
+
* - IT RUNS ON THE SAME QUEUE AS THE SENDS, so its pending nonce counts every
|
|
71
|
+
* send queued before it. Two signs with no send between them read the same
|
|
72
|
+
* nonce: nothing was submitted, as on anvil.
|
|
73
|
+
* - Its `4100` names only the `accounts` remedy: impersonation never signs
|
|
74
|
+
* (ADR 0017).
|
|
75
|
+
*
|
|
76
|
+
* AN IMPERSONATED `from` (task `devnode-impersonation`, see
|
|
77
|
+
* ./impersonation.ts) is filled exactly as a dev account's is and given the
|
|
78
|
+
* FABRICATED signature of `fabricatedSignature` instead of a real one, then
|
|
79
|
+
* sent through `evm_sendRawTransactionAs` (the option requires a `'trusted'`
|
|
80
|
+
* node). A dev account that is also impersonated sends with its key: the key
|
|
81
|
+
* is looked up first. `eth_signTransaction` refuses an impersonated `from`
|
|
82
|
+
* with `4100`, since what it returns would be a signature that is not one.
|
|
83
|
+
*/
|
|
84
|
+
import { Common, Hardfork, Mainnet } from '@ethereumjs/common';
|
|
85
|
+
import { createTx } from '@ethereumjs/tx';
|
|
86
|
+
import { bytesToHex } from '@ethereumjs/util';
|
|
87
|
+
import { RpcError } from 'webevm';
|
|
88
|
+
import { fabricatedSignature, impersonatedNoKeyMessage, } from './impersonation.js';
|
|
89
|
+
import { noKeyMessage } from './sign.js';
|
|
90
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
91
|
+
const HEX_QUANTITY = /^0x[0-9a-fA-F]+$/;
|
|
92
|
+
const HEX_DATA = /^0x([0-9a-fA-F]{2})*$/;
|
|
93
|
+
/** The fields that make a request an EIP-1559 one. */
|
|
94
|
+
const FEE_1559 = ['maxFeePerGas', 'maxPriorityFeePerGas'];
|
|
95
|
+
/** EIP-4844's fields, which this layer does not build a transaction from. */
|
|
96
|
+
const BLOB_FIELDS = [
|
|
97
|
+
'blobVersionedHashes',
|
|
98
|
+
'maxFeePerBlobGas',
|
|
99
|
+
'blobs',
|
|
100
|
+
'sidecars',
|
|
101
|
+
];
|
|
102
|
+
/**
|
|
103
|
+
* A malformed request, thrown by the helpers below and turned into a `-32602`
|
|
104
|
+
* naming the method that was called (`eth_sendTransaction` or
|
|
105
|
+
* `eth_signTransaction`) where the request is built.
|
|
106
|
+
*/
|
|
107
|
+
class InvalidRequest extends Error {
|
|
108
|
+
}
|
|
109
|
+
function invalid(message) {
|
|
110
|
+
throw new InvalidRequest(message);
|
|
111
|
+
}
|
|
112
|
+
/** A request's quantity as a bigint, or `undefined` when it is absent. */
|
|
113
|
+
function quantity(p, field) {
|
|
114
|
+
const value = p[field];
|
|
115
|
+
if (value == null)
|
|
116
|
+
return undefined;
|
|
117
|
+
if (typeof value === 'string' && HEX_QUANTITY.test(value))
|
|
118
|
+
return BigInt(value);
|
|
119
|
+
if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0)
|
|
120
|
+
return BigInt(value);
|
|
121
|
+
if (typeof value === 'bigint' && value >= 0n)
|
|
122
|
+
return value;
|
|
123
|
+
return invalid(`\`${field}\` must be a hex quantity (received ${JSON.stringify(String(value))}).`);
|
|
124
|
+
}
|
|
125
|
+
function present(p, field) {
|
|
126
|
+
return p[field] != null;
|
|
127
|
+
}
|
|
128
|
+
/** The envelope type the request names or implies, refusing a conflict. */
|
|
129
|
+
function envelopeType(p) {
|
|
130
|
+
for (const field of BLOB_FIELDS) {
|
|
131
|
+
if (present(p, field))
|
|
132
|
+
invalid(`\`${field}\` is an EIP-4844 (type 3) field, and a dev account does not send type 3 transactions. Sign it yourself and use eth_sendRawTransaction.`);
|
|
133
|
+
}
|
|
134
|
+
const has1559 = FEE_1559.some((f) => present(p, f));
|
|
135
|
+
const explicit = quantity(p, 'type');
|
|
136
|
+
let type;
|
|
137
|
+
if (explicit !== undefined) {
|
|
138
|
+
if (explicit !== 0n &&
|
|
139
|
+
explicit !== 1n &&
|
|
140
|
+
explicit !== 2n &&
|
|
141
|
+
explicit !== 4n)
|
|
142
|
+
invalid(`type ${explicit} is not one a dev account sends: 0 (legacy), 1 (EIP-2930), 2 (EIP-1559) or 4 (EIP-7702).`);
|
|
143
|
+
type = Number(explicit);
|
|
144
|
+
}
|
|
145
|
+
else if (present(p, 'authorizationList'))
|
|
146
|
+
type = 4;
|
|
147
|
+
else if (present(p, 'gasPrice') && !has1559)
|
|
148
|
+
type = present(p, 'accessList') ? 1 : 0;
|
|
149
|
+
else
|
|
150
|
+
type = 2;
|
|
151
|
+
const conflict = (field) => invalid(`\`${field}\` cannot be carried by a type ${type} transaction, and a dev account's transaction carries every field it is given rather than dropping one. Remove it, or ${type === 0 || type === 1 ? 'remove `gasPrice` and pass EIP-1559 fees' : 'pick a type that carries it'}.`);
|
|
152
|
+
if (type === 0 || type === 1) {
|
|
153
|
+
for (const f of FEE_1559)
|
|
154
|
+
if (present(p, f))
|
|
155
|
+
conflict(f);
|
|
156
|
+
if (present(p, 'authorizationList'))
|
|
157
|
+
conflict('authorizationList');
|
|
158
|
+
if (type === 0 && present(p, 'accessList'))
|
|
159
|
+
conflict('accessList');
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
if (present(p, 'gasPrice'))
|
|
163
|
+
conflict('gasPrice');
|
|
164
|
+
if (type === 2 && present(p, 'authorizationList'))
|
|
165
|
+
conflict('authorizationList');
|
|
166
|
+
}
|
|
167
|
+
return type;
|
|
168
|
+
}
|
|
169
|
+
/** The request's call data, `data` or `input`, refusing two different ones. */
|
|
170
|
+
function callData(p) {
|
|
171
|
+
const { data, input } = p;
|
|
172
|
+
for (const [name, v] of [
|
|
173
|
+
['data', data],
|
|
174
|
+
['input', input],
|
|
175
|
+
]) {
|
|
176
|
+
if (v != null && (typeof v !== 'string' || !HEX_DATA.test(v)))
|
|
177
|
+
invalid(`\`${name}\` must be even-length 0x hex.`);
|
|
178
|
+
}
|
|
179
|
+
if (typeof data === 'string' &&
|
|
180
|
+
typeof input === 'string' &&
|
|
181
|
+
data.toLowerCase() !== input.toLowerCase())
|
|
182
|
+
invalid('both `data` and `input` are set and they differ. Pass one, or the same bytes in both.');
|
|
183
|
+
return (input ?? data ?? '0x').toLowerCase();
|
|
184
|
+
}
|
|
185
|
+
/** An authorization entry in the form `@ethereumjs/tx` reads, `v` accepted as yParity. */
|
|
186
|
+
function authorization(entry) {
|
|
187
|
+
if (entry === null || typeof entry !== 'object')
|
|
188
|
+
invalid('each `authorizationList` entry must be {chainId, address, nonce, yParity, r, s}.');
|
|
189
|
+
const e = entry;
|
|
190
|
+
let yParity = e.yParity ?? e.v;
|
|
191
|
+
if (typeof yParity === 'string' && HEX_QUANTITY.test(yParity)) {
|
|
192
|
+
const parity = BigInt(yParity);
|
|
193
|
+
if (parity >= 27n)
|
|
194
|
+
yParity = `0x${(parity - 27n).toString(16)}`;
|
|
195
|
+
}
|
|
196
|
+
const out = {};
|
|
197
|
+
for (const [field, value] of Object.entries({
|
|
198
|
+
chainId: e.chainId,
|
|
199
|
+
address: e.address,
|
|
200
|
+
nonce: e.nonce,
|
|
201
|
+
yParity,
|
|
202
|
+
r: e.r,
|
|
203
|
+
s: e.s,
|
|
204
|
+
})) {
|
|
205
|
+
if (typeof value !== 'string')
|
|
206
|
+
invalid(`an \`authorizationList\` entry's \`${field}\` must be a hex string.`);
|
|
207
|
+
out[field] = value;
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The layer's `eth_sendTransaction` and `eth_signTransaction`: functions of the
|
|
213
|
+
* request's params, which run every send and every sign on ONE queue, signing
|
|
214
|
+
* with the given accounts' keys, or, for an address `impersonation` holds, a
|
|
215
|
+
* fabricated signature.
|
|
216
|
+
*/
|
|
217
|
+
export function createTransactionMethods(node, accounts, impersonation) {
|
|
218
|
+
const keys = new Map(accounts.map((a) => [a.address, a.privateKey]));
|
|
219
|
+
let common;
|
|
220
|
+
const signingCommon = () => (common ??= (async () => {
|
|
221
|
+
const chainId = BigInt((await node.request({ method: 'eth_chainId' })));
|
|
222
|
+
return {
|
|
223
|
+
chainId,
|
|
224
|
+
common: new Common({
|
|
225
|
+
chain: { ...Mainnet, chainId: Number(chainId), name: 'webevm-devnode' },
|
|
226
|
+
hardfork: Hardfork.Prague,
|
|
227
|
+
}),
|
|
228
|
+
};
|
|
229
|
+
})().catch((e) => {
|
|
230
|
+
common = undefined;
|
|
231
|
+
throw e;
|
|
232
|
+
}));
|
|
233
|
+
/** Fill and sign; `-32602` for a malformed request, named by `method`. */
|
|
234
|
+
async function build(params, method) {
|
|
235
|
+
try {
|
|
236
|
+
return await fillAndSign(params, method);
|
|
237
|
+
}
|
|
238
|
+
catch (e) {
|
|
239
|
+
if (e instanceof InvalidRequest)
|
|
240
|
+
throw new RpcError(-32602, `${method}: ${e.message}`);
|
|
241
|
+
throw e;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async function fillAndSign(params, method) {
|
|
245
|
+
const p = (Array.isArray(params) ? params[0] : undefined);
|
|
246
|
+
if (p === null || typeof p !== 'object' || Array.isArray(p))
|
|
247
|
+
invalid('expected one transaction request object as its parameter.');
|
|
248
|
+
const request = p;
|
|
249
|
+
if (typeof request.from !== 'string' || !ADDRESS.test(request.from))
|
|
250
|
+
invalid('`from` must be the 20-byte hex address of the dev account to send from.');
|
|
251
|
+
const from = request.from.toLowerCase();
|
|
252
|
+
// The key first: a dev account that is also impersonated signs with it.
|
|
253
|
+
const privateKey = keys.get(from);
|
|
254
|
+
if (!privateKey) {
|
|
255
|
+
const impersonated = impersonation.addresses.has(from);
|
|
256
|
+
if (method === 'eth_signTransaction')
|
|
257
|
+
throw new RpcError(4100, impersonated
|
|
258
|
+
? impersonatedNoKeyMessage(method, from)
|
|
259
|
+
: noKeyMessage(method, from));
|
|
260
|
+
if (!impersonated)
|
|
261
|
+
throw new RpcError(4100, `eth_sendTransaction: ${from} is not a dev account, so @webevm/devnode holds no key to sign for it. ` +
|
|
262
|
+
`Configure its private key in the dev node's \`accounts\` option, or impersonate it: ` +
|
|
263
|
+
(impersonation.enabled
|
|
264
|
+
? `call hardhat_impersonateAccount (or anvil_impersonateAccount) with ["${from}"] first.`
|
|
265
|
+
: `turn on the dev node's \`impersonation\` option, then call hardhat_impersonateAccount (or anvil_impersonateAccount) with ["${from}"].`));
|
|
266
|
+
}
|
|
267
|
+
const type = envelopeType(request);
|
|
268
|
+
const data = callData(request);
|
|
269
|
+
const to = request.to == null ? undefined : request.to;
|
|
270
|
+
if (to !== undefined && (typeof to !== 'string' || !ADDRESS.test(to)))
|
|
271
|
+
invalid('`to` must be a 20-byte hex address, or absent to create.');
|
|
272
|
+
const { chainId, common } = await signingCommon();
|
|
273
|
+
const requestChainId = quantity(request, 'chainId');
|
|
274
|
+
if (requestChainId !== undefined && requestChainId !== chainId)
|
|
275
|
+
invalid(`\`chainId\` ${requestChainId} is not this node's chain ID (${chainId}).`);
|
|
276
|
+
if (request.accessList != null && !Array.isArray(request.accessList))
|
|
277
|
+
invalid('`accessList` must be an array of {address, storageKeys}.');
|
|
278
|
+
if (request.authorizationList != null &&
|
|
279
|
+
!Array.isArray(request.authorizationList))
|
|
280
|
+
invalid('`authorizationList` must be an array of {chainId, address, nonce, yParity, r, s}.');
|
|
281
|
+
// Validate every named quantity before any round trip.
|
|
282
|
+
const value = quantity(request, 'value') ?? 0n;
|
|
283
|
+
const named = {
|
|
284
|
+
nonce: quantity(request, 'nonce'),
|
|
285
|
+
gas: quantity(request, 'gas'),
|
|
286
|
+
gasPrice: quantity(request, 'gasPrice'),
|
|
287
|
+
maxFeePerGas: quantity(request, 'maxFeePerGas'),
|
|
288
|
+
maxPriorityFeePerGas: quantity(request, 'maxPriorityFeePerGas'),
|
|
289
|
+
};
|
|
290
|
+
const nonce = named.nonce ??
|
|
291
|
+
BigInt((await node.request({
|
|
292
|
+
method: 'eth_getTransactionCount',
|
|
293
|
+
params: [from, 'pending'],
|
|
294
|
+
})));
|
|
295
|
+
let gas = named.gas;
|
|
296
|
+
if (gas === undefined) {
|
|
297
|
+
// The same request, minus the `gas` being estimated.
|
|
298
|
+
const estimate = { ...request, from };
|
|
299
|
+
delete estimate.gas;
|
|
300
|
+
gas = BigInt((await node.request({
|
|
301
|
+
method: 'eth_estimateGas',
|
|
302
|
+
params: [estimate],
|
|
303
|
+
})));
|
|
304
|
+
}
|
|
305
|
+
const txData = {
|
|
306
|
+
type,
|
|
307
|
+
nonce,
|
|
308
|
+
gasLimit: gas,
|
|
309
|
+
to,
|
|
310
|
+
value,
|
|
311
|
+
data,
|
|
312
|
+
};
|
|
313
|
+
if (type === 0 || type === 1) {
|
|
314
|
+
txData.gasPrice =
|
|
315
|
+
named.gasPrice ??
|
|
316
|
+
BigInt((await node.request({ method: 'eth_gasPrice' })));
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
let { maxFeePerGas, maxPriorityFeePerGas } = named;
|
|
320
|
+
if (maxFeePerGas === undefined || maxPriorityFeePerGas === undefined) {
|
|
321
|
+
// The node's own EIP-1559 filling, on a plain transfer whose nonce and
|
|
322
|
+
// gas are fixed so it neither reads the nonce nor estimates.
|
|
323
|
+
const probe = { from, to: from, nonce: '0x0', gas: '0x5208' };
|
|
324
|
+
if (maxFeePerGas !== undefined)
|
|
325
|
+
probe.maxFeePerGas = `0x${maxFeePerGas.toString(16)}`;
|
|
326
|
+
if (maxPriorityFeePerGas !== undefined)
|
|
327
|
+
probe.maxPriorityFeePerGas = `0x${maxPriorityFeePerGas.toString(16)}`;
|
|
328
|
+
const filled = (await node.request({
|
|
329
|
+
method: 'eth_fillTransaction',
|
|
330
|
+
params: [probe],
|
|
331
|
+
}));
|
|
332
|
+
maxFeePerGas ??= BigInt(filled.tx.maxFeePerGas);
|
|
333
|
+
maxPriorityFeePerGas ??= BigInt(filled.tx.maxPriorityFeePerGas);
|
|
334
|
+
}
|
|
335
|
+
txData.maxFeePerGas = maxFeePerGas;
|
|
336
|
+
txData.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
337
|
+
}
|
|
338
|
+
if (type !== 0) {
|
|
339
|
+
txData.chainId = chainId;
|
|
340
|
+
txData.accessList = request.accessList ?? [];
|
|
341
|
+
}
|
|
342
|
+
if (type === 4) {
|
|
343
|
+
txData.authorizationList = (request.authorizationList ?? []).map(authorization);
|
|
344
|
+
}
|
|
345
|
+
try {
|
|
346
|
+
if (privateKey) {
|
|
347
|
+
const raw = bytesToHex(createTx(txData, { common })
|
|
348
|
+
.sign(privateKey, false)
|
|
349
|
+
.serialize());
|
|
350
|
+
return { raw, from };
|
|
351
|
+
}
|
|
352
|
+
// Impersonated: the fabricated signature, y-parity 0 (EIP-155's
|
|
353
|
+
// `chainId * 2 + 35` on a legacy transaction).
|
|
354
|
+
const { r, s } = fabricatedSignature(from);
|
|
355
|
+
const v = type === 0 ? chainId * 2n + 35n : 0n;
|
|
356
|
+
const raw = bytesToHex(createTx({ ...txData, v, r, s }, { common }).serialize());
|
|
357
|
+
return { raw, from };
|
|
358
|
+
}
|
|
359
|
+
catch (e) {
|
|
360
|
+
return invalid(`the transaction could not be built: ${e.message}`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async function send(params) {
|
|
364
|
+
const { raw, from } = await build(params, 'eth_sendTransaction');
|
|
365
|
+
return (await node.request(node.senderMode === 'trusted'
|
|
366
|
+
? { method: 'evm_sendRawTransactionAs', params: [raw, from] }
|
|
367
|
+
: { method: 'eth_sendRawTransaction', params: [raw] }));
|
|
368
|
+
}
|
|
369
|
+
// The queue: each job starts when the one before it has settled, whatever
|
|
370
|
+
// its outcome, so a refused one cannot stall the ones behind it. A sign
|
|
371
|
+
// runs on it too, so it reads the pending nonce AFTER every send queued
|
|
372
|
+
// before it has been submitted.
|
|
373
|
+
let queue = Promise.resolve();
|
|
374
|
+
function enqueue(run) {
|
|
375
|
+
const job = queue.then(run);
|
|
376
|
+
queue = job.catch(() => undefined);
|
|
377
|
+
return job;
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
sendTransaction: (params) => enqueue(() => send(params)),
|
|
381
|
+
signTransaction: (params) => enqueue(async () => (await build(params, 'eth_signTransaction')).raw),
|
|
382
|
+
inOrder: (job) => enqueue(async () => job()),
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=send.js.map
|
package/dist/send.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../src/send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAC,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAgB,MAAM,QAAQ,CAAC;AAG/C,OAAO,EACN,mBAAmB,EACnB,wBAAwB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAEvC,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAEzC,sDAAsD;AACtD,MAAM,QAAQ,GAAG,CAAC,cAAc,EAAE,sBAAsB,CAAU,CAAC;AACnE,6EAA6E;AAC7E,MAAM,WAAW,GAAG;IACnB,qBAAqB;IACrB,kBAAkB;IAClB,OAAO;IACP,UAAU;CACD,CAAC;AAIX;;;;GAIG;AACH,MAAM,cAAe,SAAQ,KAAK;CAAG;AAErC,SAAS,OAAO,CAAC,OAAe;IAC/B,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,0EAA0E;AAC1E,SAAS,QAAQ,CAAC,CAAU,EAAE,KAAa;IAC1C,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,KAAK,IAAI,I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DevAccount } from './accounts.js';
|
|
2
|
+
import { type Impersonation } from './impersonation.js';
|
|
3
|
+
type SigningMethod = 'personal_sign' | 'eth_sign' | 'eth_signTypedData_v4' | 'eth_signTransaction';
|
|
4
|
+
/** The message of a `4100` refusal: no key is held for `address`. */
|
|
5
|
+
export declare function noKeyMessage(method: SigningMethod, address: string): string;
|
|
6
|
+
/** The layer's message-signing methods, over the given accounts' keys. */
|
|
7
|
+
export interface MessageSigner {
|
|
8
|
+
personalSign(params: unknown): Promise<string>;
|
|
9
|
+
ethSign(params: unknown): Promise<string>;
|
|
10
|
+
signTypedDataV4(params: unknown): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createMessageSigner(accounts: readonly DevAccount[], impersonation: Impersonation): MessageSigner;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=sign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAE9C,OAAO,EAA2B,KAAK,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAOhF,KAAK,aAAa,GACf,eAAe,GACf,UAAU,GACV,sBAAsB,GACtB,qBAAqB,CAAC;AAEzB,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3E;AA4CD,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC7B,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD;AAED,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,aAAa,EAAE,aAAa,GAC1B,aAAa,CA8Ef"}
|