diff --git a/package-lock.json b/package-lock.json index 7d21ab02d..6076136db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11258,6 +11258,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/qrcode": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz", + "integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/react": { "version": "19.1.2", "license": "MIT", @@ -18239,7 +18249,7 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -28155,7 +28165,7 @@ }, "node_modules/safer-buffer": { "version": "2.1.2", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/sax": { @@ -32112,16 +32122,16 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.20.5", + "version": "1.20.6", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@onflow/config": "1.6.3", - "@onflow/fcl-core": "1.22.2", - "@onflow/fcl-wc": "6.0.10", + "@onflow/fcl-core": "1.22.3", + "@onflow/fcl-wc": "6.0.11", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.4", - "@onflow/sdk": "1.11.2", + "@onflow/sdk": "1.12.0", "@onflow/types": "1.5.0", "@onflow/util-actor": "1.3.5", "@onflow/util-address": "1.2.4", @@ -32188,7 +32198,7 @@ }, "packages/fcl-core": { "name": "@onflow/fcl-core", - "version": "1.22.2", + "version": "1.22.3", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", @@ -32196,8 +32206,8 @@ "@onflow/config": "1.6.3", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.4", - "@onflow/sdk": "1.11.2", - "@onflow/transport-http": "1.14.0", + "@onflow/sdk": "1.12.0", + "@onflow/transport-http": "1.15.0", "@onflow/types": "1.5.0", "@onflow/util-actor": "1.3.5", "@onflow/util-address": "1.2.4", @@ -32257,14 +32267,14 @@ }, "packages/fcl-ethereum-provider": { "name": "@onflow/fcl-ethereum-provider", - "version": "0.0.12", + "version": "0.0.13", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@ethersproject/bytes": "^5.7.0", "@ethersproject/hash": "^5.7.0", "@noble/hashes": "^1.7.1", - "@onflow/fcl-wc": "6.0.10", + "@onflow/fcl-wc": "6.0.11", "@onflow/rlp": "^1.2.4", "@walletconnect/ethereum-provider": "^2.20.2", "@walletconnect/jsonrpc-http-connection": "^1.0.8", @@ -32285,7 +32295,7 @@ "jest": "^29.7.0" }, "peerDependencies": { - "@onflow/fcl": "1.20.5" + "@onflow/fcl": "1.20.6" } }, "packages/fcl-ethereum-provider/node_modules/@scure/bip32": { @@ -32513,14 +32523,14 @@ }, "packages/fcl-rainbowkit-adapter": { "name": "@onflow/fcl-rainbowkit-adapter", - "version": "0.2.8", + "version": "0.2.9", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@ethersproject/bytes": "^5.7.0", "@ethersproject/hash": "^5.7.0", - "@onflow/fcl-ethereum-provider": "0.0.12", - "@onflow/fcl-wagmi-adapter": "0.0.12", + "@onflow/fcl-ethereum-provider": "0.0.13", + "@onflow/fcl-wagmi-adapter": "0.0.13", "@onflow/rlp": "^1.2.4", "@wagmi/core": "^2.16.3", "mipd": "^0.0.7", @@ -32541,7 +32551,7 @@ "jest": "^29.7.0" }, "peerDependencies": { - "@onflow/fcl": "1.20.5", + "@onflow/fcl": "1.20.6", "@rainbow-me/rainbowkit": "^2.2.3", "react": "17.x || 18.x || 19.x" } @@ -32558,15 +32568,15 @@ }, "packages/fcl-react-native": { "name": "@onflow/fcl-react-native", - "version": "1.13.5", + "version": "1.13.6", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@onflow/config": "1.6.3", - "@onflow/fcl-core": "1.22.2", + "@onflow/fcl-core": "1.22.3", "@onflow/interaction": "0.0.11", "@onflow/rlp": "1.2.4", - "@onflow/sdk": "1.11.2", + "@onflow/sdk": "1.12.0", "@onflow/types": "1.5.0", "@onflow/util-actor": "1.3.5", "@onflow/util-address": "1.2.4", @@ -32617,13 +32627,13 @@ }, "packages/fcl-wagmi-adapter": { "name": "@onflow/fcl-wagmi-adapter", - "version": "0.0.12", + "version": "0.0.13", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@ethersproject/bytes": "^5.7.0", "@ethersproject/hash": "^5.7.0", - "@onflow/fcl-ethereum-provider": "0.0.12", + "@onflow/fcl-ethereum-provider": "0.0.13", "@onflow/rlp": "^1.2.4", "viem": "^2.22.21" }, @@ -32639,13 +32649,13 @@ "jest": "^29.7.0" }, "peerDependencies": { - "@onflow/fcl": "1.20.5", + "@onflow/fcl": "1.20.6", "@wagmi/core": "^2.16.3" } }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "6.0.10", + "version": "6.0.11", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", @@ -32672,7 +32682,7 @@ "jest-preset-preact": "^4.1.1" }, "peerDependencies": { - "@onflow/fcl-core": "1.22.2" + "@onflow/fcl-core": "1.22.3" } }, "packages/fcl-wc/node_modules/@scure/bip32": { @@ -33007,6 +33017,7 @@ "@headlessui/react": "^2.2.2", "@tanstack/react-query": "^5.67.3", "@testing-library/react": "^16.2.0", + "qrcode": "^1.5.3", "tailwind-merge": "^3.3.1" }, "devDependencies": { @@ -33017,6 +33028,7 @@ "@onflow/typedefs": "^1.8.0", "@testing-library/dom": "^10.4.0", "@types/jest": "^29.5.13", + "@types/qrcode": "^1.5.6", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "@typescript-eslint/eslint-plugin": "^6.21.0", @@ -33057,13 +33069,13 @@ }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.11.2", + "version": "1.12.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", "@onflow/config": "1.6.3", "@onflow/rlp": "1.2.4", - "@onflow/transport-http": "1.14.0", + "@onflow/transport-http": "1.15.0", "@onflow/typedefs": "1.8.0", "@onflow/types": "1.5.0", "@onflow/util-actor": "1.3.5", @@ -33113,13 +33125,13 @@ }, "devDependencies": { "@onflow/fcl-bundle": "1.7.1", - "@onflow/sdk": "1.11.2", + "@onflow/sdk": "1.12.0", "jest": "^29.7.0" } }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.14.0", + "version": "1.15.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.25.7", @@ -33137,7 +33149,7 @@ "devDependencies": { "@onflow/fcl-bundle": "1.7.1", "@onflow/rlp": "1.2.4", - "@onflow/sdk": "1.11.2", + "@onflow/sdk": "1.12.0", "@onflow/types": "1.5.0", "jest": "^29.7.0", "jest-websocket-mock": "^2.5.0", diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.json index 750059502..8f7b065e5 100644 --- a/packages/react-sdk/package.json +++ b/packages/react-sdk/package.json @@ -33,6 +33,7 @@ "@onflow/typedefs": "^1.8.0", "@testing-library/dom": "^10.4.0", "@types/jest": "^29.5.13", + "@types/qrcode": "^1.5.6", "@types/react": "^19.0.10", "@types/react-dom": "^19.0.4", "@typescript-eslint/eslint-plugin": "^6.21.0", @@ -50,6 +51,7 @@ "@headlessui/react": "^2.2.2", "@tanstack/react-query": "^5.67.3", "@testing-library/react": "^16.2.0", + "qrcode": "^1.5.3", "tailwind-merge": "^3.3.1" }, "peerDependencies": { diff --git a/packages/react-sdk/src/components/FundContent.tsx b/packages/react-sdk/src/components/FundContent.tsx index e39cfefe5..e7c56a771 100644 --- a/packages/react-sdk/src/components/FundContent.tsx +++ b/packages/react-sdk/src/components/FundContent.tsx @@ -141,7 +141,7 @@ export const FundContent: React.FC = () => { - +
diff --git a/packages/react-sdk/src/components/internal/QRCode.tsx b/packages/react-sdk/src/components/internal/QRCode.tsx index a3e6631ed..aabe959c7 100644 --- a/packages/react-sdk/src/components/internal/QRCode.tsx +++ b/packages/react-sdk/src/components/internal/QRCode.tsx @@ -1,110 +1,103 @@ -import React from "react" +import React, {useMemo, Fragment} from "react" +import QRCodeLib from "qrcode" -export interface QRCodeProps {} - -export const QRCode: React.FC = () => { - return ( -
-
- - {/* Top-left corner marker */} - - - - - {/* Top-right corner marker */} - - - - - {/* Bottom-left corner marker */} - - - - - {/* Data pattern - scattered squares */} - - - - +export interface QRCodeProps { + value: string + size?: number +} - - - - +export const QRCode: React.FC = ({value, size = 200}) => { + const {modules, length, findingPatternPositions} = useMemo(() => { + if (!value) { + return {modules: [], length: 0, findingPatternPositions: []} + } - - - + const qr = QRCodeLib.create(value, { + errorCorrectionLevel: "H", + }) + const modules1D = Array.from(qr.modules.data) + const modules: boolean[][] = [] + const length = qr.modules.size - - - - - - - - - + // Check if the module is part of the finder pattern + const isFindingPattern = (x: number, y: number) => + (x < 8 && (y < 8 || y >= length - 8)) || (x >= length - 8 && y < 8) - - - - - - - - + for (let i = 0; i < length; i++) { + modules.push( + [...modules1D.slice(i * length, (i + 1) * length)].map((bit, j) => { + return bit === 1 && !isFindingPattern(i, j) + }) + ) + } - - - - - - - - + // Positions of the finder patterns used for custom rendering + const findingPatternPositions = [ + [0, 0], + [0, length - 7], + [length - 7, 0], + ] - - - - - - - + return {modules, length, findingPatternPositions} + }, [value]) - - - - - - - - + if (!value || length === 0) { + return null + } - - - - - - + return ( +
+
+ + + {modules.map((row, y) => + row.map((cell, x) => + cell ? ( + + ) : null + ) + )} - - - - - + {findingPatternPositions.map(([x, y]) => { + return ( + + + + - - - - - - + + + ) + })} +