Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transferable balance #10842

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/apps/public/locales/ar/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@
"total staked": "إجمالي المرهون",
"transactions": "معاملات",
"transfer received": "تم استلام التحويل",
"transferrable": "قابل للتحويل",
"transferable": "قابل للتحويل",
"trusted social recovery helpers": "مساعدو الإسترجاع الاجتماعي الموثوق بهم",
"turnout": "معدل المشاركة في الإنتخابات",
"twitter": "تويتر",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/bn/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@
"transactions": "লেনদেনসমূহ",
"transfer received": "প্রাপ্ত হস্তান্তর",
"transfer remark/comment": "হস্তান্তর উক্তি/মন্তব্য",
"transferrable": "হস্তান্তরযোগ্য",
"transferable": "হস্তান্তরযোগ্য",
"trusted social recovery helpers": "বিশ্বস্ত সামাজিক পুনরুদ্ধার সহায়কবৃন্দ",
"turnout": "ভোটার",
"twitter": "টুইটার",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
"total balance": "total balance",
"total deposit": "total deposit",
"total locked": "total locked",
"total transferrable": "total transferrable",
"total transferable": "total transferable",
"trusted social recovery helpers": "trusted social recovery helpers",
"twitter": "twitter",
"unbonding": "unbonding",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"read": "read",
"read contract only, no execution": "read contract only, no execution",
"status": "status",
"transferrable": "transferrable",
"transferable": "transferable",
"unique deployment salt": "unique deployment salt",
"use deployment salt": "use deployment salt",
"use estimated gas": "use estimated gas",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-democracy.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"send from account": "send from account",
"threshold": "threshold",
"total": "total",
"transferrable": "transferrable",
"transferable": "transferable",
"turnout": "turnout",
"votes": "votes",
"voting period": "voting period",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"files": "files",
"password": "password",
"status": "status",
"transferrable": "transferrable",
"transferable": "transferable",
"⚡️ Thunder Gateway": "⚡️ Thunder Gateway"
}
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-gilt.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"send via proxy": "send via proxy",
"submit gilt bid": "submit gilt bid",
"target": "target",
"transferrable": "transferrable",
"transferable": "transferable",
"use proxied account": "use proxied account",
"yes": "yes"
}
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-nis.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"queues": "queues",
"send via proxy": "send via proxy",
"submit nis bid": "submit nis bid",
"transferrable": "transferrable",
"transferable": "transferable",
"use proxied account": "use proxied account"
}
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-parachains.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"timeout": "timeout",
"total": "total",
"total raised / cap": "total raised / cap",
"transferrable": "transferrable",
"transferable": "transferable",
"validation code": "validation code",
"validator {{index}}": "validator {{index}}",
"value": "value",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-preimages.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"propose": "propose",
"send from account": "send from account",
"status": "status",
"transferrable": "transferrable"
"transferable": "transferable"
}
2 changes: 1 addition & 1 deletion packages/apps/public/locales/en/app-referenda.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"total": "total",
"total issuance": "total issuance",
"track origin": "track origin",
"transferrable": "transferrable",
"transferable": "transferable",
"vote": "vote",
"votes": "votes",
"{{blocks}} blocks": "{{blocks}} blocks",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/public/locales/en/react-components.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
"threshold": "threshold",
"total": "total",
"transactions": "transactions",
"transferrable": "transferrable",
"transferrable minus fees": "transferrable minus fees",
"transferable": "transferable",
"transferable minus fees": "transferable minus fees",
"twitter": "twitter",
"type": "type",
"unbonding": "unbonding",
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1754,13 +1754,13 @@
"total stake": "",
"total staked": "",
"total sub": "",
"total transferrable": "",
"total transferable": "",
"track origin": "",
"transactions": "",
"transfer asset": "",
"transfer received": "",
"transferrable": "",
"transferrable minus fees": "",
"transferable": "",
"transferable minus fees": "",
"transfers": "",
"trusted social recovery helpers": "",
"turnout": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@
"total staked": "staked total",
"transactions": "transacciones",
"transfer received": "transferencia recibida",
"transferrable": "transferible",
"transferable": "transferible",
"trusted social recovery helpers": "asistentes de confianza para la recuperación social",
"turnout": "participación",
"twitter": "twitter",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1433,8 +1433,8 @@
"transactions": "transactions",
"transfer received": "transfert reçu",
"transfer remark/comment": "transférer une remarque/commentaire",
"transferrable": "transferrable",
"transferrable minus fees": "transferable moins les frais",
"transferable": "transferable",
"transferable minus fees": "transferable moins les frais",
"trusted social recovery helpers": "assistants sociaux de confiance",
"turnout": "participation",
"twitter": "twitter",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@
"total staked": "कुल दांव",
"transactions": "लेनदेन",
"transfer received": "स्थानांतरण प्राप्त हुआ",
"transferrable": "हस्तांतरणीय",
"transferable": "हस्तांतरणीय",
"trusted social recovery helpers": "विश्वसनीय सामाजिक पुनर्प्राप्ति सहायक",
"turnout": "भागीदारी",
"twitter": "ट्विटर",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/public/locales/id/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,8 @@
"transactions": "transaksi",
"transfer received": "transfer diterima",
"transfer remark/comment": "transfer ucapan/komentar",
"transferrable": "yang dapat ditransfer",
"transferrable minus fees": "biaya dikurangi yang dapat dialihkan",
"transferable": "yang dapat ditransfer",
"transferable minus fees": "biaya dikurangi yang dapat dialihkan",
"trusted social recovery helpers": "pemulihan sosial helper terpercaya",
"turnout": "beralih",
"twitter": "twitter",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/public/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2017,8 +2017,8 @@
"transfer asset": "trasferimento asset",
"transfer received": "trasferimento ricevuto",
"transfer remark/comment": "commento/nota sul trasferimento",
"transferrable": "trasferibili",
"transferrable minus fees": "transferibile al netto delle commissioni",
"transferable": "trasferibili",
"transferable minus fees": "transferibile al netto delle commissioni",
"transfers": "trasferimenti",
"trusted social recovery helpers": "garanti di fiducia per recupero account",
"turnout": "partecipanti",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@
"threshold": "出発点",
"transactions": "トランザクション",
"transfer received": "受信",
"transferrable": "送信可能な",
"transferable": "送信可能な",
"trusted social recovery helpers": "信頼できるソーシャルリカバリーヘルパー",
"twitter": "twitter",
"type": "タイプ",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/public/locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1389,8 +1389,8 @@
"transactions": "거래 목록",
"transfer received": "트랜스퍼를 받았습니다",
"transfer remark/comment": "이체할 발언/ 논평",
"transferrable": "이체 가능",
"transferrable minus fees": "수수료를 제외하고 이체 가능",
"transferable": "이체 가능",
"transferable minus fees": "수수료를 제외하고 이체 가능",
"trusted social recovery helpers": "신뢰할 수 있는 \"계정 복구 도우미\" 목록",
"turnout": "투표자 수",
"twitter": "트워터",
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/public/locales/pl/add-accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@
"threshold": "próg / limit",
"total deposit": "ogólny depozyt",
"transactions": "tranzakcje",
"transferrable": "możliwy do przeslania",
"transferrable minus fees": "możliwy do przesłania po odjęciu opłat",
"transferable": "możliwy do przeslania",
"transferable minus fees": "możliwy do przesłania po odjęciu opłat",
"trusted social recovery helpers": "zaufani pomocnicy w naprawie społecznej",
"twitter": "twitter",
"type": "typ",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@
"total staked": "total em participação",
"transactions": "transações",
"transfer received": "transferência recebida",
"transferrable": "transferível",
"transferable": "transferível",
"trusted social recovery helpers": "auxiliares confiáveis de recuperação social",
"turnout": "vire para fora",
"twitter": "Twitter",
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1384,12 +1384,12 @@
"total peers": "всего соединений с другими нодами",
"total stake": "всего стейк",
"total staked": "всего застейкано",
"total transferrable": "всего доступно для перевода",
"total transferable": "всего доступно для перевода",
"transactions": "транзакции",
"transfer asset": "отправить средства",
"transfer received": "трансферов получено",
"transferrable": "передаваемые",
"transferrable minus fees": "доступное для перевода без комиссии",
"transferable": "передаваемые",
"transferable minus fees": "доступное для перевода без комиссии",
"trusted social recovery helpers": "доверяемые помощники для социального восстановления",
"turnout": "оказаться",
"twitter": "twitter",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/ur/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@
"transactions": "ٹرانزیکشنز",
"transfer received": "منتقلی موصول ہوئی",
"transfer remark/comment": "منتقلی پر کمینٹ/ریمارک دیں",
"transferrable": "قابل منتقلی",
"transferable": "قابل منتقلی",
"trusted social recovery helpers": "قابل اعتماد سوشل ریکوری ہیلپرز",
"turnout": "ٹرن آؤٹ",
"twitter": "ٹویٹر",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@
"transactions": "交易",
"transfer received": "转账接收成功",
"transfer remark/comment": "转账备注/评论",
"transferrable": "可转账的",
"transferable": "可转账的",
"trusted social recovery helpers": "信任的社交恢复帮手",
"turnout": "结果",
"twitter": "Twitter",
Expand Down
2 changes: 1 addition & 1 deletion packages/page-accounts/src/Accounts/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
locked: balancesAll.lockedBalance,
redeemable: stakingInfo?.redeemable || BN_ZERO,
total: balancesAll.freeBalance.add(balancesAll.reservedBalance),
transferrable: balancesAll.availableBalance,
transferable: balancesAll.transferable || balancesAll.availableBalance,
unbonding: calcUnbonding(stakingInfo)
});

