Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1daf872f8 |
@@ -2097,7 +2097,7 @@ view would leave a wallet one click from deletion.
|
||||
and raw data are read from that network's Blockscout, the one Settings has for
|
||||
it, and its etherscan links open that network's explorer. They are read only
|
||||
while "Use Blockscout" is on. The screen can still be shown with it off, when
|
||||
the user opens Settings from it, turns the setting off and presses Back; then
|
||||
the popup reopens onto it after the user turned the setting off; then
|
||||
Blockscout is not asked, and a line in their place says "No block, decoded
|
||||
details, network details or raw data are shown, because "Use Blockscout" is
|
||||
off in Settings."
|
||||
@@ -2752,12 +2752,9 @@ Contacted by default:
|
||||
them the balance of every tracked token at every address (`balanceOf`),
|
||||
estimate gas (`eth_estimateGas`), fetch nonces (`eth_getTransactionCount`),
|
||||
broadcast transactions (`eth_sendRawTransaction`), and check transaction
|
||||
receipts. ENS lookups, of a name typed into Send and of the names shown for
|
||||
the user's addresses, are made through it alone, so a name whose resolver says
|
||||
it is resolved off-chain does not resolve. The default endpoint is a public
|
||||
RPC (configurable by the user to any endpoint they prefer, including a local
|
||||
node). By default the extension talks to
|
||||
`https://ethereum-rpc.publicnode.com`.
|
||||
receipts. The default endpoint is a public RPC (configurable by the user to
|
||||
any endpoint they prefer, including a local node). By default the extension
|
||||
talks to `https://ethereum-rpc.publicnode.com`.
|
||||
- **Data sent**: Ethereum addresses, transaction data, contract call
|
||||
parameters. The RPC endpoint can see all on-chain queries and submitted
|
||||
transactions.
|
||||
|
||||
+1
-10
@@ -38,18 +38,9 @@ const { resolveTokenDecimals } = require("./approvalAmount");
|
||||
// ethers knows chains this wallet does not, so an id that is not one of ours
|
||||
// is a caller bug and must not resolve to a working provider for some other
|
||||
// chain.
|
||||
//
|
||||
// `disableCcipRead` keeps every ENS lookup on the RPC endpoint. Left on, as
|
||||
// ethers has it, a resolver that says a name is resolved off-chain makes ethers
|
||||
// fetch the web address the resolver gives, straight from the browser, with the
|
||||
// name being looked up; for the reverse lookup of the user's addresses that is
|
||||
// the user's own name (https://git.eeqj.de/sneak/AutistMask/issues/668). Such a
|
||||
// name does not resolve.
|
||||
function getProvider(rpcUrl, networkId) {
|
||||
const net = Network.from(requireNetworkId(networkId).id);
|
||||
const provider = new JsonRpcProvider(rpcUrl, net, { staticNetwork: net });
|
||||
provider.disableCcipRead = true;
|
||||
return provider;
|
||||
return new JsonRpcProvider(rpcUrl, net, { staticNetwork: net });
|
||||
}
|
||||
|
||||
function requireNetworkId(networkId) {
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
// ENS lookups ask nothing but the RPC endpoint. A resolver can answer that a
|
||||
// name is resolved off-chain, naming a web address to fetch the answer from;
|
||||
// ethers fetches it unless the provider has `disableCcipRead` set, and that
|
||||
// request would carry the name to a server other than the RPC endpoint
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/668). With it set, such a name
|
||||
// does not resolve.
|
||||
//
|
||||
// The provider getProvider() builds runs against a fake JSON-RPC node,
|
||||
// answered through ethers' own request hook, which also records the address of
|
||||
// every request ethers makes, the off-chain fetch included.
|
||||
|
||||
const { FetchRequest, Interface } = require("ethers");
|
||||
const { getProvider } = require("../src/shared/balances");
|
||||
|
||||
const RPC_URL = "https://rpc.example.invalid";
|
||||
const RESOLVER = "0x5555555555555555555555555555555555555555";
|
||||
const USER = "0x1111111111111111111111111111111111111111";
|
||||
const NAME = "offchain.eth";
|
||||
|
||||
// The ENS registry's resolver(), and the resolver's functions ethers calls: the
|
||||
// registry names RESOLVER for every name, the resolver says it resolves names
|
||||
// through resolve(), gives NAME as the reverse record of any address, and
|
||||
// answers resolve() with the OffchainLookup error that says the name is
|
||||
// resolved off-chain.
|
||||
const ens = new Interface([
|
||||
"function resolver(bytes32) view returns (address)",
|
||||
"function supportsInterface(bytes4) view returns (bool)",
|
||||
"function name(bytes32) view returns (string)",
|
||||
"function resolve(bytes, bytes) view returns (bytes)",
|
||||
"error OffchainLookup(address sender, string[] urls, bytes callData, bytes4 callbackFunction, bytes extraData)",
|
||||
]);
|
||||
|
||||
let asked;
|
||||
|
||||
// One JSON-RPC answer. Anything but a call to one of the functions above is
|
||||
// refused.
|
||||
function reply(req) {
|
||||
const envelope = { jsonrpc: "2.0", id: req.id };
|
||||
const call =
|
||||
req.method === "eth_call" ? ens.parseTransaction(req.params[0]) : null;
|
||||
if (call === null) {
|
||||
return {
|
||||
...envelope,
|
||||
error: { code: -32601, message: "method not found" },
|
||||
};
|
||||
}
|
||||
if (call.name === "resolve") {
|
||||
const offchain = ens.encodeErrorResult("OffchainLookup", [
|
||||
RESOLVER,
|
||||
["https://gateway.example.invalid/{sender}/{data}.json"],
|
||||
"0x1234",
|
||||
"0x12345678",
|
||||
"0x",
|
||||
]);
|
||||
return {
|
||||
...envelope,
|
||||
error: { code: 3, message: "execution reverted", data: offchain },
|
||||
};
|
||||
}
|
||||
const answers = {
|
||||
resolver: [RESOLVER],
|
||||
supportsInterface: [true],
|
||||
name: [NAME],
|
||||
};
|
||||
return {
|
||||
...envelope,
|
||||
result: ens.encodeFunctionResult(call.name, answers[call.name]),
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
asked = [];
|
||||
FetchRequest.registerGetUrl(async (req) => {
|
||||
asked.push(req.url);
|
||||
// Any other address is the off-chain fetch, answered as not found.
|
||||
if (req.url !== RPC_URL) {
|
||||
return {
|
||||
statusCode: 404,
|
||||
statusMessage: "Not Found",
|
||||
headers: {},
|
||||
body: null,
|
||||
};
|
||||
}
|
||||
const body = JSON.parse(Buffer.from(req.body).toString("utf8"));
|
||||
const answer = Array.isArray(body) ? body.map(reply) : reply(body);
|
||||
return {
|
||||
statusCode: 200,
|
||||
statusMessage: "OK",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: Buffer.from(JSON.stringify(answer)),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
FetchRequest.registerGetUrl(FetchRequest.createGetUrlFunc());
|
||||
});
|
||||
|
||||
test("a name typed into Send that is resolved off-chain does not resolve, and only the RPC endpoint is asked", async () => {
|
||||
const provider = getProvider(RPC_URL, "mainnet");
|
||||
const [outcome] = await Promise.allSettled([provider.resolveName(NAME)]);
|
||||
expect(asked.filter((url) => url !== RPC_URL)).toEqual([]);
|
||||
expect(outcome).toEqual({ status: "fulfilled", value: null });
|
||||
});
|
||||
|
||||
test("the reverse lookup of a user's address whose name is resolved off-chain finds no name, and only the RPC endpoint is asked", async () => {
|
||||
const provider = getProvider(RPC_URL, "mainnet");
|
||||
const [outcome] = await Promise.allSettled([provider.lookupAddress(USER)]);
|
||||
expect(asked.filter((url) => url !== RPC_URL)).toEqual([]);
|
||||
expect(outcome).toEqual({ status: "fulfilled", value: null });
|
||||
});
|
||||
Reference in New Issue
Block a user