@lukso/transaction-view-headless 0.4.3 → 0.4.4-dev.ba618e9

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 (41) hide show
  1. package/.turbo/turbo-build.log +32 -30
  2. package/.turbo/turbo-typecheck.log +1 -1
  3. package/ARG_ACCESS_PATTERN.md +265 -0
  4. package/CHANGELOG.md +14 -0
  5. package/CONTEXT_VARIANT_GUIDE.md +4 -4
  6. package/EVENT_SYSTEM_SUMMARY.md +601 -0
  7. package/HEADER_EVENTS_GUIDE.md +291 -0
  8. package/RECOMPOSITION_REFERENCE.md +303 -0
  9. package/TRANSACTION_MODIFICATION_GUIDE.md +927 -0
  10. package/dist/composables/index.cjs +1 -1
  11. package/dist/composables/index.cjs.map +1 -1
  12. package/dist/composables/index.d.cts +3 -3
  13. package/dist/composables/index.d.ts +3 -3
  14. package/dist/composables/index.js +1 -1
  15. package/dist/composables/index.js.map +1 -1
  16. package/dist/{index-CSDjhiKV.d.cts → index-BqL7xdDl.d.cts} +2 -2
  17. package/dist/{index-CMLU1hKL.d.ts → index-CNUHqRdk.d.ts} +2 -2
  18. package/dist/index.cjs +60 -1
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +5 -4
  21. package/dist/index.d.ts +5 -4
  22. package/dist/index.js +55 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/registry/index.d.cts +2 -2
  25. package/dist/registry/index.d.ts +2 -2
  26. package/dist/types/index.cjs +68 -0
  27. package/dist/types/index.cjs.map +1 -1
  28. package/dist/types/index.d.cts +229 -169
  29. package/dist/types/index.d.ts +229 -169
  30. package/dist/types/index.js +55 -0
  31. package/dist/types/index.js.map +1 -1
  32. package/dist/utils/index.d.cts +1 -1
  33. package/dist/utils/index.d.ts +1 -1
  34. package/dist/{view-loader-dD86QAlQ.d.cts → view-loader--mEEI8YY.d.ts} +1 -1
  35. package/dist/{view-loader-ii8AxiQR.d.ts → view-loader-D7ApWfdN.d.cts} +1 -1
  36. package/dist/view-matching-C9G3z8lQ.d.cts +203 -0
  37. package/dist/view-matching-C9G3z8lQ.d.ts +203 -0
  38. package/package.json +3 -3
  39. package/src/composables/use-transaction-playback.ts +8 -5
  40. package/src/types/index.ts +14 -0
  41. package/src/types/view-events.ts +322 -0
@@ -1,6 +1,6 @@
1
- export { L as LoaderHelpers, U as UniversalViewLoader, V as ViewLoadingError, g as getGlobalLoader, s as setGlobalLoader } from '../view-loader-dD86QAlQ.cjs';
1
+ export { L as LoaderHelpers, U as UniversalViewLoader, V as ViewLoadingError, g as getGlobalLoader, s as setGlobalLoader } from '../view-loader-D7ApWfdN.cjs';
2
2
  import { DecoderResult } from '@lukso/transaction-decoder';
3
- import { ViewRegistry, ViewDefinition, ViewMatchOptions, ViewMatch } from '../types/index.cjs';
3
+ import { i as ViewRegistry, a as ViewDefinition, h as ViewMatchOptions, b as ViewMatch } from '../view-matching-C9G3z8lQ.cjs';
4
4
 
