Skip to content

Commit

Permalink
Merge pull request #222 from helius-labs/devnet
Browse files Browse the repository at this point in the history
Devnet
  • Loading branch information
solhosty authored Sep 15, 2023
2 parents 2e6a6de + 19a5fbb commit 486de01
Show file tree
Hide file tree
Showing 58 changed files with 668 additions and 439 deletions.
1 change: 0 additions & 1 deletion .env.template

This file was deleted.

7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-vercel": "^2.0.2",
"@tailwindcss/typography": "^0.5.8",
"@types/js-cookie": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"autoprefixer": "^10.4.7",
Expand Down
8 changes: 7 additions & 1 deletion src/lib/components/account-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@
export let account: string = "";
export let link: string = "";
const accountInfo = client.accountInfo.createQuery(account);
const params = new URLSearchParams(window.location.search);
const network = params.get("network");
const isMainnetValue = network !== "devnet";
const accountInfo = client.accountInfo.createQuery([
account,
isMainnetValue,
]);
const price = client.price.createQuery(SOL);
const balance = tweened(0, {
Expand Down
10 changes: 7 additions & 3 deletions src/lib/components/account-info.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
import CopyButton from "$lib/components/copy-button.svelte";
import Namor from "$lib/components/providers/namor-provider.svelte";
export let account = "";
const client = trpcWithQuery($page);
const accountInfo = client.accountInfo.createQuery(account);
const params = new URLSearchParams(window.location.search);
const network = params.get("network");
const isMainnetValue = network !== "devnet";
const accountInfo = client.accountInfo.createQuery([
account,
isMainnetValue,
]);
const price = client.price.createQuery(SOL);
const balance = tweened(0, {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/collapse.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
export let showDetails = false;
</script>

<div class="collapse collapse-arrow rounded-md border">
<div class="collapse-arrow collapse rounded-md border">
<input
type="checkbox"
bind:checked={showDetails}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/copy-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</script>

<button
class="btn btn-xs {classList}"
class="btn-xs btn {classList}"
class:btn-success={copied}
class:btn-ghost={!copied}
on:click={copy}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="mr-12">
<a
href="https://discord.gg/mV3dNPwDnZ"
class="btn btn-ghost"
class="btn-ghost btn"
>
<Icon
id="discord"
Expand All @@ -23,7 +23,7 @@
</a>
<a
href="https://twitter.com/heliuslabs"
class="btn btn-ghost"
class="btn-ghost btn"
>
<Icon
id="twitter"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/json.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
success="copied json"
/>
<button
class="btn btn-ghost btn-sm"
class="btn-ghost btn-sm btn"
on:click={() => (showCode = !showCode)}
>
{#if showCode}
Expand Down
12 changes: 11 additions & 1 deletion src/lib/components/log-messages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@
</style>

<script lang="ts">
import { txn } from "$lib/state/stores/txn";
import { parseProgramLogs } from "$lib/util/program-logs";
import { onMount } from "svelte";
export let logs: string[];
const parsedLogs = parseProgramLogs(logs);
onMount(() => {
//@ts-ignore
if (parsedLogs == "") {
txn.set(false);
} else {
txn.set(true);
}
});
const totalComputeUnits = parsedLogs.reduce(
(sum, log) => sum + log.computeUnits,
0
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modals.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<h3 class="ml-3 text-xl font-bold">{$modalsStore.title}</h3>
<div>
<button
class="btn btn-ghost btn-md"
class="btn-ghost btn-md btn"
on:click={hideModal}
>
<Icon
Expand Down
13 changes: 11 additions & 2 deletions src/lib/components/modals/menu.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{#each [{ name: "Home", url: "/" }, { name: "About Helius APIs", url: "https://helius.xyz" }, { name: "Contribute", url: "https://github.com/helius-labs/xray" }, { name: "Join Discord", url: "https://discord.gg/mV3dNPwDnZ" }] as { name, url }}
<script>
import Network from "../network.svelte";
const params = new URLSearchParams(window.location.search);
const network = params.get("network");
const isMainnetValue = network !== "devnet";
</script>

{#each [{ name: "Home", url: `/?network=${isMainnetValue ? "mainnet" : "devnet"}` }, { name: "About Helius APIs", url: "https://helius.xyz" }, { name: "Contribute", url: "https://github.com/helius-labs/xray" }, { name: "Join Discord", url: "https://discord.gg/nSkq35VUf5" }] as { name, url }}
<a
href={url}
data-sveltekit-reload
class="btn btn-ghost w-full">{name}</a
class="btn-ghost btn w-full">{name}</a
>
{/each}
<Network />
4 changes: 2 additions & 2 deletions src/lib/components/modals/transaction-filter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</script>

<button
class="btn btn-ghost w-full"
class="btn-ghost btn w-full"
on:click={() => handleClick("")}>All Transactions</button
>
{#each filterList as [key, value]}
<button
class="btn btn-ghost w-full"
class="btn-ghost btn w-full"
on:click={() => handleClick(key)}
>
{value.filterLabel}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modals/wallets.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<a
href="/account/{address}"
data-sveltekit-reload
class="btn btn-ghost w-full">{shortenString(address, 8)}</a
class="btn-ghost btn w-full">{shortenString(address, 8)}</a
>
{/each}
13 changes: 8 additions & 5 deletions src/lib/components/nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import Stats from "$lib/components/stats.svelte";
import { showModal } from "$lib/state/stores/modals";
const params = new URLSearchParams(window.location.search);
const network = params.get("network");
const isMainnetValue = network !== "devnet";
</script>

<Stats />
Expand All @@ -23,8 +26,8 @@
}}
>
<a
class="btn btn-ghost px-2"
href="/"
class="btn-ghost btn px-2"
href="/?network={isMainnetValue ? 'mainnet' : 'devnet'}"
rel="noreferrer"
>
<span class="text-3xl">XRAY</span>
Expand All @@ -43,7 +46,7 @@
<div class="col-span-2 flex items-center justify-end">
<div class="flex justify-end pr-2">
<button
class="btn btn-ghost"
class="btn-ghost btn"
on:click={() => showModal("HELP")}
>
<Icon
Expand All @@ -52,7 +55,7 @@
/>
</button>
<button
class="btn btn-ghost"
class="btn-ghost btn"
on:click={() => showModal("MENU")}
>
<Icon
Expand All @@ -66,7 +69,7 @@

{#if $page.url.pathname !== "/"}
<button
class="btn btn-secondary btn-sm fixed bottom-4 right-3 z-10 cursor-pointer rounded-full"
class="btn-secondary btn-sm btn fixed bottom-4 right-3 z-10 cursor-pointer rounded-full"
on:click={() => window.scrollTo({ behavior: "smooth", top: 0 })}
>
<Icon
Expand Down
41 changes: 41 additions & 0 deletions src/lib/components/network.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script lang="ts">
import { onMount } from "svelte";
let isMainnetValue = true;
onMount(() => {
const savedIsMainnet = localStorage.getItem("isMainnet");
if (savedIsMainnet !== null) {
isMainnetValue = JSON.parse(savedIsMainnet);
}
});
onMount(() => {
const params = new URLSearchParams(window.location.search);
const network = params.get("network");
isMainnetValue = network !== "devnet";
localStorage.setItem("isMainnet", JSON.stringify(isMainnetValue));
});
function toggleNetwork(event: Event) {
isMainnetValue = (event.target as HTMLInputElement).checked;
localStorage.setItem("isMainnet", JSON.stringify(isMainnetValue));
const params = new URLSearchParams(window.location.search);
params.set("network", isMainnetValue ? "mainnet" : "devnet");
history.replaceState({}, "", "?" + params.toString());
history.go(0);
}
</script>

<div class="toggle-container m-auto mt-2 flex w-full flex-col justify-center">
<label class="toggle-label m-auto flex flex-col">
<input
type="checkbox"
class="toggle flex justify-center"
bind:checked={isMainnetValue}
on:change={toggleNetwork}
/>
<span class="toggle-mark" />
</label>
<span class="network-text m-auto my-1 flex flex-col font-bold"
>{isMainnetValue ? "Mainnet" : "Devnet"}</span
>
</div>
2 changes: 1 addition & 1 deletion src/lib/components/powered-by-helius.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<a
class="btn btn-ghost flex items-center text-left"
class="btn-ghost btn flex items-center text-left"
href="https://helius.xyz/"
rel="noreferrer"
target="_blank"
Expand Down
8 changes: 0 additions & 8 deletions src/lib/components/providers/token-provider-2.svelte

This file was deleted.

19 changes: 12 additions & 7 deletions src/lib/components/providers/token-provider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@
export let address: string;
let intersecting = false;
const params = new URLSearchParams(window.location.search);
const network = params.get("network");
const isMainnetValue = network !== "devnet";
const client = trpcWithQuery($page);
const token = client.token.createQuery([address], {
const token = client.token.createQuery([address, isMainnetValue], {
refetchOnMount: false,
refetchOnWindowFocus: false,
});
const accountInfo = client.accountInfo.createQuery(address, {
refetchOnMount: false,
refetchOnWindowFocus: false,
});
const accountInfo = client.accountInfo.createQuery(
[address, isMainnetValue],
{
refetchOnMount: false,
refetchOnWindowFocus: false,
}
);
const token2022Metadata: {
[key: string]: {
Expand Down Expand Up @@ -57,7 +62,7 @@
sellerFeeBasisPoints: 0,
};
const asset = client.asset.createQuery(address, {
const asset = client.asset.createQuery([address, isMainnetValue], {
refetchOnMount: false,
refetchOnWindowFocus: false,
});
Expand Down
Loading

1 comment on commit 486de01

@vercel
Copy link

@vercel vercel bot commented on 486de01 Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.