Follow-up from PR #41.
Context
PR #41 migrated cbtc-lib off the deprecated submit-and-wait-for-transaction-tree JSON Ledger API endpoint. As part of preserving identical behavior, two flows still re-fetch from active contracts after submit:
src/mint_redeem/mint.rs:194-211 — create_deposit_account calls list_deposit_accounts after submit.
src/mint_redeem/redeem.rs:222-239 — create_withdraw_account calls list_withdraw_accounts after submit.
This re-fetch was originally there to populate the canonical struct (via *Account::from_active_contract). The migration's updated comments correctly note that the flat submit response under verbose=true already carries createArgument and createdEventBlob, so the re-fetch is no longer strictly necessary.
GitHub Copilot raised this during PR #41 review: #41 (comment)
Proposal
Apply the pattern already used by credentials.rs:425-447 and redeem.rs:475-498 (the submit_withdraw flow):
let created_event_value = &created_event["value"];
let active_contract = JsActiveContract {
created_event: Box::new(ledger::models::CreatedEvent {
contract_id: created_event_value["contractId"].as_str().unwrap_or("").to_string(),
template_id: template_id.to_string(),
create_argument: Some(Some(created_event_value["createArgument"].clone())),
created_event_blob: created_event_value["createdEventBlob"].as_str().unwrap_or("").to_string(),
..Default::default()
}),
reassignment_counter: 0,
synchronizer_id: String::new(),
};
return DepositAccount::from_active_contract(&active_contract);
…replacing the list_deposit_accounts / list_withdraw_accounts round-trip.
Benefits
- Shaves one network round-trip per mint and redeem-create flow.
- Brings these flows into structural parity with the credentials and
submit_withdraw flows.
Risks / verification
- Verify
list_deposit_accounts / list_withdraw_accounts aren't doing anything else load-bearing (e.g., waiting for indexing) before removing the call.
- The error paths change slightly: a missing
createdEventBlob in the submit response would now produce an empty-string blob instead of an error from the list-call. Worth confirming this is fine.
- Integration test (
examples/integration_test.rs) covers both flows end-to-end.
Affected code
src/mint_redeem/mint.rs — create_deposit_account
src/mint_redeem/redeem.rs — create_withdraw_account
Follow-up from PR #41.
Context
PR #41 migrated cbtc-lib off the deprecated
submit-and-wait-for-transaction-treeJSON Ledger API endpoint. As part of preserving identical behavior, two flows still re-fetch from active contracts after submit:src/mint_redeem/mint.rs:194-211—create_deposit_accountcallslist_deposit_accountsafter submit.src/mint_redeem/redeem.rs:222-239—create_withdraw_accountcallslist_withdraw_accountsafter submit.This re-fetch was originally there to populate the canonical struct (via
*Account::from_active_contract). The migration's updated comments correctly note that the flat submit response underverbose=truealready carriescreateArgumentandcreatedEventBlob, so the re-fetch is no longer strictly necessary.GitHub Copilot raised this during PR #41 review: #41 (comment)
Proposal
Apply the pattern already used by
credentials.rs:425-447andredeem.rs:475-498(thesubmit_withdrawflow):…replacing the
list_deposit_accounts/list_withdraw_accountsround-trip.Benefits
submit_withdrawflows.Risks / verification
list_deposit_accounts/list_withdraw_accountsaren't doing anything else load-bearing (e.g., waiting for indexing) before removing the call.createdEventBlobin the submit response would now produce an empty-string blob instead of an error from the list-call. Worth confirming this is fine.examples/integration_test.rs) covers both flows end-to-end.Affected code
src/mint_redeem/mint.rs—create_deposit_accountsrc/mint_redeem/redeem.rs—create_withdraw_account