fix(deeplink): recognize address-less algorand:// asset opt-in QRs [PERA-4744] - #1107
Conversation
Should-fixA present-but-corrupt address is now discarded instead of rejected — A truncated or misread QR used to return if (address && !isValidAlgorandAddress(address)) {
return null
}
if (amount === '0' && assetId) {
return {
type: DeeplinkType.ASSET_OPT_IN,
sourceUrl: url,
assetId,
address: address || undefined,
} as AssetOptInDeeplink
}That preserves everything the PR is after ( The comment is doing more work than the code needs — // Address-less by design: an opt-in has no receiver, so this must resolve
// before the address guard below.Same for the 4-line comment on the first new test — the test name already says it. Nits
Questions / awareness
|
|
Addressed the corrupt-vs-address-less case as suggested: a present-but-invalid address now returns null (unrecognized) while a genuinely address-less link still opts in, with a test covering both a truncated and a non-address string. Trimmed the comment/removed hasValidAddress too, and filed PERA-4753 for the non-numeric asset= validation. |
Pull Request Template
Description
Scanning an asset opt-in QR of the form
algorand://?amount=0&asset=<id>did nothing on iOS + Android — the scanner didn't recognize it (functional on native Pera 6). This is the format Pera's opt-in QR generator emits (confirmed by decoding the reported QR:algorand://?amount=0&asset=1152109334).An opt-in is a self opt-in, so the QR has no receiver address — the authority is empty.
parseAlgorandUriran its!address || !isValidAlgorandAddress(address)guard before the opt-in branch, so the ARC-90 path returned null for every address-less opt-in andparseDeeplinkreported it as unrecognized. Theperawallet://old-parser already accepts the address-less form, and downstreamuseAssetOptInDeeplinkalready prompts the user to pick an account when the link carries none — only thealgorand://path was out of parity.Moved the opt-in resolution ahead of the address guard:
amount === '0'+ an asset now returnsASSET_OPT_INwith the address only when one is present and valid, otherwiseundefined(handler prompts for the account). The change is tightly scoped — every transfer path still requires a valid receiver, soalgorand://?amount=100and other address-less transfers stay null, andalgorand://<addr>?amount=0&asset=<id>keeps its address.Added parser tests: the real reported QR →
ASSET_OPT_INwith no address; an opt-in that carries an address keeps it; and an address-less non-opt-in transfer still returns null.Related Issues
Closes https://algorandfoundation.atlassian.net/browse/PERA-4744
Checklist
Additional Notes