mirror of
https://github.com/3lLobo/zkAuth.git
synced 2026-01-09 12:27:55 -05:00
Merge branch 'main' into hideTheTree
This commit is contained in:
5
backend/config.ts
Normal file
5
backend/config.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const address = {
|
||||
zkWalletFactory: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
||||
HashCheckVerifier: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
||||
OtpMerkleTreeVerifier: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity^0.8.17;
|
||||
|
||||
import "hardhat/console.sol";
|
||||
|
||||
@@ -34,8 +34,9 @@ contract ZkSocialRecoveryWallet is IERC721Receiver {
|
||||
|
||||
mapping(uint256 => bool) usedProofs;
|
||||
|
||||
bool isRecoveryOn;
|
||||
bool public isRecoveryOn;
|
||||
|
||||
address public otpVerifierAddress;
|
||||
ZkOtpValidator otpVerifier;
|
||||
|
||||
struct RecoveryProcedure {
|
||||
@@ -131,6 +132,8 @@ contract ZkSocialRecoveryWallet is IERC721Receiver {
|
||||
|
||||
thresholdForRecovery = _thresholdForRecovery;
|
||||
|
||||
otpVerifierAddress = _otpVerifier;
|
||||
|
||||
otpVerifier = new ZkOtpValidator(_root, _otpVerifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,26 @@ pragma solidity ^0.8.17;
|
||||
import './ZkSocialRecoveryWallet.sol';
|
||||
|
||||
contract ZkWalletFactory {
|
||||
ZkSocialRecoveryWallet[] wallets;
|
||||
mapping(address => address) public userAddressToWalletAddress;
|
||||
event WalletCreated(address walletAddress);
|
||||
|
||||
constructor() {}
|
||||
address public hashCheckVerifier;
|
||||
|
||||
constructor(address _hashCheckVerifier) {
|
||||
hashCheckVerifier = _hashCheckVerifier;
|
||||
}
|
||||
|
||||
function deployWallet(
|
||||
address _hashCheckVerifier,
|
||||
uint256 _ownerPasswordHash,
|
||||
address[] memory _trustees,
|
||||
uint256[] memory _passwordHashes,
|
||||
uint256 _thresholdForRecovery,
|
||||
address _otpVerifier,
|
||||
uint256 _root
|
||||
|
||||
uint256 _root,
|
||||
address _otpVerifier
|
||||
) external returns (address walletAddress) {
|
||||
ZkSocialRecoveryWallet wallet = new ZkSocialRecoveryWallet(
|
||||
_hashCheckVerifier,
|
||||
hashCheckVerifier,
|
||||
_ownerPasswordHash,
|
||||
_trustees,
|
||||
_passwordHashes,
|
||||
@@ -28,7 +31,13 @@ contract ZkWalletFactory {
|
||||
_root,
|
||||
_otpVerifier
|
||||
);
|
||||
wallets.push(wallet);
|
||||
emit WalletCreated(address(wallet));
|
||||
walletAddress = address(wallet);
|
||||
userAddressToWalletAddress[msg.sender] = walletAddress;
|
||||
|
||||
emit WalletCreated(walletAddress);
|
||||
}
|
||||
|
||||
function getUserWalletAddress(address _user) external view returns(address _walletAddress) {
|
||||
_walletAddress = userAddressToWalletAddress[_user];
|
||||
}
|
||||
}
|
||||
|
||||
41
backend/deploy/00_deploy.ts
Normal file
41
backend/deploy/00_deploy.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { HardhatRuntimeEnvironment } from 'hardhat/types'
|
||||
import { DeployFunction } from 'hardhat-deploy/types'
|
||||
import { ethers } from 'hardhat'
|
||||
import fs from 'fs'
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const { deployments, getNamedAccounts } = hre
|
||||
const { deploy } = deployments
|
||||
|
||||
const { owner } = await getNamedAccounts()
|
||||
|
||||
const HashCheckVerifier = await deploy('HashCheckVerifier', {
|
||||
from: owner,
|
||||
log: true,
|
||||
autoMine: true,
|
||||
})
|
||||
|
||||
const OtpMerkleTreeVerifier = await deploy('OtpMerkleTreeVerifier', {
|
||||
from: owner,
|
||||
log: true,
|
||||
autoMine: true,
|
||||
})
|
||||
|
||||
const ZkWalletFactory = await deploy('ZkWalletFactory', {
|
||||
from: owner,
|
||||
args: [HashCheckVerifier.address],
|
||||
log: true,
|
||||
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
|
||||
})
|
||||
|
||||
fs.writeFileSync(
|
||||
'./config.ts',
|
||||
`export const address = {
|
||||
zkWalletFactory: "${ZkWalletFactory.address}",
|
||||
HashCheckVerifier: "${HashCheckVerifier.address}",
|
||||
OtpMerkleTreeVerifier: "${OtpMerkleTreeVerifier.address}",
|
||||
}\n`
|
||||
)
|
||||
}
|
||||
export default func
|
||||
func.tags = ['all']
|
||||
@@ -1,13 +1,32 @@
|
||||
import { HardhatUserConfig } from 'hardhat/config'
|
||||
import 'hardhat-deploy'
|
||||
import 'hardhat-deploy-ethers'
|
||||
import '@typechain/hardhat'
|
||||
|
||||
import '@nomicfoundation/hardhat-toolbox'
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: '0.8.17',
|
||||
solidity: {
|
||||
compilers: [
|
||||
{
|
||||
version: '0.8.17',
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 1000,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
namedAccounts: {
|
||||
owner: 0,
|
||||
},
|
||||
networks: {
|
||||
// for testnet
|
||||
'optimism-goerli': {
|
||||
url: 'https://goerli.optimism.io',
|
||||
// accounts: [privateKey1, ]
|
||||
//accounts: [privateKey1, ]
|
||||
},
|
||||
// for the local dev environment
|
||||
'optimism-local': {
|
||||
|
||||
29136
backend/package-lock.json
generated
29136
backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -28,26 +28,23 @@
|
||||
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
|
||||
"@nomicfoundation/hardhat-toolbox": "^1.0.2",
|
||||
"@nomiclabs/hardhat-ethers": "^2.1.1",
|
||||
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
|
||||
"@nomiclabs/hardhat-etherscan": "^3.1.0",
|
||||
"@openzeppelin/contracts": "^4.7.3",
|
||||
"@remix-project/remixd": "^0.6.6",
|
||||
"@typechain/hardhat": "^6.1.3",
|
||||
"chai": "^4.3.6",
|
||||
"ethers": "^5.7.1",
|
||||
"hardhat": "^2.11.1",
|
||||
"hardhat-deploy-ethers": "^0.3.0-beta.13",
|
||||
"hardhat-gas-reporter": "^1.0.9",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typechain/ethers-v5": "^10.1.0",
|
||||
"solidity-coverage": "^0.8.2",
|
||||
"typechain": "^8.1.0",
|
||||
"hardhat": "^2.11.2",
|
||||
"@nomiclabs/hardhat-ethers": "^2.0.6",
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.3",
|
||||
"@openzeppelin/contracts": "^4.7.3",
|
||||
"@typechain/ethers-v5": "^10.1.0",
|
||||
"chai": "^4.3.6",
|
||||
"circom_tester": "^0.0.11",
|
||||
"circomlib": "^2.0.5",
|
||||
@@ -55,14 +52,14 @@
|
||||
"circomlib-ml": "^1.1.0",
|
||||
"circomlibjs": "^0.1.7",
|
||||
"dotenv": "^16.0.1",
|
||||
"ethereum-waffle": "^3.4.4",
|
||||
"ethers": "^5.6.8",
|
||||
"hardhat": "^2.9.7",
|
||||
"hardhat": "^2.11.2",
|
||||
"hardhat-contract-sizer": "^2.4.0",
|
||||
"hardhat-deploy": "^0.10.4",
|
||||
"hardhat-gas-reporter": "^1.0.7",
|
||||
"snarkjs": "^0.4.24",
|
||||
"solidity-coverage": "^0.8.2",
|
||||
"totp-generator": "^0.0.13",
|
||||
"typechain": "^8.1.0",
|
||||
"web3-utils": "^1.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
},
|
||||
"include": ["hardhat.config.ts", "./scripts", "./deploy", "./test"]
|
||||
}
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
/* eslint-disable */
|
||||
import type * as access from "./access";
|
||||
export type { access };
|
||||
import type * as token from "./token";
|
||||
export type { token };
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
Overrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type { FunctionFragment, Result } from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../../../../common";
|
||||
|
||||
export interface IERC721ReceiverInterface extends utils.Interface {
|
||||
functions: {
|
||||
"onERC721Received(address,address,uint256,bytes)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(nameOrSignatureOrTopic: "onERC721Received"): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "onERC721Received",
|
||||
values: [
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BytesLike>
|
||||
]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(
|
||||
functionFragment: "onERC721Received",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
|
||||
events: {};
|
||||
}
|
||||
|
||||
export interface IERC721Receiver extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: IERC721ReceiverInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
onERC721Received(
|
||||
operator: PromiseOrValue<string>,
|
||||
from: PromiseOrValue<string>,
|
||||
tokenId: PromiseOrValue<BigNumberish>,
|
||||
data: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
};
|
||||
|
||||
onERC721Received(
|
||||
operator: PromiseOrValue<string>,
|
||||
from: PromiseOrValue<string>,
|
||||
tokenId: PromiseOrValue<BigNumberish>,
|
||||
data: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
callStatic: {
|
||||
onERC721Received(
|
||||
operator: PromiseOrValue<string>,
|
||||
from: PromiseOrValue<string>,
|
||||
tokenId: PromiseOrValue<BigNumberish>,
|
||||
data: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
};
|
||||
|
||||
filters: {};
|
||||
|
||||
estimateGas: {
|
||||
onERC721Received(
|
||||
operator: PromiseOrValue<string>,
|
||||
from: PromiseOrValue<string>,
|
||||
tokenId: PromiseOrValue<BigNumberish>,
|
||||
data: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
onERC721Received(
|
||||
operator: PromiseOrValue<string>,
|
||||
from: PromiseOrValue<string>,
|
||||
tokenId: PromiseOrValue<BigNumberish>,
|
||||
data: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type { IERC721Receiver } from "./IERC721Receiver";
|
||||
@@ -0,0 +1,5 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type * as erc721 from "./ERC721";
|
||||
export type { erc721 };
|
||||
624
backend/typechain-types/contracts/TotpAuthenticator.ts
Normal file
624
backend/typechain-types/contracts/TotpAuthenticator.ts
Normal file
@@ -0,0 +1,624 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
Overrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type {
|
||||
FunctionFragment,
|
||||
Result,
|
||||
EventFragment,
|
||||
} from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../common";
|
||||
|
||||
export type AuthDataStruct = {
|
||||
totp5: PromiseOrValue<BigNumberish>;
|
||||
totp6hash: PromiseOrValue<BytesLike>;
|
||||
time: PromiseOrValue<BigNumberish>;
|
||||
};
|
||||
|
||||
export type AuthDataStructOutput = [BigNumber, string, BigNumber] & {
|
||||
totp5: BigNumber;
|
||||
totp6hash: string;
|
||||
time: BigNumber;
|
||||
};
|
||||
|
||||
export type AuthenticationStruct = {
|
||||
isValid: PromiseOrValue<boolean>;
|
||||
time: PromiseOrValue<BigNumberish>;
|
||||
};
|
||||
|
||||
export type AuthenticationStructOutput = [boolean, BigNumber] & {
|
||||
isValid: boolean;
|
||||
time: BigNumber;
|
||||
};
|
||||
|
||||
export interface TotpAuthenticatorInterface extends utils.Interface {
|
||||
functions: {
|
||||
"authenticate(uint256,uint256)": FunctionFragment;
|
||||
"completedAuth(uint256)": FunctionFragment;
|
||||
"getAuthentication(uint256)": FunctionFragment;
|
||||
"owner()": FunctionFragment;
|
||||
"renounceOwnership()": FunctionFragment;
|
||||
"requestCounter()": FunctionFragment;
|
||||
"requests(uint256,uint256)": FunctionFragment;
|
||||
"resetAuthenticator()": FunctionFragment;
|
||||
"responses(uint256)": FunctionFragment;
|
||||
"setRequest(address)": FunctionFragment;
|
||||
"setResponse(uint256,uint256,bytes32,uint256)": FunctionFragment;
|
||||
"transferOwnership(address)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| "authenticate"
|
||||
| "completedAuth"
|
||||
| "getAuthentication"
|
||||
| "owner"
|
||||
| "renounceOwnership"
|
||||
| "requestCounter"
|
||||
| "requests"
|
||||
| "resetAuthenticator"
|
||||
| "responses"
|
||||
| "setRequest"
|
||||
| "setResponse"
|
||||
| "transferOwnership"
|
||||
): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "authenticate",
|
||||
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "completedAuth",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "getAuthentication",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "renounceOwnership",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "requestCounter",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "requests",
|
||||
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "resetAuthenticator",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "responses",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setRequest",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setResponse",
|
||||
values: [
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "transferOwnership",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(
|
||||
functionFragment: "authenticate",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "completedAuth",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "getAuthentication",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "renounceOwnership",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "requestCounter",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "requests", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "resetAuthenticator",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "responses", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "setRequest", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "setResponse",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "transferOwnership",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
|
||||
events: {
|
||||
"EventAuthRequest(address,address,uint256)": EventFragment;
|
||||
"EventAuthResponse(address,uint256,tuple)": EventFragment;
|
||||
"EventAuthValid(uint256,tuple)": EventFragment;
|
||||
"EventResetContract(uint256)": EventFragment;
|
||||
"OwnershipTransferred(address,address)": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "EventAuthRequest"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "EventAuthResponse"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "EventAuthValid"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "EventResetContract"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "OwnershipTransferred"): EventFragment;
|
||||
}
|
||||
|
||||
export interface EventAuthRequestEventObject {
|
||||
requestor: string;
|
||||
target: string;
|
||||
requestId: BigNumber;
|
||||
}
|
||||
export type EventAuthRequestEvent = TypedEvent<
|
||||
[string, string, BigNumber],
|
||||
EventAuthRequestEventObject
|
||||
>;
|
||||
|
||||
export type EventAuthRequestEventFilter =
|
||||
TypedEventFilter<EventAuthRequestEvent>;
|
||||
|
||||
export interface EventAuthResponseEventObject {
|
||||
responder: string;
|
||||
requestId: BigNumber;
|
||||
response: AuthDataStructOutput;
|
||||
}
|
||||
export type EventAuthResponseEvent = TypedEvent<
|
||||
[string, BigNumber, AuthDataStructOutput],
|
||||
EventAuthResponseEventObject
|
||||
>;
|
||||
|
||||
export type EventAuthResponseEventFilter =
|
||||
TypedEventFilter<EventAuthResponseEvent>;
|
||||
|
||||
export interface EventAuthValidEventObject {
|
||||
requestId: BigNumber;
|
||||
authentication: AuthenticationStructOutput;
|
||||
}
|
||||
export type EventAuthValidEvent = TypedEvent<
|
||||
[BigNumber, AuthenticationStructOutput],
|
||||
EventAuthValidEventObject
|
||||
>;
|
||||
|
||||
export type EventAuthValidEventFilter = TypedEventFilter<EventAuthValidEvent>;
|
||||
|
||||
export interface EventResetContractEventObject {
|
||||
time: BigNumber;
|
||||
}
|
||||
export type EventResetContractEvent = TypedEvent<
|
||||
[BigNumber],
|
||||
EventResetContractEventObject
|
||||
>;
|
||||
|
||||
export type EventResetContractEventFilter =
|
||||
TypedEventFilter<EventResetContractEvent>;
|
||||
|
||||
export interface OwnershipTransferredEventObject {
|
||||
previousOwner: string;
|
||||
newOwner: string;
|
||||
}
|
||||
export type OwnershipTransferredEvent = TypedEvent<
|
||||
[string, string],
|
||||
OwnershipTransferredEventObject
|
||||
>;
|
||||
|
||||
export type OwnershipTransferredEventFilter =
|
||||
TypedEventFilter<OwnershipTransferredEvent>;
|
||||
|
||||
export interface TotpAuthenticator extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: TotpAuthenticatorInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
authenticate(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_lastDigit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
completedAuth(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[boolean, BigNumber] & { isValid: boolean; time: BigNumber }>;
|
||||
|
||||
getAuthentication(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[AuthenticationStructOutput]>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
renounceOwnership(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
requestCounter(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
|
||||
requests(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
arg1: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[string]>;
|
||||
|
||||
resetAuthenticator(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
responses(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<
|
||||
[BigNumber, string, BigNumber] & {
|
||||
totp5: BigNumber;
|
||||
totp6hash: string;
|
||||
time: BigNumber;
|
||||
}
|
||||
>;
|
||||
|
||||
setRequest(
|
||||
_target: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setResponse(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_totp5: PromiseOrValue<BigNumberish>,
|
||||
_totp6hash: PromiseOrValue<BytesLike>,
|
||||
_time: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
transferOwnership(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
};
|
||||
|
||||
authenticate(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_lastDigit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
completedAuth(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[boolean, BigNumber] & { isValid: boolean; time: BigNumber }>;
|
||||
|
||||
getAuthentication(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<AuthenticationStructOutput>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
renounceOwnership(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
requestCounter(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
requests(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
arg1: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
resetAuthenticator(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
responses(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<
|
||||
[BigNumber, string, BigNumber] & {
|
||||
totp5: BigNumber;
|
||||
totp6hash: string;
|
||||
time: BigNumber;
|
||||
}
|
||||
>;
|
||||
|
||||
setRequest(
|
||||
_target: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setResponse(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_totp5: PromiseOrValue<BigNumberish>,
|
||||
_totp6hash: PromiseOrValue<BytesLike>,
|
||||
_time: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
transferOwnership(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
callStatic: {
|
||||
authenticate(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_lastDigit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
completedAuth(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[boolean, BigNumber] & { isValid: boolean; time: BigNumber }>;
|
||||
|
||||
getAuthentication(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<AuthenticationStructOutput>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
renounceOwnership(overrides?: CallOverrides): Promise<void>;
|
||||
|
||||
requestCounter(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
requests(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
arg1: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
resetAuthenticator(overrides?: CallOverrides): Promise<void>;
|
||||
|
||||
responses(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<
|
||||
[BigNumber, string, BigNumber] & {
|
||||
totp5: BigNumber;
|
||||
totp6hash: string;
|
||||
time: BigNumber;
|
||||
}
|
||||
>;
|
||||
|
||||
setRequest(
|
||||
_target: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
setResponse(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_totp5: PromiseOrValue<BigNumberish>,
|
||||
_totp6hash: PromiseOrValue<BytesLike>,
|
||||
_time: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
transferOwnership(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
filters: {
|
||||
"EventAuthRequest(address,address,uint256)"(
|
||||
requestor?: null,
|
||||
target?: null,
|
||||
requestId?: null
|
||||
): EventAuthRequestEventFilter;
|
||||
EventAuthRequest(
|
||||
requestor?: null,
|
||||
target?: null,
|
||||
requestId?: null
|
||||
): EventAuthRequestEventFilter;
|
||||
|
||||
"EventAuthResponse(address,uint256,tuple)"(
|
||||
responder?: null,
|
||||
requestId?: null,
|
||||
response?: null
|
||||
): EventAuthResponseEventFilter;
|
||||
EventAuthResponse(
|
||||
responder?: null,
|
||||
requestId?: null,
|
||||
response?: null
|
||||
): EventAuthResponseEventFilter;
|
||||
|
||||
"EventAuthValid(uint256,tuple)"(
|
||||
requestId?: null,
|
||||
authentication?: null
|
||||
): EventAuthValidEventFilter;
|
||||
EventAuthValid(
|
||||
requestId?: null,
|
||||
authentication?: null
|
||||
): EventAuthValidEventFilter;
|
||||
|
||||
"EventResetContract(uint256)"(time?: null): EventResetContractEventFilter;
|
||||
EventResetContract(time?: null): EventResetContractEventFilter;
|
||||
|
||||
"OwnershipTransferred(address,address)"(
|
||||
previousOwner?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnershipTransferredEventFilter;
|
||||
OwnershipTransferred(
|
||||
previousOwner?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnershipTransferredEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {
|
||||
authenticate(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_lastDigit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
completedAuth(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
getAuthentication(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
renounceOwnership(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
requestCounter(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
requests(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
arg1: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
resetAuthenticator(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
responses(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setRequest(
|
||||
_target: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setResponse(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_totp5: PromiseOrValue<BigNumberish>,
|
||||
_totp6hash: PromiseOrValue<BytesLike>,
|
||||
_time: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
transferOwnership(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
authenticate(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_lastDigit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
completedAuth(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
getAuthentication(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
renounceOwnership(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
requestCounter(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
requests(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
arg1: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
resetAuthenticator(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
responses(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setRequest(
|
||||
_target: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setResponse(
|
||||
_requestId: PromiseOrValue<BigNumberish>,
|
||||
_totp5: PromiseOrValue<BigNumberish>,
|
||||
_totp6hash: PromiseOrValue<BytesLike>,
|
||||
_time: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
transferOwnership(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
142
backend/typechain-types/contracts/Verifiers/HashCheckVerifier.ts
Normal file
142
backend/typechain-types/contracts/Verifiers/HashCheckVerifier.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type { FunctionFragment, Result } from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../../common";
|
||||
|
||||
export interface HashCheckVerifierInterface extends utils.Interface {
|
||||
functions: {
|
||||
"verifyProof(uint256[2],uint256[2][2],uint256[2],uint256[1])": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(nameOrSignatureOrTopic: "verifyProof"): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "verifyProof",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>]
|
||||
]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(
|
||||
functionFragment: "verifyProof",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
|
||||
events: {};
|
||||
}
|
||||
|
||||
export interface HashCheckVerifier extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: HashCheckVerifierInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<[boolean] & { r: boolean }>;
|
||||
};
|
||||
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
|
||||
callStatic: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
};
|
||||
|
||||
filters: {};
|
||||
|
||||
estimateGas: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type * as hashCheckVerifierSol from "./HashCheckVerifier.sol";
|
||||
export type { hashCheckVerifierSol };
|
||||
export type { HashCheckVerifier } from "./HashCheckVerifier";
|
||||
export type { OtpMerkleTreeVerifier } from "./OtpMerkleTreeVerifier";
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type { FunctionFragment, Result } from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../../common";
|
||||
|
||||
export interface IHashCheckVerifierInterface extends utils.Interface {
|
||||
functions: {
|
||||
"verifyProof(uint256[2],uint256[2][2],uint256[2],uint256[1])": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(nameOrSignatureOrTopic: "verifyProof"): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "verifyProof",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>]
|
||||
]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(
|
||||
functionFragment: "verifyProof",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
|
||||
events: {};
|
||||
}
|
||||
|
||||
export interface IHashCheckVerifier extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: IHashCheckVerifierInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<[boolean]>;
|
||||
};
|
||||
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
|
||||
callStatic: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
};
|
||||
|
||||
filters: {};
|
||||
|
||||
estimateGas: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
verifyProof(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>],
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,708 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
Overrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type {
|
||||
FunctionFragment,
|
||||
Result,
|
||||
EventFragment,
|
||||
} from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../../common";
|
||||
|
||||
export interface ZkSocialRecoveryWalletInterface extends utils.Interface {
|
||||
functions: {
|
||||
"cancelRecovery(uint256[2],uint256[2][2],uint256[2],uint256[1],uint256)": FunctionFragment;
|
||||
"currentRecoveryNumber()": FunctionFragment;
|
||||
"executeRecoveryChange(uint256[2],uint256[2][2],uint256[2],uint256[1],uint256)": FunctionFragment;
|
||||
"executeTxn(uint256[2],uint256[2][2],uint256[2],uint256[2],address,uint256)": FunctionFragment;
|
||||
"isRecoveryOn()": FunctionFragment;
|
||||
"onERC721Received(address,address,uint256,bytes)": FunctionFragment;
|
||||
"otpVerifierAddress()": FunctionFragment;
|
||||
"owner()": FunctionFragment;
|
||||
"startRecovery(uint256[2],uint256[2][2],uint256[2],uint256[1],address)": FunctionFragment;
|
||||
"voteInRecovery(uint256[2],uint256[2][2],uint256[2],uint256[1],uint256)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| "cancelRecovery"
|
||||
| "currentRecoveryNumber"
|
||||
| "executeRecoveryChange"
|
||||
| "executeTxn"
|
||||
| "isRecoveryOn"
|
||||
| "onERC721Received"
|
||||
| "otpVerifierAddress"
|
||||
| "owner"
|
||||
| "startRecovery"
|
||||
| "voteInRecovery"
|
||||
): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "cancelRecovery",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>],
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "currentRecoveryNumber",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "executeRecoveryChange",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>],
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "executeTxn",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "isRecoveryOn",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "onERC721Received",
|
||||
values: [
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BytesLike>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "otpVerifierAddress",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "startRecovery",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>],
|
||||
PromiseOrValue<string>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "voteInRecovery",
|
||||
values: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>],
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(
|
||||
functionFragment: "cancelRecovery",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "currentRecoveryNumber",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "executeRecoveryChange",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "executeTxn", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "isRecoveryOn",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "onERC721Received",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "otpVerifierAddress",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "startRecovery",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "voteInRecovery",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
|
||||
events: {
|
||||
"NewRecoveryProcedure(address,address,uint256)": EventFragment;
|
||||
"RecoveryCancelled(address,uint256)": EventFragment;
|
||||
"RecoveryExecuted(address,address,uint256)": EventFragment;
|
||||
"VotedInRecovery(address,uint256)": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "NewRecoveryProcedure"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "RecoveryCancelled"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "RecoveryExecuted"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "VotedInRecovery"): EventFragment;
|
||||
}
|
||||
|
||||
export interface NewRecoveryProcedureEventObject {
|
||||
newProposedOwner: string;
|
||||
trusteeInitializer: string;
|
||||
currRecoveryRound: BigNumber;
|
||||
}
|
||||
export type NewRecoveryProcedureEvent = TypedEvent<
|
||||
[string, string, BigNumber],
|
||||
NewRecoveryProcedureEventObject
|
||||
>;
|
||||
|
||||
export type NewRecoveryProcedureEventFilter =
|
||||
TypedEventFilter<NewRecoveryProcedureEvent>;
|
||||
|
||||
export interface RecoveryCancelledEventObject {
|
||||
Owner: string;
|
||||
RecoveryRound: BigNumber;
|
||||
}
|
||||
export type RecoveryCancelledEvent = TypedEvent<
|
||||
[string, BigNumber],
|
||||
RecoveryCancelledEventObject
|
||||
>;
|
||||
|
||||
export type RecoveryCancelledEventFilter =
|
||||
TypedEventFilter<RecoveryCancelledEvent>;
|
||||
|
||||
export interface RecoveryExecutedEventObject {
|
||||
oldOwner: string;
|
||||
newOwner: string;
|
||||
RecoveryRound: BigNumber;
|
||||
}
|
||||
export type RecoveryExecutedEvent = TypedEvent<
|
||||
[string, string, BigNumber],
|
||||
RecoveryExecutedEventObject
|
||||
>;
|
||||
|
||||
export type RecoveryExecutedEventFilter =
|
||||
TypedEventFilter<RecoveryExecutedEvent>;
|
||||
|
||||
export interface VotedInRecoveryEventObject {
|
||||
trustee: string;
|
||||
RecoveryRound: BigNumber;
|
||||
}
|
||||
export type VotedInRecoveryEvent = TypedEvent<
|
||||
[string, BigNumber],
|
||||
VotedInRecoveryEventObject
|
||||
>;
|
||||
|
||||
export type VotedInRecoveryEventFilter = TypedEventFilter<VotedInRecoveryEvent>;
|
||||
|
||||
export interface ZkSocialRecoveryWallet extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: ZkSocialRecoveryWalletInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
cancelRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
currentRecoveryNumber(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
|
||||
executeRecoveryChange(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
executeTxn(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
callee: PromiseOrValue<string>,
|
||||
value: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
isRecoveryOn(overrides?: CallOverrides): Promise<[boolean]>;
|
||||
|
||||
onERC721Received(
|
||||
arg0: PromiseOrValue<string>,
|
||||
arg1: PromiseOrValue<string>,
|
||||
arg2: PromiseOrValue<BigNumberish>,
|
||||
arg3: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[string]>;
|
||||
|
||||
otpVerifierAddress(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
startRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
voteInRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
};
|
||||
|
||||
cancelRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
currentRecoveryNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
executeRecoveryChange(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
executeTxn(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
callee: PromiseOrValue<string>,
|
||||
value: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
isRecoveryOn(overrides?: CallOverrides): Promise<boolean>;
|
||||
|
||||
onERC721Received(
|
||||
arg0: PromiseOrValue<string>,
|
||||
arg1: PromiseOrValue<string>,
|
||||
arg2: PromiseOrValue<BigNumberish>,
|
||||
arg3: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
otpVerifierAddress(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
startRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
voteInRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
callStatic: {
|
||||
cancelRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
currentRecoveryNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
executeRecoveryChange(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
executeTxn(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
callee: PromiseOrValue<string>,
|
||||
value: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
isRecoveryOn(overrides?: CallOverrides): Promise<boolean>;
|
||||
|
||||
onERC721Received(
|
||||
arg0: PromiseOrValue<string>,
|
||||
arg1: PromiseOrValue<string>,
|
||||
arg2: PromiseOrValue<BigNumberish>,
|
||||
arg3: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
otpVerifierAddress(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
startRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
voteInRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
};
|
||||
|
||||
filters: {
|
||||
"NewRecoveryProcedure(address,address,uint256)"(
|
||||
newProposedOwner?: PromiseOrValue<string> | null,
|
||||
trusteeInitializer?: PromiseOrValue<string> | null,
|
||||
currRecoveryRound?: null
|
||||
): NewRecoveryProcedureEventFilter;
|
||||
NewRecoveryProcedure(
|
||||
newProposedOwner?: PromiseOrValue<string> | null,
|
||||
trusteeInitializer?: PromiseOrValue<string> | null,
|
||||
currRecoveryRound?: null
|
||||
): NewRecoveryProcedureEventFilter;
|
||||
|
||||
"RecoveryCancelled(address,uint256)"(
|
||||
Owner?: PromiseOrValue<string> | null,
|
||||
RecoveryRound?: null
|
||||
): RecoveryCancelledEventFilter;
|
||||
RecoveryCancelled(
|
||||
Owner?: PromiseOrValue<string> | null,
|
||||
RecoveryRound?: null
|
||||
): RecoveryCancelledEventFilter;
|
||||
|
||||
"RecoveryExecuted(address,address,uint256)"(
|
||||
oldOwner?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null,
|
||||
RecoveryRound?: null
|
||||
): RecoveryExecutedEventFilter;
|
||||
RecoveryExecuted(
|
||||
oldOwner?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null,
|
||||
RecoveryRound?: null
|
||||
): RecoveryExecutedEventFilter;
|
||||
|
||||
"VotedInRecovery(address,uint256)"(
|
||||
trustee?: PromiseOrValue<string> | null,
|
||||
RecoveryRound?: null
|
||||
): VotedInRecoveryEventFilter;
|
||||
VotedInRecovery(
|
||||
trustee?: PromiseOrValue<string> | null,
|
||||
RecoveryRound?: null
|
||||
): VotedInRecoveryEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {
|
||||
cancelRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
currentRecoveryNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
executeRecoveryChange(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
executeTxn(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
callee: PromiseOrValue<string>,
|
||||
value: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
isRecoveryOn(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
onERC721Received(
|
||||
arg0: PromiseOrValue<string>,
|
||||
arg1: PromiseOrValue<string>,
|
||||
arg2: PromiseOrValue<BigNumberish>,
|
||||
arg3: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
otpVerifierAddress(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
startRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
voteInRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
cancelRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
currentRecoveryNumber(
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
executeRecoveryChange(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
executeTxn(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
input: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
callee: PromiseOrValue<string>,
|
||||
value: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
isRecoveryOn(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
onERC721Received(
|
||||
arg0: PromiseOrValue<string>,
|
||||
arg1: PromiseOrValue<string>,
|
||||
arg2: PromiseOrValue<BigNumberish>,
|
||||
arg3: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
otpVerifierAddress(
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
startRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
voteInRecovery(
|
||||
a: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
b: [
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
|
||||
],
|
||||
c: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
|
||||
Input: [PromiseOrValue<BigNumberish>],
|
||||
recoveryRoundNumber: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type { IHashCheckVerifier } from "./IHashCheckVerifier";
|
||||
export type { ZkSocialRecoveryWallet } from "./ZkSocialRecoveryWallet";
|
||||
249
backend/typechain-types/contracts/ZkWalletFactory.ts
Normal file
249
backend/typechain-types/contracts/ZkWalletFactory.ts
Normal file
@@ -0,0 +1,249 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
Overrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type {
|
||||
FunctionFragment,
|
||||
Result,
|
||||
EventFragment,
|
||||
} from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../common";
|
||||
|
||||
export interface ZkWalletFactoryInterface extends utils.Interface {
|
||||
functions: {
|
||||
"deployWallet(uint256,address[],uint256[],uint256,address,uint256)": FunctionFragment;
|
||||
"getUserWalletAddress(address)": FunctionFragment;
|
||||
"hashCheckVerifier()": FunctionFragment;
|
||||
"userAddressToWalletAddress(address)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| "deployWallet"
|
||||
| "getUserWalletAddress"
|
||||
| "hashCheckVerifier"
|
||||
| "userAddressToWalletAddress"
|
||||
): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "deployWallet",
|
||||
values: [
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<string>[],
|
||||
PromiseOrValue<BigNumberish>[],
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "getUserWalletAddress",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "hashCheckVerifier",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "userAddressToWalletAddress",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(
|
||||
functionFragment: "deployWallet",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "getUserWalletAddress",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "hashCheckVerifier",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "userAddressToWalletAddress",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
|
||||
events: {
|
||||
"WalletCreated(address)": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "WalletCreated"): EventFragment;
|
||||
}
|
||||
|
||||
export interface WalletCreatedEventObject {
|
||||
walletAddress: string;
|
||||
}
|
||||
export type WalletCreatedEvent = TypedEvent<[string], WalletCreatedEventObject>;
|
||||
|
||||
export type WalletCreatedEventFilter = TypedEventFilter<WalletCreatedEvent>;
|
||||
|
||||
export interface ZkWalletFactory extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: ZkWalletFactoryInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
deployWallet(
|
||||
_ownerPasswordHash: PromiseOrValue<BigNumberish>,
|
||||
_trustees: PromiseOrValue<string>[],
|
||||
_passwordHashes: PromiseOrValue<BigNumberish>[],
|
||||
_thresholdForRecovery: PromiseOrValue<BigNumberish>,
|
||||
_otpVerifier: PromiseOrValue<string>,
|
||||
_root: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
getUserWalletAddress(
|
||||
_user: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[string] & { _walletAddress: string }>;
|
||||
|
||||
hashCheckVerifier(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
userAddressToWalletAddress(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[string]>;
|
||||
};
|
||||
|
||||
deployWallet(
|
||||
_ownerPasswordHash: PromiseOrValue<BigNumberish>,
|
||||
_trustees: PromiseOrValue<string>[],
|
||||
_passwordHashes: PromiseOrValue<BigNumberish>[],
|
||||
_thresholdForRecovery: PromiseOrValue<BigNumberish>,
|
||||
_otpVerifier: PromiseOrValue<string>,
|
||||
_root: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
getUserWalletAddress(
|
||||
_user: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
hashCheckVerifier(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
userAddressToWalletAddress(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
callStatic: {
|
||||
deployWallet(
|
||||
_ownerPasswordHash: PromiseOrValue<BigNumberish>,
|
||||
_trustees: PromiseOrValue<string>[],
|
||||
_passwordHashes: PromiseOrValue<BigNumberish>[],
|
||||
_thresholdForRecovery: PromiseOrValue<BigNumberish>,
|
||||
_otpVerifier: PromiseOrValue<string>,
|
||||
_root: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
getUserWalletAddress(
|
||||
_user: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
hashCheckVerifier(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
userAddressToWalletAddress(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
};
|
||||
|
||||
filters: {
|
||||
"WalletCreated(address)"(walletAddress?: null): WalletCreatedEventFilter;
|
||||
WalletCreated(walletAddress?: null): WalletCreatedEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {
|
||||
deployWallet(
|
||||
_ownerPasswordHash: PromiseOrValue<BigNumberish>,
|
||||
_trustees: PromiseOrValue<string>[],
|
||||
_passwordHashes: PromiseOrValue<BigNumberish>[],
|
||||
_thresholdForRecovery: PromiseOrValue<BigNumberish>,
|
||||
_otpVerifier: PromiseOrValue<string>,
|
||||
_root: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
getUserWalletAddress(
|
||||
_user: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
hashCheckVerifier(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
userAddressToWalletAddress(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
deployWallet(
|
||||
_ownerPasswordHash: PromiseOrValue<BigNumberish>,
|
||||
_trustees: PromiseOrValue<string>[],
|
||||
_passwordHashes: PromiseOrValue<BigNumberish>[],
|
||||
_thresholdForRecovery: PromiseOrValue<BigNumberish>,
|
||||
_otpVerifier: PromiseOrValue<string>,
|
||||
_root: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
getUserWalletAddress(
|
||||
_user: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
hashCheckVerifier(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
userAddressToWalletAddress(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
@@ -5,4 +5,7 @@ import type * as verifiers from "./Verifiers";
|
||||
export type { verifiers };
|
||||
import type * as zkOtpValidatorSol from "./ZkOtpValidator.sol";
|
||||
export type { zkOtpValidatorSol };
|
||||
export type { ZkSocialRecoveryWallet } from "./ZkSocialRecoveryWallet";
|
||||
import type * as zkSocialRecoveryWalletSol from "./ZkSocialRecoveryWallet.sol";
|
||||
export type { zkSocialRecoveryWalletSol };
|
||||
export type { TotpAuthenticator } from "./TotpAuthenticator";
|
||||
export type { ZkWalletFactory } from "./ZkWalletFactory";
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as access from "./access";
|
||||
export * as token from "./token";
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Contract, Signer, utils } from "ethers";
|
||||
import type { Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
IERC721Receiver,
|
||||
IERC721ReceiverInterface,
|
||||
} from "../../../../../@openzeppelin/contracts/token/ERC721/IERC721Receiver";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "operator",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "address",
|
||||
name: "from",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "tokenId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "data",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "onERC721Received",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bytes4",
|
||||
name: "",
|
||||
type: "bytes4",
|
||||
},
|
||||
],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
export class IERC721Receiver__factory {
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): IERC721ReceiverInterface {
|
||||
return new utils.Interface(_abi) as IERC721ReceiverInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): IERC721Receiver {
|
||||
return new Contract(address, _abi, signerOrProvider) as IERC721Receiver;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { IERC721Receiver__factory } from "./IERC721Receiver__factory";
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as erc721 from "./ERC721";
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as hashCheckVerifierSol from "./HashCheckVerifier.sol";
|
||||
export { HashCheckVerifier__factory } from "./HashCheckVerifier__factory";
|
||||
export { OtpMerkleTreeVerifier__factory } from "./OtpMerkleTreeVerifier__factory";
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,60 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Contract, Signer, utils } from "ethers";
|
||||
import type { Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
IHashCheckVerifier,
|
||||
IHashCheckVerifierInterface,
|
||||
} from "../../../contracts/ZkSocialRecoveryWallet.sol/IHashCheckVerifier";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256[2]",
|
||||
name: "a",
|
||||
type: "uint256[2]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[2][2]",
|
||||
name: "b",
|
||||
type: "uint256[2][2]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[2]",
|
||||
name: "c",
|
||||
type: "uint256[2]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[1]",
|
||||
name: "input",
|
||||
type: "uint256[1]",
|
||||
},
|
||||
],
|
||||
name: "verifyProof",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
export class IHashCheckVerifier__factory {
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): IHashCheckVerifierInterface {
|
||||
return new utils.Interface(_abi) as IHashCheckVerifierInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): IHashCheckVerifier {
|
||||
return new Contract(address, _abi, signerOrProvider) as IHashCheckVerifier;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { IHashCheckVerifier__factory } from "./IHashCheckVerifier__factory";
|
||||
export { ZkSocialRecoveryWallet__factory } from "./ZkSocialRecoveryWallet__factory";
|
||||
File diff suppressed because one or more lines are too long
@@ -3,4 +3,6 @@
|
||||
/* eslint-disable */
|
||||
export * as verifiers from "./Verifiers";
|
||||
export * as zkOtpValidatorSol from "./ZkOtpValidator.sol";
|
||||
export { ZkSocialRecoveryWallet__factory } from "./ZkSocialRecoveryWallet__factory";
|
||||
export * as zkSocialRecoveryWalletSol from "./ZkSocialRecoveryWallet.sol";
|
||||
export { TotpAuthenticator__factory } from "./TotpAuthenticator__factory";
|
||||
export { ZkWalletFactory__factory } from "./ZkWalletFactory__factory";
|
||||
|
||||
87
backend/typechain-types/hardhat.d.ts
vendored
87
backend/typechain-types/hardhat.d.ts
vendored
@@ -1,87 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { ethers } from "ethers";
|
||||
import {
|
||||
FactoryOptions,
|
||||
HardhatEthersHelpers as HardhatEthersHelpersBase,
|
||||
} from "@nomiclabs/hardhat-ethers/types";
|
||||
|
||||
import * as Contracts from ".";
|
||||
|
||||
declare module "hardhat/types/runtime" {
|
||||
interface HardhatEthersHelpers extends HardhatEthersHelpersBase {
|
||||
getContractFactory(
|
||||
name: "Ownable",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.Ownable__factory>;
|
||||
getContractFactory(
|
||||
name: "Verifier",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.Verifier__factory>;
|
||||
getContractFactory(
|
||||
name: "OtpMerkleTreeVerifier",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.OtpMerkleTreeVerifier__factory>;
|
||||
getContractFactory(
|
||||
name: "IOtpMerkleTreeVerifier",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.IOtpMerkleTreeVerifier__factory>;
|
||||
getContractFactory(
|
||||
name: "ZkOtpValidator",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.ZkOtpValidator__factory>;
|
||||
getContractFactory(
|
||||
name: "ZkSocialRecoveryWallet",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.ZkSocialRecoveryWallet__factory>;
|
||||
|
||||
getContractAt(
|
||||
name: "Ownable",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.Ownable>;
|
||||
getContractAt(
|
||||
name: "Verifier",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.Verifier>;
|
||||
getContractAt(
|
||||
name: "OtpMerkleTreeVerifier",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.OtpMerkleTreeVerifier>;
|
||||
getContractAt(
|
||||
name: "IOtpMerkleTreeVerifier",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.IOtpMerkleTreeVerifier>;
|
||||
getContractAt(
|
||||
name: "ZkOtpValidator",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.ZkOtpValidator>;
|
||||
getContractAt(
|
||||
name: "ZkSocialRecoveryWallet",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.ZkSocialRecoveryWallet>;
|
||||
|
||||
// default types
|
||||
getContractFactory(
|
||||
name: string,
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<ethers.ContractFactory>;
|
||||
getContractFactory(
|
||||
abi: any[],
|
||||
bytecode: ethers.utils.BytesLike,
|
||||
signer?: ethers.Signer
|
||||
): Promise<ethers.ContractFactory>;
|
||||
getContractAt(
|
||||
nameOrAbi: string | any[],
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<ethers.Contract>;
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,21 @@ export type { contracts };
|
||||
export * as factories from "./factories";
|
||||
export type { Ownable } from "./@openzeppelin/contracts/access/Ownable";
|
||||
export { Ownable__factory } from "./factories/@openzeppelin/contracts/access/Ownable__factory";
|
||||
export type { Verifier } from "./contracts/Verifiers/HashCheckVerifier.sol/Verifier";
|
||||
export { Verifier__factory } from "./factories/contracts/Verifiers/HashCheckVerifier.sol/Verifier__factory";
|
||||
export type { IERC721Receiver } from "./@openzeppelin/contracts/token/ERC721/IERC721Receiver";
|
||||
export { IERC721Receiver__factory } from "./factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory";
|
||||
export type { TotpAuthenticator } from "./contracts/TotpAuthenticator";
|
||||
export { TotpAuthenticator__factory } from "./factories/contracts/TotpAuthenticator__factory";
|
||||
export type { HashCheckVerifier } from "./contracts/Verifiers/HashCheckVerifier";
|
||||
export { HashCheckVerifier__factory } from "./factories/contracts/Verifiers/HashCheckVerifier__factory";
|
||||
export type { OtpMerkleTreeVerifier } from "./contracts/Verifiers/OtpMerkleTreeVerifier";
|
||||
export { OtpMerkleTreeVerifier__factory } from "./factories/contracts/Verifiers/OtpMerkleTreeVerifier__factory";
|
||||
export type { IOtpMerkleTreeVerifier } from "./contracts/ZkOtpValidator.sol/IOtpMerkleTreeVerifier";
|
||||
export { IOtpMerkleTreeVerifier__factory } from "./factories/contracts/ZkOtpValidator.sol/IOtpMerkleTreeVerifier__factory";
|
||||
export type { ZkOtpValidator } from "./contracts/ZkOtpValidator.sol/ZkOtpValidator";
|
||||
export { ZkOtpValidator__factory } from "./factories/contracts/ZkOtpValidator.sol/ZkOtpValidator__factory";
|
||||
export type { ZkSocialRecoveryWallet } from "./contracts/ZkSocialRecoveryWallet";
|
||||
export { ZkSocialRecoveryWallet__factory } from "./factories/contracts/ZkSocialRecoveryWallet__factory";
|
||||
export type { IHashCheckVerifier } from "./contracts/ZkSocialRecoveryWallet.sol/IHashCheckVerifier";
|
||||
export { IHashCheckVerifier__factory } from "./factories/contracts/ZkSocialRecoveryWallet.sol/IHashCheckVerifier__factory";
|
||||
export type { ZkSocialRecoveryWallet } from "./contracts/ZkSocialRecoveryWallet.sol/ZkSocialRecoveryWallet";
|
||||
export { ZkSocialRecoveryWallet__factory } from "./factories/contracts/ZkSocialRecoveryWallet.sol/ZkSocialRecoveryWallet__factory";
|
||||
export type { ZkWalletFactory } from "./contracts/ZkWalletFactory";
|
||||
export { ZkWalletFactory__factory } from "./factories/contracts/ZkWalletFactory__factory";
|
||||
|
||||
@@ -8,6 +8,7 @@ import { CheckIcon } from '@heroicons/react/20/solid'
|
||||
import { ThreeDots } from 'react-loader-spinner'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { PlusIcon } from '@heroicons/react/24/solid'
|
||||
import { PasswordTOTPBox, PasswordZKBox } from '.'
|
||||
|
||||
interface ModalSetSocialProps {}
|
||||
|
||||
@@ -316,59 +317,57 @@ const ModalSetSocial = (props: ModalSetSocialProps) => {
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex flex-row gap-3 justify-center">
|
||||
<button
|
||||
className="dark:bg-gray-800 bg-white
|
||||
<div className="mt-3 flex flex-row gap-3 justify-center">
|
||||
<button
|
||||
className="dark:bg-gray-800 bg-white
|
||||
dark:hover:bg-gray-700 hover:bg-gray-100
|
||||
dark:border-gray-600 border-gray-300
|
||||
rounded-full border w-9 h-9"
|
||||
onClick={(e) => addAccount(e)}
|
||||
>
|
||||
<PlusIcon
|
||||
height={'1.2rem'}
|
||||
width={'1.2rem'}
|
||||
className="mx-auto"
|
||||
/>
|
||||
</button>
|
||||
{naccounts > 3 ? (
|
||||
<button
|
||||
className="dark:bg-gray-800 bg-white
|
||||
onClick={(e) => addAccount(e)}
|
||||
>
|
||||
<PlusIcon
|
||||
height={'1.2rem'}
|
||||
width={'1.2rem'}
|
||||
className="mx-auto"
|
||||
/>
|
||||
</button>
|
||||
{naccounts > 3 ? (
|
||||
<button
|
||||
className="dark:bg-gray-800 bg-white
|
||||
dark:hover:bg-gray-700 hover:bg-gray-100
|
||||
dark:border-gray-600 border-gray-300
|
||||
rounded-full border w-9 h-9"
|
||||
onClick={(e) => removeAccount(e)}
|
||||
>
|
||||
<MinusIcon
|
||||
height={'1.2rem'}
|
||||
width={'1.2rem'}
|
||||
className="mx-auto"
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
onClick={(e) => removeAccount(e)}
|
||||
>
|
||||
<MinusIcon
|
||||
height={'1.2rem'}
|
||||
width={'1.2rem'}
|
||||
className="mx-auto"
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-50 ml-3 button-color disabled:opacity-25"
|
||||
onClick={() => setOpen(false)}
|
||||
disabled={!allVerified}
|
||||
>
|
||||
Set
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 sm:mt-0 sm:w-auto sm:text-sm "
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<div
|
||||
id="password"
|
||||
className="w-full mt-3 flex flex-row gap-3 justify-center"
|
||||
>
|
||||
{false ? (
|
||||
<PasswordTOTPBox
|
||||
setOpen={setOpen}
|
||||
allVerified={allVerified}
|
||||
/>
|
||||
) : (
|
||||
<PasswordZKBox
|
||||
setOpen={setOpen}
|
||||
allVerified={allVerified}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Panel>
|
||||
</Transition.Child>
|
||||
|
||||
84
dapp/components/dashboard/PasswordTOTPBox.tsx
Normal file
84
dapp/components/dashboard/PasswordTOTPBox.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
import { useState, useRef } from 'react'
|
||||
import { usePinInput, PinInputActions } from 'react-pin-input-hook'
|
||||
var jsotp = require('jsotp')
|
||||
var base32 = require('thirty-two')
|
||||
|
||||
interface PasswordTOTPBoxParams {
|
||||
setOpen: any
|
||||
allVerified: boolean
|
||||
}
|
||||
|
||||
const PasswordTOTPBox = (props: PasswordTOTPBoxParams) => {
|
||||
// PIN state management
|
||||
const [verified, setVerified] = useState(false)
|
||||
const [pin, setPin] = useState(['', '', '', '', '', ''])
|
||||
const [error, setError] = useState(false)
|
||||
const actionRef = useRef<PinInputActions>(null)
|
||||
const { fields } = usePinInput({
|
||||
values: pin,
|
||||
onChange: setPin,
|
||||
error,
|
||||
actionRef,
|
||||
placeholder: '•',
|
||||
})
|
||||
|
||||
function verifyCode(e: React.FormEvent<HTMLButtonElement>) {
|
||||
e.preventDefault()
|
||||
// Check if there is at least one empty field. If there is, the input is considered empty.
|
||||
if (pin.includes('')) {
|
||||
// Setting the error.
|
||||
setError(true)
|
||||
// We set the focus on the first empty field if `error: true` was passed as a parameter in `options`.
|
||||
actionRef.current?.focus()
|
||||
}
|
||||
const verifier = jsotp.TOTP('SECRET')
|
||||
if (verifier.verify(pin.join(''))) {
|
||||
setVerified(true)
|
||||
} else {
|
||||
setVerified(false)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div className="w-full flex flex-col">
|
||||
<div className="my-4">
|
||||
<label
|
||||
htmlFor="password"
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300 text-center"
|
||||
>
|
||||
Authenticator Code
|
||||
</label>
|
||||
|
||||
<div className="pin-input flex flex-row justify-center">
|
||||
{fields.map((propsField, index) => (
|
||||
<input
|
||||
key={index}
|
||||
className="pin-input__field w-10 p-2.5 mx-1 text-2xl rounded-lg text-center font-mono
|
||||
bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
||||
{...propsField}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-50 ml-3 button-color disabled:opacity-25"
|
||||
onClick={() => props.setOpen(false)}
|
||||
disabled={!props.allVerified}
|
||||
>
|
||||
Set
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 sm:mt-0 sm:w-auto sm:text-sm "
|
||||
onClick={() => props.setOpen(false)}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PasswordTOTPBox
|
||||
59
dapp/components/dashboard/PasswordZKBox.tsx
Normal file
59
dapp/components/dashboard/PasswordZKBox.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
interface PasswordZKBoxParams {
|
||||
setOpen: any
|
||||
allVerified: boolean
|
||||
}
|
||||
|
||||
const PasswordZKBox = (props: PasswordZKBoxParams) => {
|
||||
// PIN state management
|
||||
const [verified, setVerified] = useState(false)
|
||||
const [password, setPassword] = useState('')
|
||||
const [error, setError] = useState(false)
|
||||
|
||||
function verifyCode(e: React.FormEvent<HTMLButtonElement>) {
|
||||
e.preventDefault()
|
||||
// Check if there is at least one empty field. If there is, the input is considered empty.
|
||||
}
|
||||
return (
|
||||
<div className="w-full flex flex-col">
|
||||
<div className="w-full flex flex-col justify-center my-4 ">
|
||||
<label
|
||||
htmlFor="password"
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300 text-center"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
id="passwordzk"
|
||||
name="password"
|
||||
type="password"
|
||||
className="w-1/2 p-2.5 mx-auto rounded-lg
|
||||
bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
||||
placeholder="••••••••"
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-50 ml-3 button-color disabled:opacity-25"
|
||||
onClick={() => props.setOpen(false)}
|
||||
disabled={!props.allVerified}
|
||||
>
|
||||
Set
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 sm:mt-0 sm:w-auto sm:text-sm "
|
||||
onClick={() => props.setOpen(false)}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default PasswordZKBox
|
||||
@@ -6,3 +6,5 @@ export { default as ModalSetSocial } from './ModalSetSocial'
|
||||
export { default as ModalApprovedTxs } from './ModalApprovedTxs'
|
||||
export { default as ModalChangePassword } from './ModalChangePassword'
|
||||
export { default as ModalTxDetails } from './ModalTxDetails'
|
||||
export { default as PasswordTOTPBox } from './PasswordTOTPBox'
|
||||
export { default as PasswordZKBox } from './PasswordZKBox'
|
||||
|
||||
124
dapp/components/home/Hero.tsx
Normal file
124
dapp/components/home/Hero.tsx
Normal file
@@ -0,0 +1,124 @@
|
||||
import { motion } from 'framer-motion'
|
||||
import Link from 'next/link'
|
||||
import Lottie from 'react-lottie-player'
|
||||
import lottieJson from '../../public/security.json'
|
||||
|
||||
const containerBox = {
|
||||
hidden: {},
|
||||
show: {
|
||||
transition: {
|
||||
staggerChildren: 0.1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const ImageBox = {
|
||||
hidden: { x: 100, opacity: 0 },
|
||||
show: {
|
||||
x: 0,
|
||||
opacity: 1,
|
||||
transition: {
|
||||
duration: 0.6,
|
||||
ease: 'easeOut',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const containerLeft = {
|
||||
hidden: {},
|
||||
show: {
|
||||
transition: {
|
||||
staggerChildren: 0.2,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const txTitle = {
|
||||
hidden: { opacity: 0, y: 50 },
|
||||
show: {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
transition: {
|
||||
duration: 0.8,
|
||||
ease: 'easeOut',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const txButtons = {
|
||||
hidden: { x: 100, opacity: 0 },
|
||||
show: {
|
||||
x: 0,
|
||||
opacity: 1,
|
||||
transition: {
|
||||
duration: 0.8,
|
||||
ease: 'easeOut',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const Hero = () => {
|
||||
return (
|
||||
<section>
|
||||
<motion.div
|
||||
variants={containerBox}
|
||||
initial="hidden"
|
||||
animate="show"
|
||||
className="grid max-w-6xl px-4 py-8 mx-auto lg:gap-8 xl:gap-0 lg:py-16 lg:grid-cols-12"
|
||||
>
|
||||
<motion.div
|
||||
variants={containerLeft}
|
||||
initial="hidden"
|
||||
animate="show"
|
||||
className="mr-auto place-self-center lg:col-span-7"
|
||||
>
|
||||
<motion.div variants={txTitle}>
|
||||
<h1 className="max-w-2xl mb-4 text-4xl font-extrabold tracking-tight leading-none md:text-5xl xl:text-6xl dark:text-white">
|
||||
Zero-knowledge authentification for your smart contracts
|
||||
</h1>
|
||||
</motion.div>
|
||||
<motion.div variants={txTitle}>
|
||||
<p className="max-w-2xl mb-6 font-light text-gray-500 lg:mb-8 md:text-lg lg:text-xl dark:text-gray-400">
|
||||
Secure your onchain operations with a two-factor authentification
|
||||
system powered by zero-knowledge proofs
|
||||
</p>
|
||||
</motion.div>
|
||||
<motion.div variants={txButtons}>
|
||||
<Link href="/login">
|
||||
<a className="inline-flex items-center justify-center px-5 py-3 mr-3 text-base font-medium text-center text-white rounded-lg bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-900">
|
||||
Get started
|
||||
<svg
|
||||
className="w-5 h-5 ml-2 -mr-1"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 20 20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
|
||||
clipRule="evenodd"
|
||||
></path>
|
||||
</svg>
|
||||
</a>
|
||||
</Link>
|
||||
<Link href="recovery">
|
||||
<a className="inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-gray-900 border border-gray-300 rounded-lg hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 dark:text-white dark:border-gray-700 dark:hover:bg-gray-700 dark:focus:ring-gray-800">
|
||||
Authenticate a friend
|
||||
</a>
|
||||
</Link>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
<motion.div
|
||||
variants={ImageBox}
|
||||
initial="hidden"
|
||||
animate="show"
|
||||
className="hidden lg:mt-0 lg:col-span-5 lg:flex"
|
||||
>
|
||||
<Lottie loop animationData={lottieJson} play style={{ width: 600 }} />
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
export default Hero
|
||||
1
dapp/components/home/index.ts
Normal file
1
dapp/components/home/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as Hero } from './Hero'
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from './home'
|
||||
export * from './login'
|
||||
export * from './navbar'
|
||||
export * from './dashboard'
|
||||
export * from './layout'
|
||||
export * from './recovery'
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
import { useEthers } from '@usedapp/core'
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { motion } from 'framer-motion'
|
||||
|
||||
import { ConnectWalletButton, TotpSetup, ZkPasswordSetup, CardChoice } from '.'
|
||||
import { connectFactory } from '../../helpers/contracts'
|
||||
import { ethers } from 'ethers'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
const LogInBox = () => {
|
||||
const { account, library: provider } = useEthers()
|
||||
const [authType, setAuthType] = useState('')
|
||||
const router = useRouter()
|
||||
|
||||
// Load data to know if user has wallet
|
||||
useEffect(() => {
|
||||
const loadInfo = async () => {
|
||||
if (provider && account) {
|
||||
const zkWalletFactory = connectFactory(provider)
|
||||
const walletAddress = await zkWalletFactory.userAddressToWalletAddress(
|
||||
account
|
||||
)
|
||||
if (walletAddress !== ethers.constants.AddressZero) {
|
||||
router.push('./dashboard')
|
||||
}
|
||||
}
|
||||
}
|
||||
if (provider && account) {
|
||||
loadInfo()
|
||||
}
|
||||
}, [provider, account])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { Fragment, useState } from 'react'
|
||||
import { Fragment, useState, useEffect } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import {
|
||||
ExclamationTriangleIcon,
|
||||
XMarkIcon,
|
||||
CheckIcon,
|
||||
} from '@heroicons/react/24/outline'
|
||||
import { ThreeDots } from 'react-loader-spinner'
|
||||
import { useTheme } from 'next-themes'
|
||||
|
||||
interface ModalVerifyTotpProps {
|
||||
verified: boolean
|
||||
@@ -12,21 +15,51 @@ interface ModalVerifyTotpProps {
|
||||
}
|
||||
|
||||
const ModalVerifyTotp = (props: ModalVerifyTotpProps) => {
|
||||
const router = useRouter()
|
||||
const [open, setOpen] = useState(false)
|
||||
const onSubmit = (e: React.UIEvent<HTMLButtonElement>) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const onSubmit = async (e: React.UIEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault()
|
||||
props.verifyCode(e)
|
||||
setLoading(true)
|
||||
await props.verifyCode(e)
|
||||
setLoading(false)
|
||||
setOpen(true)
|
||||
}
|
||||
|
||||
const goToDashboard = (e: React.UIEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault()
|
||||
router.push('./dashboard')
|
||||
}
|
||||
|
||||
// Manage theme hydration
|
||||
const { theme } = useTheme()
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
useEffect(() => {
|
||||
if (theme) {
|
||||
setLoaded(true)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
className="w-full h-10 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
onClick={(e) => onSubmit(e)}
|
||||
>
|
||||
Verify
|
||||
{loading ? (
|
||||
<div className="flex justify-center">
|
||||
<ThreeDots
|
||||
height="20"
|
||||
width="35"
|
||||
radius="9"
|
||||
color={theme == 'dark' ? '#ffffff' : '#3b83f6'}
|
||||
ariaLabel="three-dots-loading"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div>Verify</div>
|
||||
)}
|
||||
</button>
|
||||
<Transition.Root show={open} as={Fragment}>
|
||||
<Dialog as="div" className="relative z-10" onClose={setOpen}>
|
||||
@@ -107,23 +140,31 @@ const ModalVerifyTotp = (props: ModalVerifyTotpProps) => {
|
||||
</div>
|
||||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||
{props.verified === false ? (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-full justify-center rounded-md border border-transparent px-4 py-2 text-base text-center font-medium shadow-sm focus:ring-offset-2 sm:ml-3 sm:w-auto sm:text-sm text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
Try Again
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 sm:mt-0 sm:w-auto sm:text-sm"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-full justify-center rounded-md border border-transparent px-4 py-2 text-base text-center font-medium shadow-sm focus:ring-offset-2 sm:ml-3 sm:w-auto sm:text-sm text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
onClick={() => setOpen(false)}
|
||||
onClick={(e) => goToDashboard(e)}
|
||||
>
|
||||
Try Again
|
||||
Go to Dashboard
|
||||
</button>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2 sm:mt-0 sm:w-auto sm:text-sm"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</Dialog.Panel>
|
||||
</Transition.Child>
|
||||
|
||||
@@ -1,31 +1,17 @@
|
||||
import { useQRCode } from 'next-qrcode'
|
||||
|
||||
function makeURI(account: string, secret: string): string {
|
||||
const type = 'totp'
|
||||
const issuer = 'zkAuth' //encodeURIComponent(issuer)
|
||||
const algorithm = 'SHA1'
|
||||
const period = '30'
|
||||
const digits = '6'
|
||||
|
||||
const uri = `otpauth://${type}/${issuer}:${account}?secret=${secret}&issuer=${issuer}&algorithm=${algorithm}&digits=${digits}&period=${period}`
|
||||
|
||||
return uri
|
||||
}
|
||||
|
||||
interface QRProps {
|
||||
account: string
|
||||
secret: string
|
||||
uri: string
|
||||
}
|
||||
|
||||
const QrCodeAuth = (props: QRProps) => {
|
||||
const { Canvas } = useQRCode()
|
||||
const URI = makeURI(props.account, props.secret)
|
||||
console.log('URI:', URI)
|
||||
const defaultURI = 'otpauth://totp/zkAuth:zkAuth?secret='
|
||||
|
||||
return (
|
||||
<div className="flex justify-center">
|
||||
<Canvas
|
||||
text={URI}
|
||||
text={props.uri == '' ? defaultURI : props.uri}
|
||||
options={{
|
||||
type: 'image/jpeg',
|
||||
quality: 0.3,
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { ArrowUturnLeftIcon } from '@heroicons/react/24/outline'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { ThreeDots } from 'react-loader-spinner'
|
||||
|
||||
import { useEthers } from '@usedapp/core'
|
||||
import { ethers } from 'ethers'
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import { usePinInput, PinInputActions } from 'react-pin-input-hook'
|
||||
import { ModalVerifyTotp, QrCodeAuth } from './'
|
||||
|
||||
var jsotp = require('jsotp')
|
||||
var base32 = require('thirty-two')
|
||||
import { prepareMerkleTree, generateInput } from '../../helpers/utils'
|
||||
import {
|
||||
connectFactory,
|
||||
connectTOTPVerifier,
|
||||
deployZkOTPValidator,
|
||||
deployZkWallet,
|
||||
zkTimestampProof,
|
||||
} from '../../helpers/contracts'
|
||||
|
||||
interface TotpSetupProps {
|
||||
setAuthType: (arg: string) => void
|
||||
@@ -14,19 +24,22 @@ interface TotpSetupProps {
|
||||
const TotpSetup = (props: TotpSetupProps) => {
|
||||
const { account, library: provider } = useEthers()
|
||||
|
||||
// Secret State Management
|
||||
const [secret, setSecret] = useState('')
|
||||
// URI State Management
|
||||
const [uri, setUri] = useState('')
|
||||
const [blur, setBlur] = useState('opacity-50 blur-sm')
|
||||
const loadSecret = async (e: React.FormEvent<HTMLButtonElement>) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const createTOTPWallet = async (e: React.FormEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault()
|
||||
if (provider != undefined) {
|
||||
const signer = provider.getSigner()
|
||||
const signature = await signer.signMessage('zkAuth') // TODO: Random Input? ZK?
|
||||
const secretEncoded = base32
|
||||
.encode(signature)
|
||||
.toString()
|
||||
.replace(/=/g, '')
|
||||
setSecret(secretEncoded)
|
||||
setLoading(true)
|
||||
if (provider && account) {
|
||||
const [URI, _, root] = await prepareMerkleTree(account)
|
||||
|
||||
connectFactory(provider)
|
||||
const otpValidator = await deployZkOTPValidator(root, provider)
|
||||
await deployZkWallet(otpValidator, root, provider)
|
||||
|
||||
setUri(URI)
|
||||
setBlur('')
|
||||
}
|
||||
}
|
||||
@@ -44,7 +57,7 @@ const TotpSetup = (props: TotpSetupProps) => {
|
||||
placeholder: '•',
|
||||
})
|
||||
|
||||
function verifyCode(e: React.FormEvent<HTMLButtonElement>) {
|
||||
const verifyCode = async (e: React.FormEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault()
|
||||
// Check if there is at least one empty field. If there is, the input is considered empty.
|
||||
if (pin.includes('')) {
|
||||
@@ -53,15 +66,33 @@ const TotpSetup = (props: TotpSetupProps) => {
|
||||
// We set the focus on the first empty field if `error: true` was passed as a parameter in `options`.
|
||||
actionRef.current?.focus()
|
||||
}
|
||||
const verifier = jsotp.TOTP(secret)
|
||||
if (verifier.verify(pin.join(''))) {
|
||||
setVerified(true)
|
||||
} else {
|
||||
setVerified(false)
|
||||
|
||||
if (provider && account) {
|
||||
const totpObject = await generateInput(pin.join(''))
|
||||
if (totpObject) {
|
||||
connectTOTPVerifier(provider, account)
|
||||
try {
|
||||
const tx = await zkTimestampProof(totpObject)
|
||||
await tx.wait()
|
||||
setVerified(true)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
setVerified(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!account) return null
|
||||
// Manage theme hydration
|
||||
const { theme } = useTheme()
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
useEffect(() => {
|
||||
if (theme) {
|
||||
setLoaded(true)
|
||||
}
|
||||
})
|
||||
|
||||
if (!account || !loaded) return null
|
||||
return (
|
||||
<div className="relative w-full max-w-sm bg-white rounded-lg border border-gray-200 shadow-md p-6 md:p-8 dark:bg-gray-800 dark:border-gray-700">
|
||||
<div className="absolute top-0 right-0 hidden pt-4 pr-4 sm:block">
|
||||
@@ -80,14 +111,26 @@ const TotpSetup = (props: TotpSetupProps) => {
|
||||
</div>
|
||||
<div className="relative flex justify-center items-center">
|
||||
<div className={blur}>
|
||||
<QrCodeAuth account={account} secret={secret} />
|
||||
<QrCodeAuth uri={uri} />
|
||||
</div>
|
||||
{secret == '' ? (
|
||||
{uri == '' ? (
|
||||
<button
|
||||
className="absolute w-1/2 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
onClick={(e) => loadSecret(e)}
|
||||
className="absolute w-1/2 h-10 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
||||
onClick={(e) => createTOTPWallet(e)}
|
||||
>
|
||||
Set up 2FA
|
||||
{loading ? (
|
||||
<div className="flex justify-center">
|
||||
<ThreeDots
|
||||
height="20"
|
||||
width="35"
|
||||
radius="9"
|
||||
color={theme == 'dark' ? '#ffffff' : '#3b83f6'}
|
||||
ariaLabel="three-dots-loading"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div>Set up 2FA</div>
|
||||
)}
|
||||
</button>
|
||||
) : (
|
||||
<></>
|
||||
|
||||
@@ -5,7 +5,9 @@ import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
ArrowRightOnRectangleIcon,
|
||||
} from '@heroicons/react/20/solid'
|
||||
import { AiOutlineDashboard } from 'react-icons/ai'
|
||||
import { shortenAddress, useEthers, useLookupAddress } from '@usedapp/core'
|
||||
import Link from 'next/link'
|
||||
|
||||
function classNames(...classes: any) {
|
||||
return classes.filter(Boolean).join(' ')
|
||||
@@ -66,26 +68,27 @@ const DropdownAccount = (props: DropdownProps) => {
|
||||
</a>
|
||||
)}
|
||||
</Menu.Item>
|
||||
{/* <Menu.Item>
|
||||
<Menu.Item>
|
||||
{({ active }) => (
|
||||
<a
|
||||
className={classNames(
|
||||
active
|
||||
? "bg-gray-100 text-gray-900 dark:bg-gray-700 dark:text-gray-100"
|
||||
: "text-gray-700 dark:text-gray-300",
|
||||
"group flex items-center px-4 py-2 text-sm"
|
||||
)}
|
||||
onClick={() => deactivate()}
|
||||
>
|
||||
<ArrowRightOnRectangleIcon
|
||||
className="mr-3 h-5 w-5 text-gray-400
|
||||
<Link href="/dashboard">
|
||||
<a
|
||||
className={classNames(
|
||||
active
|
||||
? 'bg-gray-100 text-gray-900 dark:bg-gray-700 dark:text-gray-100'
|
||||
: 'text-gray-700 dark:text-gray-300',
|
||||
'group flex items-center px-4 py-2 text-sm'
|
||||
)}
|
||||
>
|
||||
<AiOutlineDashboard
|
||||
className="mr-3 h-5 w-5 text-gray-400
|
||||
dark:text-gray-300 group-hover:text-gray-500 dark:group-hover:text-gray-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
Logout
|
||||
</a>
|
||||
aria-hidden="true"
|
||||
/>
|
||||
Dashboard
|
||||
</a>
|
||||
</Link>
|
||||
)}
|
||||
</Menu.Item> */}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEthers } from '@usedapp/core'
|
||||
import { useTheme } from 'next-themes'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { DropdownAccount, ToggleColorMode } from '.'
|
||||
import { ConnectWalletButton } from '..'
|
||||
@@ -22,12 +23,16 @@ const Navbar = () => {
|
||||
zkAuth
|
||||
</span> */}
|
||||
{loaded ? (
|
||||
<Image
|
||||
src="/zkAuth.svg"
|
||||
height={50}
|
||||
width={100}
|
||||
className={`filter-logo-${theme}`}
|
||||
/>
|
||||
<Link href="/">
|
||||
<a>
|
||||
<Image
|
||||
src="/zkAuth.svg"
|
||||
height={50}
|
||||
width={100}
|
||||
className={`filter-logo-${theme}`}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
||||
237
dapp/components/recovery/RecoveryBox.tsx
Normal file
237
dapp/components/recovery/RecoveryBox.tsx
Normal file
@@ -0,0 +1,237 @@
|
||||
import {
|
||||
ArrowUturnLeftIcon,
|
||||
CheckIcon,
|
||||
XMarkIcon,
|
||||
} from '@heroicons/react/24/outline'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { ethers } from 'ethers'
|
||||
import { AlchemyProvider } from '@ethersproject/providers'
|
||||
import { shortenAddress, useEthers, useResolveName } from '@usedapp/core'
|
||||
import { ThreeDots } from 'react-loader-spinner'
|
||||
import { useTheme } from 'next-themes'
|
||||
import Link from 'next/link'
|
||||
|
||||
const RecoveryBox = () => {
|
||||
const { account, library: provider } = useEthers()
|
||||
|
||||
// PIN state management
|
||||
const [password, setPassword] = useState('')
|
||||
|
||||
// Set password to blockchain
|
||||
const onSubmit = (e: React.FormEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
// Setting Infura Provider TODO: Optimize
|
||||
let providerIsSet = false
|
||||
const [alchemyProvider, setInfuraProvider] = useState<
|
||||
AlchemyProvider | undefined
|
||||
>()
|
||||
useEffect(() => {
|
||||
if (!providerIsSet) {
|
||||
const infura = new AlchemyProvider('homestead', process.env.API_KEY)
|
||||
setInfuraProvider(infura)
|
||||
providerIsSet = true
|
||||
}
|
||||
}, [providerIsSet])
|
||||
|
||||
interface Account {
|
||||
[address: string]: string
|
||||
ens: string
|
||||
verified: string
|
||||
value: string
|
||||
}
|
||||
const [accounts, setAccount] = useState<Account>({
|
||||
address: '',
|
||||
ens: '',
|
||||
verified: '',
|
||||
value: '',
|
||||
})
|
||||
|
||||
// Sets the address when input changes value
|
||||
const setAddress = (name: string) => {
|
||||
//TODO: Extra fromatting
|
||||
if (name.includes('.')) {
|
||||
setAccount({
|
||||
...accounts,
|
||||
address: '',
|
||||
ens: name,
|
||||
verified: '',
|
||||
value: name,
|
||||
})
|
||||
} else {
|
||||
setAccount({
|
||||
...accounts,
|
||||
address: name,
|
||||
ens: '',
|
||||
verified: '',
|
||||
value: name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const verifyAccount = async () => {
|
||||
setAccount({
|
||||
...accounts,
|
||||
verified: 'loading',
|
||||
})
|
||||
|
||||
// TODO: Verify if account has indeed requested recovery
|
||||
|
||||
if (alchemyProvider) {
|
||||
// Get address from ENS if exists
|
||||
const addressfromENS = await alchemyProvider.resolveName(accounts['ens'])
|
||||
const isValidAccount = ethers.utils.isAddress(accounts['address'])
|
||||
|
||||
// We verify if either ENS or address are correctly set and modify states
|
||||
if (addressfromENS) {
|
||||
setAccount({
|
||||
...accounts,
|
||||
address: addressfromENS,
|
||||
verified: 'verified',
|
||||
value: `${accounts['ens']} (${shortenAddress(addressfromENS)})`,
|
||||
})
|
||||
} else if (isValidAccount) {
|
||||
const ensFromAdddress = await alchemyProvider.lookupAddress(
|
||||
accounts['address']
|
||||
)
|
||||
setAccount({
|
||||
...accounts,
|
||||
ens: ensFromAdddress ?? '',
|
||||
verified: 'verified',
|
||||
value: ensFromAdddress
|
||||
? `${ensFromAdddress} (${shortenAddress(accounts['address'])})`
|
||||
: accounts['address'],
|
||||
})
|
||||
} else {
|
||||
setAccount({
|
||||
...accounts,
|
||||
verified: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Manage theme hydration
|
||||
const { theme } = useTheme()
|
||||
const [loaded, setLoaded] = useState(false)
|
||||
useEffect(() => {
|
||||
if (theme) {
|
||||
setLoaded(true)
|
||||
}
|
||||
})
|
||||
if (!loaded) return null
|
||||
|
||||
//if (!account) return null
|
||||
return (
|
||||
<div className="relative w-full max-w-md bg-white rounded-lg border border-gray-200 shadow-md p-6 md:p-8 dark:bg-gray-800 dark:border-gray-700">
|
||||
<div className="absolute top-0 right-0 hidden pt-4 pr-4 sm:block">
|
||||
<Link href="/">
|
||||
<a className="absolute top-3 right-2.5 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-800 dark:hover:text-white">
|
||||
<span className="sr-only">Back</span>
|
||||
<ArrowUturnLeftIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
<form className="space-y-6 mb-2" action="#">
|
||||
<h5 className="text-2xl font-medium flex justify-center text-gray-900 dark:text-white">
|
||||
Validate Account Recovery
|
||||
</h5>
|
||||
|
||||
<div>
|
||||
<label
|
||||
htmlFor="text"
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300"
|
||||
>
|
||||
Address or ENS domain to recover
|
||||
</label>
|
||||
<div
|
||||
className={`w-full flex flex-row items-center h-14 p-2 rounded-lg
|
||||
bg-gray-50 border border-gray-300 text-gray-900 dark:bg-gray-600 dark:border-gray-500 dark:text-white focus-within:outline focus-within:outline-2 ${
|
||||
accounts['verified'] == 'error'
|
||||
? 'outline outline-2 outline-red-500 dark:outline-red-500 focus-within:outline-red-500 dark:focus-within:outline-red-500'
|
||||
: 'focus-within:outline-blue-500 dark:focus-within:outline-blue-500'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
id="account"
|
||||
name="account"
|
||||
type="text"
|
||||
className="w-5/6 border-none bg-transparent dark:bg-transparent outline-0 focus:ring-0 placeholder-gray-300 dark:placeholder-gray-500"
|
||||
placeholder="0x000...0000 or vitalik.eth"
|
||||
value={accounts['value']}
|
||||
onChange={(e) => setAddress(e.target.value)}
|
||||
/>
|
||||
{{
|
||||
verified: (
|
||||
<div className="mx-auto flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-green-200">
|
||||
<CheckIcon
|
||||
className="h-6 w-6 text-green-600"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
error: (
|
||||
<div className="mx-auto flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-red-200">
|
||||
<XMarkIcon
|
||||
className="h-6 w-6 text-red-600"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
loading: (
|
||||
<div className="mx-auto">
|
||||
<ThreeDots
|
||||
height="35"
|
||||
width="35"
|
||||
radius="9"
|
||||
color={theme == 'dark' ? '#ffffff' : '#3b83f6'}
|
||||
ariaLabel="three-dots-loading"
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
}[accounts['verified']] || (
|
||||
<button
|
||||
className="w-1/6 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 px-2 py-2 mx-auto"
|
||||
onClick={() => verifyAccount()}
|
||||
>
|
||||
Verify
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
htmlFor="password"
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
name="password"
|
||||
type="text"
|
||||
className="w-full p-2.5 mb-4 rounded-lg
|
||||
bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white"
|
||||
placeholder="••••••••"
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
|
||||
disabled:opacity-25"
|
||||
onClick={(e) => onSubmit(e)}
|
||||
disabled={accounts['verified'] != 'verified'}
|
||||
>
|
||||
Confirm Recovery
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default RecoveryBox
|
||||
1
dapp/components/recovery/index.ts
Normal file
1
dapp/components/recovery/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as RecoveryBox } from './RecoveryBox'
|
||||
1
dapp/globals.d.ts
vendored
1
dapp/globals.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
declare module 'circomlibjs'
|
||||
declare module 'totp-generator'
|
||||
declare module 'crypto-browserify'
|
||||
declare module 'snarkjs'
|
||||
|
||||
45
dapp/helpers/circuits/generate_calldata.ts
Normal file
45
dapp/helpers/circuits/generate_calldata.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/* global BigInt */
|
||||
|
||||
import { generateWitness } from './generate_witness'
|
||||
import { groth16 } from 'snarkjs'
|
||||
|
||||
export async function generateCalldata(input: Object, circuit_name: string) {
|
||||
let generateWitnessSuccess = true
|
||||
|
||||
let witness = await generateWitness(input, circuit_name)
|
||||
.then()
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
generateWitnessSuccess = false
|
||||
})
|
||||
|
||||
//console.log(witness);
|
||||
|
||||
if (!generateWitnessSuccess) {
|
||||
return
|
||||
}
|
||||
|
||||
const { proof, publicSignals } = await groth16.prove(
|
||||
`${circuit_name}_circuit_final.zkey`,
|
||||
witness
|
||||
)
|
||||
|
||||
const calldata = await groth16.exportSolidityCallData(proof, publicSignals)
|
||||
|
||||
const argv = calldata
|
||||
.replace(/["[\]\s]/g, '')
|
||||
.split(',')
|
||||
.map((x: any) => BigInt(x).toString())
|
||||
|
||||
//console.log(argv);
|
||||
|
||||
const a = [argv[0], argv[1]]
|
||||
const b = [
|
||||
[argv[2], argv[3]],
|
||||
[argv[4], argv[5]],
|
||||
]
|
||||
const c = [argv[6], argv[7]]
|
||||
const Input = argv.slice(8)
|
||||
|
||||
return [a, b, c, Input]
|
||||
}
|
||||
13
dapp/helpers/circuits/generate_witness.ts
Normal file
13
dapp/helpers/circuits/generate_witness.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import wc from './witness_calculator'
|
||||
|
||||
export async function generateWitness(input: Object, circuit_name: string) {
|
||||
const response = await fetch(`${circuit_name}_circuit.wasm`)
|
||||
const buffer = await response.arrayBuffer()
|
||||
//console.log(buffer);
|
||||
let buff
|
||||
|
||||
await wc(buffer).then(async (witnessCalculator) => {
|
||||
buff = await witnessCalculator.calculateWTNSBin(input, 0)
|
||||
})
|
||||
return buff
|
||||
}
|
||||
292
dapp/helpers/circuits/witness_calculator.js
Normal file
292
dapp/helpers/circuits/witness_calculator.js
Normal file
@@ -0,0 +1,292 @@
|
||||
/* global BigInt */
|
||||
module.exports = async function builder(code, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
const wasmModule = await WebAssembly.compile(code);
|
||||
|
||||
let wc;
|
||||
|
||||
|
||||
const instance = await WebAssembly.instantiate(wasmModule, {
|
||||
runtime: {
|
||||
exceptionHandler: function (code) {
|
||||
let errStr;
|
||||
if (code === 1) {
|
||||
errStr = "Signal not found. ";
|
||||
} else if (code === 2) {
|
||||
errStr = "Too many signals set. ";
|
||||
} else if (code === 3) {
|
||||
errStr = "Signal already set. ";
|
||||
} else if (code === 4) {
|
||||
errStr = "Assert Failed. ";
|
||||
} else if (code === 5) {
|
||||
errStr = "Not enough memory. ";
|
||||
} else {
|
||||
errStr = "Unknown error\n";
|
||||
}
|
||||
// get error message from wasm
|
||||
errStr += getMessage();
|
||||
throw new Error(errStr);
|
||||
},
|
||||
showSharedRWMemory: function () {
|
||||
printSharedRWMemory();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
const sanityCheck =
|
||||
options
|
||||
// options &&
|
||||
// (
|
||||
// options.sanityCheck ||
|
||||
// options.logGetSignal ||
|
||||
// options.logSetSignal ||
|
||||
// options.logStartComponent ||
|
||||
// options.logFinishComponent
|
||||
// );
|
||||
|
||||
|
||||
wc = new WitnessCalculator(instance, sanityCheck);
|
||||
return wc;
|
||||
|
||||
function getMessage() {
|
||||
var message = "";
|
||||
var c = instance.exports.getMessageChar();
|
||||
while (c !== 0) {
|
||||
message += String.fromCharCode(c);
|
||||
c = instance.exports.getMessageChar();
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
function printSharedRWMemory() {
|
||||
const shared_rw_memory_size = instance.exports.getFieldNumLen32();
|
||||
const arr = new Uint32Array(shared_rw_memory_size);
|
||||
for (let j = 0; j < shared_rw_memory_size; j++) {
|
||||
arr[shared_rw_memory_size - 1 - j] = instance.exports.readSharedRWMemory(j);
|
||||
}
|
||||
console.log(fromArray32(arr));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class WitnessCalculator {
|
||||
constructor(instance, sanityCheck) {
|
||||
this.instance = instance;
|
||||
|
||||
this.version = this.instance.exports.getVersion();
|
||||
this.n32 = this.instance.exports.getFieldNumLen32();
|
||||
|
||||
this.instance.exports.getRawPrime();
|
||||
const arr = new Array(this.n32);
|
||||
for (let i = 0; i < this.n32; i++) {
|
||||
arr[this.n32 - 1 - i] = this.instance.exports.readSharedRWMemory(i);
|
||||
}
|
||||
this.prime = fromArray32(arr);
|
||||
|
||||
this.witnessSize = this.instance.exports.getWitnessSize();
|
||||
|
||||
this.sanityCheck = sanityCheck;
|
||||
}
|
||||
|
||||
circom_version() {
|
||||
return this.instance.exports.getVersion();
|
||||
}
|
||||
|
||||
async _doCalculateWitness(input, sanityCheck) {
|
||||
//input is assumed to be a map from signals to arrays of bigints
|
||||
|
||||
this.instance.exports.init((this.sanityCheck || sanityCheck) ? 1 : 0);
|
||||
const keys = Object.keys(input);
|
||||
var input_counter = 0;
|
||||
keys.forEach((k) => {
|
||||
const h = fnvHash(k);
|
||||
const hMSB = parseInt(h.slice(0, 8), 16);
|
||||
const hLSB = parseInt(h.slice(8, 16), 16);
|
||||
const fArr = flatArray(input[k]);
|
||||
for (let i = 0; i < fArr.length; i++) {
|
||||
const arrFr = toArray32(fArr[i], this.n32)
|
||||
for (let j = 0; j < this.n32; j++) {
|
||||
this.instance.exports.writeSharedRWMemory(j, arrFr[this.n32 - 1 - j]);
|
||||
}
|
||||
try {
|
||||
this.instance.exports.setInputSignal(hMSB, hLSB, i);
|
||||
input_counter++;
|
||||
} catch (err) {
|
||||
// console.log(`After adding signal ${i} of ${k}`)
|
||||
throw new Error(err);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
if (input_counter < this.instance.exports.getInputSize()) {
|
||||
throw new Error(`Not all inputs have been set. Only ${input_counter} out of ${this.instance.exports.getInputSize()}`);
|
||||
}
|
||||
}
|
||||
|
||||
async calculateWitness(input, sanityCheck) {
|
||||
|
||||
const w = [];
|
||||
|
||||
await this._doCalculateWitness(input, sanityCheck);
|
||||
|
||||
for (let i = 0; i < this.witnessSize; i++) {
|
||||
this.instance.exports.getWitness(i);
|
||||
const arr = new Uint32Array(this.n32);
|
||||
for (let j = 0; j < this.n32; j++) {
|
||||
arr[this.n32 - 1 - j] = this.instance.exports.readSharedRWMemory(j);
|
||||
}
|
||||
w.push(fromArray32(arr));
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
async calculateBinWitness(input, sanityCheck) {
|
||||
|
||||
const buff32 = new Uint32Array(this.witnessSize * this.n32);
|
||||
const buff = new Uint8Array(buff32.buffer);
|
||||
await this._doCalculateWitness(input, sanityCheck);
|
||||
|
||||
for (let i = 0; i < this.witnessSize; i++) {
|
||||
this.instance.exports.getWitness(i);
|
||||
const pos = i * this.n32;
|
||||
for (let j = 0; j < this.n32; j++) {
|
||||
buff32[pos + j] = this.instance.exports.readSharedRWMemory(j);
|
||||
}
|
||||
}
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
|
||||
async calculateWTNSBin(input, sanityCheck) {
|
||||
|
||||
const buff32 = new Uint32Array(this.witnessSize * this.n32 + this.n32 + 11);
|
||||
|
||||
const buff = new Uint8Array(buff32.buffer);
|
||||
await this._doCalculateWitness(input, sanityCheck);
|
||||
|
||||
//"wtns"
|
||||
buff[0] = "w".charCodeAt(0)
|
||||
buff[1] = "t".charCodeAt(0)
|
||||
buff[2] = "n".charCodeAt(0)
|
||||
buff[3] = "s".charCodeAt(0)
|
||||
|
||||
//version 2
|
||||
buff32[1] = 2;
|
||||
|
||||
//number of sections: 2
|
||||
buff32[2] = 2;
|
||||
|
||||
//id section 1
|
||||
buff32[3] = 1;
|
||||
|
||||
const n8 = this.n32 * 4;
|
||||
//id section 1 length in 64bytes
|
||||
const idSection1length = 8 + n8;
|
||||
const idSection1lengthHex = idSection1length.toString(16);
|
||||
buff32[4] = parseInt(idSection1lengthHex.slice(0, 8), 16);
|
||||
buff32[5] = parseInt(idSection1lengthHex.slice(8, 16), 16);
|
||||
|
||||
//this.n32
|
||||
buff32[6] = n8;
|
||||
|
||||
//prime number
|
||||
this.instance.exports.getRawPrime();
|
||||
|
||||
var pos = 7;
|
||||
for (let j = 0; j < this.n32; j++) {
|
||||
buff32[pos + j] = this.instance.exports.readSharedRWMemory(j);
|
||||
}
|
||||
pos += this.n32;
|
||||
|
||||
// witness size
|
||||
buff32[pos] = this.witnessSize;
|
||||
pos++;
|
||||
|
||||
//id section 2
|
||||
buff32[pos] = 2;
|
||||
pos++;
|
||||
|
||||
// section 2 length
|
||||
const idSection2length = n8 * this.witnessSize;
|
||||
const idSection2lengthHex = idSection2length.toString(16);
|
||||
buff32[pos] = parseInt(idSection2lengthHex.slice(0, 8), 16);
|
||||
buff32[pos + 1] = parseInt(idSection2lengthHex.slice(8, 16), 16);
|
||||
|
||||
pos += 2;
|
||||
for (let i = 0; i < this.witnessSize; i++) {
|
||||
this.instance.exports.getWitness(i);
|
||||
for (let j = 0; j < this.n32; j++) {
|
||||
buff32[pos + j] = this.instance.exports.readSharedRWMemory(j);
|
||||
}
|
||||
pos += this.n32;
|
||||
}
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function toArray32(s, size) {
|
||||
const res = []; //new Uint32Array(size); //has no unshift
|
||||
let rem = BigInt(s);
|
||||
const radix = BigInt(0x100000000);
|
||||
while (rem) {
|
||||
res.unshift(Number(rem % radix));
|
||||
rem = rem / radix;
|
||||
}
|
||||
if (size) {
|
||||
var i = size - res.length;
|
||||
while (i > 0) {
|
||||
res.unshift(0);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function fromArray32(arr) { //returns a BigInt
|
||||
var res = BigInt(0);
|
||||
const radix = BigInt(0x100000000);
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
res = res * radix + BigInt(arr[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function flatArray(a) {
|
||||
var res = [];
|
||||
fillArray(res, a);
|
||||
return res;
|
||||
|
||||
function fillArray(res, a) {
|
||||
if (Array.isArray(a)) {
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
fillArray(res, a[i]);
|
||||
}
|
||||
} else {
|
||||
res.push(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fnvHash(str) {
|
||||
let uint64_max = 18446744073709551616n;
|
||||
// let uint64_max = BigInt(2) ** BigInt(64);
|
||||
let hash = BigInt("0xCBF29CE484222325");
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
hash ^= BigInt(str[i].charCodeAt());
|
||||
hash *= BigInt(0x100000001B3);
|
||||
hash %= uint64_max;
|
||||
}
|
||||
let shash = hash.toString(16);
|
||||
let n = 16 - shash.length;
|
||||
shash = '0'.repeat(n).concat(shash);
|
||||
return shash;
|
||||
}
|
||||
150
dapp/helpers/contracts.ts
Normal file
150
dapp/helpers/contracts.ts
Normal file
@@ -0,0 +1,150 @@
|
||||
import { ethers } from 'ethers'
|
||||
import { address } from '../../backend/config'
|
||||
import { generateCalldata } from './circuits/generate_calldata'
|
||||
|
||||
import zkWalletFactoryJson from '../../backend/artifacts/contracts/ZkWalletFactory.sol/ZkWalletFactory.json'
|
||||
|
||||
import ZkOtpValidatorJson from '../../backend/artifacts/contracts/ZkOtpValidator.sol/ZkOtpValidator.json'
|
||||
|
||||
import ZkWalletJson from '../../backend/artifacts/contracts/ZkSocialRecoveryWallet.sol/ZkSocialRecoveryWallet.json'
|
||||
|
||||
let zkWalletFactory: ethers.Contract
|
||||
let ZkOtpValidator: ethers.Contract
|
||||
|
||||
export async function connectTOTPVerifier(
|
||||
provider: ethers.providers.JsonRpcProvider,
|
||||
account: string
|
||||
) {
|
||||
let signer = provider.getSigner()
|
||||
// We connect to get wallet address
|
||||
const ifaceFactory = new ethers.utils.Interface(zkWalletFactoryJson.abi)
|
||||
|
||||
zkWalletFactory = new ethers.Contract(
|
||||
address['zkWalletFactory'],
|
||||
ifaceFactory,
|
||||
signer
|
||||
)
|
||||
|
||||
const walletAddress = await zkWalletFactory.userAddressToWalletAddress(
|
||||
account
|
||||
)
|
||||
|
||||
// We retrieve zk totp verificator address
|
||||
const ifaceWallet = new ethers.utils.Interface(ZkWalletJson.abi)
|
||||
|
||||
const zkWallet = new ethers.Contract(walletAddress, ifaceWallet, signer)
|
||||
const zkOtpValidatorAddress = await zkWallet.otpVerifierAddress()
|
||||
|
||||
const iface = new ethers.utils.Interface(ZkOtpValidatorJson.abi)
|
||||
ZkOtpValidator = new ethers.Contract(zkOtpValidatorAddress, iface, signer)
|
||||
|
||||
console.log('Connect to zkOTP Contract:', ZkOtpValidator)
|
||||
}
|
||||
|
||||
export function connectFactory(provider: ethers.providers.JsonRpcProvider) {
|
||||
let signer = provider.getSigner()
|
||||
|
||||
const iface = new ethers.utils.Interface(zkWalletFactoryJson.abi)
|
||||
|
||||
zkWalletFactory = new ethers.Contract(
|
||||
address['zkWalletFactory'],
|
||||
iface,
|
||||
signer
|
||||
)
|
||||
console.log('Connect to ZkWalletFactory Contract:', zkWalletFactory)
|
||||
return zkWalletFactory
|
||||
}
|
||||
|
||||
export async function deployZkOTPValidator(
|
||||
root: BigInt,
|
||||
provider: ethers.providers.JsonRpcProvider
|
||||
) {
|
||||
const iface = new ethers.utils.Interface(ZkOtpValidatorJson.abi)
|
||||
let signer = provider.getSigner()
|
||||
const ZkOTPValidatorFactory = new ethers.ContractFactory(
|
||||
iface,
|
||||
ZkOtpValidatorJson.bytecode,
|
||||
signer
|
||||
)
|
||||
|
||||
const ZkOTPValidator = await ZkOTPValidatorFactory.deploy(
|
||||
root,
|
||||
address['OtpMerkleTreeVerifier']
|
||||
)
|
||||
|
||||
localStorage.setItem('ZkOTPValidator Address', ZkOTPValidator.address)
|
||||
|
||||
return ZkOTPValidator.address
|
||||
}
|
||||
|
||||
export async function deployZkWallet(
|
||||
otpVerifier: string,
|
||||
root: BigInt,
|
||||
provider: ethers.providers.JsonRpcProvider
|
||||
) {
|
||||
connectFactory(provider)
|
||||
|
||||
const zkWalletFactoryContract = await zkWalletFactory.deployWallet(
|
||||
0,
|
||||
[],
|
||||
[],
|
||||
0,
|
||||
otpVerifier,
|
||||
root
|
||||
)
|
||||
|
||||
return zkWalletFactoryContract.address
|
||||
}
|
||||
|
||||
// export async function zkProof(input: Object) {
|
||||
|
||||
// let calldata = await generateCalldata(input);
|
||||
// let tx;
|
||||
|
||||
// if (calldata) {
|
||||
// tx = await otp.naiveApproval(calldata[0], calldata[1], calldata[2], calldata[3])
|
||||
// .catch((error: any) => {
|
||||
// console.log(error);
|
||||
// let errorMsg;
|
||||
// if (error.reason) {
|
||||
// errorMsg = error.reason;
|
||||
// } else if (error.data.message) {
|
||||
// errorMsg = error.data.message;
|
||||
// } else {
|
||||
// errorMsg = "Unknown error."
|
||||
// }
|
||||
// throw errorMsg;
|
||||
// });
|
||||
// } else {
|
||||
// throw new Error("Witness generation failed.");
|
||||
// }
|
||||
// return tx;
|
||||
// }
|
||||
|
||||
export async function zkTimestampProof(input: Object) {
|
||||
let calldata = await generateCalldata(input, 'otp_verification')
|
||||
let tx
|
||||
|
||||
if (calldata) {
|
||||
tx = await ZkOtpValidator.verifyOTP(
|
||||
calldata[0],
|
||||
calldata[1],
|
||||
calldata[2],
|
||||
calldata[3]
|
||||
).catch((error: any) => {
|
||||
console.log(error)
|
||||
let errorMsg
|
||||
if (error.reason) {
|
||||
errorMsg = error.reason
|
||||
} else if (error.data.message) {
|
||||
errorMsg = error.data.message
|
||||
} else {
|
||||
errorMsg = 'Unknown error.'
|
||||
}
|
||||
throw errorMsg
|
||||
})
|
||||
} else {
|
||||
throw new Error('Witness generation failed.')
|
||||
}
|
||||
return tx
|
||||
}
|
||||
@@ -4,25 +4,23 @@ import { buildPoseidon } from 'circomlibjs'
|
||||
import totp from 'totp-generator'
|
||||
import crypto from 'crypto-browserify'
|
||||
import base32 from 'hi-base32'
|
||||
import QRCode from 'qrcode'
|
||||
import { ethers } from 'ethers'
|
||||
import { encrypt, EthEncryptedData } from 'eth-sig-util'
|
||||
|
||||
const uriPrefix = 'otpauth://totp/zkAuth:account?secret='
|
||||
const uriSuffix = '&issuer=zkAuth'
|
||||
|
||||
/**
|
||||
* Prepares Merkle Tree of hashes of [time, OTP(time)] and stores it on storage
|
||||
*
|
||||
* @returns an array containing the uri of TOTP, the secret of the TOTP, the root of the merkle tree and the encrypted hashes
|
||||
*/
|
||||
export async function prepareMerkleTree() {
|
||||
export async function prepareMerkleTree(
|
||||
address: string
|
||||
): Promise<[string, string, BigInt]> {
|
||||
const SECRET = prepareSecret()
|
||||
const uri = await prepareQRCode(SECRET)
|
||||
const uri = prepareURI(SECRET, address)
|
||||
|
||||
const startTime = Math.floor(Date.now() / 30000 - 1) * 30000
|
||||
let poseidon = await buildPoseidon()
|
||||
let hashes: string[] = []
|
||||
let hashes: BigInt[] = []
|
||||
let tokens: Record<number, any> = {}
|
||||
|
||||
for (let i = 0; i < 2 ** 7; i++) {
|
||||
@@ -59,7 +57,10 @@ export async function prepareMerkleTree() {
|
||||
* @param encryptedHashes - the user specific encrypted hashes
|
||||
* @returns a formatted object ready to use with contract verification
|
||||
*/
|
||||
export async function generateInput(otp: string | number, encryptedHashes: string) {
|
||||
export async function generateInput(
|
||||
otp: string | number,
|
||||
encryptedHashes: string
|
||||
) {
|
||||
// let hashes = localStorage.getItem('OTPhashes')?.split(',').map(BigInt)
|
||||
// console.log(hashes)
|
||||
const hashes = await decryptOrSignMetamask(encryptedHashes, 'eth_decrypt')
|
||||
@@ -110,8 +111,16 @@ export async function generateInput(otp: string | number, encryptedHashes: strin
|
||||
}
|
||||
}
|
||||
|
||||
async function prepareQRCode(secret: string) {
|
||||
return await QRCode.toDataURL(uriPrefix.concat(secret).concat(uriSuffix))
|
||||
function prepareURI(secret: string, address: string) {
|
||||
const type = 'totp'
|
||||
const issuer = 'zkAuth' //encodeURIComponent(issuer)
|
||||
const algorithm = 'SHA1'
|
||||
const period = '30'
|
||||
const digits = '6'
|
||||
|
||||
const uri = `otpauth://${type}/${issuer}:${address}?secret=${secret}&issuer=${issuer}&algorithm=${algorithm}&digits=${digits}&period=${period}`
|
||||
|
||||
return uri
|
||||
}
|
||||
|
||||
function prepareSecret(length = 20) {
|
||||
@@ -119,7 +128,6 @@ function prepareSecret(length = 20) {
|
||||
return base32.encode(randomBuffer).replace(/=/g, '')
|
||||
}
|
||||
|
||||
|
||||
// request MetaMask to decrypt data with the users wallet
|
||||
// decrypt DEPRECATED still works tho https://docs.metamask.io/guide/rpc-api.html#restricted-methods
|
||||
// Examples https://github.com/metamask/test-dapp
|
||||
@@ -129,7 +137,10 @@ function prepareSecret(length = 20) {
|
||||
'eth_decrypt' to decrypt
|
||||
'eth_signTypedData_v4' to sign
|
||||
*/
|
||||
export async function decryptOrSignMetamask(encryptedData: string, method: string): Promise<string | undefined> {
|
||||
export async function decryptOrSignMetamask(
|
||||
encryptedData: string,
|
||||
method: string
|
||||
): Promise<string | undefined> {
|
||||
var provider = new ethers.providers.Web3Provider(window.ethereum)
|
||||
var from = await provider.listAccounts()
|
||||
let params
|
||||
@@ -151,9 +162,9 @@ export async function decryptOrSignMetamask(encryptedData: string, method: strin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function encryptMetamask(data: string): Promise<string | undefined> {
|
||||
|
||||
export async function encryptMetamask(
|
||||
data: string
|
||||
): Promise<string | undefined> {
|
||||
// let encryptionPublicKey: string;
|
||||
var provider = new ethers.providers.Web3Provider(window.ethereum)
|
||||
var from = await provider.listAccounts()
|
||||
@@ -164,11 +175,10 @@ export async function encryptMetamask(data: string): Promise<string | undefined>
|
||||
params: [from[0]],
|
||||
})
|
||||
if (encryptionPublicKey) {
|
||||
|
||||
const encryptedData = await encrypt(
|
||||
encryptionPublicKey,
|
||||
{ data },
|
||||
'x25519-xsalsa20-poly1305',
|
||||
'x25519-xsalsa20-poly1305'
|
||||
)
|
||||
|
||||
return JSON.stringify(encryptedData)
|
||||
@@ -186,7 +196,7 @@ const msgV4 = (Message: string): string => {
|
||||
},
|
||||
// Defining the message signing data content.
|
||||
message: {
|
||||
Key: "zk-Key",
|
||||
Key: 'zk-Key',
|
||||
Message,
|
||||
},
|
||||
// Refers to the keys of the *types* object below.
|
||||
@@ -202,8 +212,8 @@ const msgV4 = (Message: string): string => {
|
||||
{ name: 'Key', type: 'string' },
|
||||
],
|
||||
},
|
||||
}
|
||||
)
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
const exampleMsg: string = "Sign this msg to provide a wallet-bound key for en-/decryption of the Merkle tree hashes used to proof your authentication with zero Knowledge. Also: plant a tree 🌳"
|
||||
const exampleMsg: string =
|
||||
'Sign this msg to provide a wallet-bound key for en-/decryption of the Merkle tree hashes used to proof your authentication with zero Knowledge. Also: plant a tree 🌳'
|
||||
|
||||
@@ -5,6 +5,14 @@ const nextConfig = {
|
||||
swcMinify: true,
|
||||
webpack: (config) => {
|
||||
config.resolve.fallback = { fs: false }
|
||||
config.resolve.extensions = ['*', '.mjs', '.js', 'jsx', '.ts', '.tsx', '.json']
|
||||
config.module.rules.push(
|
||||
{
|
||||
test: /\.mjs$/,
|
||||
include: /node_modules/,
|
||||
type: 'javascript/auto'
|
||||
})
|
||||
|
||||
|
||||
return config
|
||||
},
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"prettier": "prettier --write . --config ../.prettierrc"
|
||||
"prettier": "prettier --write . --config ../.prettierrc",
|
||||
"postinstall": "patch-package"
|
||||
},
|
||||
"dependencies": {
|
||||
"@headlessui/react": "^1.7.1",
|
||||
@@ -28,11 +29,17 @@
|
||||
"next": "12.3.0",
|
||||
"next-qrcode": "^2.2.0",
|
||||
"next-themes": "^0.2.1",
|
||||
"patch-package": "^6.4.7",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"process": "^0.11.10",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-icons": "^4.4.0",
|
||||
"react-loader-spinner": "^5.3.4",
|
||||
"react-lottie-player": "^1.4.3",
|
||||
"react-password-checklist": "^1.4.1",
|
||||
"react-pin-input-hook": "^1.0.8",
|
||||
"snarkjs": "0.4.19",
|
||||
"thirty-two": "^1.0.2",
|
||||
"totp-generator": "^0.0.13",
|
||||
"web3.storage": "^4.4.0",
|
||||
|
||||
@@ -5,10 +5,7 @@ import { ThemeProvider } from 'next-themes'
|
||||
import { DAppProvider } from '@usedapp/core'
|
||||
import { Provider as CeramicProvider } from '@self.id/react'
|
||||
|
||||
|
||||
const config = {
|
||||
multicallAddresses: ['0x'],
|
||||
}
|
||||
const config = {}
|
||||
|
||||
function MyApp({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { NextPage } from 'next'
|
||||
import { LogInBox } from '../components'
|
||||
import { Hero } from '../components'
|
||||
|
||||
const Home: NextPage = () => {
|
||||
return (
|
||||
<div className="h-[calc(100vh-100px)] flex justify-center items-center">
|
||||
<LogInBox />
|
||||
<div className="h-[calc(100vh-100px)] w-6xl flex justify-center items-center">
|
||||
<Hero />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
12
dapp/pages/login.tsx
Normal file
12
dapp/pages/login.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { NextPage } from 'next'
|
||||
import { LogInBox } from '../components'
|
||||
|
||||
const LogIn: NextPage = () => {
|
||||
return (
|
||||
<div className="h-[calc(100vh-100px)] flex justify-center items-center">
|
||||
<LogInBox />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default LogIn
|
||||
19
dapp/pages/recovery.tsx
Normal file
19
dapp/pages/recovery.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { motion } from 'framer-motion'
|
||||
import type { NextPage } from 'next'
|
||||
import { RecoveryBox } from '../components'
|
||||
|
||||
const Recovery: NextPage = () => {
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ y: 10, opacity: 0, scale: 0.9 }}
|
||||
animate={{ y: 0, opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{ duration: 0.6, ease: 'easeOut' }}
|
||||
className="h-[calc(100vh-100px)] flex justify-center items-center"
|
||||
>
|
||||
<RecoveryBox />
|
||||
</motion.div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Recovery
|
||||
190
dapp/patches/@graphql-inspector+core+3.4.0.patch
Normal file
190
dapp/patches/@graphql-inspector+core+3.4.0.patch
Normal file
@@ -0,0 +1,190 @@
|
||||
diff --git a/node_modules/@graphql-inspector/core/index.mjs b/node_modules/@graphql-inspector/core/index.mjs
|
||||
index d157994..c0ba5aa 100644
|
||||
--- a/node_modules/@graphql-inspector/core/index.mjs
|
||||
+++ b/node_modules/@graphql-inspector/core/index.mjs
|
||||
@@ -2,7 +2,7 @@ import { __awaiter } from 'tslib';
|
||||
import { Kind, TypeInfo, visit, visitWithTypeInfo, GraphQLError, getNamedType, isScalarType, isInterfaceType, isObjectType, isUnionType, isInputObjectType, isListType, isNonNullType, isWrappingType, isEnumType, parse, extendSchema, TokenKind, print, validate as validate$1, printType } from 'graphql';
|
||||
import inspect from 'object-inspect';
|
||||
import { DepGraph } from 'dependency-graph';
|
||||
-import { Parser } from 'graphql/language/parser';
|
||||
+import { Parser } from 'graphql/language/parser.js';
|
||||
|
||||
function keyMap(list, keyFn) {
|
||||
return list.reduce((map, item) => {
|
||||
@@ -1304,7 +1304,7 @@ function changesInType(oldType, newType, addChange) {
|
||||
else if (isInterfaceType(oldType) && isInterfaceType(newType)) {
|
||||
changesInInterface(oldType, newType, addChange);
|
||||
}
|
||||
- else if (isScalarType(oldType) && isScalarType(newType)) ;
|
||||
+ else if (isScalarType(oldType) && isScalarType(newType));
|
||||
else {
|
||||
addChange(typeKindChanged(oldType, newType));
|
||||
}
|
||||
@@ -1745,82 +1745,82 @@ function validate(schema, sources, options) {
|
||||
// since we include fragments, validate only operations
|
||||
.filter(doc => doc.hasOperations)
|
||||
.forEach(doc => {
|
||||
- const docWithOperations = {
|
||||
- kind: Kind.DOCUMENT,
|
||||
- definitions: doc.operations.map(d => d.node),
|
||||
- };
|
||||
- const extractedFragments = (extractFragments(print(docWithOperations)) || [])
|
||||
- // resolve all nested fragments
|
||||
- .map(fragmentName => resolveFragment(graph.getNodeData(fragmentName), graph))
|
||||
- // flatten arrays
|
||||
- .reduce((list, current) => list.concat(current), [])
|
||||
- // remove duplicates
|
||||
- .filter((def, i, all) => all.findIndex(item => item.name.value === def.name.value) === i);
|
||||
- const merged = {
|
||||
- kind: Kind.DOCUMENT,
|
||||
- definitions: [...docWithOperations.definitions, ...extractedFragments],
|
||||
- };
|
||||
- let transformedSchema = config.apollo ? transformSchemaWithApollo(schema) : schema;
|
||||
- const transformedDoc = config.apollo
|
||||
- ? transformDocumentWithApollo(merged, {
|
||||
- keepClientFields: config.keepClientFields,
|
||||
- })
|
||||
- : merged;
|
||||
- const errors = validate$1(transformedSchema, transformedDoc) || [];
|
||||
- if (config.maxDepth) {
|
||||
- const depthError = validateQueryDepth({
|
||||
- source: doc.source,
|
||||
- doc: transformedDoc,
|
||||
- maxDepth: config.maxDepth,
|
||||
- fragmentGraph: graph,
|
||||
- });
|
||||
- if (depthError) {
|
||||
- errors.push(depthError);
|
||||
+ const docWithOperations = {
|
||||
+ kind: Kind.DOCUMENT,
|
||||
+ definitions: doc.operations.map(d => d.node),
|
||||
+ };
|
||||
+ const extractedFragments = (extractFragments(print(docWithOperations)) || [])
|
||||
+ // resolve all nested fragments
|
||||
+ .map(fragmentName => resolveFragment(graph.getNodeData(fragmentName), graph))
|
||||
+ // flatten arrays
|
||||
+ .reduce((list, current) => list.concat(current), [])
|
||||
+ // remove duplicates
|
||||
+ .filter((def, i, all) => all.findIndex(item => item.name.value === def.name.value) === i);
|
||||
+ const merged = {
|
||||
+ kind: Kind.DOCUMENT,
|
||||
+ definitions: [...docWithOperations.definitions, ...extractedFragments],
|
||||
+ };
|
||||
+ let transformedSchema = config.apollo ? transformSchemaWithApollo(schema) : schema;
|
||||
+ const transformedDoc = config.apollo
|
||||
+ ? transformDocumentWithApollo(merged, {
|
||||
+ keepClientFields: config.keepClientFields,
|
||||
+ })
|
||||
+ : merged;
|
||||
+ const errors = validate$1(transformedSchema, transformedDoc) || [];
|
||||
+ if (config.maxDepth) {
|
||||
+ const depthError = validateQueryDepth({
|
||||
+ source: doc.source,
|
||||
+ doc: transformedDoc,
|
||||
+ maxDepth: config.maxDepth,
|
||||
+ fragmentGraph: graph,
|
||||
+ });
|
||||
+ if (depthError) {
|
||||
+ errors.push(depthError);
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
- if (config.maxAliasCount) {
|
||||
- const aliasError = validateAliasCount({
|
||||
- source: doc.source,
|
||||
- doc: transformedDoc,
|
||||
- maxAliasCount: config.maxAliasCount,
|
||||
- fragmentGraph: graph,
|
||||
- });
|
||||
- if (aliasError) {
|
||||
- errors.push(aliasError);
|
||||
+ if (config.maxAliasCount) {
|
||||
+ const aliasError = validateAliasCount({
|
||||
+ source: doc.source,
|
||||
+ doc: transformedDoc,
|
||||
+ maxAliasCount: config.maxAliasCount,
|
||||
+ fragmentGraph: graph,
|
||||
+ });
|
||||
+ if (aliasError) {
|
||||
+ errors.push(aliasError);
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
- if (config.maxDirectiveCount) {
|
||||
- const directiveError = validateDirectiveCount({
|
||||
- source: doc.source,
|
||||
- doc: transformedDoc,
|
||||
- maxDirectiveCount: config.maxDirectiveCount,
|
||||
- fragmentGraph: graph,
|
||||
- });
|
||||
- if (directiveError) {
|
||||
- errors.push(directiveError);
|
||||
+ if (config.maxDirectiveCount) {
|
||||
+ const directiveError = validateDirectiveCount({
|
||||
+ source: doc.source,
|
||||
+ doc: transformedDoc,
|
||||
+ maxDirectiveCount: config.maxDirectiveCount,
|
||||
+ fragmentGraph: graph,
|
||||
+ });
|
||||
+ if (directiveError) {
|
||||
+ errors.push(directiveError);
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
- if (config.maxTokenCount) {
|
||||
- const tokenCountError = validateTokenCount({
|
||||
- source: doc.source,
|
||||
- document: transformedDoc,
|
||||
- maxTokenCount: config.maxTokenCount,
|
||||
- getReferencedFragmentSource: fragmentName => print(graph.getNodeData(fragmentName)),
|
||||
- });
|
||||
- if (tokenCountError) {
|
||||
- errors.push(tokenCountError);
|
||||
+ if (config.maxTokenCount) {
|
||||
+ const tokenCountError = validateTokenCount({
|
||||
+ source: doc.source,
|
||||
+ document: transformedDoc,
|
||||
+ maxTokenCount: config.maxTokenCount,
|
||||
+ getReferencedFragmentSource: fragmentName => print(graph.getNodeData(fragmentName)),
|
||||
+ });
|
||||
+ if (tokenCountError) {
|
||||
+ errors.push(tokenCountError);
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
- const deprecated = config.strictDeprecated ? findDeprecatedUsages(transformedSchema, transformedDoc) : [];
|
||||
- const duplicatedFragments = config.strictFragments ? findDuplicatedFragments(fragmentNames) : [];
|
||||
- if (sumLengths(errors, duplicatedFragments, deprecated) > 0) {
|
||||
- invalidDocuments.push({
|
||||
- source: doc.source,
|
||||
- errors: [...errors, ...duplicatedFragments],
|
||||
- deprecated,
|
||||
- });
|
||||
- }
|
||||
- });
|
||||
+ const deprecated = config.strictDeprecated ? findDeprecatedUsages(transformedSchema, transformedDoc) : [];
|
||||
+ const duplicatedFragments = config.strictFragments ? findDuplicatedFragments(fragmentNames) : [];
|
||||
+ if (sumLengths(errors, duplicatedFragments, deprecated) > 0) {
|
||||
+ invalidDocuments.push({
|
||||
+ source: doc.source,
|
||||
+ errors: [...errors, ...duplicatedFragments],
|
||||
+ deprecated,
|
||||
+ });
|
||||
+ }
|
||||
+ });
|
||||
return invalidDocuments;
|
||||
}
|
||||
function findDuplicatedFragments(fragmentNames) {
|
||||
@@ -1849,9 +1849,9 @@ function similar(schema, typeName, threshold = 0.4) {
|
||||
const targets = Object.keys(schema.getTypeMap())
|
||||
.filter(name => !isPrimitive(name) && !isForIntrospection(name))
|
||||
.map(name => ({
|
||||
- typeId: name,
|
||||
- value: stripType(typeMap[name]),
|
||||
- }));
|
||||
+ typeId: name,
|
||||
+ value: stripType(typeMap[name]),
|
||||
+ }));
|
||||
const results = {};
|
||||
if (typeof typeName !== 'undefined' && !targets.some(t => t.typeId === typeName)) {
|
||||
throw new Error(`Type '${typeName}' doesn't exist`);
|
||||
1165
dapp/public/security.json
Normal file
1165
dapp/public/security.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
@@ -13,8 +14,15 @@
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true
|
||||
"incremental": true,
|
||||
"useUnknownInCatchVariables": false
|
||||
},
|
||||
"include": ["next-env.d.ts", "globals.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"globals.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"helpers/circuits/witness_calculator.js"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user