@lukso/transaction-view-headless 0.4.3-dev.a07a66f → 0.4.3-dev.e33b252

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 (39) hide show
  1. package/.turbo/turbo-build.log +31 -33
  2. package/CONTEXT_VARIANT_GUIDE.md +4 -4
  3. package/dist/composables/index.cjs +1 -1
  4. package/dist/composables/index.cjs.map +1 -1
  5. package/dist/composables/index.d.cts +3 -3
  6. package/dist/composables/index.d.ts +3 -3
  7. package/dist/composables/index.js +1 -1
  8. package/dist/composables/index.js.map +1 -1
  9. package/dist/{index-CNUHqRdk.d.ts → index-CMLU1hKL.d.ts} +2 -2
  10. package/dist/{index-BqL7xdDl.d.cts → index-CSDjhiKV.d.cts} +2 -2
  11. package/dist/index.cjs +1 -60
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +4 -5
  14. package/dist/index.d.ts +4 -5
  15. package/dist/index.js +1 -55
  16. package/dist/index.js.map +1 -1
  17. package/dist/registry/index.d.cts +2 -2
  18. package/dist/registry/index.d.ts +2 -2
  19. package/dist/types/index.cjs +0 -68
  20. package/dist/types/index.cjs.map +1 -1
  21. package/dist/types/index.d.cts +169 -229
  22. package/dist/types/index.d.ts +169 -229
  23. package/dist/types/index.js +0 -55
  24. package/dist/types/index.js.map +1 -1
  25. package/dist/utils/index.d.cts +1 -1
  26. package/dist/utils/index.d.ts +1 -1
  27. package/dist/{view-loader--mEEI8YY.d.ts → view-loader-dD86QAlQ.d.cts} +1 -1
  28. package/dist/{view-loader-D7ApWfdN.d.cts → view-loader-ii8AxiQR.d.ts} +1 -1
  29. package/package.json +3 -3
  30. package/src/composables/use-transaction-playback.ts +5 -8
  31. package/src/types/index.ts +0 -14
  32. package/ARG_ACCESS_PATTERN.md +0 -265
  33. package/EVENT_SYSTEM_SUMMARY.md +0 -601
  34. package/HEADER_EVENTS_GUIDE.md +0 -291
  35. package/RECOMPOSITION_REFERENCE.md +0 -303
  36. package/TRANSACTION_MODIFICATION_GUIDE.md +0 -927
  37. package/dist/view-matching-C9G3z8lQ.d.cts +0 -203
  38. package/dist/view-matching-C9G3z8lQ.d.ts +0 -203
  39. package/src/types/view-events.ts +0 -322
