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

chore: remove foundation and types deps from boxes #3389

Merged
merged 19 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 12 additions & 11 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export { AccountWalletWithPrivateKey, AccountWallet, Wallet, SignerlessWallet }
export {
AztecAddress,
EthAddress,
Point,
Fr,
Fq,
FunctionSelector,
GlobalVariables,
GrumpkinScalar,
Point,
getContractDeploymentInfo,
} from '@aztec/circuits.js';

Expand All @@ -86,8 +86,8 @@ export {
ExtendedContractData,
ExtendedNote,
FunctionCall,
INITIAL_L2_BLOCK_NUM,
GrumpkinPrivateKey,
INITIAL_L2_BLOCK_NUM,
L2Actor,
L2Block,
L2BlockL2Logs,
Expand All @@ -97,41 +97,42 @@ export {
MerkleTreeId,
NodeInfo,
Note,
PXE,
PackedArguments,
PartialAddress,
PublicKey,
PXE,
SyncStatus,
Tx,
TxExecutionRequest,
TxHash,
TxReceipt,
TxStatus,
UnencryptedL2Log,
emptyFunctionCall,
createAztecNodeClient,
emptyFunctionCall,
merkleTreeIds,
mockTx,
} from '@aztec/types';

export { ContractArtifact, FunctionArtifact } from '@aztec/foundation/abi';

// TODO: These kinds of things have no place on our public api.
// External devs will almost certainly have their own methods of doing these things.
// If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
export { ContractArtifact, FunctionArtifact, encodeArguments } from '@aztec/foundation/abi';
export { sha256, init } from '@aztec/foundation/crypto';
export { DebugLogger, createDebugLogger, onLog } from '@aztec/foundation/log';
export { fileURLToPath } from '@aztec/foundation/url';
export { retry, retryUntil } from '@aztec/foundation/retry';
export { sleep } from '@aztec/foundation/sleep';
export { elapsed } from '@aztec/foundation/timer';
export { retry, retryUntil } from '@aztec/foundation/retry';
export { sha256, init } from '@aztec/foundation/crypto';
export { fileURLToPath } from '@aztec/foundation/url';
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
export { makeFetch } from '@aztec/foundation/json-rpc/client';

export {
deployL1Contract,
deployL1Contracts,
DeployL1Contracts,
L1ContractArtifactsForDeployment,
deployL1Contract,
deployL1Contracts,
} from '@aztec/ethereum';

export { FieldsOf } from '@aztec/foundation/types';
3 changes: 0 additions & 3 deletions yarn-project/boxes/blank-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
"dependencies": {
"@aztec/aztec-ui": "^0.1.14",
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/types": "workspace:^",
"classnames": "^2.3.2",
"formik": "^2.4.3",
"node-sass": "^9.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { callContractFunction, deployContract, viewContractFunction } from '../.
import { convertArgs } from '../../scripts/util.js';
import styles from './contract_function_form.module.scss';
import { Button, Loader } from '@aztec/aztec-ui';
import { AztecAddress, CompleteAddress, Fr } from '@aztec/aztec.js';
import { ContractArtifact, FunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, ContractArtifact, Fr, FunctionArtifact } from '@aztec/aztec.js';
import { useFormik } from 'formik';
import * as Yup from 'yup';

Expand Down
3 changes: 1 addition & 2 deletions yarn-project/boxes/blank-react/src/app/contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Copy } from './components/copy.js';
import { ContractFunctionForm, Popup } from './components/index.js';
import styles from './contract.module.scss';
import { Button, ButtonSize, ButtonTheme, Card, CardTheme, ImageButton, ImageButtonIcon } from '@aztec/aztec-ui';
import { AztecAddress, CompleteAddress } from '@aztec/aztec.js';
import { FunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, FunctionArtifact } from '@aztec/aztec.js';
import { ReactNode, useState } from 'react';

const functionTypeSortOrder = {
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/boxes/blank-react/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BlankContractArtifact } from './artifacts/Blank.js';
import { PXE, createPXEClient } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { ContractArtifact, PXE, createPXEClient } from '@aztec/aztec.js';

// update this if using a different contract

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { getWallet } from './util.js';
import { AztecAddress, PXE, CompleteAddress, Contract, TxReceipt } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { FieldsOf } from '@aztec/foundation/types';
import { AztecAddress, CompleteAddress, Contract, ContractArtifact, FieldsOf, PXE, TxReceipt } from '@aztec/aztec.js';

export async function callContractFunction(
address: AztecAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { AztecAddress, CompleteAddress, DeployMethod, Fr } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { PXE } from '@aztec/types';
import { AztecAddress, CompleteAddress, ContractArtifact, DeployMethod, Fr, PXE } from '@aztec/aztec.js';

export async function deployContract(
activeWallet: CompleteAddress,
Expand Down
12 changes: 9 additions & 3 deletions yarn-project/boxes/blank-react/src/scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { AccountWallet, Fr, getSandboxAccountsWallets } from '@aztec/aztec.js';
import { FunctionArtifact, encodeArguments } from '@aztec/foundation/abi';
import { PXE, CompleteAddress } from '@aztec/types';
import {
AccountWallet,
CompleteAddress,
Fr,
FunctionArtifact,
PXE,
encodeArguments,
getSandboxAccountsWallets,
} from '@aztec/aztec.js';

export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
const untypedArgs = functionAbi.parameters.map(param => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getWallet } from './util.js';
import { AztecAddress, PXE, CompleteAddress, Contract } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, Contract, ContractArtifact, PXE } from '@aztec/aztec.js';

export async function viewContractFunction(
address: AztecAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
PXE,
TxStatus,
Wallet,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { createDebugLogger } from '@aztec/foundation/log';

const logger = createDebugLogger('aztec:http-pxe-client');

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank-react/tsconfig.dest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ".",
"references": [{ "path": "../../aztec.js" }, { "path": "../../foundation" }, { "path": "../../types" }],
"references": [{ "path": "../../aztec.js" }],
"exclude": ["src/**/*.test.ts"]
}
9 changes: 0 additions & 9 deletions yarn-project/boxes/blank-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,5 @@
{
"path": "../../aztec.js"
},
{
"path": "../../circuits.js"
},
{
"path": "../../foundation"
},
{
"path": "../../types"
}
]
}
2 changes: 0 additions & 2 deletions yarn-project/boxes/blank/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
"dependencies": {
"@aztec/aztec-ui": "^0.1.14",
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/foundation": "workspace:^",
"serve": "^14.2.1"
},
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/boxes/blank/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import {
AztecAddress,
CompleteAddress,
Contract,
ContractArtifact,
DeployMethod,
FieldsOf,
Fr,
FunctionArtifact,
PXE,
TxReceipt,
createPXEClient,
encodeArguments,
getSandboxAccountsWallets,
} from '@aztec/aztec.js';
import { ContractArtifact, FunctionArtifact, encodeArguments } from '@aztec/foundation/abi';
import { FieldsOf } from '@aztec/foundation/types';

