Skip to content

Commit

Permalink
feat(connect): nostrSignEvent path
Browse files Browse the repository at this point in the history
  • Loading branch information
martykan committed Dec 12, 2024
1 parent ad11d72 commit b7da7fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 11 additions & 2 deletions packages/connect/src/api/nostrSignEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
}
}
14 changes: 12 additions & 2 deletions packages/connect/src/types/api/nostrSignEvent.ts
Original file line number Diff line number Diff line change
@@ -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<typeof NostrSignEvent>;
export const NostrSignEvent = Type.Intersect([
Type.Object({
path: DerivationPath,
}),
Type.Omit(PROTO.NostrSignEvent, Type.Literal('address_n')),
]);

export declare function nostrSignEvent(
params: Params<PROTO.NostrSignEvent>,
params: Params<NostrSignEvent>,
): Response<PROTO.NostrEventSignature>;

0 comments on commit b7da7fa

Please sign in to comment.