Add `isX` / `assertIsX` helpers for `Client` objects
- 主要語言
- TypeScript
- 星號
- 695
- 分支
- 210
- 平均合併
- 21 小時 33 分鐘
- 30 天內合併 PR
- 90
描述
## Motivation
See https://github.com/anza-xyz/kit-plugins/pull/361#discussion_r3764610661
Many plugins include code along the lines of:
```ts
if (!client.planTransaction || !client.planTransactions) {
throw new Error('some error message')
}
```
Other objects in Kit, like `TransactionMessage`, have a rich API of `isX` and `assertIsX` helpers to check their runtime properties + type narrow.
We should add similar helpers for clients.
## Example use case
```ts
assertIsClientWithPlanningFunctions(client)
```
## Details
It would probably make sense to use the `ClientWithX` boundaries, so test for both `planTransaction` and `planTransactions` together for instance.
These would be added to the `plugin-interfaces` package alongside these types
Would also make sense to add to the wallet plugin (which doesn't have its Client type in Kit, so this is a change in kit-plugins)
Would throw `SolanaError` for the `assertIsX` helpers, removing a non-typed error path from most plugins.
貢獻指南
研究方向
Start in the plugin-interfaces package where the ClientWithX types are defined, then inspect the analogous isX and assertIsX helpers on TransactionMessage. Review the wallet plugin's Client type as well. Done means the relevant ClientWithX boundaries have runtime checks, type-narrowing assertions throw SolanaError, and tests cover the helpers.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- typescript
- 領域
- api
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100