Skip to content

Commit

Permalink
fix(rpc): fix the return type of get_transaction api
Browse files Browse the repository at this point in the history
the return type should include the status of the transaction
  • Loading branch information
Keith-CY committed Jul 9, 2019
1 parent 91d3fbd commit a1a5cf4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/ckb-sdk-rpc/src/defaultRPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ export class DefaultRPC {
/**
* @method getTransaction
* @memberof DefaultRPC
* @description rpc to get trasnaction by its hash
* @description rpc to get trasnaction wtih its status by its hash
* @param {string} hash - the transaction hash of the target transaction
* @return {Promise<object>} transaction object
* @return {Promise<object>} transaction object with transaction status
*/
public getTransaction!: (hash: CKBComponents.Hash) => Promise<CKBComponents.Transaction>
public getTransaction!: (hash: CKBComponents.Hash) => Promise<CKBComponents.TransactionWithStatus>

/**
* @method getBlockHash
Expand Down
6 changes: 1 addition & 5 deletions packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ declare module CKB_RPC {
export type Cycles = CKBComponents.Cycles
export type Size = CKBComponents.Size

export enum TransactionStatus {
Pending = 'pending',
Proposed = 'proposed',
Committed = 'committed',
}
export type TransactionStatus = CKBComponents.TransactionStatus

export interface Script {
args: Bytes[]
Expand Down
13 changes: 13 additions & 0 deletions packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ declare namespace CKBComponents {
export type Nonce = string
export type Cycles = string
export type Size = string
export enum TransactionStatus {
Pending = 'pending',
Proposed = 'proposed',
Committed = 'committed',
}
/**
* @typedef Bytes, keep consistent with CKB
* @description Bytes will be serialized to string
Expand Down Expand Up @@ -122,6 +127,14 @@ declare namespace CKBComponents {
hash: Hash256
}

export interface TransactionWithStatus {
transaction: Transaction
txStatus: {
blockHash: Hash256 | null
status: TransactionStatus
}
}

/**
* @typeof TransactionPoint
* @property blockNumber
Expand Down

0 comments on commit a1a5cf4

Please sign in to comment.