@marigoldlabs/web3-tester 0.1.2 → 0.4.2
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/.env.example +26 -17
- package/LICENSE +21 -0
- package/README.md +480 -48
- package/dist/anvil.d.ts +90 -2
- package/dist/anvil.d.ts.map +1 -1
- package/dist/anvil.js +215 -13
- package/dist/anvil.js.map +1 -1
- package/dist/benchmark.d.ts +55 -0
- package/dist/benchmark.d.ts.map +1 -0
- package/dist/benchmark.js +168 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/contracts/test-erc20.d.ts +227 -0
- package/dist/contracts/test-erc20.d.ts.map +1 -0
- package/dist/contracts/test-erc20.js +8 -0
- package/dist/contracts/test-erc20.js.map +1 -0
- package/dist/erc20.d.ts +38 -0
- package/dist/erc20.d.ts.map +1 -0
- package/dist/erc20.js +229 -0
- package/dist/erc20.js.map +1 -0
- package/dist/fixtures.d.ts +44 -2
- package/dist/fixtures.d.ts.map +1 -1
- package/dist/fixtures.js +162 -17
- package/dist/fixtures.js.map +1 -1
- package/dist/index.d.ts +26 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/injected-provider.d.ts.map +1 -1
- package/dist/injected-provider.js +863 -77
- package/dist/injected-provider.js.map +1 -1
- package/dist/live-fixtures.d.ts +32 -3
- package/dist/live-fixtures.d.ts.map +1 -1
- package/dist/live-fixtures.js +64 -27
- package/dist/live-fixtures.js.map +1 -1
- package/dist/matchers.d.ts +90 -0
- package/dist/matchers.d.ts.map +1 -0
- package/dist/matchers.js +268 -0
- package/dist/matchers.js.map +1 -0
- package/dist/metamask-extension.d.ts +34 -0
- package/dist/metamask-extension.d.ts.map +1 -0
- package/dist/metamask-extension.js +97 -0
- package/dist/metamask-extension.js.map +1 -0
- package/dist/mock-wallet-controller.d.ts +354 -4
- package/dist/mock-wallet-controller.d.ts.map +1 -1
- package/dist/mock-wallet-controller.js +1444 -58
- package/dist/mock-wallet-controller.js.map +1 -1
- package/dist/private-key-rpc-client.d.ts +1744 -2
- package/dist/private-key-rpc-client.d.ts.map +1 -1
- package/dist/private-key-rpc-client.js +245 -30
- package/dist/private-key-rpc-client.js.map +1 -1
- package/dist/real-wallet-cache.d.ts +103 -0
- package/dist/real-wallet-cache.d.ts.map +1 -0
- package/dist/real-wallet-cache.js +331 -0
- package/dist/real-wallet-cache.js.map +1 -0
- package/dist/real-wallet-extension-fixtures.d.ts +35 -0
- package/dist/real-wallet-extension-fixtures.d.ts.map +1 -0
- package/dist/real-wallet-extension-fixtures.js +96 -0
- package/dist/real-wallet-extension-fixtures.js.map +1 -0
- package/dist/real-wallet-extension.d.ts +86 -0
- package/dist/real-wallet-extension.d.ts.map +1 -0
- package/dist/real-wallet-extension.js +245 -0
- package/dist/real-wallet-extension.js.map +1 -0
- package/dist/real-wallet-fixtures.d.ts +52 -0
- package/dist/real-wallet-fixtures.d.ts.map +1 -0
- package/dist/real-wallet-fixtures.js +88 -0
- package/dist/real-wallet-fixtures.js.map +1 -0
- package/dist/real-wallet.d.ts +119 -19
- package/dist/real-wallet.d.ts.map +1 -1
- package/dist/real-wallet.js +1656 -144
- package/dist/real-wallet.js.map +1 -1
- package/dist/safe.d.ts +311 -0
- package/dist/safe.d.ts.map +1 -0
- package/dist/safe.js +743 -0
- package/dist/safe.js.map +1 -0
- package/dist/transactions.d.ts +118 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/transactions.js +207 -0
- package/dist/transactions.js.map +1 -0
- package/dist/types.d.ts +36 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/wallet-personas.d.ts +99 -0
- package/dist/wallet-personas.d.ts.map +1 -0
- package/dist/wallet-personas.js +666 -0
- package/dist/wallet-personas.js.map +1 -0
- package/dist/walletconnect.d.ts +373 -0
- package/dist/walletconnect.d.ts.map +1 -0
- package/dist/walletconnect.js +799 -0
- package/dist/walletconnect.js.map +1 -0
- package/examples/live-sepolia.spec.ts +20 -1
- package/examples/playwright.config.ts +8 -0
- package/package.json +90 -8
- package/docs/API.md +0 -223
- package/docs/ARCHITECTURE.md +0 -81
- package/docs/CONSUMING_FROM_FJORD.md +0 -123
- package/docs/FJORD_LIVE_QA.md +0 -87
- package/docs/RELEASE_CHECKLIST.md +0 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-key-rpc-client.d.ts","sourceRoot":"","sources":["../src/private-key-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"private-key-rpc-client.d.ts","sourceRoot":"","sources":["../src/private-key-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,GAAG,EAET,MAAM,MAAM,CAAC;AAId,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,GAAG,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AA4BF,KAAK,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AA4JrF,qBAAa,mBAAoB,YAAW,SAAS;IACnD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAM;IACtC,QAAQ,CAAC,uBAAuB,EAAE,KAAK,CAAC;QACtC,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA3E3t4B;IAED,wEAAwE;IAClE,iBAAiB,CAAC,OAAO,EAAE;QAC/B,eAAe,EAAE,GAAG,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;YAaa,qBAAqB;IAgBnC,OAAO,CAAC,wBAAwB;CAqCjC"}
|
|
@@ -1,24 +1,159 @@
|
|
|
1
|
-
import { createPublicClient, createWalletClient,
|
|
1
|
+
import { createPublicClient, createWalletClient, http, isAddress, } from 'viem';
|
|
2
2
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
3
|
import { sepolia } from 'viem/chains';
|
|
4
|
+
import { providerError } from './errors.js';
|
|
5
|
+
// Anvil/Hardhat chains are safe targets but viem does not mark them
|
|
6
|
+
// `testnet: true`, so they need their own allowlist entry.
|
|
7
|
+
const LOCAL_DEV_CHAIN_IDS = new Set([1337, 31337]);
|
|
8
|
+
const isTestChain = (chain) => chain.testnet === true || LOCAL_DEV_CHAIN_IDS.has(chain.id);
|
|
4
9
|
const normalizePrivateKey = (privateKey) => {
|
|
5
10
|
const trimmed = privateKey.trim();
|
|
6
11
|
return trimmed.startsWith('0x') ? trimmed : `0x${trimmed}`;
|
|
7
12
|
};
|
|
8
13
|
const asHex = (value) => typeof value === 'string' && value.startsWith('0x') ? value : undefined;
|
|
14
|
+
// Hex payloads must be signed as raw bytes: decoding to UTF-8 first corrupts
|
|
15
|
+
// binary messages (TextDecoder substitutes U+FFFD instead of throwing), and for
|
|
16
|
+
// valid UTF-8 text the EIP-191 digest over the raw bytes is identical anyway.
|
|
9
17
|
const normalizeMessage = (message) => {
|
|
10
18
|
const hex = asHex(message);
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
return hex ? { raw: hex } : String(message ?? '');
|
|
20
|
+
};
|
|
21
|
+
const parseParams = (request) => Array.isArray(request.params) ? [...request.params] : [];
|
|
22
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
23
|
+
const parseAddressField = (value, field) => {
|
|
24
|
+
if (value === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (typeof value === 'string' && isAddress(value))
|
|
27
|
+
return value;
|
|
28
|
+
throw new Error(`${field} must be a valid address.`);
|
|
29
|
+
};
|
|
30
|
+
const parseNullableAddressField = (value, field) => {
|
|
31
|
+
if (value === null)
|
|
32
|
+
return null;
|
|
33
|
+
return parseAddressField(value, field);
|
|
34
|
+
};
|
|
35
|
+
const parseHexField = (value, field) => {
|
|
36
|
+
if (value === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
if (typeof value === 'string' && value.startsWith('0x'))
|
|
39
|
+
return value;
|
|
40
|
+
throw new Error(`${field} must be a 0x-prefixed hex string.`);
|
|
41
|
+
};
|
|
42
|
+
const parseHexArrayField = (value, field) => {
|
|
43
|
+
if (value === undefined)
|
|
44
|
+
return undefined;
|
|
45
|
+
if (!Array.isArray(value))
|
|
46
|
+
throw new Error(`${field} must be an array.`);
|
|
47
|
+
return value.map((entry, index) => {
|
|
48
|
+
if (typeof entry === 'string' && entry.startsWith('0x'))
|
|
49
|
+
return entry;
|
|
50
|
+
throw new Error(`${field}[${index}] must be a 0x-prefixed hex string.`);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const parseQuantity = (value, field) => {
|
|
54
|
+
if (value === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
if (typeof value === 'bigint')
|
|
57
|
+
return value;
|
|
58
|
+
if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0)
|
|
59
|
+
return BigInt(value);
|
|
60
|
+
if (typeof value === 'string') {
|
|
61
|
+
try {
|
|
62
|
+
return BigInt(value);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Fall through to the shared error below.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw new Error(`${field} must be a non-negative integer, bigint, decimal string, or 0x-hex quantity.`);
|
|
69
|
+
};
|
|
70
|
+
const parseIndex = (value, field) => {
|
|
71
|
+
const quantity = parseQuantity(value, field);
|
|
72
|
+
if (quantity === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
const parsed = Number(quantity);
|
|
75
|
+
if (!Number.isSafeInteger(parsed))
|
|
76
|
+
throw new Error(`${field} is too large to fit in a JavaScript number.`);
|
|
77
|
+
return parsed;
|
|
78
|
+
};
|
|
79
|
+
const parseChainId = (value) => parseIndex(value, 'chainId');
|
|
80
|
+
const transactionTypeAliases = {
|
|
81
|
+
'0x0': 'legacy',
|
|
82
|
+
'0x1': 'eip2930',
|
|
83
|
+
'0x2': 'eip1559',
|
|
84
|
+
'0x3': 'eip4844',
|
|
85
|
+
'0x4': 'eip7702',
|
|
86
|
+
legacy: 'legacy',
|
|
87
|
+
eip2930: 'eip2930',
|
|
88
|
+
eip1559: 'eip1559',
|
|
89
|
+
eip4844: 'eip4844',
|
|
90
|
+
eip7702: 'eip7702',
|
|
91
|
+
};
|
|
92
|
+
const parseTransactionType = (value) => {
|
|
93
|
+
if (value === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
if (typeof value !== 'string')
|
|
96
|
+
throw new Error('type must be a transaction type string.');
|
|
97
|
+
const normalized = value.toLowerCase();
|
|
98
|
+
const type = transactionTypeAliases[normalized];
|
|
99
|
+
if (!type) {
|
|
100
|
+
throw new Error(`Unsupported transaction type "${value}". Expected legacy/eip2930/eip1559/eip4844/eip7702 or 0x0-0x4.`);
|
|
13
101
|
}
|
|
14
|
-
|
|
15
|
-
|
|
102
|
+
return type;
|
|
103
|
+
};
|
|
104
|
+
const parseAccessList = (value) => {
|
|
105
|
+
if (value === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
if (!Array.isArray(value))
|
|
108
|
+
throw new Error('accessList must be an array.');
|
|
109
|
+
return value.map((entry, index) => {
|
|
110
|
+
if (!isRecord(entry))
|
|
111
|
+
throw new Error(`accessList[${index}] must be an object.`);
|
|
112
|
+
const address = parseAddressField(entry.address, `accessList[${index}].address`);
|
|
113
|
+
if (!address)
|
|
114
|
+
throw new Error(`accessList[${index}].address is required.`);
|
|
115
|
+
const storageKeys = parseHexArrayField(entry.storageKeys, `accessList[${index}].storageKeys`);
|
|
116
|
+
return {
|
|
117
|
+
address,
|
|
118
|
+
storageKeys: storageKeys ?? [],
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
// Dapp-supplied authorization entries are RPC-shaped (hex chainId/nonce/
|
|
123
|
+
// yParity) while viem's sendTransaction expects numbers — a silent
|
|
124
|
+
// passthrough would RLP-encode garbage, so malformed entries fail loudly.
|
|
125
|
+
const parseAuthorizationList = (value) => {
|
|
126
|
+
if (value === undefined) {
|
|
127
|
+
return undefined;
|
|
16
128
|
}
|
|
17
|
-
|
|
18
|
-
|
|
129
|
+
if (!Array.isArray(value)) {
|
|
130
|
+
throw new Error('authorizationList must be an array.');
|
|
19
131
|
}
|
|
132
|
+
return value.map((entry, index) => {
|
|
133
|
+
const item = (entry ?? {});
|
|
134
|
+
const address = (item.address ?? item.contractAddress);
|
|
135
|
+
if (typeof address !== 'string' || !address.startsWith('0x')) {
|
|
136
|
+
throw new Error(`authorizationList[${index}] needs an address.`);
|
|
137
|
+
}
|
|
138
|
+
const toNumber = (raw, name) => {
|
|
139
|
+
if (typeof raw === 'number') {
|
|
140
|
+
return raw;
|
|
141
|
+
}
|
|
142
|
+
if (typeof raw === 'string' && raw.startsWith('0x')) {
|
|
143
|
+
return Number(BigInt(raw));
|
|
144
|
+
}
|
|
145
|
+
throw new Error(`authorizationList[${index}].${name} must be a number or 0x-hex string.`);
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
address: address,
|
|
149
|
+
chainId: toNumber(item.chainId, 'chainId'),
|
|
150
|
+
nonce: toNumber(item.nonce, 'nonce'),
|
|
151
|
+
r: item.r,
|
|
152
|
+
s: item.s,
|
|
153
|
+
yParity: toNumber(item.yParity ?? 0, 'yParity'),
|
|
154
|
+
};
|
|
155
|
+
});
|
|
20
156
|
};
|
|
21
|
-
const parseParams = (request) => Array.isArray(request.params) ? [...request.params] : [];
|
|
22
157
|
export class PrivateKeyRpcClient {
|
|
23
158
|
account;
|
|
24
159
|
chain;
|
|
@@ -26,8 +161,14 @@ export class PrivateKeyRpcClient {
|
|
|
26
161
|
sentTransactionRequests = [];
|
|
27
162
|
publicClient;
|
|
28
163
|
walletClient;
|
|
164
|
+
rpcChainVerified = false;
|
|
29
165
|
constructor(options) {
|
|
30
166
|
this.chain = options.chain ?? sepolia;
|
|
167
|
+
if (!options.allowMainnet && !isTestChain(this.chain)) {
|
|
168
|
+
throw new Error(`PrivateKeyRpcClient refuses chain "${this.chain.name}" (id ${this.chain.id}) because it is not marked as a testnet. ` +
|
|
169
|
+
'This client signs and broadcasts without confirmation prompts. Pass allowMainnet: true to target a production chain, ' +
|
|
170
|
+
'or use a chain definition with testnet: true.');
|
|
171
|
+
}
|
|
31
172
|
this.account = privateKeyToAccount(normalizePrivateKey(options.privateKey));
|
|
32
173
|
const transport = http(options.rpcUrl);
|
|
33
174
|
this.publicClient = createPublicClient({
|
|
@@ -43,11 +184,20 @@ export class PrivateKeyRpcClient {
|
|
|
43
184
|
async request(request) {
|
|
44
185
|
const params = parseParams(request);
|
|
45
186
|
switch (request.method) {
|
|
187
|
+
// Answered locally: the client holds exactly one key, and remote RPC
|
|
188
|
+
// nodes answer [] (a needless network roundtrip that would also blind
|
|
189
|
+
// MockWalletController's account validation in live mode).
|
|
190
|
+
case 'eth_accounts':
|
|
191
|
+
return [this.account.address];
|
|
46
192
|
case 'personal_sign': {
|
|
193
|
+
// Standard order is [message, address]; some legacy callers send
|
|
194
|
+
// [address, message]. When both params are addresses the request is
|
|
195
|
+
// ambiguous, so prefer the standard order and treat the first as the
|
|
196
|
+
// message.
|
|
47
197
|
const [first, second] = params;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
198
|
+
const firstIsAddress = typeof first === 'string' && isAddress(first);
|
|
199
|
+
const secondIsAddress = typeof second === 'string' && isAddress(second);
|
|
200
|
+
const message = firstIsAddress && !secondIsAddress && second !== undefined ? second : first;
|
|
51
201
|
return this.walletClient.signMessage({
|
|
52
202
|
account: this.account,
|
|
53
203
|
message: normalizeMessage(message),
|
|
@@ -60,6 +210,9 @@ export class PrivateKeyRpcClient {
|
|
|
60
210
|
message: normalizeMessage(message),
|
|
61
211
|
});
|
|
62
212
|
}
|
|
213
|
+
// v3 payloads (no arrays or recursive structs) hash identically under
|
|
214
|
+
// v4 rules, so both versions share the same signing path.
|
|
215
|
+
case 'eth_signTypedData_v3':
|
|
63
216
|
case 'eth_signTypedData_v4': {
|
|
64
217
|
const [, typedData] = params;
|
|
65
218
|
const parsed = typeof typedData === 'string'
|
|
@@ -73,34 +226,40 @@ export class PrivateKeyRpcClient {
|
|
|
73
226
|
types: parsed.types,
|
|
74
227
|
});
|
|
75
228
|
}
|
|
229
|
+
case 'eth_signTypedData':
|
|
230
|
+
throw new Error('eth_signTypedData (legacy v1) is not supported by PrivateKeyRpcClient. Use eth_signTypedData_v4.');
|
|
231
|
+
// Also a broadcast — it must not slip past the chain check through the
|
|
232
|
+
// default passthrough.
|
|
233
|
+
case 'eth_sendRawTransaction': {
|
|
234
|
+
await this.assertRpcChainMatches();
|
|
235
|
+
const hash = (await this.publicClient.request(request));
|
|
236
|
+
this.sentTransactions.push(hash);
|
|
237
|
+
this.sentTransactionRequests.push({ hash });
|
|
238
|
+
return hash;
|
|
239
|
+
}
|
|
76
240
|
case 'eth_sendTransaction': {
|
|
77
241
|
const [transaction] = params;
|
|
78
242
|
if (!transaction) {
|
|
79
243
|
throw new Error('eth_sendTransaction requires a transaction object.');
|
|
80
244
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
chain: this.chain,
|
|
84
|
-
to: transaction.to,
|
|
85
|
-
data: transaction.data,
|
|
86
|
-
value: transaction.value ? BigInt(transaction.value) : undefined,
|
|
87
|
-
gas: transaction.gas ? BigInt(transaction.gas) : undefined,
|
|
88
|
-
gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : undefined,
|
|
89
|
-
nonce: transaction.nonce ? Number(BigInt(transaction.nonce)) : undefined,
|
|
90
|
-
maxFeePerGas: transaction.maxFeePerGas
|
|
91
|
-
? BigInt(transaction.maxFeePerGas)
|
|
92
|
-
: undefined,
|
|
93
|
-
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
|
|
94
|
-
? BigInt(transaction.maxPriorityFeePerGas)
|
|
95
|
-
: undefined,
|
|
96
|
-
};
|
|
245
|
+
await this.assertRpcChainMatches();
|
|
246
|
+
const request = this.toSendTransactionRequest(transaction);
|
|
97
247
|
const hash = await this.walletClient.sendTransaction(request);
|
|
98
248
|
this.sentTransactions.push(hash);
|
|
99
249
|
this.sentTransactionRequests.push({
|
|
250
|
+
accessList: request.accessList,
|
|
251
|
+
from: this.account.address,
|
|
252
|
+
gas: request.gas?.toString(),
|
|
253
|
+
gasPrice: request.gasPrice?.toString(),
|
|
100
254
|
hash,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
255
|
+
maxFeePerBlobGas: request.maxFeePerBlobGas?.toString(),
|
|
256
|
+
maxFeePerGas: request.maxFeePerGas?.toString(),
|
|
257
|
+
maxPriorityFeePerGas: request.maxPriorityFeePerGas?.toString(),
|
|
258
|
+
nonce: request.nonce,
|
|
259
|
+
to: request.to,
|
|
260
|
+
data: request.data,
|
|
261
|
+
type: request.type,
|
|
262
|
+
value: request.value?.toString(),
|
|
104
263
|
});
|
|
105
264
|
return hash;
|
|
106
265
|
}
|
|
@@ -108,5 +267,61 @@ export class PrivateKeyRpcClient {
|
|
|
108
267
|
return this.publicClient.request(request);
|
|
109
268
|
}
|
|
110
269
|
}
|
|
270
|
+
/** Read-only viem public client backing this wallet (matchers, receipt waits). */
|
|
271
|
+
get client() {
|
|
272
|
+
return this.publicClient;
|
|
273
|
+
}
|
|
274
|
+
/** Signs an EIP-7702 authorization with this client's local account. */
|
|
275
|
+
async signAuthorization(options) {
|
|
276
|
+
return this.walletClient.signAuthorization({
|
|
277
|
+
account: this.account,
|
|
278
|
+
contractAddress: options.contractAddress,
|
|
279
|
+
chainId: options.chainId,
|
|
280
|
+
nonce: options.nonce,
|
|
281
|
+
executor: options.executor,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// A mismatched rpcUrl/chain pair must fail loudly before anything is
|
|
285
|
+
// broadcast; success is cached, failures retry so a transient RPC error
|
|
286
|
+
// does not poison the client.
|
|
287
|
+
async assertRpcChainMatches() {
|
|
288
|
+
if (this.rpcChainVerified) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const reportedChainId = await this.publicClient.getChainId();
|
|
292
|
+
if (reportedChainId !== this.chain.id) {
|
|
293
|
+
throw new Error(`The RPC endpoint reports chain id ${reportedChainId} but this client is configured for "${this.chain.name}" (id ${this.chain.id}). ` +
|
|
294
|
+
'Refusing to broadcast. Check the rpcUrl and chain options.');
|
|
295
|
+
}
|
|
296
|
+
this.rpcChainVerified = true;
|
|
297
|
+
}
|
|
298
|
+
toSendTransactionRequest(transaction) {
|
|
299
|
+
const from = parseAddressField(transaction.from, 'from');
|
|
300
|
+
if (from && from.toLowerCase() !== this.account.address.toLowerCase()) {
|
|
301
|
+
throw providerError(4100, `eth_sendTransaction requested from ${from}, but this PrivateKeyRpcClient only controls ${this.account.address}.`);
|
|
302
|
+
}
|
|
303
|
+
const chainId = parseChainId(transaction.chainId);
|
|
304
|
+
if (chainId !== undefined && chainId !== this.chain.id) {
|
|
305
|
+
throw new Error(`eth_sendTransaction chainId ${chainId} does not match configured chain "${this.chain.name}" (id ${this.chain.id}).`);
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
account: this.account,
|
|
309
|
+
accessList: parseAccessList(transaction.accessList),
|
|
310
|
+
authorizationList: parseAuthorizationList(transaction.authorizationList),
|
|
311
|
+
blobVersionedHashes: parseHexArrayField(transaction.blobVersionedHashes, 'blobVersionedHashes'),
|
|
312
|
+
blobs: parseHexArrayField(transaction.blobs, 'blobs'),
|
|
313
|
+
chain: this.chain,
|
|
314
|
+
data: parseHexField(transaction.data ?? transaction.input, 'data'),
|
|
315
|
+
gas: parseQuantity(transaction.gas, 'gas'),
|
|
316
|
+
gasPrice: parseQuantity(transaction.gasPrice, 'gasPrice'),
|
|
317
|
+
maxFeePerBlobGas: parseQuantity(transaction.maxFeePerBlobGas, 'maxFeePerBlobGas'),
|
|
318
|
+
maxFeePerGas: parseQuantity(transaction.maxFeePerGas, 'maxFeePerGas'),
|
|
319
|
+
maxPriorityFeePerGas: parseQuantity(transaction.maxPriorityFeePerGas, 'maxPriorityFeePerGas'),
|
|
320
|
+
nonce: parseIndex(transaction.nonce, 'nonce'),
|
|
321
|
+
to: parseNullableAddressField(transaction.to, 'to'),
|
|
322
|
+
type: parseTransactionType(transaction.type),
|
|
323
|
+
value: parseQuantity(transaction.value, 'value'),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
111
326
|
}
|
|
112
327
|
//# sourceMappingURL=private-key-rpc-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-key-rpc-client.js","sourceRoot":"","sources":["../src/private-key-rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,IAAI,EACJ,SAAS,GAKV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,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CAAC;YAC7C,EAAE,EAAE,yBAAyB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC;YACnD,IAAI,EAAE,oBAAoB,CAAC,WAAW,CAAC,IAAI,CAAC;YAC5C,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC;SACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type RealWalletExtensionLaunchOptions, type RealWalletExtensionSession } from './real-wallet-extension.js';
|
|
2
|
+
import { type RealWalletSession, type RealWalletSetup, type WalletGeneration } from './real-wallet.js';
|
|
3
|
+
export type BuildWalletProfileOptions = {
|
|
4
|
+
/** Unpacked MetaMask extension directory (see prepareMetaMaskExtension). */
|
|
5
|
+
extensionPath: string;
|
|
6
|
+
/** Wallet setup; seedPhrase is required to build a profile. */
|
|
7
|
+
setup: RealWalletSetup;
|
|
8
|
+
/** Directory cached profiles live in. Defaults to ~/.cache/web3-tester/profiles. */
|
|
9
|
+
cacheDir?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Run the one-time onboarding headless. No default — set it here or via
|
|
12
|
+
* WEB3_TESTER_REAL_WALLET_HEADLESS=true|false (see RealWalletLaunchOptions).
|
|
13
|
+
*/
|
|
14
|
+
headless?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* UI generation to drive during onboarding/customization. Defaults to the
|
|
17
|
+
* extension manifest's major version; set it (matching the per-test launch)
|
|
18
|
+
* for custom builds whose manifest version does not reflect their UI.
|
|
19
|
+
*/
|
|
20
|
+
generation?: WalletGeneration;
|
|
21
|
+
/** Rebuild even if a cached profile exists. */
|
|
22
|
+
force?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* One-time profile customization (import keys, add accounts/networks/
|
|
25
|
+
* tokens) baked into the cached profile — `key` joins the cache key, so
|
|
26
|
+
* bump it whenever `run` changes. The builder waits for extension state to
|
|
27
|
+
* flush to disk (13.x persists to IndexedDB with a debounce) before
|
|
28
|
+
* closing, so mutations survive profile close. Note: whatever account/
|
|
29
|
+
* network `run` leaves selected is what every cloned per-test profile
|
|
30
|
+
* boots with — switch back to the primary account before returning if
|
|
31
|
+
* tests expect the defaults.
|
|
32
|
+
*/
|
|
33
|
+
customize?: {
|
|
34
|
+
key: string;
|
|
35
|
+
run(session: RealWalletSession): Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type BuildWalletExtensionProfileOptions = Omit<RealWalletExtensionLaunchOptions, 'profileDir'> & {
|
|
39
|
+
/**
|
|
40
|
+
* User-controlled cache identity for the setup callback and any external
|
|
41
|
+
* wallet state it depends on (seed phrase, imported key, test account,
|
|
42
|
+
* network config, etc.). Bump this whenever setup changes.
|
|
43
|
+
*/
|
|
44
|
+
cacheKey: string;
|
|
45
|
+
/** Directory cached profiles live in. Defaults to ~/.cache/web3-tester/profiles. */
|
|
46
|
+
cacheDir?: string;
|
|
47
|
+
/** Rebuild even if a cached profile exists. */
|
|
48
|
+
force?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* One-time extension setup baked into the cached profile. Use this to
|
|
51
|
+
* unlock/import/onboard Rabby, Coinbase Wallet, Phantom, or other
|
|
52
|
+
* non-MetaMask Chromium wallets with wallet-specific Playwright locators.
|
|
53
|
+
*/
|
|
54
|
+
setup?: {
|
|
55
|
+
run(session: RealWalletExtensionSession): Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Wait for extension storage writes before closing. Defaults to true when
|
|
59
|
+
* setup is provided, false otherwise. Pass false for setup callbacks that do
|
|
60
|
+
* not mutate persisted extension state.
|
|
61
|
+
*/
|
|
62
|
+
waitForState?: boolean | {
|
|
63
|
+
quietMs?: number;
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Polls the profile's extension storage (IndexedDB leveldb + blob and Local
|
|
69
|
+
* Extension Settings) from Node until a write newer than `since` lands and
|
|
70
|
+
* the directories stay quiet for `quietMs` (default 1500ms — 500ms of margin
|
|
71
|
+
* above MetaMask 13.x's verified 1000ms OperationSafener debounce). Times
|
|
72
|
+
* out silently; the customize-persistence smoke test is the regression trap
|
|
73
|
+
* for a missed flush.
|
|
74
|
+
*/
|
|
75
|
+
export declare function waitForExtensionStatePersisted(profileDir: string, extensionId: string, options?: {
|
|
76
|
+
since?: number;
|
|
77
|
+
quietMs?: number;
|
|
78
|
+
timeoutMs?: number;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
export declare const defaultProfileCacheDir: () => string;
|
|
81
|
+
/**
|
|
82
|
+
* Builds (once) and returns a cached, fully onboarded MetaMask profile
|
|
83
|
+
* directory keyed by (seed phrase, password, extension version). The first
|
|
84
|
+
* call walks MetaMask onboarding in a real browser; subsequent calls return
|
|
85
|
+
* instantly. Use cloneWalletProfile to obtain a disposable per-test copy —
|
|
86
|
+
* never launch the cached directory directly.
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildWalletProfile(options: BuildWalletProfileOptions): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Builds (once) and returns a cached profile for any unpacked Chromium wallet
|
|
91
|
+
* extension. The caller owns wallet-specific onboarding/unlock selectors in
|
|
92
|
+
* `setup.run`; this helper only supplies the persistent profile, extension
|
|
93
|
+
* launch, cache locking, ready marker, and optional extension-state flush.
|
|
94
|
+
* Use cloneWalletProfile to obtain disposable per-test copies.
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildWalletExtensionProfile(options: BuildWalletExtensionProfileOptions): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Copies a cached profile into a disposable directory (per test or per
|
|
99
|
+
* worker) so parallel runs never collide on Chromium's profile singleton
|
|
100
|
+
* lock and tests cannot dirty the cache.
|
|
101
|
+
*/
|
|
102
|
+
export declare function cloneWalletProfile(cachedProfileDir: string, targetDir: string): Promise<string>;
|
|
103
|
+
//# sourceMappingURL=real-wallet-cache.d.ts.map
|
|
@@ -0,0 +1 @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