-
Notifications
You must be signed in to change notification settings - Fork 253
Add DeBridge #131
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
Open
parthg1901
wants to merge
11
commits into
blorm-network:main
Choose a base branch
from
parthg1901:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add DeBridge #131
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
699a76c
fix: correct balance variable typo and refactor token approval method
parthg1901 d73e071
feat: add DebridgeConnection
parthg1901 e516142
feat: configure debridge connection
parthg1901 3f63a39
fix: replace EthereumConnectionError with EVMConnectionError
parthg1901 067d94e
feat: connect debridge to the chain connections
parthg1901 71b893d
update README
parthg1901 c48a0c1
feat: add dlnHook parameter
parthg1901 a768197
minor changes
parthg1901 1fdcd5a
reduce required params
parthg1901 7348f14
fix: handle token approvals correctly
parthg1901 bc658cf
Merge branch 'main' into main
parthg1901 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,4 +23,5 @@ SOLANA_PRIVATE_KEY= | |
| DISCORD_TOKEN= | ||
| XAI_API_KEY= | ||
| TOGETHER_API_KEY= | ||
| DEBRIDGE_ACCESS_KEY= | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| import logging | ||
| from src.action_handler import register_action | ||
|
|
||
| logger = logging.getLogger("actions.debridge_actions") | ||
|
|
||
| @register_action("create-bridge-tx") | ||
| def create_bridge_tx(agent, **kwargs): | ||
| """Create Bridge TX using Debridge""" | ||
| try: | ||
| required_args = ['srcChainId', 'srcChainTokenIn', 'srcChainTokenInAmount', 'dstChainId', 'dstChainTokenOut', 'dstChainTokenOutAmount', 'dstChainTokenOutRecipient', 'srcChainOrderAuthorityAddress', 'dstChainOrderAuthorityAddress'] | ||
| for arg in required_args: | ||
| if arg not in kwargs: | ||
| logger.error(f"Missing required argument: {arg}") | ||
| return None | ||
|
|
||
| response = agent.connection_manager.connections["debridge"].create_bridge_tx( | ||
| srcChainId=kwargs['srcChainId'], | ||
| srcChainTokenIn=kwargs['srcChainTokenIn'], | ||
| srcChainTokenInAmount=kwargs['srcChainTokenInAmount'], | ||
| dstChainId=kwargs['dstChainId'], | ||
| dstChainTokenOut=kwargs['dstChainTokenOut'], | ||
| dstChainTokenOutAmount=kwargs['dstChainTokenOutAmount'], | ||
| dstChainTokenOutRecipient=kwargs['dstChainTokenOutRecipient'], | ||
| srcChainOrderAuthorityAddress=kwargs['srcChainOrderAuthorityAddress'], | ||
| dstChainOrderAuthorityAddress=kwargs['dstChainOrderAuthorityAddress'], | ||
| affiliateFeeRecipient=kwargs.get('affiliateFeeRecipient'), | ||
| prependOperatingExpense=kwargs.get('prependOperatingExpense', True), | ||
| affiliateFeePercent=kwargs.get('affiliateFeePercent', 0) | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to create bridge transaction: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("get-order-status") | ||
| def get_order_status(agent, **kwargs): | ||
| """Get order status using Debridge""" | ||
| try: | ||
| response = agent.connection_manager.connections["debridge"].get_order_status( | ||
| id=kwargs.get('id'), | ||
| hash=kwargs.get('hash') | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to get order status: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("get-order-details") | ||
| def get_order_details(agent, **kwargs): | ||
| """Get order details using Debridge""" | ||
| try: | ||
| if 'id' not in kwargs: | ||
| logger.error("Missing required argument: id") | ||
| return None | ||
|
|
||
| response = agent.connection_manager.connections["debridge"].get_order_details( | ||
| id=kwargs['id'] | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to get order details: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("cancel-tx") | ||
| def cancel_tx(agent, **kwargs): | ||
| """Cancel transaction using Debridge""" | ||
| try: | ||
| if 'id' not in kwargs: | ||
| logger.error("Missing required argument: id") | ||
| return None | ||
|
|
||
| response = agent.connection_manager.connections["debridge"].cancel_tx( | ||
| id=kwargs['id'] | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to cancel transaction: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("extcall-cancel-tx") | ||
| def extcall_cancel_tx(agent, **kwargs): | ||
| """External call to cancel transaction using Debridge""" | ||
| try: | ||
| if 'id' not in kwargs: | ||
| logger.error("Missing required argument: id") | ||
| return None | ||
|
|
||
| response = agent.connection_manager.connections["debridge"].extcall_cancel_tx( | ||
| id=kwargs['id'] | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to perform external call to cancel transaction: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("get-supported-chains") | ||
| def get_supported_chains(agent, **kwargs): | ||
| """Get supported chains using Debridge""" | ||
| try: | ||
| response = agent.connection_manager.connections["debridge"].get_supported_chains() | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to get supported chains: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("get-token-list") | ||
| def get_token_list(agent, **kwargs): | ||
| """Get token list using Debridge""" | ||
| try: | ||
| if 'chainId' not in kwargs: | ||
| logger.error("Missing required argument: chainId") | ||
| return None | ||
|
|
||
| response = agent.connection_manager.connections["debridge"].get_token_list( | ||
| chainId=kwargs['chainId'] | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to get token list: {str(e)}") | ||
| return None | ||
|
|
||
| @register_action("execute-bridge-tx") | ||
| def execute_bridge_tx(agent, **kwargs): | ||
| """Execute bridge transaction using Debridge""" | ||
| try: | ||
| if 'connection' not in kwargs: | ||
| logger.error("Missing required argument: connection") | ||
| return None | ||
|
|
||
| response = agent.connection_manager.connections["debridge"].execute_bridge_tx( | ||
| connection=kwargs['connection'], | ||
| compute_unit_price=kwargs.get('compute_unit_price', 200_000), | ||
| compute_unit_limit=kwargs.get('compute_unit_limit') | ||
| ) | ||
| return response | ||
| except Exception as e: | ||
| logger.error(f"Failed to execute bridge transaction: {str(e)}") | ||
| return None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.