Skip to content

Commit bb8d761

Browse files
chore: 🤖 resolve review-comments
1 parent 91c4f76 commit bb8d761

7 files changed

Lines changed: 62 additions & 22 deletions

File tree

‎.github/workflows/auth-ff-merge.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
issues: write
2020
steps:
2121
- name: Polymesh Action - Auth and Fast-Forward
22-
uses: PolymeshAssociation/polymesh-action-public@v2.0.1
22+
uses: PolymeshAssociation/polymesh-action-public@v2.0.2
2323
with:
2424
allowed-signers: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
2525
github-token: ${{ secrets.GITHUB_TOKEN }}

‎src/layouts/Portfolio/components/NftAssetTable/components/TickerCell/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const TickerCell: React.FC<ITickerCellProps> = ({ info }) => {
2424
)}
2525
</StyledImageWrap>
2626
{name}
27-
{ticker ? ` (${ticker})` : '-'}
27+
{ticker ? ` (${ticker})` : ''}
2828
</StyledCell>
2929
);
3030
};

‎src/layouts/Portfolio/components/NftView/components/NftAsset/hooks.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const useNftAsset = () => {
4444
buildBalanceSearchParams({
4545
holder: selectedHolder,
4646
portfolioId: selectedPortfolioId,
47+
accountAddress: selectedAccountAddress,
4748
additionalParams: {
4849
nftCollection,
4950
},
@@ -86,6 +87,7 @@ export const useNftAsset = () => {
8687
buildBalanceSearchParams({
8788
holder: selectedHolder,
8889
portfolioId: selectedPortfolioId,
90+
accountAddress: selectedAccountAddress,
8991
}),
9092
);
9193
} finally {

‎src/layouts/Portfolio/components/NftView/components/NftAsset/index.tsx‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@ export const NftAsset = () => {
4444
const did = nft.ownerDid;
4545
const portfolioId = nft.ownerPortfolioId;
4646

47-
try {
48-
(async () => {
47+
(async () => {
48+
try {
4949
const name = await polkadotApi.query.portfolio.portfolios(
5050
did,
5151
portfolioId,
5252
);
5353
if (name.isNone) {
5454
setPortfolioName('');
55+
return;
5556
}
5657
setPortfolioName(`${portfolioId} / ${bytesToString(name.unwrap())}`);
57-
})();
58-
} catch (error) {
59-
setPortfolioName('');
60-
}
58+
} catch {
59+
setPortfolioName('');
60+
}
61+
})();
6162
}, [nftLoading, nft?.ownerPortfolioId, nft?.ownerDid, polkadotApi]);
6263

6364
if (nftLoading) {

‎src/layouts/Staking/components/StakingAccountInfo/components/ModalForm/hooks.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export const useModalForm = (modalType: EModalOptions | null, max?: number) => {
1717
api: { sdk },
1818
} = useContext(PolymeshContext);
1919

20+
const sdkRef = useRef(sdk);
21+
sdkRef.current = sdk;
22+
23+
const maxRef = useRef(max);
24+
maxRef.current = max;
25+
2026
// Lazily build and cache the form config on the first render only.
2127
const formConfigRef = useRef<{
2228
mode: keyof ValidationMode;
@@ -26,9 +32,10 @@ export const useModalForm = (modalType: EModalOptions | null, max?: number) => {
2632

2733
if (formConfigRef.current === null && modalType) {
2834
const isValidAddress = (address: string) => {
29-
if (!sdk) return false;
35+
const currentSdk = sdkRef.current;
36+
if (!currentSdk) return false;
3037
try {
31-
return sdk.accountManagement.isValidAddress({ address });
38+
return currentSdk.accountManagement.isValidAddress({ address });
3239
} catch {
3340
return false;
3441
}
@@ -45,7 +52,10 @@ export const useModalForm = (modalType: EModalOptions | null, max?: number) => {
4552
(value) =>
4653
value ? /^-?\d+(\.\d{1,6})?$/.test(value.toString()) : true,
4754
)
48-
.max(Number(max), 'Insufficient balance')
55+
.test('max-balance', 'Insufficient balance', (value) => {
56+
if (value == null || maxRef.current == null) return true;
57+
return value <= maxRef.current;
58+
})
4959
.test('is-zero', 'Amount must be greater than 0', (value) => value !== 0);
5060

5161
const specifiedAccountValidation = yup

‎src/layouts/Transfers/components/TransferItem/components/InstructionLeg/index.tsx‎

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,35 @@ export const InstructionLeg: React.FC<ILegProps> = ({
7575

7676
const isSmallScreen = isMobile || isTablet;
7777

78+
const isSelectedSendingParticipant =
79+
legDetails?.sendingDid === identity?.did ||
80+
legDetails?.sendingAddress === selectedAccount;
81+
82+
const isSelectedReceivingParticipant =
83+
legDetails?.receivingDid === identity?.did ||
84+
legDetails?.receivingAddress === selectedAccount;
85+
86+
const getSendingParticipantLabel = () => {
87+
if (!legDetails) return '';
88+
if (isSelectedSendingParticipant) return 'Selected participant';
89+
if (legDetails.sendingDid) return formatDid(legDetails.sendingDid);
90+
if (legDetails.sendingAddress) {
91+
return (
92+
allAccountsWithMeta.find((a) => a.address === legDetails.sendingAddress)
93+
?.meta.name ?? formatDid(legDetails.sendingAddress)
94+
);
95+
}
96+
return 'No identity';
97+
};
98+
99+
const getReceivingParticipantLabel = () => {
100+
if (!legDetails) return '';
101+
if (isSelectedReceivingParticipant) return 'Selected participant';
102+
return formatDid(
103+
legDetails.receivingDid || legDetails.receivingAddress || '',
104+
);
105+
};
106+
78107
const toggleModal = () => {
79108
setAssetDetailsModalOpen(false);
80109
};
@@ -196,9 +225,7 @@ export const InstructionLeg: React.FC<ILegProps> = ({
196225
)}
197226
>
198227
<Text size="large" bold>
199-
{legDetails.sendingDid === identity?.did
200-
? 'Selected participant'
201-
: formatDid(legDetails.sendingDid)}
228+
{getSendingParticipantLabel()}
202229
</Text>
203230
<CopyToClipboard
204231
value={legDetails.sendingDid || legDetails.sendingAddress || ''}
@@ -231,11 +258,7 @@ export const InstructionLeg: React.FC<ILegProps> = ({
231258
)}
232259
>
233260
<Text size="large" bold>
234-
{legDetails.receivingDid === identity?.did
235-
? 'Selected participant'
236-
: formatDid(
237-
legDetails.receivingDid || legDetails.receivingAddress,
238-
)}
261+
{getReceivingParticipantLabel()}
239262
</Text>
240263
<CopyToClipboard
241264
value={

‎src/layouts/Transfers/components/TransfersHeader/components/SendAsset/components/BasicForm/index.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@ export const BasicForm: React.FC<IBasicFormProps> = ({ toggleModal }) => {
5050
api: { sdk },
5151
} = useContext(PolymeshContext);
5252

53+
const sdkRef = useRef(sdk);
54+
sdkRef.current = sdk;
55+
5356
const formConfigRef = useRef<ReturnType<typeof createBasicFormConfig> | null>(
5457
null,
5558
);
5659
if (formConfigRef.current === null) {
5760
formConfigRef.current = createBasicFormConfig((address) => {
58-
if (!sdk) return false;
61+
const currentSdk = sdkRef.current;
62+
if (!currentSdk) return false;
5963
try {
60-
return sdk.accountManagement.isValidAddress({ address });
64+
return currentSdk.accountManagement.isValidAddress({ address });
6165
} catch {
6266
return false;
6367
}
@@ -328,7 +332,7 @@ export const BasicForm: React.FC<IBasicFormProps> = ({ toggleModal }) => {
328332
...allPortfolios.map(({ id, name }) =>
329333
id === 'default' ? 'Default Portfolio' : `${id} / ${name}`,
330334
),
331-
...(hasAccountAssets ? ['Selected Account'] : []),
335+
...(hasAccountAssets ? ['Account'] : []),
332336
]}
333337
error={undefined}
334338
enableSearch

0 commit comments

Comments
 (0)