Update rewards api - #12
Conversation
There was a problem hiding this comment.
PR Summary
This PR updates the Coinbase SDK to handle changes in the rewards API, focusing on timestamp formatting and empty balance handling.
- Updated
HistoricalBalance.fromModel()insrc/coinbase/historical_balance.tsto handle empty string amounts - Modified
StakingReward.amount()insrc/coinbase/staking_reward.tsto return 0 for empty string amounts - Added
src/examples/solana_list_rewards.tsdemonstrating Solana staking rewards and balances retrieval - Updated test files to reflect API changes and new empty string handling
- Potential issue: Hardcoded future date (2024) in the Solana example script may cause unexpected behavior
5 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings
| const asset = Asset.fromModel(model.asset); | ||
| return new HistoricalBalance( | ||
| asset.fromAtomicAmount(new Decimal(model.amount)), | ||
| model.amount != "" ? asset.fromAtomicAmount(new Decimal(model.amount)) : new Decimal(0), |
There was a problem hiding this comment.
style: Consider using model.amount === '' for strict equality comparison
| * @returns The amount. | ||
| */ | ||
| public amount(): Amount { | ||
| if (this.model.amount == "") return 0; |
There was a problem hiding this comment.
style: Consider using strict equality (===) instead of loose equality (==) for consistency with TypeScript best practices.
| async function printStakingInfo() { | ||
| Coinbase.configureFromJson({ filePath: "~/Downloads/cdp_api_key.json" }); | ||
|
|
||
| const startTime = new Date(2024, 5).toISOString(); |
There was a problem hiding this comment.
logic: Using a future date (2024) as the start time may lead to unexpected results or errors. Consider using a more recent or dynamic start date.
| console.log(balances); | ||
| } | ||
|
|
||
| printStakingInfo(); |
There was a problem hiding this comment.
style: Function is defined but not exported. If this file is intended to be used as a module, consider exporting the function.
What changed? Why?
Rewards api changes
Qualified Impact