@aztec/aztec.js 0.0.1-commit.d431d1c → 0.0.1-commit.e310a4c8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dest/api/block.d.ts +2 -2
  2. package/dest/api/block.d.ts.map +1 -1
  3. package/dest/api/block.js +1 -1
  4. package/dest/api/contract.d.ts +16 -10
  5. package/dest/api/contract.d.ts.map +1 -1
  6. package/dest/api/contract.js +14 -8
  7. package/dest/api/keys.d.ts +1 -1
  8. package/dest/api/keys.js +1 -1
  9. package/dest/api/node.d.ts +8 -4
  10. package/dest/api/node.d.ts.map +1 -1
  11. package/dest/api/node.js +7 -3
  12. package/dest/api/tx.d.ts +2 -2
  13. package/dest/api/tx.d.ts.map +1 -1
  14. package/dest/api/tx.js +1 -1
  15. package/dest/api/wallet.d.ts +3 -2
  16. package/dest/api/wallet.d.ts.map +1 -1
  17. package/dest/api/wallet.js +2 -1
  18. package/dest/contract/base_contract_interaction.d.ts +8 -10
  19. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  20. package/dest/contract/base_contract_interaction.js +5 -17
  21. package/dest/contract/deploy_method.d.ts +63 -16
  22. package/dest/contract/deploy_method.d.ts.map +1 -1
  23. package/dest/contract/deploy_method.js +36 -19
  24. package/dest/contract/interaction_options.d.ts +42 -5
  25. package/dest/contract/interaction_options.d.ts.map +1 -1
  26. package/dest/contract/interaction_options.js +8 -1
  27. package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -10
  28. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
  29. package/dest/contract/protocol_contracts/auth-registry.js +61 -479
  30. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -11
  31. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
  32. package/dest/contract/protocol_contracts/contract-class-registry.js +10 -422
  33. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
  34. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
  35. package/dest/contract/protocol_contracts/contract-instance-registry.js +80 -486
  36. package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
  37. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
  38. package/dest/contract/protocol_contracts/fee-juice.js +0 -414
  39. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +3 -3
  40. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
  41. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +13 -14
  42. package/dest/contract/protocol_contracts/public-checks.d.ts +3 -3
  43. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
  44. package/dest/contract/protocol_contracts/public-checks.js +13 -22
  45. package/dest/contract/wait_for_proven.js +1 -1
  46. package/dest/contract/wait_opts.d.ts +16 -0
  47. package/dest/contract/wait_opts.d.ts.map +1 -0
  48. package/dest/contract/wait_opts.js +5 -0
  49. package/dest/utils/authwit.d.ts +6 -6
  50. package/dest/utils/authwit.d.ts.map +1 -1
  51. package/dest/utils/authwit.js +2 -6
  52. package/dest/utils/node.d.ts +12 -1
  53. package/dest/utils/node.d.ts.map +1 -1
  54. package/dest/utils/node.js +46 -0
  55. package/dest/wallet/capabilities.d.ts +444 -0
  56. package/dest/wallet/capabilities.d.ts.map +1 -0
  57. package/dest/wallet/capabilities.js +3 -0
  58. package/dest/wallet/deploy_account_method.d.ts +19 -5
  59. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  60. package/dest/wallet/index.d.ts +2 -1
  61. package/dest/wallet/index.d.ts.map +1 -1
  62. package/dest/wallet/index.js +1 -0
  63. package/dest/wallet/wallet.d.ts +1356 -18
  64. package/dest/wallet/wallet.d.ts.map +1 -1
  65. package/dest/wallet/wallet.js +136 -4
  66. package/package.json +9 -9
  67. package/src/api/block.ts +1 -1
  68. package/src/api/contract.ts +22 -7
  69. package/src/api/keys.ts +2 -2
  70. package/src/api/node.ts +7 -3
  71. package/src/api/tx.ts +2 -0
  72. package/src/api/wallet.ts +43 -0
  73. package/src/contract/base_contract_interaction.ts +27 -15
  74. package/src/contract/deploy_method.ts +115 -23
  75. package/src/contract/interaction_options.ts +49 -4
  76. package/src/contract/protocol_contracts/auth-registry.ts +37 -240
  77. package/src/contract/protocol_contracts/contract-class-registry.ts +3 -204
  78. package/src/contract/protocol_contracts/contract-instance-registry.ts +34 -234
  79. package/src/contract/protocol_contracts/fee-juice.ts +0 -202
  80. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +6 -12
  81. package/src/contract/protocol_contracts/public-checks.ts +6 -14
  82. package/src/contract/wait_for_proven.ts +1 -1
  83. package/src/contract/wait_opts.ts +21 -0
  84. package/src/utils/authwit.ts +16 -4
  85. package/src/utils/node.ts +62 -0
  86. package/src/wallet/capabilities.ts +491 -0
  87. package/src/wallet/deploy_account_method.ts +19 -4
  88. package/src/wallet/index.ts +1 -0
  89. package/src/wallet/wallet.ts +148 -12
  90. package/dest/contract/deploy_sent_tx.d.ts +0 -48
  91. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  92. package/dest/contract/deploy_sent_tx.js +0 -46
  93. package/dest/contract/sent_tx.d.ts +0 -50
  94. package/dest/contract/sent_tx.d.ts.map +0 -1
  95. package/dest/contract/sent_tx.js +0 -90
  96. package/src/contract/deploy_sent_tx.ts +0 -75
  97. package/src/contract/sent_tx.ts +0 -129
