Skip to content

Commit

Permalink
Merge pull request #53 from zCloak-Network/kycEvent
Browse files Browse the repository at this point in the history
feat: add arbi one contract and chaintool mainnet url
  • Loading branch information
linhan authored Aug 14, 2023
2 parents 8285d62 + 8d30637 commit c7d49b0
Show file tree
Hide file tree
Showing 9 changed files with 1,510 additions and 25 deletions.
1,462 changes: 1,462 additions & 0 deletions packages/app-config/src/abi/arbitrum-sbt.ts

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion packages/app-config/src/abi/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright 2021-2023 zcloak authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { arbitrumGoerli, baseGoerli, lineaTestnet, optimismGoerli } from '@credential/react-components';
import { arbitrum, arbitrumGoerli, baseGoerli, lineaTestnet, optimismGoerli } from '@credential/react-components';

import { arbitrumGoerliSbtAbi } from './arbiGoerli-sbt';
import { arbitrumSbtAbi } from './arbitrum-sbt';
import { baseSbtAbi } from './base-sbt';
import { lineaAbi } from './linea-sbt';
import { opSbtAbi } from './op-sbt';
Expand All @@ -18,6 +19,8 @@ export function getAbi(chainId?: number) {
return lineaAbi;
case arbitrumGoerli.id:
return arbitrumGoerliSbtAbi;
case arbitrum.id:
return arbitrumSbtAbi;
default:
return undefined;
}
Expand Down
20 changes: 15 additions & 5 deletions packages/app-config/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { HexString } from '@zcloak/crypto/types';

import { arbitrumGoerli, baseGoerli, lineaTestnet, optimismGoerli } from '@credential/react-components';
import { arbitrum, arbitrumGoerli, baseGoerli, lineaTestnet, optimismGoerli } from '@credential/react-components';

import { isRelease } from './isRelease';

Expand Down Expand Up @@ -33,26 +33,36 @@ const lineaGerliConfig = isRelease

const arbitrumGoerliConfig = '0xEBE3dc938916cCa495598bbce35DCcB788F5B995';

const arbitrumConfig = '0xbd0adbaee8e3b5b375a40e2ce870e6af1e355e98';

export const CONTRACTS_CONFIG: CONTRACT_CONFIG = {
[optimismGoerli.id]: optimismGoerliConfig,
[baseGoerli.id]: baseGoerliConfig,
[lineaTestnet.id]: lineaGerliConfig,
[arbitrumGoerli.id]: arbitrumGoerliConfig
[arbitrumGoerli.id]: arbitrumGoerliConfig,
[arbitrum.id]: arbitrumConfig
};

export const zkSBTVersion: zkSBTVersion = {
[optimismGoerli.id]: '0',
[baseGoerli.id]: '1',
[lineaTestnet.id]: '1',
[arbitrumGoerli.id]: '1.1'
[arbitrumGoerli.id]: '1.1',
[arbitrum.id]: '1.1'
};

export const ZKSBT_CHAIN_ID = isRelease ? optimismGoerli.id : optimismGoerli.id;
export const VERIFIER_ADDRESS = '0xC2BADDbf6DCeDA9b68638a9de84063c1E0ee4350';

export const ZKSBT_CTYPE = isRelease
? '0x0289711acb57f600850341c7b0c8ab484b004ca8a6471777417cea2b8a88ba7a'
: '0x0faa3462b6d45be3ce01dc570d8465035f68f516610b267a7b01d9b895d04351';
? {
testnet: '0x0289711acb57f600850341c7b0c8ab484b004ca8a6471777417cea2b8a88ba7a',
mainnet: '0x54f1fd6c1ada6d7c69d3e3ced40c12405648561e7f379c4778933c2c8aad1f70'
}
: {
testnet: '0x0faa3462b6d45be3ce01dc570d8465035f68f516610b267a7b01d9b895d04351',
mainnet: '0x54f1fd6c1ada6d7c69d3e3ced40c12405648561e7f379c4778933c2c8aad1f70'
};

export const ETHERSCAN_URL = 'https://goerli-optimism.etherscan.io/tx';
export const ARBISCAN_URL = 'https://goerli.arbiscan.io/tx';
Expand Down
1 change: 0 additions & 1 deletion packages/app-config/src/isRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
// SPDX-License-Identifier: Apache-2.0

export const isRelease = location.hostname.includes('zkid.app');
export const isTestnet = location.href.includes('demo');
4 changes: 3 additions & 1 deletion packages/app-config/src/zk/chaintool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function getPublicInput() {
return `${Math.floor(new Date(compareDate).getTime())}`;
}

const zksbtCtype = location.href.includes('demo') ? ZKSBT_CTYPE.testnet : ZKSBT_CTYPE.mainnet;

const config: ZkProgramConfig[] = [
{
name: 'Adult Check',
Expand Down Expand Up @@ -902,6 +904,6 @@ begin
}
];

const option: ZkProgramOption = [[ZKSBT_CTYPE], config];
const option: ZkProgramOption = [[zksbtCtype], config];

