Skip to content

Commit

Permalink
feat(conenct): add nostrSignEvent method
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 committed Dec 11, 2024
1 parent 66aada4 commit bfa15cf
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/connect/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
32 changes: 32 additions & 0 deletions packages/connect/src/api/nostrSignEvent.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 2 additions & 0 deletions packages/connect/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export const factory = <

nostrGetPublicKey: params => call({ ...params, method: 'nostrGetPublicKey' }),

nostrSignEvent: params => call({ ...params, method: 'nostrSignEvent' }),

nemGetAddress: params =>
call({
...params,
Expand Down
4 changes: 4 additions & 0 deletions packages/connect/src/types/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -252,6 +253,9 @@ export interface TrezorConnect {
// todo:
nostrGetPublicKey: typeof nostrGetPublicKey;

// todo:
nostrSignEvent: typeof nostrSignEvent;

// todo: link docs
getSettings: typeof getSettings;

Expand Down
6 changes: 6 additions & 0 deletions packages/connect/src/types/api/nostrSignEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { PROTO } from '../../constants';
import { Params, Response } from '../params';

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

0 comments on commit bfa15cf

Please sign in to comment.