fix crypto-js dependency
This commit is contained in:
parent
ca51d24d76
commit
bd8cab80dd
|
@ -41,7 +41,6 @@
|
|||
"@glitchful-dev/sol-apy-sdk": "3.0.1",
|
||||
"@headlessui/react": "1.6.6",
|
||||
"@heroicons/react": "2.0.10",
|
||||
"@metaplex-foundation/js": "0.19.4",
|
||||
"@project-serum/anchor": "0.25.0",
|
||||
"@pythnetwork/client": "2.15.0",
|
||||
"@solana/spl-governance": "0.3.27",
|
||||
|
@ -55,6 +54,7 @@
|
|||
"@types/howler": "2.2.7",
|
||||
"@web3auth/sign-in-with-solana": "1.0.0",
|
||||
"big.js": "6.2.1",
|
||||
"csv-stringify": "6.4.4",
|
||||
"dayjs": "1.11.9",
|
||||
"decimal.js": "10.4.0",
|
||||
"i18next": "23.2.11",
|
||||
|
@ -107,7 +107,8 @@
|
|||
},
|
||||
"resolutions": {
|
||||
"@coral-xyz/anchor": "^0.27.0",
|
||||
"eslint-config-next/eslint-import-resolver-typescript/tsconfig-paths/json5": "1.0.2"
|
||||
"eslint-config-next/eslint-import-resolver-typescript/tsconfig-paths/json5": "1.0.2",
|
||||
"crypto-js": ">=4.1.1"
|
||||
},
|
||||
"lavamoat": {
|
||||
"allowScripts": {
|
||||
|
|
|
@ -29,7 +29,6 @@ import {
|
|||
import EmptyWallet from '../utils/wallet'
|
||||
import { TransactionNotification, notify } from '../utils/notifications'
|
||||
import {
|
||||
getNFTsByOwner,
|
||||
getTokenAccountsByOwnerWithWrappedSol,
|
||||
TokenAccount,
|
||||
} from '../utils/tokens'
|
||||
|
@ -59,7 +58,6 @@ import {
|
|||
TotalInterestDataItem,
|
||||
TradeForm,
|
||||
TokenStatsItem,
|
||||
NFT,
|
||||
TourSettings,
|
||||
ProfileDetails,
|
||||
MangoTokenStatsItem,
|
||||
|
@ -245,10 +243,6 @@ export type MangoStore = {
|
|||
tradeForm: TradeForm
|
||||
wallet: {
|
||||
tokens: TokenAccount[]
|
||||
nfts: {
|
||||
data: NFT[] | []
|
||||
loading: boolean
|
||||
}
|
||||
}
|
||||
window: {
|
||||
width: number
|
||||
|
@ -265,7 +259,6 @@ export type MangoStore = {
|
|||
fetchGroup: () => Promise<void>
|
||||
reloadMangoAccount: (slot?: number) => Promise<void>
|
||||
fetchMangoAccounts: (ownerPk: PublicKey) => Promise<void>
|
||||
fetchNfts: (connection: Connection, walletPk: PublicKey) => void
|
||||
fetchProfileDetails: (walletPk: string) => void
|
||||
fetchSwapHistory: (
|
||||
mangoAccountPk: string,
|
||||
|
@ -418,10 +411,6 @@ const mangoStore = create<MangoStore>()(
|
|||
},
|
||||
wallet: {
|
||||
tokens: [],
|
||||
nfts: {
|
||||
data: [],
|
||||
loading: false,
|
||||
},
|
||||
},
|
||||
window: {
|
||||
width: 0,
|
||||
|
@ -697,24 +686,6 @@ const mangoStore = create<MangoStore>()(
|
|||
})
|
||||
}
|
||||
},
|
||||
fetchNfts: async (connection: Connection, ownerPk: PublicKey) => {
|
||||
const set = get().set
|
||||
set((state) => {
|
||||
state.wallet.nfts.loading = true
|
||||
})
|
||||
try {
|
||||
const nfts = await getNFTsByOwner(ownerPk, connection)
|
||||
set((state) => {
|
||||
state.wallet.nfts.data = nfts
|
||||
})
|
||||
} catch (error) {
|
||||
console.warn('Error: unable to fetch nfts.', error)
|
||||
} finally {
|
||||
set((state) => {
|
||||
state.wallet.nfts.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
fetchSwapHistory: async (
|
||||
mangoAccountPk: string,
|
||||
timeout = 0,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { PublicKey } from '@metaplex-foundation/js'
|
||||
|
||||
// lev stake
|
||||
export const BORROW_TOKEN = 'SOL'
|
||||
|
||||
|
@ -139,9 +137,6 @@ export const NOTIFICATION_API_WEBSOCKET =
|
|||
export const SWITCHBOARD_PROGRAM_ID =
|
||||
'SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f'
|
||||
|
||||
export const AUCTION_HOUSE_ID = new PublicKey(
|
||||
'BGBBt6G9bp36i5qt7PWjBWg3VNef1zPozAN9RFsEPDkh',
|
||||
)
|
||||
export const CUSTOM_TOKEN_ICONS: { [key: string]: boolean } = {
|
||||
bonk: true,
|
||||
btc: true,
|
||||
|
|
|
@ -1,18 +1,6 @@
|
|||
import { PublicKey, Connection } from '@solana/web3.js'
|
||||
import { TokenInstructions } from '@project-serum/serum'
|
||||
import {
|
||||
getAssociatedTokenAddress,
|
||||
toUiDecimals,
|
||||
} from '@blockworks-foundation/mango-v4'
|
||||
import {
|
||||
Metaplex,
|
||||
Nft,
|
||||
Sft,
|
||||
SftWithToken,
|
||||
NftWithToken,
|
||||
Metadata,
|
||||
JsonMetadata,
|
||||
} from '@metaplex-foundation/js'
|
||||
import { toUiDecimals } from '@blockworks-foundation/mango-v4'
|
||||
|
||||
export class TokenAccount {
|
||||
publicKey!: PublicKey
|
||||
|
@ -38,12 +26,6 @@ export class TokenAccount {
|
|||
}
|
||||
}
|
||||
|
||||
type RawNft = Nft | Sft | SftWithToken | NftWithToken
|
||||
type NftWithATA = RawNft & {
|
||||
owner: null | PublicKey
|
||||
tokenAccountAddress: null | PublicKey
|
||||
}
|
||||
|
||||
function exists<T>(item: T | null | undefined): item is T {
|
||||
return !!item
|
||||
}
|
||||
|
@ -85,64 +67,6 @@ export async function getTokenAccountsByOwnerWithWrappedSol(
|
|||
return [solAccount].concat(tokenAccounts)
|
||||
}
|
||||
|
||||
const enhanceNFT = (nft: NftWithATA) => {
|
||||
return {
|
||||
image: nft.json?.image || '',
|
||||
name: nft.json?.name || '',
|
||||
address: nft.metadataAddress.toBase58(),
|
||||
collectionAddress: nft.collection?.address.toBase58(),
|
||||
mint: nft.mint.address.toBase58(),
|
||||
tokenAccount: nft.tokenAccountAddress?.toBase58() || '',
|
||||
}
|
||||
}
|
||||
|
||||
function loadNft(
|
||||
nft: Metadata<JsonMetadata<string>> | Nft | Sft,
|
||||
connection: Connection,
|
||||
) {
|
||||
const metaplex = new Metaplex(connection)
|
||||
|
||||
return Promise.race([
|
||||
metaplex
|
||||
.nfts()
|
||||
// @ts-ignore
|
||||
.load({ metadata: nft })
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
return null
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
||||
export async function getNFTsByOwner(owner: PublicKey, connection: Connection) {
|
||||
const metaplex = new Metaplex(connection)
|
||||
|
||||
const rawNfts = await metaplex.nfts().findAllByOwner({
|
||||
owner,
|
||||
})
|
||||
|
||||
const nfts = await Promise.all(
|
||||
rawNfts.map((nft) => loadNft(nft, connection)),
|
||||
).then((nfts) =>
|
||||
Promise.all(
|
||||
nfts.filter(exists).map(async (nft) => ({
|
||||
...nft,
|
||||
owner,
|
||||
tokenAccountAddress: await getAssociatedTokenAddress(
|
||||
nft.mint.address,
|
||||
owner,
|
||||
true,
|
||||
).catch((e) => {
|
||||
console.error(e)
|
||||
return null
|
||||
}),
|
||||
})),
|
||||
),
|
||||
)
|
||||
|
||||
return nfts.map(enhanceNFT)
|
||||
}
|
||||
|
||||
export const formatTokenSymbol = (symbol: string) => {
|
||||
if (symbol.toLowerCase().includes('portal')) {
|
||||
const truncSymbol = symbol.split(' ')[0].toUpperCase()
|
||||
|
|
Loading…
Reference in New Issue