Conversation
|
|
||
| import { waitForTx } from './node.js'; | ||
|
|
||
| describe('waitForTx', () => { |
There was a problem hiding this comment.
These are ported from the old sent_tx.test.ts
| * @param options - Deployment options (same as send, but wait is always true) | ||
| * @returns The deployed contract instance | ||
| */ | ||
| public async deployed(options: DeployOptions): Promise<TContract> { |
There was a problem hiding this comment.
I finally understand what deployed is 😆 ! Suggest to rename:
| public async deployed(options: DeployOptions): Promise<TContract> { | |
| public async deployedInstance(options: DeployOptions): Promise<TContract> { |
Ack it's a bit more verbose but this doesn't seem something that people need to write all the time so I think the declarativeness is worth the mild extra typing
There was a problem hiding this comment.
I'm leaning towards just killing it. It does not seem like a lot of gain when you can do:
const { contract } = await MyContract.deploy(wallet).send({ from: address });There was a problem hiding this comment.
oh I wholeheartedly agree 💯
There was a problem hiding this comment.
Found an alternative approach:
const contract = await MyContract.deploy(wallet).send({ from: address });
const txHash = await MyContract.deploy(wallet).send({ from: address, wait: NO_WAIT });
const receipt = await MyContract.deploy(wallet).send({ from: address, wait: { returnReceipt: true }});WDYT?
| /** | ||
| * Type for wait options in interactions - can be false (no wait), WaitOpts (custom wait), or undefined (default wait) | ||
| */ | ||
| export type InteractionWaitOptions = false | WaitOpts | undefined; |
There was a problem hiding this comment.
this type is what I would consider rewriting as a tagged union
There was a problem hiding this comment.
WDYT about replacing the false here with a const expression?
type NO_WAIT = "NO_WAIT";That way we don't need the builder pattern and the thing wouldn't be falsy
There was a problem hiding this comment.
better than false definitely!
There was a problem hiding this comment.
another issue with false is it's very natural for someone approaching this API to go like "wait, sure yeah:" => wait: true
There was a problem hiding this comment.
This has been implemented as a symbol (which turns to a boolean during serialization and then back)
branded string
mverzilli
left a comment
There was a problem hiding this comment.
Colossal work! Sorry for the spam of API opinions, none of those should block this and in any case they can feed into future conversations
Closes: https://linear.app/aztec-labs/issue/F-112/reevaluate-basecontractinteractionsend Closes: #13895 This PR removes the infamous `SendTx` class and its derivations, avoiding the confusing syntax described in #13895 of ```typescript const tx = contract.methods.fn().send(); // tx is not actually sent here console.log(await tx.getTxHash()); // tx is sent now? I just wanted the txhash! await tx.wait(); // tx is confirmed ``` `sendTx` now allows the consumer to specify wait options. Furthermore, we leverage typescript's type system to dynamically change the return type depending on the input options: ```typescript const receipt = await contract.methods.fn.send({ from: address }); // Result is TxReceipt const txHash = await contract.methods.fn.send({ from: address, wait: false }); // Result is TxHash ``` A utility called `waitForTx` has been introduced so things like these are possible: ```typescript const txHash = await contract.methods.fn.send({ from: address, wait: false }); await waitForTx(aztecNode, txHash, { timeout: 300 }); ``` All of this allows us to make the `Wallet` interface leaner too, so `getTxReceipt` has been removed from it. Co-authored-by: thunkar <gregojquiros@gmail.com>
80539fa to
c7ef263
Compare
Flakey Tests🤖 says: This CI run detected 2 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
Somehow got past CI: #19778 Co-authored-by: thunkar <gregojquiros@gmail.com>
Migration notes for #19778 Co-authored-by: Gregorio Juliana <gregojquiros@gmail.com> Co-authored-by: thunkar <gregojquiros@gmail.com>
Migration notes for #19778
Updates documentation to reflect changes from PR #19778: - Remove .wait() calls - send() now returns receipt directly - Remove .deployed() calls - send() returns contract for deployments - Add NO_WAIT option and waitForTx utility examples - Update getTxReceipt to use node instead of wallet Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
## Summary Comprehensive documentation updates for aztec.js guides and related developer documentation. ### API Updates (from #19778) - Remove `.wait()` calls - `send()` now returns receipt directly - Remove `.deployed()` calls - `send()` returns contract for deployments - Add `NO_WAIT` option and `waitForTx` utility examples - Update `getTxReceipt` to use node instead of wallet ### Type-Checked Examples - Add runnable TypeScript examples in `docs/examples/ts/` for: - `aztecjs_connection` - Connection and account creation examples - `aztecjs_advanced` - `skip_initialization` and `poll_for_events` examples - `aztecjs_authwit` - Authorization witness examples - `aztecjs_testing` - Testing examples - Examples are validated with `config.yaml` files for CI integration ### Documentation Improvements - Add note explaining `TestWallet` vs production wallets in account creation guide - Clarify undeclared variables in code examples - Format code blocks for consistency - Update `devnetTag` version reference ### Bug Fixes - Update installation commands to use `-L` flag for curl (follows redirects) **Files updated:** - `how_to_send_transaction.md` - `how_to_deploy_contract.md` - `how_to_create_account.md` - `how_to_pay_fees.md` - `how_to_use_authwit.md` - `how_to_test.md` - `how_to_read_data.md` - `how_to_connect_to_local_network.md` - Various versioned docs with curl -L fix ## Test plan - [ ] Verify documentation builds successfully - [ ] Review code examples for accuracy against new API - [ ] Run type-checked examples to verify they compile 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Josh Crites <jc@joshcrites.com>
## Summary Comprehensive documentation updates for aztec.js guides and related developer documentation. ### API Updates (from #19778) - Remove `.wait()` calls - `send()` now returns receipt directly - Remove `.deployed()` calls - `send()` returns contract for deployments - Add `NO_WAIT` option and `waitForTx` utility examples - Update `getTxReceipt` to use node instead of wallet ### Type-Checked Examples - Add runnable TypeScript examples in `docs/examples/ts/` for: - `aztecjs_connection` - Connection and account creation examples - `aztecjs_advanced` - `skip_initialization` and `poll_for_events` examples - `aztecjs_authwit` - Authorization witness examples - `aztecjs_testing` - Testing examples - Examples are validated with `config.yaml` files for CI integration ### Documentation Improvements - Add note explaining `TestWallet` vs production wallets in account creation guide - Clarify undeclared variables in code examples - Format code blocks for consistency - Update `devnetTag` version reference ### Bug Fixes - Update installation commands to use `-L` flag for curl (follows redirects) **Files updated:** - `how_to_send_transaction.md` - `how_to_deploy_contract.md` - `how_to_create_account.md` - `how_to_pay_fees.md` - `how_to_use_authwit.md` - `how_to_test.md` - `how_to_read_data.md` - `how_to_connect_to_local_network.md` - Various versioned docs with curl -L fix ## Test plan - [ ] Verify documentation builds successfully - [ ] Review code examples for accuracy against new API - [ ] Run type-checked examples to verify they compile 🤖 Generated with [Claude Code](https://claude.ai/code)
## Summary Comprehensive documentation updates for aztec.js guides and related developer documentation. ### API Updates (from #19778) - Remove `.wait()` calls - `send()` now returns receipt directly - Remove `.deployed()` calls - `send()` returns contract for deployments - Add `NO_WAIT` option and `waitForTx` utility examples - Update `getTxReceipt` to use node instead of wallet ### Type-Checked Examples - Add runnable TypeScript examples in `docs/examples/ts/` for: - `aztecjs_connection` - Connection and account creation examples - `aztecjs_advanced` - `skip_initialization` and `poll_for_events` examples - `aztecjs_authwit` - Authorization witness examples - `aztecjs_testing` - Testing examples - Examples are validated with `config.yaml` files for CI integration ### Documentation Improvements - Add note explaining `TestWallet` vs production wallets in account creation guide - Clarify undeclared variables in code examples - Format code blocks for consistency - Update `devnetTag` version reference ### Bug Fixes - Update installation commands to use `-L` flag for curl (follows redirects) **Files updated:** - `how_to_send_transaction.md` - `how_to_deploy_contract.md` - `how_to_create_account.md` - `how_to_pay_fees.md` - `how_to_use_authwit.md` - `how_to_test.md` - `how_to_read_data.md` - `how_to_connect_to_local_network.md` - Various versioned docs with curl -L fix ## Test plan - [ ] Verify documentation builds successfully - [ ] Review code examples for accuracy against new API - [ ] Run type-checked examples to verify they compile 🤖 Generated with [Claude Code](https://claude.ai/code)
Closes: https://linear.app/aztec-labs/issue/F-112/reevaluate-basecontractinteractionsend
Closes: #13895
This PR removes the infamous
SendTxclass and its derivations, avoiding the confusing syntax described in #13895 ofsendTxnow allows the consumer to specify wait options. Furthermore, we leverage typescript's type system to dynamically change the return type depending on the input options:A utility called
waitForTxhas been introduced so things like these are possible:All of this allows us to make the
Walletinterface leaner too, sogetTxReceipthas been removed from it.