Merge remote-tracking branch 'origin/feature/m-jordan' into feature/m

This commit is contained in:
bartosz-lipinski 2021-04-26 23:19:59 -05:00
commit 6d4c03809b
4 changed files with 41 additions and 38 deletions

View File

@ -70,18 +70,18 @@ export class AuctionData {
resource: PublicKey;
/// Token mint for the SPL token being used to bid
tokenMint: PublicKey;
/// The time the last bid was placed, used to keep track of auction timing.
lastBid: BN | null;
/// Slot time the auction was officially ended by.
endedAt: BN | null;
/// End time is the cut-off point that the auction is forced to end by.
endAuctionAt: BN | null;
/// Gap time is the amount of time in slots after the previous bid at which the auction ends.
endAuctionGap: BN | null;
/// The state the auction is in, whether it has started or ended.
state: AuctionState;
/// Auction Bids, each user may have one bid open at a time.
bidState: BidState;
/// The time the last bid was placed, used to keep track of auction timing.
lastBid?: BN;
/// Slot time the auction was officially ended by.
endedAt?: BN;
/// End time is the cut-off point that the auction is forced to end by.
endAuctionAt?: BN;
/// Gap time is the amount of time in slots after the previous bid at which the auction ends.
endAuctionGap?: BN;
/// Used for precalculation on the front end, not a backend key
auctionManagerKey?: PublicKey;
@ -90,22 +90,22 @@ export class AuctionData {
authority: PublicKey;
resource: PublicKey;
tokenMint: PublicKey;
lastBid: BN | null;
endedAt: BN | null;
endAuctionAt: BN | null;
endAuctionGap: BN | null;
state: AuctionState;
bidState: BidState;
lastBid?: BN;
endedAt?: BN;
endAuctionAt?: BN;
endAuctionGap?: BN;
}) {
this.authority = args.authority;
this.resource = args.resource;
this.tokenMint = args.tokenMint;
this.state = args.state;
this.bidState = args.bidState;
this.lastBid = args.lastBid;
this.endedAt = args.endedAt;
this.endAuctionAt = args.endAuctionAt;
this.endAuctionGap = args.endAuctionGap;
this.state = args.state;
this.bidState = args.bidState;
}
}
@ -273,12 +273,12 @@ export const AUCTION_SCHEMA = new Map<any, any>([
['authority', 'pubkey'],
['resource', 'pubkey'],
['tokenMint', 'pubkey'],
['state', 'u8'],
['bidState', BidState],
['lastBid', { kind: 'option', type: 'u64' }],
['endedAt', { kind: 'option', type: 'u64' }],
['endAuctionAt', { kind: 'option', type: 'u64' }],
['endAuctionGap', { kind: 'option', type: 'u64' }],
['state', 'u8'],
['bidState', BidState],
],
},
],

View File

@ -172,8 +172,8 @@ class TransferUpdateAuthorityArgs {
class CreateMasterEditionArgs {
instruction: number = 3;
maxSupply?: BN;
constructor(args: { maxSupply?: BN }) {
maxSupply: BN | null;
constructor(args: { maxSupply: BN | null }) {
this.maxSupply = args.maxSupply;
}
}
@ -561,7 +561,7 @@ export async function createMasterEdition(
)
)[0];
const value = new CreateMasterEditionArgs({ maxSupply });
const value = new CreateMasterEditionArgs({ maxSupply: maxSupply || null });
const data = Buffer.from(serialize(METADATA_SCHEMA, value));
const keys = [

View File

@ -66,23 +66,25 @@ export const useAuctions = (state: AuctionViewState) => {
} = useMeta();
useEffect(() => {
Object.keys(auctions).forEach(a => {
const auction = auctions[a];
const existingAuctionView = auctionViews[a];
const nextAuctionView = processAccountsIntoAuctionView(
auction,
auctionManagers,
safetyDepositBoxesByVaultAndIndex,
metadataByMint,
bidderMetadataByAuctionAndBidder,
bidderPotsByAuctionAndBidder,
accountByMint,
clock,
state,
existingAuctionView,
);
setAuctionViews(nA => ({ ...nA, [a]: nextAuctionView }));
});
console.log('Clock', clock);
if (clock != 0)
Object.keys(auctions).forEach(a => {
const auction = auctions[a];
const existingAuctionView = auctionViews[a];
const nextAuctionView = processAccountsIntoAuctionView(
auction,
auctionManagers,
safetyDepositBoxesByVaultAndIndex,
metadataByMint,
bidderMetadataByAuctionAndBidder,
bidderPotsByAuctionAndBidder,
accountByMint,
clock,
state,
existingAuctionView,
);
setAuctionViews(nA => ({ ...nA, [a]: nextAuctionView }));
});
}, [
clock,
state,
@ -117,6 +119,7 @@ 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)

View File

@ -130,7 +130,7 @@ export const AuctionCreateView = () => {
const [attributes, setAttributes] = useState<AuctionState>({
reservationPrice: 0,
items: [],
category: AuctionCategory.Single,
category: AuctionCategory.Open,
saleType: 'auction',
winnersCount: 1,
});
@ -191,7 +191,7 @@ export const AuctionCreateView = () => {
wallet,
settings,
winnerLimit,
new BN((attributes.auctionDuration || 1) * 60),
new BN((attributes.auctionDuration || 1) * 60 * 60 * 24),
new BN((attributes.gapTime || 1) * 60),
attributes.items,
// TODO: move to config