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

Feat: Support assets dynamically from the backend #72

Merged
merged 7 commits into from
Jun 19, 2024

Conversation

erdimaden
Copy link
Contributor

@erdimaden erdimaden commented Jun 18, 2024

What changed? Why?

This makes the SDK able to dynamically support any assets added from the backend.

Main changes

  • Fixes balance handling for non-hardcoded assets to convert to whole amounts using the backend specified precision
  • Fetches assets before transfer/trade so that we can convert to atomic amounts at the SDK layer without hardcoding

Qualified Impact

@erdimaden erdimaden changed the base branch from master to v0.0.8 June 18, 2024 23:40
@erdimaden erdimaden changed the title Feat/dynamic assets Feat: Support assets dynamically from the backend Jun 18, 2024
@erdimaden erdimaden marked this pull request as ready for review June 18, 2024 23:58
@@ -253,19 +272,19 @@ export class Address {
* Creates a trade model for the specified amount and assets.
*
* @param amount - The amount of the Asset to send.
* @param fromAssetId - The ID of the Asset to trade from. For Ether, eth, gwei, and wei are supported.
* @param toAssetId - The ID of the Asset to trade to. For Ether, eth, gwei, and wei are supported.
* @param fromAsset - The Asset to trade from. For Ether, eth, gwei, and wei are supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove For Ether, eth, gwei, and wei are supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! updated.

break;
case "eth":
break;
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default should be break. we are supporting more erc20s on mainnet now https://docs-cdp-developer-platform-preview.cbhq.net/wallets/docs/assets/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only for ETH, Wei, or Gwei usage. ERC20 tokens should not be able to bypass the model.asset_id !== Coinbase.toAssetId(assetId) guard.

@erdimaden erdimaden requested a review from jazz-cb June 19, 2024 00:58
@erdimaden erdimaden merged commit 068f170 into v0.0.8 Jun 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants