Skip to content

Commit

Permalink
Enforce import order in TS (#1069)
Browse files Browse the repository at this point in the history
* Enforce TS import order

* use modern TS type assertion

* fix merge
  • Loading branch information
spypsy authored Jul 14, 2023
1 parent eede42b commit 16d0f78
Show file tree
Hide file tree
Showing 248 changed files with 759 additions and 511 deletions.
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/acvm/acvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';

import { ForeignCallInput, ForeignCallOutput, WitnessMap, executeCircuit } from 'acvm_js';

/**
Expand Down
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/acvm/acvm_fields_reader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Fr } from '@aztec/foundation/fields';

import { ACVMField, fromACVMField } from './acvm.js';

/**
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/acir-simulator/src/acvm/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import {
MAX_NEW_COMMITMENTS_PER_CALL,
MAX_NEW_L2_TO_L1_MSGS_PER_CALL,
MAX_NEW_NULLIFIERS_PER_CALL,
NUM_FIELDS_PER_SHA256,
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
NUM_FIELDS_PER_SHA256,
PrivateCircuitPublicInputs,
MAX_READ_REQUESTS_PER_CALL,
RETURN_VALUES_LENGTH,
} from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr, Point } from '@aztec/foundation/fields';

import { getReturnWitness } from 'acvm_js';

import { ACVMField, ACVMWitness, fromACVMField } from './acvm.js';

// Utilities to read TS classes from ACVM Field arrays
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/acir-simulator/src/acvm/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ACVMField, toACVMField } from './acvm.js';

import {
CallContext,
ContractDeploymentData,
Expand All @@ -8,9 +6,11 @@ import {
PrivateCircuitPublicInputs,
PublicCallRequest,
} from '@aztec/circuits.js';
import { CommitmentDataOracleInputs, MessageLoadOracleInputs } from '../client/db_oracle.js';
import { Fr } from '@aztec/foundation/fields';

import { CommitmentDataOracleInputs, MessageLoadOracleInputs } from '../client/db_oracle.js';
import { ACVMField, toACVMField } from './acvm.js';

// Utilities to write TS classes to ACVM Field arrays
// In the order that the ACVM expects them

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PrivateHistoricTreeRoots, ReadRequestMembershipWitness, TxContext } from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr, Point } from '@aztec/foundation/fields';

import {
ACVMField,
fromACVMField,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/client/db_oracle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PartialContractAddress } from '@aztec/circuits.js';
import { FunctionAbi } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr, Point } from '@aztec/foundation/fields';
import { FunctionAbi } from '@aztec/foundation/abi';
import { PartialContractAddress } from '@aztec/circuits.js';

import { CommitmentsDB } from '../index.js';

Expand Down
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/client/debug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ForeignCallInput } from 'acvm_js';

import { ACVMField } from '../acvm/index.js';

/**
Expand Down
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/client/execution_result.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PrivateCallStackItem, PublicCallRequest, ReadRequestMembershipWitness } from '@aztec/circuits.js';
import { Fr } from '@aztec/foundation/fields';
import { FunctionL2Logs } from '@aztec/types';

import { ACVMField } from '../acvm/index.js';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ import {
ZkTokenContractAbi,
} from '@aztec/noir-contracts/examples';
import { PackedArguments, TxExecutionRequest } from '@aztec/types';

import { jest } from '@jest/globals';
import { MockProxy, mock } from 'jest-mock-extended';
import { default as levelup } from 'levelup';
import { default as memdown, type MemDown } from 'memdown';
import { type MemDown, default as memdown } from 'memdown';

import { buildL1ToL2Message } from '../test/utils.js';
import { NoirPoint, computeSlotForMapping, toPublicKey } from '../utils.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Fr, Point } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';
import { to2Fields } from '@aztec/foundation/serialize';
import { FunctionL2Logs, NotePreimage, NoteSpendingInfo } from '@aztec/types';

import { extractPublicInputs, frToAztecAddress, frToSelector } from '../acvm/deserialize.js';
import {
ZERO_ACVM_FIELD,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
import { ExecutionRequest, TxExecutionRequest } from '@aztec/types';

import { PackedArgsCache } from '../packed_args_cache.js';
import { ClientTxExecutionContext } from './client_execution_context.js';
import { DBOracle } from './db_oracle.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { CircuitsWasm, FunctionData, PrivateHistoricTreeRoots } from '@aztec/circuits.js';
import { Grumpkin } from '@aztec/circuits.js/barretenberg';

import { encodeArguments } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { ZkTokenContractAbi } from '@aztec/noir-contracts/examples';
import { ExecutionRequest } from '@aztec/types';

import { mock } from 'jest-mock-extended';

import { NoirPoint, toPublicKey } from '../utils.js';
import { DBOracle } from './db_oracle.js';
import { AcirSimulator } from './simulator.js';
import { encodeArguments } from '@aztec/foundation/abi';

describe('Unconstrained Execution test suite', () => {
let bbWasm: CircuitsWasm;
Expand Down
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/public/db.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EthAddress, PrivateHistoricTreeRoots } from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';

import { CommitmentDataOracleInputs, MessageLoadOracleInputs } from '../index.js';

/**
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/acir-simulator/src/public/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { padArrayEnd } from '@aztec/foundation/collection';
import { createDebugLogger } from '@aztec/foundation/log';
import { FunctionL2Logs } from '@aztec/types';

import {
ZERO_ACVM_FIELD,
acvm,
Expand All @@ -23,11 +24,11 @@ import {
toAcvmCommitmentLoadOracleInputs,
toAcvmL1ToL2MessageLoadOracleInputs,
} from '../acvm/index.js';
import { oracleDebugCallToFormattedStr } from '../client/debug.js';
import { PackedArgsCache } from '../packed_args_cache.js';
import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js';
import { PublicExecution, PublicExecutionResult } from './execution.js';
import { ContractStorageActionsCollector } from './state_actions.js';
import { oracleDebugCallToFormattedStr } from '../client/debug.js';
import { PackedArgsCache } from '../packed_args_cache.js';

// Copied from crate::abi at noir-contracts/src/contracts/noir-aztec/src/abi.nr
const NOIR_MAX_RETURN_VALUES = 4;
Expand Down
19 changes: 10 additions & 9 deletions yarn-project/acir-simulator/src/public/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import { Grumpkin, pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg';
import {
CallContext,
FunctionData,
CircuitsWasm,
PrivateHistoricTreeRoots,
L1_TO_L2_MSG_TREE_HEIGHT,
FunctionData,
GlobalVariables,
L1_TO_L2_MSG_TREE_HEIGHT,
PrivateHistoricTreeRoots,
} from '@aztec/circuits.js';
import { Grumpkin, pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg';
import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { keccak } from '@aztec/foundation/crypto';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
import { toBigInt } from '@aztec/foundation/serialize';
import {
ChildAbi,
NonNativeTokenContractAbi,
ParentAbi,
PublicTokenContractAbi,
TestContractAbi,
} from '@aztec/noir-contracts/examples';
import { toBigInt } from '@aztec/foundation/serialize';
import { keccak } from '@aztec/foundation/crypto';

import { MockProxy, mock } from 'jest-mock-extended';
import { default as memdown, type MemDown } from 'memdown';
import { type MemDown, default as memdown } from 'memdown';

import { buildL1ToL2Message } from '../test/utils.js';
import { NoirPoint, computeSlotForMapping, toPublicKey } from '../utils.js';
import { CommitmentsDB, PublicContractsDB, PublicStateDB } from './db.js';
import { PublicExecution } from './execution.js';
import { PublicExecutor } from './executor.js';
import { buildL1ToL2Message } from '../test/utils.js';

export const createMemDown = () => (memdown as any)() as MemDown<any, any>;

Expand Down
1 change: 1 addition & 0 deletions yarn-project/acir-simulator/src/public/state_actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ContractStorageRead, ContractStorageUpdateRequest } from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';

import { PublicStateDB } from './db.js';

/**
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AztecAddress, CircuitsWasm, EthAddress, Fr } from '@aztec/circuits.js';
import { computeSecretMessageHash } from '@aztec/circuits.js/abis';
import { L1ToL2Message, L1Actor, L2Actor } from '@aztec/types';
import { sha256ToField } from '@aztec/foundation/crypto';
import { AztecAddress, CircuitsWasm, EthAddress, Fr } from '@aztec/circuits.js';
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/types';

/**
* Test utility function to craft an L1 to L2 message.
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fr, Point } from '@aztec/foundation/fields';
import { Grumpkin, pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg';
import { CircuitsWasm } from '@aztec/circuits.js';
import { Grumpkin, pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg';
import { Fr, Point } from '@aztec/foundation/fields';

/**
* A point in the format that noir uses.
Expand Down
14 changes: 8 additions & 6 deletions yarn-project/archiver/src/archiver/archiver.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { InboxAbi, RollupAbi, ContractDeploymentEmitterAbi } from '@aztec/l1-artifacts';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { randomBytes } from '@aztec/foundation/crypto';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { sleep } from '@aztec/foundation/sleep';
import { ContractDeploymentEmitterAbi, InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
import {
ContractData,
ContractPublicData,
Expand All @@ -7,15 +12,12 @@ import {
L2BlockL2Logs,
LogType,
} from '@aztec/types';

import { MockProxy, mock } from 'jest-mock-extended';
import { Chain, HttpTransport, Log, PublicClient, Transaction, encodeFunctionData, toHex } from 'viem';

import { Archiver } from './archiver.js';
import { EthAddress } from '@aztec/foundation/eth-address';
import { sleep } from '@aztec/foundation/sleep';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { randomBytes } from '@aztec/foundation/crypto';
import { ArchiverDataStore, MemoryArchiverStore } from './archiver_store.js';
import { Fr } from '@aztec/foundation/fields';

describe('Archiver', () => {
const rollupAddress = '0x0000000000000000000000000000000000000000';
Expand Down
17 changes: 9 additions & 8 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import omit from 'lodash.omit';
import { createEthereumChain } from '@aztec/ethereum';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
import { RunningPromise } from '@aztec/foundation/running-promise';
import { EthAddress } from '@aztec/foundation/eth-address';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { INITIAL_L2_BLOCK_NUM, L1ToL2Message, L1ToL2MessageSource, L2BlockL2Logs, LogType } from '@aztec/types';
import {
ContractData,
ContractPublicData,
ContractDataSource,
ContractPublicData,
EncodedContractFunction,
L2Block,
L2BlockSource,
L2LogsSource,
} from '@aztec/types';

import omit from 'lodash.omit';
import { Chain, HttpTransport, PublicClient, createPublicClient, http } from 'viem';
import { createEthereumChain } from '@aztec/ethereum';
import { Fr } from '@aztec/foundation/fields';

import { ArchiverDataStore, MemoryArchiverStore } from './archiver_store.js';
import { ArchiverConfig } from './config.js';
import {
retrieveBlocks,
retrieveNewCancelledL1ToL2Messages,
retrieveNewContractData,
retrieveNewPendingL1ToL2Messages,
retrieveNewCancelledL1ToL2Messages,
} from './data_retrieval.js';
import { ArchiverDataStore, MemoryArchiverStore } from './archiver_store.js';

/**
* Pulls L2 blocks in a non-blocking manner and provides interface for their retrieval.
Expand Down
9 changes: 5 additions & 4 deletions yarn-project/archiver/src/archiver/archiver_store.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import {
ContractData,
ContractPublicData,
L2Block,
INITIAL_L2_BLOCK_NUM,
ContractData,
L1ToL2Message,
L2Block,
L2BlockL2Logs,
LogType,
} from '@aztec/types';
import { Fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';

import { L1ToL2MessageStore, PendingL1ToL2MessageStore } from './l1_to_l2_message_store.js';

/**
Expand Down
12 changes: 7 additions & 5 deletions yarn-project/archiver/src/archiver/data_retrieval.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { ContractPublicData, L1ToL2Message, L2Block } from '@aztec/types';

import { PublicClient } from 'viem';

import {
getContractDeploymentLogs,
getL1ToL2MessageCancelledLogs,
getL2BlockProcessedLogs,
getPendingL1ToL2MessageLogs,
getL1ToL2MessageCancelledLogs,
processBlockLogs,
processCancelledL1ToL2MessagesLogs,
processContractDeploymentLogs,
processPendingL1ToL2MessageAddedLogs,
processCancelledL1ToL2MessagesLogs,
} from './eth_log_handlers.js';
import { EthAddress } from '@aztec/foundation/eth-address';
import { ContractPublicData, L1ToL2Message, L2Block } from '@aztec/types';
import { Fr } from '@aztec/foundation/fields';

/**
* Data retrieved from logs
Expand Down
19 changes: 10 additions & 9 deletions yarn-project/archiver/src/archiver/eth_log_handlers.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { Hex, Log, PublicClient, decodeFunctionData, getAbiItem, getAddress, hexToBytes } from 'viem';
import { InboxAbi, RollupAbi, ContractDeploymentEmitterAbi } from '@aztec/l1-artifacts';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { ContractDeploymentEmitterAbi, InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
import {
L1ToL2Message,
L1Actor,
L2Actor,
L2Block,
ContractPublicData,
BufferReader,
ContractData,
ContractPublicData,
EncodedContractFunction,
L1Actor,
L1ToL2Message,
L2Actor,
L2Block,
} from '@aztec/types';
import { EthAddress } from '@aztec/foundation/eth-address';
import { AztecAddress } from '@aztec/foundation/aztec-address';

import { Hex, Log, PublicClient, decodeFunctionData, getAbiItem, getAddress, hexToBytes } from 'viem';

/**
* Processes newly received MessageAdded (L1 to L2) logs.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Fr } from '@aztec/foundation/fields';
import { L1ToL2MessageStore, PendingL1ToL2MessageStore } from './l1_to_l2_message_store.js';
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/types';

import { L1ToL2MessageStore, PendingL1ToL2MessageStore } from './l1_to_l2_message_store.js';

describe('l1_to_l2_message_store', () => {
let store: L1ToL2MessageStore;
let entryKey: Fr;
Expand Down
Loading

0 comments on commit 16d0f78

Please sign in to comment.