// docs:end:imports

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/src/tests/blank.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
PXE,
TxStatus,
Wallet,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { createDebugLogger } from '@aztec/foundation/log';

const logger = createDebugLogger('aztec:blank-box-test');

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/tsconfig.dest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ".",
"references": [{ "path": "../../aztec.js" }, { "path": "../../foundation" }, { "path": "../../types" }],
"references": [{ "path": "../../aztec.js" }],
"exclude": ["src/**/*.test.ts"]
}
6 changes: 0 additions & 6 deletions yarn-project/boxes/blank/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,5 @@
{
"path": "../../aztec.js"
},
{
"path": "../../circuits.js"
},
{
"path": "../../foundation"
}
]
}
3 changes: 0 additions & 3 deletions yarn-project/boxes/token/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
"dependencies": {
"@aztec/aztec-ui": "^0.1.14",
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/types": "workspace:^",
"classnames": "^2.3.2",
"formik": "^2.4.3",
"node-sass": "^9.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { callContractFunction, deployContract, viewContractFunction } from '../.
import { convertArgs } from '../../scripts/util.js';
import styles from './contract_function_form.module.scss';
import { Button, Loader } from '@aztec/aztec-ui';
import { AztecAddress, CompleteAddress, Fr } from '@aztec/aztec.js';
import { ContractArtifact, FunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, ContractArtifact, Fr, FunctionArtifact } from '@aztec/aztec.js';
import { useFormik } from 'formik';
import * as Yup from 'yup';

Expand Down
3 changes: 1 addition & 2 deletions yarn-project/boxes/token/src/app/contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Copy } from './components/copy.js';
import { ContractFunctionForm, Popup } from './components/index.js';
import styles from './contract.module.scss';
import { Button, ButtonSize, ButtonTheme, Card, CardTheme, ImageButton, ImageButtonIcon } from '@aztec/aztec-ui';
import { AztecAddress, CompleteAddress } from '@aztec/aztec.js';
import { FunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, FunctionArtifact } from '@aztec/aztec.js';
import { ReactNode, useState } from 'react';

