Skip to content

Commit a7474ec

Browse files
Merge branch 'develop'
2 parents 9e91527 + 02ad9fd commit a7474ec

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smontero/smartvaults-js-client",
3-
"version": "0.0.63",
3+
"version": "0.0.64",
44
"description": "SmartVaults javascript client",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/SmartVaults.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,6 @@ export class SmartVaults {
236236
.toFilters()
237237
const metadataEvents = await this.nostrClient.list(metadataFilter)
238238
const profiles: SmartVaultsTypes.Profile[] = await this.eventKindHandlerFactor.getHandler(Kind.Metadata).handle(metadataEvents)
239-
const verifiedKeyAgentsPubkeys = new Set(await this.getVerifiedKeyAgentsPubKeys())
240-
const unverifiedKeyAgentsPubkeys = await this.getUnverifiedKeyAgentEventsByPubkey()
241-
profiles.forEach(profile => {
242-
profile.isKeyAgent = unverifiedKeyAgentsPubkeys.has(profile.publicKey) || verifiedKeyAgentsPubkeys.has(profile.publicKey)
243-
profile.isVerified = verifiedKeyAgentsPubkeys.has(profile.publicKey)
244-
})
245239
return profiles
246240
}
247241

src/event-kind-handler/MetadataHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class MetadataHandler extends EventKindHandler {
4242
}
4343
}
4444

45-
this.store.store({ content: { publicKey, ...metadata }, id: event.id });
45+
this.store.store({ content: { publicKey, ...metadata, isKeyAgent: false, isVerified: false }, id: event.id });
4646
});
4747

4848
const results = await Promise.allSettled(fetchPromises);

src/service/NostrClient.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,45 @@ export class NostrClient {
6868
ok: [],
6969
failed: []
7070
}
71-
function onResponse(status, relay) {
71+
72+
function onOkResponse(status: string, relay: string): void {
73+
result[status].push(relay)
74+
numRelays--
75+
if (numRelays <= 0) {
76+
listeners.forEach(cb => { cb(result) })
77+
listeners = new Set()
78+
}
79+
}
80+
81+
const onFailedResponse = (status: string, relay: string, count: number): void => {
82+
if (count === 1) console.log(`Event with id ${event.id} failed to publish to ${relay}, retrying...`)
83+
if (count > 5) {
84+
console.log(`Event with id ${event.id} failed to publish to ${relay}, max retries reached`)
85+
return
86+
}
7287
result[status].push(relay)
7388
numRelays--
89+
// Retry
90+
setTimeout(() => {
91+
const pub = this.pool.publish([relay], event)
92+
pub.on('ok', (relay) => {
93+
console.log(`Retry ${count} for event ${event.id} suceeded`, relay)
94+
})
95+
pub.on('failed', (relay) => {
96+
console.log(`Retry ${count} for event ${event.id} failed, retrying...`, relay)
97+
onFailedResponse('failed', relay, count + 1)
98+
})
99+
}, 61000)
74100
if (numRelays <= 0) {
75101
listeners.forEach(cb => { cb(result) })
76102
listeners = new Set()
77103
}
78104
}
79105
pub.on('ok', (relay) => {
80-
onResponse('ok', relay)
106+
onOkResponse('ok', relay)
81107
})
82108
pub.on('failed', (relay) => {
83-
onResponse('failed', relay)
109+
onFailedResponse('failed', relay, 1)
84110
})
85111
return {
86112
on(type, cb) {

src/util/NostrUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function getTagValue(
7777
* @example
7878
* const isNip05Verified = await isNip05Verified([email protected], aliciesPublicKey);
7979
*/
80-
export async function isNip05Verified(nip05: string, publicKey: string, timeout = 700): Promise<boolean> {
80+
export async function isNip05Verified(nip05: string, publicKey: string, timeout = 1000): Promise<boolean> {
8181

8282
const HTTP_OK = 200;
8383
const nip05Array = nip05.split('@');

0 commit comments

Comments
 (0)