diff --git a/js/packages/web/src/actions/sendRedeemBid.ts b/js/packages/web/src/actions/sendRedeemBid.ts index e0be071..3d7f361 100644 --- a/js/packages/web/src/actions/sendRedeemBid.ts +++ b/js/packages/web/src/actions/sendRedeemBid.ts @@ -129,8 +129,8 @@ export async function sendRedeemBid( winnerIndex = auctionView.auction.info.bidState.getWinnerIndex( auctionView.myBidderPot?.info.bidderAct, ); - console.log('Winner index', winnerIndex); - + /**@ToDo need to fix hardcoded winner index for instant sale*/ + winnerIndex = 0; if (winnerIndex !== null) { // items is a prebuilt array of arrays where each entry represents one // winning spot, and each entry in it represents one type of item that can diff --git a/js/packages/web/src/components/AuctionCard/index.tsx b/js/packages/web/src/components/AuctionCard/index.tsx index 09a7e85..7e0c3d1 100644 --- a/js/packages/web/src/components/AuctionCard/index.tsx +++ b/js/packages/web/src/components/AuctionCard/index.tsx @@ -25,7 +25,7 @@ import { import { useWallet } from '@solana/wallet-adapter-react'; import { AuctionView, useBidsForAuction, useUserBalance } from '../../hooks'; import { sendPlaceBid } from '../../actions/sendPlaceBid'; -import { bidAndClaimInstantSale } from '../../actions/bidAndClaimInstantSale'; +// import { bidAndClaimInstantSale } from '../../actions/bidAndClaimInstantSale'; import { AuctionNumbers } from './../AuctionNumbers'; import { sendRedeemBid, @@ -184,6 +184,7 @@ export const AuctionCard = ({ action?: JSX.Element; }) => { const connection = useConnection(); + const {update} = useMeta(); const wallet = useWallet(); const { setVisible } = useWalletModal(); @@ -517,10 +518,11 @@ export const AuctionCard = ({ ); setLastBid(bid); // TODO: Remove this by propating necessary information to sendRedeemBid - window.location.reload(); - return; + // window.location.reload(); } + await update(); + setShowBidModal(false); // Claim the purchase diff --git a/js/packages/web/src/contexts/meta/meta.tsx b/js/packages/web/src/contexts/meta/meta.tsx index fe98208..0e43ae4 100644 --- a/js/packages/web/src/contexts/meta/meta.tsx +++ b/js/packages/web/src/contexts/meta/meta.tsx @@ -52,6 +52,7 @@ const MetaContext = React.createContext({ payoutTickets: {}, prizeTrackingTickets: {}, stores: {}, + update: () => {}, }); export function MetaProvider({ children = null as any }) { @@ -108,30 +109,33 @@ export function MetaProvider({ children = null as any }) { [setState], ); - useEffect(() => { - (async () => { - if (!storeAddress) { - if (isReady) { - setIsLoading(false); - } - return; - } else if (!state.store) { - setIsLoading(true); + async function update () { + if (!storeAddress) { + if (isReady) { + setIsLoading(false); } + return; + } else if (!state.store) { + setIsLoading(true); + } - console.log('-----> Query started'); + console.log('-----> Query started'); - const nextState = await loadAccounts(connection, all); + const nextState = await loadAccounts(connection, all); + console.log('loadAccounts',nextState) + console.log('------->Query finished'); - console.log('------->Query finished'); + setState(nextState); - setState(nextState); + setIsLoading(false); + console.log('------->set finished'); - setIsLoading(false); - console.log('------->set finished'); + updateMints(nextState.metadataByMint); + } - updateMints(nextState.metadataByMint); - })(); + + useEffect(() => { + update(); }, [connection, setState, updateMints, storeAddress, isReady]); const updateStateValue = useMemo( @@ -228,6 +232,7 @@ export function MetaProvider({ children = null as any }) { value={{ ...state, isLoading, + update }} > {children} diff --git a/js/packages/web/src/contexts/meta/types.ts b/js/packages/web/src/contexts/meta/types.ts index 368cb68..0dc572c 100644 --- a/js/packages/web/src/contexts/meta/types.ts +++ b/js/packages/web/src/contexts/meta/types.ts @@ -76,6 +76,7 @@ export interface MetaState { export interface MetaContextState extends MetaState { isLoading: boolean; + update: () => void; } export type AccountAndPubkey = { diff --git a/js/packages/web/src/models/metaplex/claimBid.ts b/js/packages/web/src/models/metaplex/claimBid.ts index d9f9141..91d60ce 100644 --- a/js/packages/web/src/models/metaplex/claimBid.ts +++ b/js/packages/web/src/models/metaplex/claimBid.ts @@ -1,4 +1,5 @@ import { + getAuctionExtended, getBidderPotKey, programIds, StringPublicKey, @@ -34,6 +35,11 @@ export async function claimBid( const value = new ClaimBidArgs(); const data = Buffer.from(serialize(SCHEMA, value)); + const auctionExtendedKey = await getAuctionExtended({ + auctionProgramId: PROGRAM_IDS.auction, + resource: vault, + }); + const keys = [ { pubkey: toPublicKey(acceptPayment), @@ -61,6 +67,11 @@ export async function claimBid( isSigner: false, isWritable: false, }, + { + pubkey: toPublicKey(auctionExtendedKey), + isSigner: false, + isWritable: false, + }, { pubkey: toPublicKey(bidder), isSigner: false,