feat: add across action provider (ts) - #566
Conversation
✅ Heimdall Review Status
|
KanishkKhurana
left a comment
There was a problem hiding this comment.
left one comment around manual txn simulation and executing the deposit txn.
overall, really good job from an Across Protocol integration POV
| } | ||
|
|
||
| // Simulate the deposit transaction | ||
| const { request } = await acrossClient.simulateDepositTx({ |
There was a problem hiding this comment.
Diving deep into the logic behind this, are we simulating txn and executing the deposit fn manually because there's no way to trigger a wallet extension ?
I ask because we have the executeQuote function which will be able to wrap complexities around txn simulation and executing the deposit txn.
overall this is a stellar job. thank you for putting in the effort here!
There was a problem hiding this comment.
Hi @KanishkKhurana , thank you for the feedback!
I initially used executeQuote which would indeed simplify the process. This works fine until progress.step === "deposit" is succesful but then throws errors in the progress.step === "fill" step. I suspect this is because no RPC was available for the destination chain.
Now thinking about it again, it might work when we just add the destination chain to the viem client. It would certainly be nice to also return the fill txHash. A bit busy atm but will give it a try in the next days and get back to you
There was a problem hiding this comment.
So executeQuote would work if provided with an additional publicClient for the destinationChain.
However, I think it is best to stick to the current manual tx implementation to avoid some edge cases where the fill transaction is delayed significantly. The agent would then be stuck and not return any response for an extended period of time.
In my last commit, I added the depositID to the 'bridge_token' tool output
and implemented a 'check_deposit_status' tool to check the status for a given depositID
CarsonRoscoe
left a comment
There was a problem hiding this comment.
Please add a entry into typescript/agentkit/README.md's ## Action Providers section, so this action is discoverable via readmes
Note: entries are in alphabetical order
Added entry to README |
|
Hi @CarsonRoscoe, thanks for the feedback, I implemented the changes. I have one question about the wallets created by CdpWalletProvider and saved in wallet_data.txt when using the chatbot.ts example script. Is there an easy way to use this wallet on a different chain? It seems editing the networkId in wallet_data.txt and reimporting has no effect. You can export the private key of the cdpWallet but then importing only supports mnemonicPhrase. If the chain cannot be easily switched, do we need a warning for wallets created with CdpWalletProvider or do not default the recipient address to sender? |
There was a problem hiding this comment.
re: Wallet question
Yes, the current version of the CDP server wallet exports to 1 wallet per chain. The same API keys work on all the networks, however it will generate a different address/private key per network.
We understand the current wallet persistence approach is lacking. We're exploring other approaches, for example in the python side, if you run pipx run create-onchain-agent --beginnner to generate a chatbot, you can see here that we handle the wallets on a per-network basis now.
We will be refactoring all the examples shortly to use a similar approach in order to make sure that its a different wallet generated per network.
The temporary solution to the question regarding networks is to rename your file when you change networks. i.e. rename towallet_data_base_sepolia.txt when you switch networks and generate a new wallet, and then rename back when you go back. After the refactor, this process will happen automatically for you.
OK I see, thanks for the info. Imo it would be better to have the same address on all chains. My concern in relation to this cross-chain action is that a user sends eg ETH from Base to Ethereum with destinationAdress = senderAdress. But then after switching to Ethereum a new wallet is created and the funds deposited at destinationAdress are not accessible (within AgentKit). But even if that happens, I suppose its possible to export the private key and then import it in MM or another wallet, so the funds would at least not be lost. |
Agreed. Fyi, multi-network wallet API support is coming soon, but in the meantime, you are right that funds are safe and can be accessed through exporting the private key. You can also swap out the |
Added warning about this and recommendation to use ViemWalletProvider to across readme |
Description
Adds new action provider to perform cross-chain interactions via the Across protocol.
Across SDK is added as new dependency.
Implements:
-> supports native ETH and ERC-20 transfers (as long as supported by Across)
Tests
Checklist