@@ -1,265 +0,0 @@
1
- # Accessing Transaction Arguments - Correct Pattern
2
-
3
- ## Current Structure (As of Latest Version)
4
-
5
- Transaction arguments are stored in an `args` array with this structure:
6
-
7
- ```typescript
8
- interface DecoderResult {
9
- // ...
10
- args: Array<{
11
- name: string // Argument name (e.g., "from", "to", "amount")
12
- type: string // Solidity type (e.g., "address", "uint256")
13
- value: any // The actual value
14
- internalType?: string // Internal type if different (rarely used)
15
- }>
16
- }
17
- ```
18
-
19
- ## ❌ Old Pattern (Don't Use)
20
-
21
- ```typescript
22
- // OLD - namedArgs is deprecated
23
- const from = transaction.namedArgs?.from
24
- const to = transaction.namedArgs?.to
25
- const amount = transaction.namedArgs?.amount
26
- ```
27
-
28
- ## ✅ Correct Pattern
29
-
30
- ### Use the Built-in Helper
31
-
32
- The `@lukso/transaction-decoder` package exports a `getArgByName` helper:
33
-
34
- ```typescript
35
- import { getArgByName } from '@lukso/transaction-decoder'
36
-
37
- // Get individual args
38
- const from = getArgByName(transaction.args, 'from') as string | undefined
39
- const to = getArgByName(transaction.args, 'to') as string | undefined
40
- const amount = getArgByName(transaction.args, 'amount') as bigint | undefined
41
- const force = (getArgByName(transaction.args, 'force') as boolean) ?? false
42
- const data = (getArgByName(transaction.args, 'data') as string) ?? '0x'
43
- ```
44
-
45
- ### Implementation (for reference)
46
-
47
- ```typescript
48
- /**
49
- * Get argument value by name from transaction args array
50
- * Already exported from @lukso/transaction-decoder
51
- */
52
- export function getArgByName(
53
- args: ArrayArgs | undefined,
54
- name: string
55
- ): unknown {
56
- if (!args) return undefined
57
- const arg = args.find((arg) => arg.name === name)
58
- return arg?.value
59
- }
60
- ```
61
-
62
- ### In View Components
63
-
64
- ```typescript
65
- import { getArgByName } from '@lukso/transaction-decoder'
66
- import { dispatchHeaderInfo, dispatchTransactionModification } from '@lukso/transaction-view-headless'
67
-
68
- @customElement('lsp7-transfer-view')
69
- export class LSP7TransferView extends CoreLitElement {
70
- @property({ type: Object }) transaction!: DecoderResult
71
-
72
- connectedCallback() {
73
- super.connectedCallback()
74
-
75
- // Emit header info
76
- dispatchHeaderInfo(this, {
77
- from: getArgByName(this.transaction.args, 'from') as string,
78
- to: getArgByName(this.transaction.args, 'to') as string,
79
- title: 'LSP7 Transfer'
80
- })
81
- }
82
-
83
- private handleForceChange(checked: boolean) {
84
- // Re-encode with updated argument
85
- const newData = encodeFunctionData({
86
- abi: LSP7_ABI,
87
- functionName: 'transfer',
88
- args: [
89
- getArgByName(this.transaction.args, 'from'),
90
- getArgByName(this.transaction.args, 'to'),
91
- getArgByName(this.transaction.args, 'amount'),
92
- checked, // <-- modified
93
- getArgByName(this.transaction.args, 'data') ?? '0x'
94
- ]
95
- })
96
-
97
- dispatchTransactionModification(this, {
98
- data: newData,
99
- transactionIndex: this.index,
100
- reason: 'User enabled force transfer',
101
- userInitiated: true
102
- })
103
- }
104
- }
105
- ```
106
-
107
- ### In Recomposition Logic
108
-
109
- ```typescript
110
- import { getArgByName } from '@lukso/transaction-decoder'
111
-
112
- private async recomposeWrapper(wrapper: DecoderResult): Promise<string> {
113
- switch (wrapper.functionName) {
114
- case 'execute':
115
- return encodeFunctionData({
116
- abi: UP_ABI,
117
- functionName: 'execute',
118
- args: [
119
- getArgByName(wrapper.args, 'operationType') as number,
120
- getArgByName(wrapper.args, 'target') as string,
121
- getArgByName(wrapper.args, 'value') as bigint,
122
- wrapper.children[0].data // <-- updated child data
123
- ]
124
- })
125
-
126
- case 'executeBatch':
127
- return encodeFunctionData({
128
- abi: UP_ABI,
129
- functionName: 'executeBatch',
130
- args: [
131
- getArgByName(wrapper.args, 'operationTypes') as number[],
132
- getArgByName(wrapper.args, 'targets') as string[],
133
- getArgByName(wrapper.args, 'values') as bigint[],
134
- wrapper.children.map(child => child.data) // <-- updated children
135
- ]
136
- })
137
-
138
- case 'executeRelayCall':
139
- return encodeFunctionData({
140
- abi: KEY_MANAGER_ABI,
141
- functionName: 'executeRelayCall',
142
- args: [
143
- getArgByName(wrapper.args, 'signature') as string,
144
- getArgByName(wrapper.args, 'nonce') as bigint,
145
- getArgByName(wrapper.args, 'validityTimestamps') as bigint,
146
- wrapper.children[0].data // <-- updated execute/executeBatch
147
- ]
148
- })
149
- }
150
- }
151
- ```
152
-
153
- ## Migration Guide
154
-
155
- ### Before (namedArgs - deprecated)
156
-
157
- ```typescript
158
- // Header info
159
- dispatchHeaderInfo(this, {
160
- from: this.transaction.namedArgs?.from,
161
- to: this.transaction.namedArgs?.to
162
- })
163
-
164
- // Recompose wrapper
165
- encodeFunctionData({
166
- abi: UP_ABI,
167
- functionName: 'execute',
168
- args: [
169
- wrapper.namedArgs.operationType,
170
- wrapper.namedArgs.target,
171
- wrapper.namedArgs.value,
172
- wrapper.children[0].data
173
- ]
174
- })
175
- ```
176
-
177
- ### After (args array with getArgByName)
178
-
179
- ```typescript
180
- import { getArgByName } from '@lukso/transaction-decoder'
181
-
182
- // Header info
183
- dispatchHeaderInfo(this, {
184
- from: getArgByName(this.transaction.args, 'from') as string,
185
- to: getArgByName(this.transaction.args, 'to') as string
186
- })
187
-
188
- // Recompose wrapper
189
- encodeFunctionData({
190
- abi: UP_ABI,
191
- functionName: 'execute',
192
- args: [
193
- getArgByName(wrapper.args, 'operationType') as number,
194
- getArgByName(wrapper.args, 'target') as string,
195
- getArgByName(wrapper.args, 'value') as bigint,
196
- wrapper.children[0].data
197
- ]
198
- })
199
- ```
200
-
201
- ## Type Safety
202
-
203
- For better type safety, you can create typed getters:
204
-
205
- ```typescript
206
- class TransactionArgHelper {
207
- constructor(private tx: DecoderResult) {}
208
-
209
- getString(name: string): string | undefined {
210
- return this.tx.args?.find(arg => arg.name === name)?.value as string
211
- }
212
-
213
- getBigInt(name: string): bigint | undefined {
214
- return this.tx.args?.find(arg => arg.name === name)?.value as bigint
215
- }
216
-
217
- getBoolean(name: string): boolean | undefined {
218
- return this.tx.args?.find(arg => arg.name === name)?.value as boolean
219
- }
220
-
221
- getAddress(name: string): string | undefined {
222
- return this.getString(name) // Addresses are strings
223
- }
224
-
225
- getArray<T>(name: string): T[] | undefined {
226
- return this.tx.args?.find(arg => arg.name === name)?.value as T[]
227
- }
228
- }
229
-
230
- // Usage
231
- const helper = new TransactionArgHelper(transaction)
232
- const from = helper.getAddress('from')
233
- const amount = helper.getBigInt('amount')
234
- const force = helper.getBoolean('force') ?? false
235
- ```
236
-
237
- ## Summary
238
-
239
- **Key Change**: `transaction.namedArgs.foo` → `getArgByName(transaction.args, 'foo')`
240
-
241
- **Always use `getArgByName` from `@lukso/transaction-decoder` to access arguments by name from the `args` array.**
242
-
243
- ### Quick Reference
244
-
245
- ```typescript
246
- import { getArgByName } from '@lukso/transaction-decoder'
247
-
248
- // Extract args
249
- const from = getArgByName(transaction.args, 'from') as string
250
- const to = getArgByName(transaction.args, 'to') as string
251
- const amount = getArgByName(transaction.args, 'amount') as bigint
252
- const force = (getArgByName(transaction.args, 'force') as boolean) ?? false
253
-
254
- // In recomposition
255
- encodeFunctionData({
256
- abi: UP_ABI,
257
- functionName: 'execute',
258
- args: [
259
- getArgByName(wrapper.args, 'operationType') as number,
260
- getArgByName(wrapper.args, 'target') as string,
261
- getArgByName(wrapper.args, 'value') as bigint,
262
- wrapper.children[0].data
263
- ]
264
- })
265
- ```