Auto-add receiving address on wallet setup
This commit is contained in:
@@ -19,12 +19,13 @@ import {
|
||||
last,
|
||||
simpleCache,
|
||||
normalizeUrl,
|
||||
nthNe,
|
||||
} from "@welshman/lib"
|
||||
import {decrypt, Nip01Signer} from "@welshman/signer"
|
||||
import type {UploadTask} from "@welshman/editor"
|
||||
import type {Feed} from "@welshman/feeds"
|
||||
import {makeIntersectionFeed, feedFromFilters, makeRelayFeed} from "@welshman/feeds"
|
||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||
import type {TrustedEvent, EventContent, Profile} from "@welshman/util"
|
||||
import {
|
||||
WRAP,
|
||||
DELETE,
|
||||
@@ -63,6 +64,10 @@ import {
|
||||
canUploadBlob,
|
||||
encryptFile,
|
||||
makeBlossomAuthEvent,
|
||||
isPublishedProfile,
|
||||
editProfile,
|
||||
createProfile,
|
||||
uniqTags,
|
||||
} from "@welshman/util"
|
||||
import {Pool, AuthStatus, SocketStatus} from "@welshman/net"
|
||||
import {Router} from "@welshman/router"
|
||||
@@ -102,6 +107,7 @@ import {
|
||||
canDecrypt,
|
||||
ensureUnwrapped,
|
||||
userInboxRelays,
|
||||
getMembershipUrls,
|
||||
} from "@app/core/state"
|
||||
import {loadAlertStatuses} from "@app/core/requests"
|
||||
import {platform, platformName, getPushInfo} from "@app/util/push"
|
||||
@@ -772,3 +778,29 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
||||
return {error: e.toString()}
|
||||
}
|
||||
}
|
||||
|
||||
// Update Profile
|
||||
|
||||
export const updateProfile = async ({
|
||||
profile,
|
||||
shouldBroadcast = !getTag(PROTECTED, profile.event?.tags || []),
|
||||
}: {
|
||||
profile: Profile
|
||||
shouldBroadcast?: boolean
|
||||
}) => {
|
||||
const router = Router.get()
|
||||
const template = isPublishedProfile(profile) ? editProfile(profile) : createProfile(profile)
|
||||
const scenarios = [router.FromRelays(getMembershipUrls(userMembership.get()))]
|
||||
|
||||
if (shouldBroadcast) {
|
||||
scenarios.push(router.FromUser(), router.Index())
|
||||
template.tags = template.tags.filter(nthNe(0, "-"))
|
||||
} else {
|
||||
template.tags = uniqTags([...template.tags, PROTECTED])
|
||||
}
|
||||
|
||||
const event = makeEvent(template.kind, template)
|
||||
const relays = router.merge(scenarios).getUrls()
|
||||
|
||||
await publishThunk({event, relays}).result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user