Skip to content

Commit 59f0475

Browse files
authored
V0.16.0 (#94)
* Bug fix for non-checksummed address (#91) * chore: fixed casing error for assetids * updated changelog * edited changelog to unreleased * chore: added USDC gasless transfer e2e test (#92) * chore: added USDC gasless transfer e2e test * unset dev configuration for sdk * updated CHANGELOG * Milan/v0.16.0 release prep (#93) * skipped gasless transfer test * chore: bumped version to v0.16.0
1 parent 539bb86 commit 59f0475

File tree

7 files changed

+65
-11
lines changed

7 files changed

+65
-11
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# CDP Python SDK Changelog
22

3+
## [0.16.0] - 2025-01-28
4+
5+
### Added
6+
7+
- Add E2E test for gasless transfers `Wallet.createTransfer({..., gasless: true})`
8+
9+
### Fixed
10+
11+
- Fixed a bug where non-checksummed asset IDs were throwing an error.
12+
313
## [0.15.0] - 2025-01-17
414

515
### Added

cdp/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.15.0"
1+
__version__ = "0.16.0"

cdp/asset.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ def from_model(cls, model: AssetModel, asset_id: str | None = None) -> "Asset":
4141
"""
4242
decimals = model.decimals
4343

44-
if asset_id and asset_id != model.asset_id:
45-
match asset_id:
46-
case "gwei":
47-
decimals = GWEI_DECIMALS
48-
case "wei":
49-
decimals = 0
50-
case _:
51-
raise ValueError(f"Unsupported asset ID: {asset_id}")
44+
if asset_id and model.asset_id:
45+
normalized_asset_id = asset_id.lower()
46+
normalized_model_asset_id = model.asset_id.lower()
47+
48+
if normalized_asset_id != normalized_model_asset_id:
49+
match normalized_asset_id:
50+
case "gwei":
51+
decimals = GWEI_DECIMALS
52+
case "wei":
53+
decimals = 0
54+
case _:
55+
raise ValueError(f"Unsupported asset ID: {asset_id}")
5256

5357
return cls(
5458
network_id=model.network_id,

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
project = 'CDP SDK'
1616
author = 'Coinbase Developer Platform'
17-
release = '0.15.0'
17+
release = '0.16.0'
1818

1919
# -- General configuration ---------------------------------------------------
2020
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cdp-sdk"
3-
version = "0.15.0"
3+
version = "0.16.0"
44
description = "CDP Python SDK"
55
authors = ["John Peterson <[email protected]>"]
66
license = "LICENSE.md"

tests/test_asset.py

+16
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ def test_asset_from_model_with_invalid_asset_id(asset_model_factory):
5252
with pytest.raises(ValueError, match="Unsupported asset ID: invalid"):
5353
Asset.from_model(asset_model, asset_id="invalid")
5454

55+
def test_asset_from_model_with_non_checksummed_address(asset_model_factory):
56+
"""Test asset from model with non-checksummed address."""
57+
asset_model = asset_model_factory(asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98", decimals=18)
58+
59+
asset = Asset.from_model(asset_model, asset_id="0x8309fbdf021edf768dc13195741940ba544dea98")
60+
assert asset.asset_id == "0x8309fbdf021edf768dc13195741940ba544dea98"
61+
assert asset.decimals == 18
62+
63+
def test_asset_from_model_with_checksummed_address(asset_model_factory):
64+
"""Test asset from model with checksummed address."""
65+
asset_model = asset_model_factory(asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98", decimals=18)
66+
67+
asset = Asset.from_model(asset_model, asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98")
68+
assert asset.asset_id == "0x8309fbdF021eDF768DC13195741940ba544dEa98"
69+
assert asset.decimals == 18
70+
5571

5672
@patch("cdp.Cdp.api_clients")
5773
def test_asset_fetch(mock_api_clients, asset_model_factory):

tests/test_e2e.py

+24
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,27 @@ def test_historical_balances(imported_wallet):
170170
balances = list(imported_wallet.default_address.historical_balances("eth"))
171171
assert balances
172172
assert all(balance.amount > 0 for balance in balances)
173+
174+
175+
@pytest.mark.skip(reason="Gasless transfers have unpredictable latency")
176+
def test_gasless_transfer(imported_wallet):
177+
"""Test gasless transfer."""
178+
destination_wallet = Wallet.create()
179+
180+
initial_source_balance = imported_wallet.balance("usdc")
181+
initial_dest_balance = destination_wallet.balance("usdc")
182+
183+
transfer = imported_wallet.transfer(
184+
amount=Decimal("0.000001"), asset_id="usdc", gasless=True, destination=destination_wallet
185+
).wait()
186+
187+
time.sleep(20)
188+
189+
assert transfer.status.value == "complete"
190+
191+
final_source_balance = imported_wallet.balance("usdc")
192+
final_dest_balance = destination_wallet.balance("usdc")
193+
194+
assert final_source_balance < initial_source_balance
195+
assert final_dest_balance > initial_dest_balance
196+
assert final_dest_balance == Decimal("0.000001")

0 commit comments

Comments
 (0)