@aztec/aztec.js 0.0.1-commit.d431d1c → 0.0.1-commit.db765a8
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/api/abi.d.ts +2 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/block.d.ts +2 -2
- package/dest/api/block.d.ts.map +1 -1
- package/dest/api/block.js +1 -1
- package/dest/api/contract.d.ts +18 -12
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +16 -10
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/events.d.ts +10 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +30 -20
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +3 -3
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +17 -8
- package/dest/contract/contract_function_interaction.d.ts +7 -16
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +107 -18
- package/dest/contract/deploy_method.d.ts +91 -19
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +68 -30
- package/dest/contract/get_gas_limits.js +3 -3
- package/dest/contract/interaction_options.d.ts +99 -21
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +41 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +3 -3
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/auth-registry.js +49 -20
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -22
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +13 -671
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-instance-registry.js +80 -486
- package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/fee-juice.js +7 -413
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +3 -3
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +40 -15
- package/dest/contract/protocol_contracts/public-checks.d.ts +3 -3
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/public-checks.js +40 -23
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
- package/dest/fee/private_fee_payment_method.js +10 -10
- package/dest/fee/public_fee_payment_method.js +10 -10
- package/dest/fee/sponsored_fee_payment.js +3 -3
- package/dest/utils/abi_types.d.ts +6 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/abi_types.js +1 -1
- package/dest/utils/authwit.d.ts +6 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +12 -12
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/capabilities.d.ts +452 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +31 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +26 -0
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1639 -93
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +186 -27
- package/package.json +20 -11
- package/src/api/abi.ts +1 -0
- package/src/api/block.ts +1 -1
- package/src/api/contract.ts +31 -9
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +1 -0
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +48 -1
- package/src/contract/base_contract_interaction.ts +28 -15
- package/src/contract/batch_call.ts +17 -14
- package/src/contract/contract_function_interaction.ts +114 -26
- package/src/contract/deploy_method.ts +172 -35
- package/src/contract/get_gas_limits.ts +3 -3
- package/src/contract/interaction_options.ts +141 -23
- package/src/contract/protocol_contracts/auth-registry.ts +13 -14
- package/src/contract/protocol_contracts/contract-class-registry.ts +4 -347
- package/src/contract/protocol_contracts/contract-instance-registry.ts +34 -234
- package/src/contract/protocol_contracts/fee-juice.ts +2 -202
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +11 -13
- package/src/contract/protocol_contracts/public-checks.ts +11 -15
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +7 -7
- package/src/fee/public_fee_payment_method.ts +8 -8
- package/src/fee/sponsored_fee_payment.ts +3 -3
- package/src/utils/abi_types.ts +7 -0
- package/src/utils/authwit.ts +31 -21
- package/src/utils/node.ts +62 -0
- package/src/wallet/capabilities.ts +500 -0
- package/src/wallet/deploy_account_method.ts +56 -4
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +257 -50
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/sent_tx.ts +0 -129
- package/src/deployment/broadcast_function.ts +0 -148
|
@@ -32,7 +32,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
|
|
|
32
32
|
type: {
|
|
33
33
|
kind: 'struct',
|
|
34
34
|
fields: [
|
|
35
|
-
{ name: 'storage', type: { kind: 'array', length:
|
|
35
|
+
{ name: 'storage', type: { kind: 'array', length: 15, type: { kind: 'field' } } },
|
|
36
36
|
{ name: 'len', type: { kind: 'integer', sign: 'unsigned', width: 32 } },
|
|
37
37
|
],
|
|
38
38
|
path: 'std::collections::bounded_vec::BoundedVec',
|
|
@@ -93,22 +93,16 @@ const PublicChecksContractArtifact: ContractArtifact = {
|
|
|
93
93
|
},
|
|
94
94
|
'4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
|
|
95
95
|
'4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
|
|
96
|
+
'5417577161503694006': { error_kind: 'fmtstring', length: 56, item_types: [{ kind: 'field' }] },
|
|
97
|
+
'5421095327929394772': { error_kind: 'string', string: 'attempt to bit-shift with overflow' },
|
|
98
|
+
'9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
|
|
96
99
|
'9791669845391776238': {
|
|
97
100
|
error_kind: 'string',
|
|
98
101
|
string: '0 has a square root; you cannot claim it is not square',
|
|
99
102
|
},
|
|
100
|
-
'9885968605480832328': {
|
|
101
|
-
error_kind: 'string',
|
|
102
|
-
string: 'Attempted to read past the length of a CapsuleArray',
|
|
103
|
-
},
|
|
104
103
|
'10135509984888824963': { error_kind: 'fmtstring', length: 58, item_types: [{ kind: 'field' }] },
|
|
105
104
|
'10791800398362570014': { error_kind: 'string', string: 'extend_from_bounded_vec out of bounds' },
|
|
106
|
-
'11021520179822076911': {
|
|
107
|
-
error_kind: 'string',
|
|
108
|
-
string: 'Attempted to delete past the length of a CapsuleArray',
|
|
109
|
-
},
|
|
110
105
|
'11692359521570349358': { error_kind: 'fmtstring', length: 40, item_types: [] },
|
|
111
|
-
'12327971061804302172': { error_kind: 'fmtstring', length: 98, item_types: [] },
|
|
112
106
|
'12469291177396340830': { error_kind: 'string', string: 'call to assert_max_bit_size' },
|
|
113
107
|
'12913276134398371456': { error_kind: 'string', string: 'push out of bounds' },
|
|
114
108
|
'13557316507370296400': {
|
|
@@ -155,10 +149,8 @@ const PublicChecksContractArtifact: ContractArtifact = {
|
|
|
155
149
|
},
|
|
156
150
|
'12511970388699677811': { error_kind: 'fmtstring', length: 27, item_types: [{ kind: 'field' }] },
|
|
157
151
|
'13950240626967988787': { error_kind: 'string', string: 'Timestamp mismatch.' },
|
|
158
|
-
'14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
|
|
159
152
|
'15015303112667403944': { error_kind: 'fmtstring', length: 17, item_types: [] },
|
|
160
153
|
'15764276373176857197': { error_kind: 'string', string: 'Stack too deep' },
|
|
161
|
-
'16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
|
|
162
154
|
},
|
|
163
155
|
},
|
|
164
156
|
bytecode: Buffer.from([]),
|
|
@@ -167,7 +159,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
|
|
|
167
159
|
{
|
|
168
160
|
...{
|
|
169
161
|
functionType: FunctionType.UTILITY,
|
|
170
|
-
name: '
|
|
162
|
+
name: 'sync_state',
|
|
171
163
|
isOnlySelf: false,
|
|
172
164
|
isStatic: false,
|
|
173
165
|
isInitializer: false,
|
|
@@ -194,6 +186,9 @@ const PublicChecksContractArtifact: ContractArtifact = {
|
|
|
194
186
|
},
|
|
195
187
|
'4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
|
|
196
188
|
'4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
|
|
189
|
+
'5417577161503694006': { error_kind: 'fmtstring', length: 56, item_types: [{ kind: 'field' }] },
|
|
190
|
+
'5421095327929394772': { error_kind: 'string', string: 'attempt to bit-shift with overflow' },
|
|
191
|
+
'9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
|
|
197
192
|
'9791669845391776238': {
|
|
198
193
|
error_kind: 'string',
|
|
199
194
|
string: '0 has a square root; you cannot claim it is not square',
|
|
@@ -230,6 +225,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
|
|
|
230
225
|
length: 133,
|
|
231
226
|
item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
|
|
232
227
|
},
|
|
228
|
+
'17655676068928457687': { error_kind: 'string', string: 'Reader did not read all data' },
|
|
233
229
|
},
|
|
234
230
|
},
|
|
235
231
|
bytecode: Buffer.from([]),
|
|
@@ -318,7 +314,7 @@ export class PublicChecksContract extends ContractBase {
|
|
|
318
314
|
/** public_dispatch(selector: field) */
|
|
319
315
|
public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
320
316
|
|
|
321
|
-
/**
|
|
322
|
-
|
|
317
|
+
/** sync_state() */
|
|
318
|
+
sync_state: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
|
|
323
319
|
};
|
|
324
320
|
}
|
|
@@ -2,7 +2,7 @@ import { retryUntil } from '@aztec/foundation/retry';
|
|
|
2
2
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
3
|
import type { TxReceipt } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
|
-
import { DefaultWaitOpts } from './
|
|
5
|
+
import { DefaultWaitOpts } from './wait_opts.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Options for waiting for a transaction to be proven.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TxStatus } from '@aztec/stdlib/tx';
|
|
2
|
+
|
|
3
|
+
/** Options related to waiting for a tx. */
|
|
4
|
+
export type WaitOpts = {
|
|
5
|
+
/** The amount of time to ignore TxStatus.DROPPED receipts (in seconds) due to the presumption that it is being propagated by the p2p network. Defaults to 5. */
|
|
6
|
+
ignoreDroppedReceiptsFor?: number;
|
|
7
|
+
/** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */
|
|
10
|
+
interval?: number;
|
|
11
|
+
/** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
|
|
12
|
+
dontThrowOnRevert?: boolean;
|
|
13
|
+
/** The minimum inclusion status to wait for. If set, waits until the receipt reaches this status or higher. Defaults to CHECKPOINTED. */
|
|
14
|
+
waitForStatus?: TxStatus;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const DefaultWaitOpts: WaitOpts = {
|
|
18
|
+
ignoreDroppedReceiptsFor: 5,
|
|
19
|
+
timeout: 300,
|
|
20
|
+
interval: 1,
|
|
21
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
6
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -27,10 +27,11 @@ export class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
|
27
27
|
|
|
28
28
|
return new ExecutionPayload(
|
|
29
29
|
[
|
|
30
|
-
{
|
|
31
|
-
to: ProtocolContractAddress.FeeJuice,
|
|
30
|
+
FunctionCall.from({
|
|
32
31
|
name: 'claim_and_end_setup',
|
|
32
|
+
to: ProtocolContractAddress.FeeJuice,
|
|
33
33
|
selector,
|
|
34
|
+
type: FunctionType.PRIVATE,
|
|
34
35
|
hideMsgSender: false,
|
|
35
36
|
isStatic: false,
|
|
36
37
|
args: [
|
|
@@ -40,8 +41,7 @@ export class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
|
|
|
40
41
|
new Fr(this.claim.messageLeafIndex),
|
|
41
42
|
],
|
|
42
43
|
returnTypes: [],
|
|
43
|
-
|
|
44
|
-
},
|
|
44
|
+
}),
|
|
45
45
|
],
|
|
46
46
|
[],
|
|
47
47
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -102,21 +102,21 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
102
102
|
|
|
103
103
|
const witness = await this.wallet.createAuthWit(this.sender, {
|
|
104
104
|
caller: this.paymentContract,
|
|
105
|
-
call: {
|
|
105
|
+
call: FunctionCall.from({
|
|
106
106
|
name: 'transfer_to_public',
|
|
107
|
-
|
|
107
|
+
to: await this.getAsset(),
|
|
108
108
|
selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
|
|
109
109
|
type: FunctionType.PRIVATE,
|
|
110
110
|
hideMsgSender: false,
|
|
111
111
|
isStatic: false,
|
|
112
|
-
|
|
112
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
113
113
|
returnTypes: [],
|
|
114
|
-
},
|
|
114
|
+
}),
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
return new ExecutionPayload(
|
|
118
118
|
[
|
|
119
|
-
{
|
|
119
|
+
FunctionCall.from({
|
|
120
120
|
name: 'fee_entrypoint_private',
|
|
121
121
|
to: this.paymentContract,
|
|
122
122
|
selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
|
|
@@ -125,7 +125,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
|
|
|
125
125
|
isStatic: false,
|
|
126
126
|
args: [maxFee, txNonce],
|
|
127
127
|
returnTypes: [],
|
|
128
|
-
},
|
|
128
|
+
}),
|
|
129
129
|
],
|
|
130
130
|
[witness],
|
|
131
131
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -94,16 +94,16 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
94
94
|
|
|
95
95
|
const intent = {
|
|
96
96
|
caller: this.paymentContract,
|
|
97
|
-
call: {
|
|
97
|
+
call: FunctionCall.from({
|
|
98
98
|
name: 'transfer_in_public',
|
|
99
|
-
|
|
99
|
+
to: await this.getAsset(),
|
|
100
100
|
selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
|
|
101
101
|
type: FunctionType.PUBLIC,
|
|
102
|
-
isStatic: false,
|
|
103
102
|
hideMsgSender: false /** The target function performs an authwit check, so msg_sender is needed */,
|
|
104
|
-
|
|
103
|
+
isStatic: false,
|
|
104
|
+
args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
|
|
105
105
|
returnTypes: [],
|
|
106
|
-
},
|
|
106
|
+
}),
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
const setPublicAuthWitInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
@@ -116,7 +116,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
116
116
|
return new ExecutionPayload(
|
|
117
117
|
[
|
|
118
118
|
...(await setPublicAuthWitInteraction.request()).calls,
|
|
119
|
-
{
|
|
119
|
+
FunctionCall.from({
|
|
120
120
|
name: 'fee_entrypoint_public',
|
|
121
121
|
to: this.paymentContract,
|
|
122
122
|
selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
|
|
@@ -125,7 +125,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
|
|
|
125
125
|
isStatic: false,
|
|
126
126
|
args: [maxFee, txNonce],
|
|
127
127
|
returnTypes: [],
|
|
128
|
-
},
|
|
128
|
+
}),
|
|
129
129
|
],
|
|
130
130
|
[],
|
|
131
131
|
[],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -22,7 +22,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
22
22
|
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
23
23
|
return new ExecutionPayload(
|
|
24
24
|
[
|
|
25
|
-
{
|
|
25
|
+
FunctionCall.from({
|
|
26
26
|
name: 'sponsor_unconditionally',
|
|
27
27
|
to: this.paymentContract,
|
|
28
28
|
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
@@ -31,7 +31,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
|
31
31
|
isStatic: false,
|
|
32
32
|
args: [],
|
|
33
33
|
returnTypes: [],
|
|
34
|
-
},
|
|
34
|
+
}),
|
|
35
35
|
],
|
|
36
36
|
[],
|
|
37
37
|
[],
|
package/src/utils/abi_types.ts
CHANGED
|
@@ -23,3 +23,10 @@ export type U128Like = bigint | number;
|
|
|
23
23
|
|
|
24
24
|
/** Any type that can be converted into a struct with a single `inner` field. */
|
|
25
25
|
export type WrappedFieldLike = { /** Wrapped value */ inner: FieldLike } | FieldLike;
|
|
26
|
+
|
|
27
|
+
/** Noir `Option<T>` lowered ABI shape, plus ergonomic direct `T | null | undefined` inputs. */
|
|
28
|
+
export type OptionLike<T> =
|
|
29
|
+
| T
|
|
30
|
+
| null
|
|
31
|
+
| undefined
|
|
32
|
+
| { /** Whether the option is populated */ _is_some: boolean; /** Wrapped value */ _value: T };
|
package/src/utils/authwit.ts
CHANGED
|
@@ -9,12 +9,15 @@ import type { TxProfileResult } from '@aztec/stdlib/tx';
|
|
|
9
9
|
|
|
10
10
|
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
11
11
|
import type {
|
|
12
|
+
InteractionWaitOptions,
|
|
12
13
|
ProfileInteractionOptions,
|
|
13
14
|
SendInteractionOptions,
|
|
15
|
+
SendInteractionOptionsWithoutWait,
|
|
16
|
+
SendReturn,
|
|
14
17
|
SimulateInteractionOptions,
|
|
15
|
-
|
|
18
|
+
SimulationResult,
|
|
19
|
+
TxSendResultMined,
|
|
16
20
|
} from '../contract/interaction_options.js';
|
|
17
|
-
import type { SentTx } from '../contract/sent_tx.js';
|
|
18
21
|
import type { Wallet } from '../wallet/index.js';
|
|
19
22
|
|
|
20
23
|
/** Intent with an inner hash */
|
|
@@ -187,10 +190,12 @@ export async function lookupValidity(
|
|
|
187
190
|
errorTypes: {},
|
|
188
191
|
} as FunctionAbi;
|
|
189
192
|
try {
|
|
190
|
-
results.isValidInPrivate = (
|
|
191
|
-
consumer,
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
results.isValidInPrivate = (
|
|
194
|
+
await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [consumer, innerHash]).simulate({
|
|
195
|
+
from: onBehalfOf,
|
|
196
|
+
authWitnesses: [witness],
|
|
197
|
+
})
|
|
198
|
+
).result as boolean;
|
|
194
199
|
// TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
|
|
195
200
|
// eslint-disable-next-line no-empty
|
|
196
201
|
} catch {}
|
|
@@ -217,12 +222,12 @@ export async function lookupValidity(
|
|
|
217
222
|
returnTypes: [{ kind: 'boolean' }],
|
|
218
223
|
errorTypes: {},
|
|
219
224
|
} as FunctionAbi;
|
|
220
|
-
results.isValidInPublic = (
|
|
221
|
-
wallet,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
).
|
|
225
|
+
results.isValidInPublic = (
|
|
226
|
+
await new ContractFunctionInteraction(wallet, ProtocolContractAddress.AuthRegistry, isConsumableAbi, [
|
|
227
|
+
onBehalfOf,
|
|
228
|
+
messageHash,
|
|
229
|
+
]).simulate({ from: onBehalfOf })
|
|
230
|
+
).result as boolean;
|
|
226
231
|
|
|
227
232
|
return results;
|
|
228
233
|
}
|
|
@@ -260,14 +265,10 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
260
265
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
261
266
|
* @returns The result of the transaction as returned by the contract function.
|
|
262
267
|
*/
|
|
263
|
-
public override simulate<T extends SimulateInteractionOptions>(
|
|
264
|
-
options: Omit<T, 'from'>,
|
|
265
|
-
): Promise<SimulationReturn<T['includeMetadata']>>;
|
|
266
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
267
268
|
public override simulate(
|
|
268
|
-
options: Omit<SimulateInteractionOptions, 'from'> = {},
|
|
269
|
-
): Promise<
|
|
270
|
-
return super.simulate({ ...options, from: this.from });
|
|
269
|
+
options: Omit<SimulateInteractionOptions, 'from'> = {} as Omit<SimulateInteractionOptions, 'from'>,
|
|
270
|
+
): Promise<SimulationResult> {
|
|
271
|
+
return super.simulate({ ...options, from: this.from } as SimulateInteractionOptions);
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
/**
|
|
@@ -286,9 +287,18 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
286
287
|
* Overrides the send method, adding the sender of the authwit (authorizer) as from
|
|
287
288
|
* and preventing misuse
|
|
288
289
|
* @param options - An optional object containing 'fee' options information
|
|
289
|
-
* @returns A
|
|
290
|
+
* @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
|
|
290
291
|
*/
|
|
291
|
-
public override send(options
|
|
292
|
+
public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxSendResultMined>;
|
|
293
|
+
// Generic overload for explicit wait values
|
|
294
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
295
|
+
public override send<W extends InteractionWaitOptions>(
|
|
296
|
+
options?: Omit<SendInteractionOptions<W>, 'from'>,
|
|
297
|
+
): Promise<SendReturn<W>>;
|
|
298
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
299
|
+
public override send(
|
|
300
|
+
options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
|
|
301
|
+
): Promise<SendReturn<InteractionWaitOptions>> {
|
|
292
302
|
return super.send({ ...options, from: this.from });
|
|
293
303
|
}
|
|
294
304
|
|
package/src/utils/node.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
3
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
5
|
+
import { SortedTxStatuses, TxStatus } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
import { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
|
|
4
8
|
|
|
5
9
|
export const waitForNode = async (node: AztecNode, logger?: Logger) => {
|
|
6
10
|
await retryUntil(async () => {
|
|
@@ -16,4 +20,62 @@ export const waitForNode = async (node: AztecNode, logger?: Logger) => {
|
|
|
16
20
|
}, 'RPC Get Node Info');
|
|
17
21
|
};
|
|
18
22
|
|
|
23
|
+
/** Returns true if the receipt status is at least the desired status level. */
|
|
24
|
+
function hasReachedStatus(receipt: TxReceipt, desiredStatus: TxStatus): boolean {
|
|
25
|
+
return SortedTxStatuses.indexOf(receipt.status) >= SortedTxStatuses.indexOf(desiredStatus);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Waits for a transaction to be mined and returns its receipt.
|
|
30
|
+
* @param node - The Aztec node to query for transaction status
|
|
31
|
+
* @param txHash - The hash of the transaction to wait for
|
|
32
|
+
* @param opts - Optional configuration for waiting behavior
|
|
33
|
+
* @returns The transaction receipt
|
|
34
|
+
* @throws If the transaction fails and dontThrowOnRevert is not set
|
|
35
|
+
*/
|
|
36
|
+
export async function waitForTx(node: AztecNode, txHash: TxHash, opts?: WaitOpts): Promise<TxReceipt> {
|
|
37
|
+
const startTime = Date.now();
|
|
38
|
+
const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
|
|
39
|
+
const waitForStatus = opts?.waitForStatus ?? TxStatus.CHECKPOINTED;
|
|
40
|
+
|
|
41
|
+
const receipt = await retryUntil(
|
|
42
|
+
async () => {
|
|
43
|
+
const txReceipt = await node.getTxReceipt(txHash);
|
|
44
|
+
// If receipt is not yet available, try again
|
|
45
|
+
if (txReceipt.isPending()) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
// If the tx was "dropped", either return it or ignore based on timing.
|
|
49
|
+
// We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
|
|
50
|
+
// If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
|
|
51
|
+
if (txReceipt.isDropped()) {
|
|
52
|
+
const elapsedSeconds = (Date.now() - startTime) / 1000;
|
|
53
|
+
if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
|
|
54
|
+
return txReceipt;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
// Check if the receipt has reached the desired status level
|
|
59
|
+
if (!hasReachedStatus(txReceipt, waitForStatus)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return txReceipt;
|
|
63
|
+
},
|
|
64
|
+
'isMined',
|
|
65
|
+
opts?.timeout ?? DefaultWaitOpts.timeout,
|
|
66
|
+
opts?.interval ?? DefaultWaitOpts.interval,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (!receipt.isMined()) {
|
|
70
|
+
throw new Error(`Transaction ${txHash.toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
|
|
71
|
+
}
|
|
72
|
+
if (!receipt.hasExecutionSucceeded() && !opts?.dontThrowOnRevert) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Transaction ${txHash.toString()} reverted: ${receipt.executionResult}. Reason: ${receipt.error ?? 'unknown'}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return receipt;
|
|
79
|
+
}
|
|
80
|
+
|
|
19
81
|
export { createAztecNodeClient, type AztecNode } from '@aztec/stdlib/interfaces/client';
|