fix: read USD prices from Chainlink price feeds through the RPC endpoint (closes #525)
CoinDesk now refuses requests without an API key, so mainnet showed no USD prices. Mainnet prices now come from Chainlink's USD price feeds, read with eth_call through the user's RPC endpoint; no other service is asked. The bundled list pairs each of 53 tokens with its feed by contract address, and ETH and WETH use ETH/USD. The popup reads the feeds of ETH and the tokens the user holds or tracks in one batched request, at most every 5 minutes. A reading older than its heartbeat plus 30 minutes, or not positive, is no price. A token with no feed shows no USD value. CoinDesk is gone. RULES.md still names the CoinDesk price API. Model: opus-5-5
This commit was merged in pull request #681.
This commit is contained in:
@@ -226,6 +226,7 @@ const PRIVATE_KEY = "0x" + "11".repeat(32);
|
||||
const HOLDER = new Wallet(PRIVATE_KEY).address;
|
||||
const RECIPIENT = "0xC0FfEE0000000000000000000000000000c0fFEe";
|
||||
const TOKEN = "0x7070707070707070707070707070707070707070";
|
||||
const USDC = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
|
||||
const PASSWORD = "correct horse battery staple";
|
||||
|
||||
function el(id) {
|
||||
@@ -318,7 +319,7 @@ async function switchReopenAndGoBack(reviewedOn, switchedTo) {
|
||||
setBackRenderer(makeBackRenderer(state, { confirmTx }));
|
||||
confirmTx.init({});
|
||||
prices.ETH = 2000;
|
||||
prices.USDC = 1;
|
||||
prices[USDC] = 1;
|
||||
mockNode.asked = [];
|
||||
global.fetch.mockClear();
|
||||
goBack();
|
||||
@@ -641,7 +642,7 @@ describe.each([
|
||||
test("of an ERC-20 token, links the token contract to that network's explorer and prices the token by that network", async () => {
|
||||
mockNode.tokenUnits[reviewedOn] = 50000000n;
|
||||
await review(reviewedOn, {
|
||||
token: TOKEN,
|
||||
token: USDC,
|
||||
tokenSymbol: "USDC",
|
||||
tokenDecimals: 6,
|
||||
amount: "10",
|
||||
@@ -652,7 +653,7 @@ describe.each([
|
||||
"ERC-20 token transfer (USDC)",
|
||||
);
|
||||
expect(el("confirm-token-contract").innerHTML).toContain(
|
||||
`href="${explorerUrl}/address/${TOKEN}"`,
|
||||
`href="${explorerUrl}/address/${USDC}"`,
|
||||
);
|
||||
expect(el("confirm-amount").textContent).toBe(
|
||||
"10.0000 USDC" + usdOn(reviewedOn, "$10.00"),
|
||||
|
||||
Reference in New Issue
Block a user