@webevm/devnode 0.0.0-stage → 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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +221 -2
  3. package/dist/accounts.d.ts +82 -0
  4. package/dist/accounts.d.ts.map +1 -0
  5. package/dist/accounts.js +129 -0
  6. package/dist/accounts.js.map +1 -0
  7. package/dist/allocs.d.ts +26 -0
  8. package/dist/allocs.d.ts.map +1 -0
  9. package/dist/allocs.js +99 -0
  10. package/dist/allocs.js.map +1 -0
  11. package/dist/dev-node.d.ts +63 -0
  12. package/dist/dev-node.d.ts.map +1 -0
  13. package/dist/dev-node.js +166 -0
  14. package/dist/dev-node.js.map +1 -0
  15. package/dist/eip712.d.ts +23 -0
  16. package/dist/eip712.d.ts.map +1 -0
  17. package/dist/eip712.js +333 -0
  18. package/dist/eip712.js.map +1 -0
  19. package/dist/impersonation.d.ts +20 -0
  20. package/dist/impersonation.d.ts.map +1 -0
  21. package/dist/impersonation.js +95 -0
  22. package/dist/impersonation.js.map +1 -0
  23. package/dist/index.d.ts +11 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +8 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/send.d.ts +20 -0
  28. package/dist/send.d.ts.map +1 -0
  29. package/dist/send.js +385 -0
  30. package/dist/send.js.map +1 -0
  31. package/dist/sign.d.ts +14 -0
  32. package/dist/sign.d.ts.map +1 -0
  33. package/dist/sign.js +155 -0
  34. package/dist/sign.js.map +1 -0
  35. package/dist/worker-host.d.ts +87 -0
  36. package/dist/worker-host.d.ts.map +1 -0
  37. package/dist/worker-host.js +112 -0
  38. package/dist/worker-host.js.map +1 -0
  39. package/package.json +79 -3
  40. package/src/accounts.ts +218 -0
  41. package/src/allocs.ts +134 -0
  42. package/src/dev-node.ts +220 -0
  43. package/src/eip712.ts +390 -0
  44. package/src/impersonation.ts +119 -0
  45. package/src/index.ts +25 -0
  46. package/src/send.ts +469 -0
  47. package/src/sign.ts +199 -0
  48. package/src/worker-host.ts +151 -0
