Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/testapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"acorn": "^8.15.0",
"framer-motion": "^10.13.1",
"next": "^14.2.10",
"qrcode.react": "^4.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "7.45.2",
"viem": "^2.27.2"
},
"devDependencies": {
"@testing-library/react": "^16.2.0",
"@types/qrcode.react": "^3.0.0",
"@types/react": "18.2.15",
"typescript": "^5.1.6",
"vitest": "^3.0.4"
Expand Down
100 changes: 100 additions & 0 deletions examples/testapp/src/pages/prolink-playground/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
useColorModeValue,
useToast,
} from '@chakra-ui/react';
import { QRCodeSVG } from 'qrcode.react';
import { useState } from 'react';

export default function ProlinkPlayground() {
Expand Down Expand Up @@ -114,11 +115,15 @@ export default function ProlinkPlayground() {
const [decodeError, setDecodeError] = useState<string | null>(null);
const [decodeResult, setDecodeResult] = useState<unknown>(null);

// Base deeplink section
const [baseDeeplink, setBaseDeeplink] = useState<string | null>(null);

const generateProlink = async () => {
setLoading(true);
setError(null);
setEncodedPayload('');
setDecodedResult(null);
setBaseDeeplink(null);

try {
let request: {
Expand Down Expand Up @@ -247,6 +252,29 @@ export default function ProlinkPlayground() {
});
};

const generateBaseDeeplink = () => {
const deeplink = `https://base.app/base-pay?p=${encodedPayload}`;
setBaseDeeplink(deeplink);
toast({
title: 'Base Deeplink Generated!',
description: 'Scan the QR code or copy the link to use it',
status: 'success',
duration: 3000,
});
};

const copyDeeplinkToClipboard = () => {
if (baseDeeplink) {
navigator.clipboard.writeText(baseDeeplink);
toast({
title: 'Copied!',
description: 'Base deeplink copied to clipboard',
status: 'success',
duration: 2000,
});
}
};

const decodePayload = async () => {
setDecodeLoading(true);
setDecodeError(null);
Expand Down Expand Up @@ -616,6 +644,7 @@ export default function ProlinkPlayground() {
<TabList>
<Tab>Encoded Payload</Tab>
<Tab>Decoded Result</Tab>
<Tab>Base Deeplink & QR Code</Tab>
</TabList>

<TabPanels>
Expand Down Expand Up @@ -645,6 +674,77 @@ export default function ProlinkPlayground() {
</Code>
</Box>
</TabPanel>

{/* Base Deeplink & QR Code Tab */}
<TabPanel>
<VStack spacing={6} align="stretch">
{!baseDeeplink ? (
<Box>
<Text mb={4} color="gray.600">
Generate a Base App deeplink to use this prolink in the Base
mobile app. The deeplink will include the encoded prolink as a
URL parameter.
</Text>
<Button
colorScheme="blue"
onClick={generateBaseDeeplink}
size="lg"
>
Generate Base Deeplink
</Button>
</Box>
) : (
<>
<Box>
<HStack mb={2}>
<Text fontWeight="bold">Base Deeplink URL:</Text>
<Button size="sm" onClick={copyDeeplinkToClipboard}>
Copy
</Button>
</HStack>
<Box p={4} bg={codeBgColor} borderRadius="md" overflowX="auto">
<Code
display="block"
whiteSpace="pre-wrap"
wordBreak="break-all"
>
{baseDeeplink}
</Code>
</Box>
</Box>

<Box>
<Text fontWeight="bold" mb={4}>
QR Code:
</Text>
<Box
display="flex"
justifyContent="center"
p={6}
bg="white"
borderRadius="md"
borderWidth="1px"
borderColor={borderColor}
>
<QRCodeSVG value={baseDeeplink} size={256} />
</Box>
<Text fontSize="sm" color="gray.600" mt={2} textAlign="center">
Scan this QR code with the Base mobile app to execute the
prolink
</Text>
</Box>

<Button
colorScheme="blue"
variant="outline"
onClick={generateBaseDeeplink}
>
Regenerate
</Button>
</>
)}
</VStack>
</TabPanel>
</TabPanels>
</Tabs>
)}
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3626,6 +3626,15 @@ __metadata:
languageName: node
linkType: hard

"@types/qrcode.react@npm:^3.0.0":
version: 3.0.0
resolution: "@types/qrcode.react@npm:3.0.0"
dependencies:
qrcode.react: "npm:*"
checksum: 10/8ce11d0455fca9a898f6e9d499529526671c5e398f44cf2bc507ad84e1e4982ff0f384261e52b16b933bdd1d6db6bef27b437f90bb804a039ddfe21112d19da5
languageName: node
linkType: hard

"@types/react@npm:18.2.15":
version: 18.2.15
resolution: "@types/react@npm:18.2.15"
Expand Down Expand Up @@ -8241,6 +8250,15 @@ __metadata:
languageName: node
linkType: hard

"qrcode.react@npm:*, qrcode.react@npm:^4.2.0":
version: 4.2.0
resolution: "qrcode.react@npm:4.2.0"
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
checksum: 10/665036d88b160e6d5de4e24d101bc63bd2b76712802e874bbffe56c6b6e5fe50c63f02c3cba2975b2e2b555c1f1e112cbb42987f8cb3a626ce2d17023cfde6ac
languageName: node
linkType: hard

"queue-lit@npm:^1.5.1":
version: 1.5.2
resolution: "queue-lit@npm:1.5.2"
Expand Down Expand Up @@ -8867,10 +8885,12 @@ __metadata:
"@metamask/eth-sig-util": "npm:^7.0.0"
"@testing-library/react": "npm:^16.2.0"
"@types/acorn": "npm:^4.0.6"
"@types/qrcode.react": "npm:^3.0.0"
"@types/react": "npm:18.2.15"
acorn: "npm:^8.15.0"
framer-motion: "npm:^10.13.1"
next: "npm:^14.2.10"
qrcode.react: "npm:^4.2.0"
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
react-hook-form: "npm:7.45.2"
Expand Down