@aztec/aztec.js 0.16.3 → 0.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dest/artifacts/ecdsa_account_contract.json +2 -2
  2. package/dest/artifacts/schnorr_account_contract.json +2 -2
  3. package/dest/artifacts/schnorr_single_key_account_contract.json +2 -2
  4. package/dest/index.d.ts +8 -7
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +7 -6
  7. package/package.json +5 -5
  8. package/src/account/contract/base_account_contract.ts +0 -25
  9. package/src/account/contract/ecdsa_account_contract.ts +0 -38
  10. package/src/account/contract/index.ts +0 -37
  11. package/src/account/contract/schnorr_account_contract.ts +0 -38
  12. package/src/account/contract/single_key_account_contract.ts +0 -45
  13. package/src/account/defaults/default_entrypoint.ts +0 -102
  14. package/src/account/defaults/default_interface.ts +0 -38
  15. package/src/account/defaults/entrypoint_payload.ts +0 -89
  16. package/src/account/defaults/index.ts +0 -3
  17. package/src/account/index.ts +0 -124
  18. package/src/account/interface.ts +0 -35
  19. package/src/account/manager/deploy_account_sent_tx.ts +0 -42
  20. package/src/account/manager/index.ts +0 -156
  21. package/src/account/manager/util.ts +0 -29
  22. package/src/account/utils.ts +0 -47
  23. package/src/api/README.md +0 -7
  24. package/src/api/abi.ts +0 -1
  25. package/src/api/aztec_address.ts +0 -1
  26. package/src/api/eth_address.ts +0 -1
  27. package/src/api/ethereum.ts +0 -6
  28. package/src/api/fields.ts +0 -1
  29. package/src/api/init.ts +0 -1
  30. package/src/api/interfaces/pxe.ts +0 -1
  31. package/src/api/log_id.ts +0 -1
  32. package/src/api/tx_hash.ts +0 -1
  33. package/src/artifacts/ecdsa_account_contract.json +0 -699
  34. package/src/artifacts/schnorr_account_contract.json +0 -687
  35. package/src/artifacts/schnorr_single_key_account_contract.json +0 -622
  36. package/src/contract/base_contract_interaction.ts +0 -61
  37. package/src/contract/batch_call.ts +0 -23
  38. package/src/contract/checker.ts +0 -117
  39. package/src/contract/contract.ts +0 -59
  40. package/src/contract/contract_base.ts +0 -70
  41. package/src/contract/contract_function_interaction.ts +0 -80
  42. package/src/contract/index.ts +0 -42
  43. package/src/contract/sent_tx.ts +0 -137
  44. package/src/contract_deployer/contract_deployer.ts +0 -26
  45. package/src/contract_deployer/deploy_method.ts +0 -139
  46. package/src/contract_deployer/deploy_sent_tx.ts +0 -71
  47. package/src/contract_deployer/index.ts +0 -3
  48. package/src/index.ts +0 -137
  49. package/src/pxe_client.ts +0 -63
  50. package/src/sandbox/index.ts +0 -85
  51. package/src/utils/abi_types.ts +0 -10
  52. package/src/utils/authwit.ts +0 -24
  53. package/src/utils/cheat_codes.ts +0 -300
  54. package/src/utils/defaults.ts +0 -4
  55. package/src/utils/index.ts +0 -7
  56. package/src/utils/l1_contracts.ts +0 -21
  57. package/src/utils/l2_contracts.ts +0 -12
  58. package/src/utils/pub_key.ts +0 -12
  59. package/src/utils/secrets.ts +0 -11
  60. package/src/wallet/account_wallet.ts +0 -86
  61. package/src/wallet/base_wallet.ts +0 -120
  62. package/src/wallet/index.ts +0 -12
  63. package/src/wallet/signerless_wallet.ts +0 -38
