-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(boxes): adding clone contract option (#4980)
- Loading branch information
1 parent
426bd6d
commit a427aa5
Showing
21 changed files
with
793 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
node_modules | ||
dest | ||
src/contracts/target | ||
boxes/**/contracts/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.yarn/* | ||
!.yarn/releases | ||
|
||
node_modules | ||
dist | ||
artifacts | ||
src/contracts/target | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
codegenCache.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/artifacts/**/*.json | ||
src/artifacts/**/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 120, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Contract-Only Box | ||
|
||
This box is a one-stop-shop for Aztec with the %%contract_name%% example contract. You can use it as a boilerplate to start developing your own Aztec app in seconds! | ||
|
||
## How to start | ||
|
||
The script copied one of the example contracts and put it into a one-size-fits-all "box". With it, you can run commands such as: | ||
|
||
- `yarn test` -> Runs the built-in tests | ||
- `yarn compile` -> Compiles your contract so it can be deployed | ||
- `yarn codegen` -> Generates a handy TS interface file with all your contract's methods so they're easy to interact with | ||
- `yarn clean` -> Removes artifacts and other things you may not want to have lying around | ||
- `yarn formatting` -> Formats your code with prettier | ||
- | ||
|
||
## Testing | ||
|
||
Contract-only boxes give you basic test functionality through `jest`, and check for existence and correct working of the sandbox. | ||
|
||
If you want some ideas to test the contract you just bootstrapped, check out [our own e2e test suite!](%%e2e_test_url%%) | ||
|
||
## More information | ||
|
||
Visit the [Aztec Docs](https://docs.aztec.network) for more information on how Aztec works, and the [Awesome Aztec Repository](https://github.com/AztecProtocol/awesome-aztec) for more cool projects, boilerplates and tooling. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "@aztec/contract_box", | ||
"description": "My Aztec contract", | ||
"private": true, | ||
"version": "0.1.0", | ||
"type": "module", | ||
"scripts": { | ||
"compile": "cd src && ${AZTEC_NARGO:-aztec-nargo} compile", | ||
"codegen": "${AZTEC_CLI:-aztec-cli} codegen target -o artifacts --ts", | ||
"clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./target", | ||
"prep": "yarn clean && yarn compile && yarn codegen && tsc -b", | ||
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand", | ||
"formatting": "prettier --check ./src && eslint ./src", | ||
"formatting:fix": "prettier -w ./src" | ||
}, | ||
"dependencies": { | ||
"@aztec/accounts": "latest", | ||
"@aztec/aztec.js": "latest" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest/presets/default-esm", | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": [ | ||
"ts-jest", | ||
{ | ||
"useESM": true | ||
} | ||
] | ||
}, | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.js$": "$1" | ||
}, | ||
"testRegex": "tests/.*\\.test\\.ts$", | ||
"rootDir": "./" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "1.42.0", | ||
"@types/jest": "^29.5.0", | ||
"@types/node": "^20.11.17", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"html-webpack-plugin": "^5.6.0", | ||
"jest": "^29.6.4", | ||
"stream-browserify": "^3.0.0", | ||
"ts-loader": "^9.5.1", | ||
"tty-browserify": "^0.0.1", | ||
"typescript": "^5.0.4", | ||
"util": "^0.12.5", | ||
"webpack": "^5.90.1", | ||
"webpack-cli": "^5.1.4", | ||
"webpack-dev-server": "^4.15.1" | ||
}, | ||
"packageManager": "yarn@4.0.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { createPXEClient, PXE, GrumpkinScalar, AccountManager, Wallet } from '@aztec/aztec.js'; | ||
import { SingleKeyAccountContract } from '@aztec/accounts/single_key'; | ||
import { derivePublicKey } from '@aztec/circuits.js'; | ||
|
||
describe('Account Tests', () => { | ||
const pxeURL = process.env.PXE_URL || 'http://localhost:8080'; | ||
let pxe: PXE; | ||
let account: AccountManager; | ||
let wallet: Wallet; | ||
|
||
const privateKey = GrumpkinScalar.fromString('0x1234'); | ||
const expectedPublicKey = derivePublicKey(privateKey).toString(); | ||
|
||
test('Can start the PXE server', async () => { | ||
pxe = createPXEClient(pxeURL); | ||
const { chainId } = await pxe.getNodeInfo(); | ||
expect(chainId).toBe(31337); | ||
}); | ||
|
||
beforeEach(() => { | ||
const accountContract = new SingleKeyAccountContract(privateKey); | ||
account = new AccountManager(pxe, privateKey, accountContract); | ||
}); | ||
|
||
test('Can create an account contract with a known address', async () => { | ||
const publicKey = account.getCompleteAddress().publicKey.toString(); | ||
expect(publicKey).toEqual(expectedPublicKey); | ||
}); | ||
|
||
test('Can deploy a contract with a known address', async () => { | ||
({ wallet } = await (await account.deploy()).wait()); | ||
const publicKey = wallet.getCompleteAddress().publicKey.toString(); | ||
expect(publicKey).toEqual(expectedPublicKey); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2020", | ||
"outDir": "artifacts/build", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"skipLibCheck": true | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
Oops, something went wrong.