Skip to content

Commit bb0d1ee

Browse files
committed
Handle USDC request links with query params (such as amount)
1 parent fe03afa commit bb0d1ee

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/modals/UsdcSendModal.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,19 @@ export default defineComponent({
495495
// For now only plain USDC/Polygon/ETH addresses are supported.
496496
// TODO support Polygon-USDC request links and even consider removing scanning of plain addresses
497497
// due to the risk of USDC being sent on the wrong chain.
498-
uri = uri.replace(`${window.location.origin}/`, '')
499-
.replace('polygon:', '');
498+
const url = new URL(uri);
500499
const { ethers } = await getPolygonClient();
501-
if (ethers.utils.isAddress(uri)) {
500+
if (ethers.utils.isAddress(url.pathname)) {
502501
if (event) {
503502
// Prevent paste event being applied to the recipient label field, that now became focussed.
504503
event.preventDefault();
505504
}
506505
507-
onAddressEntered(uri);
506+
await onAddressEntered(url.pathname);
507+
508+
if (url.searchParams.has('amount')) {
509+
amount.value = parseFloat(url.searchParams.get('amount')!) * 1e6;
510+
}
508511
}
509512
}
510513

0 commit comments

Comments
 (0)