-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CLI wallet initial version (#7651)
Initial version of the CLI wallet, basically porting the old CLI commands `create-account`, `deploy` and `send`. Instead of specifying a private key, whenever an account is created an alias can be given to it via the `-a` param. This will store the account info (including secret key!) in a DB, so that the account alias can be referenced later in the other commands. `aztec-wallet create-account -a main` ``` New account: Address: 0x032fc6676fea75427cffc4fafffb1ae8ec29340bc1d5814ec56c5d82fe8eec51 Public key: 0x27aaf1b4f4250d45a085524ae0e7dd4bfe62c3e7de7c3c614fd7b0fe34af21152cea6630aed6b3bddda2f2918bdd8e590e1cbcdd01a82fa95ac44dc758d6cac526ccd74bb8c11c4fc7014ed558a001583c7cf9a65c8adb2840763c325e29fc6e185acaa0f6dce3ccfec068ef090d7b450c6ad540a4e86baf204f53acab7839542bb4c2b71210b02c59bca7870d0973861a01688811acf2263f1eeefa459c240e280b949204c944e63349710c939898e739354f700cbcd427b059b558e818625325426f0ab1586937384e222000974bd917d5e498cfa7f83118096fdf176b617b2a41aeae4d6ab0d1ff9035d6295782d42a40087111aa6215cdbdd633402dd726 Private key: 0x252cef68955eee66a0f346eea4eff84d8dfca1740794436913c10c49ce1b5566 Partial address: 0x011e89c12b17cb0a602369148e82c2dd2910a7ad847cbcb818fb9bffbce02b6b Salt: 0x0000000000000000000000000000000000000000000000000000000000000000 Init hash: 0x0673bba8f408c1bcf6faaaec4e526662871386562d8c98ff303a138599a977c1 Deployer: 0x0000000000000000000000000000000000000000000000000000000000000000 Waiting for account contract deployment... Deploy tx hash: 2e6f063986636d3aa96c1bdc9546f96c5f40472fac2ff1031cc79186c0a87573 Deploy tx fee: 200013616 ``` And then you can do: `aztec-wallet deploy ./noir-projects/noir-contracts.js/artifacts/token_contract-Token.json --args 0x032fc6676fea75427cffc4fafffb1ae8ec29340bc1d5814ec56c5d82fe8eec51 Test TST 18 -a main` The new wallet command (`aztec-wallet`) is added as part of the suite of tools users get when doing `aztec-up`
- Loading branch information
Showing
74 changed files
with
673 additions
and
338 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
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,11 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
export SKIP_NET=1 | ||
export SKIP_PORT_ASSIGNMENT=1 | ||
export WALLET_DATA_DIRECTORY=$(dirname $0)/wallet-data | ||
export ENV_VARS_TO_INJECT=WALLET_DATA_DIRECTORY | ||
|
||
mkdir -p $WALLET_DATA_DIRECTORY | ||
|
||
$(dirname $0)/.aztec-run aztecprotocol/cli-wallet $@ |
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './pxe_client.js'; | ||
export * from './node/index.js'; |
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,69 @@ | ||
import { type PXE } from '@aztec/circuit-types'; | ||
import { type DebugLogger } from '@aztec/foundation/log'; | ||
import { NoRetryError } from '@aztec/foundation/retry'; | ||
|
||
import axios, { type AxiosError, type AxiosResponse } from 'axios'; | ||
|
||
import { createPXEClient } from '../pxe_client.js'; | ||
|
||
/** | ||
* A fetch implementation using axios. | ||
* @param host - The URL of the host. | ||
* @param rpcMethod - The RPC method to call. | ||
* @param body - The body of the request. | ||
* @param useApiEndpoints - Whether to use the API endpoints or inject the method in the body. | ||
* @param _noRetry - Whether to retry on non-server errors. | ||
* @returns The response data. | ||
*/ | ||
async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndpoints: boolean, _noRetry = true) { | ||
let resp: AxiosResponse; | ||
if (useApiEndpoints) { | ||
resp = await axios | ||
.post(`${host}/${rpcMethod}`, body, { | ||
headers: { 'content-type': 'application/json' }, | ||
}) | ||
.catch((error: AxiosError) => { | ||
if (error.response) { | ||
return error.response; | ||
} | ||
throw error; | ||
}); | ||
} else { | ||
resp = await axios | ||
.post( | ||
host, | ||
{ ...body, method: rpcMethod }, | ||
{ | ||
headers: { 'content-type': 'application/json' }, | ||
}, | ||
) | ||
.catch((error: AxiosError) => { | ||
if (error.response) { | ||
return error.response; | ||
} | ||
throw error; | ||
}); | ||
} | ||
|
||
const isOK = resp.status >= 200 && resp.status < 300; | ||
if (isOK) { | ||
return resp.data; | ||
} else if (resp.status >= 400 && resp.status < 500) { | ||
throw new NoRetryError('(JSON-RPC PROPAGATED) ' + resp.data.error.message); | ||
} else { | ||
throw new Error('(JSON-RPC PROPAGATED) ' + resp.data.error.message); | ||
} | ||
} | ||
|
||
/** | ||
* Creates a PXE client with a given set of retries on non-server errors. | ||
* Checks that PXE matches the expected version, and warns if not. | ||
* @param rpcUrl - URL of the RPC server wrapping the PXE. | ||
* @param _logger - Debug logger to warn version incompatibilities. | ||
* @returns A PXE client. | ||
*/ | ||
export function createCompatibleClient(rpcUrl: string, _logger: DebugLogger): Promise<PXE> { | ||
// Use axios due to timeout issues with fetch when proving TXs. | ||
const pxe = createPXEClient(rpcUrl, axiosFetch); | ||
return Promise.resolve(pxe); | ||
} |
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
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 |
---|---|---|
|
@@ -36,6 +36,9 @@ | |
{ | ||
"path": "../cli" | ||
}, | ||
{ | ||
"path": "../cli-wallet" | ||
}, | ||
{ | ||
"path": "../entrypoints" | ||
}, | ||
|
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 @@ | ||
module.exports = require('@aztec/foundation/eslint'); |
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 @@ | ||
FROM aztecprotocol/yarn-project AS yarn-project | ||
ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/cli-wallet/dest/bin/index.js"] | ||
|
||
# The version has been updated in yarn-project. | ||
# Adding COMMIT_TAG here to rebuild versioned image. | ||
ARG COMMIT_TAG="" |
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 @@ | ||
# Aztec wallet Documentation | ||
|
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,96 @@ | ||
{ | ||
"name": "@aztec/cli-wallet", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"exports": { | ||
".": "./dest/cmds/index.js", | ||
"./cli": "./dest/bin/index.js" | ||
}, | ||
"typedocOptions": { | ||
"entryPoints": [ | ||
"./src/cmds/index.ts" | ||
], | ||
"name": "Aztec CLI wallet", | ||
"tsconfig": "./tsconfig.json" | ||
}, | ||
"bin": { | ||
"aztec-wallet": "./dest/bin/index.js" | ||
}, | ||
"scripts": { | ||
"start": "node --no-warnings ./dest/bin", | ||
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin", | ||
"dev": "DEBUG='aztec:*' LOG_LEVEL=debug && node ./dest/bin", | ||
"build": "yarn clean && tsc -b", | ||
"build:dev": "tsc -b --watch", | ||
"clean": "rm -rf ./dest .tsbuildinfo", | ||
"formatting": "run -T prettier --check ./src && run -T eslint ./src", | ||
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", | ||
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests" | ||
}, | ||
"inherits": [ | ||
"../package.common.json" | ||
], | ||
"jest": { | ||
"preset": "ts-jest/presets/default-esm", | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1" | ||
}, | ||
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", | ||
"rootDir": "./src", | ||
"extensionsToTreatAsEsm": [ | ||
".ts" | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": [ | ||
"@swc/jest", | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"reporters": [ | ||
[ | ||
"default", | ||
{ | ||
"summaryThreshold": 9999 | ||
} | ||
] | ||
] | ||
}, | ||
"dependencies": { | ||
"@aztec/accounts": "workspace:^", | ||
"@aztec/aztec.js": "workspace:^", | ||
"@aztec/circuits.js": "workspace:^", | ||
"@aztec/cli": "workspace:^", | ||
"@aztec/foundation": "workspace:^", | ||
"@aztec/kv-store": "workspace:^", | ||
"commander": "^12.1.0", | ||
"source-map-support": "^0.5.21", | ||
"tslib": "^2.4.0" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.5.0", | ||
"@types/jest": "^29.5.0", | ||
"@types/node": "^18.7.23", | ||
"@types/source-map-support": "^0.5.10", | ||
"jest": "^29.5.0", | ||
"jest-mock-extended": "^3.0.5", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.4" | ||
}, | ||
"files": [ | ||
"dest", | ||
"src", | ||
"!*.test.*" | ||
], | ||
"types": "./dest/index.d.ts", | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
Oops, something went wrong.
83f8d9c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.nativeconstruct_proof_ultrahonk_power_of_2/20
5166.802439999998
ms/iter4807.637082999989
ms/iter1.07
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ludamad @codygunton