@aztec/aztec.js 0.40.1 → 0.42.0
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/index.d.ts +2 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/interface.d.ts +16 -1
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -1
- package/dest/account/wallet.d.ts +2 -2
- package/dest/account/wallet.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +8 -5
- package/dest/account_manager/index.d.ts +1 -1
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +2 -1
- package/dest/api/abi.d.ts +2 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/abi.js +1 -1
- package/dest/api/fee.d.ts +2 -0
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +3 -1
- package/dest/contract/base_contract_interaction.d.ts +7 -6
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +20 -9
- package/dest/contract/batch_call.d.ts +11 -0
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +50 -2
- package/dest/contract/contract_function_interaction.d.ts +2 -7
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +22 -36
- package/dest/contract/deploy_method.d.ts +5 -1
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +22 -6
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/get_gas_limits.d.ts.map +1 -1
- package/dest/contract/get_gas_limits.js +5 -3
- package/dest/contract/sent_tx.js +2 -2
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_entrypoint.js +6 -2
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +7 -5
- package/dest/entrypoint/payload.d.ts +26 -9
- package/dest/entrypoint/payload.d.ts.map +1 -1
- package/dest/entrypoint/payload.js +51 -28
- package/dest/fee/fee_payment_method.d.ts +6 -7
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.d.ts +5 -25
- package/dest/fee/native_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.js +9 -45
- package/dest/fee/native_fee_payment_method_with_claim.d.ts +17 -0
- package/dest/fee/native_fee_payment_method_with_claim.d.ts.map +1 -0
- package/dest/fee/native_fee_payment_method_with_claim.js +32 -0
- package/dest/fee/no_fee_payment_method.d.ts +13 -0
- package/dest/fee/no_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/no_fee_payment_method.js +17 -0
- package/dest/fee/private_fee_payment_method.d.ts +1 -5
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +15 -12
- package/dest/fee/public_fee_payment_method.d.ts +1 -5
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +15 -12
- package/dest/index.d.ts +11 -12
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +10 -11
- package/dest/rpc_clients/pxe_client.js +3 -3
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +2 -6
- package/dest/utils/cheat_codes.js +3 -3
- package/dest/wallet/account_wallet.d.ts +12 -1
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +58 -4
- package/dest/wallet/base_wallet.d.ts +10 -3
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +12 -3
- package/dest/wallet/create_recipient.d.ts.map +1 -1
- package/dest/wallet/create_recipient.js +3 -1
- package/dest/wallet/signerless_wallet.d.ts +2 -1
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +9 -6
- package/package.json +7 -7
- package/src/account/index.ts +2 -2
- package/src/account/interface.ts +17 -1
- package/src/account/wallet.ts +2 -2
- package/src/account_manager/deploy_account_method.ts +11 -3
- package/src/account_manager/index.ts +5 -1
- package/src/api/abi.ts +2 -2
- package/src/api/fee.ts +2 -0
- package/src/contract/base_contract_interaction.ts +32 -8
- package/src/contract/batch_call.ts +77 -1
- package/src/contract/contract_function_interaction.ts +31 -34
- package/src/contract/deploy_method.ts +23 -6
- package/src/contract/get_gas_limits.ts +4 -3
- package/src/contract/sent_tx.ts +1 -1
- package/src/entrypoint/default_entrypoint.ts +7 -1
- package/src/entrypoint/default_multi_call_entrypoint.ts +6 -4
- package/src/entrypoint/payload.ts +61 -25
- package/src/fee/fee_payment_method.ts +6 -8
- package/src/fee/native_fee_payment_method.ts +8 -46
- package/src/fee/native_fee_payment_method_with_claim.ts +33 -0
- package/src/fee/no_fee_payment_method.ts +23 -0
- package/src/fee/private_fee_payment_method.ts +15 -14
- package/src/fee/public_fee_payment_method.ts +15 -18
- package/src/index.ts +34 -32
- package/src/rpc_clients/pxe_client.ts +2 -2
- package/src/utils/authwit.ts +1 -5
- package/src/utils/cheat_codes.ts +3 -3
- package/src/wallet/account_wallet.ts +65 -3
- package/src/wallet/base_wallet.ts +21 -3
- package/src/wallet/create_recipient.ts +2 -0
- package/src/wallet/signerless_wallet.ts +10 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
2
|
+
import { type GasSettings } from '@aztec/circuits.js';
|
|
3
3
|
import { computeSecretHash } from '@aztec/circuits.js/hash';
|
|
4
|
-
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
|
+
import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
|
|
5
5
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
6
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
7
7
|
|
|
@@ -43,12 +43,8 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
43
43
|
return this.asset;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @returns The contract address responsible for holding the fee payment.
|
|
49
|
-
*/
|
|
50
|
-
getPaymentContract() {
|
|
51
|
-
return this.paymentContract;
|
|
46
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
47
|
+
return Promise.resolve(this.paymentContract);
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
/**
|
|
@@ -64,9 +60,13 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
64
60
|
this.wallet.getChainId(),
|
|
65
61
|
this.wallet.getVersion(),
|
|
66
62
|
{
|
|
63
|
+
name: 'unshield',
|
|
67
64
|
args: [this.wallet.getCompleteAddress().address, this.paymentContract, maxFee, nonce],
|
|
68
|
-
|
|
65
|
+
selector: FunctionSelector.fromSignature('unshield((Field),(Field),Field,Field)'),
|
|
66
|
+
type: FunctionType.PRIVATE,
|
|
67
|
+
isStatic: false,
|
|
69
68
|
to: this.asset,
|
|
69
|
+
returnTypes: [],
|
|
70
70
|
},
|
|
71
71
|
);
|
|
72
72
|
await this.wallet.createAuthWit(messageHash);
|
|
@@ -75,12 +75,13 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
75
75
|
|
|
76
76
|
return [
|
|
77
77
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
name: 'fee_entrypoint_private',
|
|
79
|
+
to: this.paymentContract,
|
|
80
|
+
selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field),Field,Field)'),
|
|
81
|
+
type: FunctionType.PRIVATE,
|
|
82
|
+
isStatic: false,
|
|
83
83
|
args: [maxFee, this.asset, secretHashForRebate, nonce],
|
|
84
|
+
returnTypes: [],
|
|
84
85
|
},
|
|
85
86
|
];
|
|
86
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
3
|
-
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
2
|
+
import { type GasSettings } from '@aztec/circuits.js';
|
|
3
|
+
import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
|
|
4
4
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
@@ -21,7 +21,6 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
21
21
|
* Address which will hold the fee payment.
|
|
22
22
|
*/
|
|
23
23
|
protected paymentContract: AztecAddress,
|
|
24
|
-
|
|
25
24
|
/**
|
|
26
25
|
* An auth witness provider to authorize fee payments
|
|
27
26
|
*/
|
|
@@ -36,12 +35,8 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
36
35
|
return this.asset;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* @returns The contract address responsible for holding the fee payment.
|
|
42
|
-
*/
|
|
43
|
-
getPaymentContract() {
|
|
44
|
-
return this.paymentContract;
|
|
38
|
+
getFeePayer(): Promise<AztecAddress> {
|
|
39
|
+
return Promise.resolve(this.paymentContract);
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
/**
|
|
@@ -57,24 +52,26 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
57
52
|
this.wallet.getChainId(),
|
|
58
53
|
this.wallet.getVersion(),
|
|
59
54
|
{
|
|
55
|
+
name: 'transfer_public',
|
|
60
56
|
args: [this.wallet.getAddress(), this.paymentContract, maxFee, nonce],
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
),
|
|
57
|
+
selector: FunctionSelector.fromSignature('transfer_public((Field),(Field),Field,Field)'),
|
|
58
|
+
type: FunctionType.PUBLIC,
|
|
59
|
+
isStatic: false,
|
|
65
60
|
to: this.asset,
|
|
61
|
+
returnTypes: [],
|
|
66
62
|
},
|
|
67
63
|
);
|
|
68
64
|
|
|
69
65
|
return Promise.resolve([
|
|
70
66
|
this.wallet.setPublicAuthWit(messageHash, true).request(),
|
|
71
67
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
name: 'fee_entrypoint_public',
|
|
69
|
+
to: this.paymentContract,
|
|
70
|
+
selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,(Field),Field)'),
|
|
71
|
+
type: FunctionType.PRIVATE,
|
|
72
|
+
isStatic: false,
|
|
77
73
|
args: [maxFee, this.asset, nonce],
|
|
74
|
+
returnTypes: [],
|
|
78
75
|
},
|
|
79
76
|
]);
|
|
80
77
|
}
|
package/src/index.ts
CHANGED
|
@@ -20,35 +20,36 @@
|
|
|
20
20
|
* TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
|
|
21
21
|
*/
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
ContractFunctionInteraction,
|
|
23
|
+
BatchCall,
|
|
25
24
|
Contract,
|
|
26
25
|
ContractBase,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ContractNotes,
|
|
30
|
-
|
|
31
|
-
BatchCall,
|
|
26
|
+
ContractFunctionInteraction,
|
|
27
|
+
type ContractMethod,
|
|
28
|
+
type ContractNotes,
|
|
29
|
+
type ContractStorageLayout,
|
|
32
30
|
DeployMethod,
|
|
33
31
|
DeploySentTx,
|
|
32
|
+
type SendMethodOptions,
|
|
33
|
+
SentTx,
|
|
34
|
+
type WaitOpts,
|
|
34
35
|
} from './contract/index.js';
|
|
35
36
|
|
|
36
37
|
export { ContractDeployer } from './deployment/index.js';
|
|
37
38
|
|
|
38
39
|
export {
|
|
39
|
-
generatePublicKey,
|
|
40
|
-
FieldLike,
|
|
41
|
-
EthAddressLike,
|
|
42
|
-
CheatCodes,
|
|
43
40
|
AztecAddressLike,
|
|
41
|
+
CheatCodes,
|
|
42
|
+
EthAddressLike,
|
|
43
|
+
EthCheatCodes,
|
|
44
|
+
FieldLike,
|
|
44
45
|
FunctionSelectorLike,
|
|
45
46
|
WrappedFieldLike,
|
|
46
|
-
EthCheatCodes,
|
|
47
47
|
computeAuthWitMessageHash,
|
|
48
48
|
computeInnerAuthWitHash,
|
|
49
49
|
computeOuterAuthWitHash,
|
|
50
|
-
|
|
50
|
+
generatePublicKey,
|
|
51
51
|
waitForAccountSynch,
|
|
52
|
+
waitForPXE,
|
|
52
53
|
} from './utils/index.js';
|
|
53
54
|
|
|
54
55
|
export { createPXEClient } from './rpc_clients/index.js';
|
|
@@ -58,21 +59,21 @@ export { AuthWitnessProvider } from './account/index.js';
|
|
|
58
59
|
export { AccountContract } from './account/index.js';
|
|
59
60
|
export { AccountManager } from './account_manager/index.js';
|
|
60
61
|
|
|
61
|
-
export { AccountWalletWithSecretKey,
|
|
62
|
+
export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, Wallet } from './wallet/index.js';
|
|
62
63
|
|
|
63
64
|
// // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
|
|
64
65
|
// // here once the issue is resolved.
|
|
65
66
|
export {
|
|
66
67
|
AztecAddress,
|
|
67
68
|
EthAddress,
|
|
68
|
-
Fr,
|
|
69
69
|
Fq,
|
|
70
|
+
Fr,
|
|
70
71
|
GlobalVariables,
|
|
71
72
|
GrumpkinScalar,
|
|
73
|
+
INITIAL_L2_BLOCK_NUM,
|
|
72
74
|
Point,
|
|
73
|
-
getContractInstanceFromDeployParams, // TODO(@spalladino) This method should be used from within the DeployMethod but not exposed in aztec.js
|
|
74
75
|
getContractClassFromArtifact,
|
|
75
|
-
|
|
76
|
+
getContractInstanceFromDeployParams,
|
|
76
77
|
} from '@aztec/circuits.js';
|
|
77
78
|
|
|
78
79
|
export { computeSecretHash } from '@aztec/circuits.js/hash';
|
|
@@ -90,17 +91,21 @@ export {
|
|
|
90
91
|
AuthWitness,
|
|
91
92
|
AztecNode,
|
|
92
93
|
Body,
|
|
94
|
+
Comparator,
|
|
93
95
|
CompleteAddress,
|
|
96
|
+
EncryptedL2BlockL2Logs,
|
|
97
|
+
EncryptedLogHeader,
|
|
98
|
+
EncryptedLogIncomingBody,
|
|
99
|
+
EncryptedLogOutgoingBody,
|
|
94
100
|
ExtendedNote,
|
|
95
|
-
|
|
101
|
+
FunctionCall,
|
|
96
102
|
GrumpkinPrivateKey,
|
|
97
|
-
L1ToL2Message,
|
|
98
103
|
L1Actor,
|
|
104
|
+
L1ToL2Message,
|
|
99
105
|
L2Actor,
|
|
100
106
|
L2Block,
|
|
101
107
|
L2BlockL2Logs,
|
|
102
|
-
|
|
103
|
-
UnencryptedL2BlockL2Logs,
|
|
108
|
+
EncryptedNoteL2BlockL2Logs,
|
|
104
109
|
LogFilter,
|
|
105
110
|
LogId,
|
|
106
111
|
LogType,
|
|
@@ -110,40 +115,37 @@ export {
|
|
|
110
115
|
PackedValues,
|
|
111
116
|
PartialAddress,
|
|
112
117
|
PublicKey,
|
|
118
|
+
SiblingPath,
|
|
113
119
|
SyncStatus,
|
|
114
120
|
Tx,
|
|
115
121
|
TxExecutionRequest,
|
|
116
122
|
TxHash,
|
|
117
123
|
TxReceipt,
|
|
118
124
|
TxStatus,
|
|
125
|
+
UnencryptedL2BlockL2Logs,
|
|
119
126
|
UnencryptedL2Log,
|
|
120
127
|
createAztecNodeClient,
|
|
121
|
-
emptyFunctionCall,
|
|
122
128
|
merkleTreeIds,
|
|
123
129
|
mockTx,
|
|
124
|
-
Comparator,
|
|
125
|
-
SiblingPath,
|
|
126
|
-
EncryptedLogHeader,
|
|
127
|
-
EncryptedLogBody,
|
|
128
130
|
} from '@aztec/circuit-types';
|
|
129
131
|
export { NodeInfo } from '@aztec/types/interfaces';
|
|
130
132
|
|
|
131
|
-
export {
|
|
133
|
+
export { ContractClassWithId, ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
132
134
|
|
|
133
135
|
// TODO: These kinds of things have no place on our public api.
|
|
134
136
|
// External devs will almost certainly have their own methods of doing these things.
|
|
135
137
|
// If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
|
|
136
138
|
export { encodeArguments } from '@aztec/foundation/abi';
|
|
139
|
+
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
137
140
|
export { sha256 } from '@aztec/foundation/crypto';
|
|
141
|
+
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
138
142
|
export { DebugLogger, createDebugLogger, onLog } from '@aztec/foundation/log';
|
|
139
143
|
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
144
|
+
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
140
145
|
export { sleep } from '@aztec/foundation/sleep';
|
|
141
146
|
export { elapsed } from '@aztec/foundation/timer';
|
|
142
|
-
export { fileURLToPath } from '@aztec/foundation/url';
|
|
143
|
-
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
144
|
-
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
145
|
-
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
146
147
|
export { FieldsOf } from '@aztec/foundation/types';
|
|
148
|
+
export { fileURLToPath } from '@aztec/foundation/url';
|
|
147
149
|
|
|
148
150
|
export {
|
|
149
151
|
DeployL1Contracts,
|
|
@@ -155,6 +157,6 @@ export {
|
|
|
155
157
|
// Start of section that exports public api via granular api.
|
|
156
158
|
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|
|
157
159
|
// This entire index file will be deprecated at some point after we're satisfied.
|
|
158
|
-
export * from './api/init.js';
|
|
159
160
|
export * from './api/abi.js';
|
|
160
161
|
export * from './api/fee.js';
|
|
162
|
+
export * from './api/init.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthWitness,
|
|
3
|
-
|
|
3
|
+
EncryptedNoteL2BlockL2Logs,
|
|
4
4
|
ExtendedNote,
|
|
5
5
|
ExtendedUnencryptedL2Log,
|
|
6
6
|
L2Block,
|
|
@@ -54,7 +54,7 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false)
|
|
|
54
54
|
TxExecutionRequest,
|
|
55
55
|
TxHash,
|
|
56
56
|
},
|
|
57
|
-
{ Tx, SimulatedTx, TxReceipt,
|
|
57
|
+
{ Tx, SimulatedTx, TxReceipt, EncryptedNoteL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness },
|
|
58
58
|
false,
|
|
59
59
|
'pxe',
|
|
60
60
|
fetch,
|
package/src/utils/authwit.ts
CHANGED
|
@@ -22,11 +22,7 @@ export const computeAuthWitMessageHash = (caller: AztecAddress, chainId: Fr, ver
|
|
|
22
22
|
action.to.toField(),
|
|
23
23
|
chainId,
|
|
24
24
|
version,
|
|
25
|
-
computeInnerAuthWitHash([
|
|
26
|
-
caller.toField(),
|
|
27
|
-
action.functionData.selector.toField(),
|
|
28
|
-
PackedValues.fromValues(action.args).hash,
|
|
29
|
-
]),
|
|
25
|
+
computeInnerAuthWitHash([caller.toField(), action.selector.toField(), PackedValues.fromValues(action.args).hash]),
|
|
30
26
|
);
|
|
31
27
|
};
|
|
32
28
|
// docs:end:authwit_computeAuthWitMessageHash
|
package/src/utils/cheat_codes.ts
CHANGED
|
@@ -265,11 +265,11 @@ export class AztecCheatCodes {
|
|
|
265
265
|
public async warp(to: number): Promise<void> {
|
|
266
266
|
const rollupContract = (await this.pxe.getNodeInfo()).l1ContractAddresses.rollupAddress;
|
|
267
267
|
await this.eth.setNextBlockTimestamp(to);
|
|
268
|
-
// also store this time on the rollup contract (slot
|
|
268
|
+
// also store this time on the rollup contract (slot 2 tracks `lastBlockTs`).
|
|
269
269
|
// This is because when the sequencer executes public functions, it uses the timestamp stored in the rollup contract.
|
|
270
|
-
await this.eth.store(rollupContract, 1n, BigInt(to));
|
|
271
|
-
// also store this on slot 2 of the rollup contract (`lastWarpedBlockTs`) which tracks the last time warp was used.
|
|
272
270
|
await this.eth.store(rollupContract, 2n, BigInt(to));
|
|
271
|
+
// also store this on slot 3 of the rollup contract (`lastWarpedBlockTs`) which tracks the last time warp was used.
|
|
272
|
+
await this.eth.store(rollupContract, 3n, BigInt(to));
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AuthWitness, type FunctionCall, type PXE, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
2
|
+
import { AztecAddress, CANONICAL_KEY_REGISTRY_ADDRESS, Fq, Fr, derivePublicKeyFromSecretKey } from '@aztec/circuits.js';
|
|
3
3
|
import { type ABIParameterVisibility, type FunctionAbi, FunctionType } from '@aztec/foundation/abi';
|
|
4
4
|
|
|
5
5
|
import { type AccountInterface } from '../account/interface.js';
|
|
@@ -165,6 +165,30 @@ export class AccountWallet extends BaseWallet {
|
|
|
165
165
|
return { isValidInPrivate, isValidInPublic };
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Rotates the account master nullifier key pair.
|
|
170
|
+
* @param newNskM - The new master nullifier secret key we want to use.
|
|
171
|
+
* @remarks - This function also calls the canonical key registry with the account's new derived master nullifier public key.
|
|
172
|
+
* We are doing it this way to avoid user error, in the case that a user rotates their keys in the key registry,
|
|
173
|
+
* but fails to do so in the key store. This leads to unspendable notes.
|
|
174
|
+
*
|
|
175
|
+
* This does not hinder our ability to spend notes tied to a previous master nullifier public key, provided we have the master nullifier secret key for it.
|
|
176
|
+
*/
|
|
177
|
+
public async rotateNullifierKeys(newNskM: Fq = Fq.random()): Promise<void> {
|
|
178
|
+
// We rotate our secret key in the keystore first, because if the subsequent interaction fails, there are no bad side-effects.
|
|
179
|
+
// If vice versa (the key registry is called first), but the call to the PXE fails, we will end up in a situation with unspendable notes, as we have not committed our
|
|
180
|
+
// nullifier secret key to our wallet.
|
|
181
|
+
await this.pxe.rotateNskM(this.getAddress(), newNskM);
|
|
182
|
+
const interaction = new ContractFunctionInteraction(
|
|
183
|
+
this,
|
|
184
|
+
AztecAddress.fromBigInt(CANONICAL_KEY_REGISTRY_ADDRESS),
|
|
185
|
+
this.getRotateNpkMAbi(),
|
|
186
|
+
[this.getAddress(), derivePublicKeyFromSecretKey(newNskM), Fr.ZERO],
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
await interaction.send().wait();
|
|
190
|
+
}
|
|
191
|
+
|
|
168
192
|
/**
|
|
169
193
|
* Returns a function interaction to cancel a message hash as authorized in this account.
|
|
170
194
|
* @param messageHashOrIntent - The message or the caller and action to authorize/revoke
|
|
@@ -204,8 +228,9 @@ export class AccountWallet extends BaseWallet {
|
|
|
204
228
|
return {
|
|
205
229
|
name: 'approve_public_authwit',
|
|
206
230
|
isInitializer: false,
|
|
207
|
-
functionType: FunctionType.
|
|
231
|
+
functionType: FunctionType.PUBLIC,
|
|
208
232
|
isInternal: true,
|
|
233
|
+
isStatic: false,
|
|
209
234
|
parameters: [
|
|
210
235
|
{
|
|
211
236
|
name: 'message_hash',
|
|
@@ -221,8 +246,9 @@ export class AccountWallet extends BaseWallet {
|
|
|
221
246
|
return {
|
|
222
247
|
name: 'cancel_authwit',
|
|
223
248
|
isInitializer: false,
|
|
224
|
-
functionType: FunctionType.
|
|
249
|
+
functionType: FunctionType.PRIVATE,
|
|
225
250
|
isInternal: true,
|
|
251
|
+
isStatic: false,
|
|
226
252
|
parameters: [
|
|
227
253
|
{
|
|
228
254
|
name: 'message_hash',
|
|
@@ -240,6 +266,7 @@ export class AccountWallet extends BaseWallet {
|
|
|
240
266
|
isInitializer: false,
|
|
241
267
|
functionType: FunctionType.UNCONSTRAINED,
|
|
242
268
|
isInternal: false,
|
|
269
|
+
isStatic: false,
|
|
243
270
|
parameters: [
|
|
244
271
|
{
|
|
245
272
|
name: 'myself',
|
|
@@ -265,4 +292,39 @@ export class AccountWallet extends BaseWallet {
|
|
|
265
292
|
returnTypes: [{ kind: 'array', length: 2, type: { kind: 'boolean' } }],
|
|
266
293
|
};
|
|
267
294
|
}
|
|
295
|
+
|
|
296
|
+
private getRotateNpkMAbi(): FunctionAbi {
|
|
297
|
+
return {
|
|
298
|
+
name: 'rotate_npk_m',
|
|
299
|
+
isInitializer: false,
|
|
300
|
+
functionType: FunctionType.PUBLIC,
|
|
301
|
+
isInternal: false,
|
|
302
|
+
isStatic: false,
|
|
303
|
+
parameters: [
|
|
304
|
+
{
|
|
305
|
+
name: 'address',
|
|
306
|
+
type: {
|
|
307
|
+
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
308
|
+
kind: 'struct',
|
|
309
|
+
path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
310
|
+
},
|
|
311
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: 'new_npk_m',
|
|
315
|
+
type: {
|
|
316
|
+
fields: [
|
|
317
|
+
{ name: 'x', type: { kind: 'field' } },
|
|
318
|
+
{ name: 'y', type: { kind: 'field' } },
|
|
319
|
+
],
|
|
320
|
+
kind: 'struct',
|
|
321
|
+
path: 'authwit::aztec::protocol_types::grumpkin_point::GrumpkinPoint',
|
|
322
|
+
},
|
|
323
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
324
|
+
},
|
|
325
|
+
{ name: 'nonce', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
|
|
326
|
+
],
|
|
327
|
+
returnTypes: [],
|
|
328
|
+
};
|
|
329
|
+
}
|
|
268
330
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type LogFilter,
|
|
8
8
|
type NoteFilter,
|
|
9
9
|
type PXE,
|
|
10
|
+
type PXEInfo,
|
|
10
11
|
type SimulatedTx,
|
|
11
12
|
type SyncStatus,
|
|
12
13
|
type Tx,
|
|
@@ -15,7 +16,8 @@ import {
|
|
|
15
16
|
type TxHash,
|
|
16
17
|
type TxReceipt,
|
|
17
18
|
} from '@aztec/circuit-types';
|
|
18
|
-
import { type
|
|
19
|
+
import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
|
|
20
|
+
import { type AztecAddress, type CompleteAddress, type Fq, type Fr, type PartialAddress } from '@aztec/circuits.js';
|
|
19
21
|
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
20
22
|
import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
21
23
|
import { type NodeInfo } from '@aztec/types/interfaces';
|
|
@@ -54,6 +56,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
54
56
|
},
|
|
55
57
|
): Promise<AuthWitness>;
|
|
56
58
|
|
|
59
|
+
abstract rotateNullifierKeys(newNskM: Fq): Promise<void>;
|
|
60
|
+
|
|
57
61
|
getAddress() {
|
|
58
62
|
return this.getCompleteAddress().address;
|
|
59
63
|
}
|
|
@@ -69,6 +73,9 @@ export abstract class BaseWallet implements Wallet {
|
|
|
69
73
|
registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
70
74
|
return this.pxe.registerAccount(secretKey, partialAddress);
|
|
71
75
|
}
|
|
76
|
+
rotateNskM(address: AztecAddress, secretKey: Fq) {
|
|
77
|
+
return this.pxe.rotateNskM(address, secretKey);
|
|
78
|
+
}
|
|
72
79
|
registerRecipient(account: CompleteAddress): Promise<void> {
|
|
73
80
|
return this.pxe.registerRecipient(account);
|
|
74
81
|
}
|
|
@@ -127,8 +134,13 @@ export abstract class BaseWallet implements Wallet {
|
|
|
127
134
|
getBlock(number: number): Promise<L2Block | undefined> {
|
|
128
135
|
return this.pxe.getBlock(number);
|
|
129
136
|
}
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
simulateUnconstrained(
|
|
138
|
+
functionName: string,
|
|
139
|
+
args: any[],
|
|
140
|
+
to: AztecAddress,
|
|
141
|
+
from?: AztecAddress | undefined,
|
|
142
|
+
): Promise<any> {
|
|
143
|
+
return this.pxe.simulateUnconstrained(functionName, args, to, from);
|
|
132
144
|
}
|
|
133
145
|
getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
|
|
134
146
|
return this.pxe.getUnencryptedLogs(filter);
|
|
@@ -148,6 +160,9 @@ export abstract class BaseWallet implements Wallet {
|
|
|
148
160
|
getSyncStatus(): Promise<SyncStatus> {
|
|
149
161
|
return this.pxe.getSyncStatus();
|
|
150
162
|
}
|
|
163
|
+
getSyncStats(): Promise<{ [key: string]: NoteProcessorStats }> {
|
|
164
|
+
return this.pxe.getSyncStats();
|
|
165
|
+
}
|
|
151
166
|
addAuthWitness(authWitness: AuthWitness) {
|
|
152
167
|
return this.pxe.addAuthWitness(authWitness);
|
|
153
168
|
}
|
|
@@ -160,4 +175,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
160
175
|
isContractPubliclyDeployed(address: AztecAddress): Promise<boolean> {
|
|
161
176
|
return this.pxe.isContractPubliclyDeployed(address);
|
|
162
177
|
}
|
|
178
|
+
getPXEInfo(): Promise<PXEInfo> {
|
|
179
|
+
return this.pxe.getPXEInfo();
|
|
180
|
+
}
|
|
163
181
|
}
|
|
@@ -8,6 +8,8 @@ import { CompleteAddress } from '@aztec/circuits.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export async function createRecipient(pxe: PXE): Promise<CompleteAddress> {
|
|
10
10
|
const completeAddress = CompleteAddress.random();
|
|
11
|
+
// docs:start:register-recipient
|
|
11
12
|
await pxe.registerRecipient(completeAddress);
|
|
13
|
+
// docs:end:register-recipient
|
|
12
14
|
return completeAddress;
|
|
13
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AuthWitness, type PXE, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
-
import { type CompleteAddress, type Fr } from '@aztec/circuits.js';
|
|
2
|
+
import { type CompleteAddress, type Fq, type Fr } from '@aztec/circuits.js';
|
|
3
3
|
|
|
4
4
|
import { DefaultEntrypoint } from '../entrypoint/default_entrypoint.js';
|
|
5
5
|
import { type EntrypointInterface, type ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
@@ -24,22 +24,26 @@ export class SignerlessWallet extends BaseWallet {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
getChainId(): Fr {
|
|
27
|
-
throw new Error('Method not implemented.');
|
|
27
|
+
throw new Error('SignerlessWallet: Method getChainId not implemented.');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
getVersion(): Fr {
|
|
31
|
-
throw new Error('Method not implemented.');
|
|
31
|
+
throw new Error('SignerlessWallet: Method getVersion not implemented.');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
getPublicKeysHash(): Fr {
|
|
35
|
-
throw new Error('Method not implemented.');
|
|
35
|
+
throw new Error('SignerlessWallet: Method getPublicKeysHash not implemented.');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
getCompleteAddress(): CompleteAddress {
|
|
39
|
-
throw new Error('Method not implemented.');
|
|
39
|
+
throw new Error('SignerlessWallet: Method getCompleteAddress not implemented.');
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
createAuthWit(_messageHash: Fr): Promise<AuthWitness> {
|
|
43
|
-
throw new Error('Method not implemented.');
|
|
43
|
+
throw new Error('SignerlessWallet: Method createAuthWit not implemented.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
rotateNullifierKeys(_newNskM: Fq): Promise<void> {
|
|
47
|
+
throw new Error('SignerlessWallet: Method rotateNullifierKeys not implemented.');
|
|
44
48
|
}
|
|
45
49
|
}
|