From 4c764395be215afe766f4ab036a0c51381ff7481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Mon, 8 Apr 2024 14:48:18 +0200 Subject: [PATCH] add backup rpc to claim --- apis/rewards.ts | 2 +- components/rewards/Claim.tsx | 14 +++++++++++--- components/rewards/RewardsComponents.tsx | 10 ++++++++-- package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/apis/rewards.ts b/apis/rewards.ts index f35e9dd1..b4aa0af0 100644 --- a/apis/rewards.ts +++ b/apis/rewards.ts @@ -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 diff --git a/components/rewards/Claim.tsx b/components/rewards/Claim.tsx index deeed7b7..a212ae7b 100644 --- a/components/rewards/Claim.tsx +++ b/components/rewards/Claim.tsx @@ -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) diff --git a/components/rewards/RewardsComponents.tsx b/components/rewards/RewardsComponents.tsx index 6cadbc82..a4ea8f0d 100644 --- a/components/rewards/RewardsComponents.tsx +++ b/components/rewards/RewardsComponents.tsx @@ -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()) diff --git a/package.json b/package.json index 3d6a2647..dc976f5b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index bf46ca1a..d7568995 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"