diff --git a/src/partials/finance/TransactionsTable.jsx b/src/partials/finance/TransactionsTable.jsx
index 8b8022f..3ca3d08 100644
--- a/src/partials/finance/TransactionsTable.jsx
+++ b/src/partials/finance/TransactionsTable.jsx
@@ -4,7 +4,7 @@ import TransactionItem from './TransactionsTableItem';
import Image01 from '../../images/transactions-image-01.svg';
import { observer } from 'mobx-react-lite';
-const TransactionsTable = observer(({ data, rowClick }) => {
+const TransactionsTable = observer(({ data, rowClick, lockedFor }) => {
return (
@@ -30,7 +30,9 @@ const TransactionsTable = observer(({ data, rowClick }) => {
- Sent Votes
+
+ {lockedFor === 'Voiting' ? 'Sent Votes' : 'Blocked votes'}
+
|
@@ -42,14 +44,25 @@ const TransactionsTable = observer(({ data, rowClick }) => {
key={delegate.address}
id={delegate.address}
image={Image01}
- balance={delegate.token.balance}
- name={delegate.dpos.delegate.username || delegate.address}
- total={delegate.dpos.delegate.totalVotesReceived}
- hasSevice={false}
+ balance={delegate?.token?.balance}
+ name={delegate.dpos?.delegate?.username || delegate.address}
+ total={delegate.dpos?.delegate?.totalVotesReceived || ''}
+ hasSevice={
+ delegate.dpos?.delegate?.username === 'delegate_0'
+ }
date={delegate.date}
+ displayReturn={lockedFor === 'Unlocking'}
status={delegate.status}
- amount={store.accountSentVotes[delegate.address] || 0}
- handleClick={() => rowClick(delegate)}
+ amount={
+ (lockedFor === 'Voiting'
+ ? store.accountSentVotes[delegate.address]
+ : store.accountLockedVotesCanReturnSum[
+ delegate.address
+ ]) || ''
+ }
+ handleClick={() =>
+ lockedFor === 'Voiting' && rowClick(delegate)
+ }
/>
);
})}
diff --git a/src/partials/finance/TransactionsTableItem.jsx b/src/partials/finance/TransactionsTableItem.jsx
index 50f0f15..8b3fa6f 100644
--- a/src/partials/finance/TransactionsTableItem.jsx
+++ b/src/partials/finance/TransactionsTableItem.jsx
@@ -43,14 +43,6 @@ const TransactionsTableItem = observer((props) => {
/>
{props.name}
- {store.accountLockedVotesCanReturn[props.id] && (
-
- Return votes
-
- )}
@@ -72,21 +64,36 @@ const TransactionsTableItem = observer((props) => {
{props.balance}/idn
|
- {props.total}/idn
+
+ {props.total}
+ {props.total && '/idn'}
+
|
-
- {props.status}
-
+ {props.displayReturn ? (
+ store.accountLockedVotesCanReturn[props.id] && (
+
+ Return votes
+
+ )
+ ) : (
+
+ {props.status}
+
+ )}
|
- {props.amount.toString()}/idn
+ {props.amount.toString()}
+ {props.amount && '/idn'}
|
diff --git a/src/shared/fetchWrapper.js b/src/shared/fetchWrapper.js
index e237abf..90eb93a 100644
--- a/src/shared/fetchWrapper.js
+++ b/src/shared/fetchWrapper.js
@@ -64,7 +64,12 @@ function request(method, url, headers = {}, token, body) {
requestOptions.headers.Authorization = null;
}
setTimeout(() => controller.abort(), 15000);
- return fetch(prepareUrl(url), requestOptions);
+ return fetch(prepareUrl(url), requestOptions).then((res) => {
+ if (res.status > 400) {
+ store.addNotification(new Date().getTime(), 'error', res.statusText);
+ }
+ return res;
+ });
}
function get(url, headers, attempts = 3) {
diff --git a/src/store/store.js b/src/store/store.js
index 5dc2462..2c838bc 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -13,7 +13,6 @@ import { statusMap } from '../shared/statusMap';
import { generateSvgAvatar } from '../images/GenerateOnboardingSvg/GenerateSvg';
import { decryptedData } from '../utils/decryptedData';
import {
- bytesToMbytes,
encryptAccountData,
encryptSharedData,
formatBytes,
@@ -55,6 +54,8 @@ class Store {
},
};
+ _notifications = [];
+
constructor() {
makeAutoObservable(this, {});
@@ -93,7 +94,7 @@ class Store {
.then((r) => this.fetchVPNServersSuccess(r));
}
- fetchDelegates(offset = 0, limit = 10) {
+ fetchDelegates(offset = 0, limit = 100) {
fetchWrapper
.getAuth(`delegates?limit=${limit}&offset=${offset}`)
.then((r) => this.fetchDelegatesSuccess(r));
@@ -253,10 +254,9 @@ class Store {
this.passPhrase
);
- const { amount, unvoteHeight } =
- this.accountLockedVotesCanReturn[delegateAddress];
+ const unlockObjects = this.accountLockedVotesCanReturn[delegateAddress];
- const signedTx = builder.unlock(delegateAddress, amount, unvoteHeight);
+ const signedTx = builder.unlock(delegateAddress, unlockObjects);
if (signedTx) {
fetchWrapper
@@ -507,15 +507,27 @@ class Store {
.reduce(
(acc, e) => ({
...acc,
- [e.delegateAddress]: {
- amount: BigInt(e.amount || 0) / 100000000n,
- unvoteHeight: e.unvoteHeight,
- },
+ [e.delegateAddress]: [
+ {
+ ...acc[e.delegateAddress],
+ amount: BigInt(e.amount || 0) / 100000000n,
+ unvoteHeight: e.unvoteHeight,
+ },
+ ],
}),
{}
);
}
+ get accountLockedVotesCanReturnSum() {
+ return Object.fromEntries(
+ Object.entries(this.accountLockedVotesCanReturn).map(([key, val]) => [
+ key,
+ val.reduce((sum, e) => sum + e.amount, 0n),
+ ])
+ );
+ }
+
get accountFeaturesMap() {
return this.accountFeatures.reduce(
(acc, item) => ({
@@ -644,7 +656,7 @@ class Store {
...delegate.dpos.delegate,
totalVotesReceived: Number(
BigInt(delegate.dpos.delegate.totalVotesReceived) / 100000000n
- ).toString(),
+ ),
},
},
}));
@@ -653,6 +665,22 @@ class Store {
get delegatesMeta() {
return this._delegates.meta;
}
+
+ get notifications() {
+ return this._notifications;
+ }
+
+ addNotification(id, type, message) {
+ this._notifications.push({
+ id,
+ type,
+ message,
+ });
+ }
+
+ removeNotification(id) {
+ this._notifications = this._notifications.filter((e) => e.id !== id);
+ }
}
export const store = new Store();
diff --git a/src/utils/Utils.js b/src/utils/Utils.js
index 3e35050..06e8565 100644
--- a/src/utils/Utils.js
+++ b/src/utils/Utils.js
@@ -197,7 +197,7 @@ export const generateTransaction = (
delegateAddress,
amount
),
- unlock: (delegateAddress, amount, unvoteHeight) =>
+ unlock: (delegateAddress, unlockObjects) =>
generateUnlockTransaction(
nonce,
senderPublicKey,
@@ -205,8 +205,7 @@ export const generateTransaction = (
passPhrase,
fee,
delegateAddress,
- amount,
- unvoteHeight
+ unlockObjects
),
};
};
@@ -379,8 +378,7 @@ const generateUnlockTransaction = (
passPhrase = '',
fee = BigInt(500000),
delegateAddress = '',
- amount = 0n,
- unvoteHeight = 0
+ unlockObjects = []
) => {
const tx = {
moduleID: 5,
@@ -389,13 +387,11 @@ const generateUnlockTransaction = (
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
fee,
asset: {
- unlockObjects: [
- {
- delegateAddress: Buffer.from(delegateAddress, 'hex'),
- amount: amount * 100000000n,
- unvoteHeight,
- },
- ],
+ unlockObjects: unlockObjects.map((e) => ({
+ delegateAddress: Buffer.from(delegateAddress, 'hex'),
+ amount: e.amount * 100000000n,
+ unvoteHeight: e.unvoteHeight,
+ })),
},
};