@aztec/aztec.js 3.0.0-canary.a9708bd → 3.0.0-devnet.2
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.
- package/dest/account/account.d.ts +60 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +59 -0
- package/dest/account/account_contract.d.ts +5 -5
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_contract.js +0 -1
- package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
- package/dest/account/account_with_secret_key.d.ts.map +1 -0
- package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
- package/dest/account/index.d.ts +1 -4
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -4
- package/dest/account/signerless_account.d.ts +24 -0
- package/dest/account/signerless_account.d.ts.map +1 -0
- package/dest/account/signerless_account.js +27 -0
- package/dest/api/abi.d.ts +1 -0
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/account.d.ts +4 -2
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +3 -1
- package/dest/api/addresses.d.ts +1 -0
- package/dest/api/addresses.d.ts.map +1 -1
- package/dest/api/addresses.js +1 -0
- package/dest/api/authorization.d.ts +2 -0
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +2 -0
- package/dest/api/block.d.ts +3 -0
- package/dest/api/block.d.ts.map +1 -0
- package/dest/api/block.js +2 -0
- package/dest/api/contract.d.ts +4 -5
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -3
- package/dest/api/crypto.d.ts +2 -0
- package/dest/api/crypto.d.ts.map +1 -0
- package/dest/api/crypto.js +1 -0
- package/dest/api/ethereum.d.ts +0 -1
- package/dest/api/ethereum.d.ts.map +1 -1
- package/dest/api/ethereum.js +0 -1
- package/dest/api/events.d.ts +12 -0
- package/dest/api/events.d.ts.map +1 -0
- package/dest/api/events.js +30 -0
- package/dest/api/fee.d.ts +1 -2
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +0 -1
- package/dest/api/keys.d.ts +4 -0
- package/dest/api/keys.d.ts.map +1 -0
- package/dest/api/keys.js +3 -0
- package/dest/api/log.d.ts +1 -0
- package/dest/api/log.d.ts.map +1 -1
- package/dest/api/log.js +1 -0
- package/dest/api/messaging.d.ts +3 -0
- package/dest/api/messaging.d.ts.map +1 -0
- package/dest/api/messaging.js +2 -0
- package/dest/api/node.d.ts +21 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +18 -0
- package/dest/api/note.d.ts +2 -0
- package/dest/api/note.d.ts.map +1 -0
- package/dest/api/note.js +1 -0
- package/dest/api/protocol.d.ts +3 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +2 -0
- package/dest/api/trees.d.ts +3 -0
- package/dest/api/trees.d.ts.map +1 -0
- package/dest/api/trees.js +2 -0
- package/dest/api/tx.d.ts +2 -0
- package/dest/api/tx.d.ts.map +1 -0
- package/dest/api/tx.js +1 -0
- package/dest/api/utils.d.ts +10 -6
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +10 -5
- package/dest/api/wallet.d.ts +4 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +4 -1
- package/dest/contract/base_contract_interaction.d.ts +6 -48
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +6 -106
- package/dest/contract/batch_call.d.ts +6 -14
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +42 -52
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +2 -12
- package/dest/contract/contract_base.d.ts +1 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +29 -40
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +41 -53
- package/dest/contract/deploy_method.d.ts +63 -56
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +68 -86
- package/dest/contract/deploy_sent_tx.d.ts +0 -1
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +7 -10
- package/dest/contract/interaction_options.d.ts +74 -19
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +51 -3
- package/dest/contract/sent_tx.d.ts +3 -3
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +5 -5
- package/dest/contract/wait_for_proven.d.ts +3 -3
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +2 -2
- package/dest/deployment/publish_instance.d.ts +1 -1
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +2 -5
- package/dest/ethereum/portal_manager.d.ts +3 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +3 -5
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +12 -7
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +21 -12
- package/dest/fee/fee_payment_method.d.ts +26 -0
- package/dest/fee/fee_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_payment_method.js +3 -0
- package/dest/fee/private_fee_payment_method.d.ts +22 -5
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +34 -13
- package/dest/fee/public_fee_payment_method.d.ts +22 -5
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +37 -14
- package/dest/fee/sponsored_fee_payment.d.ts +2 -0
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +4 -0
- package/dest/utils/authwit.d.ts +77 -25
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +219 -24
- package/dest/utils/cross_chain.d.ts +24 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +30 -0
- package/dest/utils/fee_juice.d.ts +3 -2
- package/dest/utils/fee_juice.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +3 -2
- package/dest/{fee → wallet}/account_entrypoint_meta_payment_method.d.ts +13 -10
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
- package/dest/wallet/account_manager.d.ts +69 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +113 -0
- package/dest/wallet/base_wallet.d.ts +78 -35
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +216 -48
- package/dest/wallet/deploy_account_method.d.ts +52 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +77 -0
- package/dest/wallet/index.d.ts +2 -15
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +2 -19
- package/dest/wallet/wallet.d.ts +2473 -6
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +202 -3
- package/package.json +25 -21
- package/src/account/account.ts +97 -0
- package/src/account/account_contract.ts +4 -6
- package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
- package/src/account/index.ts +1 -4
- package/src/account/signerless_account.ts +46 -0
- package/src/api/abi.ts +11 -0
- package/src/api/account.ts +4 -2
- package/src/api/addresses.ts +1 -0
- package/src/api/authorization.ts +11 -0
- package/src/api/block.ts +2 -0
- package/src/api/contract.ts +16 -8
- package/src/api/crypto.ts +1 -0
- package/src/api/ethereum.ts +0 -1
- package/src/api/events.ts +44 -0
- package/src/api/fee.ts +1 -2
- package/src/api/keys.ts +8 -0
- package/src/api/log.ts +1 -0
- package/src/api/messaging.ts +2 -0
- package/src/api/node.ts +20 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +2 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +11 -0
- package/src/api/utils.ts +12 -19
- package/src/api/wallet.ts +33 -5
- package/src/contract/base_contract_interaction.ts +9 -138
- package/src/contract/batch_call.ts +52 -61
- package/src/contract/contract.ts +2 -12
- package/src/contract/contract_function_interaction.ts +65 -97
- package/src/contract/deploy_method.ts +117 -99
- package/src/contract/deploy_sent_tx.ts +4 -10
- package/src/contract/interaction_options.ts +126 -24
- package/src/contract/sent_tx.ts +4 -4
- package/src/contract/wait_for_proven.ts +4 -4
- package/src/deployment/publish_instance.ts +3 -8
- package/src/ethereum/portal_manager.ts +4 -12
- package/src/fee/fee_juice_payment_method_with_claim.ts +26 -17
- package/src/fee/fee_payment_method.ts +26 -0
- package/src/fee/private_fee_payment_method.ts +60 -41
- package/src/fee/public_fee_payment_method.ts +73 -49
- package/src/fee/sponsored_fee_payment.ts +6 -0
- package/src/utils/authwit.ts +250 -38
- package/src/utils/cross_chain.ts +53 -0
- package/src/utils/fee_juice.ts +4 -3
- package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
- package/src/wallet/account_manager.ts +154 -0
- package/src/wallet/base_wallet.ts +287 -78
- package/src/wallet/deploy_account_method.ts +125 -0
- package/src/wallet/index.ts +2 -32
- package/src/wallet/wallet.ts +357 -29
- package/dest/account_manager/account_manager.d.ts +0 -119
- package/dest/account_manager/account_manager.d.ts.map +0 -1
- package/dest/account_manager/account_manager.js +0 -202
- package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_sent_tx.js +0 -29
- package/dest/account_manager/index.d.ts +0 -3
- package/dest/account_manager/index.d.ts.map +0 -1
- package/dest/account_manager/index.js +0 -2
- package/dest/api/interfaces.d.ts +0 -2
- package/dest/api/interfaces.d.ts.map +0 -1
- package/dest/api/interfaces.js +0 -1
- package/dest/api/log_id.d.ts +0 -2
- package/dest/api/log_id.d.ts.map +0 -1
- package/dest/api/log_id.js +0 -1
- package/dest/api/rpc.d.ts +0 -3
- package/dest/api/rpc.d.ts.map +0 -1
- package/dest/api/rpc.js +0 -2
- package/dest/api/tx_hash.d.ts +0 -2
- package/dest/api/tx_hash.d.ts.map +0 -1
- package/dest/api/tx_hash.js +0 -1
- package/dest/contract/deploy_proven_tx.d.ts +0 -21
- package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
- package/dest/contract/deploy_proven_tx.js +0 -21
- package/dest/contract/proven_tx.d.ts +0 -21
- package/dest/contract/proven_tx.d.ts.map +0 -1
- package/dest/contract/proven_tx.js +0 -23
- package/dest/ethereum/l1_contracts.d.ts +0 -3
- package/dest/ethereum/l1_contracts.d.ts.map +0 -1
- package/dest/ethereum/l1_contracts.js +0 -13
- package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +0 -1
- package/dest/fee/account_entrypoint_meta_payment_method.js +0 -64
- package/dest/fee/fee_juice_payment_method.d.ts +0 -14
- package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_juice_payment_method.js +0 -21
- package/dest/fee/utils.d.ts +0 -13
- package/dest/fee/utils.d.ts.map +0 -1
- package/dest/fee/utils.js +0 -32
- package/dest/index.d.ts +0 -59
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -62
- package/dest/rpc_clients/node/index.d.ts +0 -12
- package/dest/rpc_clients/node/index.d.ts.map +0 -1
- package/dest/rpc_clients/node/index.js +0 -72
- package/dest/rpc_clients/pxe_client.d.ts +0 -10
- package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
- package/dest/rpc_clients/pxe_client.js +0 -23
- package/dest/utils/pxe.d.ts +0 -4
- package/dest/utils/pxe.d.ts.map +0 -1
- package/dest/utils/pxe.js +0 -14
- package/dest/wallet/account_wallet.d.ts +0 -74
- package/dest/wallet/account_wallet.d.ts.map +0 -1
- package/dest/wallet/account_wallet.js +0 -232
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.d.ts +0 -23
- package/dest/wallet/signerless_wallet.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.js +0 -33
- package/src/account_manager/account_manager.ts +0 -276
- package/src/account_manager/deploy_account_sent_tx.ts +0 -46
- package/src/account_manager/index.ts +0 -2
- package/src/api/interfaces.ts +0 -1
- package/src/api/log_id.ts +0 -1
- package/src/api/rpc.ts +0 -2
- package/src/api/tx_hash.ts +0 -1
- package/src/contract/deploy_proven_tx.ts +0 -45
- package/src/contract/proven_tx.ts +0 -36
- package/src/ethereum/l1_contracts.ts +0 -21
- package/src/fee/account_entrypoint_meta_payment_method.ts +0 -89
- package/src/fee/fee_juice_payment_method.ts +0 -25
- package/src/fee/utils.ts +0 -39
- package/src/index.ts +0 -85
- package/src/rpc_clients/node/index.ts +0 -77
- package/src/rpc_clients/pxe_client.ts +0 -25
- package/src/utils/pxe.ts +0 -17
- package/src/wallet/account_wallet.ts +0 -246
- package/src/wallet/signerless_wallet.ts +0 -56
package/src/index.ts
DELETED
|
@@ -1,85 +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/addresses';
|
|
17
|
-
* import { EthAddress } from '@aztec/aztec.js/eth_address';
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export { Fq, Fr, Point, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
24
|
-
|
|
25
|
-
export { SiblingPath } from '@aztec/foundation/trees';
|
|
26
|
-
|
|
27
|
-
export { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
28
|
-
|
|
29
|
-
export { MerkleTreeId, merkleTreeIds } from '@aztec/stdlib/trees';
|
|
30
|
-
export { type PublicKey, PublicKeys } from '@aztec/stdlib/keys';
|
|
31
|
-
export { computeSecretHash } from '@aztec/stdlib/hash';
|
|
32
|
-
export {
|
|
33
|
-
computeAppNullifierSecretKey,
|
|
34
|
-
deriveKeys,
|
|
35
|
-
deriveMasterIncomingViewingSecretKey,
|
|
36
|
-
deriveMasterNullifierSecretKey,
|
|
37
|
-
} from '@aztec/stdlib/keys';
|
|
38
|
-
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
39
|
-
export {
|
|
40
|
-
Tx,
|
|
41
|
-
TxExecutionRequest,
|
|
42
|
-
TxHash,
|
|
43
|
-
TxReceipt,
|
|
44
|
-
TxStatus,
|
|
45
|
-
Capsule,
|
|
46
|
-
HashedValues,
|
|
47
|
-
GlobalVariables,
|
|
48
|
-
} from '@aztec/stdlib/tx';
|
|
49
|
-
export { Body, L2Block } from '@aztec/stdlib/block';
|
|
50
|
-
export { LogId, type LogFilter } from '@aztec/stdlib/logs';
|
|
51
|
-
export { L1ToL2Message, L2Actor, L1Actor } from '@aztec/stdlib/messaging';
|
|
52
|
-
export { UniqueNote, ExtendedNote, Comparator, Note } from '@aztec/stdlib/note';
|
|
53
|
-
export { type PXE, EventType } from '@aztec/stdlib/interfaces/client';
|
|
54
|
-
|
|
55
|
-
export { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
56
|
-
|
|
57
|
-
// TODO: These kinds of things have no place on our public api.
|
|
58
|
-
// External devs will almost certainly have their own methods of doing these things.
|
|
59
|
-
// If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
|
|
60
|
-
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
61
|
-
export { sha256, Grumpkin, Schnorr } from '@aztec/foundation/crypto';
|
|
62
|
-
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
63
|
-
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
64
|
-
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
65
|
-
export { sleep } from '@aztec/foundation/sleep';
|
|
66
|
-
export { elapsed } from '@aztec/foundation/timer';
|
|
67
|
-
export { type FieldsOf } from '@aztec/foundation/types';
|
|
68
|
-
export { fileURLToPath } from '@aztec/foundation/url';
|
|
69
|
-
|
|
70
|
-
// Start of section that exports public api via granular api.
|
|
71
|
-
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|
|
72
|
-
// This entire index file will be deprecated at some point after we're satisfied.
|
|
73
|
-
export * from './api/abi.js';
|
|
74
|
-
export * from './api/authorization.js';
|
|
75
|
-
export * from './api/account.js';
|
|
76
|
-
export * from './api/addresses.js';
|
|
77
|
-
export * from './api/deployment.js';
|
|
78
|
-
export * from './api/ethereum.js';
|
|
79
|
-
export * from './api/eth_address.js';
|
|
80
|
-
export * from './api/fee.js';
|
|
81
|
-
export * from './api/log.js';
|
|
82
|
-
export * from './api/contract.js';
|
|
83
|
-
export * from './api/utils.js';
|
|
84
|
-
export * from './api/rpc.js';
|
|
85
|
-
export * from './api/wallet.js';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry';
|
|
4
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
6
|
-
|
|
7
|
-
import { Axios, type AxiosError } from 'axios';
|
|
8
|
-
import { inspect } from 'util';
|
|
9
|
-
|
|
10
|
-
import { createPXEClient } from '../pxe_client.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A fetch implementation using axios.
|
|
14
|
-
* @param host - The URL of the host.
|
|
15
|
-
* @param rpcMethod - The RPC method to call.
|
|
16
|
-
* @param body - The body of the request.
|
|
17
|
-
* @returns The response data.
|
|
18
|
-
*/
|
|
19
|
-
async function axiosFetch(host: string, body: unknown) {
|
|
20
|
-
const request = new Axios({
|
|
21
|
-
headers: { 'content-type': 'application/json' },
|
|
22
|
-
transformRequest: [(data: any) => jsonStringify(data)],
|
|
23
|
-
transformResponse: [(data: any) => JSON.parse(data)],
|
|
24
|
-
});
|
|
25
|
-
const [url, content] = [host, body];
|
|
26
|
-
const resp = await request.post(url, content).catch((error: AxiosError) => {
|
|
27
|
-
if (error.response) {
|
|
28
|
-
return error.response;
|
|
29
|
-
}
|
|
30
|
-
const errorMessage = `Error fetching from host ${host}: ${inspect(error)}`;
|
|
31
|
-
throw new Error(errorMessage);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const isOK = resp.status >= 200 && resp.status < 300;
|
|
35
|
-
if (isOK) {
|
|
36
|
-
const headers = {
|
|
37
|
-
get: (header: string) =>
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
39
|
-
typeof resp.headers.get === 'function' ? resp.headers.get(header)?.toString() : undefined,
|
|
40
|
-
};
|
|
41
|
-
return { response: resp.data, headers };
|
|
42
|
-
} else {
|
|
43
|
-
const errorMessage = `Error ${resp.status} from json-rpc server ${host}: ${resp.data}`;
|
|
44
|
-
if (resp.status >= 400 && resp.status < 500) {
|
|
45
|
-
throw new NoRetryError(errorMessage);
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error(errorMessage);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Creates a PXE client with a given set of retries on non-server errors.
|
|
54
|
-
* Checks that PXE matches the expected version, and warns if not.
|
|
55
|
-
* @param rpcUrl - URL of the RPC server wrapping the PXE.
|
|
56
|
-
* @param _logger - Debug logger to warn version incompatibilities.
|
|
57
|
-
* @returns A PXE client.
|
|
58
|
-
*/
|
|
59
|
-
export function createCompatibleClient(
|
|
60
|
-
rpcUrl: string,
|
|
61
|
-
logger: Logger = createLogger('aztecjs:pxe_client'),
|
|
62
|
-
versions: Partial<ComponentsVersions> = {},
|
|
63
|
-
): Promise<PXE> {
|
|
64
|
-
// Use axios due to timeout issues with fetch when proving TXs.
|
|
65
|
-
const fetch = async (host: string, body: unknown) => {
|
|
66
|
-
return await retry(
|
|
67
|
-
() => axiosFetch(host, body),
|
|
68
|
-
`JsonRpcClient request to ${host}`,
|
|
69
|
-
makeBackoff([1, 2, 3]),
|
|
70
|
-
logger,
|
|
71
|
-
false,
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
const pxe = createPXEClient(rpcUrl, versions, fetch);
|
|
75
|
-
|
|
76
|
-
return Promise.resolve(pxe);
|
|
77
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
2
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
3
|
-
import { type PXE, PXESchema } from '@aztec/stdlib/interfaces/client';
|
|
4
|
-
import { type ComponentsVersions, getVersioningResponseHandler } from '@aztec/stdlib/versioning';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates a JSON-RPC client to remotely talk to PXE.
|
|
8
|
-
* @param url - The URL of the PXE.
|
|
9
|
-
* @param fetch - The fetch implementation to use.
|
|
10
|
-
* @returns A JSON-RPC client of PXE.
|
|
11
|
-
*/
|
|
12
|
-
export function createPXEClient(
|
|
13
|
-
url: string,
|
|
14
|
-
versions: Partial<ComponentsVersions> = {},
|
|
15
|
-
fetch = makeFetch([1, 2, 3], false),
|
|
16
|
-
): PXE {
|
|
17
|
-
return createSafeJsonRpcClient<PXE>(url, PXESchema, {
|
|
18
|
-
namespaceMethods: 'pxe',
|
|
19
|
-
fetch,
|
|
20
|
-
onResponse: getVersioningResponseHandler({
|
|
21
|
-
l2ProtocolContractsTreeRoot: protocolContractTreeRoot.toString(),
|
|
22
|
-
...versions,
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
}
|
package/src/utils/pxe.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
|
-
|
|
5
|
-
export const waitForPXE = async (pxe: PXE, logger?: Logger) => {
|
|
6
|
-
await retryUntil(async () => {
|
|
7
|
-
try {
|
|
8
|
-
logger?.verbose('Attempting to contact PXE...');
|
|
9
|
-
await pxe.getNodeInfo();
|
|
10
|
-
logger?.verbose('Contacted PXE');
|
|
11
|
-
return true;
|
|
12
|
-
} catch {
|
|
13
|
-
logger?.verbose('Failed to contact PXE');
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}, 'RPC Get Node Info');
|
|
17
|
-
};
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import type { FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
-
import { type ABIParameterVisibility, type FunctionAbi, FunctionType } from '@aztec/stdlib/abi';
|
|
6
|
-
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
7
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
9
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
10
|
-
|
|
11
|
-
import type { AccountInterface } from '../account/interface.js';
|
|
12
|
-
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
13
|
-
import {
|
|
14
|
-
type IntentAction,
|
|
15
|
-
type IntentInnerHash,
|
|
16
|
-
computeAuthWitMessageHash,
|
|
17
|
-
computeInnerAuthWitHashFromAction,
|
|
18
|
-
} from '../utils/authwit.js';
|
|
19
|
-
import { BaseWallet } from './base_wallet.js';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A wallet implementation that forwards authentication requests to a provided account.
|
|
23
|
-
*/
|
|
24
|
-
export class AccountWallet extends BaseWallet {
|
|
25
|
-
constructor(
|
|
26
|
-
pxe: PXE,
|
|
27
|
-
protected account: AccountInterface,
|
|
28
|
-
) {
|
|
29
|
-
super(pxe);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
createTxExecutionRequest(
|
|
33
|
-
exec: ExecutionPayload,
|
|
34
|
-
fee: FeeOptions,
|
|
35
|
-
options: TxExecutionOptions,
|
|
36
|
-
): Promise<TxExecutionRequest> {
|
|
37
|
-
return this.account.createTxExecutionRequest(exec, fee, options);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getChainId(): Fr {
|
|
41
|
-
return this.account.getChainId();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getVersion(): Fr {
|
|
45
|
-
return this.account.getVersion();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Computes an authentication witness from either a message hash or an intent.
|
|
50
|
-
*
|
|
51
|
-
* If a message hash is provided, it will create a witness for the hash directly.
|
|
52
|
-
* Otherwise, it will compute the message hash using the intent, along with the
|
|
53
|
-
* chain id and the version values provided by the wallet.
|
|
54
|
-
*
|
|
55
|
-
* @param messageHashOrIntent - The message hash of the intent to approve
|
|
56
|
-
* @returns The authentication witness
|
|
57
|
-
*/
|
|
58
|
-
async createAuthWit(messageHashOrIntent: Fr | Buffer | IntentAction | IntentInnerHash): Promise<AuthWitness> {
|
|
59
|
-
let messageHash: Fr;
|
|
60
|
-
if (Buffer.isBuffer(messageHashOrIntent)) {
|
|
61
|
-
messageHash = Fr.fromBuffer(messageHashOrIntent);
|
|
62
|
-
} else if (messageHashOrIntent instanceof Fr) {
|
|
63
|
-
messageHash = messageHashOrIntent;
|
|
64
|
-
} else {
|
|
65
|
-
messageHash = await this.getMessageHash(messageHashOrIntent);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return this.account.createAuthWit(messageHash);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Returns a function interaction to set a message hash as authorized or revoked in this account.
|
|
73
|
-
*
|
|
74
|
-
* Public calls can then consume this authorization.
|
|
75
|
-
*
|
|
76
|
-
* @param messageHashOrIntent - The message hash or intent to authorize/revoke
|
|
77
|
-
* @param authorized - True to authorize, false to revoke authorization.
|
|
78
|
-
* @returns - A function interaction.
|
|
79
|
-
*/
|
|
80
|
-
public async setPublicAuthWit(
|
|
81
|
-
messageHashOrIntent: Fr | Buffer | IntentInnerHash | IntentAction,
|
|
82
|
-
authorized: boolean,
|
|
83
|
-
): Promise<ContractFunctionInteraction> {
|
|
84
|
-
let messageHash: Fr;
|
|
85
|
-
if (Buffer.isBuffer(messageHashOrIntent)) {
|
|
86
|
-
messageHash = Fr.fromBuffer(messageHashOrIntent);
|
|
87
|
-
} else if (messageHashOrIntent instanceof Fr) {
|
|
88
|
-
messageHash = messageHashOrIntent;
|
|
89
|
-
} else {
|
|
90
|
-
messageHash = await this.getMessageHash(messageHashOrIntent);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return new ContractFunctionInteraction(this, ProtocolContractAddress.AuthRegistry, this.getSetAuthorizedAbi(), [
|
|
94
|
-
messageHash,
|
|
95
|
-
authorized,
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private async getInnerHashAndConsumer(intent: IntentInnerHash | IntentAction): Promise<{
|
|
100
|
-
/** The inner hash */
|
|
101
|
-
innerHash: Fr;
|
|
102
|
-
/** The consumer of the authwit */
|
|
103
|
-
consumer: AztecAddress;
|
|
104
|
-
}> {
|
|
105
|
-
if ('caller' in intent && 'action' in intent) {
|
|
106
|
-
const action =
|
|
107
|
-
intent.action instanceof ContractFunctionInteraction ? (await intent.action.request()).calls[0] : intent.action;
|
|
108
|
-
return {
|
|
109
|
-
innerHash: await computeInnerAuthWitHashFromAction(intent.caller, action),
|
|
110
|
-
consumer: action.to,
|
|
111
|
-
};
|
|
112
|
-
} else if (Buffer.isBuffer(intent.innerHash)) {
|
|
113
|
-
return { innerHash: Fr.fromBuffer(intent.innerHash), consumer: intent.consumer };
|
|
114
|
-
}
|
|
115
|
-
return { innerHash: intent.innerHash, consumer: intent.consumer };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Returns the message hash for the given intent
|
|
120
|
-
*
|
|
121
|
-
* @param intent - A tuple of (consumer and inner hash) or (caller and action)
|
|
122
|
-
* @returns The message hash
|
|
123
|
-
*/
|
|
124
|
-
private getMessageHash(intent: IntentInnerHash | IntentAction): Promise<Fr> {
|
|
125
|
-
const chainId = this.getChainId();
|
|
126
|
-
const version = this.getVersion();
|
|
127
|
-
return computeAuthWitMessageHash(intent, { chainId, version });
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Lookup the validity of an authwit in private and public contexts.
|
|
132
|
-
*
|
|
133
|
-
* Uses the chain id and version of the wallet.
|
|
134
|
-
*
|
|
135
|
-
* @param onBehalfOf - The address of the "approver"
|
|
136
|
-
* @param intent - The consumer and inner hash or the caller and action to lookup
|
|
137
|
-
* @param witness - The computed authentication witness to check
|
|
138
|
-
* @returns - A struct containing the validity of the authwit in private and public contexts.
|
|
139
|
-
*/
|
|
140
|
-
async lookupValidity(
|
|
141
|
-
onBehalfOf: AztecAddress,
|
|
142
|
-
intent: IntentInnerHash | IntentAction,
|
|
143
|
-
witness: AuthWitness,
|
|
144
|
-
): Promise<{
|
|
145
|
-
/** boolean flag indicating if the authwit is valid in private context */
|
|
146
|
-
isValidInPrivate: boolean;
|
|
147
|
-
/** boolean flag indicating if the authwit is valid in public context */
|
|
148
|
-
isValidInPublic: boolean;
|
|
149
|
-
}> {
|
|
150
|
-
const { innerHash, consumer } = await this.getInnerHashAndConsumer(intent);
|
|
151
|
-
|
|
152
|
-
const messageHash = await this.getMessageHash(intent);
|
|
153
|
-
const results = { isValidInPrivate: false, isValidInPublic: false };
|
|
154
|
-
|
|
155
|
-
// Check private
|
|
156
|
-
try {
|
|
157
|
-
results.isValidInPrivate = (await new ContractFunctionInteraction(this, onBehalfOf, this.getLookupValidityAbi(), [
|
|
158
|
-
consumer,
|
|
159
|
-
innerHash,
|
|
160
|
-
]).simulate({ from: this.getAddress(), authWitnesses: [witness] })) as boolean;
|
|
161
|
-
// TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
|
|
162
|
-
// eslint-disable-next-line no-empty
|
|
163
|
-
} catch {}
|
|
164
|
-
|
|
165
|
-
// check public
|
|
166
|
-
results.isValidInPublic = (await new ContractFunctionInteraction(
|
|
167
|
-
this,
|
|
168
|
-
ProtocolContractAddress.AuthRegistry,
|
|
169
|
-
this.getIsConsumableAbi(),
|
|
170
|
-
[onBehalfOf, messageHash],
|
|
171
|
-
).simulate({ from: this.getAddress() })) as boolean;
|
|
172
|
-
|
|
173
|
-
return results;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/** Returns the complete address of the account that implements this wallet. */
|
|
177
|
-
public getCompleteAddress() {
|
|
178
|
-
return this.account.getCompleteAddress();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** Returns the address of the account that implements this wallet. */
|
|
182
|
-
public override getAddress() {
|
|
183
|
-
return this.getCompleteAddress().address;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
private getSetAuthorizedAbi(): FunctionAbi {
|
|
187
|
-
return {
|
|
188
|
-
name: 'set_authorized',
|
|
189
|
-
isInitializer: false,
|
|
190
|
-
functionType: FunctionType.PUBLIC,
|
|
191
|
-
isInternal: true,
|
|
192
|
-
isStatic: false,
|
|
193
|
-
parameters: [
|
|
194
|
-
{
|
|
195
|
-
name: 'message_hash',
|
|
196
|
-
type: { kind: 'field' },
|
|
197
|
-
visibility: 'private' as ABIParameterVisibility,
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: 'authorize',
|
|
201
|
-
type: { kind: 'boolean' },
|
|
202
|
-
visibility: 'private' as ABIParameterVisibility,
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
returnTypes: [],
|
|
206
|
-
errorTypes: {},
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
private getLookupValidityAbi(): FunctionAbi {
|
|
211
|
-
return {
|
|
212
|
-
name: 'lookup_validity',
|
|
213
|
-
isInitializer: false,
|
|
214
|
-
functionType: FunctionType.UTILITY,
|
|
215
|
-
isInternal: false,
|
|
216
|
-
isStatic: false,
|
|
217
|
-
parameters: [{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility }],
|
|
218
|
-
returnTypes: [{ kind: 'boolean' }],
|
|
219
|
-
errorTypes: {},
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
private getIsConsumableAbi(): FunctionAbi {
|
|
224
|
-
return {
|
|
225
|
-
name: 'utility_is_consumable',
|
|
226
|
-
isInitializer: false,
|
|
227
|
-
functionType: FunctionType.UTILITY,
|
|
228
|
-
isInternal: false,
|
|
229
|
-
isStatic: false,
|
|
230
|
-
parameters: [
|
|
231
|
-
{
|
|
232
|
-
name: 'address',
|
|
233
|
-
type: {
|
|
234
|
-
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
235
|
-
kind: 'struct',
|
|
236
|
-
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
237
|
-
},
|
|
238
|
-
visibility: 'private' as ABIParameterVisibility,
|
|
239
|
-
},
|
|
240
|
-
{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
|
|
241
|
-
],
|
|
242
|
-
returnTypes: [{ kind: 'boolean' }],
|
|
243
|
-
errorTypes: {},
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
2
|
-
import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces';
|
|
3
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
4
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
|
-
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
7
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
8
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
9
|
-
|
|
10
|
-
import type { IntentAction, IntentInnerHash } from '../utils/authwit.js';
|
|
11
|
-
import { BaseWallet } from './base_wallet.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Wallet implementation which creates a transaction request directly to the requested contract without any signing.
|
|
15
|
-
*/
|
|
16
|
-
export class SignerlessWallet extends BaseWallet {
|
|
17
|
-
constructor(
|
|
18
|
-
pxe: PXE,
|
|
19
|
-
private entrypoint?: EntrypointInterface,
|
|
20
|
-
) {
|
|
21
|
-
super(pxe);
|
|
22
|
-
}
|
|
23
|
-
async createTxExecutionRequest(
|
|
24
|
-
execution: ExecutionPayload,
|
|
25
|
-
fee: FeeOptions,
|
|
26
|
-
options: TxExecutionOptions,
|
|
27
|
-
): Promise<TxExecutionRequest> {
|
|
28
|
-
let entrypoint = this.entrypoint;
|
|
29
|
-
if (!entrypoint) {
|
|
30
|
-
const { l1ChainId: chainId, rollupVersion } = await this.pxe.getNodeInfo();
|
|
31
|
-
entrypoint = new DefaultEntrypoint(chainId, rollupVersion);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return entrypoint.createTxExecutionRequest(execution, fee, options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getChainId(): Fr {
|
|
38
|
-
throw new Error('SignerlessWallet: Method getChainId not implemented.');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getVersion(): Fr {
|
|
42
|
-
throw new Error('SignerlessWallet: Method getVersion not implemented.');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getPublicKeysHash(): Fr {
|
|
46
|
-
throw new Error('SignerlessWallet: Method getPublicKeysHash not implemented.');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getCompleteAddress(): CompleteAddress {
|
|
50
|
-
throw new Error('SignerlessWallet: Method getCompleteAddress not implemented.');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
createAuthWit(_intent: Fr | Buffer | IntentInnerHash | IntentAction): Promise<AuthWitness> {
|
|
54
|
-
throw new Error('SignerlessWallet: Method createAuthWit not implemented.');
|
|
55
|
-
}
|
|
56
|
-
}
|