export default option;
10 changes: 9 additions & 1 deletion packages/page-sbt-event/src/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ const Introduction: React.FC<{ isTest: boolean }> = ({ isTest }) => {

return (
<>
<Stack ml='auto' width={250}>
<Stack
style={{
position: 'fixed',
top: '20%',
left: '50%',
transform: 'translate(-50%, -50%)'
}}
width={250}
>
<Collapse in={open}>
<Alert
action={
Expand Down
24 changes: 10 additions & 14 deletions packages/page-sbt-event/src/hooks/useSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { StepCardProps } from '../StepCard';

const ImportedKey = 'import_to_zkID_wallet';

const zksbtCtype = location.href.includes('demo') ? ZKSBT_CTYPE.testnet : ZKSBT_CTYPE.mainnet;

const stepsConfig: StepCardProps[] = [
{
label: 'Step1',
Expand All @@ -34,9 +36,7 @@ const stepsConfig: StepCardProps[] = [
title: 'Finish Chaintool KYC',
onClick: () =>
window.open(
!location.href.includes('zk-kyc-demo2023')
? 'https://passport.chaintool.ai/'
: 'https://passport.chaintool.ai/',
!location.href.includes('zk-kyc-demo2023') ? 'https://zkkyc.chaintool.ai/' : 'https://passport.chaintool.ai/',
'_blank'
),
isLocked: false
Expand All @@ -62,7 +62,7 @@ function getMessage(messages: Message<keyof MessageData>[], did: Did): Message<k
(message) =>
message.msgType === 'Send_issuedVC' &&
message.receiver === did.getKeyUrl('keyAgreement') &&
message?.ctype === ZKSBT_CTYPE
message?.ctype === zksbtCtype
)[0];
}

Expand All @@ -72,8 +72,7 @@ export function useSteps() {

const messages = useMessages('all');
const message = getMessage(messages, did);

const credentials = useLiveQuery(getCredentials, [])?.filter((credential) => credential.ctype === ZKSBT_CTYPE);
const credentials = useLiveQuery(getCredentials, [])?.filter((credential) => credential.ctype === zksbtCtype);
const _credential = useMemo(() => credentials?.[credentials?.length - 1], [credentials]);

const importedKey = `${ImportedKey}:${did.id}`;
Expand All @@ -83,6 +82,7 @@ export function useSteps() {

const { decrypt } = useContext(AppContext);
const { notifyError } = useContext(NotificationContext);
const isTestnet = location.href.includes('demo');

const navigate = useNavigate();

Expand Down Expand Up @@ -113,9 +113,7 @@ export function useSteps() {
newSteps[2].isLocked = false;

newSteps[2].onClick = () => {
navigate(
!location.href.includes('zk-kyc-demo2023') ? `/sbt/${credential.digest}` : `/sbtdemo/${credential.digest}`
);
navigate(!isTestnet ? `/sbt/${credential.digest}` : `/sbtdemo/${credential.digest}`);
changeNetwork();
};

Expand All @@ -127,7 +125,7 @@ export function useSteps() {
} catch (error) {
notifyError(error);
}
}, [decrypt, message, importedKey, navigate, notifyError, changeNetwork]);
}, [decrypt, message, importedKey, navigate, notifyError, changeNetwork, isTestnet]);

useEffect(() => {
const credential = _credential?.vc;
Expand All @@ -141,9 +139,7 @@ export function useSteps() {
newSteps[2].isLocked = false;

newSteps[2].onClick = () => {
navigate(
!location.href.includes('zk-kyc-demo2023') ? `/sbt/${credential.digest}` : `/sbtdemo/${credential.digest}`
);
navigate(!isTestnet ? `/sbt/${credential.digest}` : `/sbtdemo/${credential.digest}`);
changeNetwork();
};

Expand All @@ -156,7 +152,7 @@ export function useSteps() {

setSteps(newSteps);
}
}, [decrypt, isImported, importVc, _credential, navigate, changeNetwork]);
}, [decrypt, isImported, importVc, _credential, navigate, changeNetwork, isTestnet]);

useEffect(() => {
const newSteps = [...stepsConfig];
Expand Down
7 changes: 6 additions & 1 deletion packages/page-sbt/src/Mint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ function Mint({ onCancel, result, vc }: Props) {
result.image // sbtlink
];

if (chain?.id === baseGoerli.id || chain?.id === lineaTestnet.id || chain?.id === arbitrumGoerli.id) {
if (
chain?.id === baseGoerli.id ||
chain?.id === lineaTestnet.id ||
chain?.id === arbitrumGoerli.id ||
chain?.id === arbitrum.id
) {
const publicInput = result.publicInput === '' ? [] : result.publicInput.split(',');

params.splice(3, 0, publicInput);
Expand Down
2 changes: 1 addition & 1 deletion packages/page-sbt/src/modal/MintStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const MintStatus: React.FC<{
OpenSea
</Button>
<Button onClick={() => window.open(`${ARBISCAN_URL}/${hash}`)} startIcon={<img src={ArbLogo} />}>
Etherscan
Arbiscan
</Button>
</Stack>
)}
Expand Down

0 comments on commit c7d49b0

Please sign in to comment.