From fac45f793b037746e527a3d07e30624dced60534 Mon Sep 17 00:00:00 2001 From: homura Date: Tue, 23 Jul 2024 19:52:35 +0900 Subject: [PATCH] feat(rpc): new method test_tx_pool_accept --- packages/rpc/__tests__/ckb-rpc-helpers.js | 2 +- packages/rpc/src/Base/index.ts | 5 +++++ packages/rpc/src/Base/pool.ts | 8 ++++++++ packages/rpc/src/resultFormatter.ts | 5 ++++- packages/rpc/src/types/api.ts | 8 +++++++- packages/rpc/src/types/rpc.ts | 5 +++++ 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/rpc/__tests__/ckb-rpc-helpers.js b/packages/rpc/__tests__/ckb-rpc-helpers.js index 85607d63e..78797b8a5 100644 --- a/packages/rpc/__tests__/ckb-rpc-helpers.js +++ b/packages/rpc/__tests__/ckb-rpc-helpers.js @@ -33,7 +33,7 @@ describe('ckb-rpc settings and helpers', () => { }) it('has 47 basic rpc', () => { - expect(Object.values(rpc)).toHaveLength(47) + expect(Object.values(rpc)).toHaveLength(48) }) it('set node url to http://test.localhost:8114', () => { diff --git a/packages/rpc/src/Base/index.ts b/packages/rpc/src/Base/index.ts index 4af67a2df..b5ca6bcab 100644 --- a/packages/rpc/src/Base/index.ts +++ b/packages/rpc/src/Base/index.ts @@ -536,6 +536,11 @@ export interface Base { ) => Promise; getDeploymentsInfo: () => Promise; + + testTxPoolAccept: ( + tx: CKBComponents.RawTransaction, + outputsValidator?: CKBComponents.OutputsValidator + ) => Promise; } export class Base { diff --git a/packages/rpc/src/Base/pool.ts b/packages/rpc/src/Base/pool.ts index a5d9a3364..caa8e2f14 100644 --- a/packages/rpc/src/Base/pool.ts +++ b/packages/rpc/src/Base/pool.ts @@ -27,4 +27,12 @@ export default { paramsFormatters: [], resultFormatters: resultFmts.toRawTxPool, }, + + testTxPoolAccept: { + method: "test_tx_pool_accept", + paramsFormatters: [ + paramsFmts.toRawTransaction, + paramsFmts.toOutputsValidator, + ], + }, }; diff --git a/packages/rpc/src/resultFormatter.ts b/packages/rpc/src/resultFormatter.ts index 5bde78d2a..d89c583c6 100644 --- a/packages/rpc/src/resultFormatter.ts +++ b/packages/rpc/src/resultFormatter.ts @@ -139,7 +139,10 @@ const toTip = (tip: RPC.Tip): CKBComponents.Tip => ({ function isBlockWithCycles(value: unknown): value is BlockWithCycles { return ( - !!value && typeof value === "object" && "block" in value && "cycles" in value + !!value && + typeof value === "object" && + "block" in value && + "cycles" in value ); } diff --git a/packages/rpc/src/types/api.ts b/packages/rpc/src/types/api.ts index 596cd89da..1e066e14f 100644 --- a/packages/rpc/src/types/api.ts +++ b/packages/rpc/src/types/api.ts @@ -38,7 +38,7 @@ export namespace CKBComponents { Proposed = "proposed", Committed = "committed", } - + export type Cycle = string; export type ScriptHashType = api.HashType; export type DepType = "code" | "depGroup"; @@ -319,6 +319,12 @@ export namespace CKBComponents { } export type DeploymentPos = api.DeploymentPos; + + export interface EntryCompleted { + cycles: Cycle; + /// Cached tx fee + fee: Capacity; + } export type DeploymentState = api.DeploymentState; export type DeploymentInfo = api.DeploymentInfo; export type DeploymentsInfo = api.DeploymentsInfo; diff --git a/packages/rpc/src/types/rpc.ts b/packages/rpc/src/types/rpc.ts index a19139027..2074af2a3 100644 --- a/packages/rpc/src/types/rpc.ts +++ b/packages/rpc/src/types/rpc.ts @@ -549,4 +549,9 @@ export namespace RPC { is_initial_block_download: boolean; alerts: Vec; } + + export interface EntryCompleted { + cycles: Cycles; + fee: Capacity; + } }