From fc94460a700f8f81267ad786d5dec35de2baa779 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Fri, 15 Nov 2024 19:12:59 +0700 Subject: [PATCH] Release 0.0.4 Core|0.0.5 CDP Langchain|0.0.4 Twitter Langchain --- cdp-agentkit-core/CHANGELOG.md | 4 +++ .../actions/wow/buy_token.py | 36 ++++++++++--------- .../actions/wow/sell_token.py | 31 ++++++++-------- cdp-agentkit-core/docs/conf.py | 2 +- cdp-agentkit-core/pyproject.toml | 2 +- .../tests/actions/wow/test_buy_token.py | 14 ++++---- .../tests/actions/wow/test_sell_token.py | 14 ++++---- cdp-langchain/CHANGELOG.md | 7 ++++ cdp-langchain/docs/conf.py | 2 +- cdp-langchain/pyproject.toml | 4 +-- twitter-langchain/pyproject.toml | 4 +-- 11 files changed, 71 insertions(+), 49 deletions(-) diff --git a/cdp-agentkit-core/CHANGELOG.md b/cdp-agentkit-core/CHANGELOG.md index 0d2507605..3a5487c34 100644 --- a/cdp-agentkit-core/CHANGELOG.md +++ b/cdp-agentkit-core/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## [0.0.4] - 2024-11-15 + +### Added + - Added `wow_buy_token` and `wow_sell_token`. - Added `token_uri` to `wow_create_token` action for custom token metadata. - Refactor twitter actions to conform to extendable `twitter-langchain` updates. diff --git a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py index 2b40a7362..bf1be2915 100644 --- a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py +++ b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py @@ -47,22 +47,26 @@ def wow_buy_token(wallet: Wallet, contract_address: str, amount_eth_in_wei: str) min_tokens = str(int((token_quote * 99) // 100)) # Using integer division to floor the result has_graduated = get_has_graduated(wallet.network_id, contract_address) - invocation = wallet.invoke_contract( - contract_address=contract_address, - method="buy", - abi=WOW_ABI, - args={ - "recipient": wallet.default_address.address_id, - "refundRecipient": wallet.default_address.address_id, - "orderReferrer": "0x0000000000000000000000000000000000000000", - "expectedMarketType": has_graduated and "1" or "0", - "minOrderSize": min_tokens, - "sqrtPriceLimitX96": "0", - "comment": "", - }, - amount=amount_eth_in_wei, - asset_id="wei", - ).wait() + + try: + invocation = wallet.invoke_contract( + contract_address=contract_address, + method="buy", + abi=WOW_ABI, + args={ + "recipient": wallet.default_address.address_id, + "refundRecipient": wallet.default_address.address_id, + "orderReferrer": "0x0000000000000000000000000000000000000000", + "expectedMarketType": has_graduated and "1" or "0", + "minOrderSize": min_tokens, + "sqrtPriceLimitX96": "0", + "comment": "", + }, + amount=amount_eth_in_wei, + asset_id="wei", + ).wait() + except Exception as e: + return f"Error buying Zora Wow ERC20 memecoin {e!s}" return f"Purchased WoW ERC20 memecoin with transaction hash: {invocation.transaction.transaction_hash}" diff --git a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py index 536af1fe3..44a9c99e3 100644 --- a/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py +++ b/cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py @@ -47,20 +47,23 @@ def wow_sell_token(wallet: Wallet, contract_address: str, amount_tokens_in_wei: # Multiply by 98/100 and floor to get 98% of quote as minimum (slippage protection) min_eth = str(int((eth_quote * 98) // 100)) - invocation = wallet.invoke_contract( - contract_address=contract_address, - method="sell", - abi=WOW_ABI, - args={ - "tokensToSell": str(amount_tokens_in_wei), - "recipient": wallet.default_address.address_id, - "orderReferrer": "0x0000000000000000000000000000000000000000", - "comment": "", - "expectedMarketType": "1" if has_graduated else "0", - "minPayoutSize": min_eth, - "sqrtPriceLimitX96": "0", - }, - ).wait() + try: + invocation = wallet.invoke_contract( + contract_address=contract_address, + method="sell", + abi=WOW_ABI, + args={ + "tokensToSell": str(amount_tokens_in_wei), + "recipient": wallet.default_address.address_id, + "orderReferrer": "0x0000000000000000000000000000000000000000", + "comment": "", + "expectedMarketType": "1" if has_graduated else "0", + "minPayoutSize": min_eth, + "sqrtPriceLimitX96": "0", + }, + ).wait() + except Exception as e: + return f"Error selling Zora Wow ERC20 memecoin {e!s}" return ( f"Sold WoW ERC20 memecoin with transaction hash: {invocation.transaction.transaction_hash}" diff --git a/cdp-agentkit-core/docs/conf.py b/cdp-agentkit-core/docs/conf.py index 85ed815b2..7b860da16 100644 --- a/cdp-agentkit-core/docs/conf.py +++ b/cdp-agentkit-core/docs/conf.py @@ -13,7 +13,7 @@ project = 'CDP Agentkit - Core' author = 'Coinbase Developer Platform' -release = '0.0.3' +release = '0.0.4' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/cdp-agentkit-core/pyproject.toml b/cdp-agentkit-core/pyproject.toml index 0ed4a40d2..526f65301 100644 --- a/cdp-agentkit-core/pyproject.toml +++ b/cdp-agentkit-core/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdp-agentkit-core" -version = "0.0.3" +version = "0.0.4" description = "CDP Agentkit core primitives" authors = ["John Peterson "] readme = "README.md" diff --git a/cdp-agentkit-core/tests/actions/wow/test_buy_token.py b/cdp-agentkit-core/tests/actions/wow/test_buy_token.py index f68245f13..a94f2bbac 100644 --- a/cdp-agentkit-core/tests/actions/wow/test_buy_token.py +++ b/cdp-agentkit-core/tests/actions/wow/test_buy_token.py @@ -124,11 +124,13 @@ def test_buy_token_api_error(wallet_factory): mock_wallet, "invoke_contract", side_effect=Exception("API error") ) as mock_invoke, ): - with pytest.raises(Exception, match="API error"): - wow_buy_token( - mock_wallet, - MOCK_CONTRACT_ADDRESS, - MOCK_AMOUNT_ETH, - ) + action_response = wow_buy_token( + mock_wallet, + MOCK_CONTRACT_ADDRESS, + MOCK_AMOUNT_ETH, + ) + + expected_response = "Error buying Zora Wow ERC20 memecoin API error" + assert action_response == expected_response mock_invoke.assert_called_once() diff --git a/cdp-agentkit-core/tests/actions/wow/test_sell_token.py b/cdp-agentkit-core/tests/actions/wow/test_sell_token.py index a2f004421..0db1ecc5e 100644 --- a/cdp-agentkit-core/tests/actions/wow/test_sell_token.py +++ b/cdp-agentkit-core/tests/actions/wow/test_sell_token.py @@ -134,11 +134,13 @@ def test_sell_token_api_error(wallet_factory): mock_wallet, "invoke_contract", side_effect=Exception("API error") ) as mock_invoke, ): - with pytest.raises(Exception, match="API error"): - wow_sell_token( - mock_wallet, - MOCK_CONTRACT_ADDRESS, - MOCK_AMOUNT_TOKENS, - ) + action_response = wow_sell_token( + mock_wallet, + MOCK_CONTRACT_ADDRESS, + MOCK_AMOUNT_TOKENS, + ) + + expected_response = "Error selling Zora Wow ERC20 memecoin API error" + assert action_response == expected_response mock_invoke.assert_called_once() diff --git a/cdp-langchain/CHANGELOG.md b/cdp-langchain/CHANGELOG.md index d3ba71291..8dc846756 100644 --- a/cdp-langchain/CHANGELOG.md +++ b/cdp-langchain/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +## [0.0.5] - 2024-11-15 + +### Added + +- Bump dependency `cdp-agentkit-core` to version `0.0.4`. + + ## [0.0.4] - 2024-11-10 ### Added diff --git a/cdp-langchain/docs/conf.py b/cdp-langchain/docs/conf.py index fb635bb01..e855435e6 100644 --- a/cdp-langchain/docs/conf.py +++ b/cdp-langchain/docs/conf.py @@ -13,7 +13,7 @@ project = 'CDP Agentkit - LangChain' author = 'Coinbase Developer Platform' -release = '0.0.4' +release = '0.0.5' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/cdp-langchain/pyproject.toml b/cdp-langchain/pyproject.toml index 73b794d7e..cccfeebc9 100644 --- a/cdp-langchain/pyproject.toml +++ b/cdp-langchain/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdp-langchain" -version = "0.0.4" +version = "0.0.5" description = "CDP Agentkit Langchain Extension" authors = ["John Peterson "] readme = "README.md" @@ -15,7 +15,7 @@ langchain-openai = "^0.2.4" langgraph = "^0.2.39" cdp-sdk = "^0.10.3" pydantic = "^2.0" -cdp-agentkit-core = "^0.0.3" +cdp-agentkit-core = "^0.0.4" [tool.poetry.group.dev.dependencies] ruff = "^0.7.1" diff --git a/twitter-langchain/pyproject.toml b/twitter-langchain/pyproject.toml index 67df9e259..d167e59be 100644 --- a/twitter-langchain/pyproject.toml +++ b/twitter-langchain/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "twitter-langchain" -version = "0.0.3" +version = "0.0.4" description = "Twitter Langchain Toolkit" authors = ["John Peterson "] license = "Apache-2.0" @@ -11,7 +11,7 @@ python = "^3.10" pydantic = "^2.9.2" langchain = "^0.3.7" tweepy = "^4.14.0" -cdp-agentkit-core = "^0.0.3" +cdp-agentkit-core = "^0.0.4" standard-imghdr = "^3.13.0" [tool.poetry.group.dev.dependencies]