diff --git a/packages/connect/src/api/index.ts b/packages/connect/src/api/index.ts index 63231d5fbb8..ae4875072f5 100644 --- a/packages/connect/src/api/index.ts +++ b/packages/connect/src/api/index.ts @@ -37,6 +37,7 @@ export { default as getOwnershipId } from './getOwnershipId'; export { default as getOwnershipProof } from './getOwnershipProof'; export { default as getPublicKey } from './getPublicKey'; export { default as nostrGetPublicKey } from './nostrGetPublicKey'; +export { default as nostrSignEvent } from './nostrSignEvent'; export { default as getSettings } from './getSettings'; // export { default as init } from './init'; // export { default as manifest } from './manifest'; diff --git a/packages/connect/src/api/nostrSignEvent.ts b/packages/connect/src/api/nostrSignEvent.ts new file mode 100644 index 00000000000..5266df87833 --- /dev/null +++ b/packages/connect/src/api/nostrSignEvent.ts @@ -0,0 +1,32 @@ +import { Assert } from '@trezor/schema-utils'; + +import { AbstractMethod } from '../core/AbstractMethod'; +import { PROTO } from '../constants'; + +export default class NostrSignEvent extends AbstractMethod<'nostrSignEvent', PROTO.NostrSignEvent> { + init() { + this.requiredPermissions = ['read', 'write']; + + Assert(PROTO.NostrSignEvent, this.payload); + + this.params = this.payload; + } + + get info() { + return 'sign nostr event? '; + } + + get confirmation() { + return { + // todo: + view: 'export-xpub' as const, + label: 'sign?', + }; + } + + async run() { + const cmd = this.device.getCommands(); + const response = await cmd.typedCall('NostrSignEvent', 'NostrEventSignature', this.params); + return response.message; + } +} diff --git a/packages/connect/src/factory.ts b/packages/connect/src/factory.ts index aa97749b708..4b0cd0e35c9 100644 --- a/packages/connect/src/factory.ts +++ b/packages/connect/src/factory.ts @@ -150,6 +150,8 @@ export const factory = < nostrGetPublicKey: params => call({ ...params, method: 'nostrGetPublicKey' }), + nostrSignEvent: params => call({ ...params, method: 'nostrSignEvent' }), + nemGetAddress: params => call({ ...params, diff --git a/packages/connect/src/types/api/index.ts b/packages/connect/src/types/api/index.ts index f2ed7801f26..e6c465c21bc 100644 --- a/packages/connect/src/types/api/index.ts +++ b/packages/connect/src/types/api/index.ts @@ -52,6 +52,7 @@ import { getOwnershipId } from './getOwnershipId'; import { getOwnershipProof } from './getOwnershipProof'; import { getPublicKey } from './getPublicKey'; import { nostrGetPublicKey } from './nostrGetPublicKey'; +import { nostrSignEvent } from './nostrSignEvent'; import { getSettings } from './getSettings'; import { init } from './init'; import { manifest } from './manifest'; @@ -252,6 +253,9 @@ export interface TrezorConnect { // todo: nostrGetPublicKey: typeof nostrGetPublicKey; + // todo: + nostrSignEvent: typeof nostrSignEvent; + // todo: link docs getSettings: typeof getSettings; diff --git a/packages/connect/src/types/api/nostrSignEvent.ts b/packages/connect/src/types/api/nostrSignEvent.ts new file mode 100644 index 00000000000..d313713fa84 --- /dev/null +++ b/packages/connect/src/types/api/nostrSignEvent.ts @@ -0,0 +1,6 @@ +import { PROTO } from '../../constants'; +import { Params, Response } from '../params'; + +export declare function nostrSignEvent( + params: Params, +): Response;