You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code change adds a new test case to the fusion-swap.ts test suite, which calculates and prints the transaction cost when the source asset is the native SOL token (native source). The test sets up an order with srcMint set to NATIVE_MINT and srcAssetIsNative set to true. It constructs a transaction that transfers lamports to Alice's associated token account (ATA) for the native mint, synchronizes the native account, executes the create instruction of the program, and finally prints the transaction costs.
Issues and Suggestions:
Missing Associated Token Account for Native Mint
Issue: The test assumes that Alice's associated token account for the native mint (NATIVE_MINT) already exists. If this ATA does not exist, transferring lamports to it will fail because the account does not exist on-chain.
Suggestion: Ensure that Alice's ATA for the native mint exists before attempting the transfer. If it might not exist, add an instruction to create it:
import{createAssociatedTokenAccountInstruction}from"@solana/spl-token";constataAddress=state.alice.atas[splToken.NATIVE_MINT.toString()].address;constataExists=awaitprovider.connection.getAccountInfo(ataAddress);if(!ataExists){tx.add(createAssociatedTokenAccountInstruction(state.alice.keypair.publicKey,// payerataAddress,// ATA addressstate.alice.keypair.publicKey,// ownersplToken.NATIVE_MINT// mint));}
Action: Include a check and create the ATA if it doesn't exist to prevent transaction failure.
Unnecessary Inclusion of payer in Signers
Issue: The sendAndConfirmTransaction function includes payer in the signers array along with state.alice.keypair. If payer is not required to sign any instructions in this transaction, including it is unnecessary and could cause confusion.
Suggestion: Remove payer from the signers array if it's not needed:
Action: Verify if payer needs to sign the transaction. If not, exclude it from the signers to streamline the transaction.
By addressing these issues, the test will be more robust and conform to best practices, ensuring that it functions correctly in all scenarios.
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
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.