Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Web Wallet Connect #116

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
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
13 changes: 9 additions & 4 deletions javascript/dwa-starter-react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@web5/api": "0.10.0",
"@web5/credentials": "^1.0.3",
"@web5/dids": "^1.1.1",
"@web5/agent": "^0.7.3",
"@web5/api": "0.0.0-next-3cfc21d-20240920195338",
"@web5/browser": "0.0.0-next-3cfc21d-20240920195338",
"@web5/common": "^1.0.2",
"@web5/credentials": "^1.1.1",
"@web5/dids": "^1.1.4",
"@web5/user-agent": "^0.6.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.407.0",
"next-themes": "^0.3.0",
"node-stdlib-browser": "^1.2.0",
"qrcode.react": "^4.0.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.1",
Expand Down Expand Up @@ -58,4 +63,4 @@
"sharp": "0.32.6",
"sharp-ico": "0.1.5"
}
}
}
481 changes: 320 additions & 161 deletions javascript/dwa-starter-react-vite/pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { DeleteIcon, Trash2Icon } from "lucide-react"
import { Input } from "../ui/input"
import { Typography } from "../ui/typography"

interface ConnectPinProps {
value: string;
onChange: (value: string) => void;
close: () => void;
submit: (pin: string) => void;
}

const ConnectPin: React.FC<ConnectPinProps> = ({ onChange, value, close, submit }) => {

const submitPin = () => {
if (value.length === 0) {
return;
}
submit(value)
}

return (<div>
<Typography variant="p">Please enter the PIN on your wallet</Typography>
<div className="mt-2">
<Input
value={value}
readOnly
className="w-full p-2 border rounded text-center text-lg"
placeholder="Enter PIN"
/>
</div>
<div className="grid grid-cols-3 gap-2">
{[1, 2, 3, 4, 5, 6, 7, 8, 9].map((num) => (
<button
key={num}
className="p-2 border-1 rounded text-primary flex justify-center items-center"
onClick={() => onChange(value + num.toString())}
>
{num}
</button>
))}
<button
className="p-2 border-1 rounded text-primary flex justify-center items-center"
onClick={() => onChange('')}
>
<Trash2Icon className="h-6 w-6" />
</button>
<button
className="p-2 border-1 rounded text-primary flex justify-center items-center"
onClick={() => onChange(value + '0')}
>
0
</button>
<button
className="p-2 border-1 rounded text-primary flex justify-center items-center"
onClick={() => onChange(value.slice(0, -1))}
>
<DeleteIcon className="h-6 w-6" />
</button>
{value.length > 0 && (
<button
className="p-2 border rounded col-span-3 mt-2 bg-primary text-secondary hover:bg-primary-dark"
onClick={submitPin}
>
Submit
</button>
) || (
<button
className="p-2 border rounded col-span-3 mt-2 bg-primary text-secondary hover:bg-primary-dark"
onClick={() => close()}
>
Cancel
</button>
)}
</div>
</div>)
}

export default ConnectPin;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { QRCodeCanvas } from "qrcode.react";
import { Typography } from "../ui/typography";
import { Button } from "../ui/button";
import { XIcon } from "lucide-react";

interface ConnectQRProps {
value: string;
close: () => void;
}

const ConnectQR: React.FC<ConnectQRProps> = ({ close, value }) => {
return (<div>
<a href={value}>
<Typography variant="h3">Scan QR Code</Typography>
<QRCodeCanvas value={value} size={256} className="mt-4 p-2 bg-primary" bgColor="rgb(250,204, 21)" fgColor="rgb(41,37,36)" />
</a>
<div className="mt-4">
<Button onClick={() => close()}>Cancel <XIcon className="ml-2 h-4 w-4" /></Button>
</div>
</div>)
}

export default ConnectQR;
Loading
Loading