-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
113 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './lib/app-config.provider' | ||
export * from './lib/sdk-provider' | ||
export * from './lib/use-currencies' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { useSdk } from './sdk-provider' | ||
|
||
export function useCurrencies() { | ||
const sdk = useSdk() | ||
return useQuery({ | ||
queryKey: ['currencies'], | ||
queryFn: () => sdk.currencies().then((res) => res.data?.items ?? []), | ||
retry: 0, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
libs/web/solana/data-access/src/lib/solana-label-provider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ellipsify } from '@tokengator-mint/sdk' | ||
import { useCurrencies } from '@tokengator-mint/web-core-data-access' | ||
import { createContext, ReactNode, useContext } from 'react' | ||
|
||
export interface SolanaLabelProviderContext { | ||
map: Map<string, string> | ||
getLabel: (mint: string) => string | ||
} | ||
|
||
const Context = createContext<SolanaLabelProviderContext>({} as SolanaLabelProviderContext) | ||
|
||
export function SolanaLabelProvider({ children }: { children: ReactNode }) { | ||
const currencyQuery = useCurrencies() | ||
const map = new Map<string, string>() | ||
currencyQuery.data?.forEach((currency) => { | ||
map.set(currency.mint, currency.symbol) | ||
}) | ||
const value: SolanaLabelProviderContext = { | ||
map, | ||
getLabel: (mint: string) => map.get(mint) ?? ellipsify(mint), | ||
} | ||
return <Context.Provider value={value}>{children}</Context.Provider> | ||
} | ||
|
||
export function useSolanaLabel() { | ||
return useContext(Context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters