implement update auctionview without refresh, fix claimBid instruction
This commit is contained in:
parent
3c7a9d2ae3
commit
d9d87407ee
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -52,6 +52,7 @@ const MetaContext = React.createContext<MetaContextState>({
|
|||
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<UpdateStateValueFunc>(
|
||||
|
@ -228,6 +232,7 @@ export function MetaProvider({ children = null as any }) {
|
|||
value={{
|
||||
...state,
|
||||
isLoading,
|
||||
update
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
|
|
@ -76,6 +76,7 @@ export interface MetaState {
|
|||
|
||||
export interface MetaContextState extends MetaState {
|
||||
isLoading: boolean;
|
||||
update: () => void;
|
||||
}
|
||||
|
||||
export type AccountAndPubkey = {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue