-
Notifications
You must be signed in to change notification settings - Fork 103
Single address mode settings and receiving page #4462
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
base: develop
Are you sure you want to change the base?
Conversation
…oggle Create single address toggle
| const firstAddress = stores.wallets.selectedOrFail.allAddresses.utxoAddresses.find( | ||
| a => a.address.Type === CoreAddressTypes.CARDANO_BASE | ||
| ); | ||
| const walletAddress = addressHexToBech32(firstAddress.address.Hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Potential null access on address lookup result
The find() call for CARDANO_BASE address returns undefined if no matching address exists, but the result is used without a null check on line 13 (firstAddress.address.Hash) and line 25 (firstAddress.IsUsed). This can cause a runtime crash if a wallet somehow has no base addresses.
| }); | ||
|
|
||
| export const useReceive = () => | ||
| React.useContext(ReceiveContext) ?? console.log('useReceive: needs to be wrapped in a Receive ContextProvider'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Hook returns undefined instead of throwing error
The useReceive hook uses the nullish coalescing operator with console.log() as the fallback. Since console.log returns undefined, when the context is not available, the hook returns undefined instead of throwing an error or providing a useful fallback. This can cause silent failures and confusing runtime errors for consumers who expect a valid context object.
| +onCopyAddressTooltip: string => void, | ||
| |}; | ||
|
|
||
| export default class SingleAddress extends Component<Props> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yushih This single Address mode page should be added in new UI feature folder if I'm not mistaken and not in the old UI as its new
| export default class SingleAddress extends Component<Props> { | ||
| static contextType: any = IntlContext; | ||
|
|
||
| render(): Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And refactored to a functional component as well in the new UI
| import { addressHexToBech32 } from '../../api/ada/lib/cardanoCrypto/utils'; | ||
| import { CoreAddressTypes } from '../../api/ada/lib/storage/database/primitives/enums'; | ||
|
|
||
| export default class SingleAddressReceivePage extends Component<StoresProps> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - the new page should be added in the new UI - pages for wallet - receive, if we don't have it we should create a new page for this and refactored to a functional component
| async updateSelectedWalletSingleAddressMode(mode: boolean): Promise<void> { | ||
| runInAction(() => { | ||
| this.singleAddressMode[String(this.selectedOrFail.publicDeriverId)] = mode; | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use the Receive Context Provider to add this logic as we will gradually try to reduce the use of the mobX stores in the future as much as we can - or we can create a hook for this in receive feature (new UI)
Note
Introduces a per-wallet Single Address Mode with a settings toggle, persistent local storage, and a new receive page that displays a single address with QR and copy actions; updates routing and context accordingly.
WalletSettingsPageviaEnableSingleAddressSettings.SingleAddressReceivePageand UI componentcomponents/wallet/receive/SingleAddress(QR, explorer link, copy).ReceiveContextProviderand conditionally route incontainers/wallet/Receiveto single-address page when enabled.api/localStorage:SINGLE_ADDRESS_MODE, getters/setters,SingleAddressModetype).WalletStore(singleAddressModeobservable,isSelectedWalletSingleAddressgetter, updater action).en-US.jsonanduseStringshook.ReceiveContextProvider(selected wallet in context) and placeholder use-cases (SingleAddressMode.tsx,MultiAddressMode.tsx).Written by Cursor Bugbot for commit 371db0c. This will update automatically on new commits. Configure here.