@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.
Files changed (71) hide show
  1. package/dist/browser.cjs +73 -41
  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-2ZO6MJJX.js → chunk-G7JZHSYX.js} +12 -11
  9. package/dist/chunk-G7JZHSYX.js.map +1 -0
  10. package/dist/{chunk-FKBKAWB3.js → chunk-GGBHTWJL.js} +5 -5
  11. package/dist/chunk-GGBHTWJL.js.map +1 -0
  12. package/dist/{chunk-NDBDNXBI.js → chunk-GXZOF3QY.js} +27 -3
  13. package/dist/chunk-GXZOF3QY.js.map +1 -0
  14. package/dist/{chunk-T4H2HHIB.js → chunk-XVHJWV5U.js} +32 -25
  15. package/dist/chunk-XVHJWV5U.js.map +1 -0
  16. package/dist/data.cjs +62 -31
  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 +73 -41
  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 +43 -31
  27. package/dist/server.cjs.map +1 -1
  28. package/dist/server.d.cts +2 -1
  29. package/dist/server.d.ts +2 -1
  30. package/dist/server.js +12 -7
  31. package/dist/server.js.map +1 -1
  32. package/dist/{utils-BEpSreRR.d.cts → utils-CBAkjQh3.d.cts} +1 -1
  33. package/dist/{utils-De_c6fUK.d.ts → utils-xT9-km0r.d.ts} +1 -1
  34. package/package.json +3 -3
  35. package/src/core/dataModel.ts +31 -1
  36. package/src/core/integrateDecoder.ts +2 -1
  37. package/src/decoder/browserCache.ts +6 -1
  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 +6 -1
  44. package/src/decoder/lruCache.ts +6 -1
  45. package/src/decoder/lsp7TransferBatch.test.ts +3 -0
  46. package/src/decoder/plugins/enhanceBurntPix.ts +2 -1
  47. package/src/decoder/plugins/enhanceGraffiti.ts +17 -3
  48. package/src/decoder/plugins/enhanceLSP26FollowerSystem.ts +8 -4
  49. package/src/decoder/plugins/enhanceLSP6KeyManager.ts +1 -0
  50. package/src/decoder/plugins/enhanceLSP7DigitalAsset.ts +7 -5
  51. package/src/decoder/plugins/enhanceLSP9Vault.ts +8 -7
  52. package/src/decoder/plugins/enhanceRetrieveAbi.ts +6 -5
  53. package/src/decoder/plugins/index.ts +1 -3
  54. package/src/decoder/plugins/schemaDefault.ts +4 -3
  55. package/src/decoder/plugins/standardPlugin.ts +1 -1
  56. package/src/decoder/singleGQL.ts +2 -2
  57. package/src/decoder/transaction.ts +2 -1
  58. package/src/decoder/utils.ts +2 -2
  59. package/src/example/usage.ts +4 -3
  60. package/src/server/addressResolver.ts +1 -1
  61. package/src/server/decodeTransactionSync.ts +1 -0
  62. package/src/server/decodeTransactionsBatch.ts +1 -1
  63. package/src/server/finishDecoding.ts +8 -4
  64. package/src/server/lsp23Resolver.ts +3 -2
  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-2ZO6MJJX.js.map +0 -1
  69. package/dist/chunk-FKBKAWB3.js.map +0 -1
  70. package/dist/chunk-NDBDNXBI.js.map +0 -1
  71. package/dist/chunk-T4H2HHIB.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as TransactionAddressResolver, T as TransactionDecoderResult, i as consumerModel, l as createAggregationKey, j as createGlobalInstance, a as decodeTransaction, k as decodeTransactionAsync, m as defaultPlugins, n as defaultSchemaPlugins, p as getArgByName, q as needsEnhancement, o as standardPlugin, s as standardSchemaPlugin } from './utils-BEpSreRR.cjs';
1
+ export { A as TransactionAddressResolver, T as TransactionDecoderResult, i as consumerModel, l as createAggregationKey, j as createGlobalInstance, a as decodeTransaction, k as decodeTransactionAsync, m as defaultPlugins, n as defaultSchemaPlugins, p as getArgByName, q as needsEnhancement, o as standardPlugin, s as standardSchemaPlugin } from './utils-CBAkjQh3.cjs';
2
2
  import * as viem from 'viem';
3
3
  import { Chain, Hex, Address } from 'viem';
4
4
  import * as _preact_signals_core from '@preact/signals-core';