const functionTypeSortOrder = {
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/boxes/token/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { TokenContractArtifact } from './artifacts/Token.js';
import { PXE, createPXEClient } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { ContractArtifact, PXE, createPXEClient } from '@aztec/aztec.js';

// update this if using a different contract

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getWallet } from './util.js';
import { AztecAddress, PXE, CompleteAddress, Contract } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, Contract, ContractArtifact, PXE } from '@aztec/aztec.js';

export async function callContractFunction(
address: AztecAddress,
Expand Down
4 changes: 1 addition & 3 deletions yarn-project/boxes/token/src/scripts/deploy_contract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { AztecAddress, CompleteAddress, DeployMethod, Fr } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { PXE } from '@aztec/types';
import { AztecAddress, CompleteAddress, ContractArtifact, DeployMethod, Fr, PXE } from '@aztec/aztec.js';

export async function deployContract(
activeWallet: CompleteAddress,
Expand Down
12 changes: 9 additions & 3 deletions yarn-project/boxes/token/src/scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { AccountWallet, Fr, getSandboxAccountsWallets } from '@aztec/aztec.js';
import { FunctionArtifact, encodeArguments } from '@aztec/foundation/abi';
import { CompleteAddress, PXE } from '@aztec/types';
import {
AccountWallet,
CompleteAddress,
Fr,
FunctionArtifact,
PXE,
encodeArguments,
getSandboxAccountsWallets,
} from '@aztec/aztec.js';

function convertBasicArg(paramType: string, value: any) {
switch (paramType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getWallet } from './util.js';
import { AztecAddress, PXE, CompleteAddress, Contract } from '@aztec/aztec.js';
import { ContractArtifact } from '@aztec/foundation/abi';
import { AztecAddress, CompleteAddress, Contract, ContractArtifact, PXE } from '@aztec/aztec.js';

export async function viewContractFunction(
address: AztecAddress,
Expand Down
7 changes: 4 additions & 3 deletions yarn-project/boxes/token/src/tests/token.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import { TokenContract } from '../artifacts/Token.js';
import { TokenSimulator } from './token_simulator.js';
import {
AccountWallet,
CompleteAddress,
DebugLogger,
ExtendedNote,
Fr,
Note,
PXE,
TxHash,
TxStatus,
computeAuthWitMessageHash,
computeMessageSecretHash,
createDebugLogger,
createPXEClient,
getSandboxAccountsWallets,
waitForSandbox,
} from '@aztec/aztec.js';
import { CompleteAddress } from '@aztec/circuits.js';
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
import { ExtendedNote } from '@aztec/types';
import { afterEach, beforeAll, expect, jest } from '@jest/globals';

// assumes sandbox is running locally, which this script does not trigger
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/boxes/token/tsconfig.dest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ".",
"references": [{ "path": "../../aztec.js" }, { "path": "../../foundation" }, { "path": "../../types" }],
"references": [{ "path": "../../aztec.js" }],
"exclude": ["src/**/*.test.ts"]
}
9 changes: 0 additions & 9 deletions yarn-project/boxes/token/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,5 @@
{
"path": "../../aztec.js"
},
{
"path": "../../circuits.js"
},
{
"path": "../../foundation"
},
{
"path": "../../types"
}
]
}
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/abi/function_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class FunctionSelector {
static fromString(selector: string) {
const buf = Buffer.from(selector.replace(/^0x/i, ''), 'hex');
if (buf.length !== FunctionSelector.SIZE) {
throw new Error(`Invalid length ${buf.length}.`);
throw new Error(`Invalid FunctionSelector length ${buf.length}.`);
}
return FunctionSelector.fromBuffer(buf);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/aztec-address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Fr } from '../fields/index.js';
export class AztecAddress extends Fr {
constructor(buffer: Buffer) {
if (buffer.length !== 32) {
throw new Error(`Invalid length ${buffer.length}.`);
throw new Error(`Invalid AztecAddress length ${buffer.length}.`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran into this when testing against published sandbox instead of local version - slightly more detailed error message helps distinguish between these two

}
super(buffer);
}
Expand Down
Loading