Skip to content

Commit

Permalink
fix: copy address tips not a same wallet (#2783)
Browse files Browse the repository at this point in the history
* fix: copy address tip not a same wallet

* chore: update app version

* fix: bulksender header

---------

Co-authored-by: sunnylqm <sunnylqm@onekey.so>
  • Loading branch information
originalix and sunnylqm committed Mar 31, 2023
1 parent 45223ac commit 413522f
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 10 deletions.
Expand Up @@ -73,7 +73,10 @@ const AccountSectionItem: FC<Props> = ({
(value) => {
switch (value) {
case 'copy':
copyAddress(item.displayAddress ?? item.address);
copyAddress({
address: item.address,
displayAddress: item.displayAddress,
});
break;
case 'rename':
DialogManager.show({
Expand Down
Expand Up @@ -124,7 +124,10 @@ function AccountItemSelectDropdown({
switch (value) {
case 'copy':
setTimeout(() => {
copyAddress(account.displayAddress || account.address);
copyAddress({
address: account.address,
displayAddress: account.displayAddress,
});
}, 150);
break;
case 'rename':
Expand Down
17 changes: 14 additions & 3 deletions packages/kit/src/hooks/useCopyAddress.ts
Expand Up @@ -30,14 +30,25 @@ export function useCopyAddress({
const navigation = useNavigation();

const copyAddress = useCallback(
(address?: string, template?: string, customPath?: string) => {
({
address,
displayAddress,
template,
customPath,
}: {
address?: string;
displayAddress?: string;
template?: string;
customPath?: string;
}) => {
if (isHwWallet) {
navigation.navigate(RootRoutes.Modal, {
screen: ModalRoutes.Receive,
params: {
screen: ReceiveTokenModalRoutes.ReceiveToken,
params: {
address,
displayAddress,
wallet,
network,
account,
Expand All @@ -47,8 +58,8 @@ export function useCopyAddress({
},
});
} else {
if (!address) return;
copyToClipboard(address);
if (!displayAddress && !address) return;
copyToClipboard(displayAddress ?? address ?? '');
ToastManager.show({
title: intl.formatMessage({ id: 'msg__address_copied' }),
});
Expand Down
Expand Up @@ -171,7 +171,7 @@ const BitcoinUsedAddress: FC = () => {

const onCopyAddress = useCallback(
({ address, path }: { address: string; path: string }) => {
copyAddress(address, account?.template, path);
copyAddress({ address, template: account?.template, customPath: path });
},
[copyAddress, account?.template],
);
Expand Down
5 changes: 4 additions & 1 deletion packages/kit/src/views/Overlay/AccountMoreMenu.tsx
Expand Up @@ -227,7 +227,10 @@ const AccountMoreMenu: FC<IMenu> = (props) => {
id: 'action__copy_address',
onPress: () => {
setTimeout(() => {
copyAddress(account?.address);
copyAddress({
address: account?.address,
displayAddress: account?.displayAddress,
});
});
},
icon: 'Square2StackMini',
Expand Down
8 changes: 6 additions & 2 deletions packages/kit/src/views/ReceiveToken/index.tsx
Expand Up @@ -42,7 +42,7 @@ const ReceiveToken = () => {

const route = useRoute<NavigationProps>();

const { address, name } = route.params ?? {};
const { address, displayAddress, name } = route.params ?? {};
const routePrams = route.params;

const isVerticalLayout = useIsVerticalLayout();
Expand All @@ -59,7 +59,11 @@ const ReceiveToken = () => {
const walletId = wallet?.id || '';

const shownAddress =
address ?? account?.displayAddress ?? account?.address ?? '';
displayAddress ??
address ??
account?.displayAddress ??
account?.address ??
'';
const shownName = name ?? account?.name ?? '';

const { engine } = backgroundApiProxy;
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/views/ReceiveToken/types.ts
Expand Up @@ -9,6 +9,7 @@ export { ReceiveTokenModalRoutes };
export type ReceiveTokenRoutesParams = {
[ReceiveTokenModalRoutes.ReceiveToken]: {
address?: string;
displayAddress?: string;
name?: string;

wallet?: Wallet | null;
Expand Down
5 changes: 4 additions & 1 deletion packages/kit/src/views/Wallet/AccountInfo/index.tsx
Expand Up @@ -122,7 +122,10 @@ const AccountAmountInfo: FC = () => {
_hover={{ bg: 'surface-hovered' }}
_pressed={{ bg: 'surface-pressed' }}
onPress={() => {
copyAddress(account?.displayAddress ?? account?.address);
copyAddress({
address: account?.address,
displayAddress: account?.displayAddress,
});
}}
>
<Text
Expand Down

0 comments on commit 413522f

Please sign in to comment.