-
Notifications
You must be signed in to change notification settings - Fork 0
Update rewards api #12
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.ts
to handle empty string amounts - Modified
StakingReward.amount()
insrc/coinbase/staking_reward.ts
to return 0 for empty string amounts - Added
src/examples/solana_list_rewards.ts
demonstrating 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
@@ -35,7 +35,7 @@ export class HistoricalBalance { | |||
public static fromModel(model: HistoricalBalanceModel): HistoricalBalance { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using model.amount === ''
for strict equality comparison
@@ -85,6 +85,7 @@ export class StakingReward { | |||
* @returns The amount. | |||
*/ | |||
public amount(): Amount { | |||
if (this.model.amount == "") return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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