Skip to content

Commit

Permalink
Support scanning raw EVM addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 3, 2023
1 parent 2686f77 commit 401a9f4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/modals/ScanQrModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export default defineComponent({
const { hasBitcoinAddresses, hasUsdcAddresses } = useAccountStore();
const checkResult = (result: string) => {
console.debug('Scanned QR code:', result); // eslint-disable-line no-console
// Cashlink
if (/https:\/\/hub\.nimiq(-testnet)?\.com\/cashlink\//.test(result)) {
// result is a cashlink so redirect to hub
Expand Down Expand Up @@ -138,8 +140,20 @@ export default defineComponent({
if (config.usdc.enabled && hasUsdcAddresses.value) {
// Run in parallel, without awaiting.
loadEthersLibrary().then((ethers) => {
// For USDC we don't support scanning plain addresses to avoid the risk of sending Polygon USDC to
// an Ethereum wallet, because the addresses are the same.
// Support scanning plain addresses. The send modal shows a warning for unknown addresses
// that users must make sure this is a Polygon USDC address.
if (result.startsWith('0x')) {
const address = ethers.utils.getAddress(result);
router.replace(`/${createEthereumRequestLink(
address,
Currency.USDC,
{
chainId: config.environment === ENV_MAIN
? EthereumChain.POLYGON_MAINNET
: EthereumChain.POLYGON_MUMBAI_TESTNET,
},
)}`);
}
// USDC Request Link
// We only accept links on Polygon to avoid sending Polygon USDC to an Ethereum wallet. We accept:
Expand Down

0 comments on commit 401a9f4

Please sign in to comment.