Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JSONValue internally used only #536

Merged
merged 5 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export {
Scalar,
ProvablePure,
Provable,
JSONValue,
Ledger,
isReady,
shutdown,
Expand Down
11 changes: 10 additions & 1 deletion src/lib/circuit_value.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'reflect-metadata';
import { Circuit, JSONValue, ProvablePure, Provable } from '../snarky.js';
import { Circuit, ProvablePure, Provable } from '../snarky.js';
import { Field, Bool } from './core.js';
import { Context } from './global-context.js';
import { inCheckedComputation, snarkContext } from './proof_system.js';
Expand Down Expand Up @@ -32,6 +32,7 @@ export {
InferCircuitValue,
Provables,
HashInput,
JSONValue,
};

type Constructor<T> = new (...args: any) => T;
Expand Down Expand Up @@ -1074,6 +1075,14 @@ function getBlindingValue() {

type Tuple<T> = [T, ...T[]] | [];

type JSONValue =
| number
| string
| boolean
| null
| Array<JSONValue>
| { [key: string]: JSONValue };

type Primitive =
| typeof String
| typeof Number
Expand Down
4 changes: 2 additions & 2 deletions src/lib/mina.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This is for an account where any of a list of public keys can update the state

import { Circuit, JSONValue, Ledger, LedgerAccount } from '../snarky.js';
import { Circuit, Ledger, LedgerAccount } from '../snarky.js';
import { Field, Bool } from './core.js';
import { UInt32, UInt64 } from './int.js';
import { PrivateKey, PublicKey } from './signature.js';
Expand All @@ -22,7 +22,7 @@ import {

import * as Fetch from './fetch.js';
import { assertPreconditionInvariants, NetworkValue } from './precondition.js';
import { cloneCircuitValue } from './circuit_value.js';
import { cloneCircuitValue, JSONValue } from './circuit_value.js';
import { Proof, snarkContext, verify } from './proof_system.js';
import { Context } from './global-context.js';
import { emptyReceiptChainHash } from './hash.js';
Expand Down
1 change: 0 additions & 1 deletion src/lib/zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Ledger,
Pickles,
Poseidon as Poseidon_,
JSONValue,
Provable,
} from '../snarky.js';
import {
Expand Down
15 changes: 3 additions & 12 deletions src/snarky.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export {
isReady,
shutdown,
Pickles,
JSONValue,
Account as LedgerAccount,
};

Expand Down Expand Up @@ -359,7 +358,7 @@ declare class Field {
*/

static toJSON(x: Field): string;
static fromJSON(x: JSONValue): Field | null;
static fromJSON(x: string): Field;

static check(x: Field): void;

Expand Down Expand Up @@ -486,7 +485,7 @@ declare class Bool {
static fromFields(fields: Field[]): Bool;

static toJSON(x: Bool): boolean;
static fromJSON(x: JSONValue): Bool | null;
static fromJSON(x: boolean): Bool;
static check(x: Bool): void;

// monkey-patched in JS
Expand Down Expand Up @@ -636,7 +635,7 @@ declare class Scalar {
static random(): Scalar;

static toJSON(x: Scalar): string;
static fromJSON(x: JSONValue): Scalar | null;
static fromJSON(x: string): Scalar;
static check(x: Scalar): void;
}

Expand Down Expand Up @@ -957,12 +956,4 @@ declare const Pickles: {
proofToBase64Transaction: (proof: Pickles.Proof) => string;
};

type JSONValue =
| number
| string
| boolean
| null
| Array<JSONValue>
| { [key: string]: JSONValue };

type AuthRequired = 'Signature' | 'Proof' | 'Either' | 'None' | 'Impossible';