@lukso/transaction-decoder 1.3.0 → 1.3.1-dev.3b54e9f

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