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