@hsuite/native-connect-types 1.0.0

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 (87) hide show
  1. package/README.md +50 -0
  2. package/dist/address-avatar.d.ts +67 -0
  3. package/dist/address-avatar.d.ts.map +1 -0
  4. package/dist/address-avatar.js +130 -0
  5. package/dist/address-avatar.js.map +1 -0
  6. package/dist/addressbook.d.ts +289 -0
  7. package/dist/addressbook.d.ts.map +1 -0
  8. package/dist/addressbook.js +82 -0
  9. package/dist/addressbook.js.map +1 -0
  10. package/dist/enrichment.d.ts +88 -0
  11. package/dist/enrichment.d.ts.map +1 -0
  12. package/dist/enrichment.js +47 -0
  13. package/dist/enrichment.js.map +1 -0
  14. package/dist/hedera-system-accounts.d.ts +49 -0
  15. package/dist/hedera-system-accounts.d.ts.map +1 -0
  16. package/dist/hedera-system-accounts.js +56 -0
  17. package/dist/hedera-system-accounts.js.map +1 -0
  18. package/dist/identity.d.ts +94 -0
  19. package/dist/identity.d.ts.map +1 -0
  20. package/dist/identity.js +190 -0
  21. package/dist/identity.js.map +1 -0
  22. package/dist/index.d.ts +43 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +52 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/ledger.d.ts +848 -0
  27. package/dist/ledger.d.ts.map +1 -0
  28. package/dist/ledger.js +152 -0
  29. package/dist/ledger.js.map +1 -0
  30. package/dist/messages.d.ts +726 -0
  31. package/dist/messages.d.ts.map +1 -0
  32. package/dist/messages.js +252 -0
  33. package/dist/messages.js.map +1 -0
  34. package/dist/multisig-account.d.ts +419 -0
  35. package/dist/multisig-account.d.ts.map +1 -0
  36. package/dist/multisig-account.js +201 -0
  37. package/dist/multisig-account.js.map +1 -0
  38. package/dist/private-key-export.d.ts +112 -0
  39. package/dist/private-key-export.d.ts.map +1 -0
  40. package/dist/private-key-export.js +11 -0
  41. package/dist/private-key-export.js.map +1 -0
  42. package/dist/rpc.d.ts +872 -0
  43. package/dist/rpc.d.ts.map +1 -0
  44. package/dist/rpc.js +143 -0
  45. package/dist/rpc.js.map +1 -0
  46. package/dist/transaction-approval.d.ts +895 -0
  47. package/dist/transaction-approval.d.ts.map +1 -0
  48. package/dist/transaction-approval.js +11 -0
  49. package/dist/transaction-approval.js.map +1 -0
  50. package/dist/transaction-parser.d.ts +93 -0
  51. package/dist/transaction-parser.d.ts.map +1 -0
  52. package/dist/transaction-parser.js +11 -0
  53. package/dist/transaction-parser.js.map +1 -0
  54. package/dist/vault.d.ts +673 -0
  55. package/dist/vault.d.ts.map +1 -0
  56. package/dist/vault.js +188 -0
  57. package/dist/vault.js.map +1 -0
  58. package/dist/widget.types.d.ts +323 -0
  59. package/dist/widget.types.d.ts.map +1 -0
  60. package/dist/widget.types.js +140 -0
  61. package/dist/widget.types.js.map +1 -0
  62. package/package.json +43 -0
  63. package/src/address-avatar.ts +181 -0
  64. package/src/addressbook.spec.ts +220 -0
  65. package/src/addressbook.ts +115 -0
  66. package/src/enrichment.ts +97 -0
  67. package/src/hedera-system-accounts.ts +60 -0
  68. package/src/identity.spec.ts +243 -0
  69. package/src/identity.ts +244 -0
  70. package/src/index.ts +197 -0
  71. package/src/ledger.spec.ts +366 -0
  72. package/src/ledger.ts +567 -0
  73. package/src/messages.ts +381 -0
  74. package/src/multisig-account.spec.ts +362 -0
  75. package/src/multisig-account.ts +310 -0
  76. package/src/private-key-export.ts +117 -0
  77. package/src/rpc.spec.ts +396 -0
  78. package/src/rpc.ts +257 -0
  79. package/src/transaction-approval.ts +1033 -0
  80. package/src/transaction-parser.ts +98 -0
  81. package/src/vault.spec.ts +268 -0
  82. package/src/vault.ts +256 -0
  83. package/src/widget.types.spec.ts +337 -0
  84. package/src/widget.types.ts +501 -0
  85. package/tsconfig.build.json +17 -0
  86. package/tsconfig.json +11 -0
  87. package/vitest.config.ts +36 -0
