Add sign util
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
import {derived, writable} from "svelte/store"
|
import {derived, writable} from "svelte/store"
|
||||||
import {cached, randomId, append, omit, equals, assoc} from "@welshman/lib"
|
import {cached, randomId, append, omit, equals, assoc} from "@welshman/lib"
|
||||||
import {withGetter} from "@welshman/store"
|
import {withGetter} from "@welshman/store"
|
||||||
import {Wallet, WRAP, getPubkeyTagValues, HashedEvent, SignedEvent} from "@welshman/util"
|
import {
|
||||||
|
Wallet,
|
||||||
|
WRAP,
|
||||||
|
getPubkeyTagValues,
|
||||||
|
HashedEvent,
|
||||||
|
StampedEvent,
|
||||||
|
SignedEvent,
|
||||||
|
} from "@welshman/util"
|
||||||
import {
|
import {
|
||||||
Nip59,
|
Nip59,
|
||||||
WrappedSigner,
|
WrappedSigner,
|
||||||
@@ -266,6 +273,8 @@ export const getSignerFromPubkey = (pubkey: string) => {
|
|||||||
|
|
||||||
export const signer = withGetter(derived(session, getSigner))
|
export const signer = withGetter(derived(session, getSigner))
|
||||||
|
|
||||||
|
export const sign = (event: StampedEvent) => signer.get()?.sign(event)
|
||||||
|
|
||||||
export const nip44EncryptToSelf = (payload: string) => {
|
export const nip44EncryptToSelf = (payload: string) => {
|
||||||
const $pubkey = pubkey.get()
|
const $pubkey = pubkey.get()
|
||||||
const $signer = signer.get()
|
const $signer = signer.get()
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ export class Thunk {
|
|||||||
// that results from waiting for remote signers
|
// that results from waiting for remote signers
|
||||||
try {
|
try {
|
||||||
const signedEvent = await this.signer.sign(this.event, {
|
const signedEvent = await this.signer.sign(this.event, {
|
||||||
signal: AbortSignal.timeout(15_000),
|
signal: AbortSignal.timeout(30_000),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Copy the signature over since we deferred signing
|
// Copy the signature over since we deferred signing
|
||||||
|
|||||||
Reference in New Issue
Block a user