@@ -44,7 +44,6 @@ const FeeJuiceContractArtifact: ContractArtifact = {
44
44
  errorTypes: {
45
45
  '361444214588792908': { error_kind: 'string', string: 'attempt to multiply with overflow' },
46
46
  '1998584279744703196': { error_kind: 'string', string: 'attempt to subtract with overflow' },
47
- '2754040237334517471': { error_kind: 'fmtstring', length: 92, item_types: [] },
48
47
  '6609888949476313245': { error_kind: 'string', string: 'Message not in state' },
49
48
  '11019205087382408538': { error_kind: 'string', string: 'Field failed to decompose into specified 4 limbs' },
50
49
  '12370419938245003393': { error_kind: 'string', string: 'Field failed to decompose into specified 36 limbs' },
@@ -94,121 +93,6 @@ const FeeJuiceContractArtifact: ContractArtifact = {
94
93
  bytecode: Buffer.from([]),
95
94
  debugSymbols: '',
96
95
  },
97
- {
98
- ...{
99
- functionType: FunctionType.UTILITY,
100
- name: 'process_message',
101
- isOnlySelf: false,
102
- isStatic: false,
103
- isInitializer: false,
104
- parameters: [
105
- {
106
- name: 'message_ciphertext',
107
- type: {
108
- kind: 'struct',
109
- fields: [
110
- { name: 'storage', type: { kind: 'array', length: 17, type: { kind: 'field' } } },
111
- { name: 'len', type: { kind: 'integer', sign: 'unsigned', width: 32 } },
112
- ],
113
- path: 'std::collections::bounded_vec::BoundedVec',
114
- },
115
- visibility: 'private',
116
- },
117
- {
118
- name: 'message_context',
119
- type: {
120
- kind: 'struct',
121
- fields: [
122
- { name: 'tx_hash', type: { kind: 'field' } },
123
- {
124
- name: 'unique_note_hashes_in_tx',
125
- type: {
126
- kind: 'struct',
127
- fields: [
128
- { name: 'storage', type: { kind: 'array', length: 64, type: { kind: 'field' } } },
129
- { name: 'len', type: { kind: 'integer', sign: 'unsigned', width: 32 } },
130
- ],
131
- path: 'std::collections::bounded_vec::BoundedVec',
132
- },
133
- },
134
- { name: 'first_nullifier_in_tx', type: { kind: 'field' } },
135
- {
136
- name: 'recipient',
137
- type: {
138
- kind: 'struct',
139
- fields: [{ name: 'inner', type: { kind: 'field' } }],
140
- path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
141
- },
142
- },
143
- ],
144
- path: 'aztec::messages::processing::message_context::MessageContext',
145
- },
146
- visibility: 'private',
147
- },
148
- ],
149
- returnTypes: [],
150
- errorTypes: {
151
- '361444214588792908': { error_kind: 'string', string: 'attempt to multiply with overflow' },
152
- '992401946138144806': { error_kind: 'string', string: 'Attempted to read past end of BoundedVec' },
153
- '1998584279744703196': { error_kind: 'string', string: 'attempt to subtract with overflow' },
154
- '2967937905572420042': {
155
- error_kind: 'fmtstring',
156
- length: 61,
157
- item_types: [{ kind: 'field' }, { kind: 'field' }],
158
- },
159
- '3330370348214585450': {
160
- error_kind: 'fmtstring',
161
- length: 48,
162
- item_types: [{ kind: 'field' }, { kind: 'field' }],
163
- },
164
- '3670003311596808700': {
165
- error_kind: 'fmtstring',
166
- length: 77,
167
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
168
- },
169
- '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
170
- '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
171
- '9791669845391776238': {
172
- error_kind: 'string',
173
- string: '0 has a square root; you cannot claim it is not square',
174
- },
175
- '9885968605480832328': {
176
- error_kind: 'string',
177
- string: 'Attempted to read past the length of a CapsuleArray',
178
- },
179
- '10135509984888824963': { error_kind: 'fmtstring', length: 58, item_types: [{ kind: 'field' }] },
180
- '10791800398362570014': { error_kind: 'string', string: 'extend_from_bounded_vec out of bounds' },
181
- '11021520179822076911': {
182
- error_kind: 'string',
183
- string: 'Attempted to delete past the length of a CapsuleArray',
184
- },
185
- '11692359521570349358': { error_kind: 'fmtstring', length: 40, item_types: [] },
186
- '12327971061804302172': { error_kind: 'fmtstring', length: 98, item_types: [] },
187
- '12469291177396340830': { error_kind: 'string', string: 'call to assert_max_bit_size' },
188
- '12913276134398371456': { error_kind: 'string', string: 'push out of bounds' },
189
- '13557316507370296400': {
190
- error_kind: 'fmtstring',
191
- length: 130,
192
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
193
- },
194
- '14938672389828944159': {
195
- error_kind: 'fmtstring',
196
- length: 146,
197
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
198
- },
199
- '14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
200
- '15764276373176857197': { error_kind: 'string', string: 'Stack too deep' },
201
- '16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
202
- '17531474008201752295': {
203
- error_kind: 'fmtstring',
204
- length: 133,
205
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
206
- },
207
- },
208
- },
209
- bytecode: Buffer.from([]),
210
- debugSymbols: '',
211
- },
212
96
  {
213
97
  ...{
214
98
  functionType: FunctionType.PUBLIC,
@@ -247,77 +131,6 @@ const FeeJuiceContractArtifact: ContractArtifact = {
247
131
  bytecode: Buffer.from([]),
248
132
  debugSymbols: '',
249
133
  },
250
- {
251
- ...{
252
- functionType: FunctionType.UTILITY,
253
- name: 'sync_private_state',
254
- isOnlySelf: false,
255
- isStatic: false,
256
- isInitializer: false,
257
- parameters: [],
258
- returnTypes: [],
259
- errorTypes: {
260
- '361444214588792908': { error_kind: 'string', string: 'attempt to multiply with overflow' },
261
- '992401946138144806': { error_kind: 'string', string: 'Attempted to read past end of BoundedVec' },
262
- '1998584279744703196': { error_kind: 'string', string: 'attempt to subtract with overflow' },
263
- '2967937905572420042': {
264
- error_kind: 'fmtstring',
265
- length: 61,
266
- item_types: [{ kind: 'field' }, { kind: 'field' }],
267
- },
268
- '3330370348214585450': {
269
- error_kind: 'fmtstring',
270
- length: 48,
271
- item_types: [{ kind: 'field' }, { kind: 'field' }],
272
- },
273
- '3670003311596808700': {
274
- error_kind: 'fmtstring',
275
- length: 77,
276
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
277
- },
278
- '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
279
- '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
280
- '9791669845391776238': {
281
- error_kind: 'string',
282
- string: '0 has a square root; you cannot claim it is not square',
283
- },
284
- '9885968605480832328': {
285
- error_kind: 'string',
286
- string: 'Attempted to read past the length of a CapsuleArray',
287
- },
288
- '10135509984888824963': { error_kind: 'fmtstring', length: 58, item_types: [{ kind: 'field' }] },
289
- '10791800398362570014': { error_kind: 'string', string: 'extend_from_bounded_vec out of bounds' },
290
- '11021520179822076911': {
291
- error_kind: 'string',
292
- string: 'Attempted to delete past the length of a CapsuleArray',
293
- },
294
- '11692359521570349358': { error_kind: 'fmtstring', length: 40, item_types: [] },
295
- '12327971061804302172': { error_kind: 'fmtstring', length: 98, item_types: [] },
296
- '12469291177396340830': { error_kind: 'string', string: 'call to assert_max_bit_size' },
297
- '12913276134398371456': { error_kind: 'string', string: 'push out of bounds' },
298
- '13557316507370296400': {
299
- error_kind: 'fmtstring',
300
- length: 130,
301
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
302
- },
303
- '14938672389828944159': {
304
- error_kind: 'fmtstring',
305
- length: 146,
306
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
307
- },
308
- '14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
309
- '15764276373176857197': { error_kind: 'string', string: 'Stack too deep' },
310
- '16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
311
- '17531474008201752295': {
312
- error_kind: 'fmtstring',
313
- length: 133,
314
- item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
315
- },
316
- },
317
- },
318
- bytecode: Buffer.from([]),
319
- debugSymbols: '',
320
- },
321
134
  ],
322
135
  nonDispatchPublicFunctions: [
323
136
  {
@@ -445,22 +258,7 @@ export class FeeJuiceContract extends ContractBase {
445
258
  ) => ContractFunctionInteraction) &
446
259
  Pick<ContractMethod, 'selector'>;
447
260
 
448
- /** process_message(message_ciphertext: struct, message_context: struct) */
449
- process_message: ((
450
- message_ciphertext: FieldLike[],
451
- message_context: {
452
- tx_hash: FieldLike;
453
- unique_note_hashes_in_tx: FieldLike[];
454
- first_nullifier_in_tx: FieldLike;
455
- recipient: AztecAddressLike;
456
- },
457
- ) => ContractFunctionInteraction) &
458
- Pick<ContractMethod, 'selector'>;
459
-
460
261
  /** public_dispatch(selector: field) */
461
262
  public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
462
-
463
- /** sync_private_state() */
464
- sync_private_state: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
465
263
  };
466
264
  }
@@ -160,22 +160,14 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
160
160
  },
161
161
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
162
162
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
163
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
163
164
  '9791669845391776238': {
164
165
  error_kind: 'string',
165
166
  string: '0 has a square root; you cannot claim it is not square',
166
167
  },
167
- '9885968605480832328': {
168
- error_kind: 'string',
169
- string: 'Attempted to read past the length of a CapsuleArray',
170
- },
171
168
  '10135509984888824963': { error_kind: 'fmtstring', length: 58, item_types: [{ kind: 'field' }] },
172
169
  '10791800398362570014': { error_kind: 'string', string: 'extend_from_bounded_vec out of bounds' },
173
- '11021520179822076911': {
174
- error_kind: 'string',
175
- string: 'Attempted to delete past the length of a CapsuleArray',
176
- },
177
170
  '11692359521570349358': { error_kind: 'fmtstring', length: 40, item_types: [] },
178
- '12327971061804302172': { error_kind: 'fmtstring', length: 98, item_types: [] },
179
171
  '12469291177396340830': { error_kind: 'string', string: 'call to assert_max_bit_size' },
180
172
  '12913276134398371456': { error_kind: 'string', string: 'push out of bounds' },
181
173
  '13557316507370296400': {
@@ -204,7 +196,7 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
204
196
  {
205
197
  ...{
206
198
  functionType: FunctionType.UTILITY,
207
- name: 'sync_private_state',
199
+ name: 'sync_state',
208
200
  isOnlySelf: false,
209
201
  isStatic: false,
210
202
  isInitializer: false,
@@ -231,6 +223,7 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
231
223
  },
232
224
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
233
225
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
226
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
234
227
  '9791669845391776238': {
235
228
  error_kind: 'string',
236
229
  string: '0 has a square root; you cannot claim it is not square',
@@ -267,6 +260,7 @@ const MultiCallEntrypointContractArtifact: ContractArtifact = {
267
260
  length: 133,
268
261
  item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
269
262
  },
263
+ '17655676068928457687': { error_kind: 'string', string: 'Reader did not read all data' },
270
264
  },
271
265
  },
272
266
  bytecode: Buffer.from([]),
@@ -332,7 +326,7 @@ export class MultiCallEntrypointContract extends ContractBase {
332
326
  /** public_dispatch(selector: field) */
333
327
  public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
334
328
 
335
- /** sync_private_state() */
336
- sync_private_state: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
329
+ /** sync_state() */
330
+ sync_state: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
337
331
  };
338
332
  }
@@ -93,22 +93,14 @@ 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
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
96
97
  '9791669845391776238': {
97
98
  error_kind: 'string',
98
99
  string: '0 has a square root; you cannot claim it is not square',
99
100
  },
100
- '9885968605480832328': {
101
- error_kind: 'string',
102
- string: 'Attempted to read past the length of a CapsuleArray',
103
- },
104
101
  '10135509984888824963': { error_kind: 'fmtstring', length: 58, item_types: [{ kind: 'field' }] },
105
102
  '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
103
  '11692359521570349358': { error_kind: 'fmtstring', length: 40, item_types: [] },
111
- '12327971061804302172': { error_kind: 'fmtstring', length: 98, item_types: [] },
112
104
  '12469291177396340830': { error_kind: 'string', string: 'call to assert_max_bit_size' },
113
105
  '12913276134398371456': { error_kind: 'string', string: 'push out of bounds' },
114
106
  '13557316507370296400': {
@@ -155,10 +147,8 @@ const PublicChecksContractArtifact: ContractArtifact = {
155
147
  },
156
148
  '12511970388699677811': { error_kind: 'fmtstring', length: 27, item_types: [{ kind: 'field' }] },
157
149
  '13950240626967988787': { error_kind: 'string', string: 'Timestamp mismatch.' },
158
- '14990209321349310352': { error_kind: 'string', string: 'attempt to add with overflow' },
159
150
  '15015303112667403944': { error_kind: 'fmtstring', length: 17, item_types: [] },
160
151
  '15764276373176857197': { error_kind: 'string', string: 'Stack too deep' },
161
- '16431471497789672479': { error_kind: 'string', string: 'Index out of bounds' },
162
152
  },
163
153
  },