@@ -0,0 +1,895 @@
1
+ /**
2
+ * HSuite Native Connect
3
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4
+ *
5
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
6
+ *
7
+ * This file is part of HSuite Native Connect. For commercial licensing,
8
+ * visit https://hsuite.finance/licensing
9
+ */
10
+ /**
11
+ * @file Transaction approval types for secure user consent workflows.
12
+ *
13
+ * This module defines the comprehensive type system for transaction approval,
14
+ * supporting both Hedera and XRPL transactions with full transaction parsing,
15
+ * risk assessment, and fee estimation.
16
+ *
17
+ * Key Types:
18
+ * - {@link HederaTransactionData} - All Hedera transaction types
19
+ * - {@link XrplTransactionData} - All XRPL transaction types
20
+ * - {@link TransactionApprovalContext} - Complete approval request context
21
+ * - {@link RiskAssessment} - Transaction risk analysis
22
+ *
23
+ * Approval Flow:
24
+ * 1. dApp sends sign/signAndSubmit request
25
+ * 2. Wallet parses transaction into {@link TransactionData}
26
+ * 3. Risk assessment generates {@link RiskFactor} list
27
+ * 4. UI displays {@link TransactionApprovalContext}
28
+ * 5. User approves/rejects via {@link TransactionApprovalEvent}
29
+ *
30
+ * @module types/transaction-approval
31
+ *
32
+ * Type definitions for transaction approval system supporting Hedera and XRPL transactions.
33
+ * Used by the wallet UI to display transaction details and collect user approval.
34
+ */
35
+ /**
36
+ * @description A single display-ready field produced by a ledger parser.
37
+ *
38
+ * Used by the approval modal's "Additional Details" card and the inner-tx
39
+ * recursive renderers (scheduled tx, batch contents). Each field is a flat
40
+ * label/value pair; `highlight` boosts visual prominence (primary parameters
41
+ * like Token Name, Mint Amount, etc.).
42
+ */
43
+ export interface ParsedTransactionField {
44
+ /** Display label (e.g., "Token Name", "From Account"). */
45
+ label: string;
46
+ /** Display value (already formatted by the parser; pipes may further enrich). */
47
+ value: string;
48
+ /** When true, render with accent colour. Used for primary parameters. */
49
+ highlight?: boolean;
50
+ }
51
+ /**
52
+ * @description Canonical kind discriminator for parsed transactions.
53
+ *
54
+ * Used by the approval modal (and future body resolver) to dispatch on
55
+ * transaction type without having to defensively match against the
56
+ * parser's human-readable label and its canonical camelCase form.
57
+ *
58
+ * Naming rules:
59
+ * - **Always ledger-prefixed**: `'hedera.*'` or future `'xrpl.*'`.
60
+ * Plain `'transfer.hbar'` is invalid.
61
+ * - **Lowercase, dotted**: words are joined with `.` (not camelCase).
62
+ * - **2–3 segments**: `'hedera.batch'` (2) or `'hedera.token.burn'`
63
+ * (3). The second segment is the SDK class family; the third is the
64
+ * variant when it matters.
65
+ */
66
+ export type TxKind = 'hedera.transfer.hbar' | 'hedera.transfer.token' | 'hedera.transfer.nft' | 'hedera.token.associate' | 'hedera.token.dissociate' | 'hedera.token.create' | 'hedera.token.mint' | 'hedera.token.burn' | 'hedera.token.update' | 'hedera.token.delete' | 'hedera.token.wipe' | 'hedera.token.freeze' | 'hedera.token.unfreeze' | 'hedera.token.pause' | 'hedera.token.unpause' | 'hedera.token.grantkyc' | 'hedera.token.revokekyc' | 'hedera.topic.create' | 'hedera.topic.update' | 'hedera.topic.delete' | 'hedera.topic.submit' | 'hedera.account.create' | 'hedera.account.update' | 'hedera.account.delete' | 'hedera.contract.call' | 'hedera.contract.create' | 'hedera.schedule.create' | 'hedera.schedule.sign' | 'hedera.schedule.delete' | 'hedera.batch' | 'hedera.message.sign' | 'hedera.file.create' | 'hedera.file.update' | 'hedera.file.delete' | 'hedera.file.append' | 'hedera.parse-error';
67
+ /**
68
+ * @description Base transaction data for approval.
69
+ *
70
+ * The mandatory shape every ledger parser emits, plus the optional fields the
71
+ * approval modal renders directly. Parsers spread their output into the
72
+ * `transactionData` slot of {@link TransactionApprovalContext}; the modal reads
73
+ * the optional display fields below to populate its UI without needing
74
+ * `unknown` casts.
75
+ *
76
+ * Ledger-specific subtypes ({@link HederaTransactionData}, {@link XrplTransactionData})
77
+ * add typed fields per transaction kind on top of this shape.
78
+ */
79
+ export interface BaseTransactionData {
80
+ /** Transaction type identifier */
81
+ type: string;
82
+ /**
83
+ * Canonical kind discriminator — stable, ledger-prefixed, lowercase
84
+ * dotted notation that the modal (and future body resolver) uses to
85
+ * dispatch on. Independent of the parser's human-readable `type`
86
+ * label which is locked into the existing wire / TOTP mapper /
87
+ * Storybook contracts.
88
+ *
89
+ * Format: `<ledger>.<family>.<variant>` (e.g.,
90
+ * `'hedera.token.burn'`, `'hedera.account.update'`).
91
+ * Two-segment kinds (`'hedera.batch'`) are allowed when there is no
92
+ * variant.
93
+ *
94
+ * Optional because parsers populate it incrementally — readers MUST
95
+ * fall back to `type`-string matching when `parsedKind` is absent so
96
+ * older wallet builds keep working with newly-parsed payloads.
97
+ */
98
+ parsedKind?: TxKind;
99
+ /** Transaction creation timestamp (ms since epoch) */
100
+ timestamp: number;
101
+ /** Optional memo/note attached to transaction */
102
+ memo?: string;
103
+ /** Additional metadata for custom fields */
104
+ metadata?: Record<string, unknown>;
105
+ /**
106
+ * Human-readable description sentence for the transaction.
107
+ * Surfaced in the modal under the type heading.
108
+ */
109
+ description?: string;
110
+ /**
111
+ * Structured list of {label, value} rows shown in the "Additional Details"
112
+ * card. Each parser decides the granularity; the modal renders them
113
+ * verbatim with optional accent for `highlight`.
114
+ */
115
+ fields?: ParsedTransactionField[];
116
+ /**
117
+ * Parser's estimate of the network fee, as a display string (e.g., "0.05 ℏ").
118
+ * Authoritative source remains the network fee schedule; this is a hint.
119
+ */
120
+ estimatedFee?: string;
121
+ /**
122
+ * Risk taxonomy assigned by the parser. The modal also consumes the
123
+ * separate {@link RiskAssessment} on {@link TransactionApprovalContext}
124
+ * when present; this property is a fallback for callers that only have
125
+ * the parser output.
126
+ */
127
+ riskLevel?: 'low' | 'medium' | 'high';
128
+ /**
129
+ * Parser-emitted reasons that justify the {@link riskLevel}. Free-form
130
+ * strings; the modal renders them as a bullet list.
131
+ */
132
+ riskFactors?: string[];
133
+ }
134
+ /**
135
+ * @description Hedera transaction data structure
136
+ * Comprehensive type definition supporting all major Hedera transaction types.
137
+ */
138
+ export interface HederaTransactionData extends BaseTransactionData {
139
+ /** Hedera transaction type */
140
+ type: 'CryptoTransfer' | 'TokenAssociate' | 'TokenDissociate' | 'TokenMint' | 'TokenBurn' | 'ScheduleCreate' | 'AccountCreate' | 'ContractCall' | 'AccountUpdate' | 'TokenCreate' | 'TokenUpdate' | 'TokenFreeze' | 'TokenUnfreeze' | 'TokenWipe' | 'TokenGrantKyc' | 'TokenRevokeKyc' | 'FileCreate' | 'FileAppend' | 'FileUpdate' | 'SignMessage' | 'BatchTransaction';
141
+ /** HBAR transfers in tinybars */
142
+ hbarTransfers?: Array<{
143
+ accountId: string;
144
+ amount: number;
145
+ }>;
146
+ /** Fungible token transfers */
147
+ tokenTransfers?: Array<{
148
+ tokenId: string;
149
+ accountId: string;
150
+ amount: number;
151
+ decimals?: number;
152
+ symbol?: string;
153
+ name?: string;
154
+ }>;
155
+ /** NFT transfers */
156
+ nftTransfers?: Array<{
157
+ tokenId: string;
158
+ sender: string;
159
+ receiver: string;
160
+ serialNumber: number;
161
+ metadata?: string;
162
+ }>;
163
+ /** Token IDs to associate/dissociate */
164
+ tokenIds?: string[];
165
+ /** Token ID for mint/burn operations */
166
+ tokenId?: string;
167
+ /** Amount to mint/burn (for fungible tokens) */
168
+ amount?: number;
169
+ /** Serial numbers (for NFT burn) */
170
+ serials?: number[];
171
+ /** Metadata list (for NFT mint) */
172
+ metadataList?: string[];
173
+ /** Token name */
174
+ tokenName?: string;
175
+ /** Token symbol */
176
+ tokenSymbol?: string;
177
+ /** Token decimals */
178
+ decimals?: number;
179
+ /** Initial supply */
180
+ initialSupply?: number;
181
+ /** Treasury account ID */
182
+ treasuryAccountId?: string;
183
+ /** The transaction to be scheduled */
184
+ scheduledTransaction?: BaseTransactionData;
185
+ /** Scheduled execution time */
186
+ executionTime?: number;
187
+ /** Whether admin key is required */
188
+ adminKeyRequired?: boolean;
189
+ /**
190
+ * HWA-22: when true, the schedule defers execution until
191
+ * `expirationTime` even after the signature threshold is reached;
192
+ * when false (default) the schedule executes immediately on
193
+ * threshold. The approval flow surfaces this through a parser
194
+ * `Execution Mode` field — an explicit type slot exists so callers
195
+ * that consume `BaseTransactionData` directly can check the flag
196
+ * without inspecting `fields[]`.
197
+ */
198
+ waitForExpiry?: boolean;
199
+ /** Initial balance in tinybars */
200
+ initialBalance?: number;
201
+ /** Public key for the new account */
202
+ publicKey?: string;
203
+ /** Max automatic token associations */
204
+ maxAutomaticTokenAssociations?: number;
205
+ /** Contract ID to call */
206
+ contractId?: string;
207
+ /** Gas limit */
208
+ gas?: number;
209
+ /** Function parameters (encoded) */
210
+ functionParameters?: string;
211
+ /** Amount of HBAR to send with call */
212
+ payableAmount?: number;
213
+ /**
214
+ * Structured transfer summary for the hero card on CryptoTransfer kinds.
215
+ * Aggregates HBAR/token/NFT transfers into a single tuple the modal can
216
+ * destructure without re-scanning `fields[]` with regex.
217
+ *
218
+ * Token entries can carry optional metadata (`decimals`, `symbol`, `name`)
219
+ * populated by `TokenMetadataCacheService` post-parse and before the modal
220
+ * opens. The parser leaves these undefined; the wallet's approval
221
+ * orchestrator enriches them so the hero renders "1.000000 USDC" instead
222
+ * of "1000000 0.0.456858".
223
+ */
224
+ transferSummary?: {
225
+ /** HBAR transfers (signed tinybar amounts; negative = debit, positive = credit). */
226
+ entries: Array<{
227
+ accountId: string;
228
+ amount: number;
229
+ }>;
230
+ /**
231
+ * Fungible-token transfers (signed raw amounts).
232
+ * Metadata fields (`decimals`, `symbol`, `name`) are optional — empty in
233
+ * the parser output, filled in by the wallet enricher when available.
234
+ */
235
+ tokenEntries: Array<{
236
+ tokenId: string;
237
+ accountId: string;
238
+ amount: number;
239
+ /** From token metadata (Mirror Node). Renders raw quantity when absent. */
240
+ decimals?: number;
241
+ /** From token metadata. Falls back to `tokenId` when absent. */
242
+ symbol?: string;
243
+ /** From token metadata. Optional display name (e.g., "USD Coin"). */
244
+ name?: string;
245
+ }>;
246
+ /**
247
+ * NFT serial transfers.
248
+ * Metadata fields (`name`, `thumbnailUrl`, `collectionName`) are
249
+ * optional — empty in the parser output, filled in by the wallet
250
+ * enricher (`NftMetadataCacheService`) when available. The hero card
251
+ * shows a thumbnail when `thumbnailUrl` is set; otherwise falls back
252
+ * to "#{serial}" + tokenId.
253
+ */
254
+ nftEntries: Array<{
255
+ tokenId: string;
256
+ sender: string;
257
+ receiver: string;
258
+ serial: number;
259
+ /** Per-serial display name (e.g., "Bored Ape #4521"). */
260
+ name?: string;
261
+ /** HTTP-resolvable thumbnail URL (IPFS converted via gateway). */
262
+ thumbnailUrl?: string;
263
+ /** Collection display name (e.g., "Bored Apes Yacht Club"). */
264
+ collectionName?: string;
265
+ }>;
266
+ };
267
+ /**
268
+ * Recursively parsed inner transaction for ScheduleCreate.
269
+ *
270
+ * Carries the same shape as the outer payload so the modal can render the
271
+ * scheduled inner with the same fidelity as a stand-alone approval (its own
272
+ * `fields[]`, `description`, etc.). Type is the discriminated union to keep
273
+ * the recursion typed across ledger kinds.
274
+ */
275
+ innerTransaction?: TransactionData;
276
+ /**
277
+ * Recursively parsed inner transactions for `BatchTransaction`.
278
+ *
279
+ * SDK 2.81.0+ exposes the decoded inner transactions on a deserialised
280
+ * `BatchTransaction` via `innerTransactions` — the parser iterates that
281
+ * list and re-routes each entry through its own dispatcher, returning
282
+ * the full {@link TransactionData} per inner so the modal can render
283
+ * the batch envelope plus each inner transaction recursively (in
284
+ * compact mode).
285
+ *
286
+ * `undefined` distinguishes "extraction failed" (SDK threw, modal
287
+ * shows blind-sign banner) from `[]` (extraction succeeded, batch is
288
+ * empty — degenerate but valid).
289
+ */
290
+ innerTransactions?: TransactionData[];
291
+ /**
292
+ * Aggregated net impact across a `BatchTransaction`'s inner txs —
293
+ * populated by the wallet's `NetImpactCalculatorService` once it has
294
+ * the signer's account ID to filter by. Surfaces "you will net -5
295
+ * HBAR + 100 USDC" so the user sees the bottom line without having
296
+ * to mentally sum every inner transfer.
297
+ *
298
+ * Only present on `BatchTransaction`. `undefined` when extraction
299
+ * failed (blind-sign path) or when the wallet didn't run the
300
+ * aggregation (e.g., non-Hedera batches).
301
+ */
302
+ batchNetImpact?: BatchNetImpact;
303
+ /**
304
+ * Structured diff for `AccountUpdate` transactions — only present when
305
+ * `type === 'AccountUpdate'`.
306
+ *
307
+ * The parser populates `changes` with one entry per field the tx is
308
+ * touching, leaving `oldValue` as `null`. The wallet enricher
309
+ * (`AccountStateFetcherService`) queries Mirror Node and fills in the
310
+ * `oldValue` so the modal can render an old → new diff side by side.
311
+ *
312
+ * `oldValuesFetched` distinguishes the case "Mirror Node failed → we
313
+ * cannot verify the old value" from "this field was unset on-chain
314
+ * before". The modal surfaces a "could not verify" badge in the
315
+ * former case so the user knows the diff is incomplete.
316
+ */
317
+ accountUpdateDiff?: AccountUpdateDiff;
318
+ /**
319
+ * Raw message payload for `TopicMessageSubmit` transactions — only
320
+ * present when `type === 'TopicMessageSubmit'`.
321
+ *
322
+ * Carries the bytes the dApp wants to publish to the consensus topic
323
+ * so the modal can render them in their original form (UTF-8 text by
324
+ * default, with a hex fallback for binary). The parser also returns
325
+ * `isBinary` after running a printability heuristic so the modal can
326
+ * decide whether to require an extra ack ("I understand this binary
327
+ * message will be permanent").
328
+ *
329
+ * The bytes flow in-memory from parser → modal within the same Angular
330
+ * app process, so a `Uint8Array` is safe — no JSON boundary in the way.
331
+ */
332
+ topicMessage?: TopicMessagePayload;
333
+ /**
334
+ * Raw payload + tx-shape verdict for `SignMessage` requests — only
335
+ * present when `type === 'SignMessage'`.
336
+ *
337
+ * The wallet's message-signing handler decodes the dApp-supplied
338
+ * message (UTF-8 or base64) and runs the bytes through the
339
+ * `TxShapeDetectorService`. When the bytes happen to decode as a valid
340
+ * Hedera `Transaction` (e.g., a CryptoTransfer disguised as a "login
341
+ * challenge"), `txShape.isTransactionShaped` is `true` and the modal
342
+ * renders a critical banner + mandatory ack to prevent silent
343
+ * authorisation of on-chain actions.
344
+ */
345
+ signMessage?: SignMessagePayload;
346
+ /**
347
+ * Schedule-sign payload — only present when `type === 'ScheduleSign'`.
348
+ *
349
+ * Carries the on-chain schedule ID so the wallet enricher can fetch
350
+ * the current state (signatures collected, executed/deleted flags)
351
+ * from Mirror Node before the modal opens. The modal then renders a
352
+ * "Signing this counts toward N collected signatures" affordance
353
+ * instead of an opaque "Sign scheduled transaction" stub.
354
+ */
355
+ scheduleSign?: ScheduleSignPayload;
356
+ /**
357
+ * Structured envelope payload for `ScheduleCreate` — only present
358
+ * when the user is creating a new schedule.
359
+ *
360
+ * Mirrors the flat `fields[]` rows (payer, expiration, admin-key,
361
+ * waitForExpiry, memo) into a typed shape the modal renders in a
362
+ * dedicated card with a live countdown to expiration. The recursive
363
+ * compact instance for the scheduled inner tx still renders below
364
+ * (Phase 3 compact-recursion in 5a936cf1).
365
+ */
366
+ scheduleCreateEnvelope?: ScheduleCreateEnvelope;
367
+ }
368
+ /**
369
+ * @description ScheduleCreate envelope payload.
370
+ *
371
+ * Every field is optional because a Schedule can be created with only
372
+ * the inner transaction — payer falls back to the operator, admin key
373
+ * to none, expiration to the node default, etc. The modal renders only
374
+ * the rows the parser could populate.
375
+ */
376
+ export interface ScheduleCreateEnvelope {
377
+ /**
378
+ * Explicit payer for the scheduled inner transaction. Falls back to
379
+ * the operator when omitted.
380
+ */
381
+ payerAccountId?: string;
382
+ /**
383
+ * `true` when the dApp set an admin key on the schedule. Display-only —
384
+ * the modal surfaces this so the user knows the schedule can be
385
+ * deleted (vs. one that becomes immutable post-creation).
386
+ */
387
+ adminKeySet?: boolean;
388
+ /**
389
+ * `true` when the dApp set `waitForExpiry`. Critical distinction —
390
+ * a waitForExpiry schedule defers execution until expiration even if
391
+ * the threshold is reached early. The modal highlights this row.
392
+ */
393
+ waitForExpiry?: boolean;
394
+ /**
395
+ * Schedule expiration timestamp in unix ms. The modal pipes this
396
+ * through {@link HsRelativeTimePipe} for the live countdown
397
+ * ("in 3 hours 42 minutes").
398
+ */
399
+ expirationMs?: number;
400
+ /** Schedule memo, when the dApp set one. */
401
+ memo?: string;
402
+ }
403
+ /**
404
+ * @description Schedule-sign approval payload.
405
+ *
406
+ * `scheduleId` is the on-chain identifier the parser extracts from the
407
+ * `ScheduleSignTransaction`. `progress` is populated by the wallet
408
+ * enricher post-parse via Mirror Node `/api/v1/schedules/{id}`. The
409
+ * enricher leaves `progress` undefined when the lookup fails so the
410
+ * modal can render a "could not verify schedule state" affordance
411
+ * instead of silently showing stale data.
412
+ */
413
+ export interface ScheduleSignPayload {
414
+ /** On-chain schedule ID being signed (e.g., `"0.0.226412"`). */
415
+ scheduleId: string;
416
+ /**
417
+ * State snapshot from Mirror Node. `undefined` when the enricher could
418
+ * not fetch the schedule (network failure, 404, etc.) — the modal
419
+ * surfaces this distinctly from the "0 signatures collected" path.
420
+ */
421
+ progress?: ScheduleProgress;
422
+ }
423
+ /**
424
+ * @description State snapshot of an on-chain Hedera schedule, as
425
+ * returned by Mirror Node `/api/v1/schedules/{id}`.
426
+ *
427
+ * Multi-sig threshold (how many signatures the schedule actually needs
428
+ * to execute) lives in the schedule's key structure off-chain and is
429
+ * not exposed by the Mirror Node — only the *count* and identities of
430
+ * signatures collected so far. The modal renders the count without a
431
+ * total so the user has a partial-but-truthful picture.
432
+ *
433
+ * `executed` / `deleted` are terminal flags — once true the schedule
434
+ * cannot accept further signatures. The modal renders a danger banner
435
+ * + blocks Approve in that case (signing a terminal schedule is
436
+ * effectively a NOP that still costs the user a tx fee).
437
+ */
438
+ export interface ScheduleProgress {
439
+ /** Schedule ID this snapshot is for. */
440
+ scheduleId: string;
441
+ /** Number of signing keys that have signed the schedule so far. */
442
+ signaturesCollected: number;
443
+ /** True when the schedule has already executed. Terminal. */
444
+ executed: boolean;
445
+ /** True when the schedule has been deleted. Terminal. */
446
+ deleted: boolean;
447
+ /** Executed timestamp (unix ms) when `executed === true`. */
448
+ executedAtMs?: number;
449
+ /** Deleted timestamp (unix ms) when `deleted === true`. */
450
+ deletedAtMs?: number;
451
+ /** Scheduled expiration timestamp (unix ms). Optional per network. */
452
+ expirationMs?: number;
453
+ /** Payer for the scheduled inner transaction (e.g., `"0.0.123"`). */
454
+ payerAccountId?: string;
455
+ }
456
+ /**
457
+ * @description Topic-message preview payload.
458
+ *
459
+ * `bytes` is the raw message the dApp asked to submit; the modal feeds
460
+ * it to {@link HsMessageContentComponent} for the UTF-8 ↔ hex toggle.
461
+ * `size` is just `bytes.byteLength` cached so the modal doesn't have to
462
+ * recompute on every change-detection cycle.
463
+ */
464
+ export interface TopicMessagePayload {
465
+ /** Raw bytes the tx will publish to the topic. */
466
+ bytes: Uint8Array;
467
+ /** Cached byte length (`bytes.byteLength`). */
468
+ size: number;
469
+ /**
470
+ * `true` when the parser's printability heuristic decided the payload
471
+ * is not UTF-8 text. Drives the binary-message ack in the modal — if
472
+ * the user can't read what they're signing, the wallet should make
473
+ * them explicitly confirm the message will be permanent.
474
+ */
475
+ isBinary: boolean;
476
+ }
477
+ /**
478
+ * @description Sign-message preview payload.
479
+ *
480
+ * Mirrors {@link TopicMessagePayload} for the byte / preview side, plus
481
+ * a `txShape` verdict that surfaces whether the bytes could be parsed
482
+ * as a Hedera transaction. The bytes flow in-memory from the wallet's
483
+ * signing handler → modal (no JSON serialisation between them) so a
484
+ * `Uint8Array` is safe.
485
+ */
486
+ export interface SignMessagePayload {
487
+ /** Raw bytes of the message to sign. */
488
+ bytes: Uint8Array;
489
+ /** Cached byte length (`bytes.byteLength`). */
490
+ size: number;
491
+ /**
492
+ * `true` when the wallet's printability heuristic decided the payload
493
+ * is not UTF-8 text. Drives the message-content card's default
494
+ * encoding view.
495
+ */
496
+ isBinary: boolean;
497
+ /**
498
+ * Original wire encoding the dApp supplied the message in. Surfaced
499
+ * for the message-content card so the user understands whether what
500
+ * they're seeing has been re-encoded for display.
501
+ */
502
+ encoding: 'utf-8' | 'base64';
503
+ /**
504
+ * Tx-shape verdict produced by `TxShapeDetectorService`. When
505
+ * `isTransactionShaped === true`, the modal renders the critical
506
+ * banner and gates Approve behind a mandatory ack.
507
+ */
508
+ txShape: TxShapeDetection;
509
+ }
510
+ /**
511
+ * @description Verdict returned by the wallet's `TxShapeDetectorService`
512
+ * for a SignMessage payload.
513
+ *
514
+ * `sdkClassName` is the human-readable name of the deserialised
515
+ * transaction class:
516
+ * - Hedera: SDK constructor name (e.g. `'TransferTransaction'`).
517
+ * - XRPL: `TransactionType` field (e.g. `'Payment'`).
518
+ *
519
+ * `parsedKind` names the parser that produced the verdict so the modal
520
+ * can frame the warning correctly:
521
+ * - `'hedera.transaction'` — decoded by `@hashgraph/sdk`.
522
+ * - `'xrpl.transaction'` — decoded by `xrpl.decode()`.
523
+ *
524
+ * The modal surfaces these verbatim in the warning so the user sees
525
+ * which on-chain action they would authorise. (H-4 / M-6).
526
+ */
527
+ export interface TxShapeDetection {
528
+ /** True when the bytes round-trip as a transaction on the supplied ledger. */
529
+ isTransactionShaped: boolean;
530
+ /** SDK class name (Hedera) / TransactionType (XRPL). Undefined on negatives. */
531
+ sdkClassName?: string;
532
+ /** Which parser produced this verdict. Undefined on negatives. */
533
+ parsedKind?: 'hedera.transaction' | 'xrpl.transaction';
534
+ }
535
+ /**
536
+ * @description Aggregated net impact across all inner transactions in
537
+ * a `BatchTransaction`. Computed from the signer's perspective —
538
+ * `hbarTinybars` is the signed delta to the signer's HBAR balance,
539
+ * each `tokens[]` entry is the signed delta per fungible token, and
540
+ * `nfts.sent` / `nfts.received` are the NFT serials the signer
541
+ * gains/loses.
542
+ *
543
+ * `otherActions` counts inner txs that aren't value transfers
544
+ * (mint/burn/associate/etc.) so the molecule can render a
545
+ * "+ N other actions" affordance without itemising every one — the
546
+ * user still sees those rendered as compact inner-tx instances below.
547
+ *
548
+ * Bigint precision because raw token quantities can exceed the JS
549
+ * safe-integer range for tokens with many decimals (e.g., 18-decimal
550
+ * tokens easily exceed 2^53).
551
+ */
552
+ export interface BatchNetImpact {
553
+ /**
554
+ * Net HBAR delta in tinybars (signed). `0n` when no HBAR moved;
555
+ * `null` when no HBAR transfers appeared in the batch at all.
556
+ */
557
+ hbarTinybars: bigint | null;
558
+ /** Per-token net deltas, keyed by tokenId. */
559
+ tokens: Array<{
560
+ tokenId: string;
561
+ /** Raw signed delta (not adjusted for decimals). */
562
+ netRaw: bigint;
563
+ decimals?: number;
564
+ symbol?: string;
565
+ name?: string;
566
+ }>;
567
+ /** NFTs the signer gains or loses in the batch. */
568
+ nfts: {
569
+ sent: Array<{
570
+ tokenId: string;
571
+ serial: number;
572
+ }>;
573
+ received: Array<{
574
+ tokenId: string;
575
+ serial: number;
576
+ }>;
577
+ };
578
+ /**
579
+ * Count of inner txs that aren't value transfers (mint, burn,
580
+ * associate, schedule, etc.). The compact inner-tx list below the
581
+ * summary card still renders each of these in full fidelity.
582
+ */
583
+ otherActions: number;
584
+ }
585
+ /**
586
+ * @description Account-update diff payload populated by the parser
587
+ * (new values) and the wallet enricher (old values).
588
+ */
589
+ export interface AccountUpdateDiff {
590
+ /** The account ID being modified (e.g., `"0.0.1234"`). */
591
+ targetAccountId: string;
592
+ /**
593
+ * `true` once the enricher successfully fetched the current account
594
+ * state from the Mirror Node. When `false`, `oldValue` entries in
595
+ * `changes` are `null` because the network call did not return.
596
+ */
597
+ oldValuesFetched: boolean;
598
+ /** One row per touched field. */
599
+ changes: AccountUpdateDiffRow[];
600
+ }
601
+ /**
602
+ * @description A single field change in an AccountUpdate.
603
+ *
604
+ * `field` is the canonical identifier; the modal maps it to the
605
+ * appropriate i18n label. `oldValue` / `newValue` are display strings —
606
+ * formatted by the parser/enricher rather than the modal, so the modal
607
+ * stays purely presentational and consistent across fields.
608
+ */
609
+ export interface AccountUpdateDiffRow {
610
+ /** Stable identifier for the field being changed. */
611
+ field: 'key' | 'memo' | 'maxAutoAssociations' | 'autoRenewPeriod' | 'expirationTime' | 'stakedNodeId' | 'stakedAccountId' | 'declineReward' | 'receiverSignatureRequired';
612
+ /**
613
+ * Pre-change display value. `null` means either the enricher could not
614
+ * fetch the old state or the field was unset on-chain before. The
615
+ * modal disambiguates via {@link AccountUpdateDiff.oldValuesFetched}.
616
+ */
617
+ oldValue: string | null;
618
+ /** Post-change display value the transaction is applying. */
619
+ newValue: string | null;
620
+ /**
621
+ * When `true`, this row gates Approve via a required ack. Currently
622
+ * only `field === 'key'` is critical — a wrong key locks the account
623
+ * permanently.
624
+ */
625
+ critical: boolean;
626
+ }
627
+ /**
628
+ * @description XRPL transaction data structure
629
+ * Comprehensive type definition supporting all major XRPL transaction types including DEX operations.
630
+ */
631
+ export interface XrplTransactionData extends BaseTransactionData {
632
+ /** XRPL transaction type */
633
+ type: 'Payment' | 'TrustSet' | 'OfferCreate' | 'OfferCancel' | 'EscrowCreate' | 'EscrowFinish' | 'EscrowCancel' | 'PaymentChannelCreate' | 'PaymentChannelFund' | 'PaymentChannelClaim' | 'NFTokenMint' | 'NFTokenBurn' | 'NFTokenCreateOffer' | 'NFTokenAcceptOffer' | 'NFTokenCancelOffer' | 'AccountSet' | 'SignerListSet' | 'SetRegularKey' | 'DepositPreauth' | 'CheckCreate' | 'CheckCash' | 'CheckCancel' | 'TicketCreate' | 'SignMessage';
634
+ /** Destination address */
635
+ destination?: string;
636
+ /** Amount (XRP drops or issued currency object) */
637
+ amount?: string | {
638
+ currency: string;
639
+ issuer: string;
640
+ value: string;
641
+ };
642
+ /** Destination tag for routing */
643
+ destinationTag?: number;
644
+ /** Source tag */
645
+ sourceTag?: number;
646
+ /** Payment paths for currency conversion */
647
+ paths?: unknown;
648
+ /** Limit on exchange rate */
649
+ sendMax?: string | {
650
+ currency: string;
651
+ issuer: string;
652
+ value: string;
653
+ };
654
+ /** Minimum amount to deliver */
655
+ deliverMin?: string | {
656
+ currency: string;
657
+ issuer: string;
658
+ value: string;
659
+ };
660
+ /** Trust line limit amount */
661
+ limitAmount?: {
662
+ currency: string;
663
+ issuer: string;
664
+ value: string;
665
+ };
666
+ /** Quality in (for trust line) */
667
+ qualityIn?: number;
668
+ /** Quality out (for trust line) */
669
+ qualityOut?: number;
670
+ /** What the taker pays */
671
+ takerPays?: string | {
672
+ currency: string;
673
+ issuer: string;
674
+ value: string;
675
+ };
676
+ /** What the taker gets */
677
+ takerGets?: string | {
678
+ currency: string;
679
+ issuer: string;
680
+ value: string;
681
+ };
682
+ /** Sequence number of offer to cancel */
683
+ offerSequence?: number;
684
+ /** Offer expiration time */
685
+ expiration?: number;
686
+ /** Escrow finish after time */
687
+ finishAfter?: number;
688
+ /** Escrow cancel after time */
689
+ cancelAfter?: number;
690
+ /** Crypto condition */
691
+ condition?: string;
692
+ /** Crypto condition fulfillment */
693
+ fulfillment?: string;
694
+ /** Owner of the escrow */
695
+ owner?: string;
696
+ /** Payment channel ID */
697
+ channel?: string;
698
+ /** Settle delay in seconds */
699
+ settleDelay?: number;
700
+ /** Public key for channel */
701
+ publicKey?: string;
702
+ /** Channel balance */
703
+ balance?: string;
704
+ /** Signature for claim */
705
+ signature?: string;
706
+ /** NFToken ID */
707
+ nftokenID?: string;
708
+ /** NFToken URI (hex encoded) */
709
+ uri?: string;
710
+ /** NFToken transfer fee (basis points) */
711
+ transferFee?: number;
712
+ /** NFToken taxon */
713
+ nftokenTaxon?: number;
714
+ /** NFToken sell offer ID */
715
+ nftokenSellOffer?: string;
716
+ /** NFToken buy offer ID */
717
+ nftokenBuyOffer?: string;
718
+ /** NFToken offers to cancel */
719
+ nftokenOffers?: string[];
720
+ /** Email hash */
721
+ emailHash?: string;
722
+ /** Message key */
723
+ messageKey?: string;
724
+ /** Domain */
725
+ domain?: string;
726
+ /** Transfer rate */
727
+ transferRate?: number;
728
+ /** Tick size for offers */
729
+ tickSize?: number;
730
+ /** Signer quorum */
731
+ signerQuorum?: number;
732
+ /** Signer entries */
733
+ signerEntries?: Array<{
734
+ account: string;
735
+ weight: number;
736
+ }>;
737
+ /** Check ID */
738
+ checkID?: string;
739
+ /** Invoice ID */
740
+ invoiceID?: string;
741
+ /** Account to authorize */
742
+ authorize?: string;
743
+ /** Account to unauthorize */
744
+ unauthorize?: string;
745
+ /** Number of tickets to create */
746
+ ticketCount?: number;
747
+ /** Transaction flags */
748
+ flags?: number;
749
+ /** Array of memos */
750
+ memos?: Array<{
751
+ data?: string;
752
+ type?: string;
753
+ format?: string;
754
+ }>;
755
+ }
756
+ /**
757
+ * @description Union type for all transaction data
758
+ */
759
+ export type TransactionData = HederaTransactionData | XrplTransactionData;
760
+ /**
761
+ * @description Transaction approval event
762
+ * Emitted when user approves or rejects a transaction.
763
+ */
764
+ export interface TransactionApprovalEvent {
765
+ /** Whether transaction was approved */
766
+ approved: boolean;
767
+ /** Timestamp of approval/rejection */
768
+ timestamp: number;
769
+ /** Optional user note/reason */
770
+ userNote?: string;
771
+ }
772
+ /**
773
+ * @description Risk factor for a transaction
774
+ */
775
+ export interface RiskFactor {
776
+ /** Type of risk */
777
+ type: 'new_address' | 'large_amount' | 'contract_interaction' | 'token_approval' | 'unusual_pattern' | 'high_fee' | 'unknown_token' | 'custom';
778
+ /** Severity level */
779
+ severity: 'info' | 'warning' | 'danger';
780
+ /** Short message describing the risk */
781
+ message: string;
782
+ /** Detailed description (optional) */
783
+ description?: string;
784
+ /** Help URL for more information (optional) */
785
+ helpUrl?: string;
786
+ }
787
+ /**
788
+ * @description Risk assessment result
789
+ * Provides overall risk level and specific risk factors.
790
+ */
791
+ export interface RiskAssessment {
792
+ /** Overall risk level */
793
+ level: 'low' | 'medium' | 'high';
794
+ /** Individual risk factors */
795
+ factors: RiskFactor[];
796
+ /** Confidence score (0-1) */
797
+ confidence?: number;
798
+ /** Recommendation for user */
799
+ recommendation?: string;
800
+ }
801
+ /**
802
+ * @description Fee breakdown item
803
+ */
804
+ export interface FeeItem {
805
+ /** Fee label (e.g., "Network Fee", "Node Fee") */
806
+ label: string;
807
+ /** Fee amount (in native currency smallest unit) */
808
+ amount: string;
809
+ /** Optional description */
810
+ description?: string;
811
+ /** Fee type for categorization */
812
+ type?: 'network' | 'node' | 'service' | 'gas' | 'priority' | 'other';
813
+ }
814
+ /**
815
+ * @description Account information for transaction context
816
+ */
817
+ export interface TransactionAccount {
818
+ /** Account address/ID */
819
+ address: string;
820
+ /** Current balance (optional) */
821
+ balance?: string;
822
+ /** Public key (optional) */
823
+ publicKey?: string;
824
+ /** Account label/name (optional) */
825
+ label?: string;
826
+ /** Ledger ID */
827
+ ledgerId: 'hedera' | 'xrpl';
828
+ /** Network ID */
829
+ networkId: string;
830
+ }
831
+ /**
832
+ * @description Complete transaction approval context
833
+ * All information needed to display transaction approval UI.
834
+ */
835
+ export interface TransactionApprovalContext {
836
+ /** Unique identifier for this approval request */
837
+ requestId: string;
838
+ /** Ledger type */
839
+ ledgerId: 'hedera' | 'xrpl';
840
+ /** Network identifier */
841
+ networkId: string;
842
+ /** Transaction type */
843
+ transactionType: string;
844
+ /** Transaction data */
845
+ transactionData: TransactionData;
846
+ /** Account initiating the transaction */
847
+ accountInfo: TransactionAccount;
848
+ /** Estimated fees */
849
+ fees?: FeeItem[];
850
+ /** Total fee amount */
851
+ totalFee?: string;
852
+ /** Risk assessment */
853
+ riskAssessment?: RiskAssessment;
854
+ /** Session ID (for dApp transactions) */
855
+ sessionId?: string;
856
+ /** Raw payload bytes */
857
+ payload?: Uint8Array;
858
+ /** Created timestamp */
859
+ createdAt: number;
860
+ /** Expiration timestamp (optional) */
861
+ expiresAt?: number;
862
+ /** Whether the dApp is requesting sign and submit (true) or sign only (false) */
863
+ signAndSubmit?: boolean;
864
+ /** Name of the dApp requesting this transaction (if from session) */
865
+ dappName?: string;
866
+ /** Protocol used for the request (native HSuite or WalletConnect) */
867
+ protocol?: 'native' | 'walletconnect';
868
+ /** Multisig-specific fields */
869
+ multisig?: {
870
+ /** Whether this is a multisig transaction requiring party signatures */
871
+ isMultisig: true;
872
+ /** The proposal ID for tracking across party members */
873
+ proposalId: string;
874
+ /** The party ID this proposal belongs to */
875
+ partyId: string;
876
+ /** Current signature progress */
877
+ progress: {
878
+ have: number;
879
+ need: number;
880
+ members: string[];
881
+ };
882
+ /** Who initiated this proposal */
883
+ initiator: string;
884
+ };
885
+ /** Inner transactions for batch transactions */
886
+ innerTransactions?: Array<{
887
+ /** Base64-encoded transaction payload */
888
+ payload: string;
889
+ /** Human-readable description of this inner transaction */
890
+ description?: string;
891
+ /** Parsed transaction data (if available) */
892
+ parsedData?: TransactionData;
893
+ }>;
894
+ }
895
+ //# sourceMappingURL=transaction-approval.d.ts.map