Skip to content

Commit

Permalink
Merge pull request #341 from shocknet/logs
Browse files Browse the repository at this point in the history
source logs
  • Loading branch information
shocknet-justin authored Oct 21, 2024
2 parents 7e41bfa + b2438d4 commit b7fb1bd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Pages/Sources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Sources = () => {


const processParsedInput = (destination: Destination) => {
console.log("processing parsed input", destination)
if (
destination.type === InputClassification.LNURL
&&
Expand All @@ -72,6 +73,7 @@ export const Sources = () => {
} else if (destination.data.includes("nprofile") || destination.type === InputClassification.LNURL || destination.type === InputClassification.LN_ADDRESS) {
setSourcePasteField(destination.data);
if (destination.data.includes("nprofile")) {
console.log("fetching beacon")
const data = decodeNprofile(destination.data);
fetchBeacon(data.pubkey, data.relays || NOSTR_RELAYS, 2 * 60).then(beacon => {
if (beacon) {
Expand Down Expand Up @@ -182,7 +184,7 @@ export const Sources = () => {
}

const addSource = useCallback(async () => {
console.log("adding")
console.log("adding source", sourcePasteField)
toggle();

if (processingSource) {
Expand All @@ -209,6 +211,7 @@ export const Sources = () => {
if (existingSpendSourceId) {
const spendSource = spendSources.sources[existingSpendSourceId];
if (adminEnrollToken && spendSource && spendSource.adminToken !== adminEnrollToken) {
console.log("resetting admin access to existing source")
setProcessingSource(true)
const client = await getNostrClient(inputSource, spendSource.keys!); // TODO: write migration to remove type override
await client.EnrollAdminToken({ admin_token: adminEnrollToken });
Expand All @@ -218,6 +221,7 @@ export const Sources = () => {
dispatch(toggleLoading({ loadingMessage: "" }))
return
}
console.log("source already exists")
setProcessingSource(false);
dispatch(toggleLoading({ loadingMessage: "" }))
toast.error(<Toast title="Error" message="Source already exists." />)
Expand All @@ -242,12 +246,13 @@ export const Sources = () => {
if (inputSource.startsWith("nprofile")) {
// nprofile


console.log("generating source pair")
const newSourceKeyPair = generateNewKeyPair();
let vanityName: string | undefined = undefined;

console.log("checking for integration data")
// integration to an existing pub account
if (integrationData.token) {
console.log("linking to existing account")
const res = await (await getNostrClient(inputSource, newSourceKeyPair))
.LinkNPubThroughToken({
token: integrationData.token,
Expand All @@ -261,8 +266,9 @@ export const Sources = () => {
}
vanityName = integrationData.lnAddress;
}

console.log("checking for invite token")
if (inviteToken) {
console.log("using invite token")
const res = await (await getNostrClient(inputSource, newSourceKeyPair))
.UseInviteLink({ invite_token: inviteToken })
if (res.status !== "OK") {
Expand All @@ -272,12 +278,13 @@ export const Sources = () => {
return;
}
}

console.log("checking for admin token")
if (adminEnrollToken) {
console.log("enrolling admin token")
const client = await getNostrClient(inputSource, newSourceKeyPair);
await client.EnrollAdminToken({ admin_token: adminEnrollToken });
}

console.log("adding source")
const resultLnurl = new URL(data!.relays![0]);
const parts = resultLnurl.hostname.split(".");
const sndleveldomain = parts.slice(-2).join('.');
Expand Down Expand Up @@ -361,6 +368,7 @@ export const Sources = () => {
return
}
}
console.log("source added")
toast.success(<Toast title="Sources" message={`${parsed ? parsed.domainName : "Nprofile"} successfuly added to sources`} />)
resetValue();
dispatch(toggleLoading({ loadingMessage: "" }))
Expand Down

0 comments on commit b7fb1bd

Please sign in to comment.