Skip to content

Commit

Permalink
update signPsbt types and added success response type
Browse files Browse the repository at this point in the history
  • Loading branch information
m-aboelenein committed Feb 28, 2024
1 parent d9ce234 commit c503e1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/request/types/btcMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type SignInputsByAddress = {
export type SignPsbtParams = {
psbt: string;
signInputs: number[] | SignInputsByAddress;
allowedSignHash: number;
allowedSignHash?: number;
broadcast?: boolean;
};

Expand All @@ -62,4 +62,4 @@ export type SignPsbtResult = {
txid?: string;
};

export type SignPsbt = MethodParamsAndResult<SendTransferParams, SendTransferResult>;
export type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
5 changes: 3 additions & 2 deletions src/request/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RpcSuccessResponse } from 'src/types';
import { GetAddresses, GetInfo, SendTransfer, SignMessage, SignPsbt } from './btcMethods';
import {
StxContractCall,
Expand Down Expand Up @@ -31,8 +32,8 @@ export type Params<Method> = Method extends keyof Requests ? Requests[Method]['p

export type Request<Method extends keyof Requests = keyof Requests> = (
requestMethod: Method,
params: Params<Method>
) => Promise<Return<Method>>;
param?: Params<Method>
) => Promise<RpcSuccessResponse<Method>>;

export * from './stxMethods';
export * from './btcMethods';
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { BitcoinProvider } from './provider';
import { Requests, Return } from './request';

export enum BitcoinNetworkType {
Mainnet = 'Mainnet',
Expand Down Expand Up @@ -57,3 +58,7 @@ export interface RpcError {
export interface RpcErrorResponse<TError extends RpcError = RpcError> extends RpcBase {
error: TError;
}

export interface RpcSuccessResponse<Method extends keyof Requests> extends RpcBase {
result: Return<Method>;
}

0 comments on commit c503e1b

Please sign in to comment.