feat: remove default store from code

This commit is contained in:
bartosz-lipinski 2021-06-08 18:00:12 -05:00
parent 43255f2616
commit b8171c5a53
15 changed files with 88 additions and 20 deletions

View File

@ -438,6 +438,11 @@ async function setupAuctionManagerInstructions(
signers: Keypair[]; signers: Keypair[];
auctionManager: PublicKey; auctionManager: PublicKey;
}> { }> {
let store = programIds().store;
if (!store) {
throw new Error('Store not initialized');
}
let signers: Keypair[] = []; let signers: Keypair[] = [];
let instructions: TransactionInstruction[] = []; let instructions: TransactionInstruction[] = [];
@ -457,7 +462,7 @@ async function setupAuctionManagerInstructions(
wallet.publicKey, wallet.publicKey,
wallet.publicKey, wallet.publicKey,
acceptPayment, acceptPayment,
programIds().store, store,
settings, settings,
instructions, instructions,
); );
@ -492,6 +497,11 @@ async function validateParticipationHelper(
participationSafetyDepositDraft: SafetyDepositDraft, participationSafetyDepositDraft: SafetyDepositDraft,
accountRentExempt: number, accountRentExempt: number,
): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[] }> { ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[] }> {
const store = programIds().store;
if (!store) {
throw new Error('Store not initialized');
}
let instructions: TransactionInstruction[] = []; let instructions: TransactionInstruction[] = [];
let signers: Keypair[] = []; let signers: Keypair[] = [];
const whitelistedCreator = participationSafetyDepositDraft.metadata.info.data const whitelistedCreator = participationSafetyDepositDraft.metadata.info.data
@ -521,7 +531,7 @@ async function validateParticipationHelper(
printingTokenHoldingAccount, printingTokenHoldingAccount,
wallet.publicKey, wallet.publicKey,
whitelistedCreator, whitelistedCreator,
programIds().store, store,
await getSafetyDepositBoxAddress( await getSafetyDepositBoxAddress(
vault, vault,
participationSafetyDepositDraft.masterEdition.info participationSafetyDepositDraft.masterEdition.info
@ -568,6 +578,11 @@ async function validateBoxes(
instructions: TransactionInstruction[][]; instructions: TransactionInstruction[][];
signers: Keypair[][]; signers: Keypair[][];
}> { }> {
const store = programIds().store;
if (!store) {
throw new Error('Store not initialized');
}
let signers: Keypair[][] = []; let signers: Keypair[][] = [];
let instructions: TransactionInstruction[][] = []; let instructions: TransactionInstruction[][] = [];
@ -628,7 +643,7 @@ async function validateBoxes(
tokenInstructions, tokenInstructions,
edition, edition,
whitelistedCreator, whitelistedCreator,
programIds().store, store,
safetyDeposits[i].draft.masterEdition?.info.printingMint, safetyDeposits[i].draft.masterEdition?.info.printingMint,
safetyDeposits[i].draft.masterEdition ? wallet.publicKey : undefined, safetyDeposits[i].draft.masterEdition ? wallet.publicKey : undefined,
); );

View File

@ -2,14 +2,17 @@ import React, { useMemo } from 'react';
import './index.less'; import './index.less';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Button, Dropdown, Menu } from 'antd'; import { Button, Dropdown, Menu } from 'antd';
import { ConnectButton, CurrentUserBadge, useWallet } from '@oyster/common'; import { ConnectButton, CurrentUserBadge, useConnection, useWallet } from '@oyster/common';
import { Notifications } from '../Notifications'; import { Notifications } from '../Notifications';
import useWindowDimensions from '../../utils/layout'; import useWindowDimensions from '../../utils/layout';
import { MenuOutlined } from '@ant-design/icons'; import { MenuOutlined } from '@ant-design/icons';
import { useMeta } from '../../contexts'; import { useMeta } from '../../contexts';
import { saveAdmin } from '../../actions/saveAdmin';
import { WhitelistedCreator } from '../../models/metaplex';
const UserActions = () => { const UserActions = () => {
const { wallet } = useWallet(); const { wallet } = useWallet();
const connection = useConnection();
const { whitelistedCreatorsByCreator, store } = useMeta(); const { whitelistedCreatorsByCreator, store } = useMeta();
const pubkey = wallet?.publicKey?.toBase58() || ''; const pubkey = wallet?.publicKey?.toBase58() || '';
@ -23,6 +26,19 @@ const UserActions = () => {
return ( return (
<> <>
{!store?.info && wallet?.publicKey && <Button className="app-btn" onClick={async () => {
if(!wallet?.publicKey) {
return;
}
await saveAdmin(connection, wallet, false, [new WhitelistedCreator({
address: wallet?.publicKey,
activated: true,
})]);
window.location.reload();
}}>Init Store</Button>}
{/* <Link to={`#`}> {/* <Link to={`#`}>
<Button className="app-btn">Bids</Button> <Button className="app-btn">Bids</Button>
</Link> */} </Link> */}

View File

@ -645,7 +645,7 @@ const processMetaplexAccounts = async (
if (a.account.owner.toBase58() != programIds().metaplex.toBase58()) return; if (a.account.owner.toBase58() != programIds().metaplex.toBase58()) return;
try { try {
const STORE_ID = programIds().store.toBase58(); const STORE_ID = programIds().store?.toBase58() || '';
if ( if (
a.account.data[0] === MetaplexKey.AuctionManagerV1 || a.account.data[0] === MetaplexKey.AuctionManagerV1 ||
@ -692,7 +692,6 @@ const processMetaplexAccounts = async (
})); }));
} else if (a.account.data[0] === MetaplexKey.StoreV1) { } else if (a.account.data[0] === MetaplexKey.StoreV1) {
const store = decodeStore(a.account.data); const store = decodeStore(a.account.data);
console.log('Found store', store);
const account: ParsedAccount<Store> = { const account: ParsedAccount<Store> = {
pubkey: a.pubkey, pubkey: a.pubkey,
account: a.account, account: a.account,

View File

@ -17,6 +17,10 @@ export async function claimBid(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault);
@ -72,7 +76,7 @@ export async function claimBid(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -26,6 +26,10 @@ export async function emptyPaymentAccount(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const value = new EmptyPaymentAccountArgs({ const value = new EmptyPaymentAccountArgs({
winningConfigIndex, winningConfigIndex,
@ -83,7 +87,7 @@ export async function emptyPaymentAccount(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -690,12 +690,17 @@ export async function getOriginalAuthority(
export async function getWhitelistedCreator(creator: PublicKey) { export async function getWhitelistedCreator(creator: PublicKey) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
return ( return (
await PublicKey.findProgramAddress( await PublicKey.findProgramAddress(
[ [
Buffer.from(METAPLEX_PREFIX), Buffer.from(METAPLEX_PREFIX),
PROGRAM_IDS.metaplex.toBuffer(), PROGRAM_IDS.metaplex.toBuffer(),
PROGRAM_IDS.store.toBuffer(), store.toBuffer(),
creator.toBuffer(), creator.toBuffer(),
], ],
PROGRAM_IDS.metaplex, PROGRAM_IDS.metaplex,

View File

@ -25,6 +25,10 @@ export async function populateParticipationPrintingAccount(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const transferAuthority: PublicKey = ( const transferAuthority: PublicKey = (
await PublicKey.findProgramAddress( await PublicKey.findProgramAddress(
@ -115,7 +119,7 @@ export async function populateParticipationPrintingAccount(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -23,6 +23,10 @@ export async function redeemBid(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault);
@ -116,7 +120,7 @@ export async function redeemBid(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -27,6 +27,10 @@ export async function redeemFullRightsTransferBid(
newAuthority: PublicKey, newAuthority: PublicKey,
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault);
@ -120,7 +124,7 @@ export async function redeemFullRightsTransferBid(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -30,6 +30,10 @@ export async function redeemParticipationBid(
tokenPaymentAccount: PublicKey, tokenPaymentAccount: PublicKey,
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault);
@ -111,7 +115,7 @@ export async function redeemParticipationBid(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -15,13 +15,17 @@ export async function setStore(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const value = new SetStoreArgs({ public: isPublic }); const value = new SetStoreArgs({ public: isPublic });
const data = Buffer.from(serialize(SCHEMA, value)); const data = Buffer.from(serialize(SCHEMA, value));
const keys = [ const keys = [
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: true, isWritable: true,
}, },

View File

@ -16,6 +16,10 @@ export async function setWhitelistedCreator(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const whitelistedCreatorPDAKey = await getWhitelistedCreator(creator); const whitelistedCreatorPDAKey = await getWhitelistedCreator(creator);
@ -44,7 +48,7 @@ export async function setWhitelistedCreator(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -14,6 +14,10 @@ export async function startAuction(
instructions: TransactionInstruction[], instructions: TransactionInstruction[],
) { ) {
const PROGRAM_IDS = programIds(); const PROGRAM_IDS = programIds();
const store = PROGRAM_IDS.store;
if (!store) {
throw new Error('Store not initialized');
}
const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault);
@ -37,7 +41,7 @@ export async function startAuction(
isWritable: false, isWritable: false,
}, },
{ {
pubkey: PROGRAM_IDS.store, pubkey: store,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },

View File

@ -7,7 +7,7 @@ import {
} from '@solana/web3.js'; } from '@solana/web3.js';
import { serialize } from 'borsh'; import { serialize } from 'borsh';
import { getAuctionKeys, SCHEMA, ValidateParticipationArgs } from '.'; import { SCHEMA, ValidateParticipationArgs } from '.';
export async function validateParticipation( export async function validateParticipation(
auctionManager: PublicKey, auctionManager: PublicKey,

View File

@ -9,7 +9,6 @@ import {
Statistic, Statistic,
Progress, Progress,
Spin, Spin,
InputNumber,
Radio, Radio,
Card, Card,
Select, Select,
@ -42,7 +41,6 @@ import {
WinningConstraint, WinningConstraint,
ParticipationConfig, ParticipationConfig,
WinningConfigItem, WinningConfigItem,
WinningConfigState,
} from '../../models/metaplex'; } from '../../models/metaplex';
import moment from 'moment'; import moment from 'moment';
import { import {
@ -59,7 +57,6 @@ import { PlusCircleOutlined } from '@ant-design/icons';
const { Option } = Select; const { Option } = Select;
const { Step } = Steps; const { Step } = Steps;
const { TextArea } = Input;
export enum AuctionCategory { export enum AuctionCategory {
Limited, Limited,