Skip to content

Commit

Permalink
feat(rpc): new method test_tx_pool_accept
Browse files Browse the repository at this point in the history
  • Loading branch information
homura committed Jul 23, 2024
1 parent a768a44 commit fac45f7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/rpc/__tests__/ckb-rpc-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/rpc/src/Base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ export interface Base {
) => Promise<CKBComponents.FeeRateStatistics>;

getDeploymentsInfo: () => Promise<CKBComponents.DeploymentsInfo>;

testTxPoolAccept: (
tx: CKBComponents.RawTransaction,
outputsValidator?: CKBComponents.OutputsValidator
) => Promise<CKBComponents.EntryCompleted>;
}

export class Base {
Expand Down
8 changes: 8 additions & 0 deletions packages/rpc/src/Base/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ export default {
paramsFormatters: [],
resultFormatters: resultFmts.toRawTxPool,
},

testTxPoolAccept: {
method: "test_tx_pool_accept",
paramsFormatters: [
paramsFmts.toRawTransaction,
paramsFmts.toOutputsValidator,
],
},
};
5 changes: 4 additions & 1 deletion packages/rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
8 changes: 7 additions & 1 deletion packages/rpc/src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions packages/rpc/src/types/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,9 @@ export namespace RPC {
is_initial_block_download: boolean;
alerts: Vec<AlertMessage>;
}

export interface EntryCompleted {
cycles: Cycles;
fee: Capacity;
}
}

0 comments on commit fac45f7

Please sign in to comment.