164
154
  bytecode: Buffer.from([]),
@@ -167,7 +157,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
167
157
  {
168
158
  ...{
169
159
  functionType: FunctionType.UTILITY,
170
- name: 'sync_private_state',
160
+ name: 'sync_state',
171
161
  isOnlySelf: false,
172
162
  isStatic: false,
173
163
  isInitializer: false,
@@ -194,6 +184,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
194
184
  },
195
185
  '4261968856572588300': { error_kind: 'string', string: 'Value does not fit in field' },
196
186
  '4440399188109668273': { error_kind: 'string', string: 'Input length must be a multiple of 32' },
187
+ '9530675838293881722': { error_kind: 'string', string: 'Writer did not write all data' },
197
188
  '9791669845391776238': {
198
189
  error_kind: 'string',
199
190
  string: '0 has a square root; you cannot claim it is not square',
@@ -230,6 +221,7 @@ const PublicChecksContractArtifact: ContractArtifact = {
230
221
  length: 133,
231
222
  item_types: [{ kind: 'integer', sign: 'unsigned', width: 32 }],
232
223
  },
224
+ '17655676068928457687': { error_kind: 'string', string: 'Reader did not read all data' },
233
225
  },
234
226
  },
235
227
  bytecode: Buffer.from([]),
@@ -318,7 +310,7 @@ export class PublicChecksContract extends ContractBase {
318
310
  /** public_dispatch(selector: field) */
319
311
  public_dispatch: ((selector: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
320
312
 
321
- /** sync_private_state() */
322
- sync_private_state: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
313
+ /** sync_state() */
314
+ sync_state: (() => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
323
315
  };
324
316
  }
@@ -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 './sent_tx.js';
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
+ };
@@ -5,16 +5,18 @@ import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, Funct
5
5
  import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { computeVarArgsHash } from '@aztec/stdlib/hash';
8
- import type { TxProfileResult } from '@aztec/stdlib/tx';
8
+ import type { TxHash, TxProfileResult, TxReceipt } 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
  SimulationReturn,
16
19
  } from '../contract/interaction_options.js';
