add backup rpc to claim

This commit is contained in:
Adrian Brzeziński 2024-04-08 14:48:18 +02:00
parent d3e4cd5403
commit 4c764395be
5 changed files with 25 additions and 11 deletions

View File

@ -3,7 +3,7 @@ import { Provider } from '@project-serum/anchor'
import { MANGO_DATA_API_URL } from 'utils/constants'
import { AnchorProvider } from '@coral-xyz/anchor'
export const DISTRIBUTION_NUMBER_PREFIX = 133
export const DISTRIBUTION_NUMBER_PREFIX = 132
type AccountTier = {
mango_account: string

View File

@ -6,7 +6,7 @@ import {
import dynamic from 'next/dynamic'
import { web3 } from '@project-serum/anchor'
import { useWallet } from '@solana/wallet-adapter-react'
import { PublicKey } from '@solana/web3.js'
import { Connection, PublicKey } from '@solana/web3.js'
import mangoStore from '@store/mangoStore'
import { useCurrentSeason, useDistribution } from 'hooks/useRewards'
import { chunk } from 'lodash'
@ -38,6 +38,7 @@ import { notify } from 'utils/notifications'
import { sleep } from 'utils'
import { createComputeBudgetIx } from '@blockworks-foundation/mango-v4'
import SendTweetModal from './SendTweetModal'
import { LITE_RPC_URL } from '@components/settings/RpcSettings'
const CLAIM_BUTTON_CLASSES =
'raised-button group mx-auto block h-12 px-6 pt-1 font-rewards text-xl after:rounded-lg focus:outline-none lg:h-14'
@ -145,13 +146,19 @@ const ClaimPage = () => {
const metaplex = new Metaplex(connection)
const tokens = claims!
.filter((x) => x.mintProperties.type.toLowerCase() === 'token')
.filter(
(x) =>
x.mintProperties.type.toLowerCase() === 'token' &&
x.mintProperties.name.toLowerCase() !== 'gpu',
)
.map((t) => jupiterTokens.find((x) => x.address === t.mint.toBase58()))
.filter((x) => x)
.map((x) => x as Token)
const nfts = claims!.filter(
(x) => x.mintProperties.type.toLowerCase() === 'nft',
(x) =>
x.mintProperties.type.toLowerCase() === 'nft' ||
x.mintProperties.name.toLowerCase() === 'gpu',
)
const nftsInfos: (Sft | SftWithToken | Nft | NftWithToken)[] = []
@ -252,6 +259,7 @@ const ClaimPage = () => {
connection,
wallet,
transactionInstructions,
backupConnections: [new Connection(LITE_RPC_URL, 'recent')],
callbacks: {
afterFirstBatchSign: (signedCount) => {
console.log('afterFirstBatchSign', signedCount)

View File

@ -63,8 +63,14 @@ export const getClaimsAsPrizes = (
nftsRewardsInfo: (Sft | SftWithToken | Nft | NftWithToken)[],
) =>
claims.map((x) => {
const rarity = x.mintProperties.rarity.toLowerCase()
const type = x.mintProperties.type.toLowerCase()
const rarity =
x.mintProperties.name.toLowerCase() === 'gpu'
? 'legendary'
: x.mintProperties.rarity.toLowerCase()
const type =
x.mintProperties.name.toLowerCase() === 'gpu'
? 'nft'
: x.mintProperties.type.toLowerCase()
const tokenInfo =
type === 'token'
? tokensInfo.find((t) => t.address === x.mint.toBase58())

View File

@ -25,7 +25,7 @@
"@blockworks-foundation/mango-mints-redemption": "^0.0.10",
"@blockworks-foundation/mango-v4": "0.23.3",
"@blockworks-foundation/mango-v4-settings": "0.14.19",
"@blockworks-foundation/mangolana": "0.0.15",
"@blockworks-foundation/mangolana": "0.0.16",
"@headlessui/react": "1.6.6",
"@heroicons/react": "2.0.18",
"@metaplex-foundation/js": "0.19.4",

View File

@ -391,10 +391,10 @@
node-fetch "2.6.11"
ws "^8.16.0"
"@blockworks-foundation/mangolana@0.0.15":
version "0.0.15"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mangolana/-/mangolana-0.0.15.tgz#8a603675028f7d7ab400cc58bf3058d2e7514cde"
integrity sha512-P31XW2w2lFBgzM+529H2f3Kz8rNC7+h0pYZub9kOcsACAt7TwLksg1fGuzSvekLn6M1JmVpPa9nISdAVfsZB5g==
"@blockworks-foundation/mangolana@0.0.16":
version "0.0.16"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mangolana/-/mangolana-0.0.16.tgz#d45a10e0d6325eb72228280c155a87ef0992a432"
integrity sha512-eoVmWWkYyreK0fH5katFvPTv5GhBetnHikpl/GNU8sm0tVzsQqmgqeqwtFjFZvbg81/Wne0JKrSNPEeKL8eEZA==
dependencies:
"@solana/web3.js" "^1.88.0"
bs58 "^5.0.0"