Skip to content

Commit fce6717

Browse files
committed
cat21-mint: refactor onto Cat21MintOrchestrator
The fat RxJS pipelines that lived in this component (selectedFeeRate$, paymentOutputsForCurrentWallet$, paymentOutputs$ + its 2-pass simulation logic) now live in the SDK's Cat21MintOrchestrator, consumed identically by cat21.space when phase C lands. Component shrinks from 265 lines of orchestration logic to a thin form + view layer: - Inject Cat21MintOrchestrator alongside the existing WalletService / Cat21ApiService. - paymentOutputs$ becomes a derived map of orchestrator.simulations$: filter insufficient rows, sort by UTXO value desc, cap at 10 for the expert panel. Same surface the template already bound. - selectedPaymentOutput stays as a component field for template compatibility but is two-way-bound to orchestrator.selectedUtxo: - paymentOutputs$ tap auto-syncs on every fresh simulation list (largest viable entry by default, or keep the user's pick if it's still viable). - selectPaymentOutput(row) handler updates both sides when the user clicks "Use this UTXO". - mintCat21() delegates to orchestrator.mint() — the orchestrator recomputes the precise fee from vsize × feeRate at call time and dispatches to the right WalletSigner. - Component-level booleans (utxoLoading, utxoError, mintCat21Loading, mintCat21Success, mintCat21Error) become read-only computed signals projecting orchestrator.state() / errorMessage() / successTxId(). Same template-facing names, same shapes; template references update to `name()` invocations + `*ngIf="x() as alias"` patterns for the two places that used optional chaining on the old field shape. ngOnInit + the form's feeRate valueChanges subscription still own the policy bits that don't belong in the SDK (minRequiredFee validator, fastestFee default-pick, the disable-min-fee-check escape hatch). AOT build clean; the bundle is unchanged in size (orchestrator was already included by the SDK bump; this commit just reorganises the component code).
1 parent a155af0 commit fce6717

2 files changed

Lines changed: 140 additions & 217 deletions

File tree

frontend/src/app/components/_ordpool/cat21-mint/cat21-mint.component.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h2 class="mt-2 mb-4">Mint a CAT-21 Ordinal</h2>
8080
</div>
8181
</div>
8282

83-
<div class="p-2 mt-4" *ngIf="(recommendedFees$ | async) && !selectedPaymentOutput && !utxoLoading">
83+
<div class="p-2 mt-4" *ngIf="(recommendedFees$ | async) && !selectedPaymentOutput && !utxoLoading()">
8484
We are sorry, but we could not find find enough funds in your payment address! 😿<br>
8585
No UTXO has enough value to execute a transaction at the current fees.
8686
We recommend sending at least
@@ -102,7 +102,7 @@ <h2 class="mt-2 mb-4">Mint a CAT-21 Ordinal</h2>
102102
This should be enough to mint <strong class="bitcoin">multiple</strong> CAT-21 ordinals. 😻😻😻
103103
</div>
104104

105-
<div *ngIf="!utxoLoading && !utxoError && (paymentOutputs$ | async)?.length">
105+
<div *ngIf="!utxoLoading() && !utxoError() && (paymentOutputs$ | async)?.length">
106106

107107
<details>
108108
<summary>Show Expert Settings</summary>
@@ -123,7 +123,7 @@ <h2 class="mt-2 mb-4">Mint a CAT-21 Ordinal</h2>
123123
[ngClass]="{ selected: x === this.selectedPaymentOutput }">
124124

125125
<button *ngIf="x !== this.selectedPaymentOutput" class="btn btn-primary float-end text-white mt-2"
126-
(click)="selectedPaymentOutput = x" type="button">
126+
(click)="selectPaymentOutput(x)" type="button">
127127
Use this UTXO
128128
</button>
129129

@@ -166,48 +166,48 @@ <h2 class="mt-2 mb-4">Mint a CAT-21 Ordinal</h2>
166166
</div>
167167
<div class="text-center mt-4">
168168

169-
<button type="submit" *ngIf="!utxoLoading && !mintCat21Success" [disabled]="form.invalid || !selectedPaymentOutput"
169+
<button type="submit" *ngIf="!utxoLoading() && !mintCat21Success()" [disabled]="form.invalid || !selectedPaymentOutput"
170170
class="btn btn-primary mt-4 mb-4 text-white">
171171

172-
<ng-container *ngIf="!mintCat21Loading">
172+
<ng-container *ngIf="!mintCat21Loading()">
173173
<img src="/resources/cat21-small-logo.svg" style="margin-top: -4px; margin-right: 6px"
174174
title="Mint a CAT-21 ordinal" height="30"> Mint my cat
175175
</ng-container>
176176

177-
<ng-container *ngIf="mintCat21Loading">
177+
<ng-container *ngIf="mintCat21Loading()">
178178
<i class="spinner-border spinner-border-sm text-light"></i> Minting your cat
179179
</ng-container>
180180

181181

182182
</button>
183183

184-
<a href="javascript:location.reload()" *ngIf="mintCat21Success" class="btn btn-primary mt-4 mb-4 text-white">
184+
<a href="javascript:location.reload()" *ngIf="mintCat21Success()" class="btn btn-primary mt-4 mb-4 text-white">
185185
<img src="/resources/cat21-small-logo.svg" style="margin-top: -4px; margin-right: 6px" title="Mint a CAT-21 ordinal" height="30"> Mint another cat!
186186
</a>
187187

188-
<button type="submit" disabled class="btn btn-primary mt-4 mb-4 text-white" *ngIf="utxoLoading">
188+
<button type="submit" disabled class="btn btn-primary mt-4 mb-4 text-white" *ngIf="utxoLoading()">
189189
<i class="spinner-border spinner-border-sm text-light"></i>
190190
Scanning your payments address
191191
</button>
192192

193193
</div>
194194
</form>
195195

196-
<div class="alert alert-success" *ngIf="mintCat21Success">
196+
<div class="alert alert-success" *ngIf="mintCat21Success() as success">
197197
✅&nbsp; Your CAT-21 transaction has now been submitted to the mempool.<br>
198-
<ng-container *ngIf="mintCat21Success?.txId">
198+
<ng-container *ngIf="success.txId">
199199
You can track the progress
200200
<a class="alert-link text-decoration-underline"
201-
[routerLink]="['/tx/' | relativeUrl, mintCat21Success.txId]">here</a>.
201+
[routerLink]="['/tx/' | relativeUrl, success.txId]">here</a>.
202202
</ng-container>
203203
</div>
204204

205-
<div class="alert alert-danger" *ngIf="mintCat21Error">
206-
❌&nbsp; {{ mintCat21Error }}
205+
<div class="alert alert-danger" *ngIf="mintCat21Error() as err">
206+
❌&nbsp; {{ err }}
207207
</div>
208208

209-
<div class="alert alert-danger" *ngIf="utxoError">
210-
❌&nbsp; {{ utxoError }}
209+
<div class="alert alert-danger" *ngIf="utxoError() as err">
210+
❌&nbsp; {{ err }}
211211
</div>
212212

213213
<div class="alert alert-danger" *ngIf="checkerError">

0 commit comments

Comments
 (0)