Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "node server.mjs --dev",
"build": "next build",
"start": "node server.mjs",
"test": "node --test \"test/*.test.mjs\" src/lib/trades.test.ts src/lib/swap/swap.test.ts src/lib/vault/keyText.test.ts src/lib/evm/plan.test.ts src/lib/tokenFilters.test.ts",
"test": "node --test \"test/*.test.mjs\" src/lib/trades.test.ts src/lib/swap/swap.test.ts src/lib/vault/keyText.test.ts src/lib/evm/plan.test.ts src/lib/tokenFilters.test.ts src/lib/chains.test.ts",
"typecheck": "tsc --noEmit",
"bundle": "node scripts/bundle-server.mjs",
"electron": "electron .",
Expand Down
16 changes: 16 additions & 0 deletions src/lib/chains.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Explorer links per chain.
* Run: `npm test` (or `node --test src/lib/chains.test.ts`) from trade-ui/.
*/
import { test } from "node:test";
import assert from "node:assert/strict";
import { explorerAccountUrl, explorerTxUrl, explorerUrl } from "./chains.ts";

const ADDRESS = "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"; // WETH on Robinhood Chain
const TX = "0x60f2d8e8ca8d64da9d3ded83a759a123ea28aca9f51a8f9b62cf34835b770cf9";

test("Robinhood Chain links open its Blockscout explorer", () => {
assert.equal(explorerAccountUrl(ADDRESS, "robinhood"), `https://robinhoodchain.blockscout.com/address/${ADDRESS}`);
assert.equal(explorerTxUrl(TX, "robinhood"), `https://robinhoodchain.blockscout.com/tx/${TX}`);
assert.equal(explorerUrl("token", ADDRESS, "robinhood"), `https://robinhoodchain.blockscout.com/token/${ADDRESS}`);
});
2 changes: 1 addition & 1 deletion src/lib/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const EXPLORER_HOST: Record<ChainId, { host: string; accountPath: string }> = {
eth: { host: "etherscan.io", accountPath: "address" },
bsc: { host: "bscscan.com", accountPath: "address" },
base: { host: "basescan.org", accountPath: "address" },
robinhood: { host: "explorer.mainnet.chain.robinhood.com", accountPath: "address" },
robinhood: { host: "robinhoodchain.blockscout.com", accountPath: "address" },
};

export function explorerUrl(kind: ExplorerKind, value: string, id: ChainId = getActiveChain()): string {
Expand Down