diff --git a/js/packages/web/src/actions/createAuctionManager.ts b/js/packages/web/src/actions/createAuctionManager.ts index b5852f9..a2b644b 100644 --- a/js/packages/web/src/actions/createAuctionManager.ts +++ b/js/packages/web/src/actions/createAuctionManager.ts @@ -438,6 +438,11 @@ async function setupAuctionManagerInstructions( signers: Keypair[]; auctionManager: PublicKey; }> { + let store = programIds().store; + if (!store) { + throw new Error('Store not initialized'); + } + let signers: Keypair[] = []; let instructions: TransactionInstruction[] = []; @@ -457,7 +462,7 @@ async function setupAuctionManagerInstructions( wallet.publicKey, wallet.publicKey, acceptPayment, - programIds().store, + store, settings, instructions, ); @@ -492,6 +497,11 @@ async function validateParticipationHelper( participationSafetyDepositDraft: SafetyDepositDraft, accountRentExempt: number, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[] }> { + const store = programIds().store; + if (!store) { + throw new Error('Store not initialized'); + } + let instructions: TransactionInstruction[] = []; let signers: Keypair[] = []; const whitelistedCreator = participationSafetyDepositDraft.metadata.info.data @@ -521,7 +531,7 @@ async function validateParticipationHelper( printingTokenHoldingAccount, wallet.publicKey, whitelistedCreator, - programIds().store, + store, await getSafetyDepositBoxAddress( vault, participationSafetyDepositDraft.masterEdition.info @@ -568,6 +578,11 @@ async function validateBoxes( instructions: TransactionInstruction[][]; signers: Keypair[][]; }> { + const store = programIds().store; + if (!store) { + throw new Error('Store not initialized'); + } + let signers: Keypair[][] = []; let instructions: TransactionInstruction[][] = []; @@ -628,7 +643,7 @@ async function validateBoxes( tokenInstructions, edition, whitelistedCreator, - programIds().store, + store, safetyDeposits[i].draft.masterEdition?.info.printingMint, safetyDeposits[i].draft.masterEdition ? wallet.publicKey : undefined, ); diff --git a/js/packages/web/src/components/AppBar/index.tsx b/js/packages/web/src/components/AppBar/index.tsx index 78c0dd9..ca636e4 100644 --- a/js/packages/web/src/components/AppBar/index.tsx +++ b/js/packages/web/src/components/AppBar/index.tsx @@ -2,14 +2,17 @@ import React, { useMemo } from 'react'; import './index.less'; import { Link } from 'react-router-dom'; 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 useWindowDimensions from '../../utils/layout'; import { MenuOutlined } from '@ant-design/icons'; import { useMeta } from '../../contexts'; +import { saveAdmin } from '../../actions/saveAdmin'; +import { WhitelistedCreator } from '../../models/metaplex'; const UserActions = () => { const { wallet } = useWallet(); + const connection = useConnection(); const { whitelistedCreatorsByCreator, store } = useMeta(); const pubkey = wallet?.publicKey?.toBase58() || ''; @@ -23,6 +26,19 @@ const UserActions = () => { return ( <> + {!store?.info && wallet?.publicKey && } + {/* */} diff --git a/js/packages/web/src/contexts/meta.tsx b/js/packages/web/src/contexts/meta.tsx index eaec9f7..b7b90af 100644 --- a/js/packages/web/src/contexts/meta.tsx +++ b/js/packages/web/src/contexts/meta.tsx @@ -645,7 +645,7 @@ const processMetaplexAccounts = async ( if (a.account.owner.toBase58() != programIds().metaplex.toBase58()) return; try { - const STORE_ID = programIds().store.toBase58(); + const STORE_ID = programIds().store?.toBase58() || ''; if ( a.account.data[0] === MetaplexKey.AuctionManagerV1 || @@ -692,7 +692,6 @@ const processMetaplexAccounts = async ( })); } else if (a.account.data[0] === MetaplexKey.StoreV1) { const store = decodeStore(a.account.data); - console.log('Found store', store); const account: ParsedAccount = { pubkey: a.pubkey, account: a.account, diff --git a/js/packages/web/src/models/metaplex/claimBid.ts b/js/packages/web/src/models/metaplex/claimBid.ts index e8a1021..1ca1481 100644 --- a/js/packages/web/src/models/metaplex/claimBid.ts +++ b/js/packages/web/src/models/metaplex/claimBid.ts @@ -17,6 +17,10 @@ export async function claimBid( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); @@ -72,7 +76,7 @@ export async function claimBid( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/emptyPaymentAccount.ts b/js/packages/web/src/models/metaplex/emptyPaymentAccount.ts index 237c2e1..3eff2b6 100644 --- a/js/packages/web/src/models/metaplex/emptyPaymentAccount.ts +++ b/js/packages/web/src/models/metaplex/emptyPaymentAccount.ts @@ -26,6 +26,10 @@ export async function emptyPaymentAccount( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const value = new EmptyPaymentAccountArgs({ winningConfigIndex, @@ -83,7 +87,7 @@ export async function emptyPaymentAccount( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/index.ts b/js/packages/web/src/models/metaplex/index.ts index 82a5f3a..489ceb0 100644 --- a/js/packages/web/src/models/metaplex/index.ts +++ b/js/packages/web/src/models/metaplex/index.ts @@ -690,12 +690,17 @@ export async function getOriginalAuthority( export async function getWhitelistedCreator(creator: PublicKey) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } + return ( await PublicKey.findProgramAddress( [ Buffer.from(METAPLEX_PREFIX), PROGRAM_IDS.metaplex.toBuffer(), - PROGRAM_IDS.store.toBuffer(), + store.toBuffer(), creator.toBuffer(), ], PROGRAM_IDS.metaplex, diff --git a/js/packages/web/src/models/metaplex/populateParticipationPrintingAccount.ts b/js/packages/web/src/models/metaplex/populateParticipationPrintingAccount.ts index 9c9791c..2989352 100644 --- a/js/packages/web/src/models/metaplex/populateParticipationPrintingAccount.ts +++ b/js/packages/web/src/models/metaplex/populateParticipationPrintingAccount.ts @@ -25,6 +25,10 @@ export async function populateParticipationPrintingAccount( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const transferAuthority: PublicKey = ( await PublicKey.findProgramAddress( @@ -115,7 +119,7 @@ export async function populateParticipationPrintingAccount( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/redeemBid.ts b/js/packages/web/src/models/metaplex/redeemBid.ts index 544a93f..f4f71dc 100644 --- a/js/packages/web/src/models/metaplex/redeemBid.ts +++ b/js/packages/web/src/models/metaplex/redeemBid.ts @@ -23,6 +23,10 @@ export async function redeemBid( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); @@ -116,7 +120,7 @@ export async function redeemBid( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/redeemFullRightsTransferBid.ts b/js/packages/web/src/models/metaplex/redeemFullRightsTransferBid.ts index 426c33c..5e3eaf3 100644 --- a/js/packages/web/src/models/metaplex/redeemFullRightsTransferBid.ts +++ b/js/packages/web/src/models/metaplex/redeemFullRightsTransferBid.ts @@ -27,6 +27,10 @@ export async function redeemFullRightsTransferBid( newAuthority: PublicKey, ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); @@ -120,7 +124,7 @@ export async function redeemFullRightsTransferBid( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/redeemParticipationBid.ts b/js/packages/web/src/models/metaplex/redeemParticipationBid.ts index bf6e8bb..c90d5ca 100644 --- a/js/packages/web/src/models/metaplex/redeemParticipationBid.ts +++ b/js/packages/web/src/models/metaplex/redeemParticipationBid.ts @@ -30,6 +30,10 @@ export async function redeemParticipationBid( tokenPaymentAccount: PublicKey, ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); @@ -111,7 +115,7 @@ export async function redeemParticipationBid( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/setStore.ts b/js/packages/web/src/models/metaplex/setStore.ts index 707ff14..84ddbf8 100644 --- a/js/packages/web/src/models/metaplex/setStore.ts +++ b/js/packages/web/src/models/metaplex/setStore.ts @@ -15,13 +15,17 @@ export async function setStore( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const value = new SetStoreArgs({ public: isPublic }); const data = Buffer.from(serialize(SCHEMA, value)); const keys = [ { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: true, }, diff --git a/js/packages/web/src/models/metaplex/setWhitelistedCreator.ts b/js/packages/web/src/models/metaplex/setWhitelistedCreator.ts index bd00209..69df57c 100644 --- a/js/packages/web/src/models/metaplex/setWhitelistedCreator.ts +++ b/js/packages/web/src/models/metaplex/setWhitelistedCreator.ts @@ -16,6 +16,10 @@ export async function setWhitelistedCreator( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const whitelistedCreatorPDAKey = await getWhitelistedCreator(creator); @@ -44,7 +48,7 @@ export async function setWhitelistedCreator( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/startAuction.ts b/js/packages/web/src/models/metaplex/startAuction.ts index fd4968c..e90ac82 100644 --- a/js/packages/web/src/models/metaplex/startAuction.ts +++ b/js/packages/web/src/models/metaplex/startAuction.ts @@ -14,6 +14,10 @@ export async function startAuction( instructions: TransactionInstruction[], ) { const PROGRAM_IDS = programIds(); + const store = PROGRAM_IDS.store; + if (!store) { + throw new Error('Store not initialized'); + } const { auctionKey, auctionManagerKey } = await getAuctionKeys(vault); @@ -37,7 +41,7 @@ export async function startAuction( isWritable: false, }, { - pubkey: PROGRAM_IDS.store, + pubkey: store, isSigner: false, isWritable: false, }, diff --git a/js/packages/web/src/models/metaplex/validateParticipation.ts b/js/packages/web/src/models/metaplex/validateParticipation.ts index 668a0df..d052131 100644 --- a/js/packages/web/src/models/metaplex/validateParticipation.ts +++ b/js/packages/web/src/models/metaplex/validateParticipation.ts @@ -7,7 +7,7 @@ import { } from '@solana/web3.js'; import { serialize } from 'borsh'; -import { getAuctionKeys, SCHEMA, ValidateParticipationArgs } from '.'; +import { SCHEMA, ValidateParticipationArgs } from '.'; export async function validateParticipation( auctionManager: PublicKey, diff --git a/js/packages/web/src/views/auctionCreate/index.tsx b/js/packages/web/src/views/auctionCreate/index.tsx index 911ffc9..32adf72 100644 --- a/js/packages/web/src/views/auctionCreate/index.tsx +++ b/js/packages/web/src/views/auctionCreate/index.tsx @@ -9,7 +9,6 @@ import { Statistic, Progress, Spin, - InputNumber, Radio, Card, Select, @@ -42,7 +41,6 @@ import { WinningConstraint, ParticipationConfig, WinningConfigItem, - WinningConfigState, } from '../../models/metaplex'; import moment from 'moment'; import { @@ -59,7 +57,6 @@ import { PlusCircleOutlined } from '@ant-design/icons'; const { Option } = Select; const { Step } = Steps; -const { TextArea } = Input; export enum AuctionCategory { Limited,