mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-18 14:04:21 +01:00
problem: some zap providers don't implement the API properly
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { Product, Rocket, ValidateZapPublisher, ZapPurchase } from '@/event_helpers/rockets';
|
||||
import { unixToRelativeTime } from '@/helpers';
|
||||
import { ndk } from '@/ndk';
|
||||
import { currentUser } from '@/stores/session';
|
||||
import { Avatar, Name } from '@nostr-dev-kit/ndk-svelte-components';
|
||||
import { onDestroy } from 'svelte';
|
||||
import { derived, writable } from 'svelte/store';
|
||||
@@ -61,14 +62,22 @@
|
||||
|
||||
zapsNotInRocket.subscribe((z) => {
|
||||
z.forEach((z) => {
|
||||
ValidateZapPublisher(rocket.Event, z.ZapReceipt).then((result) => {
|
||||
if (result) {
|
||||
validPubkeys.update((existing) => {
|
||||
existing.add(z.ZapReceipt.pubkey);
|
||||
return existing;
|
||||
});
|
||||
}
|
||||
});
|
||||
ValidateZapPublisher(rocket.Event, z.ZapReceipt)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
validPubkeys.update((existing) => {
|
||||
existing.add(z.ZapReceipt.pubkey);
|
||||
return existing;
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e.pubkey && $currentUser && e.pubkey == $currentUser.pubkey) {
|
||||
alert(
|
||||
'Nostrocket could not validate that the zap receipts published on your behalf are legitimate, this usually means we could not query your lightning service provider API. Consider switching to a lightning service provider that is known to work (e.g. getAlby).'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -747,7 +747,7 @@ export async function ValidateZapPublisher(rocket: NDKEvent, zap: NDKEvent): Pro
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.catch(reject);
|
||||
.catch((e) => reject(e));
|
||||
// let z = new NDKZap({ ndk: rocket.ndk!, zappedEvent: rocket, zappedUser: rocket.author });
|
||||
// z.getZapEndpoint().then(x=>{
|
||||
// console.log(x)
|
||||
|
||||
@@ -163,6 +163,7 @@ export async function getAuthorizedZapper(rocket: NDKEvent): Promise<string> {
|
||||
z.getZapEndpoint()
|
||||
.then((url) => {
|
||||
if (url) {
|
||||
console.log(url);
|
||||
url = url.trim().replace('/callback', '');
|
||||
fetch(url).then((result) => {
|
||||
result
|
||||
@@ -170,13 +171,16 @@ export async function getAuthorizedZapper(rocket: NDKEvent): Promise<string> {
|
||||
.then((j) => {
|
||||
resolve(j.nostrPubkey);
|
||||
})
|
||||
.catch(reject);
|
||||
.catch((e) => reject(e));
|
||||
});
|
||||
} else {
|
||||
reject();
|
||||
reject({
|
||||
reason: 'could not get zap endpoint for ' + z.zappedUser.pubkey,
|
||||
pubkey: z.zappedUser.pubkey
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(reject);
|
||||
.catch((e) => reject(e));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user