@@ -1,139 +0,0 @@
1
- import {
2
- CompleteAddress,
3
- ContractDeploymentData,
4
- FunctionData,
5
- TxContext,
6
- getContractDeploymentInfo,
7
- } from '@aztec/circuits.js';
8
- import { ContractArtifact, FunctionArtifact, encodeArguments } from '@aztec/foundation/abi';
9
- import { EthAddress } from '@aztec/foundation/eth-address';
10
- import { Fr } from '@aztec/foundation/fields';
11
- import { PXE, PackedArguments, PublicKey, Tx, TxExecutionRequest } from '@aztec/types';
12
-
13
- import { BaseContractInteraction } from '../contract/base_contract_interaction.js';
14
- import { Contract, ContractBase, SendMethodOptions } from '../contract/index.js';
15
- import { DeploySentTx } from './deploy_sent_tx.js';
16
-
17
- /**
18
- * Options for deploying a contract on the Aztec network.
19
- * Allows specifying a portal contract, contract address salt, and additional send method options.
20
- */
21
- export type DeployOptions = {
22
- /**
23
- * The Ethereum address of the Portal contract.
24
- */
25
- portalContract?: EthAddress;
26
- /**
27
- * An optional salt value used to deterministically calculate the contract address.
28
- */
29
- contractAddressSalt?: Fr;
30
- } & SendMethodOptions;
31
-
32
- /**
33
- * Creates a TxRequest from a contract ABI, for contract deployment.
34
- * Extends the ContractFunctionInteraction class.
35
- */
36
- export class DeployMethod<TContract extends ContractBase = Contract> extends BaseContractInteraction {
37
- /** The complete address of the contract. */
38
- public completeAddress?: CompleteAddress = undefined;
39
-
40
- /** Constructor function to call. */
41
- private constructorArtifact: FunctionArtifact;
42
-
43
- constructor(
44
- private publicKey: PublicKey,
45
- protected pxe: PXE,
46
- private artifact: ContractArtifact,
47
- private args: any[] = [],
48
- ) {
49
- super(pxe);
50
- const constructorArtifact = artifact.functions.find(f => f.name === 'constructor');
51
- if (!constructorArtifact) {
52
- throw new Error('Cannot find constructor in the artifact.');
53
- }
54
- this.constructorArtifact = constructorArtifact;
55
- }
56
-
57
- /**
58
- * Create a contract deployment transaction, given the deployment options.
59
- * This function internally calls `request()` and `sign()` methods to prepare
60
- * the transaction for deployment. The resulting signed transaction can be
61
- * later sent using the `send()` method.
62
- *
63
- * @param options - An object containing optional deployment settings, including portalContract, contractAddressSalt, and from.
64
- * @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
65
- */
66
- public async create(options: DeployOptions = {}) {
67
- const portalContract = options.portalContract ?? EthAddress.ZERO;
68
- const contractAddressSalt = options.contractAddressSalt ?? Fr.random();
69
-
70
- const { chainId, protocolVersion } = await this.pxe.getNodeInfo();
71
-
72
- const { completeAddress, constructorHash, functionTreeRoot } = getContractDeploymentInfo(
73
- this.artifact,
74
- this.args,
75
- contractAddressSalt,
76
- this.publicKey,
77
- );
78
-
79
- const contractDeploymentData = new ContractDeploymentData(
80
- this.publicKey,
81
- constructorHash,
82
- functionTreeRoot,
83
- contractAddressSalt,
84
- portalContract,
85
- );
86
-
87
- const txContext = new TxContext(
88
- false,
89
- false,
90
- true,
91
- contractDeploymentData,
92
- new Fr(chainId),
93
- new Fr(protocolVersion),
94
- );
95
- const args = encodeArguments(this.constructorArtifact, this.args);
96
- const functionData = FunctionData.fromAbi(this.constructorArtifact);
97
- const execution = { args, functionData, to: completeAddress.address };
98
- const packedArguments = PackedArguments.fromArgs(execution.args);
99
-
100
- const txRequest = TxExecutionRequest.from({
101
- origin: execution.to,
102
- functionData: execution.functionData,
103
- argsHash: packedArguments.hash,
104
- txContext,
105
- packedArguments: [packedArguments],
106
- authWitnesses: [],
107
- });
108
-
109
- this.txRequest = txRequest;
110
- this.completeAddress = completeAddress;
111
-
112
- // TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
113
- await this.pxe.addContracts([{ artifact: this.artifact, completeAddress, portalContract }]);
114
-
115
- return this.txRequest;
116
- }
117
-
118
- /**
119
- * Send the contract deployment transaction using the provided options.
120
- * This function extends the 'send' method from the ContractFunctionInteraction class,
121
- * allowing us to send a transaction specifically for contract deployment.
122
- *
123
- * @param options - An object containing various deployment options such as portalContract, contractAddressSalt, and from.
124
- * @returns A SentTx object that returns the receipt and the deployed contract instance.
125
- */
126
- public send(options: DeployOptions = {}): DeploySentTx<TContract> {
127
- const txHashPromise = super.send(options).getTxHash();
128
- return new DeploySentTx(this.artifact, this.pxe, txHashPromise, this.completeAddress);
129
- }
130
-
131
- /**
132
- * Simulate the request.
133
- * @param options - Deployment options.
134
- * @returns The simulated tx.
135
- */
136
- public simulate(options: DeployOptions): Promise<Tx> {
137
- return super.simulate(options);
138
- }
139
- }
@@ -1,71 +0,0 @@
1
- import { AztecAddress, CompleteAddress, FieldsOf } from '@aztec/circuits.js';
2
- import { ContractArtifact } from '@aztec/foundation/abi';
3
- import { PXE, TxHash, TxReceipt } from '@aztec/types';
4
-
5
- import { Contract } from '../contract/contract.js';
6
- import { ContractBase } from '../contract/contract_base.js';
7
- import { SentTx, WaitOpts } from '../contract/sent_tx.js';
8
- import { Wallet } from '../wallet/index.js';
9
-
10
- /** Options related to waiting for a deployment tx. */
11
- export type DeployedWaitOpts = WaitOpts & {
12
- /** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
13
- wallet?: Wallet;
14
- };
15
-
16
- /** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
17
- export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsOf<TxReceipt> & {
18
- /** Instance of the newly deployed contract. */
19
- contract: TContract;
20
- };
21
-
22
- /**
23
- * A contract deployment transaction sent to the network, extending SentTx with methods to create a contract instance.
24
- */
25
- export class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
26
- constructor(
27
- private artifact: ContractArtifact,
28
- wallet: PXE | Wallet,
29
- txHashPromise: Promise<TxHash>,
30
-
31
- /**
32
- * The complete address of the deployed contract
33
- */
34
- public completeContractAddress?: CompleteAddress,
35
- ) {
36
- super(wallet, txHashPromise);
37
- }
38
-
39
- /**
40
- * Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
41
- * @param opts - Options for configuring the waiting for the tx to be mined.
42
- * @returns The deployed contract instance.
43
- */
44
- public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
45
- const receipt = await this.wait(opts);
46
- return receipt.contract;
47
- }
48
-
49
- /**
50
- * Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
51
- * @param opts - Options for configuring the waiting for the tx to be mined.
52
- * @returns The transaction receipt with the deployed contract instance.
53
- */
54
- public async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
55
- const receipt = await super.wait(opts);
56
- const contract = await this.getContractInstance(opts?.wallet, receipt.contractAddress);
57
- return { ...receipt, contract };
58
- }
59
-
60
- protected getContractInstance(wallet?: Wallet, address?: AztecAddress): Promise<TContract> {
61
- const isWallet = (pxe: PXE | Wallet): pxe is Wallet => !!(pxe as Wallet).createTxExecutionRequest;
62
- const contractWallet = wallet ?? (isWallet(this.pxe) && this.pxe);
63
- if (!contractWallet) {
64
- throw new Error(`A wallet is required for creating a contract instance`);
65
- }
66
- if (!address) {
67
- throw new Error(`Contract address is missing from transaction receipt`);
68
- }
69
- return Contract.at(address, this.artifact, contractWallet) as Promise<TContract>;
70
- }
71
- }
@@ -1,3 +0,0 @@
1
- export * from './contract_deployer.js';
2
- export * from './deploy_sent_tx.js';
3
- export * from './deploy_method.js';
package/src/index.ts DELETED
@@ -1,137 +0,0 @@
1
- /**
2
- * This is our public api.
3
- * Do NOT "export * from ..." here.
4
- * Everything here should be explicit, to ensure we can clearly see everything we're exposing to the world.
5
- * If it's exposed, people will use it, and then we can't remove/change the api without breaking client code.
6
- * At the time of writing we overexpose things that should only be internal.
7
- *
8
- * TODO: Review and narrow scope of public api.
9
- * We should also consider exposing subsections of the api via package.json exports, like we do with foundation.
10
- * This can allow consumers to import much smaller parts of the library to incur less overhead.
11
- * It will also allow web bundlers do perform intelligent chunking of bundles etc.
12
- * Some work as been done on this within the api folder, providing the alternative import style of e.g.:
13
- * ```typescript
14
- * import { TxHash } from '@aztec.js/tx_hash'
15
- * import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/aztec.js/abi';
16
- * import { AztecAddress } from '@aztec/aztec.js/aztec_address';
17
- * import { EthAddress } from '@aztec/aztec.js/eth_address';
18
- * ```
19
- */
20
- export {
21
- WaitOpts,
22
- ContractFunctionInteraction,
23
- Contract,
24
- ContractBase,
25
- ContractMethod,
26
- SentTx,
27
- BatchCall,
28
- } from './contract/index.js';
29
-
30
- export { ContractDeployer, DeployMethod, DeploySentTx } from './contract_deployer/index.js';
31
-
32
- export {
33
- generatePublicKey,
34
- FieldLike,
35
- EthAddressLike,
36
- computeMessageSecretHash,
37
- CheatCodes,
38
- AztecAddressLike,
39
- isContractDeployed,
40
- EthCheatCodes,
41
- computeAuthWitMessageHash,
42
- } from './utils/index.js';
43
-
44
- export { createPXEClient } from './pxe_client.js';
45
-
46
- export {
47
- CompleteAddress,
48
- getSchnorrAccount,
49
- AccountContract,
50
- AccountManager,
51
- getUnsafeSchnorrAccount,
52
- EcdsaAccountContract,
53
- createAccounts,
54
- SchnorrAccountContract,
55
- SingleKeyAccountContract,
56
- createAccount,
57
- AuthWitnessProvider,
58
- BaseAccountContract,
59
- } from './account/index.js';
60
-
61
- export { waitForSandbox, getSandboxAccountsWallets, deployInitialSandboxAccounts } from './sandbox/index.js';
62
-
63
- export { AccountWalletWithPrivateKey, AccountWallet, Wallet, SignerlessWallet } from './wallet/index.js';
64
-
65
- // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
66
- // here once the issue is resolved.
67
- export {
68
- AztecAddress,
69
- EthAddress,
70
- Point,
71
- Fr,
72
- Fq,
73
- FunctionSelector,
74
- GlobalVariables,
75
- GrumpkinScalar,
76
- getContractDeploymentInfo,
77
- } from '@aztec/circuits.js';
78
-
79
- export { Grumpkin, Schnorr } from '@aztec/circuits.js/barretenberg';
80
-
81
- export {
82
- AuthWitness,
83
- AztecNode,
84
- ContractData,
85
- DeployedContract,
86
- ExtendedContractData,
87
- ExtendedNote,
88
- FunctionCall,
89
- INITIAL_L2_BLOCK_NUM,
90
- GrumpkinPrivateKey,
91
- L2Actor,
92
- L2Block,
93
- L2BlockL2Logs,
94
- LogFilter,
95
- LogId,
96
- LogType,
97
- MerkleTreeId,
98
- NodeInfo,
99
- Note,
100
- PackedArguments,
101
- PartialAddress,
102
- PublicKey,
103
- PXE,
104
- SyncStatus,
105
- Tx,
106
- TxExecutionRequest,
107
- TxHash,
108
- TxReceipt,
109
- TxStatus,
110
- UnencryptedL2Log,
111
- emptyFunctionCall,
112
- createAztecNodeClient,
113
- merkleTreeIds,
114
- mockTx,
115
- } from '@aztec/types';
116
-
117
- export { ContractArtifact, FunctionArtifact } from '@aztec/foundation/abi';
118
-
119
- // TODO: These kinds of things have no place on our public api.
120
- // External devs will almost certainly have their own methods of doing these things.
121
- // If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
122
- export { DebugLogger, createDebugLogger, onLog } from '@aztec/foundation/log';
123
- export { fileURLToPath } from '@aztec/foundation/url';
124
- export { sleep } from '@aztec/foundation/sleep';
125
- export { elapsed } from '@aztec/foundation/timer';
126
- export { retry, retryUntil } from '@aztec/foundation/retry';
127
- export { sha256, init } from '@aztec/foundation/crypto';
128
- export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
129
- export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
130
- export { makeFetch } from '@aztec/foundation/json-rpc/client';
131
-
132
- export {
133
- deployL1Contract,
134
- deployL1Contracts,
135
- DeployL1Contracts,
136
- L1ContractArtifactsForDeployment,
137
- } from '@aztec/ethereum';
package/src/pxe_client.ts DELETED
@@ -1,63 +0,0 @@
1
- import {
2
- AztecAddress,
3
- CompleteAddress,
4
- EthAddress,
5
- Fr,
6
- FunctionSelector,
7
- GrumpkinScalar,
8
- Point,
9
- } from '@aztec/circuits.js';
10
- import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
11
- import {
12
- AuthWitness,
13
- ContractData,
14
- ExtendedContractData,
15
- ExtendedNote,
16
- ExtendedUnencryptedL2Log,
17
- L2Block,
18
- L2BlockL2Logs,
19
- L2Tx,
20
- LogId,
21
- Note,
22
- PXE,
23
- Tx,
24
- TxExecutionRequest,
25
- TxHash,
26
- TxReceipt,
27
- } from '@aztec/types';
28
-
29
- export { makeFetch } from '@aztec/foundation/json-rpc/client';
30
-
31
- /**
32
- * Creates a JSON-RPC client to remotely talk to PXE.
33
- * @param url - The URL of the PXE.
34
- * @param fetch - The fetch implementation to use.
35
- * @returns A JSON-RPC client of PXE.
36
- */
37
- export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], true)): PXE =>
38
- createJsonRpcClient<PXE>(
39
- url,
40
- {
41
- CompleteAddress,
42
- FunctionSelector,
43
- AztecAddress,
44
- TxExecutionRequest,
45
- ContractData,
46
- ExtendedContractData,
47
- ExtendedUnencryptedL2Log,
48
- TxHash,
49
- EthAddress,
50
- Point,
51
- Fr,
52
- GrumpkinScalar,
53
- Note,
54
- ExtendedNote,
55
- AuthWitness,
56
- L2Tx,
57
- LogId,
58
- L2Block,
59
- },
60
- { Tx, TxReceipt, L2BlockL2Logs },
61
- false,
62
- fetch,
63
- );
@@ -1,85 +0,0 @@
1
- import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
2
- import { sleep } from '@aztec/foundation/sleep';
3
-
4
- import zip from 'lodash.zip';
5
-
6
- import SchnorrAccountContractArtifact from '../artifacts/schnorr_account_contract.json' assert { type: 'json' };
7
- import { AccountWalletWithPrivateKey, PXE, createPXEClient, getSchnorrAccount } from '../index.js';
8
-
9
- export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [
10
- GrumpkinScalar.fromString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
11
- GrumpkinScalar.fromString('aebd1b4be76efa44f5ee655c20bf9ea60f7ae44b9a7fd1fd9f189c7a0b0cdae'),
12
- GrumpkinScalar.fromString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c'),
13
- ];
14
-
15
- export const INITIAL_SANDBOX_SIGNING_KEYS = INITIAL_SANDBOX_ENCRYPTION_KEYS;
16
-
17
- export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
18
-
19
- export const INITIAL_SANDBOX_ACCOUNT_CONTRACT_ABI = SchnorrAccountContractArtifact;
20
-
21
- export const { PXE_URL = 'http://localhost:8080' } = process.env;
22
-
23
- /**
24
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the sandbox.
25
- * @param pxe - PXE instance.
26
- * @returns A set of AccountWallet implementations for each of the initial accounts.
27
- */
28
- export function getSandboxAccountsWallets(pxe: PXE): Promise<AccountWalletWithPrivateKey[]> {
29
- return Promise.all(
30
- zip(INITIAL_SANDBOX_ENCRYPTION_KEYS, INITIAL_SANDBOX_SIGNING_KEYS, INITIAL_SANDBOX_SALTS).map(
31
- ([encryptionKey, signingKey, salt]) => getSchnorrAccount(pxe, encryptionKey!, signingKey!, salt).getWallet(),
32
- ),
33
- );
34
- }
35
-
36
- /**
37
- * Deploys the initial set of schnorr signature accounts to the sandbox
38
- * @param pxe - PXE instance.
39
- * @returns The set of deployed Account objects and associated private encryption keys
40
- */
41
- export async function deployInitialSandboxAccounts(pxe: PXE) {
42
- const accounts = INITIAL_SANDBOX_ENCRYPTION_KEYS.map((privateKey, i) => {
43
- const account = getSchnorrAccount(pxe, privateKey, INITIAL_SANDBOX_SIGNING_KEYS[i], INITIAL_SANDBOX_SALTS[i]);
44
- return {
45
- account,
46
- privateKey,
47
- };
48
- });
49
- // Attempt to get as much parallelism as possible
50
- const deployMethods = await Promise.all(
51
- accounts.map(async x => {
52
- const deployMethod = await x.account.getDeployMethod();
53
- await deployMethod.create({ contractAddressSalt: x.account.salt });
54
- await deployMethod.simulate({});
55
- return deployMethod;
56
- }),
57
- );
58
- // Send tx together to try and get them in the same rollup
59
- const sentTxs = deployMethods.map(dm => {
60
- return dm.send();
61
- });
62
- await Promise.all(
63
- sentTxs.map(async (tx, i) => {
64
- const wallet = await accounts[i].account.getWallet();
65
- return tx.wait({ wallet });
66
- }),
67
- );
68
- return accounts;
69
- }
70
-
71
- /**
72
- * Function to wait until the sandbox becomes ready for use.
73
- * @param pxe - The pxe client connected to the sandbox.
74
- */
75
- export async function waitForSandbox(pxe?: PXE) {
76
- pxe = pxe ?? createPXEClient(PXE_URL);
77
- while (true) {
78
- try {
79
- await pxe.getNodeInfo();
80
- break;
81
- } catch (err) {
82
- await sleep(1000);
83
- }
84
- }
85
- }
@@ -1,10 +0,0 @@
1
- import { AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
2
-
3
- /** Any type that can be converted into a field for a contract call. */
4
- export type FieldLike = Fr | Buffer | bigint | number | { /** Converts to field */ toField: () => Fr };
5
-
6
- /** Any type that can be converted into an EthereumAddress Aztec.nr struct. */
7
- export type EthAddressLike = { /** Wrapped address */ address: FieldLike } | EthAddress;
8
-
9
- /** Any type that can be converted into an EthereumAddress Aztec.nr struct. */
10
- export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress;
@@ -1,24 +0,0 @@
1
- import { AztecAddress, GeneratorIndex } from '@aztec/circuits.js';
2
- import { pedersenHash } from '@aztec/foundation/crypto';
3
- import { FunctionCall, PackedArguments } from '@aztec/types';
4
-
5
- // docs:start:authwit_computeAuthWitMessageHash
6
- /**
7
- * Compute an authentication witness message hash from a caller and a request
8
- * H(caller: AztecAddress, target: AztecAddress, selector: Field, args_hash: Field)
9
- * @param caller - The caller approved to make the call
10
- * @param request - The request to be made (function call)
11
- * @returns The message hash for the witness
12
- */
13
- export const computeAuthWitMessageHash = (caller: AztecAddress, request: FunctionCall) => {
14
- return pedersenHash(
15
- [
16
- caller.toField(),
17
- request.to.toField(),
18
- request.functionData.selector.toField(),
19
- PackedArguments.fromArgs(request.args).hash,
20
- ].map(fr => fr.toBuffer()),
21
- GeneratorIndex.SIGNATURE_PAYLOAD,
22
- );
23
- };
24
- // docs:end:authwit_computeAuthWitMessageHash