Giter Club home page Giter Club logo

xray's Introduction

XRAY

A human-readable Solana transaction explorer powered by Helius.

๐Ÿ”— Link: https://xray.helius.xyz/

๐ŸŽฅ Demo: https://www.loom.com/share/402a4397ebd1403f8f4b7df8f024e9b8

๐Ÿค Twitter: https://twitter.com/xray_explorer

๐Ÿ’ฌ Discord: https://discord.gg/8Qxk7PmArt

๐Ÿš€ Deployments

Environment Description Directory
Production The main deployment attached to the domain. https://xray.helius.xyz/
Staging Staging branch based on contents of origin/dev. https://xray-web-git-dev-helius.vercel.app/

๐Ÿ“ฆ Packages

Name Description Directory
@helius-labs/xray-web SvelteKit app with UI and backend endpoints. apps/web
@helius-labs/xray-proton Parses transaction data to produce UI state. packages/xray-proton
@helius-labs/xray-database [WIP] Prisma client used for communicating with database. packages/xray-database

๐Ÿค Contribute

  • Fork XRAY onto your own GitHub
  • Clone it and checkout the dev branch (git checkout dev)
  • Create a new branch named [initials]/[feature] off of dev. Example q/added-a-cool-thing.
  • When ready for us to review your changes, create a PR with your new branch to be merged into the dev branch on the official repo.

๐Ÿƒ๐Ÿฝโ€โ™‚๏ธ Runbook

This is a TurboRepo monorepo that can run and build all apps/packages in parallel. Apps like the UI are located in /apps. Packages used across apps are located in /packages.

Reccomended VSCode Extensions

Tech Stack

Setup Environment

In the root of the project, create a .env file with the values mentioned in .env.template.

Install

Run the install command from the root of the project to install dependencies for all apps and packages.

npm install

Dev

Start all packages and apps in dev mode which watches for changes and adds your local environment.

npm run dev

Lint

It's reccomended you use VSCode beacuase if you do, ESLint is setup to auto fix/format as you're working.

npm run lint

Format

Formats files based on the Prettier and ESlint settings.

npm run format

Test

Tests the code, determines if it should be allowed to merge. We recommend running this locally before creating PRs.

npm run test

Build

Build all apps and packages for production.

npm run build

Build Local Environment

Build all apps and packages for production using your .env file.

npm run build:env

๐Ÿ“ฑ @helius-labs/xray-web

A SvelteKit app that contains the main XRAY UI.

Important Files & Folders

๐Ÿ“ ./src/lib Common components, utilities, and libraries used throughout the app. Import things from this directory using the $lib/ alias.
๐Ÿ“ ./src/lib/trpc The tRPC server which has all of our backend endpoints. See trpc/routes.
๐Ÿ“ ./src/lib/components Shared components used throughout the app.
๐Ÿ“ ./src/lib/trpc The tRPC server which has all of our backend endpoints.
๐Ÿ“ ./src/lib/types Global types
๐Ÿ“ ./src/lib/configs Config definitions for things like the icons, modals, and generating other types.
๐Ÿ“./src/routes Any +page or +server file in this directory becomes a page or an endpoint based on the folder structure.
๐Ÿ“./static A place to put any static assets. The files in this directory are hosted at the root of the domain. When using images, try to import them in the <script> vs put them in ./static when you can help it.
๐Ÿ“„./app.postcss Initialize/config Tailwind + global styles.
๐Ÿ“„./app.html The top level HTML template that wrapps all pages. Routes are injected into the %sveltekit.body% tag.

Routes

/ Home
/api REST endpoints (This is mostly replaces by tRPC now)
/[search] From the home page, users can navigate to /anything which attempts to resolve the search and then redirect them to /[search]/tx, /[search]/wallet, or /[search]/token based on the search.
/[search]/tx Details about a particular transaction where [search] is a transaction signature.
/[search]/wallet Details about a particular wallet where [search] is a public key.
/[search]/token Details about a particular token where [search] is a token mint address.

Vercel Config

Build Command cd ../.. && npx turbo run build --filter=web...
Output Director apps/web/.svelte-kit
Install Command npm install --prefix=../..

Styles

TailwindCSS is used for base utilies and DaisyUI contains helpful UI components.

Icons

See list of available icons in $lib/config.

Use Icons

<script>
    import Icon from "$lib/components/icon.svelte";
</script>

<Icon id="paper-plane">

Add Icons

  1. Find the icon you want on IconMon. Most of these should render fine.
  2. Click "Embed" -> "Inline" and copy only the <path>.
  3. Add a new key to $lib/config.ts that is similar to the Icon Monsters name for the icon and add your <path>.

State Management

WIP

๐Ÿ“ฆ @helius-labs/proton

Used for parsing blockchain data and making it pretty for the UI.

Important Files & Folders

๐Ÿ“„./index.ts UI calls the function in this file to parse transactions
๐Ÿ“„./src/types/index.ts Contains the types, interfaces, and enums needed to understand to work on the parser.
๐Ÿ“./src/parsers Contains all parser methods.
๐Ÿ“„./src/parsers/index.ts Exports parser files in ./src/parsers.
๐Ÿ“./src/utils Utility functions for parser functions

General Work Flow When Adding a New Transaction Type

  1. Identify a transaction type that is not currently supported.
  2. Get to know the transaction type. Here is the resource I personally like to use for it:
    • SwaggerHub - Use /v0/addresses/{address}/transactions for addresses with the specific transaction type or /v0/transactions/ for a transaction (also supports multiple transactions). I like downloading the JSON file and looking through it constantly. More transactions + edge cases are better to battle test your parser function.
  3. Add a new file or edit an existing one in ./src/parsers. (refer to other files for general structures of what a parser function should look like)
  4. Export the function in ./src/parsers/index.ts, add the transaction type to the ProtonSupportedType object in ./src/types/index.ts, and add the transaction type with the corresponding parser function to the protonParsers object in ./src/types/index.ts.
  5. Work on the parser function while testing it since it is now compatible with the UI.

Currently Supported Transactions

Transaction Type File in /src/parsers
TRANSFER /transfer.ts
SWAP /swap.ts
BURN /burn.ts
BURN_NFT /burn.ts
TOKEN_MINT /token.ts
NFT_MINT /nft.ts
NFT_SALE /nft.ts
NFT_LISTING /nft.ts
NFT_CANCEL_LISTING /nft.ts
NFT_BID /nft.ts
NFT_BID_CANCELLED /nft.ts
BORROW_FOX /fox.ts
LOAN_FOX /fox.ts
UNKNOWN /unknown.ts

๐Ÿ“ฆ @helius-labs/xray-database [WIP]

A database for savaing metadata like transaction views or user details.

xray's People

Contributors

qudo-code avatar ssamkkim avatar therealnospoon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.