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

feat: cli "unbox" command #2029

Merged
merged 141 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
97b9f9c
Initial vite project.
LeilaWang Sep 1, 2023
c75d38b
Webpack build.
LeilaWang Sep 2, 2023
6cf94f6
Aztec box ui.
LeilaWang Sep 4, 2023
7f7ad09
Merge remote-tracking branch 'origin/master' into lw/aztec_box
LeilaWang Sep 5, 2023
6af5308
Cleanup.
LeilaWang Sep 5, 2023
844981d
Make default the last config.
LeilaWang Sep 5, 2023
3b1dbb2
Change default port.
LeilaWang Sep 5, 2023
35a37d3
add serve dep and compile
dan-aztec Sep 5, 2023
f92120a
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 5, 2023
e3c4386
add wallets from rpcClient
dan-aztec Sep 5, 2023
17e51ed
select completeaddress instead of aztecaddress as wallet
dan-aztec Sep 5, 2023
d6c912d
parse address field correctly before deploy
dan-aztec Sep 5, 2023
c511c1c
fix wallet selection interaction
dan-aztec Sep 5, 2023
721d248
show selected wallets full public key
dan-aztec Sep 5, 2023
ef65a2c
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 5, 2023
95faf3d
sketch of calling contract methods
dan-aztec Sep 5, 2023
9a3ddf9
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 5, 2023
959ac33
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 6, 2023
7d9674c
upate build_manifest.json, add dockerfile and arg converter util
dan-aztec Sep 6, 2023
a2d9a5e
revert aztec.js package.json switch
dan-aztec Sep 6, 2023
d713f6b
add to worskapces
dan-aztec Sep 6, 2023
e83d64e
Revert "revert aztec.js package.json switch"
dan-aztec Sep 6, 2023
b0cc2d8
revert aztecjs package.json change, add wallet param
dan-aztec Sep 6, 2023
25b68da
update private token contract abi
dan-aztec Sep 6, 2023
e9a3ce5
convert string form values to array for yup
dan-aztec Sep 6, 2023
da75a2a
remove logs and allow hardcoded address value param names
dan-aztec Sep 6, 2023
f2b3fa3
allow box config to toggle banner animation
dan-aztec Sep 6, 2023
bc7b7c1
copy into cli command from other branch
dan-aztec Sep 6, 2023
ee3afa9
update yarnlock
dan-aztec Sep 6, 2023
772cce3
update cli to point to boxes instead of starter-kit
dan-aztec Sep 6, 2023
e1b4ef5
rename starterkit to box
dan-aztec Sep 6, 2023
4e0958a
copy more stuff into package.json
dan-aztec Sep 6, 2023
1a41a9f
Merge remote-tracking branch 'origin/master' into dan/lw/aztec_box
dan-aztec Sep 7, 2023
1730312
revert some circuits formatting
dan-aztec Sep 7, 2023
c4685ac
revert?
dan-aztec Sep 7, 2023
2f6b5e4
remove env file creation
dan-aztec Sep 7, 2023
a15f2c5
start fixing copy commands
dan-aztec Sep 7, 2023
8985652
bug on nargo.toml filtering
dan-aztec Sep 7, 2023
77ebc5a
fix aztec-li
dan-aztec Sep 7, 2023
c910cbf
add sandbox image updating and initializating to package.json scripts
dan-aztec Sep 7, 2023
02d9c4f
hide compute_nullifer method from front end
dan-aztec Sep 7, 2023
8f3ac38
add @types/node and jest
dan-aztec Sep 7, 2023
c5a53a0
initial jest test
dan-aztec Sep 7, 2023
b7438ec
readme updates
dan-aztec Sep 7, 2023
75e72a9
readme
dan-aztec Sep 7, 2023
1fd2f8f
wait instead of is_mined()
dan-aztec Sep 7, 2023
c04b875
rename mint vs transfer amounts in test
dan-aztec Sep 7, 2023
05adaf8
broken now?
dan-aztec Sep 7, 2023
194b083
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 7, 2023
70650b8
console.log
dan-aztec Sep 7, 2023
efe0347
update contract.json
dan-aztec Sep 7, 2023
1a408ee
jest works in monorepo now
dan-aztec Sep 8, 2023
bc3771d
update default account address public key
dan-aztec Sep 8, 2023
ca67592
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 8, 2023
0f92983
temp logs for failed contract deploy, modify tsconfig to remove refer…
dan-aztec Sep 8, 2023
515d3da
set version 0.1.0 but not sure that matches w/npm versions of publish…
dan-aztec Sep 8, 2023
98dc05e
clean up comments
dan-aztec Sep 8, 2023
c1bce90
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 11, 2023
a31d3f4
fix package version injection
dan-aztec Sep 11, 2023
3ef8e68
update cli and private_token_contract.json
dan-aztec Sep 11, 2023
228350b
fix the sandbox tests in subpackage
dan-aztec Sep 11, 2023
4f5b330
only copy noir source if not present in box
dan-aztec Sep 11, 2023
889dc16
remove logs and move into components/
dan-aztec Sep 11, 2023
ed8de57
move contract.tsx back to top level
dan-aztec Sep 11, 2023
2482d76
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 11, 2023
e3939e5
bump yarn.lock
dan-aztec Sep 11, 2023
09757d6
remove toplevel yarn.lock
dan-aztec Sep 11, 2023
5580c10
start fixes
dan-aztec Sep 11, 2023
4bb1540
start update to new txn api
dan-aztec Sep 11, 2023
8f55468
select the AccountWallet for the account
dan-aztec Sep 11, 2023
c83f0c8
move wallet selector in utils file
dan-aztec Sep 11, 2023
56ffd53
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 12, 2023
4d4f53e
updated contract json
dan-aztec Sep 12, 2023
8faae12
update generated class
dan-aztec Sep 12, 2023
bcf1d19
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 12, 2023
d4ae480
add copy package.json to yarn-base dockerfile
dan-aztec Sep 12, 2023
6a4ffc1
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 12, 2023
18209d9
update README to add dockerfile change for new subpackage
dan-aztec Sep 12, 2023
53adf85
try to add to CI
dan-aztec Sep 12, 2023
cd62a23
use github for deps in Nargo.toml instead of copying files
dan-aztec Sep 12, 2023
b35a627
stop downloading noir-libs since they can be configured as deps in th…
dan-aztec Sep 12, 2023
8cffe1f
make test an integration test
dan-aztec Sep 12, 2023
43eacc4
add end-to-end dep for local sandbox setup function
dan-aztec Sep 12, 2023
da2ce0c
add to circlci/config.yml jobs
dan-aztec Sep 12, 2023
34a1b90
try to add setup from @aztec/end-to-end
dan-aztec Sep 12, 2023
4447cbd
add circuits dep
dan-aztec Sep 12, 2023
100b26b
README updates, try to manually build circuits to save dockerfile
dan-aztec Sep 12, 2023
7e43035
remove early yarn test in dockerfile
dan-aztec Sep 12, 2023
edfe623
prettier
dan-aztec Sep 12, 2023
35793e0
try copying setup from end-to-end
dan-aztec Sep 12, 2023
3ddb28b
revert e2d dep in test, update test to use FE helpers
dan-aztec Sep 12, 2023
2a425ba
add a test to e2e for the unbox methods
dan-aztec Sep 12, 2023
65d66d8
fix local tests
dan-aztec Sep 12, 2023
34db68d
update e2e version of test
dan-aztec Sep 12, 2023
50dc3a5
bump e-2-e tsconfig
dan-aztec Sep 12, 2023
25f3bc1
format dependencies
dan-aztec Sep 12, 2023
24fcea8
try just boxes
dan-aztec Sep 12, 2023
b51427c
remove circular dep
dan-aztec Sep 12, 2023
4661cf3
remove some deps on boxes
dan-aztec Sep 12, 2023
63dc3b3
annotate config.ts
dan-aztec Sep 12, 2023
728a8e8
fix import but still broken
dan-aztec Sep 12, 2023
84e6cb9
inherit top level package.common.json
dan-aztec Sep 12, 2023
9030820
Revert "inherit top level package.common.json"
dan-aztec Sep 12, 2023
49d6d93
somehow wont find @aztec/boxes/private-token
dan-aztec Sep 12, 2023
b9b4e97
run yarn prepare, end-to-end removed boxes dep?
dan-aztec Sep 12, 2023
8d6b729
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
2406e81
some pr feedback
dan-aztec Sep 13, 2023
8a5934b
move arg conversion outside scripts functions
dan-aztec Sep 13, 2023
dca96d4
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
7a5e444
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
96eea37
remove test from e2e
dan-aztec Sep 13, 2023
fa02549
fix the test
dan-aztec Sep 13, 2023
d955bcd
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
fdc6d1f
yarn.lock
dan-aztec Sep 13, 2023
21edd87
small fixes
dan-aztec Sep 13, 2023
17c04aa
download the cli tag version of monorepo instead of master
dan-aztec Sep 13, 2023
773ac23
revert end-to-end changes
dan-aztec Sep 13, 2023
7c10033
try yarn install
dan-aztec Sep 13, 2023
678e195
re-add circuits dep
dan-aztec Sep 13, 2023
c9fc1bb
modify package.json script to grab pinned version of sandbox image
dan-aztec Sep 13, 2023
295d73a
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
0cac2ce
push packageVersion to first param consistently, update a string
dan-aztec Sep 13, 2023
95022e3
unneeded function
dan-aztec Sep 13, 2023
a05f3b1
fix compile command
dan-aztec Sep 13, 2023
e5e91be
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
aa269b5
update README and strip out some doc comments from the noir source files
dan-aztec Sep 13, 2023
d6f0dca
animate banner on deploy
dan-aztec Sep 13, 2023
48162be
also pin the sandbox version on the start command
dan-aztec Sep 13, 2023
f02725b
modify the nargo toml dep to use the same tag/version as the npm pack…
dan-aztec Sep 13, 2023
e6956a7
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 13, 2023
15a95a9
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 14, 2023
2d4a73d
remove CI integration for now
dan-aztec Sep 14, 2023
4609309
Revert "remove CI integration for now"
dan-aztec Sep 14, 2023
7ce5248
try not setting 3 other params, let build system figure it out
dan-aztec Sep 14, 2023
79606d1
Revert "try not setting 3 other params, let build system figure it out"
dan-aztec Sep 14, 2023
ba4ffef
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 14, 2023
6248865
Revert "Revert "remove CI integration for now""
dan-aztec Sep 14, 2023
1fbd137
remove change to base Dockerfile
dan-aztec Sep 14, 2023
461f026
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 14, 2023
fa312e5
Revert "remove change to base Dockerfile"
dan-aztec Sep 14, 2023
584bada
Merge branch 'master' into dan/lw/aztec_box
dan-aztec Sep 14, 2023
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
2 changes: 2 additions & 0 deletions yarn-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ To add a new package, make sure to add it to the `build_manifest.json`, to the `
- `package.json`
- `README.md`
- `tsconfig.json`

You may also need to modify the [Dockerfile](yarn-project/yarn-project-base/Dockerfile) to copy your new `package.json` into the container to get CI to pass.
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"exports": {
"node": "./dest/index.js",
"default": "./dest/main.js",
"import": "./dest/index.js"
"import": "./dest/index.js",
"default": "./dest/main.js"
},
"typedocOptions": {
"entryPoints": [
Expand Down
61 changes: 61 additions & 0 deletions yarn-project/boxes/private-token/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
overrides: [
{
files: ['*.ts', '*.tsx'],
parserOptions: {
// hacky workaround for CI not having the same tsconfig setup
project: true,
},
},
],
rules: {
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 2,
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'require-await': 2,
'no-console': 'warn',
'no-constant-condition': 'off',
camelcase: 2,
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['client-dest'],
message: "Fix this absolute garbage import. It's your duty to solve it before it spreads.",
},
{
group: ['dest'],
message: 'You should not be importing from a build directory. Did you accidentally do a relative import?',
},
],
},
],
'import/no-unresolved': 'error',
'import/no-extraneous-dependencies': 'error',
},
};
24 changes: 24 additions & 0 deletions yarn-project/boxes/private-token/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 6 additions & 0 deletions yarn-project/boxes/private-token/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"arrowParens": "avoid"
}
15 changes: 15 additions & 0 deletions yarn-project/boxes/private-token/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder

COPY . .

WORKDIR /usr/src/yarn-project/boxes/private-token
RUN yarn build && yarn formatting

# this feels wrong
RUN yarn cache clean
RUN yarn workspaces focus --production > /dev/null

FROM node:18-alpine
COPY --from=builder /usr/src/yarn-project/boxes/private-token /usr/src/yarn-project/boxes/private-token
WORKDIR /usr/src/yarn-project/boxes/private-token
ENTRYPOINT ["yarn"]
95 changes: 95 additions & 0 deletions yarn-project/boxes/private-token/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
This is a minimal [Aztec](https://aztec.network/) Noir smart contract and frontend bootstrapped with [`aztec-cli unbox`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/cli). It is recommended you use the `aztec-cli unbox PrivateToken` command so that the repository is copied with needed modifications from the monorepo subpackage.

Some contract specific settings for `PrivateToken` are in a [config](src/config.ts) will require manual updates depending on your changes to the source code. `aztec-cli` can be installed with `npm i -g @aztec/cli`, if you don't have it already.

## Setup

Dependencies can be installed from the root of the package:

```bash
yarn
yarn install:noir
yarn install:sandbox
yarn build
```

In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (Aztec ZK smart contract language) in addition to `@aztec/aztec-cli`.

The former are installed within `yarn install:noir` which executes

```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash

