Skip to content

Commit

Permalink
chore: dynamically load token data in lst store
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Nov 30, 2023
1 parent 10c7298 commit 966e9fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";

import { useRouter } from "next/router";
import { toast } from "react-toastify";
import { useCookies } from "react-cookie";
import { minidenticon } from "minidenticons";
import { useAnchorWallet, useWallet, WalletContextState } from "@solana/wallet-adapter-react";
Expand All @@ -11,10 +10,11 @@ import { Web3AuthNoModal } from "@web3auth/no-modal";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
import { SolanaWallet, SolanaPrivateKeyProvider } from "@web3auth/solana-provider";
import base58 from "bs58";
import { Wallet } from "@mrgnlabs/mrgn-common";

import { showErrorToast } from "~/utils/toastUtils";

import type { Wallet } from "@mrgnlabs/mrgn-common";

// wallet adapter context type to override with web3auth data
// this allows us to pass web3auth wallet to 3rd party services that expect wallet adapter
type WalletContextOverride = {
Expand Down
7 changes: 6 additions & 1 deletion apps/marginfi-v2-ui/src/store/lstStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { Connection, PublicKey } from "@solana/web3.js";
import { create, StateCreator } from "zustand";
import * as solanaStakePool from "@solana/spl-stake-pool";
import { EPOCHS_PER_YEAR, StakeData, fetchStakeAccounts } from "~/utils";
import { TokenInfo, TokenInfoMap, TokenListContainer } from "@solana/spl-token-registry";
import { TokenAccount, TokenAccountMap, fetchBirdeyePrices } from "@mrgnlabs/marginfi-v2-ui-state";
import { persist } from "zustand/middleware";
import BN from "bn.js";

import type { TokenInfo, TokenInfoMap } from "@solana/spl-token-registry";

const STAKEVIEW_APP_URL = "https://stakeview.app/apy/prev3.json";
const BASELINE_VALIDATOR_ID = "mrgn28BhocwdAUEenen3Sw2MR9cPKDpLkDvzDdR7DBD";

Expand Down Expand Up @@ -259,6 +260,10 @@ async function fetchJupiterTokenInfo(): Promise<TokenInfoMap> {
? await fetch("https://token.jup.ag/strict")
: await fetch("https://token.jup.ag/all")
).json();

// Dynamically import TokenListContainer when needed
const { TokenListContainer } = await import("@solana/spl-token-registry");

const res = new TokenListContainer(tokens);
const list = res.filterByChainId(101).getList();
const tokenMap = list
Expand Down

0 comments on commit 966e9fc

Please sign in to comment.