mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
add qrcode generation to sdk, refactor apptypes import
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AppType } from "../utils/appType";
|
||||
import { AppType } from "../../../common/src/utils/appType";
|
||||
import { Text, YStack } from 'tamagui';
|
||||
import { Coins } from '@tamagui/lucide-icons';
|
||||
import GITCOIN from '../images/gitcoin.png';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AppType } from "../utils/appType";
|
||||
import { AppType } from "../../../common/src/utils/appType";
|
||||
import { Flame } from '@tamagui/lucide-icons';
|
||||
import { Text, XStack, YStack } from 'tamagui';
|
||||
import { generateProof } from "../utils/prover";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AppType } from "../utils/appType";
|
||||
import { AppType } from "../../../common/src/utils/appType";
|
||||
import { Text, YStack } from 'tamagui';
|
||||
import { Ticket } from '@tamagui/lucide-icons';
|
||||
import ZUPASS from '../images/zupass.png';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ScrollView, YStack } from 'tamagui';
|
||||
import AppCard from '../components/AppCard';
|
||||
import { Steps } from '../utils/utils';
|
||||
import useNavigationStore from '../stores/navigationStore';
|
||||
import { AppType } from '../utils/appType';
|
||||
import { AppType } from '../../../common/src/utils/appType';
|
||||
import sbtApp from '../apps/sbt';
|
||||
import zupassApp from '../apps/zupass';
|
||||
import gitcoinApp from '../apps/gitcoin';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ScrollView, Text, YStack } from 'tamagui';
|
||||
import AppCard from '../components/AppCard';
|
||||
import { Steps } from '../utils/utils';
|
||||
import useNavigationStore from '../stores/navigationStore';
|
||||
import { AppType, createAppType } from '../utils/appType';
|
||||
import { AppType, createAppType } from '../../../common/src/utils/appType';
|
||||
import sbtApp from '../apps/sbt';
|
||||
import zupassApp from '../apps/zupass';
|
||||
import gitcoinApp from '../apps/gitcoin';
|
||||
|
||||
@@ -11,7 +11,7 @@ import { formatAttribute, Steps } from '../utils/utils';
|
||||
import { downloadZkey } from '../utils/zkeyDownload';
|
||||
import useUserStore from '../stores/userStore';
|
||||
import useNavigationStore from '../stores/navigationStore';
|
||||
import { AppType } from '../utils/appType';
|
||||
import { AppType } from '../../../common/src/utils/appType';
|
||||
import useSbtStore from '../stores/sbtStore';
|
||||
import CustomButton from '../components/CustomButton';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import ProofGrid from '../components/ProofGrid';
|
||||
import { Platform } from 'react-native';
|
||||
import { blueColor, borderColor, componentBgColor, textColor1, textColor2 } from '../utils/colors';
|
||||
import useNavigationStore from '../stores/navigationStore';
|
||||
import { AppType } from '../utils/appType';
|
||||
import { AppType } from '../../../common/src/utils/appType';
|
||||
import { appStoreMapping } from './ProveScreen';
|
||||
|
||||
const SendProofScreen: React.FC = () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { create } from 'zustand'
|
||||
import { IsZkeyDownloading, ShowWarningModalProps } from '../utils/zkeyDownload';
|
||||
import { Steps } from '../utils/utils';
|
||||
import { useToastController } from '@tamagui/toast';
|
||||
import { AppType } from '../utils/appType';
|
||||
import { AppType } from '../../../common/src/utils/appType';
|
||||
|
||||
interface NavigationState {
|
||||
step: number
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CircuitName } from "./zkeyDownload";
|
||||
import { CircuitName } from "../../../app/src/utils/zkeyDownload";
|
||||
|
||||
type DisclosureOption = "required" | "optional";
|
||||
|
||||
28
sdk/QRCodeGenerator.ts
Normal file
28
sdk/QRCodeGenerator.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import QRCode from 'easyqrcodejs';
|
||||
import { AppType } from "../common/src/utils/appType";
|
||||
|
||||
export class QRCodeGenerator {
|
||||
static async generateQRCode(appType: AppType, size: number = 256): Promise<QRCode> {
|
||||
const qrData = this.serializeAppType(appType);
|
||||
const options = {
|
||||
text: qrData,
|
||||
width: size,
|
||||
height: size,
|
||||
};
|
||||
const element = document.createElement('div'); // Create a div element to hold the QR code
|
||||
const qrcode = new QRCode(element, options);
|
||||
return qrcode; // Return the QRCode instance
|
||||
}
|
||||
|
||||
private static serializeAppType(appType: AppType): string {
|
||||
const serializableData = {
|
||||
id: appType.id,
|
||||
name: appType.name,
|
||||
disclosureOptions: appType.disclosureOptions,
|
||||
scope: appType.scope,
|
||||
circuit: appType.circuit,
|
||||
};
|
||||
|
||||
return JSON.stringify(serializableData);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
"@zk-kit/lean-imt": "^2.0.1",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"dotenv": "^16.4.5",
|
||||
"easyqrcodejs": "^4.6.1",
|
||||
"ethers": "^6.13.0",
|
||||
"fs": "^0.0.1-security",
|
||||
"js-sha1": "^0.7.0",
|
||||
@@ -51,4 +52,4 @@
|
||||
"common",
|
||||
"circuits/**/*.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user