Conversation
- Add sign and signAndBroadcast methods to UTXO toolboxes (Bitcoin, Litecoin, Dogecoin, Zcash) - Add sign and signAndBroadcast methods to EVM toolbox - Add unified sign and signAndBroadcast methods to Solana toolbox - Handle BitcoinCash special case with TransactionBuilder instead of PSBT - Create implementation plans for full wallet integration
- Create getSignTransaction and getSignAndBroadcastTransaction functions - Use ethers.js TransactionRequest type for incoming transactions - Ensure sign and signAndBroadcast have matching signatures - Clean separation of concerns for signing logic
- Rename 'sign' to 'signTransaction' across all toolboxes - Rename 'signAndBroadcast' to 'signAndSendTransaction' across all toolboxes - Better naming convention that clearly indicates the action being performed - Consistent naming across UTXO, EVM, and Solana toolboxes
| @@ -1,416 +1,426 @@ | |||
| // biome-ignore assist/source/useSortedKeys: keys are sorted by topic | |||
Comment on lines
153
to
160
| .with(Chain.Tron, async () => { | ||
| const transaction = TronTransactionSchema.safeParse(tx); | ||
| if (!transaction.success) { | ||
| throw new SwapKitError("plugin_swapkit_invalid_tx_data", { chain, tx }); | ||
| } | ||
|
|
||
| return await getWallet(chain as Chain.Tron).signAndBroadcastTransaction(transaction.data); | ||
| }) |
Collaborator
There was a problem hiding this comment.
how about:
Suggested change
| .with(Chain.Tron, async () => { | |
| const transaction = TronTransactionSchema.safeParse(tx); | |
| if (!transaction.success) { | |
| throw new SwapKitError("plugin_swapkit_invalid_tx_data", { chain, tx }); | |
| } | |
| return await getWallet(chain as Chain.Tron).signAndBroadcastTransaction(transaction.data); | |
| }) | |
| .with(...CosmosChains, Chain.Near, Chain.Tron, async (chain) => { | |
| const transaction = safeTxParse({ chain, tx }) | |
| if (!transaction.success) { | |
| throw new SwapKitError("plugin_swapkit_invalid_tx_data", { chain, tx }); | |
| } | |
| return await getWallet(chain).signAndBroadcastTransaction(transaction.data); | |
| }) |
|
|
||
| const transaction = { ...tx, ...gasPrices, gasLimit }; | ||
|
|
||
| // Sign the transaction |
Collaborator
There was a problem hiding this comment.
Suggested change
| // Sign the transaction |
| // Sign the transaction | ||
| const signedTx = await signer.signTransaction(transaction); | ||
|
|
||
| // Broadcast the signed transaction |
Collaborator
There was a problem hiding this comment.
Suggested change
| // Broadcast the signed transaction |
| // Sign the transaction | ||
| const signedTx = await signTransaction(tx); | ||
|
|
||
| // Broadcast the signed transaction |
Collaborator
There was a problem hiding this comment.
those comments are always just rephrase code written below. Please remove
Comment on lines
+133
to
+136
| signAndBroadcastTransaction: async (transaction: Transaction | VersionedTransaction) => { | ||
| const signedTx = await signTransaction(getConnection, signer)(transaction); | ||
| return broadcastTransaction(getConnection)(signedTx); | ||
| }, |
Collaborator
There was a problem hiding this comment.
I see a way to have it cleaner in future but we can keep it for now.
I.e. we could extract this signTransaction init a little bit earlier and just pass it's instance to those functions ;)
| Transaction, | ||
| TransactionBuilder, | ||
| // @ts-expect-error | ||
| } from "@psf/bitcoincashjs-lib"; |
Collaborator
There was a problem hiding this comment.
Do we remove this dep completely? PLEASE say yes
6735d9c to
94e558a
Compare
1b0724e to
1e45499
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.