@lukso/transaction-decoder 1.3.0 → 1.3.1-dev.360c7b1

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
@@ -46,7 +46,6 @@ export async function enhanceKeyManager(
46
46
  sig,
47
47
  args,
48
48
  input,
49
- blockNumber,
50
49
  to: _to,
51
50
  from: _from,
52
51
  value,
@@ -8,7 +8,6 @@ import {
8
8
  import type { AbiParameter } from 'viem'
9
9
  import { CacheKeyPrefix, makeCacheKey } from '../cache'
10
10
  import { decodeEvent } from '../events'
11
- import { pluginRegistry } from '../registry'
12
11
  import type {
13
12
  DecodeEventResult,
14
13
  DecoderOptions,
@@ -151,12 +150,11 @@ export async function enhanceLSP26FollowerSystem(
151
150
  _pluginOptions: PluginOptions,
152
151
  _options: DecoderOptions
153
152
  ) {
154
- const { functionName, sig, args, input, blockNumber, to, from, value } =
155
- result as ResultType & {
156
- sig?: `0x${string}`
157
- functionName?: string
158
- args: Array<AbiParameter & { value?: unknown }>
159
- }
153
+ const { functionName } = result as ResultType & {
154
+ sig?: `0x${string}`
155
+ functionName?: string
156
+ args: Array<AbiParameter & { value?: unknown }>
157
+ }
160
158
  switch (functionName) {
161
159
  }
162
160
  return undefined
@@ -40,15 +40,14 @@ export const enhanceLSP9VaultPlugin = standardPlugin(
40
40
  */
41
41
  export async function enhanceLSP9Vault(
42
42
  result: ResultType & ResultShared & { moduleHint?: string },
43
- pluginOptions: PluginOptions,
44
- options: DecoderOptions
43
+ _pluginOptions: PluginOptions,
44
+ _options: DecoderOptions
45
45
  ) {
46
- const { functionName, sig, args, input, blockNumber, to, from, value } =
47
- result as ResultType & {
48
- sig?: `0x${string}`
49
- functionName?: string
50
- args: Array<AbiParameter & { value?: unknown }>
51
- }
46
+ const { functionName } = result as ResultType & {
47
+ sig?: `0x${string}`
48
+ functionName?: string
49
+ args: Array<AbiParameter & { value?: unknown }>
50
+ }
52
51
  switch (functionName) {
53
52
  }
54
53
  return undefined
@@ -54,12 +54,11 @@ export async function enhanceRetrieveAbi(
54
54
  _pluginOptions: PluginOptions,
55
55
  options: DecoderOptions
56
56
  ) {
57
- const { functionName, sig, args, input, blockNumber, to, from, value } =
58
- result as ResultType & {
59
- sig?: `0x${string}`
60
- functionName?: string
61
- args: Array<AbiParameter & { value?: unknown }>
62
- }
57
+ const { input, to, from, value } = result as ResultType & {
58
+ sig?: `0x${string}`
59
+ functionName?: string
60
+ args: Array<AbiParameter & { value?: unknown }>
61
+ }
63
62
  try {
64
63
  const decoded = await getFunctionSignature(
65
64
  options.chain,
@@ -19,7 +19,9 @@ import schemaDefaultPlugin from './schemaDefault'
19
19
 
20
20
  // Force evaluation of plugins to ensure they register (prevent tree-shaking)
21
21
  // These plugins self-register via standardPlugin when imported
22
- ;[profile, keyManager, lsp7, lsp8, lsp9, lsp26, burntPix].forEach((p) => p)
22
+ ;[profile, keyManager, lsp7, lsp8, lsp9, lsp26, burntPix].forEach((p) => {
23
+ p
24
+ })
23
25
 
24
26
  import type { Hex } from 'viem'
25
27
  import type {
@@ -48,7 +48,7 @@ export function decodeKeyValuePlugin(
48
48
  if (schema) {
49
49
  try {
50
50
  // Get the raw name.
51
- const name = schema.name.replace(/[:\[\]]|<.*?>/g, '')
51
+ const name = schema.name.replace(/[:[\]]|<.*?>/g, '')
52
52
  if (schema.keyType === 'Array') {
53
53
  if (schema.key === key) {
54
54
  // Convert hex string to Uint8Array without using Buffer
@@ -59,7 +59,7 @@ export function decodeKeyValuePlugin(
59
59
  }
60
60
  // Figure out the first and last byte of the value (this is to allow
61
61
  // the older and newer ways to store the array length i.e. uint256, uint128 and so on.)
62
- const [{ start, end } = { start: 0, end: 0 }] = all.reduce(
62
+ const [{ start: _start, end } = { start: 0, end: 0 }] = all.reduce(
63
63
  (
64
64
  acc: Array<{ isZero: boolean; start: number; end: number }>,
65
65
  byte,
@@ -145,7 +145,7 @@ export function decodeKeyValuePlugin(
145
145
  }
146
146
  }
147
147
  // Decode dynamic parts.
148
- let dynamicKeyParts: string[] | string | undefined = undefined
148
+ let dynamicKeyParts: string[] | string | undefined
149
149
  if (isDynamicKeyName(schema.name)) {
150
150
  dynamicKeyParts = decodeMappingKey(key, schema).map(({ value }) =>
151
151
  isHex(value) ? (value as string).toLowerCase() : `${value}`
@@ -167,7 +167,6 @@ export function decodeKeyValuePlugin(
167
167
  defaultSchema
168
168
  ) as unknown as Record<string, unknown>[])
169
169
  : [{ value: undefined }]
170
- type Params = Parameters<typeof getDataFromExternalSources>
171
170
  let data = rawData?.[0]?.value
172
171
  // Some special cases.
173
172
  if (schema.name === 'LSP8TokenMetadataBaseURI') {
@@ -1,5 +1,5 @@
1
1
  import type { ERC725JSONSchema } from '@erc725/erc725.js'
2
- import type { Abi, AbiParameter, Hex, Log, Transaction } from 'viem'
2
+ import type { Abi, AbiParameter, Log, Transaction } from 'viem'
3
3
  import { pluginRegistry } from '../registry'
4
4
  import type {
5
5
  Aggregation,
@@ -192,7 +192,7 @@ export function subscribeToProfile(
192
192
  avatars,
193
193
  links,
194
194
  tags,
195
- controllers,
195
+ controllers: _controllers,
196
196
  ...rest
197
197
  } = prof || {}
198
198
  if (!id) {
@@ -274,7 +274,7 @@ export async function fetchProfile(
274
274
  avatars,
275
275
  links,
276
276
  tags,
277
- controllers,
277
+ controllers: _controllers,
278
278
  ...rest
279
279
  } = profile || {}
280
280
  if (!id) {
@@ -64,7 +64,7 @@ export async function decodeTransaction(
64
64
  phase: 'enhanced',
65
65
  } as DecoderResult
66
66
  }
67
- let lastError: Error | undefined
67
+ let _lastError: Error | undefined
68
68
 
69
69
  // The caller is responsible for providing the appropriate plugin set
70
70
  // For sync-only decoding, use pluginRegistry.getAll({ syncOnly: true })
@@ -148,7 +148,6 @@ export async function decodeTransaction(
148
148
  }
149
149
  } catch (e) {
150
150
  console.error(e)
151
- continue
152
151
  }
153
152
  }
154
153
  let phase: 'immediate' | 'enhanced' | 'complete' =
@@ -8,7 +8,7 @@ import {
8
8
  createPublicClient,
9
9
  type DecodeFunctionDataParameters,
10
10
  decodeAbiParameters,
11
- Hex,
11
+ type Hex,
12
12
  http,
13
13
  type PublicClient,
14
14
  slice,
@@ -30,7 +30,7 @@ import type {
30
30
  */
31
31
  export function customDecodeFunctionData<
32
32
  const abi extends Abi | readonly unknown[],
33
- preferError = false,
33
+ _preferError = false,
34
34
  >(
35
35
  parameters: Partial<
36
36
  DecodeFunctionDataParameters<abi> & {
@@ -1,12 +1,11 @@
1
1
  import debug from 'debug'
2
- import type { Transaction } from 'viem'
3
2
  import { lukso } from 'viem/chains'
4
3
  import { createDataModel } from '../data'
5
4
  import {
6
5
  AddressResolver,
7
6
  createMemoryAddressCache,
8
7
  DecoderIntegration,
9
- DecoderResult,
8
+ type DecoderResult,
10
9
  } from '../index'
11
10
 
12
11
  const setupDecoderLog = debug('app:setupDecoder')
@@ -122,7 +121,7 @@ export async function handleTransactionBatch(transactions: DecoderResult[]) {
122
121
  * Example of manual address resolution
123
122
  */
124
123
  export async function resolveAddresses() {
125
- const { dataModel, decoder } = await setupDecoder()
124
+ const { decoder } = await setupDecoder()
126
125
 
127
126
  // Get missing addresses
128
127
  const missing = decoder.getMissingAddresses()
@@ -139,7 +138,7 @@ export async function resolveAddresses() {
139
138
  }
140
139
 
141
140
  // Mock function for example
142
- async function fetchAddressDataFromAPI(addresses: unknown[]) {
141
+ async function fetchAddressDataFromAPI(_addresses: unknown[]) {
143
142
  // This would be your actual API call
144
143
  return []
145
144
  }
@@ -12,7 +12,7 @@ export class ServerAddressResolver {
12
12
 
13
13
  constructor(
14
14
  private graphqlEndpoint: string,
15
- private chain: Chain,
15
+ _chain: Chain,
16
16
  private caches: ServerDecoderCaches
17
17
  ) {
18
18
  // Create adapter to use ServerDecoderCaches as AddressIdentityCache
@@ -1,4 +1,3 @@
1
- import type { Transaction } from 'viem'
2
1
  import { collectDataKeys } from '../core/addressCollector'
3
2
  import { pluginRegistry } from '../decoder/registry'
4
3
  import { decodeTransaction as decodeTransactionCore } from '../decoder/transaction'
@@ -111,7 +111,7 @@ export async function decodeTransactionsBatch(
111
111
  })
112
112
 
113
113
  // Wait for all enhancements with remaining time budget
114
- const remainingTime = timeoutMs * 0.6 - phase1Time
114
+ const _remainingTime = timeoutMs * 0.6 - phase1Time
115
115
  const enhancedResults = await Promise.all(enhancePromises)
116
116
 
117
117
  // Update results with enhanced data
@@ -1,12 +1,11 @@
1
- import { collectDataKeys } from '../core/addressCollector'
2
1
  import { pluginRegistry } from '../decoder/registry'
3
2
  import { decodeTransaction as decodeTransactionCore } from '../decoder/transaction'
4
- import type { DecoderResult, ResultShared } from '../decoder/types'
3
+ import type { DecoderResult } from '../decoder/types'
5
4
  import { createDebug } from '../utils/debug'
6
5
  import type { ServerDecoderCaches } from './caches'
7
6
  import type { ServerDecoderOptions } from './types'
8
7
 
9
- const debug = createDebug('decoder:finishDecoding')
8
+ const _debug = createDebug('decoder:finishDecoding')
10
9
 
11
10
  /**
12
11
  * Finish decoding a transaction by running enhancement phase
@@ -18,17 +17,14 @@ export async function finishDecoding(
18
17
  caches: ServerDecoderCaches
19
18
  ): Promise<DecoderResult> {
20
19
  const startTime = Date.now()
21
- const {
22
- timeoutMs = 5000, // Give more time for finishing
23
- chain,
24
- } = options
20
+ const { chain } = options
25
21
 
26
22
  try {
27
23
  // Check cache first
28
24
  const txHash = transaction.hash || transaction.transactionHash
29
25
  if (txHash) {
30
26
  const cached = caches.getTransaction(txHash)
31
- if (cached && cached.enhancementAttempted) {
27
+ if (cached?.enhancementAttempted) {
32
28
  return {
33
29
  ...cached,
34
30
  cached: true,
@@ -1,4 +1,4 @@
1
- import type { Address, Chain } from 'viem'
1
+ import type { Address } from 'viem'
2
2
  import {
3
3
  bytesToHex,
4
4
  decodeAbiParameters,
@@ -254,7 +254,6 @@ export function buildLSP23DeploymentQuery(config: HypersyncQueryConfig) {
254
254
  profileAddresses,
255
255
  fromBlock = 0,
256
256
  toBlock,
257
- chainId,
258
257
  } = config
259
258
 
260
259
  // Prefer querying by profile addresses (more efficient)
@@ -369,7 +368,7 @@ export function parseLSP23DeploymentsFromHypersync(
369
368
  : null
370
369
 
371
370
  // Match transactions with traces
372
- for (const [txHash, profileAddress] of create2Traces) {
371
+ for (const [txHash, _profileAddress] of create2Traces) {
373
372
  const tx = txMap.get(txHash)
374
373
  if (!tx) continue
375
374
 
@@ -1,4 +1,4 @@
1
- import type { Chain, Transaction } from 'viem'
1
+ import type { Chain } from 'viem'
2
2
  import type { DataKey, DecoderResult, EnhancedInfo } from '../types'
3
3
 
4
4
  /**
@@ -271,7 +271,7 @@ export async function fetchMultipleAddresses(
271
271
  const profiles: string[] = []
272
272
  const assets: string[] = []
273
273
  const tokens: string[] = []
274
- const tokenMapping = new Map<string, { address: Address; tokenId: string }>()
274
+ const tokenMapping = new Map<string, { address: Address; tokenId?: string }>()
275
275
 
276
276
  for (const key of uncachedAddresses) {
277
277
  const hasDash = key.includes('-')
@@ -324,7 +324,7 @@ export async function fetchMultipleAddresses(
324
324
  // Process tokens (must be before assets per addressGQL.ts logic)
325
325
  if (data.Token) {
326
326
  for (const token of data.Token) {
327
- const { id, baseAsset, tokenId, ...rest } = token
327
+ const { id: _id, baseAsset, tokenId, ...rest } = token
328
328
 
329
329
  // Tokens have a composite ID format and baseAsset reference
330
330
  if (baseAsset?.id && tokenId) {
@@ -572,7 +572,7 @@ export async function getImage(
572
572
  : undefined
573
573
  }
574
574
  try {
575
- let isImage: string | undefined = undefined
575
+ let isImage: string | undefined
576
576
  if (typeof caches !== 'undefined' && !ignoreHead) {
577
577
  const cache = await caches.open('image-types')
578
578
  const cached = await cache.match(url)
@@ -588,7 +588,7 @@ export async function getImage(
588
588
  // We use this to determine what type of images we have.
589
589
  // If the images came from the indexer then this test
590
590
  // has already been done on the indexer and we can skip it here.
591
- const now = Date.now()
591
+ const _now = Date.now()
592
592
  isImage = await fetch(url, { method: 'HEAD' })
593
593
  .then((response) => {
594
594
  if (response.ok) {
@@ -18,12 +18,12 @@ export const JSONbigString = {
18
18
  /**
19
19
  * Stringify an object, converting BigInt values to strings with 'n' suffix
20
20
  */
21
- stringify: (obj: any, replacer?: any, space?: string | number): string => {
21
+ stringify: (obj: any, _replacer?: any, space?: string | number): string => {
22
22
  return JSON.stringify(
23
23
  obj,
24
- (key, value) => {
24
+ (_key, value) => {
25
25
  if (typeof value === 'bigint') {
26
- return value.toString() + 'n'
26
+ return `${value.toString()}n`
27
27
  }
28
28
  return value
29
29
  },
@@ -35,7 +35,7 @@ export const JSONbigString = {
35
35
  * Parse a JSON string, converting strings ending with 'n' back to BigInt
36
36
  */
37
37
  parse: (text: string): any => {
38
- return JSON.parse(text, (key, value) => {
38
+ return JSON.parse(text, (_key, value) => {
39
39
  if (typeof value === 'string' && /^\d+n$/.test(value)) {
40
40
  return BigInt(value.slice(0, -1))
41
41
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/shared/cache.ts","../src/client/resolveAddresses.ts","../src/core/addressResolver.ts","../src/core/integrateDecoder.ts","../src/server/lsp23Resolver.ts","../src/utils/json-bigint.ts","../src/index.ts"],"sourcesContent":["import type { DataKey, EnhancedInfo } from '../types'\n\n/**\n * Address identity cache interface\n * Can be implemented with different backends (LRU, Redis, etc.)\n */\nexport interface AddressIdentityCache {\n /**\n * Get cached address data\n */\n get(\n key: DataKey\n ): EnhancedInfo | undefined | Promise<EnhancedInfo | undefined>\n\n /**\n * Set address data in cache\n */\n set(key: DataKey, value: EnhancedInfo): void | Promise<void>\n\n /**\n * Check if address is in cache\n */\n has(key: DataKey): boolean | Promise<boolean>\n\n /**\n * Get multiple addresses at once\n */\n getMany?(\n keys: readonly DataKey[]\n ): Map<DataKey, EnhancedInfo> | Promise<Map<DataKey, EnhancedInfo>>\n\n /**\n * Set multiple addresses at once\n */\n setMany?(entries: Array<[DataKey, EnhancedInfo]>): void | Promise<void>\n\n /**\n * Clear all cached data\n */\n clear?(): void | Promise<void>\n}\n\n/**\n * Type guard to check if value is a promise\n */\nfunction isPromise<T>(value: T | Promise<T>): value is Promise<T> {\n return value instanceof Promise\n}\n\n/**\n * Helper to convert DataKey to cache key string\n */\nexport function getDataKeyCacheKey(key: DataKey): string {\n return key.toLowerCase()\n}\n\n/**\n * Convert a DataKey to the standardized string format\n * @param dataKey - A hex string (address or address:tokenId)\n * @returns The same string\n */\nexport function dataKeyToString(dataKey: DataKey): string {\n return dataKey\n}\n\n/**\n * Parse a string to a DataKey\n * @param str - String in format \"address\" or \"address:tokenId\"\n * @returns DataKey as a hex string\n */\nexport function parseDataKey(str: string): DataKey {\n // Just return the string as-is since DataKey is now always a string\n return str as DataKey\n}\n\n/**\n * Create a simple in-memory address cache\n */\nexport function createMemoryAddressIdentityCache(\n ttlMs: number = 1000 * 60 * 5 // 5 minutes default\n): AddressIdentityCache {\n const cache = new Map<string, { data: EnhancedInfo; expires: number }>()\n\n return {\n get(key: DataKey): EnhancedInfo | undefined {\n const cacheKey = getDataKeyCacheKey(key)\n const entry = cache.get(cacheKey)\n\n if (!entry) return undefined\n\n if (Date.now() > entry.expires) {\n cache.delete(cacheKey)\n return undefined\n }\n\n return entry.data\n },\n\n set(key: DataKey, value: EnhancedInfo): void {\n const cacheKey = getDataKeyCacheKey(key)\n cache.set(cacheKey, {\n data: value,\n expires: Date.now() + ttlMs,\n })\n },\n\n has(key: DataKey): boolean {\n const cacheKey = getDataKeyCacheKey(key)\n const entry = cache.get(cacheKey)\n\n if (!entry) return false\n\n if (Date.now() > entry.expires) {\n cache.delete(cacheKey)\n return false\n }\n\n return true\n },\n\n getMany(keys: DataKey[]): Map<DataKey, EnhancedInfo> {\n const results = new Map<DataKey, EnhancedInfo>()\n\n for (const key of keys) {\n const data = this.get(key)\n if (data && !isPromise(data)) {\n results.set(key, data)\n }\n }\n\n return results\n },\n\n setMany(entries: Array<[DataKey, EnhancedInfo]>): void {\n for (const [key, value] of entries) {\n this.set(key, value)\n }\n },\n\n clear(): void {\n cache.clear()\n },\n }\n}\n","import type { Chain } from 'viem'\nimport type { AddressIdentityCache } from '../shared/cache'\nimport { getDataKeyCacheKey } from '../shared/cache'\nimport type { DataKey, EnhancedInfo } from '../types'\n\nexport interface ResolveAddressesOptions {\n /**\n * API endpoint URL (defaults to '/api/resolveAddresses')\n */\n endpoint?: string\n\n /**\n * Optional cache to check before making API call\n */\n cache?: AddressIdentityCache\n\n /**\n * Maximum number of addresses per batch (defaults to 100)\n */\n batchSize?: number\n\n /**\n * Request timeout in milliseconds (defaults to 10000)\n */\n timeout?: number\n}\n\nexport interface ResolveAddressesResponse {\n success: boolean\n addresses?: Record<string, EnhancedInfo>\n cached?: number\n fetched?: number\n total?: number\n error?: string\n}\n\n/**\n * Resolve addresses using the API endpoint\n * This allows clients to populate the server cache and get resolved addresses\n */\nexport async function resolveAddresses(\n addresses: DataKey[],\n chain: Chain,\n options: ResolveAddressesOptions = {}\n): Promise<Map<DataKey, EnhancedInfo>> {\n const {\n endpoint = '/api/resolveAddresses',\n cache,\n batchSize = 100,\n timeout = 10000,\n } = options\n\n const results = new Map<DataKey, EnhancedInfo>()\n\n if (addresses.length === 0) {\n return results\n }\n\n // Check cache first if provided\n const uncachedAddresses: DataKey[] = []\n\n if (cache) {\n for (const addr of addresses) {\n const cached = await cache.get(addr)\n if (cached) {\n results.set(addr, cached)\n } else {\n uncachedAddresses.push(addr)\n }\n }\n\n if (uncachedAddresses.length === 0) {\n return results\n }\n } else {\n uncachedAddresses.push(...addresses)\n }\n\n // Process in batches\n const batches: DataKey[][] = []\n for (let i = 0; i < uncachedAddresses.length; i += batchSize) {\n batches.push(uncachedAddresses.slice(i, i + batchSize))\n }\n\n // Fetch all batches in parallel\n const batchPromises = batches.map(async (batch) => {\n try {\n // DataKey is now just Hex string, use batch directly\n const apiAddresses = batch\n\n // Make API request with timeout\n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), timeout)\n\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n chainId: chain.id,\n addresses: apiAddresses,\n }),\n signal: controller.signal,\n })\n\n clearTimeout(timeoutId)\n\n if (!response.ok) {\n console.error(\n `Address resolution failed: ${response.status} ${response.statusText}`\n )\n return\n }\n\n const data: ResolveAddressesResponse = await response.json()\n\n if (data.success && data.addresses) {\n // Convert response back to DataKey -> EnhancedInfo map\n for (const [cacheKey, enhancedInfo] of Object.entries(data.addresses)) {\n // Find the original DataKey that matches this cache key\n const matchingKey = batch.find(\n (key) => getDataKeyCacheKey(key) === cacheKey\n )\n\n if (matchingKey) {\n results.set(matchingKey, enhancedInfo)\n\n // Update cache if provided\n if (cache) {\n await cache.set(matchingKey, enhancedInfo)\n }\n }\n }\n }\n } catch (error) {\n console.error('Failed to resolve addresses batch:', error)\n }\n })\n\n await Promise.all(batchPromises)\n\n return results\n}\n\n/**\n * Create a cache-through address resolver that uses the API\n * This can be used as a drop-in replacement for fetchMultipleAddresses\n */\nexport function createApiAddressResolver(\n chain: Chain,\n options: ResolveAddressesOptions = {}\n) {\n return async (addresses: DataKey[]): Promise<Map<DataKey, EnhancedInfo>> => {\n return resolveAddresses(addresses, chain, options)\n }\n}\n","import type { Chain } from 'viem'\nimport { fetchMultipleAddresses } from '../shared/addressResolver'\nimport type { AddressIdentityCache } from '../shared/cache'\nimport type { DataKey, EnhancedInfo, IDataModel } from '../types'\n\n/**\n * Configuration for address resolver\n */\nexport interface AddressResolverConfig {\n dataModel: IDataModel\n graphqlEndpoint: string\n chain: Chain\n batchSize?: number\n batchDelay?: number\n cache?: AddressIdentityCache\n}\n\n/**\n * Resolve addresses using GraphQL\n * Replaces the old patchValue mechanism\n */\nexport class AddressResolver {\n private dataModel: IDataModel\n private graphqlEndpoint: string\n private batchSize: number\n private batchDelay: number\n private pendingAddresses = new Set<string>()\n private batchTimer?: NodeJS.Timeout\n private cache?: AddressIdentityCache\n\n constructor(config: AddressResolverConfig) {\n this.dataModel = config.dataModel\n this.graphqlEndpoint = config.graphqlEndpoint\n this.batchSize = config.batchSize || 50\n this.batchDelay = config.batchDelay || 100\n this.cache = config.cache\n }\n\n /**\n * Start watching for missing addresses\n */\n startWatching() {\n // Check for missing addresses periodically\n setInterval(() => {\n const missing = this.dataModel.getMissingKeys()\n if (missing.length > 0) {\n this.queueAddresses(missing)\n }\n }, 1000)\n }\n\n /**\n * Queue addresses for batch resolution\n */\n queueAddresses(addresses: DataKey[]) {\n // Add to pending set\n for (const addr of addresses) {\n this.pendingAddresses.add(addr)\n }\n\n // Clear existing timer\n if (this.batchTimer) {\n clearTimeout(this.batchTimer)\n }\n\n // Set new timer\n this.batchTimer = setTimeout(() => {\n this.processBatch()\n }, this.batchDelay)\n\n // Process immediately if batch is full\n if (this.pendingAddresses.size >= this.batchSize) {\n clearTimeout(this.batchTimer)\n this.processBatch()\n }\n }\n\n /**\n * Process a batch of addresses\n */\n private async processBatch() {\n const batch = Array.from(this.pendingAddresses).slice(0, this.batchSize)\n if (batch.length === 0) return\n\n // Remove from pending\n for (const key of batch) {\n this.pendingAddresses.delete(key)\n }\n\n // Convert batch keys back to DataKey format\n const dataKeys: DataKey[] = batch.map((key) => {\n return key as DataKey\n })\n\n try {\n // Fetch data using shared implementation with cache\n const results = await fetchMultipleAddresses(\n dataKeys,\n this.graphqlEndpoint,\n this.cache\n )\n\n // Convert to array for injection\n const enhancedData: EnhancedInfo[] = Array.from(results.values())\n\n // Inject data into model\n if (enhancedData.length > 0) {\n this.dataModel.injectData(enhancedData)\n }\n } catch (error) {\n console.error('Failed to resolve addresses:', error)\n\n // Mark addresses as having errors\n for (const key of dataKeys) {\n this.dataModel.setError(key, 'Failed to fetch address data')\n }\n }\n\n // Continue processing if more pending\n if (this.pendingAddresses.size > 0) {\n this.batchTimer = setTimeout(() => {\n this.processBatch()\n }, this.batchDelay)\n }\n }\n\n /**\n * Stop watching for addresses\n */\n stopWatching() {\n if (this.batchTimer) {\n clearTimeout(this.batchTimer)\n }\n }\n}\n","import { effect } from '@preact/signals-core'\nimport type { Address, Transaction } from 'viem'\nimport { lukso } from 'viem/chains'\nimport { decodeTransaction } from '../decoder/decodeTransaction'\nimport { defaultPlugins, defaultSchemaPlugins } from '../decoder/plugins'\nimport type { DecoderOptions, DecoderResult } from '../decoder/types'\nimport type { DataKey, EnhancedInfo, IDataModel } from '../types'\nimport { collectDataKeys } from './addressCollector'\n\n/**\n * Configuration for decoder integration\n */\nexport interface DecoderIntegrationConfig {\n dataModel: IDataModel\n decoderOptions?: Partial<DecoderOptions>\n addressCache?: AddressCache\n}\n\n/**\n * External cache interface for address data\n */\nexport interface AddressCache {\n get(key: DataKey): Promise<EnhancedInfo | undefined>\n set(key: DataKey, value: EnhancedInfo): Promise<void>\n has(key: DataKey): Promise<boolean>\n delete(key: DataKey): Promise<void>\n clear(): Promise<void>\n}\n\n/**\n * Integrate the decoder with the data model\n * Handles progressive transaction enhancement and address population\n */\nexport class DecoderIntegration {\n private dataModel: IDataModel\n private decoderOptions: DecoderOptions\n private addressCache?: AddressCache\n\n constructor(config: DecoderIntegrationConfig) {\n this.dataModel = config.dataModel\n this.addressCache = config.addressCache\n\n // Set up default decoder options\n this.decoderOptions = {\n plugins: defaultPlugins,\n schemaPlugins: defaultSchemaPlugins,\n wrappers: [],\n chain: config.decoderOptions?.chain || lukso,\n ...config.decoderOptions,\n }\n }\n\n /**\n * Add and decode a transaction\n * @param transaction - Raw transaction data\n * @returns Transaction signal that updates as decoding progresses\n */\n async addAndDecodeTransaction(transaction: DecoderResult) {\n // Add transaction to data model\n const signal = this.dataModel.addTransactions(transaction)\n\n // Create fresh wrappers array for this transaction\n const transactionOptions: DecoderOptions = {\n ...this.decoderOptions,\n wrappers: [], // Fresh array for collecting wrappers in this decode hierarchy\n }\n\n // Start decoding process\n const { signal: decodingSignal } = await decodeTransaction(\n transaction,\n transactionOptions\n )\n\n // Update transaction data as decoding progresses\n effect(() => {\n const state = decodingSignal.value\n if (state.data) {\n const decodedResult = state.data as DecoderResult\n\n // Process any collected wrappers\n if (transactionOptions.wrappers.length > 0) {\n // Only certain result types support wrappers\n if (\n 'wrappers' in decodedResult &&\n typeof decodedResult === 'object'\n ) {\n ;(decodedResult as Record<string, unknown>).wrappers =\n transactionOptions.wrappers\n }\n\n // Extract addresses from wrappers\n for (const wrapper of transactionOptions.wrappers) {\n this.updateAddressesFromDecoded(wrapper as DecoderResult)\n }\n }\n\n // Flatten nested batch transactions if configured\n const processedResult = this.flattenBatchTransactions(decodedResult)\n\n if (transaction.hash) {\n this.dataModel.updateTransactionData(\n transaction.hash,\n processedResult,\n 0 // decoder index\n )\n }\n\n // Extract and update addresses from decoded data\n this.updateAddressesFromDecoded(processedResult)\n }\n })\n\n return signal\n }\n\n /**\n * Add and decode multiple transactions\n * @param transactions - Array of raw transactions\n * @returns Array of transaction signals\n */\n async addAndDecodeTransactions(transactions: DecoderResult[]) {\n // Add all transactions to data model\n const signals = this.dataModel.addTransactions(transactions)\n\n // Start decoding for each transaction\n const decodingPromises = transactions.map(async (tx, index) => {\n // Create fresh wrappers array for each transaction\n const transactionOptions: DecoderOptions = {\n ...this.decoderOptions,\n wrappers: [], // Fresh array for collecting wrappers in this decode hierarchy\n }\n\n const { signal: decodingSignal } = await decodeTransaction(\n tx,\n transactionOptions\n )\n\n // Update transaction data as decoding progresses\n effect(() => {\n const state = decodingSignal.value\n if (state.data) {\n const decodedResult = state.data as DecoderResult\n\n // Process any collected wrappers\n if (transactionOptions.wrappers.length > 0) {\n // Only certain result types support wrappers\n if (\n 'wrappers' in decodedResult &&\n typeof decodedResult === 'object'\n ) {\n ;(decodedResult as Record<string, unknown>).wrappers =\n transactionOptions.wrappers\n }\n\n // Extract addresses from wrappers\n for (const wrapper of transactionOptions.wrappers) {\n this.updateAddressesFromDecoded(wrapper as DecoderResult)\n }\n }\n\n // Flatten nested batch transactions if configured\n const processedResult = this.flattenBatchTransactions(decodedResult)\n\n if (tx.hash) {\n this.dataModel.updateTransactionData(\n tx.hash,\n processedResult,\n 0 // decoder index\n )\n }\n\n // Extract and update addresses from decoded data\n this.updateAddressesFromDecoded(processedResult)\n }\n })\n\n return decodingSignal\n })\n\n await Promise.all(decodingPromises)\n return signals\n }\n\n /**\n * Extract and register addresses from decoded transaction data\n */\n private async updateAddressesFromDecoded(decodedData: DecoderResult) {\n const addresses = collectDataKeys(decodedData)\n\n // Check cache and inject into data model\n for (const address of addresses) {\n // Check cache first\n if (this.addressCache) {\n const cached = await this.addressCache.get(address)\n if (cached) {\n // Inject into data model\n this.dataModel.updateData(cached)\n }\n }\n\n // Ensure the address signal exists (creates empty signal if not)\n // This allows views to getAddress() without errors\n this.dataModel.getAddress(address)\n }\n }\n\n /**\n * Flatten nested batch transactions\n * If a batch contains another batch as a child, flatten all sub-transactions into the parent's children\n *\n * Structure:\n * - Wrappers: The \"invisible\" execute functions (execute, executeRelayCall, etc.) that wrap the actual transaction\n * - Children: The actual transactions being executed\n *\n * Result:\n * - Single transaction: { resultType: 'execute', wrappers: [...] }\n * - Batch transaction: { resultType: 'executeBatch', children: [flat list], wrappers: [...] }\n *\n * This ensures only ONE level of batch with all transactions flattened\n */\n private flattenBatchTransactions(result: DecoderResult): DecoderResult {\n // Only process batch result types\n if (\n result.resultType !== 'executeBatch' &&\n result.resultType !== 'setDataBatch'\n ) {\n return result\n }\n\n // Type guard to ensure we have children property\n if (!('children' in result) || !Array.isArray(result.children)) {\n return result\n }\n\n // Flatten children - if any child is also a batch, merge its children up\n const flattenedChildren: unknown[] = []\n\n for (const child of result.children) {\n if (typeof child === 'object' && child && 'resultType' in child) {\n const childResult = child as Record<string, unknown>\n if (\n childResult.resultType === 'executeBatch' ||\n childResult.resultType === 'setDataBatch'\n ) {\n // This child is also a batch - flatten its children into our array\n if (\n 'children' in childResult &&\n Array.isArray(childResult.children)\n ) {\n flattenedChildren.push(...childResult.children)\n }\n } else {\n // Regular child - keep as is\n flattenedChildren.push(child)\n }\n }\n }\n\n // Return updated result with flattened children\n return {\n ...result,\n children: flattenedChildren,\n } as DecoderResult\n }\n\n /**\n * Load missing address data\n * This would be called by an external service that fetches address data\n */\n async loadAddressData(addressData: EnhancedInfo[]) {\n // Update data model\n this.dataModel.injectData(addressData)\n\n // Update cache if available\n if (this.addressCache) {\n await Promise.all(\n addressData.map((data) => {\n const key: DataKey = data.tokenId\n ? (`${data.address}:${data.tokenId}` as DataKey)\n : (data.address as DataKey)\n return this.addressCache?.set(key, data) ?? Promise.resolve()\n })\n )\n }\n }\n\n /**\n * Get addresses that need to be fetched\n */\n getMissingAddresses(): DataKey[] {\n return this.dataModel.getMissingKeys()\n }\n\n /**\n * Get addresses currently being loaded\n */\n getLoadingAddresses(): DataKey[] {\n return this.dataModel.getLoadingKeys()\n }\n}\n\n/**\n * Create a simple in-memory address cache\n */\nexport function createMemoryAddressCache(): AddressCache {\n const cache = new Map<string, EnhancedInfo>()\n\n return {\n async get(key: DataKey) {\n return cache.get(key)\n },\n async set(key: DataKey, value: EnhancedInfo) {\n cache.set(key, value)\n },\n async has(key: DataKey) {\n return cache.has(key)\n },\n async delete(key: DataKey) {\n cache.delete(key)\n },\n async clear() {\n cache.clear()\n },\n }\n}\n","import type { Address, Chain } from 'viem'\nimport {\n bytesToHex,\n decodeAbiParameters,\n isHex,\n parseAbiParameters,\n} from 'viem'\n\n/**\n * LSP23 Factory address (same on all networks)\n */\nexport const LSP23_FACTORY_ADDRESS =\n '0x2300000a84d25df63081feaa37ba6b62c4c89a30' as const\n\n/**\n * deployERC1167Proxies function selector\n */\nexport const DEPLOY_ERC1167_PROXIES_SELECTOR = '0x6a66a753' as const\n\n/**\n * LSP23 deployment data structure\n */\nexport interface LSP23DeploymentData {\n profileAddress: Address\n urdAddress: Address\n deployerAddress: Address // The controller that deployed this profile\n salt: string\n primaryImplementation: Address\n secondaryImplementation: Address\n postDeploymentModule: Address\n initializationCalldata: string\n deploymentCalldata: string // Full calldata to deployERC1167Proxies\n transactionHash: string\n blockNumber: bigint\n blockTimestamp: number // Unix timestamp of the block\n chainId: number\n}\n\n/**\n * Contract deployment tuple structures\n * Primary: (bytes32 salt, uint256 fundingAmount, address implementationContract, bytes initializeCalldata)\n * Secondary: (uint256 fundingAmount, address implementationContract, bytes addInitializeCalldata, bool addConstructor, bytes constructorParams)\n */\n\n/**\n * Decode deployERC1167Proxies calldata\n *\n * Function signature:\n * deployERC1167Proxies(\n * (bytes32 salt, uint256 fundingAmount, address implementationContract, bytes initializeCalldata) primaryContractDeployment,\n * (uint256 fundingAmount, address implementationContract, bytes addInitializeCalldata, bool addConstructor, bytes constructorParams) secondaryContractDeployment,\n * address postDeploymentModule,\n * bytes postDeploymentModuleCalldata\n * )\n */\nexport function decodeDeploymentCalldata(input: string): {\n salt: string\n primaryImplementation: Address\n secondaryImplementation: Address\n postDeploymentModule: Address\n initializationCalldata: string\n} | null {\n try {\n // Remove function selector (first 4 bytes / 8 hex chars + 0x)\n const params = `0x${input.slice(10)}` as `0x${string}`\n\n // Decode the parameters\n const decoded = decodeAbiParameters(\n parseAbiParameters(\n '(bytes32,uint256,address,bytes), (uint256,address,bytes,bool,bytes), address, bytes'\n ),\n params\n )\n\n const [\n primaryDeployment,\n secondaryDeployment,\n postDeploymentModule,\n postDeploymentModuleCalldata,\n ] = decoded\n\n // Primary deployment tuple: (bytes32 salt, uint256 fundingAmount, address implementationContract, bytes initializeCalldata)\n const [salt, , primaryImplementation] = primaryDeployment as [\n string,\n bigint,\n Address,\n string,\n ]\n\n // Secondary deployment tuple: (uint256 fundingAmount, address implementationContract, bytes addInitializeCalldata, bool addConstructor, bytes constructorParams)\n const [, secondaryImplementation] = secondaryDeployment as [\n bigint,\n Address,\n string,\n boolean,\n string,\n ]\n\n if (!primaryImplementation || !secondaryImplementation) {\n return null\n }\n\n return {\n salt,\n primaryImplementation,\n secondaryImplementation,\n postDeploymentModule: postDeploymentModule as Address,\n initializationCalldata: postDeploymentModuleCalldata as string,\n }\n } catch (error) {\n console.error('Failed to decode LSP23 deployment calldata:', error)\n return null\n }\n}\n\n/**\n * Decode deployERC1167Proxies output to get deployed addresses\n *\n * Returns: (address primaryContractAddress, address secondaryContractAddress)\n */\nexport function decodeDeploymentOutput(output: string): {\n profileAddress: Address\n urdAddress: Address\n} | null {\n try {\n const decoded = decodeAbiParameters(\n parseAbiParameters('address, address'),\n output as `0x${string}`\n )\n\n return {\n profileAddress: decoded[0],\n urdAddress: decoded[1],\n }\n } catch (error) {\n console.error('Failed to decode LSP23 deployment output:', error)\n return null\n }\n}\n\n/**\n * Extract controller addresses from initialization calldata\n *\n * The initializationCalldata contains a setDataBatch call that sets up controller permissions.\n * Function: setDataBatch(bytes32[] dataKeys, bytes[] dataValues)\n *\n * The dataKeys contain entries like:\n * - AddressPermissions:Permissions:<controller-address>\n *\n * We extract controller addresses from these keys.\n */\nexport function extractControllersFromInitCalldata(\n initializationCalldata: string\n): Address[] {\n try {\n if (!initializationCalldata || initializationCalldata === '0x') {\n return []\n }\n\n // The postDeploymentModuleCalldata is raw ABI-encoded (bytes32[], bytes[])\n // No function selector - decode directly\n const decoded = decodeAbiParameters(\n parseAbiParameters('bytes32[], bytes[]'),\n initializationCalldata as `0x${string}`\n )\n\n const [dataKeys, dataValues] = decoded\n const controllers: Address[] = []\n\n // Look for AddressPermissions[] keys\n // The key is 0xdf30dba06db6a30e65354d9a64c60986 followed by zeros\n // The controller address is in the corresponding value at the same index (encoded as bytes)\n const ADDRESS_PERMISSIONS_ARRAY_PREFIX =\n '0xdf30dba06db6a30e65354d9a64c60986'\n\n for (let i = 0; i < dataKeys.length; i++) {\n const keyStr = dataKeys[i].toLowerCase()\n if (keyStr.startsWith(ADDRESS_PERMISSIONS_ARRAY_PREFIX)) {\n // The value contains the controller address\n const value = dataValues[i]\n\n // Convert to hex if it's not already\n const valueHex = isHex(value) ? value : bytesToHex(value as Uint8Array)\n\n // The value should be a 20-byte address (40 hex chars + 0x = 42 total)\n // or possibly 32 bytes with padding\n if (valueHex.length === 42) {\n // Exactly 20 bytes - this is the address\n const addr = valueHex as Address\n if (\n addr !== '0x0000000000000000000000000000000000000000' &&\n !controllers.some((c) => c.toLowerCase() === addr.toLowerCase())\n ) {\n controllers.push(addr)\n }\n }\n }\n }\n\n return controllers\n } catch (error) {\n console.error('Failed to extract controllers from init calldata:', error)\n return []\n }\n}\n\n/**\n * Hypersync query configuration for LSP23 deployments\n */\nexport interface HypersyncQueryConfig {\n /**\n * Controller addresses (derived keys) that deployed profiles\n * We only want LSP23 data for profiles WE created, not imported\n */\n controllerAddresses?: Address[]\n\n /**\n * Profile addresses to query deployment data for\n * More efficient than querying by controllers when we already know the profiles\n */\n profileAddresses?: Address[]\n\n /**\n * Starting block (0 for genesis)\n */\n fromBlock?: number\n\n /**\n * Ending block (undefined for latest)\n */\n toBlock?: number\n\n /**\n * Chain ID to query\n */\n chainId: number\n}\n\n/**\n * Build Hypersync query to find LSP23 deployments\n *\n * Strategy 1 (by profileAddresses - RECOMMENDED):\n * Query CREATE2 traces where the created address matches our profile addresses.\n * Then filter transactions to LSP23 factory and verify deployer is one of our controllers.\n * This is more efficient when we already know the profile addresses from GraphQL.\n *\n * Strategy 2 (by controllerAddresses - LEGACY):\n * Query transactions TO the LSP23 factory FROM our controller addresses.\n * This scans the entire chain history for all deployments by our controllers.\n */\nexport function buildLSP23DeploymentQuery(config: HypersyncQueryConfig) {\n const {\n controllerAddresses,\n profileAddresses,\n fromBlock = 0,\n toBlock,\n chainId,\n } = config\n\n // Prefer querying by profile addresses (more efficient)\n if (profileAddresses && profileAddresses.length > 0) {\n return {\n from_block: fromBlock,\n to_block: toBlock,\n // Query CREATE2 traces where the created address is one of our profiles\n traces: [\n {\n type: ['create2'],\n to: profileAddresses.map((addr) => addr.toLowerCase()),\n },\n ],\n // Also get the transactions to verify they're to the LSP23 factory\n transactions: [\n {\n to: [LSP23_FACTORY_ADDRESS.toLowerCase()],\n },\n ],\n field_selection: {\n transaction: ['hash', 'from', 'to', 'input', 'output', 'block_number'],\n trace: ['transaction_hash', 'type', 'from', 'to'],\n block: ['number', 'timestamp'],\n },\n include_all_blocks: false,\n }\n }\n\n // Fall back to querying by controller addresses (less efficient)\n if (controllerAddresses && controllerAddresses.length > 0) {\n return {\n from_block: fromBlock,\n to_block: toBlock,\n // Query transactions to the LSP23 factory from our controllers\n transactions: [\n {\n from: controllerAddresses.map((addr) => addr.toLowerCase()),\n to: [LSP23_FACTORY_ADDRESS.toLowerCase()],\n },\n ],\n // Also get traces to see the CREATE2 operations\n traces: [\n {\n type: ['create2'],\n // No filter on 'to' - we'll match by transaction hash\n },\n ],\n field_selection: {\n transaction: ['hash', 'from', 'to', 'input', 'output', 'block_number'],\n trace: ['transaction_hash', 'type', 'from', 'to'],\n block: ['number', 'timestamp'],\n },\n include_all_blocks: false,\n }\n }\n\n throw new Error(\n 'Either profileAddresses or controllerAddresses must be provided'\n )\n}\n\n/**\n * Parse Hypersync response to extract LSP23 deployment data\n * @param response - Hypersync API response\n * @param chainId - Chain ID\n * @param controllerAddresses - Optional list of controller addresses to filter by (only return deployments from these deployers)\n */\nexport function parseLSP23DeploymentsFromHypersync(\n response: any,\n chainId: number,\n controllerAddresses?: Address[]\n): LSP23DeploymentData[] {\n const deployments: LSP23DeploymentData[] = []\n\n if (!response?.data) {\n return deployments\n }\n\n // Build a map of block number -> timestamp\n const blockTimestamps = new Map<number, number>()\n for (const block of response.data.blocks || []) {\n blockTimestamps.set(block.number, block.timestamp)\n }\n\n // Build a map of transaction hash -> transaction data\n const txMap = new Map<string, any>()\n for (const tx of response.data.transactions || []) {\n if (\n tx.to?.toLowerCase() === LSP23_FACTORY_ADDRESS.toLowerCase() &&\n tx.input?.startsWith(DEPLOY_ERC1167_PROXIES_SELECTOR)\n ) {\n txMap.set(tx.hash.toLowerCase(), tx)\n }\n }\n\n // Process traces to find CREATE2 operations\n const create2Traces = new Map<string, Address>() // txHash -> created profile address\n\n for (const trace of response.data.traces || []) {\n if (trace.type === 'create2' && trace.to) {\n create2Traces.set(\n trace.transaction_hash.toLowerCase(),\n trace.to as Address\n )\n }\n }\n\n // Create a Set of lowercase controller addresses for efficient filtering\n const controllerSet = controllerAddresses\n ? new Set(controllerAddresses.map((addr) => addr.toLowerCase()))\n : null\n\n // Match transactions with traces\n for (const [txHash, profileAddress] of create2Traces) {\n const tx = txMap.get(txHash)\n if (!tx) continue\n\n // If controller filtering is enabled, verify the deployer is one of our controllers\n if (controllerSet && !controllerSet.has(tx.from.toLowerCase())) {\n continue\n }\n\n // Decode the transaction\n const decodedInput = decodeDeploymentCalldata(tx.input)\n const decodedOutput = tx.output ? decodeDeploymentOutput(tx.output) : null\n\n if (!decodedInput || !decodedOutput) continue\n\n // Get block timestamp for this transaction\n const blockTimestamp = blockTimestamps.get(tx.block_number) || 0\n\n deployments.push({\n profileAddress: decodedOutput.profileAddress,\n urdAddress: decodedOutput.urdAddress,\n deployerAddress: tx.from as Address, // The controller that deployed this profile\n salt: decodedInput.salt,\n primaryImplementation: decodedInput.primaryImplementation,\n secondaryImplementation: decodedInput.secondaryImplementation,\n postDeploymentModule: decodedInput.postDeploymentModule,\n initializationCalldata: decodedInput.initializationCalldata,\n deploymentCalldata: tx.input, // Full calldata to deployERC1167Proxies\n transactionHash: tx.hash,\n blockNumber: BigInt(tx.block_number),\n blockTimestamp, // Unix timestamp of the block\n chainId,\n })\n }\n\n return deployments\n}\n\n/**\n * Note: Hypersync querying should be done server-side to protect HYPERSYNC_TOKEN.\n * Use the wallet-app API endpoint /api/lsp23Deployments instead of calling Hypersync directly.\n *\n * This module exports:\n * - buildLSP23DeploymentQuery() - Build the Hypersync query structure\n * - parseLSP23DeploymentsFromHypersync() - Parse Hypersync response\n * - decodeDeploymentCalldata() - Decode LSP23 transaction input\n * - decodeDeploymentOutput() - Decode LSP23 transaction output\n */\n","/**\n * JSON serializer/deserializer that preserves BigInt types\n *\n * This implementation uses an 'n' suffix to indicate BigInt values,\n * ensuring that values that were originally BigInt remain BigInt,\n * and values that were originally numbers remain numbers.\n *\n * Example:\n * - BigInt(123) serializes to \"123n\"\n * - Number(123) serializes to 123\n *\n * This is important for blockchain data where some values must be BigInt\n * (e.g., gas, value, nonce) while others should remain as numbers\n * (e.g., array indices, status codes).\n */\n\nexport const JSONbigString = {\n /**\n * Stringify an object, converting BigInt values to strings with 'n' suffix\n */\n stringify: (obj: any, replacer?: any, space?: string | number): string => {\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'bigint') {\n return value.toString() + 'n'\n }\n return value\n },\n space\n )\n },\n\n /**\n * Parse a JSON string, converting strings ending with 'n' back to BigInt\n */\n parse: (text: string): any => {\n return JSON.parse(text, (key, value) => {\n if (typeof value === 'string' && /^\\d+n$/.test(value)) {\n return BigInt(value.slice(0, -1))\n }\n return value\n })\n },\n}\n\nexport default JSONbigString\n","/**\n * @lukso/decoder - Consumer API\n *\n * This is the main entry point for consumers of the decoder.\n * Import data provider functions from '@lukso/transaction-decoder/data' instead.\n */\n\nimport { consumerModel, createGlobalInstance } from './core/instance'\n\n// Export all types that consumers need\nexport type {\n AddressState,\n DataKey,\n EnhancedInfo,\n IDataModelConsumer,\n TransactionState,\n} from './types'\n// DecoderResult is exported from decoder/types via the decoder imports below\n\n// Export all consumer methods directly\nexport const getTransaction = consumerModel.getTransaction.bind(consumerModel)\nexport const getTransactionByKey =\n consumerModel.getTransactionByKey.bind(consumerModel)\nexport const getTransactionsByIndex =\n consumerModel.getTransactionsByIndex.bind(consumerModel)\nexport const getTransactionHashByIndex =\n consumerModel.getTransactionHashByIndex.bind(consumerModel)\nexport const getTransactionCount =\n consumerModel.getTransactionCount.bind(consumerModel)\nexport const getDecodedCount = consumerModel.getDecodedCount.bind(consumerModel)\nexport const getDecodedTransactions =\n consumerModel.getDecodedTransactions.bind(consumerModel)\nexport const getTransactionsInOrder =\n consumerModel.getTransactionsInOrder.bind(consumerModel)\n\n// Address methods\nexport const getAddress = consumerModel.getAddress.bind(consumerModel)\nexport const getSignal = consumerModel.getSignal.bind(consumerModel)\nexport const subscribe = consumerModel.subscribe.bind(consumerModel)\nexport const getState = consumerModel.getState.bind(consumerModel)\nexport const hasData = consumerModel.hasData.bind(consumerModel)\nexport const getData = consumerModel.getData.bind(consumerModel)\nexport const isLoading = consumerModel.isLoading.bind(consumerModel)\nexport const getError = consumerModel.getError.bind(consumerModel)\n\n// Collection methods\nexport const getAllKeys = consumerModel.getAllKeys.bind(consumerModel)\nexport const getAllData = consumerModel.getAllData.bind(consumerModel)\nexport const getAllTransactions =\n consumerModel.getAllTransactions.bind(consumerModel)\n\n// Also export the consumer model instance for advanced usage\nexport { consumerModel }\n\n// Export the function to create global instance (for manual setup)\nexport { createGlobalInstance }\n\n// Export client utilities\nexport {\n createApiAddressResolver,\n type ResolveAddressesOptions,\n type ResolveAddressesResponse,\n resolveAddresses,\n} from './client/resolveAddresses'\n// Export address collection utilities from core\nexport { collectDataKeys } from './core/addressCollector'\nexport {\n AddressResolver,\n type AddressResolverConfig,\n} from './core/addressResolver'\n// Export integration classes\nexport {\n type AddressCache,\n createMemoryAddressCache,\n DecoderIntegration,\n type DecoderIntegrationConfig,\n} from './core/integrateDecoder'\n// Export aggregation utilities\nexport {\n type AggregationState,\n PluginAggregationEngine,\n standardAggregation,\n} from './decoder/aggregation'\nexport type {\n AddressResolver as TransactionAddressResolver,\n TransactionDecoderResult,\n} from './decoder/decodeTransaction'\n// Export decoder integration utilities\nexport {\n decodeTransaction,\n decodeTransactionAsync,\n} from './decoder/decodeTransaction'\n// Export plugin development utilities\n// Export default plugins to ensure they're imported and register themselves\nexport {\n createAggregationKey,\n defaultPlugins,\n defaultSchemaPlugins,\n standardPlugin,\n standardSchemaPlugin,\n} from './decoder/plugins'\nexport type {\n PluginMetadata,\n SchemaPluginMetadata,\n} from './decoder/registry'\nexport {\n createNamedPlugin,\n createNamedSchemaPlugin,\n pluginRegistry,\n registerPlugin,\n registerSchemaPlugin,\n} from './decoder/registry'\nexport type {\n Aggregation,\n DecodeEventCallback,\n DecodeEventResult,\n DecoderPlugin,\n DecoderResult,\n EnhancerCallback,\n PluginOptions,\n ResultAggregate,\n ResultCreate,\n ResultError,\n ResultExecute,\n ResultExecuteBatch,\n ResultFollowProfile,\n ResultGrafitti,\n ResultRaw,\n ResultSetData,\n ResultSetDataBatch,\n ResultWrapper,\n SchemaPlugin,\n} from './decoder/types'\n// Export utility functions\nexport { getArgByName, needsEnhancement } from './decoder/utils'\n// Export LSP23 deployment resolver utilities\n// Note: Actual Hypersync querying should be done via wallet-app API to protect HYPERSYNC_TOKEN\nexport {\n buildLSP23DeploymentQuery,\n DEPLOY_ERC1167_PROXIES_SELECTOR,\n decodeDeploymentCalldata,\n decodeDeploymentOutput,\n extractControllersFromInitCalldata,\n type HypersyncQueryConfig,\n LSP23_FACTORY_ADDRESS,\n type LSP23DeploymentData,\n parseLSP23DeploymentsFromHypersync,\n} from './server/lsp23Resolver'\n// Export shared address resolver utilities\nexport {\n type AssetData,\n fetchMultipleAddresses,\n fetchProfilesByControllers,\n getGraphQLEndpoint,\n getImage,\n type ImageData,\n type ImageURL,\n type LinkData,\n type ProfileData,\n type TFetchAddressData,\n type TokenData,\n} from './shared/addressResolver'\n// Export cache utilities\nexport {\n type AddressIdentityCache,\n createMemoryAddressIdentityCache,\n dataKeyToString,\n getDataKeyCacheKey,\n parseDataKey,\n} from './shared/cache'\n// Export debug utility for edge/worker environments\nexport { createDebug } from './utils/debug'\n// Export JSON BigInt serializer/deserializer\nexport { JSONbigString } from './utils/json-bigint'\n// Release update\n// build 1\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,SAAS,UAAa,OAA4C;AAChE,SAAO,iBAAiB;AAC1B;AAFS;AAOF,SAAS,mBAAmB,KAAsB;AACvD,SAAO,IAAI,YAAY;AACzB;AAFgB;AAST,SAAS,gBAAgB,SAA0B;AACxD,SAAO;AACT;AAFgB;AAST,SAAS,aAAa,KAAsB;AAEjD,SAAO;AACT;AAHgB;AAQT,SAAS,iCACd,QAAgB,MAAO,KAAK,GACN;AACtB,QAAM,QAAQ,oBAAI,IAAqD;AAEvE,SAAO;AAAA,IACL,IAAI,KAAwC;AAC1C,YAAM,WAAW,mBAAmB,GAAG;AACvC,YAAM,QAAQ,MAAM,IAAI,QAAQ;AAEhC,UAAI,CAAC,MAAO,QAAO;AAEnB,UAAI,KAAK,IAAI,IAAI,MAAM,SAAS;AAC9B,cAAM,OAAO,QAAQ;AACrB,eAAO;AAAA,MACT;AAEA,aAAO,MAAM;AAAA,IACf;AAAA,IAEA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- {"version":3,"sources":["../src/shared/addressResolver.ts"],"sourcesContent":["import request, { gql } from 'graphql-request'\nimport type { Address, Chain, Hex } from 'viem'\nimport { lukso } from 'viem/chains'\nimport type { DataKey, EnhancedInfo } from '../types'\nimport type { AddressIdentityCache } from './cache'\n\n/**\n * GraphQL queries for address resolution\n * Using the exact schema from addressGQL.ts\n */\nconst addressesGql = gql`\nquery AddressQuery($profiles: [String!], $assets: [String!], $tokens: [String!]) {\n Profile(\n where: {id: {_in: $profiles}}\n ) {\n fullName\n id\n name\n tags\n description\n standard\n controllers {\n address\n tags\n permissions\n }\n owner {\n id\n }\n profileImages(where: {error: {_is_null: true}}, order_by: {width: asc}) {\n width\n height\n src\n verified\n }\n backgroundImages(where: {error: {_is_null: true}}, order_by: {width: asc}) {\n width\n height\n src\n verified\n }\n avatars(where: {error: {_is_null: true}}, order_by: {width: asc}) {\n width\n height\n src\n verified\n }\n }\n Token(where: {id: {_in: $tokens}}) {\n id\n baseAsset {\n id\n description\n icons {\n src\n verified\n width\n height\n }\n isCollection\n isLSP7\n isUnknown\n name\n standard\n interfaces\n decimals\n owner_id\n lsp4Creators {\n profile_id\n }\n }\n formattedTokenId\n icons {\n src\n verified\n width\n height\n }\n images(where: {index: {_eq: 0}}) {\n src\n verified\n width\n height\n }\n lsp4TokenName\n lsp4TokenSymbol\n lsp4TokenType\n lsp8TokenIdFormat\n tokenId\n name\n description\n lsp4Creators {\n profile_id\n }\n }\n Asset(where: {id: {_in: $assets}}) {\n id\n images(where: {index: {_eq: 0}}) {\n src\n width\n verified\n height\n }\n interfaces\n isCollection\n isLSP7\n isUnknown\n lsp4TokenName\n lsp4TokenSymbol\n lsp4TokenType\n method\n name\n icons {\n src\n width\n height\n }\n description\n decimals\n standard\n owner_id\n lsp4Creators {\n profile_id\n }\n }\n}\n`\n\n// Image data structure from GraphQL\nexport interface ImageData {\n width?: number\n height?: number\n url?: string // Raw URL (may be ipfs://)\n src?: string // Resolved HTTPS URL (fallback to url if not present)\n verified?: boolean\n}\n\n// Link data structure from GraphQL\nexport interface LinkData {\n url: string\n title?: string\n}\n\n// Profile data from GraphQL\nexport interface ProfileData {\n id: Hex\n name?: string\n fullName?: string\n tags?: string[]\n description?: string\n links?: LinkData[]\n standard?: string\n controllers?: Array<{\n address: string\n tags?: string[]\n permissions?: Hex\n }>\n owner?: { id: string }\n profileImages?: ImageData[]\n backgroundImages?: ImageData[]\n avatars?: ImageData[]\n}\n\n// Asset data from GraphQL\nexport interface AssetData {\n id: Hex\n name?: string\n standard?: string\n lsp4TokenName?: string\n lsp4TokenSymbol?: string\n lsp4TokenType?: string\n method?: string\n description?: string\n links?: LinkData[]\n decimals?: number\n interfaces?: string[]\n isCollection?: boolean\n isLSP7?: boolean\n isUnknown?: boolean\n icons?: ImageData[]\n images?: ImageData[]\n}\n\n// Token data from GraphQL\nexport interface TokenData {\n id: Hex\n tokenId?: Hex\n name?: string\n description?: string\n links?: LinkData[]\n lsp4TokenName?: string\n lsp4TokenSymbol?: string\n lsp4TokenType?: string\n lsp8TokenIdFormat?: string\n formattedTokenId?: string\n baseAsset?: {\n id: Hex\n description?: string\n icons?: ImageData[]\n isCollection?: boolean\n isLSP7?: boolean\n isUnknown?: boolean\n name?: string\n standard?: string\n interfaces?: string[]\n decimals?: number\n }\n icons?: ImageData[]\n images?: ImageData[]\n}\n\nexport type TFetchAddressData = {\n Profile?: ProfileData[]\n Asset?: AssetData[]\n Token?: TokenData[]\n}\n\n/**\n * Fetch multiple addresses from GraphQL and return them as a Map\n * This is the shared implementation that both server and core can use\n */\nexport async function fetchMultipleAddresses(\n addresses: readonly DataKey[],\n graphqlEndpoint: string,\n cache?: AddressIdentityCache\n): Promise<Map<DataKey, EnhancedInfo>> {\n const results = new Map<DataKey, EnhancedInfo>()\n\n if (addresses.length === 0) {\n return results\n }\n\n // Check cache first if provided\n const uncachedAddresses: DataKey[] = []\n\n if (cache) {\n // Try to get many at once if supported\n if (cache.getMany) {\n const cachedResults = await cache.getMany(addresses)\n for (const [key, value] of cachedResults) {\n results.set(key, value)\n }\n // Find which ones we still need to fetch\n for (const addr of addresses) {\n if (!results.has(addr)) {\n uncachedAddresses.push(addr)\n }\n }\n } else {\n // Fall back to individual lookups\n for (const addr of addresses) {\n const cached = await cache.get(addr)\n if (cached) {\n results.set(addr, cached)\n } else {\n uncachedAddresses.push(addr)\n }\n }\n }\n\n // If all were cached, return early\n if (uncachedAddresses.length === 0) {\n return results\n }\n } else {\n // No cache, fetch all\n uncachedAddresses.push(...addresses)\n }\n\n // Parse addresses and tokens\n const profiles: string[] = []\n const assets: string[] = []\n const tokens: string[] = []\n const tokenMapping = new Map<string, { address: Address; tokenId: string }>()\n\n for (const key of uncachedAddresses) {\n const hasDash = key.includes('-')\n const hasColon = key.includes(':')\n\n if (hasColon || hasDash) {\n const normalizedKey = key.replace(/[-:]/, '-')\n tokens.push(normalizedKey)\n const [address, tokenId] = key.split(/[-:]/)\n tokenMapping.set(key, { address: address as Address, tokenId })\n } else {\n // Regular addresses - could be profiles or assets\n profiles.push(key)\n assets.push(key)\n }\n }\n\n try {\n // Fetch data from GraphQL\n const data = (await request(graphqlEndpoint, addressesGql, {\n profiles,\n assets,\n tokens,\n })) as TFetchAddressData\n\n // Process profiles\n if (data.Profile) {\n for (const profile of data.Profile) {\n if (profile.standard !== 'LSP0ERC725Account') {\n continue\n }\n const enhancedInfo: EnhancedInfo = {\n address: profile.id as Address,\n __gqltype: 'Profile',\n name: profile.name || profile.fullName,\n fullName: profile.fullName,\n standard: profile.standard,\n tags: profile.tags,\n description: profile.description,\n owner: profile.owner,\n controllers: profile.controllers,\n profileImages: profile.profileImages,\n backgroundImages: profile.backgroundImages,\n avatars: profile.avatars,\n }\n results.set(profile.id as Address, enhancedInfo)\n }\n }\n\n // Process tokens (must be before assets per addressGQL.ts logic)\n if (data.Token) {\n for (const token of data.Token) {\n const { id, baseAsset, tokenId, ...rest } = token\n\n // Tokens have a composite ID format and baseAsset reference\n if (baseAsset?.id && tokenId) {\n const enhancedInfo: EnhancedInfo = {\n address: baseAsset.id as Address,\n tokenId: tokenId as Address,\n __gqltype: 'Token',\n ...rest,\n baseAsset,\n }\n // Store with both dash and colon separators to handle both formats\n const keyWithColon = `${baseAsset.id}:${tokenId}` as DataKey\n const keyWithDash = `${baseAsset.id}-${tokenId}` as DataKey\n results.set(keyWithColon, enhancedInfo)\n results.set(keyWithDash, enhancedInfo)\n }\n }\n }\n\n // Process assets\n if (data.Asset) {\n for (const asset of data.Asset) {\n if (asset.standard === 'LSP0ERC725Account') {\n // Skip profiles - already processed\n continue\n }\n const enhancedInfo: EnhancedInfo = {\n address: asset.id as Address,\n __gqltype: 'Asset',\n ...asset,\n }\n if (!results.has(asset.id as Address)) {\n results.set(asset.id as Address, enhancedInfo)\n }\n }\n }\n\n // Cache the newly fetched results\n if (cache) {\n const newEntries: Array<[DataKey, EnhancedInfo]> = []\n\n // Collect all new entries\n for (const [key, value] of results) {\n // Only cache entries that were fetched (not from cache)\n const isCached = addresses.some(\n (addr) => addr.toLowerCase() === key.toLowerCase()\n )\n\n if (\n isCached &&\n uncachedAddresses.some(\n (addr) => addr.toLowerCase() === key.toLowerCase()\n )\n ) {\n newEntries.push([key, value])\n }\n }\n\n // Use batch update if available\n if (cache.setMany && newEntries.length > 0) {\n await cache.setMany(newEntries)\n } else {\n // Fall back to individual updates\n for (const [key, value] of newEntries) {\n await cache.set(key, value)\n }\n }\n }\n\n return results\n } catch (error) {\n console.error('Failed to fetch addresses:', error)\n return results\n }\n}\n\n/**\n * Get GraphQL endpoint for a given chain\n */\nexport function getGraphQLEndpoint(chain: Chain): string {\n return chain.id === lukso.id\n ? 'https://envio.lukso-mainnet.universal.tech/v1/graphql'\n : 'https://envio.lukso-testnet.universal.tech/v1/graphql'\n}\n\n/**\n * GraphQL query to find profiles controlled by specific addresses\n */\nconst profilesByControllerGql = gql`\nquery ProfilesByController($controllerAddresses: [String!]) {\n Profile(\n where: {\n controllers: {\n address: { _in: $controllerAddresses }\n tags: {\n _contains: [\n \"ADDCONTROLLER\"\n \"EDITPERMISSIONS\"\n \"SUPER_TRANSFERVALUE\"\n \"TRANSFERVALUE\"\n \"SUPER_CALL\"\n \"CALL\"\n \"SUPER_STATICCALL\"\n \"STATICCALL\"\n \"DEPLOY\"\n \"SUPER_SETDATA\"\n \"SETDATA\"\n \"ENCRYPT\"\n \"DECRYPT\"\n \"SIGN\"\n \"EXECUTE_RELAY_CALL\"\n ]\n }\n }\n }\n order_by: { blockNumber: asc }\n ) {\n fullName\n id\n name\n tags\n description\n standard\n controllers {\n address\n tags\n permissions\n }\n owner {\n id\n }\n profileImages(where: {error: {_is_null: true}}, order_by: {width: asc}) {\n width\n height\n src\n verified\n }\n backgroundImages(where: {error: {_is_null: true}}, order_by: {width: asc}) {\n width\n height\n src\n verified\n }\n avatars(where: {error: {_is_null: true}}, order_by: {width: asc}) {\n width\n height\n src\n verified\n }\n }\n}\n`\n\n/**\n * Find profiles controlled by specific controller addresses\n * @param controllerAddresses - Array of controller addresses to search for\n * @param chain - Which chain to query\n * @returns Array of profile data\n */\nexport async function fetchProfilesByControllers(\n controllerAddresses: readonly Address[],\n chain: Chain\n): Promise<ProfileData[]> {\n const graphqlEndpoint = getGraphQLEndpoint(chain)\n\n try {\n const data = (await request(graphqlEndpoint, profilesByControllerGql, {\n controllerAddresses: controllerAddresses.map((addr) =>\n addr.toLowerCase()\n ),\n })) as { Profile?: ProfileData[] }\n\n return data.Profile || []\n } catch (error) {\n console.error(\n `Failed to fetch profiles by controllers on ${chain.name}:`,\n error\n )\n return []\n }\n}\n\nexport type ImageURL = {\n url?: string\n data?: string\n src?: string\n width: number\n height: number\n index?: number\n verified?: string\n}\n\n/**\n * Assuming the images are sorted ascending by width and/or height pick the first\n * image that's larger than the requested size * dpr and process that one.\n * By default this will assume the data came from the indexer and therefore\n * we do not need to verify the existence of all the images (i.e. HEAD requests for\n * each image) Setting ignoreHead to false is important during RPC mode so that\n * we can skip images that are not really available.\n *\n * @param images - array of images\n * @param options - specify arguments for search/processing\n * @returns { width, height, src } - the image that fits the criteria\n */\nexport async function getImage(\n images: ImageURL[],\n options: {\n width: number\n height?: number\n index?: number\n ignoreVerification?: boolean\n forcePng?: boolean\n ignoreHead?: boolean\n fallback?: string\n dpr?: number\n }\n): Promise<{ width: number; height: number; src?: string } | undefined> {\n const {\n width,\n height: _height,\n index,\n ignoreVerification,\n ignoreHead = true, // By default we don't want to do HEAD requests for all images.\n dpr = 1,\n } = options\n const boost = dpr === 1 ? 1.5 : 1\n const height = _height || width\n const { src: _src, verified } =\n (images || []).find(\n (i) =>\n i.width >= width * boost * dpr &&\n i.height &&\n i.height >= height * boost * dpr &&\n (index ? i.index === index : i.index === undefined)\n ) ||\n images?.at(-1) ||\n {}\n // We're talking about images here, so we should be using /image/ instead of /ipfs/\n const url = _src?.startsWith('https://api.universalprofile.cloud/ipfs/')\n ? _src?.replace(/\\/ipfs\\//, '/image/')\n : _src\n if (!url) {\n return options.fallback\n ? { src: options.fallback, width: 128, height: 128 }\n : undefined\n }\n try {\n let isImage: string | undefined = undefined\n if (typeof caches !== 'undefined' && !ignoreHead) {\n const cache = await caches.open('image-types')\n const cached = await cache.match(url)\n if (cached) {\n const response = await cached.json()\n if (response) {\n isImage = response\n }\n }\n }\n if (!isImage && !ignoreHead) {\n // HEAD will return 200, 404 and so including the 'content-type'\n // We use this to determine what type of images we have.\n // If the images came from the indexer then this test\n // has already been done on the indexer and we can skip it here.\n const now = Date.now()\n isImage = await fetch(url, { method: 'HEAD' })\n .then((response) => {\n if (response.ok) {\n const mime = response.headers.get('content-type') || ''\n response.body?.cancel()\n return /^image\\//.test(mime) ? mime : undefined\n }\n response.body?.cancel()\n return undefined\n })\n .catch((error) => {\n console.error((error as Error).stack)\n return undefined\n })\n if (isImage != null && typeof caches !== 'undefined') {\n const cache = await caches.open('image-types')\n await cache\n .put(url, new Response(JSON.stringify(isImage)))\n .catch((error) => {\n console.error((error as Error).stack, url)\n })\n }\n }\n if (isImage || ignoreHead) {\n const finalUrl = new URL(url)\n const { searchParams } = finalUrl\n const qs = new URLSearchParams(searchParams)\n if (width) {\n qs.set('width', `${width * boost}`)\n }\n if (width || height) {\n qs.set('height', `${(height || width) * boost}`)\n }\n qs.set('fit', 'cover')\n qs.set('dpr', dpr.toString())\n if (\n !options.ignoreHead &&\n !/\\/svg/.test(isImage || '') &&\n options.forcePng\n ) {\n qs.set('format', 'png')\n }\n finalUrl.search = qs.toString()\n const image = finalUrl.toString()\n return {\n width,\n height: height || width,\n src:\n verified === 'INVALID' && !ignoreVerification\n ? `${image}&blur=30`\n : image,\n }\n }\n } catch (error) {\n console.error((error as Error).stack)\n }\n return options.fallback\n ? { src: options.fallback, width: 128, height: 128 }\n : undefined\n}\n"],"mappings":";;;;;AAAA,OAAO,WAAW,WAAW;AAE7B,SAAS,aAAa;AAQtB,IAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmNrB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