@lukso/transaction-view-headless 0.4.3-dev.a07a66f → 0.4.3
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.
- package/.turbo/turbo-build.log +29 -31
- package/CONTEXT_VARIANT_GUIDE.md +4 -4
- package/dist/composables/index.cjs +1 -1
- package/dist/composables/index.cjs.map +1 -1
- package/dist/composables/index.d.cts +3 -3
- package/dist/composables/index.d.ts +3 -3
- package/dist/composables/index.js +1 -1
- package/dist/composables/index.js.map +1 -1
- package/dist/{index-CNUHqRdk.d.ts → index-CMLU1hKL.d.ts} +2 -2
- package/dist/{index-BqL7xdDl.d.cts → index-CSDjhiKV.d.cts} +2 -2
- package/dist/index.cjs +1 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +1 -55
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.cts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/types/index.cjs +0 -68
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +169 -229
- package/dist/types/index.d.ts +169 -229
- package/dist/types/index.js +0 -55
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/{view-loader--mEEI8YY.d.ts → view-loader-dD86QAlQ.d.cts} +1 -1
- package/dist/{view-loader-D7ApWfdN.d.cts → view-loader-ii8AxiQR.d.ts} +1 -1
- package/package.json +3 -3
- package/src/composables/use-transaction-playback.ts +5 -8
- package/src/types/index.ts +0 -14
- package/ARG_ACCESS_PATTERN.md +0 -265
- package/EVENT_SYSTEM_SUMMARY.md +0 -601
- package/HEADER_EVENTS_GUIDE.md +0 -291
- package/RECOMPOSITION_REFERENCE.md +0 -303
- package/TRANSACTION_MODIFICATION_GUIDE.md +0 -927
- package/dist/view-matching-C9G3z8lQ.d.cts +0 -203
- package/dist/view-matching-C9G3z8lQ.d.ts +0 -203
- package/src/types/view-events.ts +0 -322
package/dist/types/index.d.ts
CHANGED
|
@@ -1,263 +1,203 @@
|
|
|
1
|
-
|
|
2
|
-
import '@lukso/transaction-decoder';
|
|
1
|
+
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Different contexts WHERE transaction views are displayed
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Context determines the environment/location, which affects:
|
|
7
|
+
* - Available space
|
|
8
|
+
* - User intent
|
|
9
|
+
* - Security requirements
|
|
10
|
+
* - Interaction patterns
|
|
9
11
|
*/
|
|
12
|
+
type ViewContext = 'approval' | 'feed' | 'list' | 'detail' | 'review' | 'notification' | 'embed' | 'batch-summary';
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
14
|
+
* Different variants of HOW transaction views are displayed
|
|
12
15
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
-
* ```
|
|
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
|
|
29
19
|
*/
|
|
30
|
-
|
|
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
|
-
}
|
|
20
|
+
type ViewVariant = 'full' | 'collapsed' | 'minimal' | 'icon-only' | 'compact' | 'expanded' | string;
|
|
62
21
|
/**
|
|
63
|
-
*
|
|
22
|
+
* Context-specific display requirements
|
|
64
23
|
*/
|
|
65
|
-
interface
|
|
66
|
-
|
|
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;
|
|
67
37
|
}
|
|
38
|
+
|
|
39
|
+
type DecoderRecordForSelection = DecoderResult & {
|
|
40
|
+
recordType?: string;
|
|
41
|
+
functionName?: string;
|
|
42
|
+
contractAddress?: string;
|
|
43
|
+
standard?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
68
46
|
/**
|
|
69
|
-
*
|
|
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
|
-
* ```
|
|
47
|
+
* Criteria that can be used to match transactions to views
|
|
91
48
|
*/
|
|
92
|
-
interface
|
|
93
|
-
/**
|
|
94
|
-
|
|
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).
|
|
95
69
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
data: `0x${string}`;
|
|
100
|
-
/**
|
|
101
|
-
* The playback index this modification applies to
|
|
70
|
+
* IMPORTANT: Must be synchronous and only use data from DecoderResult.
|
|
71
|
+
* For async operations, populate transaction.custom in an enhancer.
|
|
102
72
|
*
|
|
103
|
-
*
|
|
104
|
-
* - 1 = first transaction (or single tx)
|
|
105
|
-
* - 2 = second child transaction
|
|
106
|
-
* - etc.
|
|
73
|
+
* @returns Number of matching conditions (0 = no match, higher = stronger match)
|
|
107
74
|
*
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
|
|
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
|
-
};
|
|
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;
|
|
148
85
|
}
|
|
149
86
|
/**
|
|
150
|
-
*
|
|
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.
|
|
87
|
+
* Framework-agnostic view definition
|
|
154
88
|
*/
|
|
155
|
-
interface
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
localTransaction: any;
|
|
169
|
-
/**
|
|
170
|
-
* Re-decoded result for verification
|
|
171
|
-
* Parent should verify this decodes successfully before applying
|
|
172
|
-
*/
|
|
173
|
-
decodedResult: any;
|
|
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;
|
|
174
102
|
}
|
|
175
103
|
/**
|
|
176
|
-
*
|
|
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.
|
|
177
113
|
*/
|
|
178
|
-
interface
|
|
179
|
-
|
|
114
|
+
interface FrameworkSupport {
|
|
115
|
+
lit: FrameworkViewConfig;
|
|
116
|
+
vue?: FrameworkViewConfig;
|
|
117
|
+
rn?: FrameworkViewConfig;
|
|
180
118
|
}
|
|
181
119
|
/**
|
|
182
|
-
*
|
|
120
|
+
* Configuration for loading a view in a specific framework
|
|
183
121
|
*/
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
};
|
|
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
|
+
}
|
|
206
130
|
/**
|
|
207
|
-
*
|
|
208
|
-
* Use this in view components to emit header information
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```typescript
|
|
212
|
-
* import { dispatchHeaderInfo } from '@lukso/transaction-view-headless'
|
|
131
|
+
* Different ways to load a view component
|
|
213
132
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* dispatchHeaderInfo(this, {
|
|
218
|
-
* from: this.transferFrom,
|
|
219
|
-
* to: this.transferTo,
|
|
220
|
-
* title: 'Token Transfer'
|
|
221
|
-
* })
|
|
222
|
-
* }
|
|
223
|
-
* }
|
|
224
|
-
* ```
|
|
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
|
|
225
136
|
*/
|
|
226
|
-
|
|
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
|
+
};
|
|
227
153
|
/**
|
|
228
|
-
*
|
|
154
|
+
* Result of matching a transaction against registered views
|
|
229
155
|
*/
|
|
230
|
-
|
|
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
|
+
}
|
|
231
166
|
/**
|
|
232
|
-
*
|
|
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
|
-
* ```
|
|
167
|
+
* Options for view matching
|
|
256
168
|
*/
|
|
257
|
-
|
|
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
|
+
}
|
|
258
185
|
/**
|
|
259
|
-
*
|
|
186
|
+
* Registry for managing view definitions
|
|
260
187
|
*/
|
|
261
|
-
|
|
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
|
+
}
|
|
262
202
|
|
|
263
|
-
export {
|
|
203
|
+
export type { DecoderRecordForSelection, FrameworkSupport, FrameworkViewConfig, ViewContext, ViewContextRequirements, ViewDefinition, ViewLoader, ViewMatch, ViewMatchCriteria, ViewMatchOptions, ViewRegistry, ViewVariant };
|
package/dist/types/index.js
CHANGED
|
@@ -1,56 +1 @@
|
|
|
1
|
-
// src/types/view-events.ts
|
|
2
|
-
var TransactionViewEvents = {
|
|
3
|
-
/**
|
|
4
|
-
* Emitted when a view wants to provide custom header information
|
|
5
|
-
* Parent containers should listen for this event and update their header accordingly
|
|
6
|
-
*/
|
|
7
|
-
HEADER_INFO: "header-info",
|
|
8
|
-
/**
|
|
9
|
-
* Emitted when a view modifies its transaction data
|
|
10
|
-
* Parent containers should listen, re-wrap if needed, and update the transaction
|
|
11
|
-
*/
|
|
12
|
-
TRANSACTION_MODIFICATION: "transaction-modification",
|
|
13
|
-
/**
|
|
14
|
-
* Emitted when a view's state changes (future use)
|
|
15
|
-
* @example Loading state, error state, interactive state changes
|
|
16
|
-
*/
|
|
17
|
-
STATE_CHANGE: "view-state-change",
|
|
18
|
-
/**
|
|
19
|
-
* Emitted when a view has an action for the user (future use)
|
|
20
|
-
* @example "Approve", "Reject", "Sign"
|
|
21
|
-
*/
|
|
22
|
-
ACTION: "view-action"
|
|
23
|
-
};
|
|
24
|
-
function dispatchHeaderInfo(element, headerInfo) {
|
|
25
|
-
element.dispatchEvent(
|
|
26
|
-
new CustomEvent(TransactionViewEvents.HEADER_INFO, {
|
|
27
|
-
bubbles: true,
|
|
28
|
-
composed: true,
|
|
29
|
-
// Allows event to cross shadow DOM boundaries
|
|
30
|
-
detail: headerInfo
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
function isHeaderInfoEvent(event) {
|
|
35
|
-
return event instanceof CustomEvent && event.type === TransactionViewEvents.HEADER_INFO;
|
|
36
|
-
}
|
|
37
|
-
function dispatchTransactionModification(element, modification) {
|
|
38
|
-
element.dispatchEvent(
|
|
39
|
-
new CustomEvent(TransactionViewEvents.TRANSACTION_MODIFICATION, {
|
|
40
|
-
bubbles: true,
|
|
41
|
-
composed: true,
|
|
42
|
-
detail: modification
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
function isTransactionModificationEvent(event) {
|
|
47
|
-
return event instanceof CustomEvent && event.type === TransactionViewEvents.TRANSACTION_MODIFICATION;
|
|
48
|
-
}
|
|
49
|
-
export {
|
|
50
|
-
TransactionViewEvents,
|
|
51
|
-
dispatchHeaderInfo,
|
|
52
|
-
dispatchTransactionModification,
|
|
53
|
-
isHeaderInfoEvent,
|
|
54
|
-
isTransactionModificationEvent
|
|
55
|
-
};
|
|
56
1
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
2
|
-
import {
|
|
2
|
+
import { ViewDefinition, ViewMatchOptions, ViewMatchCriteria, ViewMatch } from '../types/index.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Weights for different matching criteria (higher = more important)
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
2
|
-
import {
|
|
2
|
+
import { ViewDefinition, ViewMatchOptions, ViewMatchCriteria, ViewMatch } from '../types/index.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Weights for different matching criteria (higher = more important)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukso/transaction-view-headless",
|
|
3
|
-
"version": "0.4.3
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Framework-agnostic transaction decoder and view selection system",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@preact/signals-core": "^1.12.1",
|
|
37
37
|
"@tanstack/query-core": "^5.90.12",
|
|
38
|
-
"viem": "^2.43.
|
|
39
|
-
"@lukso/transaction-decoder": "1.3.3
|
|
38
|
+
"viem": "^2.43.1",
|
|
39
|
+
"@lukso/transaction-decoder": "1.3.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^25.0.3",
|
|
@@ -100,16 +100,13 @@ export interface TransactionPlaybackState {
|
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Check if a transaction is a batch transaction
|
|
103
|
-
*
|
|
104
|
-
* Only executeBatch is a navigable batch where:
|
|
105
|
-
* - Index 0 shows batch summary
|
|
106
|
-
* - Index 1+ shows individual child transactions
|
|
107
|
-
*
|
|
108
|
-
* setDataBatch is NOT a batch - it's a single transaction with a special view
|
|
109
|
-
* that renders all key/value pairs from children.
|
|
110
103
|
*/
|
|
111
104
|
function isBatchTransaction(transaction: DecoderResult): boolean {
|
|
112
|
-
return
|
|
105
|
+
return (
|
|
106
|
+
transaction.resultType === 'executeBatch' ||
|
|
107
|
+
transaction.resultType === 'setDataBatch' ||
|
|
108
|
+
!!(transaction as any).children?.length
|
|
109
|
+
)
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -3,20 +3,6 @@ export type {
|
|
|
3
3
|
ViewContextRequirements,
|
|
4
4
|
ViewVariant,
|
|
5
5
|
} from './view-contexts'
|
|
6
|
-
export type {
|
|
7
|
-
HeaderInfoEvent,
|
|
8
|
-
TransactionHeaderInfo,
|
|
9
|
-
TransactionModification,
|
|
10
|
-
TransactionModificationEvent,
|
|
11
|
-
TransactionModificationWithContext,
|
|
12
|
-
} from './view-events'
|
|
13
|
-
export {
|
|
14
|
-
dispatchHeaderInfo,
|
|
15
|
-
dispatchTransactionModification,
|
|
16
|
-
isHeaderInfoEvent,
|
|
17
|
-
isTransactionModificationEvent,
|
|
18
|
-
TransactionViewEvents,
|
|
19
|
-
} from './view-events'
|
|
20
6
|
export type {
|
|
21
7
|
DecoderRecordForSelection,
|
|
22
8
|
FrameworkSupport,
|