noirup -v aztec
```

This sandbox requires [Docker](https://www.docker.com/) to be installed _and running_ locally. In the event the image needs updating, you can run `yarn install:sandbox` which executes

```bash
docker pull aztecprotocol/aztec-sandbox:latest
```

## Getting started

After `yarn build` has run,`yarn start:sandbox` in one terminal will launch a local instance of the Aztec sandbox via Docker Compose and `yarn start:dev` will launch a frontend app for deploying and interacting with the PrivateToken contract.

At this point, [http://localhost:5173](http://localhost:5173) should provide a minimal smart contract frontend.

This folder should have the following directory structure:

```
|— README.md
|— package.json
|— src
|-config.ts - PrivateToken specific configuration for the frontend.
| You may need to update this if you modify the contract functions.
|— app
|— [frontend React .tsx code files]
|- scripts
|- [helpers for frontend to interact with contract on the sandbox]
|— contracts
|— src
| The Noir smart contract source files are here.
|— main.nr - the cloned noir contract, your starting point
|- interface.nr - autogenerated from main.nr when you compile
|— Nargo.toml [Noir build file, includes Aztec smart contract dependencies]
|— artifacts
| These are both generated from `contracts/` by the compile command
|— private_token_contract.json
|— private_token.ts
|— tests
| A simple end2end test deploying and testing the PrivateToken on a local sandbox
| using the front end helper methods in app/scripts/
| The test requires the sandbox and anvil to be running (yarn start:sandbox).
|- privatetoken.test.ts
```

Most relevant to you is likely `src/contracts/main.nr` (and the build config `src/contracts/Nargo.toml`). This contains the example PrivateToken logic that the frontend interacts with and is a good place to start writing Noir.

The `src/artifacts` folder can be re-generated from the command line with `yarn compile` which is an alias for

```bash
aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts
```

This will generate a [Contract ABI](https://www.alchemy.com/overviews/what-is-an-abi-of-a-smart-contract-examples-and-usage) and TypeScript class for the Aztec smart contract in `src/contracts/main.nr`, which the frontend uses to generate the UI.

Note: the `compile` command seems to generate a Typescript file which needs a single change -

```
import PrivateTokenContractAbiJson from 'PrivateToken.json' assert { type: 'json' };
// need to update the relative import to
import PrivateTokenContractAbiJson from './PrivateToken.json' assert { type: 'json' };
```

After compiling, you can re-deploy the upated noir smart contract from the web UI. The function interaction forms are generated from parsing the ContractABI, so they should update automatically after you recompile.

## Learn More

To learn more about Noir Smart Contract development, take a look at the following resources:

- [Awesome Noir](https://github.com/noir-lang/awesome-noir) - learn about the Noir programming language.

## Deploy on Aztec3

Coming Soon :)
96 changes: 96 additions & 0 deletions yarn-project/boxes/private-token/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "private-token",
"private": true,
"version": "0.1.0",
"type": "module",
"main": "./dest/index.js",
"scripts": {
"build": "yarn clean && webpack",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec",
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest",
"clean": "rm -rf ./dest .tsbuildinfo",
"start": "serve -p 3000 ./dest",
"start:dev": "webpack serve --mode=development",
"start:sandbox": "SANDBOX_VERSION=latest /bin/bash -c \"$(curl -fsSL 'https://sandbox.aztec.network')\" ",
"formatting": "prettier --check ./src && eslint ./src",
"formatting:fix": "prettier -w ./src",
"compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test\" \"anvil\""
},
"jest": {
"preset": "ts-jest/presets/default-esm",
"globals": {
"ts-jest": {
"useESM": true
}
},
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"testRegex": "./src/.*\\.test\\.ts$",
"rootDir": "./src"
},
"dependencies": {
"@aztec/aztec.js": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/cli": "workspace:^",
Copy link
Contributor

Choose a reason for hiding this comment

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

circuits.js and cli shouldn't be in the dependencies. Or we keep cli and remove noir-compiler and use cli to compile the contracts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing circuits.js and noir-compiler!

"@aztec/foundation": "workspace:^",
"formik": "^2.4.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"serve": "^14.2.1",
"tailwindcss": "^3.3.3",
"yup": "^1.2.0"
},
"devDependencies": {
"@types/node": "^20.5.9",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"autoprefixer": "^10.4.15",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"eslint": "^8.45.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"jest": "^29.6.4",
"postcss": "^8.4.29",
"postcss-loader": "^7.3.3",
"prettier": "^3.0.3",
"resolve-typescript-plugin": "^2.0.1",
"style-loader": "^3.3.3",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.4",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"util": "^0.12.5",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"files": [
"dest",
"src",
"!*.test.*"
],
"types": "./dest/index.d.ts"
}
6 changes: 6 additions & 0 deletions yarn-project/boxes/private-token/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const tailwindcss = require('tailwindcss');
const autoprefixer = require('autoprefixer');

module.exports = {
plugins: [tailwindcss('./tailwind.config.cjs'), autoprefixer],
};
4 changes: 4 additions & 0 deletions yarn-project/boxes/private-token/src/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.svg' {
const content: any;
export default content;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i feel like this may not be right? i dont know how about exporting types

43 changes: 43 additions & 0 deletions yarn-project/boxes/private-token/src/app/components/banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
interface Props {
background: string;
direction: string;
animated?: boolean;
}

/**
*
* @param background - background color, either "black" or "purple"
* @returns a moving banner repeating the word PRIVACY
*/
export function Banner({ background, direction, animated }: Props) {
// Determine direction
const start = !animated ? '' : direction === 'reverse' ? 'animate-marquee' : 'animate-marquee3';
const end = !animated ? '' : direction === 'reverse' ? 'animate-marquee2' : 'animate-marquee4';

// Apply relevant color styles
const containerStyles =
background === 'black'
? `relative flex overflow-x-hidden bg-indigo-950 text-orange-100`
: `relative flex overflow-x-hidden bg-orange-100 text-indigo-950`;

return (
<div className={containerStyles}>
<div className={`py-2 whitespace-nowrap ${start}`}>
{/* Generate text elements */}
{Array.from({ length: 50 }, (_, index) => (
<span className="mx-4 text-2xl NBInter" key={index}>
PRIVACY
</span>
))}
</div>
<div className={`absolute top-0 py-2 whitespace-nowrap ${end}`}>
{/* Generate text elements */}
{Array.from({ length: 50 }, (_, index) => (
<span className="mx-4 text-2xl NBInter" key={index}>
PRIVACY
</span>
))}
</div>
</div>
);
}
Loading