@@ -716,7 +716,7 @@ declare const JSONbigString: {
716
716
  /**
717
717
  * Stringify an object, converting BigInt values to strings with 'n' suffix
718
718
  */
719
- stringify: (obj: any, _replacer?: any, space?: string | number) => string;
719
+ stringify: (obj: any, replacer?: any, space?: string | number) => string;
720
720
  /**
721
721
  * Parse a JSON string, converting strings ending with 'n' back to BigInt
722
722
  */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as TransactionAddressResolver, T as TransactionDecoderResult, i as consumerModel, l as createAggregationKey, j as createGlobalInstance, a as decodeTransaction, k as decodeTransactionAsync, m as defaultPlugins, n as defaultSchemaPlugins, p as getArgByName, q as needsEnhancement, o as standardPlugin, s as standardSchemaPlugin } from './utils-De_c6fUK.js';
1
+ export { A as TransactionAddressResolver, T as TransactionDecoderResult, i as consumerModel, l as createAggregationKey, j as createGlobalInstance, a as decodeTransaction, k as decodeTransactionAsync, m as defaultPlugins, n as defaultSchemaPlugins, p as getArgByName, q as needsEnhancement, o as standardPlugin, s as standardSchemaPlugin } from './utils-xT9-km0r.js';
2
2
  import * as viem from 'viem';
3
3
  import { Chain, Hex, Address } from 'viem';
4
4
  import * as _preact_signals_core from '@preact/signals-core';