5
5
  /**
6
6
  * Default view registry implementation
@@ -1,6 +1,6 @@
1
- export { L as LoaderHelpers, U as UniversalViewLoader, V as ViewLoadingError, g as getGlobalLoader, s as setGlobalLoader } from '../view-loader-ii8AxiQR.js';
1
+ export { L as LoaderHelpers, U as UniversalViewLoader, V as ViewLoadingError, g as getGlobalLoader, s as setGlobalLoader } from '../view-loader--mEEI8YY.js';
2
2
  import { DecoderResult } from '@lukso/transaction-decoder';
3
- import { ViewRegistry, ViewDefinition, ViewMatchOptions, ViewMatch } from '../types/index.js';
3
+ import { i as ViewRegistry, a as ViewDefinition, h as ViewMatchOptions, b as ViewMatch } from '../view-matching-C9G3z8lQ.js';
4
4
 
5
5
  /**
6
6
  * Default view registry implementation
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,5 +19,69 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/types/index.ts
17
21
  var types_exports = {};
22
+ __export(types_exports, {
23
+ TransactionViewEvents: () => TransactionViewEvents,
24
+ dispatchHeaderInfo: () => dispatchHeaderInfo,
25
+ dispatchTransactionModification: () => dispatchTransactionModification,
26
+ isHeaderInfoEvent: () => isHeaderInfoEvent,
27
+ isTransactionModificationEvent: () => isTransactionModificationEvent
28
+ });
18
29
  module.exports = __toCommonJS(types_exports);
30
+
31
+ // src/types/view-events.ts
32
+ var TransactionViewEvents = {
33
+ /**
34
+ * Emitted when a view wants to provide custom header information
35
+ * Parent containers should listen for this event and update their header accordingly
36
+ */
37
+ HEADER_INFO: "header-info",
38
+ /**
39
+ * Emitted when a view modifies its transaction data
40
+ * Parent containers should listen, re-wrap if needed, and update the transaction
41
+ */
42
+ TRANSACTION_MODIFICATION: "transaction-modification",
43
+ /**
44
+ * Emitted when a view's state changes (future use)
45
+ * @example Loading state, error state, interactive state changes
46
+ */
47
+ STATE_CHANGE: "view-state-change",
48
+ /**
49
+ * Emitted when a view has an action for the user (future use)
50
+ * @example "Approve", "Reject", "Sign"
51
+ */
52
+ ACTION: "view-action"
53
+ };
54
+ function dispatchHeaderInfo(element, headerInfo) {
55
+ element.dispatchEvent(
56
+ new CustomEvent(TransactionViewEvents.HEADER_INFO, {
57
+ bubbles: true,
58
+ composed: true,
59
+ // Allows event to cross shadow DOM boundaries
60
+ detail: headerInfo
61
+ })
62
+ );
63
+ }
64
+ function isHeaderInfoEvent(event) {
65
+ return event instanceof CustomEvent && event.type === TransactionViewEvents.HEADER_INFO;
66
+ }
67
+ function dispatchTransactionModification(element, modification) {
68
+ element.dispatchEvent(
69
+ new CustomEvent(TransactionViewEvents.TRANSACTION_MODIFICATION, {
70
+ bubbles: true,
71
+ composed: true,
72
+ detail: modification
73
+ })
74
+ );
75
+ }
76
+ function isTransactionModificationEvent(event) {
77
+ return event instanceof CustomEvent && event.type === TransactionViewEvents.TRANSACTION_MODIFICATION;
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ TransactionViewEvents,
82
+ dispatchHeaderInfo,
83
+ dispatchTransactionModification,
84
+ isHeaderInfoEvent,
85
+ isTransactionModificationEvent
86
+ });
19
87
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n ViewContext,\n ViewContextRequirements,\n ViewVariant,\n} from './view-contexts'\nexport type {\n DecoderRecordForSelection,\n FrameworkSupport,\n FrameworkViewConfig,\n ViewDefinition,\n ViewLoader,\n ViewMatch,\n ViewMatchCriteria,\n ViewMatchOptions,\n ViewRegistry,\n} from './view-matching'\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/index.ts","../../src/types/view-events.ts"],"sourcesContent":["export type {\n ViewContext,\n ViewContextRequirements,\n ViewVariant,\n} from './view-contexts'\nexport type {\n HeaderInfoEvent,\n TransactionHeaderInfo,\n TransactionModification,\n TransactionModificationEvent,\n TransactionModificationWithContext,\n} from './view-events'\nexport {\n dispatchHeaderInfo,\n dispatchTransactionModification,\n isHeaderInfoEvent,\n isTransactionModificationEvent,\n TransactionViewEvents,\n} from './view-events'\nexport type {\n DecoderRecordForSelection,\n FrameworkSupport,\n FrameworkViewConfig,\n ViewDefinition,\n ViewLoader,\n ViewMatch,\n ViewMatchCriteria,\n ViewMatchOptions,\n ViewRegistry,\n} from './view-matching'\n","/**\n * View Events and Header Information Types\n *\n * Defines the event system for transaction views to communicate\n * with their parent containers about header display and other UI concerns.\n */\n\n/**\n * Header information that a view can provide to its parent container\n *\n * Views can emit this information to override the default header\n * that would be derived from the transaction's top-level from/to addresses.\n *\n * @example\n * ```typescript\n * // Inside a transfer view component\n * this.dispatchEvent(new CustomEvent('header-info', {\n * bubbles: true,\n * composed: true,\n * detail: {\n * from: transferFromAddress,\n * to: transferToAddress,\n * title: 'LSP7 Token Transfer'\n * }\n * }))\n * ```\n */\nexport interface TransactionHeaderInfo {\n /**\n * The \"from\" address to display in the header\n * Overrides the transaction's top-level from address\n */\n from?: string\n\n /**\n * The \"to\" address to display in the header\n * Overrides the transaction's top-level to address\n */\n to?: string\n\n /**\n * Optional title for the transaction\n * @example \"LSP7 Token Transfer\", \"Set Data\", \"Execute\"\n */\n title?: string\n\n /**\n * Optional subtitle or description\n * @example \"Send 100 tokens\", \"Update profile data\"\n */\n subtitle?: string\n\n /**\n * Optional icon identifier\n * @example \"transfer\", \"setdata\", \"execute\"\n */\n icon?: string\n\n /**\n * Optional additional metadata\n * Can be used for custom header rendering\n */\n metadata?: Record<string, any>\n}\n\n/**\n * Type-safe custom event for header information\n */\nexport interface HeaderInfoEvent extends CustomEvent {\n detail: TransactionHeaderInfo\n}\n\n/**\n * Transaction modification information\n *\n * Views emit this to modify their transaction's data (e.g., changing a parameter).\n * The view encodes its LOCAL transaction data, and the parent handles re-wrapping\n * if the transaction is inside Execute or ExecuteBatch wrappers.\n *\n * @example\n * ```typescript\n * // In a transfer view, user clicks \"Force Transfer\" checkbox\n * const newData = encodeFunctionData({\n * abi: LSP7_ABI,\n * functionName: 'transfer',\n * args: [from, to, amount, true, data] // force = true\n * })\n *\n * dispatchTransactionModification(this, {\n * data: newData,\n * transactionIndex: this.index,\n * reason: 'User enabled force transfer to EOA',\n * userInitiated: true\n * })\n * ```\n */\nexport interface TransactionModification {\n /**\n * The modified data for THIS transaction level (not wrapped)\n *\n * This is the encoded function call for the current transaction only,\n * not wrapped in Execute or Batch calls. The parent container handles re-wrapping.\n */\n data: `0x${string}`\n\n /**\n * The playback index this modification applies to\n *\n * - 0 = batch summary (modifies batch itself)\n * - 1 = first transaction (or single tx)\n * - 2 = second child transaction\n * - etc.\n *\n * This must match the `index` prop of <transaction-playback>\n */\n transactionIndex: number\n\n /**\n * Human-readable explanation of why this modification occurred\n *\n * @example \"User enabled force transfer to EOA\"\n * @example \"Slippage tolerance increased to 2%\"\n * @example \"Gas limit adjusted for complex operation\"\n */\n reason: string\n\n /**\n * Whether this modification was triggered by user interaction\n *\n * - true: User clicked checkbox, changed input, adjusted slider, etc.\n * - false: Automatic adjustment by view logic\n */\n userInitiated: boolean\n\n /**\n * Optional structured summary for quick display/logging\n */\n summary?: {\n /** Name of the field that changed */\n field: string\n\n /** Human-readable old value */\n oldValue: string\n\n /** Human-readable new value */\n newValue: string\n }\n\n /**\n * Optional validation information\n */\n validation?: {\n /** Whether the modification is valid */\n isValid: boolean\n\n /** Error message if invalid */\n error?: string\n\n /** Warning messages (modification is valid but user should be aware) */\n warnings?: string[]\n }\n}\n\n/**\n * Extended modification info added by transaction-playback\n *\n * This is what the top-level container receives after transaction-playback\n * adds context about where in the transaction tree this modification applies.\n */\nexport interface TransactionModificationWithContext\n extends TransactionModification {\n /**\n * Path from root transaction to this transaction\n *\n * @example [1] - Simple transaction at index 1\n * @example [0, 2] - Batch at index 0, child at index 2\n * @example [0, 1, 0] - Nested batch: batch[0].children[1].children[0]\n */\n transactionPath: number[]\n\n /**\n * The full local transaction object with modified data\n * (Before re-wrapping)\n */\n localTransaction: any // DecoderResult, but avoiding circular dep\n\n /**\n * Re-decoded result for verification\n * Parent should verify this decodes successfully before applying\n */\n decodedResult: any // DecoderResult\n}\n\n/**\n * Type-safe custom event for transaction modifications\n */\nexport interface TransactionModificationEvent extends CustomEvent {\n detail: TransactionModification\n}\n\n/**\n * Event type names for transaction views\n */\nexport const TransactionViewEvents = {\n /**\n * Emitted when a view wants to provide custom header information\n * Parent containers should listen for this event and update their header accordingly\n */\n HEADER_INFO: 'header-info',\n\n /**\n * Emitted when a view modifies its transaction data\n * Parent containers should listen, re-wrap if needed, and update the transaction\n */\n TRANSACTION_MODIFICATION: 'transaction-modification',\n\n /**\n * Emitted when a view's state changes (future use)\n * @example Loading state, error state, interactive state changes\n */\n STATE_CHANGE: 'view-state-change',\n\n /**\n * Emitted when a view has an action for the user (future use)\n * @example \"Approve\", \"Reject\", \"Sign\"\n */\n ACTION: 'view-action',\n} as const\n\n/**\n * Helper function to dispatch header info event\n * Use this in view components to emit header information\n *\n * @example\n * ```typescript\n * import { dispatchHeaderInfo } from '@lukso/transaction-view-headless'\n *\n * class MyTransferView extends LitElement {\n * connectedCallback() {\n * super.connectedCallback()\n * dispatchHeaderInfo(this, {\n * from: this.transferFrom,\n * to: this.transferTo,\n * title: 'Token Transfer'\n * })\n * }\n * }\n * ```\n */\nexport function dispatchHeaderInfo(\n element: HTMLElement,\n headerInfo: TransactionHeaderInfo\n): void {\n element.dispatchEvent(\n new CustomEvent(TransactionViewEvents.HEADER_INFO, {\n bubbles: true,\n composed: true, // Allows event to cross shadow DOM boundaries\n detail: headerInfo,\n })\n )\n}\n\n/**\n * Type guard to check if an event is a HeaderInfoEvent\n */\nexport function isHeaderInfoEvent(event: Event): event is HeaderInfoEvent {\n return (\n event instanceof CustomEvent &&\n event.type === TransactionViewEvents.HEADER_INFO\n )\n}\n\n/**\n * Helper function to dispatch transaction modification event\n * Use this in view components to emit transaction modifications\n *\n * @example\n * ```typescript\n * import { dispatchTransactionModification } from '@lukso/transaction-view-headless'\n *\n * class MyTransferView extends LitElement {\n * private handleForceCheckbox(checked: boolean) {\n * const newData = encodeFunctionData({\n * abi: LSP7_ABI,\n * functionName: 'transfer',\n * args: [...args, checked]\n * })\n *\n * dispatchTransactionModification(this, {\n * data: newData,\n * transactionIndex: this.index,\n * reason: 'User enabled force transfer',\n * userInitiated: true\n * })\n * }\n * }\n * ```\n */\nexport function dispatchTransactionModification(\n element: HTMLElement,\n modification: TransactionModification\n): void {\n element.dispatchEvent(\n new CustomEvent(TransactionViewEvents.TRANSACTION_MODIFICATION, {\n bubbles: true,\n composed: true,\n detail: modification,\n })\n )\n}\n\n/**\n * Type guard to check if an event is a TransactionModificationEvent\n */\nexport function isTransactionModificationEvent(\n event: Event\n): event is TransactionModificationEvent {\n return (\n event instanceof CustomEvent &&\n event.type === TransactionViewEvents.TRANSACTION_MODIFICATION\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2MO,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnC,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAMb,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1B,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,EAMd,QAAQ;AACV;AAsBO,SAAS,mBACd,SACA,YACM;AACN,UAAQ;AAAA,IACN,IAAI,YAAY,sBAAsB,aAAa;AAAA,MACjD,SAAS;AAAA,MACT,UAAU;AAAA;AAAA,MACV,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACF;AAKO,SAAS,kBAAkB,OAAwC;AACxE,SACE,iBAAiB,eACjB,MAAM,SAAS,sBAAsB;AAEzC;AA4BO,SAAS,gCACd,SACA,cACM;AACN,UAAQ;AAAA,IACN,IAAI,YAAY,sBAAsB,0BAA0B;AAAA,MAC9D,SAAS;AAAA,MACT,UAAU;AAAA,MACV,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACF;AAKO,SAAS,+BACd,OACuC;AACvC,SACE,iBAAiB,eACjB,MAAM,SAAS,sBAAsB;AAEzC;","names":[]}
@@ -1,203 +1,263 @@
1
- import { DecoderResult } from '@lukso/transaction-decoder';
1
+ export { D as DecoderRecordForSelection, F as FrameworkSupport, f as FrameworkViewConfig, V as ViewContext, d as ViewContextRequirements, a as ViewDefinition, g as ViewLoader, b as ViewMatch, c as ViewMatchCriteria, h as ViewMatchOptions, i as ViewRegistry, e as ViewVariant } from '../view-matching-C9G3z8lQ.cjs';
2
+ import '@lukso/transaction-decoder';
2
3
 
3
4
  /**
4
- * Different contexts WHERE transaction views are displayed
5
+ * View Events and Header Information Types
5
6
  *
6
- * Context determines the environment/location, which affects:
7
- * - Available space
8
- * - User intent
9
- * - Security requirements
10
- * - Interaction patterns
7
+ * Defines the event system for transaction views to communicate
8
+ * with their parent containers about header display and other UI concerns.
11
9
  */
12
- type ViewContext = 'approval' | 'feed' | 'list' | 'detail' | 'review' | 'notification' | 'embed' | 'batch-summary';
13
10
  /**
14
- * Different variants of HOW transaction views are displayed
11
+ * Header information that a view can provide to its parent container
15
12
  *
16
- * Variant determines the presentation style within a context:
17
- * - Same transaction can have different variants in different contexts
18
- * - Example: 'collapsed' in feed vs 'collapsed' in approval are different
13
+ * Views can emit this information to override the default header
14
+ * that would be derived from the transaction's top-level from/to addresses.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Inside a transfer view component
19
+ * this.dispatchEvent(new CustomEvent('header-info', {
20
+ * bubbles: true,
21
+ * composed: true,
22
+ * detail: {
23
+ * from: transferFromAddress,
24
+ * to: transferToAddress,
25
+ * title: 'LSP7 Token Transfer'
26
+ * }
27
+ * }))
28
+ * ```
19
29
  */
20
- type ViewVariant = 'full' | 'collapsed' | 'minimal' | 'icon-only' | 'compact' | 'expanded' | string;
30
+ interface TransactionHeaderInfo {
31
+ /**
32
+ * The "from" address to display in the header
33
+ * Overrides the transaction's top-level from address
34
+ */
35
+ from?: string;
36
+ /**
37
+ * The "to" address to display in the header
38
+ * Overrides the transaction's top-level to address
39
+ */
40
+ to?: string;
41
+ /**
42
+ * Optional title for the transaction
43
+ * @example "LSP7 Token Transfer", "Set Data", "Execute"
44
+ */
45
+ title?: string;
46
+ /**
47
+ * Optional subtitle or description
48
+ * @example "Send 100 tokens", "Update profile data"
49
+ */
50
+ subtitle?: string;
51
+ /**
52
+ * Optional icon identifier
53
+ * @example "transfer", "setdata", "execute"
54
+ */
55
+ icon?: string;
56
+ /**
57
+ * Optional additional metadata
58
+ * Can be used for custom header rendering
59
+ */
60
+ metadata?: Record<string, any>;
61
+ }
21
62
  /**
22
- * Context-specific display requirements
63
+ * Type-safe custom event for header information
23
64
  */
24
- interface ViewContextRequirements {
25
- /** Maximum height constraint */
26
- maxHeight?: number;
27
- /** Whether to show action buttons */
28
- showActions?: boolean;
29
- /** Level of detail to display */
30
- detailLevel: 'minimal' | 'summary' | 'full' | 'debug';
31
- /** Whether user can expand for more details */
32
- expandable?: boolean;
33
- /** Color scheme preference */
34
- colorScheme?: 'light' | 'dark' | 'auto';
35
- /** Whether to emphasize security warnings */
36
- emphasizeSecurity?: boolean;
65
+ interface HeaderInfoEvent extends CustomEvent {
66
+ detail: TransactionHeaderInfo;
37
67
  }
38
-
39
- type DecoderRecordForSelection = DecoderResult & {
40
- recordType?: string;
41
- functionName?: string;
42
- contractAddress?: string;
43
- standard?: string;
44
- };
45
-
46
68
  /**
47
- * Criteria that can be used to match transactions to views
69
+ * Transaction modification information
70
+ *
71
+ * Views emit this to modify their transaction's data (e.g., changing a parameter).
72
+ * The view encodes its LOCAL transaction data, and the parent handles re-wrapping
73
+ * if the transaction is inside Execute or ExecuteBatch wrappers.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // In a transfer view, user clicks "Force Transfer" checkbox
78
+ * const newData = encodeFunctionData({
79
+ * abi: LSP7_ABI,
80
+ * functionName: 'transfer',
81
+ * args: [from, to, amount, true, data] // force = true
82
+ * })
83
+ *
84
+ * dispatchTransactionModification(this, {
85
+ * data: newData,
86
+ * transactionIndex: this.index,
87
+ * reason: 'User enabled force transfer to EOA',
88
+ * userInitiated: true
89
+ * })
90
+ * ```
48
91
  */
49
- interface ViewMatchCriteria {
50
- /** LSP standard (e.g., 'LSP7', 'LSP8', 'LSP0') */
51
- standard?: string | string[];
52
- /** Function name from ABI (e.g., 'transfer', 'setData', 'execute') */
53
- functionName?: string | string[];
54
- /** Record type from decoder (e.g., 'lsp7-transfer', 'set-data') */
55
- recordType?: string | string[];
56
- /** Contract address (for specific contract implementations) */
57
- contractAddress?: string | string[];
58
- /** Chain ID (for network-specific views) */
59
- chainId?: number | number[];
60
- /** Display context (opt-in) - WHERE to display (feed, approval, list, etc.) */
61
- context?: ViewContext | ViewContext[];
62
- /** Display variant (opt-in) - HOW to display (collapsed, minimal, full, etc.) */
63
- variant?: ViewVariant | ViewVariant[];
64
- /** Context requirements (opt-in) - additional constraints for context matching */
65
- contextRequirements?: Partial<ViewContextRequirements>;
66
- /**
67
- * Custom matcher function for complex synchronous logic.
68
- * Returns the number of conditions that matched (higher = better match).
92
+ interface TransactionModification {
93
+ /**
94
+ * The modified data for THIS transaction level (not wrapped)
69
95
  *
70
- * IMPORTANT: Must be synchronous and only use data from DecoderResult.
71
- * For async operations, populate transaction.custom in an enhancer.
96
+ * This is the encoded function call for the current transaction only,
97
+ * not wrapped in Execute or Batch calls. The parent container handles re-wrapping.
98
+ */
99
+ data: `0x${string}`;
100
+ /**
101
+ * The playback index this modification applies to
72
102
  *
73
- * @returns Number of matching conditions (0 = no match, higher = stronger match)
103
+ * - 0 = batch summary (modifies batch itself)
104
+ * - 1 = first transaction (or single tx)
105
+ * - 2 = second child transaction
106
+ * - etc.
74
107
  *
75
- * @example
76
- * // Match token transfers (tokenType === 0)
77
- * customMatcher: (tx) => {
78
- * let matches = 0
79
- * if (tx.custom?.tokenType === 0) matches++
80
- * if (BigInt(tx.value || 0) > 0) matches++
81
- * return matches
82
- * }
83
- */
84
- customMatcher?: (transaction: DecoderResult) => number;
108
+ * This must match the `index` prop of <transaction-playback>
109
+ */
110
+ transactionIndex: number;
111
+ /**
112
+ * Human-readable explanation of why this modification occurred
113
+ *
114
+ * @example "User enabled force transfer to EOA"
115
+ * @example "Slippage tolerance increased to 2%"
116
+ * @example "Gas limit adjusted for complex operation"
117
+ */
118
+ reason: string;
119
+ /**
120
+ * Whether this modification was triggered by user interaction
121
+ *
122
+ * - true: User clicked checkbox, changed input, adjusted slider, etc.
123
+ * - false: Automatic adjustment by view logic
124
+ */
125
+ userInitiated: boolean;
126
+ /**
127
+ * Optional structured summary for quick display/logging
128
+ */
129
+ summary?: {
130
+ /** Name of the field that changed */
131
+ field: string;
132
+ /** Human-readable old value */
133
+ oldValue: string;
134
+ /** Human-readable new value */
135
+ newValue: string;
136
+ };
137
+ /**
138
+ * Optional validation information
139
+ */
140
+ validation?: {
141
+ /** Whether the modification is valid */
142
+ isValid: boolean;
143
+ /** Error message if invalid */
144
+ error?: string;
145
+ /** Warning messages (modification is valid but user should be aware) */
146
+ warnings?: string[];
147
+ };
85
148
  }
86
149
  /**
87
- * Framework-agnostic view definition
150
+ * Extended modification info added by transaction-playback
151
+ *
152
+ * This is what the top-level container receives after transaction-playback
153
+ * adds context about where in the transaction tree this modification applies.
88
154
  */
89
- interface ViewDefinition {
90
- /** Unique identifier for this view */
91
- id: string;
92
- /** Human-readable name */
93
- name: string;
94
- /** Criteria for matching transactions to this view */
95
- criteria: ViewMatchCriteria;
96
- /** Priority when multiple views match (higher = preferred) */
97
- priority: number;
98
- /** Supported frameworks for this view */
99
- frameworks: FrameworkSupport;
100
- /** Optional description */
101
- description?: string;
155
+ interface TransactionModificationWithContext extends TransactionModification {
156
+ /**
157
+ * Path from root transaction to this transaction
158
+ *
159
+ * @example [1] - Simple transaction at index 1
160
+ * @example [0, 2] - Batch at index 0, child at index 2
161
+ * @example [0, 1, 0] - Nested batch: batch[0].children[1].children[0]
162
+ */
163
+ transactionPath: number[];
164
+ /**
165
+ * The full local transaction object with modified data
166
+ * (Before re-wrapping)
167
+ */
168
+ localTransaction: any;
169
+ /**
170
+ * Re-decoded result for verification
171
+ * Parent should verify this decodes successfully before applying
172
+ */
173
+ decodedResult: any;
102
174
  }
103
175
  /**
104
- * Framework-specific loading configurations
105
- *
106
- * Strategic Framework Selection (Suffering Economics Optimized):
107
- * - lit: Universal web components (works in Vue, React, Angular, Svelte, etc.)
108
- * - vue: Native Vue components (optional, for Vue-specific optimizations)
109
- * - rn: React Native components (mobile-native, optional - falls back to WebView)
110
- *
111
- * Lit is the universal fallback. Vue and React Native are optional native implementations
112
- * that get priority when available in their respective environments.
176
+ * Type-safe custom event for transaction modifications
113
177
  */
114
- interface FrameworkSupport {
115
- lit: FrameworkViewConfig;
116
- vue?: FrameworkViewConfig;
117
- rn?: FrameworkViewConfig;
178
+ interface TransactionModificationEvent extends CustomEvent {
179
+ detail: TransactionModification;
118
180
  }
119
181
  /**
120
- * Configuration for loading a view in a specific framework
182
+ * Event type names for transaction views
121
183
  */
122
- interface FrameworkViewConfig {
123
- /** Loading method */
124
- loader: ViewLoader;
125
- /** Component name/identifier */
126
- component: string;
127
- /** Package where the component is located */
128
- package?: string;
129
- }
184
+ declare const TransactionViewEvents: {
185
+ /**
186
+ * Emitted when a view wants to provide custom header information
187
+ * Parent containers should listen for this event and update their header accordingly
188
+ */
189
+ readonly HEADER_INFO: "header-info";
190
+ /**
191
+ * Emitted when a view modifies its transaction data
192
+ * Parent containers should listen, re-wrap if needed, and update the transaction
193
+ */
194
+ readonly TRANSACTION_MODIFICATION: "transaction-modification";
195
+ /**
196
+ * Emitted when a view's state changes (future use)
197
+ * @example Loading state, error state, interactive state changes
198
+ */
199
+ readonly STATE_CHANGE: "view-state-change";
200
+ /**
201
+ * Emitted when a view has an action for the user (future use)
202
+ * @example "Approve", "Reject", "Sign"
203
+ */
204
+ readonly ACTION: "view-action";
205
+ };
130
206
  /**
131
- * Different ways to load a view component
207
+ * Helper function to dispatch header info event
208
+ * Use this in view components to emit header information
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * import { dispatchHeaderInfo } from '@lukso/transaction-view-headless'
132
213
  *
133
- * Loaders support both static and lazy loading:
134
- * - Static: `path: './Component.vue'` - bundled with app
135
- * - Lazy: `path: () => import('./Component.vue')` - loaded on demand
214
+ * class MyTransferView extends LitElement {
215
+ * connectedCallback() {
216
+ * super.connectedCallback()
217
+ * dispatchHeaderInfo(this, {
218
+ * from: this.transferFrom,
219
+ * to: this.transferTo,
220
+ * title: 'Token Transfer'
221
+ * })
222
+ * }
223
+ * }
224
+ * ```
136
225
  */
137
- type ViewLoader = {
138
- type: 'dynamic-import';
139
- path: string | (() => Promise<any>);
140
- } | {
141
- type: 'static-import';
142
- path: string | (() => Promise<any>);
143
- } | {
144
- type: 'custom-element';
145
- tagName: string;
146
- } | {
147
- type: 'registry-lookup';
148
- registryKey: string;
149
- } | {
150
- type: 'custom';
151
- loader: (config: FrameworkViewConfig) => Promise<any>;
152
- };
226
+ declare function dispatchHeaderInfo(element: HTMLElement, headerInfo: TransactionHeaderInfo): void;
153
227
  /**
154
- * Result of matching a transaction against registered views
228
+ * Type guard to check if an event is a HeaderInfoEvent
155
229
  */
156
- interface ViewMatch {
157
- /** The view definition that matched */
158
- view: ViewDefinition;
159
- /** Score indicating how well this view matches (0-1) */
160
- score: number;
161
- /** Which criteria matched */
162
- matchedCriteria: (keyof ViewMatchCriteria)[];
163
- /** Framework-specific loading config */
164
- frameworkConfig?: FrameworkViewConfig;
165
- }
230
+ declare function isHeaderInfoEvent(event: Event): event is HeaderInfoEvent;
166
231
  /**
167
- * Options for view matching
232
+ * Helper function to dispatch transaction modification event
233
+ * Use this in view components to emit transaction modifications
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * import { dispatchTransactionModification } from '@lukso/transaction-view-headless'
238
+ *
239
+ * class MyTransferView extends LitElement {
240
+ * private handleForceCheckbox(checked: boolean) {
241
+ * const newData = encodeFunctionData({
242
+ * abi: LSP7_ABI,
243
+ * functionName: 'transfer',
244
+ * args: [...args, checked]
245
+ * })
246
+ *
247
+ * dispatchTransactionModification(this, {
248
+ * data: newData,
249
+ * transactionIndex: this.index,
250
+ * reason: 'User enabled force transfer',
251
+ * userInitiated: true
252
+ * })
253
+ * }
254
+ * }
255
+ * ```
168
256
  */
169
- interface ViewMatchOptions {
170
- /** Target framework */
171
- framework: 'lit' | 'vue' | 'rn';
172
- /** Display context (optional) - WHERE to display (feed, approval, list, etc.) */
173
- context?: ViewContext;
174
- /** Display variant (optional) - HOW to display (collapsed, minimal, full, etc.) */
175
- variant?: ViewVariant;
176
- /** Context requirements (optional) - additional constraints for context-aware matching */
177
- contextRequirements?: Partial<ViewContextRequirements>;
178
- /** Minimum score threshold (0-1) */
179
- minScore?: number;
180
- /** Maximum number of matches to return */
181
- maxMatches?: number;
182
- /** Whether to include framework config in results */
183
- includeFrameworkConfig?: boolean;
184
- }
257
+ declare function dispatchTransactionModification(element: HTMLElement, modification: TransactionModification): void;
185
258
  /**
186
- * Registry for managing view definitions
259
+ * Type guard to check if an event is a TransactionModificationEvent
187
260
  */
188
- interface ViewRegistry {
189
- /** Register a new view */
190
- register(view: ViewDefinition): void;
191
- /** Unregister a view by ID */
192
- unregister(viewId: string): void;
193
- /** Get all registered views */
194
- getAllViews(): ViewDefinition[];
195
- /** Find best matching views for a transaction */
196
- findMatches(transaction: DecoderResult, options: ViewMatchOptions): ViewMatch[];
197
- /** Get a specific view by ID */
198
- getView(viewId: string): ViewDefinition | undefined;
199
- /** Clear all registered views */
200
- clear(): void;
201
- }
261
+ declare function isTransactionModificationEvent(event: Event): event is TransactionModificationEvent;
202
262
 
203
- export type { DecoderRecordForSelection, FrameworkSupport, FrameworkViewConfig, ViewContext, ViewContextRequirements, ViewDefinition, ViewLoader, ViewMatch, ViewMatchCriteria, ViewMatchOptions, ViewRegistry, ViewVariant };
263
+ export { type HeaderInfoEvent, type TransactionHeaderInfo, type TransactionModification, type TransactionModificationEvent, type TransactionModificationWithContext, TransactionViewEvents, dispatchHeaderInfo, dispatchTransactionModification, isHeaderInfoEvent, isTransactionModificationEvent };