17
- import type { SentTx } from '../contract/sent_tx.js';
18
20
  import type { Wallet } from '../wallet/index.js';
19
21
 
20
22
  /** Intent with an inner hash */
@@ -286,9 +288,19 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
286
288
  * Overrides the send method, adding the sender of the authwit (authorizer) as from
287
289
  * and preventing misuse
288
290
  * @param options - An optional object containing 'fee' options information
289
- * @returns A SentTx instance for tracking the transaction status and information.
291
+ * @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
290
292
  */
291
- public override send(options: Omit<SendInteractionOptions, 'from'> = {}): SentTx {
293
+ // Overload for when wait is not specified at all - returns TxReceipt
294
+ public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxReceipt>;
295
+ // Generic overload for explicit wait values
296
+ // eslint-disable-next-line jsdoc/require-jsdoc
297
+ public override send<W extends InteractionWaitOptions>(
298
+ options?: Omit<SendInteractionOptions<W>, 'from'>,
299
+ ): Promise<SendReturn<W>>;
300
+ // eslint-disable-next-line jsdoc/require-jsdoc
301
+ public override send(
302
+ options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
303
+ ): Promise<TxReceipt | TxHash> {
292
304
  return super.send({ ...options, from: this.from });
293
305
  }
294
306
 
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';