Skip to content

Commit

Permalink
wallet-ext: make sure address starts with 0x
Browse files Browse the repository at this point in the history
  • Loading branch information
pchrysochoidis committed Jul 15, 2022
1 parent ec92798 commit 352e262
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 5 additions & 1 deletion wallet/src/ui/app/KeypairVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export default class KeypairVault {
}

public getAccount(): string | null {
return this._keypair?.getPublicKey().toSuiAddress() || null;
let address = this._keypair?.getPublicKey().toSuiAddress() || null;
if (address && !address.startsWith('0x')) {
address = `0x${address}`;
}
return address;
}

public getKeyPair() {
Expand Down
4 changes: 1 addition & 3 deletions wallet/src/ui/app/components/account-address/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ type AccountAddressProps = {
};

function AccountAddress({ className, showLink = true }: AccountAddressProps) {
const address = useAppSelector(
({ account: { address } }) => address && `0x${address}`
);
const address = useAppSelector(({ account: { address } }) => address);
const shortenAddress = useMiddleEllipsis(address || '', 20);
return address ? (
<span className={cl(st.addressContainer, className)}>
Expand Down
4 changes: 1 addition & 3 deletions wallet/src/ui/app/pages/home/transfer-nft/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ function TransferNFTPage() {
() => searchParams.get('objectId'),
[searchParams]
);
const address = useAppSelector(
({ account: { address } }) => address && `0x${address}`
);
const address = useAppSelector(({ account: { address } }) => address);

let selectedNFT;
const nftCollections = useAppSelector(accountNftsSelector);
Expand Down
2 changes: 1 addition & 1 deletion wallet/src/ui/app/pages/site-connect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function SiteConnectPage() {
dispatch(
respondToPermissionRequest({
id: requestID,
accounts: allowed ? [`0x${activeAccount}`] : [],
accounts: allowed ? [activeAccount] : [],
allowed,
})
);
Expand Down

0 comments on commit 352e262

Please sign in to comment.