Expand Down
4 changes: 2 additions & 2 deletions packages/page-accounts/src/Accounts/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function Summary ({ balance, className }: Props) {
</CardSummary>
<CardSummary
className='media--900'
label={t('total transferrable')}
label={t('total transferable')}
>
<FormatBalance
className={balance ? '' : '--tmp'}
value={balance?.transferrable || 1}
value={balance?.transferable || 1}
/>
</CardSummary>
<CardSummary label={t('total locked')}>
Expand Down
6 changes: 3 additions & 3 deletions packages/page-accounts/src/Accounts/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ describe.skip('Accounts page', () => {
const rows = await accountsPage.getAccountRows();

await rows[0].assertBalancesDetails([
{ amount: balance(0), name: 'transferrable' },
{ amount: balance(0), name: 'transferable' },
{ amount: balance(30), name: 'locked' }]);
await rows[1].assertBalancesDetails([
{ amount: balance(50), name: 'transferrable' },
{ amount: balance(50), name: 'transferable' },
{ amount: balance(150), name: 'reserved' }]);
});

Expand Down Expand Up @@ -211,7 +211,7 @@ describe.skip('Accounts page', () => {
anAccountWithBalance({ availableBalance: balance(600) })
);

const summary = await screen.findByTestId(/card-summary:(total )?transferrable/i);
const summary = await screen.findByTestId(/card-summary:(total )?transferable/i);

expect(summary).toHaveTextContent(showBalance(400 + 600));
});
Expand Down
2 changes: 1 addition & 1 deletion packages/page-accounts/src/Accounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
locked: aggregate('locked'),
redeemable: aggregate('redeemable'),
total: aggregate('total'),
transferrable: aggregate('transferrable'),
transferable: aggregate('transferable'),
unbonding: aggregate('unbonding')
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/page-accounts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface SortedAccount {
export interface AccountBalance {
total: BN;
locked: BN;
transferrable: BN;
transferable: BN;
bonded: BN;
redeemable: BN;
unbonding: BN;
Expand Down
4 changes: 2 additions & 2 deletions packages/page-addresses/src/Contacts/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ describe.skip('Addresses page', () => {
const rows = await addressesPage.getAddressesRows();

await rows[0].assertBalancesDetails([
{ amount: balance(0), name: 'transferrable' },
{ amount: balance(0), name: 'transferable' },
{ amount: balance(30), name: 'locked' }]);
await rows[1].assertBalancesDetails([
{ amount: balance(50), name: 'transferrable' },
{ amount: balance(50), name: 'transferable' },
{ amount: balance(150), name: 'reserved' }]);
});

Expand Down
3 changes: 2 additions & 1 deletion packages/page-bounties/src/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';

function useBalanceImpl (accountId: string | null): Balance | undefined {
const { api } = useApi();
const balancesAll = useCall<DeriveBalancesAll>(api.derive.balances?.all, [accountId]);

return useCall<DeriveBalancesAll>(api.derive.balances?.all, [accountId])?.availableBalance;
return balancesAll?.transferable || balancesAll?.availableBalance;
}

export const useBalance = createNamedHook('useBalance', useBalanceImpl);
2 changes: 1 addition & 1 deletion packages/page-contracts/src/Codes/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function Upload ({ onClose }: Props): React.ReactElement {
label={t('deployment account')}
labelExtra={
<Available
label={t('transferrable')}
label={t('transferable')}
params={accountId}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/page-contracts/src/Contracts/Call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function Call ({ className = '', contract, messageIndex, onCallResult, onChangeM
label={t('call from account')}
labelExtra={
<Available
label={t('transferrable')}
label={t('transferable')}
params={accountId}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/page-contracts/src/Contracts/Deploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex
label={t('deployment account')}
labelExtra={
<Available
label={t('transferrable')}
label={t('transferable')}
params={accountId}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/page-democracy/src/Overview/PreImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function PreImage ({ className = '', imageHash, isImminent = false, onClose }: P
label={t('send from account')}
labelExtra={
<Available
label={<span className='label'>{t('transferrable')}</span>}
label={<span className='label'>{t('transferable')}</span>}
params={accountId}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/page-democracy/src/Overview/Propose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function Propose ({ className = '', onClose }: Props): React.ReactElement<Props>
label={t('send from account')}
labelExtra={
<Available
label={<span className='label'>{t('transferrable')}</span>}
label={<span className='label'>{t('transferable')}</span>}
params={accountId}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/page-files/src/UploadModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function UploadModal ({ className, file, onClose = NOOP, onSuccess = NOOP }: Pro
label={t('Please choose account')}
labelExtra={
<Available
label={t('transferrable')}
label={t('transferable')}
params={account}
/>
}
Expand Down
Loading
Loading