Skip to content

Commit

Permalink
Handle USDC request links with query params (such as amount)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Aug 7, 2023
1 parent fe03afa commit bb0d1ee
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/modals/UsdcSendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,19 @@ export default defineComponent({
// For now only plain USDC/Polygon/ETH addresses are supported.
// TODO support Polygon-USDC request links and even consider removing scanning of plain addresses
// due to the risk of USDC being sent on the wrong chain.
uri = uri.replace(`${window.location.origin}/`, '')
.replace('polygon:', '');
const url = new URL(uri);
const { ethers } = await getPolygonClient();
if (ethers.utils.isAddress(uri)) {
if (ethers.utils.isAddress(url.pathname)) {
if (event) {
// Prevent paste event being applied to the recipient label field, that now became focussed.
event.preventDefault();
}
onAddressEntered(uri);
await onAddressEntered(url.pathname);
if (url.searchParams.has('amount')) {
amount.value = parseFloat(url.searchParams.get('amount')!) * 1e6;
}
}
}
Expand Down

0 comments on commit bb0d1ee

Please sign in to comment.