Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
hcote committed Dec 5, 2024
1 parent 53b750d commit 5d37664
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
18 changes: 8 additions & 10 deletions packages/@magic-ext/kadena/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Extension } from '@magic-sdk/commons';
import {
KdaUnsignedCommand,
UnsignedCommand,
KadenaConfig,
KadenaPayloadMethod,
KadenaUserMetadata,
LoginWithSpireKeyResponse,
SignTransactionResponse,
SignTransactionWithSpireKeyResponse,
SpireKeyAccount,
SignatureWithPublicKey,
SignedTransactions,
} from './types';

export class KadenaExtension extends Extension.Internal<'kadena'> {
Expand All @@ -28,22 +28,20 @@ export class KadenaExtension extends Extension.Internal<'kadena'> {
};
}

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

public async signTransactionWithSpireKey(
transaction: KdaUnsignedCommand,
): Promise<SignTransactionWithSpireKeyResponse> {
public async signTransactionWithSpireKey(transaction: UnsignedCommand): Promise<SignedTransactions> {
const signedTransaction = await this.request(
this.utils.createJsonRpcRequestPayload(KadenaPayloadMethod.KadenaSignTransactionWithSpireKey, [{ transaction }]),
);
return signedTransaction;
}

public loginWithSpireKey(): Promise<LoginWithSpireKeyResponse> {
public loginWithSpireKey(): Promise<SpireKeyAccount> {
const requestPayload = this.utils.createJsonRpcRequestPayload(KadenaPayloadMethod.KadenaLoginWithSpireKey, []);
return this.request<LoginWithSpireKeyResponse>(requestPayload);
return this.request<SpireKeyAccount>(requestPayload);
}

public getUserInfo(): Promise<KadenaUserMetadata> {
Expand Down
12 changes: 6 additions & 6 deletions packages/@magic-ext/kadena/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export enum KadenaPayloadMethod {
KadenaSignTransactionWithSpireKey = 'kda_signTransactionWithSpireKey',
}

export interface SignTransactionResponse {
export interface SignatureWithPublicKey {
sig: string;
pubKey?: string;
}

export interface KdaUnsignedCommand {
export interface UnsignedCommand {
cmd: string;
hash: string;
sigs: Array<
Expand All @@ -33,7 +33,7 @@ export interface KdaUnsignedCommand {
| undefined
>;
}
export interface KdaSignedCommand {
export interface SignedCommand {
hash: string;
cmd: string;
sigs: {
Expand All @@ -42,8 +42,8 @@ export interface KdaSignedCommand {
}[];
}

export interface SignTransactionWithSpireKeyResponse {
transactions: (KdaUnsignedCommand | KdaSignedCommand)[];
export interface SignedTransactions {
transactions: (UnsignedCommand | SignedCommand)[];
}

export interface KadenaUserMetadata {
Expand Down Expand Up @@ -109,7 +109,7 @@ type Account = {
requestedFungibles?: RequestedFungible[];
};

export type LoginWithSpireKeyResponse = Account;
export type SpireKeyAccount = Account;

export type ChainId =
| '0'
Expand Down

0 comments on commit 5d37664

Please sign in to comment.