Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: update tx_pool_info and get_transaction response #696

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-lies-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/base": minor
---

feat: update `TxPoolInfo` structure nervosnetwork/ckb#3894
5 changes: 5 additions & 0 deletions .changeset/funny-foxes-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/base": minor
---

feat: update `TransactionWithStatus` structure nervosnetwork/ckb#4108
5 changes: 5 additions & 0 deletions .changeset/good-donkeys-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/rpc": minor
---

**BREAKING CHANGE**: update `txPoolInfo` response nervosnetwork/ckb#3894
5 changes: 5 additions & 0 deletions .changeset/lucky-pillows-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/rpc": minor
---

**BREAKING CHANGE**: update `get_transaction` response nervosnetwork/ckb#4108
5 changes: 5 additions & 0 deletions packages/base/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface TransactionWithStatus<Tx = Transaction> {
txStatus: TxStatus;
timeAddedToPool: Uint64 | null;
cycles: Uint64 | null;
fee: Uint64 | null;
minReplaceFee: Uint64 | null;
}

export interface Cell {
Expand Down Expand Up @@ -321,6 +323,9 @@ export interface TxPoolInfo {
totalTxCycles: HexNumber;
minFeeRate: HexNumber;
lastTxsUpdatedAt: HexNumber;
minRbfRate: HexNumber;
maxTxPoolSize: HexNumber;
txSizeLimit: HexNumber;
}

export interface TxPoolIds {
Expand Down
2 changes: 2 additions & 0 deletions packages/ckb-indexer/src/transaction_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export class CKBIndexerTransactionCollector extends BaseIndexerModule.Transactio
txStatus: tx.txStatus,
cycles: tx.cycles,
timeAddedToPool: tx.timeAddedToPool,
minReplaceFee: tx.minReplaceFee,
fee: tx.fee,
})
);
return objects;
Expand Down
40 changes: 30 additions & 10 deletions packages/ckb-indexer/tests/test_cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -7082,7 +7082,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7120,7 +7122,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7158,7 +7162,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7196,7 +7202,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7234,7 +7242,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7272,7 +7282,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7310,7 +7322,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
]

Expand Down Expand Up @@ -7398,7 +7412,9 @@ const transactionsByType = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7464,7 +7480,9 @@ const transactionsByType = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
}
];

Expand Down Expand Up @@ -7533,7 +7551,9 @@ const transactionsByLockAndType = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
}
];

Expand Down
2 changes: 2 additions & 0 deletions packages/ckb-indexer/tests/transaction_collector.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,7 @@ function mockTxWithStatus({
txStatus: { status: "committed" },
timeAddedToPool: null,
cycles: null,
fee: null,
minReplaceFee: null,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export const unresolvedTransaction: TransactionWithStatus = {
},
cycles: null,
timeAddedToPool: null,
fee: null,
minReplaceFee: null,
};
export const unresolvedTransactionList: TransactionWithStatus[] = [
unresolvedTransaction,
Expand Down Expand Up @@ -253,6 +255,8 @@ export const resolvedTransaction: TransactionWithStatus = {
},
cycles: null,
timeAddedToPool: null,
fee: null,
minReplaceFee: null,
};

export const batchRequestTransaction = [
Expand Down
4 changes: 4 additions & 0 deletions packages/hd-cache/tests/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const mockTxs: TransactionWithStatus[] = [
},
timeAddedToPool: null,
cycles: null,
fee: null,
minReplaceFee: null,
},
{
transaction: {
Expand Down Expand Up @@ -124,6 +126,8 @@ const mockTxs: TransactionWithStatus[] = [
},
timeAddedToPool: null,
cycles: null,
fee: null,
minReplaceFee: null,
},
];
const headerData = {
Expand Down
10 changes: 10 additions & 0 deletions packages/rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
total_tx_cycles: totalTxCycles,
total_tx_size: totalTxSize,
min_fee_rate: minFeeRate,
min_rbf_rate: minRbfRate,
tx_size_limit: txSizeLimit,
max_tx_pool_size: maxTxPoolSize,

Check warning on line 248 in packages/rpc/src/resultFormatter.ts

View check run for this annotation

Codecov / codecov/patch

packages/rpc/src/resultFormatter.ts#L246-L248

Added lines #L246 - L248 were not covered by tests
...rest
} = info;
return {
Expand All @@ -252,6 +255,9 @@
totalTxCycles,
totalTxSize,
minFeeRate,
minRbfRate,
txSizeLimit,
maxTxPoolSize,

Check warning on line 260 in packages/rpc/src/resultFormatter.ts

View check run for this annotation

Codecov / codecov/patch

packages/rpc/src/resultFormatter.ts#L258-L260

Added lines #L258 - L260 were not covered by tests
...rest,
};
};
Expand Down Expand Up @@ -326,6 +332,8 @@
transaction,
tx_status: { block_hash: blockHash, status },
time_added_to_pool,
min_replace_fee,
fee,
...rest
} = txWithStatus;
return {
Expand All @@ -338,6 +346,8 @@
: {}),
},
timeAddedToPool: time_added_to_pool,
minReplaceFee: min_replace_fee,
fee,
...rest,
};
};
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 @@ -129,6 +129,8 @@ export namespace RPC {
};
time_added_to_pool: Uint64 | null;
cycles: Uint64 | null;
fee: Capacity | null;
min_replace_fee: Capacity | null;
}

export interface TransactionPoint {
Expand Down Expand Up @@ -236,6 +238,9 @@ export namespace RPC {
tip_number: BlockNumber;
total_tx_cycles: Cycles;
total_tx_size: Size;
min_rbf_rate: Uint64;
tx_size_limit: Uint64;
max_tx_pool_size: Uint64;
}

export interface Epoch {
Expand Down
5 changes: 4 additions & 1 deletion packages/testkit/src/mock-ckb-jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export function createCKBMockRPC(options: Options): Express {
},
time_added_to_pool: null,
cycles: null,
min_replace_fee: null,
fee: null,
};
}
);
Expand Down Expand Up @@ -140,7 +142,8 @@ export function createCKBMockRPC(options: Options): Express {
if (jsonRPCResponse) {
res.json(jsonRPCResponse);
} else {
res.sendStatus(204);
const HTTP_NO_CONTENT = 204;
res.sendStatus(HTTP_NO_CONTENT);
}
});
}
Expand Down
18 changes: 18 additions & 0 deletions website/docs/migrations/migrate-to-v0.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ Please migrate to `loadFromKeystoreJson`
+ JSON.parse(fs.readFileSync(path).toString())
```

### RPC `getTransaction`'s Response Has Been Updated

```diff
-min_replace_fee
+minReplaceFee
```

### RPC `get_`'s Response Has Been Updated

```diff
-min_rbf_rate
-tx_size_limit
-max_tx_pool_size
+minRbfRate
+txSizeLimit
+MaxTxPoolSize
```

---

## Common Methods For CKB-Related Objects
Expand Down
Loading