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(
|
winnerIndex = auctionView.auction.info.bidState.getWinnerIndex(
|
||||||
auctionView.myBidderPot?.info.bidderAct,
|
auctionView.myBidderPot?.info.bidderAct,
|
||||||
);
|
);
|
||||||
console.log('Winner index', winnerIndex);
|
/**@ToDo need to fix hardcoded winner index for instant sale*/
|
||||||
|
winnerIndex = 0;
|
||||||
if (winnerIndex !== null) {
|
if (winnerIndex !== null) {
|
||||||
// items is a prebuilt array of arrays where each entry represents one
|
// 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
|
// 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 { useWallet } from '@solana/wallet-adapter-react';
|
||||||
import { AuctionView, useBidsForAuction, useUserBalance } from '../../hooks';
|
import { AuctionView, useBidsForAuction, useUserBalance } from '../../hooks';
|
||||||
import { sendPlaceBid } from '../../actions/sendPlaceBid';
|
import { sendPlaceBid } from '../../actions/sendPlaceBid';
|
||||||
import { bidAndClaimInstantSale } from '../../actions/bidAndClaimInstantSale';
|
// import { bidAndClaimInstantSale } from '../../actions/bidAndClaimInstantSale';
|
||||||
import { AuctionNumbers } from './../AuctionNumbers';
|
import { AuctionNumbers } from './../AuctionNumbers';
|
||||||
import {
|
import {
|
||||||
sendRedeemBid,
|
sendRedeemBid,
|
||||||
|
@ -184,6 +184,7 @@ export const AuctionCard = ({
|
||||||
action?: JSX.Element;
|
action?: JSX.Element;
|
||||||
}) => {
|
}) => {
|
||||||
const connection = useConnection();
|
const connection = useConnection();
|
||||||
|
const {update} = useMeta();
|
||||||
|
|
||||||
const wallet = useWallet();
|
const wallet = useWallet();
|
||||||
const { setVisible } = useWalletModal();
|
const { setVisible } = useWalletModal();
|
||||||
|
@ -517,10 +518,11 @@ export const AuctionCard = ({
|
||||||
);
|
);
|
||||||
setLastBid(bid);
|
setLastBid(bid);
|
||||||
// TODO: Remove this by propating necessary information to sendRedeemBid
|
// TODO: Remove this by propating necessary information to sendRedeemBid
|
||||||
window.location.reload();
|
// window.location.reload();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await update();
|
||||||
|
|
||||||
setShowBidModal(false);
|
setShowBidModal(false);
|
||||||
|
|
||||||
// Claim the purchase
|
// Claim the purchase
|
||||||
|
|
|
@ -52,6 +52,7 @@ const MetaContext = React.createContext<MetaContextState>({
|
||||||
payoutTickets: {},
|
payoutTickets: {},
|
||||||
prizeTrackingTickets: {},
|
prizeTrackingTickets: {},
|
||||||
stores: {},
|
stores: {},
|
||||||
|
update: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
export function MetaProvider({ children = null as any }) {
|
export function MetaProvider({ children = null as any }) {
|
||||||
|
@ -108,30 +109,33 @@ export function MetaProvider({ children = null as any }) {
|
||||||
[setState],
|
[setState],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
async function update () {
|
||||||
(async () => {
|
if (!storeAddress) {
|
||||||
if (!storeAddress) {
|
if (isReady) {
|
||||||
if (isReady) {
|
setIsLoading(false);
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (!state.store) {
|
|
||||||
setIsLoading(true);
|
|
||||||
}
|
}
|
||||||
|
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);
|
updateMints(nextState.metadataByMint);
|
||||||
console.log('------->set finished');
|
}
|
||||||
|
|
||||||
updateMints(nextState.metadataByMint);
|
|
||||||
})();
|
useEffect(() => {
|
||||||
|
update();
|
||||||
}, [connection, setState, updateMints, storeAddress, isReady]);
|
}, [connection, setState, updateMints, storeAddress, isReady]);
|
||||||
|
|
||||||
const updateStateValue = useMemo<UpdateStateValueFunc>(
|
const updateStateValue = useMemo<UpdateStateValueFunc>(
|
||||||
|
@ -228,6 +232,7 @@ export function MetaProvider({ children = null as any }) {
|
||||||
value={{
|
value={{
|
||||||
...state,
|
...state,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
update
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -76,6 +76,7 @@ export interface MetaState {
|
||||||
|
|
||||||
export interface MetaContextState extends MetaState {
|
export interface MetaContextState extends MetaState {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
|
update: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AccountAndPubkey = {
|
export type AccountAndPubkey = {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
getAuctionExtended,
|
||||||
getBidderPotKey,
|
getBidderPotKey,
|
||||||
programIds,
|
programIds,
|
||||||
StringPublicKey,
|
StringPublicKey,
|
||||||
|
@ -34,6 +35,11 @@ export async function claimBid(
|
||||||
const value = new ClaimBidArgs();
|
const value = new ClaimBidArgs();
|
||||||
const data = Buffer.from(serialize(SCHEMA, value));
|
const data = Buffer.from(serialize(SCHEMA, value));
|
||||||
|
|
||||||
|
const auctionExtendedKey = await getAuctionExtended({
|
||||||
|
auctionProgramId: PROGRAM_IDS.auction,
|
||||||
|
resource: vault,
|
||||||
|
});
|
||||||
|
|
||||||
const keys = [
|
const keys = [
|
||||||
{
|
{
|
||||||
pubkey: toPublicKey(acceptPayment),
|
pubkey: toPublicKey(acceptPayment),
|
||||||
|
@ -61,6 +67,11 @@ export async function claimBid(
|
||||||
isSigner: false,
|
isSigner: false,
|
||||||
isWritable: false,
|
isWritable: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pubkey: toPublicKey(auctionExtendedKey),
|
||||||
|
isSigner: false,
|
||||||
|
isWritable: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pubkey: toPublicKey(bidder),
|
pubkey: toPublicKey(bidder),
|
||||||
isSigner: false,
|
isSigner: false,
|
||||||
|
|
Loading…
Reference in New Issue