mirror of https://github.com/certusone/oyster.git
Latest fixes to bidder metadata
This commit is contained in:
parent
59c1fc5c54
commit
ce33240b85
|
@ -109,6 +109,7 @@ export class AuctionData {
|
|||
}
|
||||
}
|
||||
|
||||
export const BIDDER_METADATA_LEN = 32 + 32 + 8 + 8 + 1;
|
||||
export class BidderMetadata {
|
||||
// Relationship with the bidder who's metadata this covers.
|
||||
bidderPubkey: PublicKey;
|
||||
|
@ -136,6 +137,7 @@ export class BidderMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
export const BIDDER_POT_LEN = 32 + 32 + 32;
|
||||
export class BidderPot {
|
||||
/// Points at actual pot that is a token account
|
||||
bidderPot: PublicKey;
|
||||
|
|
|
@ -24,6 +24,8 @@ import {
|
|||
decodeBidderMetadata,
|
||||
BidderPot,
|
||||
decodeBidderPot,
|
||||
BIDDER_METADATA_LEN,
|
||||
BIDDER_POT_LEN,
|
||||
} from '@oyster/common';
|
||||
import { MintInfo } from '@solana/spl-token';
|
||||
import { Connection, PublicKey, PublicKeyAndAccount } from '@solana/web3.js';
|
||||
|
@ -126,7 +128,10 @@ export function MetaProvider({ children = null as any }) {
|
|||
} catch {
|
||||
// ignore errors
|
||||
// add type as first byte for easier deserialization
|
||||
try {
|
||||
}
|
||||
|
||||
try {
|
||||
if (a.account.data.length == BIDDER_METADATA_LEN) {
|
||||
const bidderMetadata = await decodeBidderMetadata(a.account.data);
|
||||
|
||||
const account: ParsedAccount<BidderMetadata> = {
|
||||
|
@ -140,28 +145,29 @@ export function MetaProvider({ children = null as any }) {
|
|||
'-' +
|
||||
bidderMetadata.bidderPubkey.toBase58()]: account,
|
||||
}));
|
||||
} catch {
|
||||
// ignore errors
|
||||
// add type as first byte for easier deserialization
|
||||
try {
|
||||
const bidderPot = await decodeBidderPot(a.account.data);
|
||||
|
||||
const account: ParsedAccount<BidderPot> = {
|
||||
pubkey: a.pubkey,
|
||||
account: a.account,
|
||||
info: bidderPot,
|
||||
};
|
||||
setBidderPotsByAuctionAndBidder(e => ({
|
||||
...e,
|
||||
[bidderPot.auctionAct.toBase58() +
|
||||
'-' +
|
||||
bidderPot.bidderAct.toBase58()]: account,
|
||||
}));
|
||||
} catch {
|
||||
// ignore errors
|
||||
// add type as first byte for easier deserialization
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore errors
|
||||
// add type as first byte for easier deserialization
|
||||
}
|
||||
try {
|
||||
if (a.account.data.length == BIDDER_POT_LEN) {
|
||||
const bidderPot = await decodeBidderPot(a.account.data);
|
||||
const account: ParsedAccount<BidderPot> = {
|
||||
pubkey: a.pubkey,
|
||||
account: a.account,
|
||||
info: bidderPot,
|
||||
};
|
||||
setBidderPotsByAuctionAndBidder(e => ({
|
||||
...e,
|
||||
[bidderPot.auctionAct.toBase58() +
|
||||
'-' +
|
||||
bidderPot.bidderAct.toBase58()]: account,
|
||||
}));
|
||||
}
|
||||
} catch {
|
||||
// ignore errors
|
||||
// add type as first byte for easier deserialization
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ export const useAuction = (id: string) => {
|
|||
useEffect(() => {
|
||||
const auction = auctions[id];
|
||||
if (auction) {
|
||||
console.log(bidderMetadataByAuctionAndBidder);
|
||||
const auctionView = processAccountsIntoAuctionView(
|
||||
auction,
|
||||
auctionManagers,
|
||||
|
|
|
@ -66,7 +66,6 @@ export const useAuctions = (state: AuctionViewState) => {
|
|||
} = useMeta();
|
||||
|
||||
useEffect(() => {
|
||||
console.log('Clock', clock);
|
||||
if (clock != 0)
|
||||
Object.keys(auctions).forEach(a => {
|
||||
const auction = auctions[a];
|
||||
|
@ -119,7 +118,6 @@ export function processAccountsIntoAuctionView(
|
|||
existingAuctionView?: AuctionView,
|
||||
): AuctionView | undefined {
|
||||
let state: AuctionViewState;
|
||||
console.log(auction?.info?.endedAt?.toNumber(), clock);
|
||||
if (
|
||||
auction.info.state == AuctionState.Ended ||
|
||||
(auction.info.endedAt && auction.info.endedAt.toNumber() <= clock)
|
||||
|
@ -152,6 +150,17 @@ export function processAccountsIntoAuctionView(
|
|||
bidderPotsByAuctionAndBidder[
|
||||
auction.pubkey.toBase58() + '-' + myPayingAccount?.pubkey.toBase58()
|
||||
];
|
||||
if (
|
||||
auction.pubkey.toBase58() ==
|
||||
'CLxhAeuhz8KX3y8yEWHADtmTzE26ofAnd6j8zwMXjW9P'
|
||||
) {
|
||||
console.log(
|
||||
'I found',
|
||||
|
||||
bidderMetadata,
|
||||
myPayingAccount?.pubkey.toBase58(),
|
||||
);
|
||||
}
|
||||
if (existingAuctionView && existingAuctionView.totallyComplete) {
|
||||
// If totally complete, we know we arent updating anythign else, let's speed things up
|
||||
// and only update the two things that could possibly change
|
||||
|
|
Loading…
Reference in New Issue