tiwiflix-wallet-connector 1.4.8 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +37 -1
- package/dist/index.js +37 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6464,6 +6464,10 @@ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAdd
|
|
|
6464
6464
|
// State for TWC price - hooks must be called before any conditional returns
|
|
6465
6465
|
const [twcPrice, setTwcPrice] = useState(null);
|
|
6466
6466
|
const [priceLoading, setPriceLoading] = useState(false);
|
|
6467
|
+
// State for TP Points
|
|
6468
|
+
const [tpPoints, setTpPoints] = useState(null);
|
|
6469
|
+
const [tpLoading, setTpLoading] = useState(false);
|
|
6470
|
+
const [tpError, setTpError] = useState(null);
|
|
6467
6471
|
// Fetch TWC price when modal opens and twcBalance is available
|
|
6468
6472
|
useEffect(() => {
|
|
6469
6473
|
if (isOpen && twcBalance && twcBalance !== '0' && twcBalance !== '0.00') {
|
|
@@ -6480,6 +6484,32 @@ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAdd
|
|
|
6480
6484
|
});
|
|
6481
6485
|
}
|
|
6482
6486
|
}, [isOpen, twcBalance]);
|
|
6487
|
+
// Fetch TP Points when modal opens
|
|
6488
|
+
useEffect(() => {
|
|
6489
|
+
if (isOpen && account?.address) {
|
|
6490
|
+
setTpLoading(true);
|
|
6491
|
+
setTpError(null);
|
|
6492
|
+
fetch(`http://localhost:3090/api/v2/user/leaderboard/points/${account.address}`)
|
|
6493
|
+
.then(response => {
|
|
6494
|
+
if (!response.ok) {
|
|
6495
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
6496
|
+
}
|
|
6497
|
+
return response.json();
|
|
6498
|
+
})
|
|
6499
|
+
.then(responseData => {
|
|
6500
|
+
// Handle nested response structure: { success, statusCode, data: { points, ... } }
|
|
6501
|
+
const points = responseData.data?.points ?? responseData.points ?? responseData.data?.totalPoints ?? 0;
|
|
6502
|
+
setTpPoints(points);
|
|
6503
|
+
setTpLoading(false);
|
|
6504
|
+
})
|
|
6505
|
+
.catch(error => {
|
|
6506
|
+
console.error('Failed to fetch TP points:', error);
|
|
6507
|
+
setTpError('Failed to load');
|
|
6508
|
+
setTpPoints(0);
|
|
6509
|
+
setTpLoading(false);
|
|
6510
|
+
});
|
|
6511
|
+
}
|
|
6512
|
+
}, [isOpen, account?.address]);
|
|
6483
6513
|
// Early return AFTER hooks
|
|
6484
6514
|
if (!isOpen || !account)
|
|
6485
6515
|
return null;
|
|
@@ -6846,7 +6876,13 @@ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAdd
|
|
|
6846
6876
|
fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
6847
6877
|
fontSize: '12px',
|
|
6848
6878
|
letterSpacing: '-0.1px',
|
|
6849
|
-
}, children:
|
|
6879
|
+
}, children: tpLoading
|
|
6880
|
+
? 'Loading...'
|
|
6881
|
+
: tpError
|
|
6882
|
+
? tpError
|
|
6883
|
+
: tpPoints !== null
|
|
6884
|
+
? `${tpPoints.toLocaleString()} TP`
|
|
6885
|
+
: '0 TP' })] })] }) }), jsxs("div", { onClick: handleBuyTWC, style: {
|
|
6850
6886
|
background: 'rgb(29, 31, 35)',
|
|
6851
6887
|
border: '1px solid rgba(113, 122, 140, 0.08)',
|
|
6852
6888
|
borderRadius: '12px',
|
package/dist/index.js
CHANGED
|
@@ -6466,6 +6466,10 @@ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAdd
|
|
|
6466
6466
|
// State for TWC price - hooks must be called before any conditional returns
|
|
6467
6467
|
const [twcPrice, setTwcPrice] = React.useState(null);
|
|
6468
6468
|
const [priceLoading, setPriceLoading] = React.useState(false);
|
|
6469
|
+
// State for TP Points
|
|
6470
|
+
const [tpPoints, setTpPoints] = React.useState(null);
|
|
6471
|
+
const [tpLoading, setTpLoading] = React.useState(false);
|
|
6472
|
+
const [tpError, setTpError] = React.useState(null);
|
|
6469
6473
|
// Fetch TWC price when modal opens and twcBalance is available
|
|
6470
6474
|
React.useEffect(() => {
|
|
6471
6475
|
if (isOpen && twcBalance && twcBalance !== '0' && twcBalance !== '0.00') {
|
|
@@ -6482,6 +6486,32 @@ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAdd
|
|
|
6482
6486
|
});
|
|
6483
6487
|
}
|
|
6484
6488
|
}, [isOpen, twcBalance]);
|
|
6489
|
+
// Fetch TP Points when modal opens
|
|
6490
|
+
React.useEffect(() => {
|
|
6491
|
+
if (isOpen && account?.address) {
|
|
6492
|
+
setTpLoading(true);
|
|
6493
|
+
setTpError(null);
|
|
6494
|
+
fetch(`http://localhost:3090/api/v2/user/leaderboard/points/${account.address}`)
|
|
6495
|
+
.then(response => {
|
|
6496
|
+
if (!response.ok) {
|
|
6497
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
6498
|
+
}
|
|
6499
|
+
return response.json();
|
|
6500
|
+
})
|
|
6501
|
+
.then(responseData => {
|
|
6502
|
+
// Handle nested response structure: { success, statusCode, data: { points, ... } }
|
|
6503
|
+
const points = responseData.data?.points ?? responseData.points ?? responseData.data?.totalPoints ?? 0;
|
|
6504
|
+
setTpPoints(points);
|
|
6505
|
+
setTpLoading(false);
|
|
6506
|
+
})
|
|
6507
|
+
.catch(error => {
|
|
6508
|
+
console.error('Failed to fetch TP points:', error);
|
|
6509
|
+
setTpError('Failed to load');
|
|
6510
|
+
setTpPoints(0);
|
|
6511
|
+
setTpLoading(false);
|
|
6512
|
+
});
|
|
6513
|
+
}
|
|
6514
|
+
}, [isOpen, account?.address]);
|
|
6485
6515
|
// Early return AFTER hooks
|
|
6486
6516
|
if (!isOpen || !account)
|
|
6487
6517
|
return null;
|
|
@@ -6848,7 +6878,13 @@ const AccountDetailsModal = ({ isOpen, onClose, account, onDisconnect, onCopyAdd
|
|
|
6848
6878
|
fontFamily: 'Lexend, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
6849
6879
|
fontSize: '12px',
|
|
6850
6880
|
letterSpacing: '-0.1px',
|
|
6851
|
-
}, children:
|
|
6881
|
+
}, children: tpLoading
|
|
6882
|
+
? 'Loading...'
|
|
6883
|
+
: tpError
|
|
6884
|
+
? tpError
|
|
6885
|
+
: tpPoints !== null
|
|
6886
|
+
? `${tpPoints.toLocaleString()} TP`
|
|
6887
|
+
: '0 TP' })] })] }) }), jsxRuntime.jsxs("div", { onClick: handleBuyTWC, style: {
|
|
6852
6888
|
background: 'rgb(29, 31, 35)',
|
|
6853
6889
|
border: '1px solid rgba(113, 122, 140, 0.08)',
|
|
6854
6890
|
borderRadius: '12px',
|
package/package.json
CHANGED