Skip to content

Commit

Permalink
Update rayscan extension
Browse files Browse the repository at this point in the history
- refac: fix linting issues
- refac: remove unused variable
- Updated & sanitized for public release
  • Loading branch information
Jds-23 committed Feb 4, 2025
1 parent 8c7450b commit 4e4c6bf
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 6 deletions.
Binary file modified extensions/rayscan/metadata/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified extensions/rayscan/metadata/view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion extensions/rayscan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
"title": "Search Transaction",
"subtitle": "search transaction",
"description": "Searchs Transaction using hash across evm blockchains",
"mode": "view"
"mode": "view",
"arguments": [
{
"name": "hash",
"type": "text",
"placeholder": "Enter transaction hash"
}
]
}
],
"dependencies": {
Expand Down
Binary file modified extensions/rayscan/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 14 additions & 4 deletions extensions/rayscan/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Action, ActionPanel, Detail, Icon, Image, List } from "@raycast/api";
import { usePromise } from "@raycast/utils";
import { useState } from "react";
import { getTransactions, openInTenderly, validateHash } from "./utils";
import { getTransactions, isNitro, openInNitro, openInTenderly, validateHash } from "./utils";
import { Transaction } from "./types";
import { network_configs } from "./networkConfig";

export default function Command() {
const [searchText, setSearchText] = useState("");
const { data, isLoading, error } = usePromise(getTransactions, [searchText], { execute: validateHash(searchText) });

const transactions = data?.transactions ?? [];
return (
<List onSearchTextChange={setSearchText} isLoading={isLoading}>
{error && (
Expand All @@ -19,7 +19,8 @@ export default function Command() {
/>
)}
{!error &&
data?.transactions.map((transaction) => {
transactions.length !== 0 &&
transactions.map((transaction) => {
const network = network_configs[transaction.network_id];
return (
<List.Item
Expand All @@ -34,6 +35,9 @@ export default function Command() {
target={<TransactionDetail transaction={transaction} />}
icon={Icon.Eye}
/>
{isNitro(transaction) && (
<Action.OpenInBrowser icon={Icon.ArrowNe} url={openInNitro(transaction)} title="Open in Nitro" />
)}
<Action.OpenInBrowser
icon={Icon.ArrowNe}
url={openInTenderly(transaction)}
Expand All @@ -44,6 +48,9 @@ export default function Command() {
/>
);
})}
{!error && transactions.length === 0 && searchText === "" && (
<List.EmptyView title="Enter a transaction hash to search" />
)}
</List>
);
}
Expand Down Expand Up @@ -90,7 +97,7 @@ export function TransactionDetail({ transaction }: { transaction: Transaction })
`- **Block Hash:** \`${transaction.block_hash}\``,
`- **Block Number:** \`${transaction.block_number.toLocaleString()}\``,
`- **From:** \`${transaction.from}\``,
`- **To:** \`${transaction.to}\``,
`- **To:** \`${transaction.to}\` \`${isNitro(transaction) ? "(Nitro)" : ""}\``,
`- **Nonce:** \`${transaction.nonce.toLocaleString()}\``,
`- **Timestamp:** \`${readableDate} (${howAgo})\``,
`## Gas Information`,
Expand Down Expand Up @@ -124,6 +131,9 @@ export function TransactionDetail({ transaction }: { transaction: Transaction })
actions={
<ActionPanel>
<Action.OpenInBrowser url={openInTenderly(transaction)} title="Open in Tenderly" />
{isNitro(transaction) && (
<Action.OpenInBrowser icon={Icon.ArrowNe} url={openInNitro(transaction)} title="Open in Nitro" />
)}
</ActionPanel>
}
/>
Expand Down
37 changes: 37 additions & 0 deletions extensions/rayscan/src/networkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,40 @@ export const network_configs: NetworkConfigMap = {
slug: null,
},
};

export const nitro_contracts: {
[chainId: string]: string;
} = {
"1": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"10": "0x8201c02d4ab2214471e8c3ad6475c8b0cd9f2d06",
"30": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"56": "0x260687ebc6c55dadd578264260f9f6e968f7b2a5",
"137": "0x1396f41d89b96eaf29a7ef9ee01ad36e452235ae",
"169": "0x21c1e74caadf990e237920d5515955a024031109",
"196": "0x21c1e74caadf990e237920d5515955a024031109",
"250": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"288": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"324": "0x8b6f1c18c866f37e6ea98aa539e0c117e70178a2",
"570": "0x21c1e74caadf990e237920d5515955a024031109",
"698": "0x21c1e74caadf990e237920d5515955a024031109",
"995": "0x7bd616192fb2b364f9d29b2026165281a5f2ff2f",
"1088": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"1101": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"1997": "0xf0773508c585246bd09bfb401aa18b72685b03f9",
"2000": "0x21c1e74caadf990e237920d5515955a024031109",
"2040": "0x21c1e74caadf990e237920d5515955a024031109",
"5000": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"8453": "0x0fa205c0446cd9eedcc7538c9e24bc55ad08207f",
"23294": "0x21c1e74caadf990e237920d5515955a024031109",
"34443": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
"42161": "0xef300fb4243a0ff3b90c8ccfa1264d78182adaa4",
"43114": "0xf9f4c3dc7ba8f56737a92d74fd67230c38af51f2",
"59144": "0x8c4acd74ff4385f3b7911432fa6787aa14406f8b",
"81457": "0x97eec1c29f745dc7c267f90292aa663d997a601d",
"167000": "0x7bd616192fb2b364f9d29b2026165281a5f2ff2f",
"200901": "0x21c1e74caadf990e237920d5515955a024031109",
"534352": "0x01b4ce0d48ce91eb6bcaf5db33870c65d641b894",
"7225878": "0x21c1e74caadf990e237920d5515955a024031109",
"728126428": "0x9d25b8289c0f3789237c1b3a88264882eed6c610",
"1313161554": "0xc21e4ebd1d92036cb467b53fe3258f219d909eb9",
};
9 changes: 8 additions & 1 deletion extensions/rayscan/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { Cache } from "@raycast/api";
import { Transaction, TransactionsResponse } from "./types";
import fetch from "node-fetch";
import { network_configs } from "./networkConfig";
import { network_configs, nitro_contracts } from "./networkConfig";
// import Parser from "rss-parser";
// import { CacheEntry, Topic } from "./types";

Expand Down Expand Up @@ -40,6 +40,13 @@ export function openInTenderly(transaction: Transaction) {
const network = network_configs[transaction.network_id];
return `https://dashboard.tenderly.co/tx/${network.slug ?? network.networkName.toLowerCase().replace(" ", "-")}/${transaction.hash}`;
}
export function openInNitro(transaction: Transaction) {
return `https://explorer.routernitro.com/tx/${transaction.hash}`;
}
export function isNitro(transaction: Transaction) {
return transaction.to === nitro_contracts[transaction.network_id];
}

// export const gqlFetcher = async (url: string, query: string, variables: any) => {
// const response = await fetch(url, {
// method: 'POST',
Expand Down
Binary file modified extensions/rayscan/view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e4c6bf

Please sign in to comment.