diff --git a/.changeset/hip-plums-warn.md b/.changeset/hip-plums-warn.md new file mode 100644 index 00000000..e7cf6ac8 --- /dev/null +++ b/.changeset/hip-plums-warn.md @@ -0,0 +1,11 @@ +--- +"@ckb-ccc/core": patch +--- + +feat(core): extra infos in the response of getTransaction + +- blockNumber +- blockHash +- cycles +- reason (When failed) +- txIndex (After CKB 0.118) diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 00000000..8f014124 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,22 @@ +{ + "mode": "pre", + "tag": "alpha", + "initialVersions": { + "@ckb-ccc/ccc": "0.0.12", + "ckb-ccc": "0.0.12", + "@ckb-ccc/connector": "0.0.12", + "@ckb-ccc/connector-react": "0.0.12", + "@ckb-ccc/core": "0.0.12", + "@ckb-ccc/ccc-demo": "0.0.1", + "@ckb-ccc/eip6963": "0.0.12", + "@ckb-ccc/faucet": "0.0.1", + "@ckb-ccc/joy-id": "0.0.12", + "@ckb-ccc/lumos-patches": "0.0.12", + "@ckb-ccc/nip07": "0.0.12", + "@ckb-ccc/okx": "0.0.12", + "@ckb-ccc/rei": "0.0.12", + "@ckb-ccc/uni-sat": "0.0.12", + "@ckb-ccc/utxo-global": "0.0.12" + }, + "changesets": [] +} diff --git a/packages/core/src/client/clientTypes.ts b/packages/core/src/client/clientTypes.ts index ed84777b..a5a4ae93 100644 --- a/packages/core/src/client/clientTypes.ts +++ b/packages/core/src/client/clientTypes.ts @@ -28,6 +28,11 @@ export type TransactionStatus = export type ClientTransactionResponse = { transaction: Transaction; status: TransactionStatus; + cycles?: Num; + blockHash?: Hex; + blockNumber?: Num; + txIndex?: Num; + reason?: string; }; /** diff --git a/packages/core/src/client/jsonRpc/transformers.ts b/packages/core/src/client/jsonRpc/transformers.ts index bfa4ae2c..34dbb8a6 100644 --- a/packages/core/src/client/jsonRpc/transformers.ts +++ b/packages/core/src/client/jsonRpc/transformers.ts @@ -19,7 +19,7 @@ import { depTypeFrom, hashTypeFrom, } from "../../ckb/index.js"; -import { Hex } from "../../hex/index.js"; +import { Hex, HexLike, hexFrom } from "../../hex/index.js"; import { NumLike, numFrom, numToHex } from "../../num/index.js"; import { apply } from "../../utils/index.js"; import { @@ -172,10 +172,18 @@ export class JsonRpcTransformers { }); } static transactionResponseTo({ - tx_status: { status }, + cycles, + tx_status: { status, block_number, block_hash, tx_index, reason }, transaction, }: { - tx_status: { status: TransactionStatus }; + cycles?: NumLike; + tx_status: { + status: TransactionStatus; + block_hash?: HexLike; + tx_index?: NumLike; + block_number?: NumLike; + reason?: string; + }; transaction: JsonRpcTransaction | null; }): ClientTransactionResponse | undefined { if (transaction == null) { @@ -185,6 +193,11 @@ export class JsonRpcTransformers { return { transaction: JsonRpcTransformers.transactionTo(transaction), status, + cycles: apply(numFrom, cycles), + blockHash: apply(hexFrom, block_hash), + blockNumber: apply(numFrom, block_number), + txIndex: apply(numFrom, tx_index), + reason, }; } static blockHeaderTo(header: JsonRpcBlockHeader): ClientBlockHeader {