@hybrd/xmtp 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -7
- package/dist/index.cjs +415 -3085
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -828
- package/dist/index.d.ts +12 -828
- package/dist/index.js +416 -3056
- package/dist/index.js.map +1 -1
- package/package.json +18 -5
- package/src/client.ts +23 -135
- package/src/index.ts +28 -81
- package/src/index.ts.old +145 -0
- package/src/lib/jwt.ts +45 -13
- package/src/lib/{message-listener.test.ts → message-listener.test.ts.old} +1 -1
- package/src/lib/subjects.ts +6 -5
- package/src/plugin.filters.test.ts +158 -0
- package/src/plugin.ts +456 -23
- package/src/resolver/address-resolver.ts +217 -211
- package/src/resolver/basename-resolver.ts +6 -5
- package/src/resolver/ens-resolver.ts +15 -14
- package/src/resolver/resolver.ts +3 -2
- package/src/resolver/xmtp-resolver.ts +10 -9
- package/src/{service-client.ts → service-client.ts.old} +26 -3
- package/src/types.ts +9 -157
- package/src/types.ts.old +157 -0
- package/.cache/tsbuildinfo.json +0 -1
- package/.turbo/turbo-build.log +0 -45
- package/.turbo/turbo-lint$colon$fix.log +0 -6
- package/.turbo/turbo-typecheck.log +0 -5
- package/biome.jsonc +0 -4
- package/scripts/generate-keys.ts +0 -25
- package/scripts/refresh-identity.ts +0 -119
- package/scripts/register-wallet.ts +0 -95
- package/scripts/revoke-all-installations.ts +0 -91
- package/scripts/revoke-installations.ts +0 -94
- package/src/endpoints.ts +0 -306
- package/tsconfig.json +0 -9
- package/tsup.config.ts +0 -14
- /package/src/lib/{message-listener.ts → message-listener.ts.old} +0 -0
|
@@ -1,221 +1,227 @@
|
|
|
1
1
|
import type { XmtpClient } from "../types"
|
|
2
|
+
import { logger } from "@hybrd/utils"
|
|
2
3
|
|
|
3
4
|
interface AddressResolverOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Maximum number of addresses to cache
|
|
7
|
+
* @default 1000
|
|
8
|
+
*/
|
|
9
|
+
maxCacheSize?: number
|
|
10
|
+
/**
|
|
11
|
+
* Cache TTL in milliseconds
|
|
12
|
+
* @default 86400000 (24 hours)
|
|
13
|
+
*/
|
|
14
|
+
cacheTtl?: number
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
interface CacheEntry {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
address: string
|
|
19
|
+
timestamp: number
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export class AddressResolver {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
23
|
+
private cache = new Map<string, CacheEntry>()
|
|
24
|
+
private readonly maxCacheSize: number
|
|
25
|
+
private readonly cacheTtl: number
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
private client: XmtpClient,
|
|
29
|
+
options: AddressResolverOptions = {}
|
|
30
|
+
) {
|
|
31
|
+
this.maxCacheSize = options.maxCacheSize ?? 1000
|
|
32
|
+
this.cacheTtl = options.cacheTtl ?? 86400000 // 24 hours
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Resolve user address from inbox ID with caching
|
|
37
|
+
*/
|
|
38
|
+
async resolveAddress(
|
|
39
|
+
inboxId: string,
|
|
40
|
+
conversationId?: string
|
|
41
|
+
): Promise<`0x${string}` | null> {
|
|
42
|
+
// Check cache first (fastest)
|
|
43
|
+
const cached = this.getCachedAddress(inboxId)
|
|
44
|
+
if (cached) {
|
|
45
|
+
logger.debug(`✅ Resolved user address from cache: ${cached}`)
|
|
46
|
+
return cached
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let userAddress = undefined
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
// Try conversation members lookup first (faster than network call)
|
|
53
|
+
if (conversationId) {
|
|
54
|
+
const conversation =
|
|
55
|
+
await this.client.conversations.getConversationById(conversationId)
|
|
56
|
+
if (conversation) {
|
|
57
|
+
userAddress = await this.resolveFromConversation(
|
|
58
|
+
conversation,
|
|
59
|
+
inboxId
|
|
60
|
+
)
|
|
61
|
+
if (userAddress) {
|
|
62
|
+
this.setCachedAddress(inboxId, userAddress)
|
|
63
|
+
logger.debug(`✅ Resolved user address: ${userAddress}`)
|
|
64
|
+
return userAddress
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Fallback to inboxStateFromInboxIds
|
|
70
|
+
userAddress = await this.resolveFromInboxState(inboxId)
|
|
71
|
+
if (userAddress) {
|
|
72
|
+
this.setCachedAddress(inboxId, userAddress)
|
|
73
|
+
logger.debug(`✅ Resolved user address via fallback: ${userAddress}`)
|
|
74
|
+
return userAddress
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
logger.debug(`⚠️ No identifiers found for inbox ${inboxId}`)
|
|
78
|
+
return null
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(`❌ Error resolving user address for ${inboxId}:`, error)
|
|
81
|
+
return null
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Resolve address from conversation members
|
|
87
|
+
*/
|
|
88
|
+
private async resolveFromConversation(
|
|
89
|
+
conversation: any,
|
|
90
|
+
inboxId: string
|
|
91
|
+
): Promise<`0x${string}` | null> {
|
|
92
|
+
try {
|
|
93
|
+
const members = await conversation.members()
|
|
94
|
+
const sender = members.find(
|
|
95
|
+
(member: any) => member.inboxId.toLowerCase() === inboxId.toLowerCase()
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if (sender) {
|
|
99
|
+
const ethIdentifier = sender.accountIdentifiers.find(
|
|
100
|
+
(id: any) => id.identifierKind === 0 // IdentifierKind.Ethereum
|
|
101
|
+
)
|
|
102
|
+
if (ethIdentifier) {
|
|
103
|
+
return ethIdentifier.identifier
|
|
104
|
+
} else {
|
|
105
|
+
logger.debug(`⚠️ No Ethereum identifier found for inbox ${inboxId}`)
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
logger.debug(
|
|
109
|
+
`⚠️ Sender not found in conversation members for inbox ${inboxId}`
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error(`❌ Error resolving from conversation members:`, error)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Resolve address from inbox state (network fallback)
|
|
121
|
+
*/
|
|
122
|
+
private async resolveFromInboxState(
|
|
123
|
+
inboxId: string
|
|
124
|
+
): Promise<`0x${string}` | null> {
|
|
125
|
+
try {
|
|
126
|
+
const inboxState = await this.client.preferences.inboxStateFromInboxIds([
|
|
127
|
+
inboxId
|
|
128
|
+
])
|
|
129
|
+
const firstState = inboxState?.[0]
|
|
130
|
+
if (firstState?.identifiers && firstState.identifiers.length > 0) {
|
|
131
|
+
const firstIdentifier = firstState.identifiers[0]
|
|
132
|
+
return firstIdentifier?.identifier as `0x${string}`
|
|
133
|
+
}
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error(`❌ Error resolving from inbox state:`, error)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return null
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get cached address if not expired
|
|
143
|
+
*/
|
|
144
|
+
private getCachedAddress(inboxId: string): `0x${string}` | null {
|
|
145
|
+
const entry = this.cache.get(inboxId)
|
|
146
|
+
if (!entry) return null
|
|
147
|
+
|
|
148
|
+
const now = Date.now()
|
|
149
|
+
if (now - entry.timestamp > this.cacheTtl) {
|
|
150
|
+
this.cache.delete(inboxId)
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return entry.address as `0x${string}`
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Cache address with LRU eviction
|
|
159
|
+
*/
|
|
160
|
+
private setCachedAddress(inboxId: string, address: `0x${string}`): void {
|
|
161
|
+
// Simple LRU: if cache is full, remove oldest entry
|
|
162
|
+
if (this.cache.size >= this.maxCacheSize) {
|
|
163
|
+
const firstKey = this.cache.keys().next().value
|
|
164
|
+
if (firstKey) {
|
|
165
|
+
this.cache.delete(firstKey)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.cache.set(inboxId, {
|
|
170
|
+
address,
|
|
171
|
+
timestamp: Date.now()
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Pre-populate cache from existing conversations
|
|
177
|
+
*/
|
|
178
|
+
async prePopulateCache(): Promise<void> {
|
|
179
|
+
logger.debug("🔄 Pre-populating address cache...")
|
|
180
|
+
try {
|
|
181
|
+
const conversations = await this.client.conversations.list()
|
|
182
|
+
let cachedCount = 0
|
|
183
|
+
|
|
184
|
+
for (const conversation of conversations) {
|
|
185
|
+
try {
|
|
186
|
+
const members = await conversation.members()
|
|
187
|
+
for (const member of members) {
|
|
188
|
+
const ethIdentifier = member.accountIdentifiers.find(
|
|
189
|
+
(id: any) => id.identifierKind === 0 // IdentifierKind.Ethereum
|
|
190
|
+
)
|
|
191
|
+
if (ethIdentifier) {
|
|
192
|
+
this.setCachedAddress(
|
|
193
|
+
member.inboxId,
|
|
194
|
+
ethIdentifier.identifier as `0x${string}`
|
|
195
|
+
)
|
|
196
|
+
cachedCount++
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.error("Error pre-caching conversation members:", error)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
logger.debug(`✅ Pre-cached ${cachedCount} address mappings`)
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error("Error pre-populating cache:", error)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Clear the cache
|
|
212
|
+
*/
|
|
213
|
+
clearCache(): void {
|
|
214
|
+
this.cache.clear()
|
|
215
|
+
logger.debug("🗑️ Address cache cleared")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get cache statistics
|
|
220
|
+
*/
|
|
221
|
+
getCacheStats(): { size: number; maxSize: number; hitRate?: number } {
|
|
222
|
+
return {
|
|
223
|
+
size: this.cache.size,
|
|
224
|
+
maxSize: this.maxCacheSize
|
|
225
|
+
}
|
|
226
|
+
}
|
|
221
227
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "viem"
|
|
8
8
|
import { mainnet } from "viem/chains"
|
|
9
9
|
import { L2ResolverAbi } from "../abi/l2_resolver"
|
|
10
|
+
import { logger } from "@hybrd/utils"
|
|
10
11
|
|
|
11
12
|
// Base L2 Resolver Address mapping by chain ID
|
|
12
13
|
// const BASENAME_L2_RESOLVER_ADDRESSES: Record<number, Address> = {
|
|
@@ -139,23 +140,23 @@ export class BasenameResolver {
|
|
|
139
140
|
*/
|
|
140
141
|
private async initializeResolver(): Promise<void> {
|
|
141
142
|
if (this.resolverAddress && this.chainId) {
|
|
142
|
-
|
|
143
|
+
logger.debug(
|
|
143
144
|
`🔄 BasenameResolver already initialized for chain ${this.chainId} with resolver ${this.resolverAddress}`
|
|
144
145
|
)
|
|
145
146
|
return
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
try {
|
|
149
|
-
|
|
150
|
+
logger.debug("🔄 Initializing BasenameResolver...")
|
|
150
151
|
this.chainId = await this.baseClient.getChainId()
|
|
151
|
-
|
|
152
|
+
logger.debug(`🔗 Chain ID detected: ${this.chainId}`)
|
|
152
153
|
|
|
153
154
|
this.resolverAddress = getResolverAddress()
|
|
154
|
-
|
|
155
|
+
logger.debug(
|
|
155
156
|
`📍 Resolver address for chain ${this.chainId}: ${this.resolverAddress}`
|
|
156
157
|
)
|
|
157
158
|
|
|
158
|
-
|
|
159
|
+
logger.debug(
|
|
159
160
|
`✅ Initialized BasenameResolver for chain ${this.chainId} with resolver ${this.resolverAddress}`
|
|
160
161
|
)
|
|
161
162
|
} catch (error) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Address, PublicClient } from "viem"
|
|
2
|
+
import { logger } from "@hybrd/utils"
|
|
2
3
|
|
|
3
4
|
interface ENSResolverOptions {
|
|
4
5
|
/**
|
|
@@ -48,33 +49,33 @@ export class ENSResolver {
|
|
|
48
49
|
* Resolve an ENS name to an Ethereum address
|
|
49
50
|
*/
|
|
50
51
|
async resolveENSName(ensName: string): Promise<Address | null> {
|
|
51
|
-
|
|
52
|
+
logger.debug(`🔍 Resolving ENS name: ${ensName}`)
|
|
52
53
|
|
|
53
54
|
try {
|
|
54
55
|
// Check cache first
|
|
55
56
|
const cached = this.getCachedAddress(ensName)
|
|
56
57
|
if (cached) {
|
|
57
|
-
|
|
58
|
+
logger.debug(`✅ Resolved ENS from cache: ${ensName} → ${cached}`)
|
|
58
59
|
return cached as Address
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
logger.debug(`📭 No cached address found for ENS: ${ensName}`)
|
|
62
63
|
|
|
63
64
|
// Resolve using mainnet ENS
|
|
64
|
-
|
|
65
|
+
logger.debug("🔄 Reading ENS contract...")
|
|
65
66
|
const address = await this.mainnetClient.getEnsAddress({
|
|
66
67
|
name: ensName
|
|
67
68
|
})
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
logger.debug(`📋 ENS contract returned address: "${address}"`)
|
|
70
71
|
|
|
71
72
|
if (address && address !== "0x0000000000000000000000000000000000000000") {
|
|
72
73
|
this.setCachedAddress(ensName, address)
|
|
73
|
-
|
|
74
|
+
logger.debug(`✅ Resolved ENS: ${ensName} → ${address}`)
|
|
74
75
|
return address
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
logger.debug(`❌ No address found for ENS: ${ensName}`)
|
|
78
79
|
return null
|
|
79
80
|
} catch (error) {
|
|
80
81
|
console.error(`❌ Error resolving ENS name ${ensName}:`, error)
|
|
@@ -89,35 +90,35 @@ export class ENSResolver {
|
|
|
89
90
|
* Resolve an address to its primary ENS name (reverse resolution)
|
|
90
91
|
*/
|
|
91
92
|
async resolveAddressToENS(address: Address): Promise<string | null> {
|
|
92
|
-
|
|
93
|
+
logger.debug(`🔍 Reverse resolving address to ENS: ${address}`)
|
|
93
94
|
|
|
94
95
|
try {
|
|
95
96
|
// Check cache first
|
|
96
97
|
const cached = this.getCachedENSName(address)
|
|
97
98
|
if (cached) {
|
|
98
|
-
|
|
99
|
+
logger.debug(
|
|
99
100
|
`✅ Resolved ENS from reverse cache: ${address} → ${cached}`
|
|
100
101
|
)
|
|
101
102
|
return cached
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
logger.debug(`📭 No cached ENS name found for address: ${address}`)
|
|
105
106
|
|
|
106
107
|
// Reverse resolve using mainnet ENS
|
|
107
|
-
|
|
108
|
+
logger.debug("🔄 Reading ENS reverse resolver...")
|
|
108
109
|
const ensName = await this.mainnetClient.getEnsName({
|
|
109
110
|
address: address
|
|
110
111
|
})
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
logger.debug(`📋 ENS reverse resolver returned: "${ensName}"`)
|
|
113
114
|
|
|
114
115
|
if (ensName && ensName.length > 0) {
|
|
115
116
|
this.setCachedENSName(address, ensName)
|
|
116
|
-
|
|
117
|
+
logger.debug(`✅ Reverse resolved: ${address} → ${ensName}`)
|
|
117
118
|
return ensName
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
logger.debug(`❌ No ENS name found for address: ${address}`)
|
|
121
122
|
return null
|
|
122
123
|
} catch (error) {
|
|
123
124
|
console.error(`❌ Error reverse resolving address ${address}:`, error)
|
package/src/resolver/resolver.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "./basename-resolver"
|
|
9
9
|
import { ENSResolver } from "./ens-resolver"
|
|
10
10
|
import { XmtpResolver } from "./xmtp-resolver"
|
|
11
|
+
import { logger } from "@hybrd/utils"
|
|
11
12
|
|
|
12
13
|
interface ResolverOptions {
|
|
13
14
|
/**
|
|
@@ -293,14 +294,14 @@ export class Resolver {
|
|
|
293
294
|
if (address) {
|
|
294
295
|
// Try basename first since that's what we expect for this address
|
|
295
296
|
const basenameResult = await this.getBasename(address)
|
|
296
|
-
|
|
297
|
+
logger.debug(
|
|
297
298
|
`🔍 [RESOLVER] Direct basename lookup for ${address}:`,
|
|
298
299
|
basenameResult
|
|
299
300
|
)
|
|
300
301
|
|
|
301
302
|
// Try to get a human-readable name
|
|
302
303
|
const resolvedName = await this.resolveAddressToName(address)
|
|
303
|
-
|
|
304
|
+
logger.debug(
|
|
304
305
|
`🔍 [RESOLVER] Universal name resolution for ${address}:`,
|
|
305
306
|
resolvedName
|
|
306
307
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { XmtpClient, XmtpMessage } from "../types"
|
|
2
|
+
import { logger } from "@hybrd/utils"
|
|
2
3
|
|
|
3
4
|
interface XmtpResolverOptions {
|
|
4
5
|
/**
|
|
@@ -61,7 +62,7 @@ export class XmtpResolver {
|
|
|
61
62
|
// Check cache first (fastest)
|
|
62
63
|
const cached = this.getCachedAddress(inboxId)
|
|
63
64
|
if (cached) {
|
|
64
|
-
|
|
65
|
+
logger.debug(
|
|
65
66
|
`✅ [XmtpResolver] Resolved user address from cache: ${cached}`
|
|
66
67
|
)
|
|
67
68
|
return cached
|
|
@@ -81,7 +82,7 @@ export class XmtpResolver {
|
|
|
81
82
|
)
|
|
82
83
|
if (userAddress) {
|
|
83
84
|
this.setCachedAddress(inboxId, userAddress)
|
|
84
|
-
|
|
85
|
+
logger.debug(
|
|
85
86
|
`✅ [XmtpResolver] Resolved user address: ${userAddress}`
|
|
86
87
|
)
|
|
87
88
|
return userAddress
|
|
@@ -93,13 +94,13 @@ export class XmtpResolver {
|
|
|
93
94
|
userAddress = await this.resolveFromInboxState(inboxId)
|
|
94
95
|
if (userAddress) {
|
|
95
96
|
this.setCachedAddress(inboxId, userAddress)
|
|
96
|
-
|
|
97
|
+
logger.debug(
|
|
97
98
|
`✅ [XmtpResolver] Resolved user address via fallback: ${userAddress}`
|
|
98
99
|
)
|
|
99
100
|
return userAddress
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
logger.debug(`⚠️ [XmtpResolver] No identifiers found for inbox ${inboxId}`)
|
|
103
104
|
return null
|
|
104
105
|
} catch (error) {
|
|
105
106
|
console.error(
|
|
@@ -117,7 +118,7 @@ export class XmtpResolver {
|
|
|
117
118
|
// Check cache first
|
|
118
119
|
const cached = this.getCachedMessage(messageId)
|
|
119
120
|
if (cached !== undefined) {
|
|
120
|
-
|
|
121
|
+
logger.debug(
|
|
121
122
|
cached
|
|
122
123
|
? `✅ [XmtpResolver] Found message from cache: ${cached.id}`
|
|
123
124
|
: `✅ [XmtpResolver] Found cached null message for: ${messageId}`
|
|
@@ -126,16 +127,16 @@ export class XmtpResolver {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
try {
|
|
129
|
-
|
|
130
|
+
logger.debug(`🔍 [XmtpResolver] Finding message: ${messageId}`)
|
|
130
131
|
const message = await this.client.conversations.getMessageById(messageId)
|
|
131
132
|
|
|
132
133
|
if (message) {
|
|
133
134
|
this.setCachedMessage(messageId, message)
|
|
134
|
-
|
|
135
|
+
logger.debug(`✅ [XmtpResolver] Found and cached message: ${message.id}`)
|
|
135
136
|
return message
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
logger.debug(`⚠️ [XmtpResolver] Message not found: ${messageId}`)
|
|
139
140
|
this.setCachedMessage(messageId, null)
|
|
140
141
|
return null
|
|
141
142
|
} catch (error) {
|
|
@@ -156,7 +157,7 @@ export class XmtpResolver {
|
|
|
156
157
|
const rootCacheKey = `root:${messageId}`
|
|
157
158
|
const cached = this.getCachedMessage(rootCacheKey)
|
|
158
159
|
if (cached !== undefined) {
|
|
159
|
-
|
|
160
|
+
logger.debug(
|
|
160
161
|
cached
|
|
161
162
|
? `✅ [XmtpResolver] Found root message from cache: ${cached.id}`
|
|
162
163
|
: `✅ [XmtpResolver] Found cached null root for: ${messageId}`
|