Merge pull request #239 from jordansexton/wallet-fixes

Wallet fixes
This commit is contained in:
B 2021-08-26 08:58:19 -05:00 committed by GitHub
commit fdcdd844f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 17 deletions

View File

@ -13,6 +13,8 @@ export async function markItemsThatArentMineAsSold(
): Promise<{ instructions: TransactionInstruction[][]; signers: Keypair[][] }> {
if (!wallet.publicKey) throw new WalletNotConnectedError();
const publicKey = wallet.publicKey.toBase58();
let signers: Array<Keypair[]> = [];
let instructions: Array<TransactionInstruction[]> = [];
@ -25,9 +27,7 @@ export async function markItemsThatArentMineAsSold(
const item = safetyDepositDrafts[i].metadata;
if (
!item.info.data.creators?.find(
c => c.address === wallet.publicKey!.toBase58(),
) &&
!item.info.data.creators?.find(c => c.address === publicKey) &&
!item.info.primarySaleHappened
) {
console.log(
@ -37,7 +37,7 @@ export async function markItemsThatArentMineAsSold(
);
await updatePrimarySaleHappenedViaToken(
item.pubkey,
wallet.publicKey.toBase58(),
publicKey,
safetyDepositDrafts[i].holding,
markInstructions,
);

View File

@ -28,8 +28,8 @@ export async function saveAdmin(
await setStore(
isPublic,
wallet.publicKey!.toBase58(),
wallet.publicKey!.toBase58(),
wallet.publicKey.toBase58(),
wallet.publicKey.toBase58(),
storeInstructions,
);
signers.push(storeSigners);
@ -43,8 +43,8 @@ export async function saveAdmin(
await setWhitelistedCreator(
wc.address,
wc.activated,
wallet.publicKey!.toBase58(),
wallet.publicKey!.toBase58(),
wallet.publicKey.toBase58(),
wallet.publicKey.toBase58(),
wcInstructions,
);
signers.push(wcSigners);

View File

@ -26,7 +26,7 @@ export const AuctionListView = () => {
const auctionsEnded = useAuctions(AuctionViewState.Ended);
const [activeKey, setActiveKey] = useState(LiveAuctionViewState.All);
const { isLoading } = useMeta();
const { wallet, connected, publicKey } = useWallet();
const { connected, publicKey } = useWallet();
const breakpointColumnsObj = {
default: 4,
1100: 3,

View File

@ -1,7 +1,7 @@
import { useConnection, useStore, WalletSigner } from '@oyster/common';
import { useConnection, useStore, useWalletModal, WalletSigner } from '@oyster/common';
import { useWallet } from '@solana/wallet-adapter-react';
import { Button } from 'antd';
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { saveAdmin } from '../../actions/saveAdmin';
import { useMeta } from '../../contexts';
@ -16,22 +16,27 @@ export const SetupView = () => {
const { setStoreForOwner } = useStore();
const history = useHistory();
const wallet = useWallet();
const { setVisible } = useWalletModal();
const connect = useCallback(
() => (wallet.wallet ? wallet.connect().catch() : setVisible(true)),
[wallet.wallet, wallet.connect, setVisible],
);
const [storeAddress, setStoreAddress] = useState<string | undefined>();
useEffect(() => {
const getStore = async () => {
if (wallet.connected) {
const store = await setStoreForOwner(wallet.publicKey?.toBase58());
if (wallet.publicKey) {
const store = await setStoreForOwner(wallet.publicKey.toBase58());
setStoreAddress(store);
} else {
setStoreAddress(undefined);
}
};
getStore();
}, [wallet.publicKey, wallet.connected]);
}, [wallet.publicKey]);
const initializeStore = async () => {
if (!wallet.publicKey || !wallet) {
if (!wallet.publicKey) {
return;
}
@ -47,7 +52,7 @@ export const SetupView = () => {
// TODO: process errors
await setStoreForOwner(undefined);
await setStoreForOwner(wallet.publicKey?.toBase58());
await setStoreForOwner(wallet.publicKey.toBase58());
history.push('/admin');
};
@ -56,7 +61,7 @@ export const SetupView = () => {
<>
{!wallet.connected && (
<p>
<Button type="primary" className="app-btn" onClick={wallet.connect}>
<Button type="primary" className="app-btn" onClick={connect}>
Connect
</Button>{' '}
to configure store.