- {slots.map((slot, i) => {
- const isEmpty = !slot.item_name && !slot.item_id;
+ {entries.map(([slotName, assetId]) => {
+ const isEmpty = !assetId;
return (
-
+
- {slot.slot_name}
+ {slotName}
- {isEmpty ? '비어있음' : `${slot.item_name} #${slot.item_id}`}
+ {isEmpty ? '비어있음' : assetId}
);
diff --git a/src/components/wallet/MarketTab.jsx b/src/components/wallet/MarketTab.jsx
index b277701..aa7bdc9 100644
--- a/src/components/wallet/MarketTab.jsx
+++ b/src/components/wallet/MarketTab.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback } from 'react';
-import { getMarketListings, getWallet, buyFromMarket, cancelListing } from '../../api/chain';
+import { getMarketListings, getListing, getWallet, buyFromMarket, cancelListing } from '../../api/chain';
import { useToast } from '../toast/useToast';
import { useConfirm } from '../confirm/useConfirm';
@@ -12,7 +12,7 @@ export default function MarketTab() {
const toast = useToast();
const confirm = useConfirm();
const [listings, setListings] = useState([]);
- const [myAddress, setMyAddress] = useState('');
+ const [myPubKey, setMyPubKey] = useState('');
const [loading, setLoading] = useState(true);
const [filter, setFilter] = useState('all');
const [processing, setProcessing] = useState(null);
@@ -20,9 +20,20 @@ export default function MarketTab() {
const load = useCallback(() => {
setLoading(true);
Promise.all([getMarketListings(), getWallet()])
- .then(([l, w]) => {
- setListings(l || []);
- setMyAddress(w?.address || '');
+ .then(([result, w]) => {
+ const ids = result?.ids || result;
+ setMyPubKey(w?.pubKeyHex || '');
+ if (!ids || !Array.isArray(ids) || ids.length === 0) {
+ setListings([]);
+ return;
+ }
+ return Promise.all(
+ ids.map((id) =>
+ getListing(id)
+ .then((data) => ({ ...data, _loaded: true }))
+ .catch(() => ({ id, _loaded: false }))
+ )
+ ).then((items) => setListings(items.filter((l) => l._loaded)));
})
.catch(() => {
toast.error('마켓 정보를 불러오지 못했습니다.');
@@ -34,12 +45,12 @@ export default function MarketTab() {
const handleBuy = async (listing) => {
const ok = await confirm(
- `${listing.item_name || '아이템'}을(를) ${Number(listing.price).toLocaleString()} TOL에 구매하시겠습니까?`
+ `${listing.asset_id}을(를) ${Number(listing.price).toLocaleString()} TOL에 구매하시겠습니까?`
);
if (!ok) return;
- setProcessing(listing.listing_id);
+ setProcessing(listing.id);
try {
- await buyFromMarket(listing.listing_id);
+ await buyFromMarket(listing.id);
toast.success('구매가 완료되었습니다.');
load();
} catch (err) {
@@ -52,9 +63,9 @@ export default function MarketTab() {
const handleCancel = async (listing) => {
const ok = await confirm('리스팅을 취소하시겠습니까?');
if (!ok) return;
- setProcessing(listing.listing_id);
+ setProcessing(listing.id);
try {
- await cancelListing(listing.listing_id);
+ await cancelListing(listing.id);
toast.success('리스팅이 취소되었습니다.');
load();
} catch (err) {
@@ -67,7 +78,7 @@ export default function MarketTab() {
if (loading) return
불러오는 중...
;
const filtered = filter === 'mine'
- ? listings.filter((l) => l.seller === myAddress)
+ ? listings.filter((l) => l.seller === myPubKey)
: listings;
return (
@@ -93,11 +104,11 @@ export default function MarketTab() {
) : (
filtered.map((listing) => {
- const isMine = listing.seller === myAddress;
+ const isMine = listing.seller === myPubKey;
return (
-
+
- {listing.item_name || '아이템'}
+ {listing.asset_id}
{truncateAddr(listing.seller)}
@@ -107,18 +118,18 @@ export default function MarketTab() {
{isMine ? (
) : (
)}
diff --git a/src/components/wallet/WalletSummary.jsx b/src/components/wallet/WalletSummary.jsx
index 3175aae..01d283c 100644
--- a/src/components/wallet/WalletSummary.jsx
+++ b/src/components/wallet/WalletSummary.jsx
@@ -17,9 +17,11 @@ export default function WalletSummary() {
getInventory().catch(() => null),
]).then(([b, assets, inv]) => {
setBalance(b?.balance != null ? b.balance : null);
- setAssetCount(assets != null ? assets.length : null);
+ const ids = assets?.ids || assets;
+ setAssetCount(Array.isArray(ids) ? ids.length : null);
+ const slots = inv?.slots;
setEquippedCount(
- inv != null ? inv.filter((s) => s.item_name || s.item_id).length : null
+ slots != null ? Object.values(slots).filter(Boolean).length : null
);
}).finally(() => setLoading(false));
}, []);
diff --git a/src/components/wallet/WalletTab.jsx b/src/components/wallet/WalletTab.jsx
index bf20a8d..41d38ab 100644
--- a/src/components/wallet/WalletTab.jsx
+++ b/src/components/wallet/WalletTab.jsx
@@ -58,7 +58,7 @@ export default function WalletTab() {
setExporting(true);
try {
const data = await exportWalletKey(password);
- setPrivateKey(data.private_key);
+ setPrivateKey(data.privateKey);
} catch (err) {
if (err.status === 401) {
setExportError(err.message);
@@ -90,8 +90,8 @@ export default function WalletTab() {
공개키
- {truncate(wallet.public_key, 4, 4)}
-