@lukso/transaction-decoder 1.3.6-dev.0a1e0b9 → 1.3.6-dev.184cdf1
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/dist/browser.cjs +13 -203
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +4 -4
- package/dist/cdn/transaction-decoder.global.js +75 -75
- package/dist/cdn/transaction-decoder.global.js.map +1 -1
- package/dist/{chunk-HFBAO6YR.js → chunk-FKBKAWB3.js} +2 -2
- package/dist/{chunk-RYQVLCCC.js → chunk-NDBDNXBI.js} +2 -2
- package/dist/{chunk-MSTGEOTX.js → chunk-SSY7TTU2.js} +4 -4
- package/dist/{chunk-MGPLCACC.js → chunk-T4H2HHIB.js} +8 -198
- package/dist/chunk-T4H2HHIB.js.map +1 -0
- package/dist/data.cjs +7 -197
- package/dist/data.cjs.map +1 -1
- package/dist/data.d.cts +3 -3
- package/dist/data.d.ts +3 -3
- package/dist/data.js +2 -2
- package/dist/{index-BWD9DaG6.d.ts → index-BzXh7poJ.d.cts} +1 -6
- package/dist/{index-BWD9DaG6.d.cts → index-BzXh7poJ.d.ts} +1 -6
- package/dist/index.cjs +13 -203
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/server.cjs +7 -197
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/dist/{utils-OR-XzeYG.d.cts → utils-BEpSreRR.d.cts} +2 -2
- package/dist/{utils-4Qdavg8r.d.ts → utils-De_c6fUK.d.ts} +2 -2
- package/package.json +8 -8
- package/src/decoder/lsp7Mint.test.ts +11 -18
- package/src/decoder/plugins/enhanceLSP0ERC725Account.ts +2 -39
- package/src/decoder/types.ts +0 -2
- package/dist/chunk-MGPLCACC.js.map +0 -1
- package/src/decoder/plugins/universalReceiverTypeIds.ts +0 -277
- /package/dist/{chunk-HFBAO6YR.js.map → chunk-FKBKAWB3.js.map} +0 -0
- /package/dist/{chunk-RYQVLCCC.js.map → chunk-NDBDNXBI.js.map} +0 -0
- /package/dist/{chunk-MSTGEOTX.js.map → chunk-SSY7TTU2.js.map} +0 -0
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import type { AbiParameter, Address, Hex } from 'viem'
|
|
2
|
-
import {
|
|
3
|
-
decodeAbiParameters,
|
|
4
|
-
encodeAbiParameters,
|
|
5
|
-
getAddress,
|
|
6
|
-
keccak256,
|
|
7
|
-
slice,
|
|
8
|
-
toHex,
|
|
9
|
-
} from 'viem'
|
|
10
|
-
import type { ArrayArgs } from '../types'
|
|
11
|
-
import { createNamedArgs } from '../utils'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Result of unwrapping a UniversalReceiver event based on its typeId.
|
|
15
|
-
* Contains the inner event that was wrapped by the UniversalReceiver notification,
|
|
16
|
-
* including rewritten topics and data fields matching the inner event's ABI.
|
|
17
|
-
*/
|
|
18
|
-
export type UnwrapResult = {
|
|
19
|
-
eventName: string
|
|
20
|
-
args: ArrayArgs
|
|
21
|
-
standard?: string
|
|
22
|
-
topics: [Hex, ...Hex[]]
|
|
23
|
-
data: Hex
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type UnwrapFn = (
|
|
27
|
-
receivedData: Hex,
|
|
28
|
-
from: Address,
|
|
29
|
-
profileAddress: Address,
|
|
30
|
-
eventName: string
|
|
31
|
-
) => UnwrapResult | undefined
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Compute topic0 (event signature hash) and ABI-encode the data field
|
|
35
|
-
* for an event with all non-indexed parameters.
|
|
36
|
-
*/
|
|
37
|
-
function encodeEventLog(
|
|
38
|
-
eventName: string,
|
|
39
|
-
params: AbiParameter[],
|
|
40
|
-
values: unknown[]
|
|
41
|
-
): { topics: [Hex, ...Hex[]]; data: Hex } {
|
|
42
|
-
const sig = `${eventName}(${params.map((p) => p.type).join(',')})`
|
|
43
|
-
const topic0 = keccak256(toHex(sig))
|
|
44
|
-
const data = encodeAbiParameters(params, values)
|
|
45
|
-
return { topics: [topic0], data }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// --- LSP26 FollowerSystem ---
|
|
49
|
-
|
|
50
|
-
// keccak256('LSP26FollowerSystem_FollowNotification')
|
|
51
|
-
const TYPEID_LSP26_FOLLOW: Hex =
|
|
52
|
-
'0x71e02f9f05bcd5816ec4f3134aa2e5a916669537ec6c77fe66ea595fabc2d51a'
|
|
53
|
-
|
|
54
|
-
// keccak256('LSP26FollowerSystem_UnfollowNotification')
|
|
55
|
-
const TYPEID_LSP26_UNFOLLOW: Hex =
|
|
56
|
-
'0x9d3c0b4012b69658977b099bdaa51eff0f0460f421fba96d15669506c00d1c4f'
|
|
57
|
-
|
|
58
|
-
// --- LSP7 DigitalAsset ---
|
|
59
|
-
|
|
60
|
-
// keccak256('LSP7Tokens_SenderNotification')
|
|
61
|
-
const TYPEID_LSP7_TOKENSSENDER: Hex =
|
|
62
|
-
'0x429ac7a06903dbc9c13dfcb3c9d11df8194581fa047c96d7a4171fc7402958ea'
|
|
63
|
-
|
|
64
|
-
// keccak256('LSP7Tokens_RecipientNotification')
|
|
65
|
-
const TYPEID_LSP7_TOKENSRECIPIENT: Hex =
|
|
66
|
-
'0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c'
|
|
67
|
-
|
|
68
|
-
// --- LSP8 IdentifiableDigitalAsset ---
|
|
69
|
-
|
|
70
|
-
// keccak256('LSP8Tokens_SenderNotification')
|
|
71
|
-
const TYPEID_LSP8_TOKENSSENDER: Hex =
|
|
72
|
-
'0xb23eae7e6d1564b295b4c3e3be402d9a2f0776c57bdf365903496f6fa481ab00'
|
|
73
|
-
|
|
74
|
-
// keccak256('LSP8Tokens_RecipientNotification')
|
|
75
|
-
const TYPEID_LSP8_TOKENSRECIPIENT: Hex =
|
|
76
|
-
'0x0b084a55ebf70fd3c06fd755269dac2212c4d3f0f4d09079780bfa50c1b2984d'
|
|
77
|
-
|
|
78
|
-
// --- Event parameter definitions ---
|
|
79
|
-
|
|
80
|
-
const followParams: AbiParameter[] = [
|
|
81
|
-
{ name: 'follower', type: 'address' },
|
|
82
|
-
{ name: 'addr', type: 'address' },
|
|
83
|
-
]
|
|
84
|
-
|
|
85
|
-
const unfollowParams: AbiParameter[] = [
|
|
86
|
-
{ name: 'unfollower', type: 'address' },
|
|
87
|
-
{ name: 'addr', type: 'address' },
|
|
88
|
-
]
|
|
89
|
-
|
|
90
|
-
const lsp7TransferParams: AbiParameter[] = [
|
|
91
|
-
{ name: 'operator', type: 'address' },
|
|
92
|
-
{ name: 'from', type: 'address' },
|
|
93
|
-
{ name: 'to', type: 'address' },
|
|
94
|
-
{ name: 'amount', type: 'uint256' },
|
|
95
|
-
{ name: 'force', type: 'bool' },
|
|
96
|
-
{ name: 'data', type: 'bytes' },
|
|
97
|
-
]
|
|
98
|
-
|
|
99
|
-
const lsp8TransferParams: AbiParameter[] = [
|
|
100
|
-
{ name: 'operator', type: 'address' },
|
|
101
|
-
{ name: 'from', type: 'address' },
|
|
102
|
-
{ name: 'to', type: 'address' },
|
|
103
|
-
{ name: 'tokenId', type: 'bytes32' },
|
|
104
|
-
{ name: 'force', type: 'bool' },
|
|
105
|
-
{ name: 'data', type: 'bytes' },
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
const notificationParams: AbiParameter[] = [
|
|
109
|
-
{ name: 'from', type: 'address' },
|
|
110
|
-
{ name: 'typeId', type: 'bytes32' },
|
|
111
|
-
{ name: 'data', type: 'bytes' },
|
|
112
|
-
]
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Decode LSP26 Follow notification.
|
|
116
|
-
* receivedData is abi.encodePacked(followerAddress) — raw 20 bytes.
|
|
117
|
-
*/
|
|
118
|
-
function unwrapLSP26Follow(
|
|
119
|
-
receivedData: Hex,
|
|
120
|
-
_from: Address,
|
|
121
|
-
profileAddress: Address,
|
|
122
|
-
_eventName: string
|
|
123
|
-
): UnwrapResult | undefined {
|
|
124
|
-
if (!receivedData || receivedData.length < 42) {
|
|
125
|
-
return undefined
|
|
126
|
-
}
|
|
127
|
-
const followerAddress = getAddress(slice(receivedData, 0, 20))
|
|
128
|
-
const values = [followerAddress, profileAddress]
|
|
129
|
-
return {
|
|
130
|
-
eventName: 'URDFollow',
|
|
131
|
-
...createNamedArgs(values, followParams),
|
|
132
|
-
...encodeEventLog('URDFollow', followParams, values),
|
|
133
|
-
standard: 'LSP26FollowerSystem',
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Decode LSP26 Unfollow notification.
|
|
139
|
-
* receivedData is abi.encodePacked(unfollowerAddress) — raw 20 bytes.
|
|
140
|
-
*/
|
|
141
|
-
function unwrapLSP26Unfollow(
|
|
142
|
-
receivedData: Hex,
|
|
143
|
-
_from: Address,
|
|
144
|
-
profileAddress: Address,
|
|
145
|
-
_eventName: string
|
|
146
|
-
): UnwrapResult | undefined {
|
|
147
|
-
if (!receivedData || receivedData.length < 42) {
|
|
148
|
-
return undefined
|
|
149
|
-
}
|
|
150
|
-
const unfollowerAddress = getAddress(slice(receivedData, 0, 20))
|
|
151
|
-
const values = [unfollowerAddress, profileAddress]
|
|
152
|
-
return {
|
|
153
|
-
eventName: 'URDUnfollow',
|
|
154
|
-
...createNamedArgs(values, unfollowParams),
|
|
155
|
-
...encodeEventLog('URDUnfollow', unfollowParams, values),
|
|
156
|
-
standard: 'LSP26FollowerSystem',
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Decode LSP7 token transfer notification.
|
|
162
|
-
* receivedData is abi.encode(operator, from, to, amount, data).
|
|
163
|
-
*/
|
|
164
|
-
function unwrapLSP7Transfer(
|
|
165
|
-
receivedData: Hex,
|
|
166
|
-
_from: Address,
|
|
167
|
-
_profileAddress: Address,
|
|
168
|
-
eventName: string
|
|
169
|
-
): UnwrapResult | undefined {
|
|
170
|
-
try {
|
|
171
|
-
const [operator, sender, recipient, amount, data] = decodeAbiParameters(
|
|
172
|
-
[
|
|
173
|
-
{ name: 'operator', type: 'address' },
|
|
174
|
-
{ name: 'from', type: 'address' },
|
|
175
|
-
{ name: 'to', type: 'address' },
|
|
176
|
-
{ name: 'amount', type: 'uint256' },
|
|
177
|
-
{ name: 'data', type: 'bytes' },
|
|
178
|
-
],
|
|
179
|
-
receivedData
|
|
180
|
-
)
|
|
181
|
-
const values = [operator, sender, recipient, amount, true, data]
|
|
182
|
-
return {
|
|
183
|
-
eventName,
|
|
184
|
-
...createNamedArgs(values, lsp7TransferParams),
|
|
185
|
-
...encodeEventLog(eventName, lsp7TransferParams, values),
|
|
186
|
-
standard: 'LSP7DigitalAsset',
|
|
187
|
-
}
|
|
188
|
-
} catch {
|
|
189
|
-
return undefined
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Decode LSP8 token transfer notification.
|
|
195
|
-
* receivedData is abi.encode(operator, from, to, tokenId, data).
|
|
196
|
-
*/
|
|
197
|
-
function unwrapLSP8Transfer(
|
|
198
|
-
receivedData: Hex,
|
|
199
|
-
_from: Address,
|
|
200
|
-
_profileAddress: Address,
|
|
201
|
-
eventName: string
|
|
202
|
-
): UnwrapResult | undefined {
|
|
203
|
-
try {
|
|
204
|
-
const [operator, sender, recipient, tokenId, data] = decodeAbiParameters(
|
|
205
|
-
[
|
|
206
|
-
{ name: 'operator', type: 'address' },
|
|
207
|
-
{ name: 'from', type: 'address' },
|
|
208
|
-
{ name: 'to', type: 'address' },
|
|
209
|
-
{ name: 'tokenId', type: 'bytes32' },
|
|
210
|
-
{ name: 'data', type: 'bytes' },
|
|
211
|
-
],
|
|
212
|
-
receivedData
|
|
213
|
-
)
|
|
214
|
-
const values = [operator, sender, recipient, tokenId, true, data]
|
|
215
|
-
return {
|
|
216
|
-
eventName,
|
|
217
|
-
...createNamedArgs(values, lsp8TransferParams),
|
|
218
|
-
...encodeEventLog(eventName, lsp8TransferParams, values),
|
|
219
|
-
standard: 'LSP8IdentifiableDigitalAsset',
|
|
220
|
-
}
|
|
221
|
-
} catch {
|
|
222
|
-
return undefined
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Registry mapping typeId → unwrap function.
|
|
228
|
-
*/
|
|
229
|
-
const typeIdUnwrappers: Record<Hex, { fn: UnwrapFn; eventName: string }> = {
|
|
230
|
-
[TYPEID_LSP26_FOLLOW]: { fn: unwrapLSP26Follow, eventName: 'Follow' },
|
|
231
|
-
[TYPEID_LSP26_UNFOLLOW]: { fn: unwrapLSP26Unfollow, eventName: 'Unfollow' },
|
|
232
|
-
[TYPEID_LSP7_TOKENSSENDER]: {
|
|
233
|
-
fn: unwrapLSP7Transfer,
|
|
234
|
-
eventName: 'URDTokensSent',
|
|
235
|
-
},
|
|
236
|
-
[TYPEID_LSP7_TOKENSRECIPIENT]: {
|
|
237
|
-
fn: unwrapLSP7Transfer,
|
|
238
|
-
eventName: 'URDTokensReceived',
|
|
239
|
-
},
|
|
240
|
-
[TYPEID_LSP8_TOKENSSENDER]: {
|
|
241
|
-
fn: unwrapLSP8Transfer,
|
|
242
|
-
eventName: 'URDTokensSent',
|
|
243
|
-
},
|
|
244
|
-
[TYPEID_LSP8_TOKENSRECIPIENT]: {
|
|
245
|
-
fn: unwrapLSP8Transfer,
|
|
246
|
-
eventName: 'URDTokensReceived',
|
|
247
|
-
},
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Unwrap a UniversalReceiver event based on its typeId.
|
|
252
|
-
* For known typeIds, decodes receivedData into specific event args.
|
|
253
|
-
* For unknown typeIds, returns a generic Notification with raw receivedData.
|
|
254
|
-
* Always rewrites topics and data to match the inner event's ABI.
|
|
255
|
-
*/
|
|
256
|
-
export function unwrapUniversalReceiver(
|
|
257
|
-
typeId: Hex,
|
|
258
|
-
receivedData: Hex,
|
|
259
|
-
from: Address,
|
|
260
|
-
profileAddress: Address
|
|
261
|
-
): UnwrapResult {
|
|
262
|
-
const entry = typeIdUnwrappers[typeId]
|
|
263
|
-
if (entry) {
|
|
264
|
-
const result = entry.fn(receivedData, from, profileAddress, entry.eventName)
|
|
265
|
-
if (result) {
|
|
266
|
-
return result
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Fallback: generic notification with raw data
|
|
271
|
-
const values = [from, typeId, receivedData]
|
|
272
|
-
return {
|
|
273
|
-
eventName: 'URDNotification',
|
|
274
|
-
...createNamedArgs(values, notificationParams),
|
|
275
|
-
...encodeEventLog('Notification', notificationParams, values),
|
|
276
|
-
}
|
|
277
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|