add qrcode generation to sdk, refactor apptypes import

This commit is contained in:
turnoffthiscomputer
2024-07-26 08:59:09 +02:00
parent 7a45263b04
commit 03cbec29ba
11 changed files with 39 additions and 10 deletions

View File

@@ -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';

View File

@@ -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";

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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';

View File

@@ -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 = () => {

View File

@@ -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

View File

@@ -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
View 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);
}
}

View File

@@ -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"
]
}
}