From b7da7fa9e2afd8ba336df0425219769393eab50d Mon Sep 17 00:00:00 2001 From: Tomas Martykan Date: Thu, 12 Dec 2024 14:30:18 +0100 Subject: [PATCH] feat(connect): nostrSignEvent path --- packages/connect/src/api/nostrSignEvent.ts | 13 +++++++++++-- packages/connect/src/types/api/nostrSignEvent.ts | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/connect/src/api/nostrSignEvent.ts b/packages/connect/src/api/nostrSignEvent.ts index 5266df87833..a8643764569 100644 --- a/packages/connect/src/api/nostrSignEvent.ts +++ b/packages/connect/src/api/nostrSignEvent.ts @@ -2,14 +2,22 @@ import { Assert } from '@trezor/schema-utils'; import { AbstractMethod } from '../core/AbstractMethod'; import { PROTO } from '../constants'; +import { NostrSignEvent as NostrSignEventSchema } from '../types/api/nostrSignEvent'; +import { validatePath } from '../utils/pathUtils'; export default class NostrSignEvent extends AbstractMethod<'nostrSignEvent', PROTO.NostrSignEvent> { init() { this.requiredPermissions = ['read', 'write']; - Assert(PROTO.NostrSignEvent, this.payload); + Assert(NostrSignEventSchema, this.payload); - this.params = this.payload; + const path = validatePath(this.payload.path, 3); + console.log('path', path); + + this.params = { + ...this.payload, + address_n: path, + }; } get info() { @@ -27,6 +35,7 @@ export default class NostrSignEvent extends AbstractMethod<'nostrSignEvent', PRO 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/types/api/nostrSignEvent.ts b/packages/connect/src/types/api/nostrSignEvent.ts index d313713fa84..63ba3eae354 100644 --- a/packages/connect/src/types/api/nostrSignEvent.ts +++ b/packages/connect/src/types/api/nostrSignEvent.ts @@ -1,6 +1,16 @@ +import { Type, Static } from '@trezor/schema-utils'; + import { PROTO } from '../../constants'; -import { Params, Response } from '../params'; +import { DerivationPath, Params, Response } from '../params'; + +export type NostrSignEvent = Static; +export const NostrSignEvent = Type.Intersect([ + Type.Object({ + path: DerivationPath, + }), + Type.Omit(PROTO.NostrSignEvent, Type.Literal('address_n')), +]); export declare function nostrSignEvent( - params: Params, + params: Params, ): Response;