Skip to content

Commit

Permalink
chore: updates types
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuascan committed Nov 21, 2024
1 parent 6e73afe commit 2f3ac2d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/@magic-ext/kadena/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Extension } from '@magic-sdk/commons';
import {
IUnsignedCommand,
KadenaConfig,
KadenaGetInfoResponse,
KadenaPayloadMethod,
Expand All @@ -26,8 +27,8 @@ export class KadenaExtension extends Extension.Internal<'kadena'> {
};
}

public signTransaction(hash: string): Promise<KadenaSignTransactionResponse> {
return this.request(this.utils.createJsonRpcRequestPayload(KadenaPayloadMethod.KadenaSignTransaction, [{ hash }]));
public signTransaction(tx: string | IUnsignedCommand): Promise<KadenaSignTransactionResponse> {
return this.request(this.utils.createJsonRpcRequestPayload(KadenaPayloadMethod.KadenaSignTransaction, [{ tx }]));
}

public loginWithSpireKey(): Promise<LoginWithSpireKeyResponse> {
Expand Down
25 changes: 24 additions & 1 deletion packages/@magic-ext/kadena/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,34 @@ export enum KadenaPayloadMethod {
KadenaGetInfo = 'kda_getInfo',
}

export interface KadenaSignTransactionResponse {
export type KadenaSignTransactionResponse = ISignatureWithPublicKey | SignedTransactions;

export interface ISignatureWithPublicKey {
sig: string;
pubKey: string;
}

interface Sig {
sig: string;
pubKey: string;
}

export interface IUnsignedCommand {
hash: string;
cmd: string;
sigs: [undefined];
}

interface ICommand {
hash: string;
cmd: string;
sigs: Sig[];
}

export interface SignedTransactions {
transactions: (IUnsignedCommand | ICommand)[];
}

export interface KadenaGetInfoResponse {
email: string | undefined;
issuer: string;
Expand Down

0 comments on commit 2f3ac2d

Please sign in to comment.