@@ -0,0 +1,63 @@
1
+ import { type NodeOptions, type SlimNode } from 'webevm';
2
+ import { type DevAccountsOptions, type DevFundingOptions } from './accounts.js';
3
+ /** The impersonation switch, which both constructors take. */
4
+ export interface ImpersonationOptions {
5
+ /**
6
+ * Answer `hardhat_impersonateAccount` / `hardhat_stopImpersonatingAccount`
7
+ * (and their `anvil_` names), and send from an impersonated address with a
8
+ * fabricated signature through `evm_sendRawTransactionAs`. Default `false`,
9
+ * when the four methods answer `-32601` naming this option. Needs a
10
+ * `senderMode: 'trusted'` node: `createDevNode` creates one, `wrapDevNode`
11
+ * refuses any other. See ./impersonation.ts.
12
+ */
13
+ impersonation?: boolean;
14
+ }
15
+ /** What {@link wrapDevNode} takes: the accounts and the impersonation switch, and nothing that funds. */
16
+ export type WrapDevNodeOptions = DevAccountsOptions & ImpersonationOptions;
17
+ /** What {@link createDevNode} takes: webevm's options plus the dev accounts, their funding and the impersonation switch. */
18
+ export type DevNodeOptions = NodeOptions & DevFundingOptions & ImpersonationOptions;
19
+ /**
20
+ * Wrap an existing node with dev accounts. FUNDS NOTHING: genesis is decided
21
+ * when a node is created, so a node created elsewhere is funded by passing
22
+ * `devAccountBalances(options)` as its `initialBalances` there.
23
+ *
24
+ * The result is a `Required<SlimNode>` (the annotation is the mechanism, as on
25
+ * webevm's worker-host proxy: a member added to `SlimNode` later, optional or
26
+ * not, fails to build here instead of reading as `undefined`):
27
+ *
28
+ * - `request` answers `eth_accounts` with the dev accounts, in order, and
29
+ * `eth_sendTransaction` from one of them (filled, signed with its key and
30
+ * submitted by the node's sender mode; see ./send.ts), signs for them
31
+ * (`eth_signTransaction`, ./send.ts; `personal_sign`, `eth_sign` and
32
+ * `eth_signTypedData_v4`, ./sign.ts), answers the impersonation methods
33
+ * (./impersonation.ts; `-32601` naming the option while it is off), and
34
+ * forwards every other method to the node, its result or its error unchanged
35
+ * (the node's own `-32601` included: the very promise the node returned);
36
+ * - `serveOn` serves THIS `request` on the port, so a served port answers the
37
+ * account methods too;
38
+ * - `dispose` stops answering on the ports it served, then disposes the node
39
+ * (whose own `dispose` closes only the ports IT served);
40
+ * - every other member delegates.
41
+ *
42
+ * Throws on an invalid account config (see `deriveDevAccounts`), and at once
43
+ * when `impersonation` is on and the node is not `senderMode: 'trusted'`.
44
+ */
45
+ export declare function wrapDevNode(node: SlimNode, options?: WrapDevNodeOptions): Required<SlimNode>;
46
+ /**
47
+ * Create a webevm node whose dev accounts are FUNDED AT GENESIS, as anvil and
48
+ * Hardhat fund theirs, and return it wrapped (see {@link wrapDevNode}).
49
+ *
50
+ * const node = await createDevNode(); // anvil's ten accounts, 10,000 ETH each
51
+ *
52
+ * The dev accounts' balances (and `fundAccounts`) are merged into webevm's
53
+ * `initialBalances` (see `devAccountBalances` for the precedence), and the node
54
+ * is created with webevm's `createNode`. Like every `initialBalances`, they
55
+ * apply to a NEW genesis only: a state restored by `loadState` or `persistence`
56
+ * keeps its own balances.
57
+ *
58
+ * With `impersonation: true` the node is created with `senderMode: 'trusted'`,
59
+ * which the option needs; an explicit `senderMode: 'recover'` alongside it is
60
+ * refused before any node is created.
61
+ */
62
+ export declare function createDevNode(options?: DevNodeOptions): Promise<Required<SlimNode>>;
63
+ //# sourceMappingURL=dev-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-node.d.ts","sourceRoot":"","sources":["../src/dev-node.ts"],"names":[],"mappings":"AAeA,OAAO,EAEN,KAAK,WAAW,EAEhB,KAAK,QAAQ,EACb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAIN,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,MAAM,eAAe,CAAC;AAKvB,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACpC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,yGAAyG;AACzG,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAE3E,4HAA4H;AAC5H,MAAM,MAAM,cAAc,GAAG,WAAW,GACvC,iBAAiB,GACjB,oBAAoB,CAAC;AAatB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,kBAAuB,GAC9B,QAAQ,CAAC,QAAQ,CAAC,CAQpB;AAqED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAClC,OAAO,GAAE,cAAmB,GAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CA+B7B"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * dev-node.ts: the `SlimNode` DECORATOR (`wrapDevNode`) and the constructor that
3
+ * funds its accounts at genesis (`createDevNode`).
4
+ *
5
+ * WHY A DECORATOR, AND WHY THIS PACKAGE. webevm's core holds no keys and answers
6
+ * every account method with a real `-32601` (ADR 0004), and offers impersonation
7
+ * only as a primitive for "a higher layer" (ADR 0002). This is that layer:
8
+ * `docs/adr/0017-dev-accounts-live-in-webevm-devnode-a-slimnode-decorator-funded-at-genesis.md`.
9
+ * It returns a NODE rather than a bare EIP-1193 provider so the same object runs
10
+ * on the main thread, over a `createWorkerNode()` proxy, and inside a worker.
11
+ *
12
+ * IT REACHES THE NODE ONLY THROUGH `SlimNode`'s PUBLIC MEMBERS, so it cannot
13
+ * depend on node internals and the core can change underneath it.
14
+ */
15
+ import { serveProvider } from '@eip-1193/over-port';
16
+ import { createNode, } from 'webevm';
17
+ import { deriveDevAccounts, devAccountBalances, } from './accounts.js';
18
+ import { createImpersonation, IMPERSONATION_METHODS } from './impersonation.js';
19
+ import { createTransactionMethods } from './send.js';
20
+ import { createMessageSigner } from './sign.js';
21
+ /** Why impersonation cannot run on `node`, or `undefined` when it can. */
22
+ function impersonationRefusal(senderMode) {
23
+ if (senderMode === 'trusted')
24
+ return undefined;
25
+ return (`@webevm/devnode: the \`impersonation\` option needs a node created with senderMode: 'trusted', ` +
26
+ `since an impersonated address's transactions carry a fabricated signature and are sent through ` +
27
+ `evm_sendRawTransactionAs, and it was given senderMode: '${String(senderMode)}'. ` +
28
+ `Create the node with senderMode: 'trusted' (createDevNode does so when the option is on), or turn the option off.`);
29
+ }
30
+ /**
31
+ * Wrap an existing node with dev accounts. FUNDS NOTHING: genesis is decided
32
+ * when a node is created, so a node created elsewhere is funded by passing
33
+ * `devAccountBalances(options)` as its `initialBalances` there.
34
+ *
35
+ * The result is a `Required<SlimNode>` (the annotation is the mechanism, as on
36
+ * webevm's worker-host proxy: a member added to `SlimNode` later, optional or
37
+ * not, fails to build here instead of reading as `undefined`):
38
+ *
39
+ * - `request` answers `eth_accounts` with the dev accounts, in order, and
40
+ * `eth_sendTransaction` from one of them (filled, signed with its key and
41
+ * submitted by the node's sender mode; see ./send.ts), signs for them
42
+ * (`eth_signTransaction`, ./send.ts; `personal_sign`, `eth_sign` and
43
+ * `eth_signTypedData_v4`, ./sign.ts), answers the impersonation methods
44
+ * (./impersonation.ts; `-32601` naming the option while it is off), and
45
+ * forwards every other method to the node, its result or its error unchanged
46
+ * (the node's own `-32601` included: the very promise the node returned);
47
+ * - `serveOn` serves THIS `request` on the port, so a served port answers the
48
+ * account methods too;
49
+ * - `dispose` stops answering on the ports it served, then disposes the node
50
+ * (whose own `dispose` closes only the ports IT served);
51
+ * - every other member delegates.
52
+ *
53
+ * Throws on an invalid account config (see `deriveDevAccounts`), and at once
54
+ * when `impersonation` is on and the node is not `senderMode: 'trusted'`.
55
+ */
56
+ export function wrapDevNode(node, options = {}) {
57
+ const accounts = deriveDevAccounts(options.accounts);
58
+ const impersonation = options.impersonation === true;
59
+ if (impersonation) {
60
+ const refusal = impersonationRefusal(node.senderMode);
61
+ if (refusal)
62
+ throw new Error(refusal);
63
+ }
64
+ return decorate(node, accounts, impersonation);
65
+ }
66
+ /** The decorator itself, over accounts already derived (and so validated). */
67
+ function decorate(node, accounts, impersonationOn) {
68
+ const addresses = accounts.map((a) => a.address);
69
+ const servedPorts = new Set();
70
+ const impersonation = createImpersonation(impersonationOn);
71
+ const transactions = createTransactionMethods(node, accounts, impersonation);
72
+ const signer = createMessageSigner(accounts, impersonation);
73
+ async function request(args) {
74
+ switch (args.method) {
75
+ case 'eth_accounts':
76
+ // A fresh array each time, so a caller mutating its answer cannot
77
+ // change the next one.
78
+ return [...addresses];
79
+ case 'eth_sendTransaction':
80
+ return transactions.sendTransaction(args.params);
81
+ case 'eth_signTransaction':
82
+ return transactions.signTransaction(args.params);
83
+ case 'personal_sign':
84
+ return signer.personalSign(args.params);
85
+ case 'eth_sign':
86
+ return signer.ethSign(args.params);
87
+ case 'eth_signTypedData_v4':
88
+ return signer.signTypedDataV4(args.params);
89
+ default:
90
+ if (IMPERSONATION_METHODS.has(args.method))
91
+ // On the send queue, so a send issued before it sees the set as it was.
92
+ return transactions.inOrder(() => impersonation.request(args.method, args.params));
93
+ return node.request(args);
94
+ }
95
+ }
96
+ const devNode = {
97
+ request,
98
+ mine: () => node.mine(),
99
+ dumpState: () => node.dumpState(),
100
+ loadState: (state) => node.loadState(state),
101
+ onNewHead: (cb) => node.onNewHead(cb),
102
+ getStateRoot: () => node.getStateRoot(),
103
+ computeStateRoot: node.computeStateRoot,
104
+ senderMode: node.senderMode,
105
+ engine: node.engine,
106
+ async serveOn(port) {
107
+ const server = serveProvider({ request }, port);
108
+ servedPorts.add(server);
109
+ return {
110
+ async close() {
111
+ server.close();
112
+ servedPorts.delete(server);
113
+ },
114
+ };
115
+ },
116
+ async dispose() {
117
+ for (const server of servedPorts)
118
+ server.close();
119
+ servedPorts.clear();
120
+ await node.dispose();
121
+ },
122
+ };
123
+ return devNode;
124
+ }
125
+ /**
126
+ * Create a webevm node whose dev accounts are FUNDED AT GENESIS, as anvil and
127
+ * Hardhat fund theirs, and return it wrapped (see {@link wrapDevNode}).
128
+ *
129
+ * const node = await createDevNode(); // anvil's ten accounts, 10,000 ETH each
130
+ *
131
+ * The dev accounts' balances (and `fundAccounts`) are merged into webevm's
132
+ * `initialBalances` (see `devAccountBalances` for the precedence), and the node
133
+ * is created with webevm's `createNode`. Like every `initialBalances`, they
134
+ * apply to a NEW genesis only: a state restored by `loadState` or `persistence`
135
+ * keeps its own balances.
136
+ *
137
+ * With `impersonation: true` the node is created with `senderMode: 'trusted'`,
138
+ * which the option needs; an explicit `senderMode: 'recover'` alongside it is
139
+ * refused before any node is created.
140
+ */
141
+ export async function createDevNode(options = {}) {
142
+ const { accounts, balance, fund, fundAccounts, initialBalances, impersonation, ...rest } = options;
143
+ const impersonationOn = impersonation === true;
144
+ if (impersonationOn && rest.senderMode !== undefined) {
145
+ const refusal = impersonationRefusal(rest.senderMode);
146
+ if (refusal)
147
+ throw new Error(refusal);
148
+ }
149
+ // Derive (and so validate) the accounts and their balances BEFORE creating a
150
+ // node, so a bad config throws with nothing left behind to dispose.
151
+ const devAccounts = deriveDevAccounts(accounts);
152
+ const funded = devAccountBalances({
153
+ accounts,
154
+ balance,
155
+ fund,
156
+ fundAccounts,
157
+ initialBalances,
158
+ });
159
+ const node = await createNode({
160
+ ...rest,
161
+ ...(impersonationOn ? { senderMode: 'trusted' } : {}),
162
+ initialBalances: funded,
163
+ });
164
+ return decorate(node, devAccounts, impersonationOn);
165
+ }
166
+ //# sourceMappingURL=dev-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-node.js","sourceRoot":"","sources":["../src/dev-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAC,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACN,UAAU,GAIV,MAAM,QAAQ,CAAC;AAChB,OAAO,EACN,iBAAiB,EACjB,kBAAkB,GAIlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,mBAAmB,EAAE,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AAC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CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,kBAAkB,CAAC;QACjC,QAAQ;QACR,OAAO;QACP,IAAI;QACJ,YAAY;QACZ,eAAe;KACf,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC;QAC7B,GAAG,IAAI;QACP,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,SAAkB,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,eAAe,EAAE,MAAM;KACvB,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** A struct type's members, as the `types` field of a request declares them. */
2
+ export type TypedDataField = {
3
+ name: string;
4
+ type: string;
5
+ };
6
+ /** The `eth_signTypedData_v4` payload. */
7
+ export interface TypedData {
8
+ types: Record<string, readonly TypedDataField[]>;
9
+ primaryType: string;
10
+ domain: Record<string, unknown>;
11
+ message: Record<string, unknown>;
12
+ }
13
+ /** The domain separator: `hashStruct(eip712Domain)`. */
14
+ export declare function hashDomain(value: unknown): Uint8Array;
15
+ /**
16
+ * The EIP-712 digest a typed-data signature signs:
17
+ * `keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message))`.
18
+ * Throws an `Error` naming the offending path on a malformed payload.
19
+ */
20
+ export declare function hashTypedData(value: unknown): Uint8Array;
21
+ /** `encodeType` for one of the payload's types (exposed for tests). */
22
+ export declare function encodeType(types: Record<string, readonly TypedDataField[]>, primary: string): string;
23
+ //# sourceMappingURL=eip712.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip712.d.ts","sourceRoot":"","sources":["../src/eip712.ts"],"names":[],"mappings":"AA4CA,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC;AAE1D,0CAA0C;AAC1C,MAAM,WAAW,SAAS;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC,CAAC;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAiTD,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAWxD;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC,EAChD,OAAO,EAAE,MAAM,GACb,MAAM,CAER"}
package/dist/eip712.js ADDED
@@ -0,0 +1,333 @@
1
+ /**
2
+ * eip712.ts: EIP-712 typed structured data hashing, this package's own code (a
3
+ * maintainer decision, ADR 0017: "EIP-712 hashing is the package's own code"),
4
+ * with no dependency beyond the keccak the package already has.
5
+ *
6
+ * It follows the EIP's text (https://eips.ethereum.org/EIPS/eip-712):
7
+ *
8
+ * - `encode(domainSeparator, message) = "\x19\x01" ‖ domainSeparator ‖ hashStruct(message)`;
9
+ * - `hashStruct(s) = keccak256(typeHash ‖ encodeData(s))`, `typeHash = keccak256(encodeType(typeOf(s)))`;
10
+ * - `encodeType` is `Name(type1 name1,...)` for the primary type, followed by
11
+ * every type it references (directly or through other types or arrays),
12
+ * SORTED BY NAME, each once;
13
+ * - `encodeData` concatenates one 32-byte word per member, in declaration
14
+ * order: `bool`, `address`, `uintN`, `intN` (sign-extended) and `bytesN`
15
+ * (right-padded) encoded as the ABI encodes them; `bytes` and `string` as the
16
+ * keccak256 of their content (a string's UTF-8 bytes); a struct as its
17
+ * `hashStruct`; an array, fixed or dynamic, as the keccak256 of its elements'
18
+ * encodings concatenated.
19
+ *
20
+ * It is verified in tests against the EIP's own published `Mail` digest and
21
+ * against viem's `hashTypedData`, never against itself.
22
+ *
23
+ * DECISIONS made here (task `devnode-signing-methods-and-eip-712`), each
24
+ * user-visible and reversible before 1.0:
25
+ *
26
+ * - A MISSING `EIP712Domain` TYPE IS DERIVED from the fields the domain has, in
27
+ * the EIP's order (`name`, `version`, `chainId`, `verifyingContract`, `salt`),
28
+ * as viem and ethers derive it. Alternative: `@metamask/eth-sig-util`'s
29
+ * `EIP712Domain()` with no fields, which hashes the domain as empty and so
30
+ * ignores a chain ID the caller passed. A request that declares the type is
31
+ * hashed with exactly the declaration.
32
+ * - `primaryType: 'EIP712Domain'` hashes the domain alone, `"\x19\x01" ‖
33
+ * domainSeparator`, as viem and eth-sig-util do.
34
+ * - VALUES ARE CHECKED, NEVER COERCED INTO A DIFFERENT MEANING: a member
35
+ * missing from the message, an integer out of its type's range, a `bytesN`
36
+ * that is not exactly N bytes, an address that is not 20 bytes, a `bool` that
37
+ * is not a boolean, or a fixed-size array of the wrong length is an error
38
+ * naming the member's path. Integers are accepted as JSON numbers (safe
39
+ * integers only), decimal strings, hex strings (`0x`, `-0x` for a negative
40
+ * `intN`) and bigints. Members the message has beyond its type are ignored, as
41
+ * the EIP encodes only the type's members.
42
+ */
43
+ import { keccak_256 } from '@noble/hashes/sha3.js';
44
+ /** The fields an `EIP712Domain` may have, in the order the EIP lists them. */
45
+ const DOMAIN_FIELDS = [
46
+ { name: 'name', type: 'string' },
47
+ { name: 'version', type: 'string' },
48
+ { name: 'chainId', type: 'uint256' },
49
+ { name: 'verifyingContract', type: 'address' },
50
+ { name: 'salt', type: 'bytes32' },
51
+ ];
52
+ const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
53
+ const ARRAY_SUFFIX = /^(.*)\[(\d*)\]$/;
54
+ const HEX_DATA = /^0x([0-9a-fA-F]{2})*$/;
55
+ const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
56
+ const UINT = /^uint(\d{1,3})$/;
57
+ const INT = /^int(\d{1,3})$/;
58
+ const BYTES_N = /^bytes(\d{1,2})$/;
59
+ const encoder = new TextEncoder();
60
+ function fail(path, message) {
61
+ throw new Error(`${path}: ${message}`);
62
+ }
63
+ function concat(parts) {
64
+ let length = 0;
65
+ for (const p of parts)
66
+ length += p.length;
67
+ const out = new Uint8Array(length);
68
+ let offset = 0;
69
+ for (const p of parts) {
70
+ out.set(p, offset);
71
+ offset += p.length;
72
+ }
73
+ return out;
74
+ }
75
+ function hexToBytes(hex) {
76
+ const out = new Uint8Array((hex.length - 2) / 2);
77
+ for (let i = 0; i < out.length; i++)
78
+ out[i] = parseInt(hex.slice(2 + 2 * i, 4 + 2 * i), 16);
79
+ return out;
80
+ }
81
+ /** A non-negative bigint below 2^256 as one big-endian 32-byte word. */
82
+ function word(value) {
83
+ const out = new Uint8Array(32);
84
+ for (let i = 31; i >= 0; i--) {
85
+ out[i] = Number(value & 0xffn);
86
+ value >>= 8n;
87
+ }
88
+ return out;
89
+ }
90
+ /** The type an array type holds, or `undefined` for a non-array type. */
91
+ function arrayOf(type) {
92
+ const m = ARRAY_SUFFIX.exec(type);
93
+ if (!m)
94
+ return undefined;
95
+ return { item: m[1], length: m[2] === '' ? undefined : Number(m[2]) };
96
+ }
97
+ /** The struct (or atomic) type at the root of a possibly-array type. */
98
+ function baseType(type) {
99
+ let t = type;
100
+ for (let a = arrayOf(t); a; a = arrayOf(t))
101
+ t = a.item;
102
+ return t;
103
+ }
104
+ function isAtomic(type) {
105
+ if (type === 'bool' || type === 'address' || type === 'string')
106
+ return true;
107
+ if (type === 'bytes')
108
+ return true;
109
+ const u = UINT.exec(type) ?? INT.exec(type);
110
+ if (u) {
111
+ const bits = Number(u[1]);
112
+ return bits >= 8 && bits <= 256 && bits % 8 === 0;
113
+ }
114
+ const b = BYTES_N.exec(type);
115
+ if (b) {
116
+ const n = Number(b[1]);
117
+ return n >= 1 && n <= 32;
118
+ }
119
+ return false;
120
+ }
121
+ /** An integer value as a bigint, from the forms a JSON-RPC request carries. */
122
+ function integer(path, value) {
123
+ if (typeof value === 'bigint')
124
+ return value;
125
+ if (typeof value === 'number') {
126
+ if (!Number.isSafeInteger(value))
127
+ fail(path, `${value} is not a safe integer; pass a large integer as a decimal or hex string.`);
128
+ return BigInt(value);
129
+ }
130
+ if (typeof value === 'string') {
131
+ if (/^-?[0-9]+$/.test(value))
132
+ return BigInt(value);
133
+ if (/^0x[0-9a-fA-F]+$/.test(value))
134
+ return BigInt(value);
135
+ if (/^-0x[0-9a-fA-F]+$/.test(value))
136
+ return -BigInt(value.slice(1));
137
+ }
138
+ return fail(path, `expected an integer (a number, a decimal string or a hex string), received ${JSON.stringify(value)}.`);
139
+ }
140
+ function hexData(path, value) {
141
+ if (typeof value !== 'string' || !HEX_DATA.test(value))
142
+ fail(path, `expected even-length 0x hex, received ${JSON.stringify(value)}.`);
143
+ return hexToBytes(value);
144
+ }
145
+ /**
146
+ * The encoder for one typed-data payload: its struct types, checked once.
147
+ */
148
+ class Encoder {
149
+ types;
150
+ typeHashes = new Map();
151
+ constructor(types) {
152
+ this.types = types;
153
+ for (const [name, fields] of Object.entries(types)) {
154
+ if (!IDENTIFIER.test(name))
155
+ fail(`types.${name}`, 'is not a valid struct type name.');
156
+ if (isAtomic(name))
157
+ fail(`types.${name}`, 'is the name of an atomic type, not a struct.');
158
+ if (!Array.isArray(fields))
159
+ fail(`types.${name}`, 'must be an array of {name, type}.');
160
+ const seen = new Set();
161
+ fields.forEach((field, i) => {
162
+ const at = `types.${name}[${i}]`;
163
+ if (field === null ||
164
+ typeof field !== 'object' ||
165
+ typeof field.name !== 'string' ||
166
+ typeof field.type !== 'string')
167
+ fail(at, 'must be {name, type} with both strings.');
168
+ if (!IDENTIFIER.test(field.name))
169
+ fail(at, `${JSON.stringify(field.name)} is not a valid member name.`);
170
+ if (seen.has(field.name))
171
+ fail(at, `member ${field.name} is declared twice.`);
172
+ seen.add(field.name);
173
+ const base = baseType(field.type);
174
+ if (!isAtomic(base) && !(base in types))
175
+ fail(at, `type ${JSON.stringify(field.type)} is neither atomic nor declared in \`types\`.`);
176
+ });
177
+ }
178
+ }
179
+ /** The struct types `primary` references, itself included, each once. */
180
+ dependencies(primary, found = new Set()) {
181
+ if (found.has(primary) || !(primary in this.types))
182
+ return found;
183
+ found.add(primary);
184
+ for (const field of this.types[primary])
185
+ this.dependencies(baseType(field.type), found);
186
+ return found;
187
+ }
188
+ /** `encodeType`: the primary type, then its references sorted by name. */
189
+ encodeType(primary) {
190
+ const deps = [...this.dependencies(primary)].filter((t) => t !== primary);
191
+ deps.sort();
192
+ return [primary, ...deps]
193
+ .map((t) => `${t}(${this.types[t].map((f) => `${f.type} ${f.name}`).join(',')})`)
194
+ .join('');
195
+ }
196
+ typeHash(primary) {
197
+ let hash = this.typeHashes.get(primary);
198
+ if (!hash) {
199
+ hash = keccak_256(encoder.encode(this.encodeType(primary)));
200
+ this.typeHashes.set(primary, hash);
201
+ }
202
+ return hash;
203
+ }
204
+ /** `hashStruct`: keccak256(typeHash ‖ encodeData(data)). */
205
+ hashStruct(primary, data, path) {
206
+ if (!(primary in this.types))
207
+ fail(path, `type ${JSON.stringify(primary)} is not declared in \`types\`.`);
208
+ if (data === null || typeof data !== 'object' || Array.isArray(data))
209
+ fail(path, `expected an object of type ${primary}.`);
210
+ const record = data;
211
+ const words = [this.typeHash(primary)];
212
+ for (const field of this.types[primary]) {
213
+ const at = `${path}.${field.name}`;
214
+ if (record[field.name] === undefined)
215
+ fail(at, `member of ${primary} is missing.`);
216
+ words.push(this.encodeValue(field.type, record[field.name], at));
217
+ }
218
+ return keccak_256(concat(words));
219
+ }
220
+ /** One member's 32-byte encoding. */
221
+ encodeValue(type, value, path) {
222
+ const array = arrayOf(type);
223
+ if (array) {
224
+ if (!Array.isArray(value))
225
+ fail(path, `expected an array (${type}).`);
226
+ if (array.length !== undefined && value.length !== array.length)
227
+ fail(path, `expected ${array.length} elements (${type}), received ${value.length}.`);
228
+ return keccak_256(concat(value.map((v, i) => this.encodeValue(array.item, v, `${path}[${i}]`))));
229
+ }
230
+ if (type in this.types)
231
+ return this.hashStruct(type, value, path);
232
+ if (type === 'string') {
233
+ if (typeof value !== 'string')
234
+ fail(path, 'expected a string.');
235
+ return keccak_256(encoder.encode(value));
236
+ }
237
+ if (type === 'bytes')
238
+ return keccak_256(hexData(path, value));
239
+ if (type === 'bool') {
240
+ if (typeof value !== 'boolean')
241
+ fail(path, 'expected true or false.');
242
+ return word(value ? 1n : 0n);
243
+ }
244
+ if (type === 'address') {
245
+ if (typeof value !== 'string' || !ADDRESS.test(value))
246
+ fail(path, `expected a 20-byte 0x address, received ${JSON.stringify(value)}.`);
247
+ return word(BigInt(value));
248
+ }
249
+ const u = UINT.exec(type);
250
+ if (u) {
251
+ const bits = BigInt(u[1]);
252
+ const v = integer(path, value);
253
+ if (v < 0n || v >= 1n << bits)
254
+ fail(path, `${v} is out of range for ${type}.`);
255
+ return word(v);
256
+ }
257
+ const s = INT.exec(type);
258
+ if (s) {
259
+ const bits = BigInt(s[1]);
260
+ const v = integer(path, value);
261
+ const half = 1n << (bits - 1n);
262
+ if (v < -half || v >= half)
263
+ fail(path, `${v} is out of range for ${type}.`);
264
+ // Sign-extended to 256 bits: two's complement.
265
+ return word(v < 0n ? (1n << 256n) + v : v);
266
+ }
267
+ const b = BYTES_N.exec(type);
268
+ if (b) {
269
+ const n = Number(b[1]);
270
+ const bytes = hexData(path, value);
271
+ if (bytes.length !== n)
272
+ fail(path, `expected exactly ${n} bytes (${type}), received ${bytes.length}.`);
273
+ const out = new Uint8Array(32);
274
+ out.set(bytes);
275
+ return out;
276
+ }
277
+ return fail(path, `unknown type ${JSON.stringify(type)}.`);
278
+ }
279
+ }
280
+ /** The domain's struct type: the one declared, or derived from its fields. */
281
+ function domainFields(typed) {
282
+ const declared = typed.types.EIP712Domain;
283
+ if (declared)
284
+ return declared;
285
+ return DOMAIN_FIELDS.filter((f) => typed.domain[f.name] !== undefined);
286
+ }
287
+ /** Check the payload's shape, so the encoder can read it as {@link TypedData}. */
288
+ function asTypedData(value) {
289
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
290
+ fail('typedData', 'expected {types, primaryType, domain, message}.');
291
+ const t = value;
292
+ if (t.types === null || typeof t.types !== 'object' || Array.isArray(t.types))
293
+ fail('types', 'expected an object of struct types.');
294
+ if (typeof t.primaryType !== 'string')
295
+ fail('primaryType', 'expected the name of a type in `types`.');
296
+ const domain = t.domain ?? {};
297
+ if (domain === null || typeof domain !== 'object' || Array.isArray(domain))
298
+ fail('domain', 'expected an object.');
299
+ return {
300
+ types: t.types,
301
+ primaryType: t.primaryType,
302
+ domain: domain,
303
+ message: (t.message ?? {}),
304
+ };
305
+ }
306
+ /** The domain separator: `hashStruct(eip712Domain)`. */
307
+ export function hashDomain(value) {
308
+ const typed = asTypedData(value);
309
+ const types = { ...typed.types, EIP712Domain: domainFields(typed) };
310
+ return new Encoder(types).hashStruct('EIP712Domain', typed.domain, 'domain');
311
+ }
312
+ /**
313
+ * The EIP-712 digest a typed-data signature signs:
314
+ * `keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message))`.
315
+ * Throws an `Error` naming the offending path on a malformed payload.
316
+ */
317
+ export function hashTypedData(value) {
318
+ const typed = asTypedData(value);
319
+ const types = { ...typed.types, EIP712Domain: domainFields(typed) };
320
+ const enc = new Encoder(types);
321
+ const parts = [
322
+ Uint8Array.of(0x19, 0x01),
323
+ enc.hashStruct('EIP712Domain', typed.domain, 'domain'),
324
+ ];
325
+ if (typed.primaryType !== 'EIP712Domain')
326
+ parts.push(enc.hashStruct(typed.primaryType, typed.message, 'message'));
327
+ return keccak_256(concat(parts));
328
+ }
329
+ /** `encodeType` for one of the payload's types (exposed for tests). */
330
+ export function encodeType(types, primary) {
331
+ return new Encoder(types).encodeType(primary);
332
+ }
333
+ //# sourceMappingURL=eip712.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip712.js","sourceRoot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AC,UAAU,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC3C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,EAAC,GAAG,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,EAAC,CAAC;IAClE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG;QACb,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACzB,GAAG,CAAC,UAAU,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC;KACtD,CAAC;IACF,IAAI,KAAK,CAAC,WAAW,KAAK,cAAc;QACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IACzE,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,UAAU,CACzB,KAAgD,EAChD,OAAe;IAEf,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** The fabricated signature's scalars for `address` (lowercase 0x hex). */
2
+ export declare function fabricatedSignature(address: string): {
3
+ r: bigint;
4
+ s: bigint;
5
+ };
6
+ /** The message of a `4100` refusal to SIGN for an impersonated address. */
7
+ export declare function impersonatedNoKeyMessage(method: string, address: string): string;
8
+ /** The impersonation methods, under both name sets. */
9
+ export declare const IMPERSONATION_METHODS: Set<string>;
10
+ /** The impersonation methods' state and their answers. */
11
+ export interface Impersonation {
12
+ /** Whether the option is on. */
13
+ readonly enabled: boolean;
14
+ /** The impersonated addresses (lowercase), empty while off. */
15
+ readonly addresses: ReadonlySet<string>;
16
+ /** Answer one of {@link IMPERSONATION_METHODS}. */
17
+ request(method: string, params: unknown): null;
18
+ }
19
+ export declare function createImpersonation(enabled: boolean): Impersonation;
20
+ //# sourceMappingURL=impersonation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"impersonation.d.ts","sourceRoot":"","sources":["../src/impersonation.ts"],"names":[],"mappings":"AAoDA,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAC,CAS3E;AAED,2EAA2E;AAC3E,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACb,MAAM,CAMR;AAED,uDAAuD;AACvD,eAAO,MAAM,qBAAqB,aAKhC,CAAC;AAEH,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC7B,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,mDAAmD;IACnD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/C;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAwBnE"}