@@ -716,7 +716,7 @@ declare const JSONbigString: {
716
716
  /**
717
717
  * Stringify an object, converting BigInt values to strings with 'n' suffix
718
718
  */
719
- stringify: (obj: any, _replacer?: any, space?: string | number) => string;
719
+ stringify: (obj: any, replacer?: any, space?: string | number) => string;
720
720
  /**
721
721
  * Parse a JSON string, converting strings ending with 'n' back to BigInt
722
722
  */
package/dist/index.js CHANGED
@@ -35,19 +35,19 @@ import {
35
35
  parseLSP23DeploymentsFromHypersync,
36
36
  resolveAddresses,
37
37
  subscribe
38
- } from "./chunk-2ZO6MJJX.js";
38
+ } from "./chunk-G7JZHSYX.js";
39
39
  import {
40
40
  consumerModel,
41
41
  createGlobalInstance,
42
42
  decodeTransaction,
43
43
  decodeTransactionAsync
44
- } from "./chunk-NDBDNXBI.js";
44
+ } from "./chunk-GXZOF3QY.js";
45
45
  import {
46
46
  fetchMultipleAddresses,
47
47
  fetchProfilesByControllers,
48
48
  getGraphQLEndpoint,
49
49
  getImage
50
- } from "./chunk-FKBKAWB3.js";
50
+ } from "./chunk-GGBHTWJL.js";
51
51
  import {
52
52
  PluginAggregationEngine,
53
53
  collectDataKeys,
@@ -65,7 +65,7 @@ import {
65
65
  standardAggregation,
66
66
  standardPlugin,
67
67
  standardSchemaPlugin
68
- } from "./chunk-T4H2HHIB.js";
68
+ } from "./chunk-XVHJWV5U.js";
69
69
  export {
70
70
  AddressResolver,
71
71
  DEPLOY_ERC1167_PROXIES_SELECTOR,
package/dist/server.cjs CHANGED
@@ -201,7 +201,7 @@ async function fetchMultipleAddresses(addresses, graphqlEndpoint, cache) {
201
201
  }
202
202
  if (data.Token) {
203
203
  for (const token of data.Token) {
204
- const { id: _id, baseAsset, tokenId, ...rest } = token;
204
+ const { id, baseAsset, tokenId, ...rest } = token;
205
205
  if (baseAsset?.id && tokenId) {
206
206
  const enhancedInfo = {
207
207
  address: baseAsset.id,
@@ -326,8 +326,9 @@ query ProfilesByController($controllerAddresses: [String!]) {
326
326
 
327
327
  // src/server/addressResolver.ts
328
328
  var ServerAddressResolver = class {
329
- constructor(graphqlEndpoint, _chain, caches2) {
329
+ constructor(graphqlEndpoint, chain, caches2) {
330
330
  this.graphqlEndpoint = graphqlEndpoint;
331
+ this.chain = chain;
331
332
  this.caches = caches2;
332
333
  this.cacheAdapter = {
333
334
  get: /* @__PURE__ */ __name((key) => this.caches.getAddress(key), "get"),
@@ -967,7 +968,7 @@ async function decodeTransaction(fullTransaction, options) {
967
968
  phase: "enhanced"
968
969
  };
969
970
  }
970
- let _lastError;
971
+ let lastError;
971
972
  const activePlugins = options.plugins;
972
973
  for (const plugin of activePlugins) {
973
974
  if (to && isAddress(to) && isAddressEqual(to, zeroAddress)) {
@@ -1030,6 +1031,7 @@ async function decodeTransaction(fullTransaction, options) {
1030
1031
  }
1031
1032
  } catch (e) {
1032
1033
  console.error(e);
1034
+ continue;
1033
1035
  }
1034
1036
  }
1035
1037
  let phase = "functionName" in transaction && transaction.functionName && transaction.standard || transaction.input === "0x" || !transaction.input ? "enhanced" : "immediate";
@@ -1249,7 +1251,7 @@ async function decodeTransactionsBatch(transactions, options, caches2) {
1249
1251
  }
1250
1252
  return decodeTransaction(tx, enhancedOptionsArray[i]);
1251
1253
  });
1252
- const _remainingTime = timeoutMs * 0.6 - phase1Time;
1254
+ const remainingTime = timeoutMs * 0.6 - phase1Time;
1253
1255
  const enhancedResults = await Promise.all(enhancePromises);
1254
1256
  enhancedResults.forEach((enhanced, i) => {
1255
1257
  if (enhanced) {
@@ -1358,15 +1360,19 @@ __name(createDebug, "createDebug");
1358
1360
  var debug_default = createDebug;
1359
1361
 
1360
1362
  // src/server/finishDecoding.ts
1361
- var _debug = createDebug("decoder:finishDecoding");
1363
+ var debug = createDebug("decoder:finishDecoding");
1362
1364
  async function finishDecoding(transaction, options, caches2) {
1363
1365
  const startTime = Date.now();
1364
- const { chain } = options;
1366
+ const {
1367
+ timeoutMs = 5e3,
1368
+ // Give more time for finishing
1369
+ chain
1370
+ } = options;
1365
1371
  try {
1366
1372
  const txHash = transaction.hash || transaction.transactionHash;
1367
1373
  if (txHash) {
1368
1374
  const cached = caches2.getTransaction(txHash);
1369
- if (cached?.enhancementAttempted) {
1375
+ if (cached && cached.enhancementAttempted) {
1370
1376
  return {
1371
1377
  ...cached,
1372
1378
  cached: true,
@@ -1834,7 +1840,7 @@ var getDataFromExternalSources = /* @__PURE__ */ __name((schemas, dataFromChain,
1834
1840
  urlDataWithHash,
1835
1841
  ipfsGateway
1836
1842
  ));
1837
- let _length = "unknown";
1843
+ let length = "unknown";
1838
1844
  if (!url.startsWith("data:") && /[=?/]$/.test(url)) {
1839
1845
  return dataEntry;
1840
1846
  }
@@ -1846,7 +1852,7 @@ var getDataFromExternalSources = /* @__PURE__ */ __name((schemas, dataFromChain,
1846
1852
  }
1847
1853
  return response.arrayBuffer().then((buffer) => new Uint8Array(buffer));
1848
1854
  });
1849
- _length = receivedData.length.toString();
1855
+ length = receivedData.length.toString();
1850
1856
  const captureHashes = {};
1851
1857
  const captureErrors = [];
1852
1858
  if (receivedData.length >= 2) {
@@ -1966,7 +1972,7 @@ function decodeKeyValuePlugin(defaultSchema2, process2) {
1966
1972
  });
1967
1973
  if (schema) {
1968
1974
  try {
1969
- const name = schema.name.replace(/[:[\]]|<.*?>/g, "");
1975
+ const name = schema.name.replace(/[:\[\]]|<.*?>/g, "");
1970
1976
  if (schema.keyType === "Array") {
1971
1977
  if (schema.key === key) {
1972
1978
  const hexString = value.slice(2);
@@ -1974,7 +1980,7 @@ function decodeKeyValuePlugin(defaultSchema2, process2) {
1974
1980
  for (let i = 0; i < hexString.length; i += 2) {
1975
1981
  all[i / 2] = Number.parseInt(hexString.substring(i, i + 2), 16);
1976
1982
  }
1977
- const [{ start: _start, end } = { start: 0, end: 0 }] = all.reduce(
1983
+ const [{ start, end } = { start: 0, end: 0 }] = all.reduce(
1978
1984
  (acc, byte, index_) => {
1979
1985
  let isZero = byte === 0 || index_ === 0;
1980
1986
  const last = acc.at(-1);
@@ -2040,7 +2046,7 @@ function decodeKeyValuePlugin(defaultSchema2, process2) {
2040
2046
  value: data2
2041
2047
  };
2042
2048
  }
2043
- let dynamicKeyParts;
2049
+ let dynamicKeyParts = void 0;
2044
2050
  if (isDynamicKeyName(schema.name)) {
2045
2051
  dynamicKeyParts = decodeMappingKey(key, schema).map(
2046
2052
  ({ value: value2 }) => isHex2(value2) ? value2.toLowerCase() : `${value2}`
@@ -2298,7 +2304,7 @@ function standardAggregation(config) {
2298
2304
  return Object.freeze(config);
2299
2305
  }
2300
2306
  __name(standardAggregation, "standardAggregation");
2301
- var debug = debug_default("decoder:aggregation");
2307
+ var debug2 = debug_default("decoder:aggregation");
2302
2308
 
2303
2309
  // src/decoder/events.ts
2304
2310
  import {
@@ -2405,9 +2411,9 @@ function customDecodeEventLog(parameters) {
2405
2411
  };
2406
2412
  }
2407
2413
  __name(customDecodeEventLog, "customDecodeEventLog");
2408
- function decodeEvent(_chain, abi3, log) {
2409
- const { data: _data } = log;
2410
- let _lastError;
2414
+ function decodeEvent(chain, abi3, log) {
2415
+ const { data: _data, address, ...rest } = log;
2416
+ let lastError;
2411
2417
  try {
2412
2418
  const result = customDecodeEventLog({
2413
2419
  abi: abi3,
@@ -3059,7 +3065,7 @@ var enhanceBurntPixPlugin = standardPlugin(
3059
3065
  aggregations: [refineAggregation]
3060
3066
  }
3061
3067
  );
3062
- async function enhanceBurntPix(result, pluginOptions, _options) {
3068
+ async function enhanceBurntPix(result, pluginOptions, options) {
3063
3069
  if ("functionName" in result && result.functionName === "refine") {
3064
3070
  return {
3065
3071
  ...result,
@@ -3074,20 +3080,25 @@ __name(enhanceBurntPix, "enhanceBurntPix");
3074
3080
  var enhanceBurntPix_default = enhanceBurntPixPlugin;
3075
3081
 
3076
3082
  // src/decoder/plugins/enhanceGraffiti.ts
3077
- import { bytesToString, hexToBytes, size as size3, slice as slice3 } from "viem";
3083
+ import {
3084
+ bytesToString,
3085
+ hexToBytes,
3086
+ size as size3,
3087
+ slice as slice3
3088
+ } from "viem";
3078
3089
  var enhanceGraffitiPlugin = Object.freeze({
3079
3090
  enhance: /* @__PURE__ */ __name(async (result, options) => enhanceGraffiti(
3080
3091
  result,
3081
3092
  { abiName: "graffiti", decoderName: "graffiti" },
3082
3093
  options
3083
3094
  ), "enhance"),
3084
- decodeEvent: /* @__PURE__ */ __name(async (_log, _options) => void 0, "decodeEvent"),
3095
+ decodeEvent: /* @__PURE__ */ __name(async (log, options) => void 0, "decodeEvent"),
3085
3096
  required: true,
3086
3097
  priority: 1e3,
3087
3098
  name: "graffiti"
3088
3099
  });
3089
3100
  async function enhanceGraffiti(result, _pluginOptions, _options) {
3090
- const { input } = result;
3101
+ const { functionName, sig, args, input } = result;
3091
3102
  if (input && size3(input || "0x") >= 4 && slice3(input || "0x", 0, 4) === "0x00000000") {
3092
3103
  let graffiti = slice3(input, 4);
3093
3104
  try {
@@ -4006,6 +4017,7 @@ async function enhanceKeyManager(result, pluginOptions, options) {
4006
4017
  sig,
4007
4018
  args,
4008
4019
  input,
4020
+ blockNumber,
4009
4021
  to: _to,
4010
4022
  from: _from,
4011
4023
  value
@@ -4275,7 +4287,7 @@ async function enhanceLSP7Metadata(result, options) {
4275
4287
  }
4276
4288
  __name(enhanceLSP7Metadata, "enhanceLSP7Metadata");
4277
4289
  async function enhanceLSP26FollowerSystem(result, _pluginOptions, _options) {
4278
- const { functionName } = result;
4290
+ const { functionName, sig, args, input, blockNumber, to, from, value } = result;
4279
4291
  switch (functionName) {
4280
4292
  }
4281
4293
  return void 0;
@@ -4435,8 +4447,8 @@ var enhanceLSP9VaultPlugin = standardPlugin(
4435
4447
  }, "decodeEvent")
4436
4448
  }
4437
4449
  );
4438
- async function enhanceLSP9Vault(result, _pluginOptions, _options) {
4439
- const { functionName } = result;
4450
+ async function enhanceLSP9Vault(result, pluginOptions, options) {
4451
+ const { functionName, sig, args, input, blockNumber, to, from, value } = result;
4440
4452
  switch (functionName) {
4441
4453
  }
4442
4454
  return void 0;
@@ -4467,7 +4479,7 @@ var enhanceLSP26FollowerSystemPlugin = standardPlugin(
4467
4479
  }
4468
4480
  );
4469
4481
  async function enhanceLSP26FollowerSystem2(result, _pluginOptions, _options) {
4470
- const { functionName, args } = result;
4482
+ const { functionName, sig, args, input, blockNumber, to, from, value } = result;
4471
4483
  const { args: _args, ...partialResult } = result;
4472
4484
  switch (functionName) {
4473
4485
  case "follow":
@@ -4483,6 +4495,7 @@ async function enhanceLSP26FollowerSystem2(result, _pluginOptions, _options) {
4483
4495
  }
4484
4496
  ]
4485
4497
  };
4498
+ break;
4486
4499
  case "followBatch":
4487
4500
  case "unfollowBatch":
4488
4501
  return {
@@ -4494,6 +4507,7 @@ async function enhanceLSP26FollowerSystem2(result, _pluginOptions, _options) {
4494
4507
  address
4495
4508
  }))
4496
4509
  };
4510
+ break;
4497
4511
  }
4498
4512
  return void 0;
4499
4513
  }
@@ -5209,7 +5223,7 @@ var LRUDecoderCache = class {
5209
5223
  if (cached && (!cached.expires || now < cached.expires)) {
5210
5224
  return cached.value;
5211
5225
  }
5212
- if (cached?.stale && now < cached.stale && !this.promises.has(key)) {
5226
+ if (cached && cached.stale && now < cached.stale && !this.promises.has(key)) {
5213
5227
  const backgroundPromise = factory(options?.signal).then(async (fresh) => {
5214
5228
  await this.set(key, fresh, options);
5215
5229
  return fresh;
@@ -5291,7 +5305,7 @@ async function fetchAbi(chain, address, options) {
5291
5305
  let isProxy = false;
5292
5306
  let decoderVerifiedContract = false;
5293
5307
  let factoryName;
5294
- const _originalKey = key;
5308
+ const originalKey = key;
5295
5309
  const addressUrl = new URL(`/api/v2/addresses/${key}`, explorer);
5296
5310
  const addressRes = await fetch(addressUrl, { signal });
5297
5311
  if (addressRes.ok) {
@@ -5459,7 +5473,7 @@ var getFunctionSignature = /* @__PURE__ */ __name(async (chain, input, to, prefe
5459
5473
  __decoder: methods.__decoder || FUNCTION_DICTIONARY_URL
5460
5474
  };
5461
5475
  }
5462
- } catch (_error) {
5476
+ } catch (error) {
5463
5477
  }
5464
5478
  }
5465
5479
  }
@@ -5498,7 +5512,7 @@ var enhanceRetrieveAbiPlugin = standardPlugin(
5498
5512
  }
5499
5513
  );
5500
5514
  async function enhanceRetrieveAbi(result, _pluginOptions, options) {
5501
- const { input, to, from, value } = result;
5515
+ const { functionName, sig, args, input, blockNumber, to, from, value } = result;
5502
5516
  try {
5503
5517
  const decoded = await getFunctionSignature(
5504
5518
  options.chain,
@@ -5525,9 +5539,7 @@ __name(enhanceRetrieveAbi, "enhanceRetrieveAbi");
5525
5539
  var enhanceRetrieveAbi_default = enhanceRetrieveAbiPlugin;
5526
5540
 
5527
5541
  // src/decoder/plugins/index.ts
5528
- [enhanceLSP0ERC725Account_default, enhanceLSP6KeyManager_default, enhanceLSP7DigitalAsset_default, enhanceLSP8IdentifiableDigitalAsset_default, enhanceLSP9Vault_default, enhanceLSP26FollowerSystem_default, enhanceBurntPix_default].forEach((p) => {
5529
- p;
5530
- });
5542
+ [enhanceLSP0ERC725Account_default, enhanceLSP6KeyManager_default, enhanceLSP7DigitalAsset_default, enhanceLSP8IdentifiableDigitalAsset_default, enhanceLSP9Vault_default, enhanceLSP26FollowerSystem_default, enhanceBurntPix_default].forEach((p) => p);
5531
5543
  var defaultPlugins = Object.freeze([
5532
5544
  enhanceGraffiti_default,
5533
5545
  enhanceLSP6KeyManager_default,