@lukso/transaction-decoder 1.3.0-dev.c21633f → 1.3.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.
- package/dist/browser.cjs +73 -41
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +4 -4
- package/dist/cdn/transaction-decoder.global.js +13 -13
- package/dist/cdn/transaction-decoder.global.js.map +1 -1
- package/dist/{chunk-2ZO6MJJX.js → chunk-G7JZHSYX.js} +12 -11
- package/dist/chunk-G7JZHSYX.js.map +1 -0
- package/dist/{chunk-FKBKAWB3.js → chunk-GGBHTWJL.js} +5 -5
- package/dist/chunk-GGBHTWJL.js.map +1 -0
- package/dist/{chunk-NDBDNXBI.js → chunk-GXZOF3QY.js} +27 -3
- package/dist/chunk-GXZOF3QY.js.map +1 -0
- package/dist/{chunk-T4H2HHIB.js → chunk-XVHJWV5U.js} +32 -25
- package/dist/chunk-XVHJWV5U.js.map +1 -0
- package/dist/data.cjs +62 -31
- package/dist/data.cjs.map +1 -1
- package/dist/data.d.cts +2 -2
- package/dist/data.d.ts +2 -2
- package/dist/data.js +2 -2
- package/dist/index.cjs +73 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/server.cjs +43 -31
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +2 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.js +12 -7
- package/dist/server.js.map +1 -1
- package/dist/{utils-BEpSreRR.d.cts → utils-CBAkjQh3.d.cts} +1 -1
- package/dist/{utils-De_c6fUK.d.ts → utils-xT9-km0r.d.ts} +1 -1
- package/package.json +3 -3
- package/src/core/dataModel.ts +31 -1
- package/src/core/integrateDecoder.ts +2 -1
- package/src/decoder/browserCache.ts +6 -1
- package/src/decoder/errors.ts +2 -2
- package/src/decoder/events.ts +3 -3
- package/src/decoder/functionSignature.ts +9 -9
- package/src/decoder/getDataFromExternalSources.ts +2 -2
- package/src/decoder/interfaces.ts +1 -1
- package/src/decoder/kvCache.ts +6 -1
- package/src/decoder/lruCache.ts +6 -1
- package/src/decoder/lsp7TransferBatch.test.ts +3 -0
- package/src/decoder/plugins/enhanceBurntPix.ts +2 -1
- package/src/decoder/plugins/enhanceGraffiti.ts +17 -3
- package/src/decoder/plugins/enhanceLSP26FollowerSystem.ts +8 -4
- package/src/decoder/plugins/enhanceLSP6KeyManager.ts +1 -0
- package/src/decoder/plugins/enhanceLSP7DigitalAsset.ts +7 -5
- package/src/decoder/plugins/enhanceLSP9Vault.ts +8 -7
- package/src/decoder/plugins/enhanceRetrieveAbi.ts +6 -5
- package/src/decoder/plugins/index.ts +1 -3
- package/src/decoder/plugins/schemaDefault.ts +4 -3
- package/src/decoder/plugins/standardPlugin.ts +1 -1
- package/src/decoder/singleGQL.ts +2 -2
- package/src/decoder/transaction.ts +2 -1
- package/src/decoder/utils.ts +2 -2
- package/src/example/usage.ts +4 -3
- package/src/server/addressResolver.ts +1 -1
- package/src/server/decodeTransactionSync.ts +1 -0
- package/src/server/decodeTransactionsBatch.ts +1 -1
- package/src/server/finishDecoding.ts +8 -4
- package/src/server/lsp23Resolver.ts +3 -2
- package/src/server/types.ts +1 -1
- package/src/shared/addressResolver.ts +4 -4
- package/src/utils/json-bigint.ts +4 -4
- package/dist/chunk-2ZO6MJJX.js.map +0 -1
- package/dist/chunk-FKBKAWB3.js.map +0 -1
- package/dist/chunk-NDBDNXBI.js.map +0 -1
- package/dist/chunk-T4H2HHIB.js.map +0 -1
package/dist/data.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/core/dataModel.ts
|
|
5
5
|
import { batch, effect, signal } from "@preact/signals-core";
|
|
6
|
-
import { isHex as isHex2, size as size2 } from "viem";
|
|
6
|
+
import { hexToBigInt, isHex as isHex2, size as size2, slice as slice2 } from "viem";
|
|
7
7
|
|
|
8
8
|
// src/core/addressCollector.ts
|
|
9
9
|
import { isHex, size } from "viem";
|
|
@@ -215,6 +215,30 @@ var DataModel = class {
|
|
|
215
215
|
constructor(options = {}) {
|
|
216
216
|
this.options = options;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Extract a 20-byte address from a potentially 32-byte hex value
|
|
220
|
+
* If the input is 32 bytes, validates it's zero-padded and takes the rightmost 20 bytes
|
|
221
|
+
* If the input is 20 bytes, returns it as-is
|
|
222
|
+
*/
|
|
223
|
+
extractAddress(hex) {
|
|
224
|
+
if (!isHex2(hex)) {
|
|
225
|
+
throw new Error(`Invalid hex value: ${hex}`);
|
|
226
|
+
}
|
|
227
|
+
const bytes = size2(hex);
|
|
228
|
+
if (bytes === 32) {
|
|
229
|
+
const first12Bytes = slice2(hex, 0, 12);
|
|
230
|
+
if (hexToBigInt(first12Bytes) !== 0n) {
|
|
231
|
+
throw new Error(
|
|
232
|
+
`Invalid 32-byte address: first 12 bytes must be zero for a padded address, got ${first12Bytes}`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
return slice2(hex, 12, 32);
|
|
236
|
+
}
|
|
237
|
+
if (bytes === 20) {
|
|
238
|
+
return hex;
|
|
239
|
+
}
|
|
240
|
+
throw new Error(`Invalid address length: ${bytes} bytes`);
|
|
241
|
+
}
|
|
218
242
|
/**
|
|
219
243
|
* Get or create a signal for a specific key
|
|
220
244
|
*/
|
|
@@ -1305,7 +1329,7 @@ Object.freeze(PluginRegistry);
|
|
|
1305
1329
|
var pluginRegistry = new PluginRegistry();
|
|
1306
1330
|
|
|
1307
1331
|
// src/decoder/transaction.ts
|
|
1308
|
-
import { isAddress, isAddressEqual, slice as
|
|
1332
|
+
import { isAddress, isAddressEqual, slice as slice3, zeroAddress } from "viem";
|
|
1309
1333
|
async function decodeTransaction(fullTransaction, options) {
|
|
1310
1334
|
const { preferError } = options;
|
|
1311
1335
|
const {
|
|
@@ -1331,7 +1355,7 @@ async function decodeTransaction(fullTransaction, options) {
|
|
|
1331
1355
|
isDecoded: true,
|
|
1332
1356
|
functionName: void 0,
|
|
1333
1357
|
__decoder: void 0,
|
|
1334
|
-
sig:
|
|
1358
|
+
sig: slice3(data || "0x", 0, 4),
|
|
1335
1359
|
resultType: "error",
|
|
1336
1360
|
errorType: "INVALID" /* INVALID */,
|
|
1337
1361
|
...createNamedArgs([], []),
|
|
@@ -1345,13 +1369,13 @@ async function decodeTransaction(fullTransaction, options) {
|
|
|
1345
1369
|
functionName: void 0,
|
|
1346
1370
|
__decoder: void 0,
|
|
1347
1371
|
standard: void 0,
|
|
1348
|
-
sig:
|
|
1372
|
+
sig: slice3(data || "0x", 0, 4),
|
|
1349
1373
|
...createNamedArgs([], []),
|
|
1350
1374
|
resultType: "execute",
|
|
1351
1375
|
phase: "enhanced"
|
|
1352
1376
|
};
|
|
1353
1377
|
}
|
|
1354
|
-
let
|
|
1378
|
+
let lastError;
|
|
1355
1379
|
const activePlugins = options.plugins;
|
|
1356
1380
|
for (const plugin of activePlugins) {
|
|
1357
1381
|
if (to && isAddress(to) && isAddressEqual(to, zeroAddress)) {
|
|
@@ -1414,6 +1438,7 @@ async function decodeTransaction(fullTransaction, options) {
|
|
|
1414
1438
|
}
|
|
1415
1439
|
} catch (e) {
|
|
1416
1440
|
console.error(e);
|
|
1441
|
+
continue;
|
|
1417
1442
|
}
|
|
1418
1443
|
}
|
|
1419
1444
|
let phase = "functionName" in transaction && transaction.functionName && transaction.standard || transaction.input === "0x" || !transaction.input ? "enhanced" : "immediate";
|
|
@@ -1432,7 +1457,7 @@ async function decodeTransaction(fullTransaction, options) {
|
|
|
1432
1457
|
__decoder: void 0,
|
|
1433
1458
|
resultType: "raw",
|
|
1434
1459
|
phase,
|
|
1435
|
-
sig:
|
|
1460
|
+
sig: slice3(
|
|
1436
1461
|
fullTransaction.input || "data" in fullTransaction && fullTransaction.data || "0x",
|
|
1437
1462
|
0,
|
|
1438
1463
|
4
|
|
@@ -1701,9 +1726,9 @@ function customDecodeEventLog(parameters) {
|
|
|
1701
1726
|
};
|
|
1702
1727
|
}
|
|
1703
1728
|
__name(customDecodeEventLog, "customDecodeEventLog");
|
|
1704
|
-
function decodeEvent(
|
|
1705
|
-
const { data: _data } = log;
|
|
1706
|
-
let
|
|
1729
|
+
function decodeEvent(chain, abi3, log) {
|
|
1730
|
+
const { data: _data, address, ...rest } = log;
|
|
1731
|
+
let lastError;
|
|
1707
1732
|
try {
|
|
1708
1733
|
const result = customDecodeEventLog({
|
|
1709
1734
|
abi: abi3,
|
|
@@ -1785,7 +1810,7 @@ var getDataFromExternalSources = /* @__PURE__ */ __name((schemas, dataFromChain,
|
|
|
1785
1810
|
urlDataWithHash,
|
|
1786
1811
|
ipfsGateway
|
|
1787
1812
|
));
|
|
1788
|
-
let
|
|
1813
|
+
let length = "unknown";
|
|
1789
1814
|
if (!url.startsWith("data:") && /[=?/]$/.test(url)) {
|
|
1790
1815
|
return dataEntry;
|
|
1791
1816
|
}
|
|
@@ -1797,7 +1822,7 @@ var getDataFromExternalSources = /* @__PURE__ */ __name((schemas, dataFromChain,
|
|
|
1797
1822
|
}
|
|
1798
1823
|
return response.arrayBuffer().then((buffer) => new Uint8Array(buffer));
|
|
1799
1824
|
});
|
|
1800
|
-
|
|
1825
|
+
length = receivedData.length.toString();
|
|
1801
1826
|
const captureHashes = {};
|
|
1802
1827
|
const captureErrors = [];
|
|
1803
1828
|
if (receivedData.length >= 2) {
|
|
@@ -1917,7 +1942,7 @@ function decodeKeyValuePlugin(defaultSchema2, process2) {
|
|
|
1917
1942
|
});
|
|
1918
1943
|
if (schema) {
|
|
1919
1944
|
try {
|
|
1920
|
-
const name = schema.name.replace(/[
|
|
1945
|
+
const name = schema.name.replace(/[:\[\]]|<.*?>/g, "");
|
|
1921
1946
|
if (schema.keyType === "Array") {
|
|
1922
1947
|
if (schema.key === key) {
|
|
1923
1948
|
const hexString = value.slice(2);
|
|
@@ -1925,7 +1950,7 @@ function decodeKeyValuePlugin(defaultSchema2, process2) {
|
|
|
1925
1950
|
for (let i = 0; i < hexString.length; i += 2) {
|
|
1926
1951
|
all[i / 2] = Number.parseInt(hexString.substring(i, i + 2), 16);
|
|
1927
1952
|
}
|
|
1928
|
-
const [{ start
|
|
1953
|
+
const [{ start, end } = { start: 0, end: 0 }] = all.reduce(
|
|
1929
1954
|
(acc, byte, index_) => {
|
|
1930
1955
|
let isZero = byte === 0 || index_ === 0;
|
|
1931
1956
|
const last = acc.at(-1);
|
|
@@ -1991,7 +2016,7 @@ function decodeKeyValuePlugin(defaultSchema2, process2) {
|
|
|
1991
2016
|
value: data2
|
|
1992
2017
|
};
|
|
1993
2018
|
}
|
|
1994
|
-
let dynamicKeyParts;
|
|
2019
|
+
let dynamicKeyParts = void 0;
|
|
1995
2020
|
if (isDynamicKeyName(schema.name)) {
|
|
1996
2021
|
dynamicKeyParts = decodeMappingKey(key, schema).map(
|
|
1997
2022
|
({ value: value2 }) => isHex3(value2) ? value2.toLowerCase() : `${value2}`
|
|
@@ -2932,7 +2957,7 @@ var enhanceBurntPixPlugin = standardPlugin(
|
|
|
2932
2957
|
aggregations: [refineAggregation]
|
|
2933
2958
|
}
|
|
2934
2959
|
);
|
|
2935
|
-
async function enhanceBurntPix(result, pluginOptions,
|
|
2960
|
+
async function enhanceBurntPix(result, pluginOptions, options) {
|
|
2936
2961
|
if ("functionName" in result && result.functionName === "refine") {
|
|
2937
2962
|
return {
|
|
2938
2963
|
...result,
|
|
@@ -2947,22 +2972,27 @@ __name(enhanceBurntPix, "enhanceBurntPix");
|
|
|
2947
2972
|
var enhanceBurntPix_default = enhanceBurntPixPlugin;
|
|
2948
2973
|
|
|
2949
2974
|
// src/decoder/plugins/enhanceGraffiti.ts
|
|
2950
|
-
import {
|
|
2975
|
+
import {
|
|
2976
|
+
bytesToString,
|
|
2977
|
+
hexToBytes,
|
|
2978
|
+
size as size4,
|
|
2979
|
+
slice as slice4
|
|
2980
|
+
} from "viem";
|
|
2951
2981
|
var enhanceGraffitiPlugin = Object.freeze({
|
|
2952
2982
|
enhance: /* @__PURE__ */ __name(async (result, options) => enhanceGraffiti(
|
|
2953
2983
|
result,
|
|
2954
2984
|
{ abiName: "graffiti", decoderName: "graffiti" },
|
|
2955
2985
|
options
|
|
2956
2986
|
), "enhance"),
|
|
2957
|
-
decodeEvent: /* @__PURE__ */ __name(async (
|
|
2987
|
+
decodeEvent: /* @__PURE__ */ __name(async (log, options) => void 0, "decodeEvent"),
|
|
2958
2988
|
required: true,
|
|
2959
2989
|
priority: 1e3,
|
|
2960
2990
|
name: "graffiti"
|
|
2961
2991
|
});
|
|
2962
2992
|
async function enhanceGraffiti(result, _pluginOptions, _options) {
|
|
2963
|
-
const { input } = result;
|
|
2964
|
-
if (input && size4(input || "0x") >= 4 &&
|
|
2965
|
-
let graffiti =
|
|
2993
|
+
const { functionName, sig, args, input } = result;
|
|
2994
|
+
if (input && size4(input || "0x") >= 4 && slice4(input || "0x", 0, 4) === "0x00000000") {
|
|
2995
|
+
let graffiti = slice4(input, 4);
|
|
2966
2996
|
try {
|
|
2967
2997
|
graffiti = bytesToString(hexToBytes(graffiti));
|
|
2968
2998
|
} catch {
|
|
@@ -3879,6 +3909,7 @@ async function enhanceKeyManager(result, pluginOptions, options) {
|
|
|
3879
3909
|
sig,
|
|
3880
3910
|
args,
|
|
3881
3911
|
input,
|
|
3912
|
+
blockNumber,
|
|
3882
3913
|
to: _to,
|
|
3883
3914
|
from: _from,
|
|
3884
3915
|
value
|
|
@@ -4148,7 +4179,7 @@ async function enhanceLSP7Metadata(result, options) {
|
|
|
4148
4179
|
}
|
|
4149
4180
|
__name(enhanceLSP7Metadata, "enhanceLSP7Metadata");
|
|
4150
4181
|
async function enhanceLSP26FollowerSystem(result, _pluginOptions, _options) {
|
|
4151
|
-
const { functionName } = result;
|
|
4182
|
+
const { functionName, sig, args, input, blockNumber, to, from, value } = result;
|
|
4152
4183
|
switch (functionName) {
|
|
4153
4184
|
}
|
|
4154
4185
|
return void 0;
|
|
@@ -4308,8 +4339,8 @@ var enhanceLSP9VaultPlugin = standardPlugin(
|
|
|
4308
4339
|
}, "decodeEvent")
|
|
4309
4340
|
}
|
|
4310
4341
|
);
|
|
4311
|
-
async function enhanceLSP9Vault(result,
|
|
4312
|
-
const { functionName } = result;
|
|
4342
|
+
async function enhanceLSP9Vault(result, pluginOptions, options) {
|
|
4343
|
+
const { functionName, sig, args, input, blockNumber, to, from, value } = result;
|
|
4313
4344
|
switch (functionName) {
|
|
4314
4345
|
}
|
|
4315
4346
|
return void 0;
|
|
@@ -4340,7 +4371,7 @@ var enhanceLSP26FollowerSystemPlugin = standardPlugin(
|
|
|
4340
4371
|
}
|
|
4341
4372
|
);
|
|
4342
4373
|
async function enhanceLSP26FollowerSystem2(result, _pluginOptions, _options) {
|
|
4343
|
-
const { functionName, args } = result;
|
|
4374
|
+
const { functionName, sig, args, input, blockNumber, to, from, value } = result;
|
|
4344
4375
|
const { args: _args, ...partialResult } = result;
|
|
4345
4376
|
switch (functionName) {
|
|
4346
4377
|
case "follow":
|
|
@@ -4356,6 +4387,7 @@ async function enhanceLSP26FollowerSystem2(result, _pluginOptions, _options) {
|
|
|
4356
4387
|
}
|
|
4357
4388
|
]
|
|
4358
4389
|
};
|
|
4390
|
+
break;
|
|
4359
4391
|
case "followBatch":
|
|
4360
4392
|
case "unfollowBatch":
|
|
4361
4393
|
return {
|
|
@@ -4367,6 +4399,7 @@ async function enhanceLSP26FollowerSystem2(result, _pluginOptions, _options) {
|
|
|
4367
4399
|
address
|
|
4368
4400
|
}))
|
|
4369
4401
|
};
|
|
4402
|
+
break;
|
|
4370
4403
|
}
|
|
4371
4404
|
return void 0;
|
|
4372
4405
|
}
|
|
@@ -5082,7 +5115,7 @@ var LRUDecoderCache = class {
|
|
|
5082
5115
|
if (cached && (!cached.expires || now < cached.expires)) {
|
|
5083
5116
|
return cached.value;
|
|
5084
5117
|
}
|
|
5085
|
-
if (cached
|
|
5118
|
+
if (cached && cached.stale && now < cached.stale && !this.promises.has(key)) {
|
|
5086
5119
|
const backgroundPromise = factory(options?.signal).then(async (fresh) => {
|
|
5087
5120
|
await this.set(key, fresh, options);
|
|
5088
5121
|
return fresh;
|
|
@@ -5164,7 +5197,7 @@ async function fetchAbi(chain, address, options) {
|
|
|
5164
5197
|
let isProxy = false;
|
|
5165
5198
|
let decoderVerifiedContract = false;
|
|
5166
5199
|
let factoryName;
|
|
5167
|
-
const
|
|
5200
|
+
const originalKey = key;
|
|
5168
5201
|
const addressUrl = new URL(`/api/v2/addresses/${key}`, explorer);
|
|
5169
5202
|
const addressRes = await fetch(addressUrl, { signal: signal3 });
|
|
5170
5203
|
if (addressRes.ok) {
|
|
@@ -5332,7 +5365,7 @@ var getFunctionSignature = /* @__PURE__ */ __name(async (chain, input, to, prefe
|
|
|
5332
5365
|
__decoder: methods.__decoder || FUNCTION_DICTIONARY_URL
|
|
5333
5366
|
};
|
|
5334
5367
|
}
|
|
5335
|
-
} catch (
|
|
5368
|
+
} catch (error) {
|
|
5336
5369
|
}
|
|
5337
5370
|
}
|
|
5338
5371
|
}
|
|
@@ -5371,7 +5404,7 @@ var enhanceRetrieveAbiPlugin = standardPlugin(
|
|
|
5371
5404
|
}
|
|
5372
5405
|
);
|
|
5373
5406
|
async function enhanceRetrieveAbi(result, _pluginOptions, options) {
|
|
5374
|
-
const { input, to, from, value } = result;
|
|
5407
|
+
const { functionName, sig, args, input, blockNumber, to, from, value } = result;
|
|
5375
5408
|
try {
|
|
5376
5409
|
const decoded = await getFunctionSignature(
|
|
5377
5410
|
options.chain,
|
|
@@ -5398,9 +5431,7 @@ __name(enhanceRetrieveAbi, "enhanceRetrieveAbi");
|
|
|
5398
5431
|
var enhanceRetrieveAbi_default = enhanceRetrieveAbiPlugin;
|
|
5399
5432
|
|
|
5400
5433
|
// src/decoder/plugins/index.ts
|
|
5401
|
-
[enhanceLSP0ERC725Account_default, enhanceLSP6KeyManager_default, enhanceLSP7DigitalAsset_default, enhanceLSP8IdentifiableDigitalAsset_default, enhanceLSP9Vault_default, enhanceLSP26FollowerSystem_default, enhanceBurntPix_default].forEach((p) =>
|
|
5402
|
-
p;
|
|
5403
|
-
});
|
|
5434
|
+
[enhanceLSP0ERC725Account_default, enhanceLSP6KeyManager_default, enhanceLSP7DigitalAsset_default, enhanceLSP8IdentifiableDigitalAsset_default, enhanceLSP9Vault_default, enhanceLSP26FollowerSystem_default, enhanceBurntPix_default].forEach((p) => p);
|
|
5404
5435
|
var defaultPlugins = Object.freeze([
|
|
5405
5436
|
enhanceGraffiti_default,
|
|
5406
5437
|
enhanceLSP6KeyManager_default,
|