UNPKG

@nori-zk/mina-token-bridge

Version:

Nori ethereum state settelment and nETH token bridge zkApp

41 lines (40 loc) 2.13 kB
import { type AccountUpdate, type Bool, type ProofBase, type PublicKey, type SmartContract, type UInt64, type VerificationKey } from 'o1js'; import { type Subclass } from 'o1js/dist/node/lib/util/types.js'; import { type Gate } from 'o1js/dist/node/bindings/crypto/bindings/kimchi-types.js'; import { type CompilableZkProgram } from '@nori-zk/o1js-zk-utils'; export type ProofClass = Subclass<typeof ProofBase>; export type CompilableZkProgramWithAnalyze = CompilableZkProgram & { analyzeMethods: () => Promise<Record<string, { actions: number; rows: number; digest: string; gates: Gate[]; proofs: ProofClass[]; }>>; }; export type Analyzable = typeof SmartContract | CompilableZkProgramWithAnalyze; export type GlobalWithWindow = { window: Partial<Window>; }; export interface FungibleTokenAdminBase { canMint(au: AccountUpdate): Promise<Bool>; canChangeAdmin(admin: PublicKey): Promise<Bool>; canPause(): Promise<Bool>; canResume(): Promise<Bool>; canChangeVerificationKey(vk: VerificationKey): Promise<Bool>; } export interface MintableToken { mint(recipient: PublicKey, amount: UInt64): Promise<AccountUpdate>; } type CharArray<S extends string> = S extends `${infer First}${infer Rest}` ? [First, ...CharArray<Rest>] : []; type CountChars<S extends string> = CharArray<S>['length']; type ArrayOfLength<Length extends number, Collected extends unknown[] = []> = Collected['length'] extends Length ? Collected : ArrayOfLength<Length, [unknown, ...Collected]>; type IsAtMost<S extends string, Max extends number> = ArrayOfLength<Max> extends [...ArrayOfLength<CountChars<S>>, ...unknown[]] ? true : false; type LengthMismatchError<Expected extends number> = { expectedLength: Expected; }; export type EnforceLength<S extends string, N extends number> = CountChars<S> extends N ? S : LengthMismatchError<N>; export type EnforceMaxLength<S extends string, Max extends number> = IsAtMost<S, Max> extends true ? S : LengthMismatchError<Max>; export declare const secretMaxLength: 20; export type SecretMaxLength = typeof secretMaxLength; export {};