chore(ui): evm to solana swap#461
Open
ramenuncle wants to merge 8 commits intomasterfrom
Open
Conversation
21ff312 to
f9e37fb
Compare
Deploying with
|
| Latest commit: |
dd428fb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5611cb7f.swim-ui.pages.dev |
| Branch Preview URL: | https://ui-evm-to-solana-swap.swim-ui.pages.dev |
ramenuncle
commented
Oct 25, 2022
wormat
reviewed
Oct 25, 2022
| sourceChainConfig, | ||
| ); | ||
| const setComputeUnitLimitIx = ComputeBudgetProgram.setComputeUnitLimit({ | ||
| units: 900_000, |
Contributor
Author
There was a problem hiding this comment.
Not sure, just copying from solana-contracts package
Collaborator
There was a problem hiding this comment.
Could you check with Ricky what the best value for this is in each case?
Comment on lines
+178
to
+194
| const crossChainInitiateTx = await evmClient.getTx( | ||
| crossChainInitiateResponse, | ||
| ); | ||
| crossChainInitiateTxId = crossChainInitiateTx.id; | ||
| updateInteractionState(interaction.id, (draft) => { | ||
| if ( | ||
| draft.interactionType !== InteractionType.SwapV2 || | ||
| draft.swapType !== SwapType.CrossChainEvmToSolana | ||
| ) { | ||
| throw new Error("Interaction type mismatch"); | ||
| } | ||
| draft.crossChainInitiateTxId = crossChainInitiateTx.id; | ||
| }); | ||
| } | ||
| const crossChainInitiateTx = await evmClient.getTx( | ||
| crossChainInitiateTxId, | ||
| ); |
3828add to
fa7bfd2
Compare
fa7bfd2 to
1c76651
Compare
wormat
reviewed
Oct 25, 2022
wormat
reviewed
Oct 25, 2022
af975cd to
22d5e54
Compare
ramenuncle
commented
Oct 26, 2022
Comment on lines
+177
to
+220
| const completeTransferTxGenerator = | ||
| solanaClient.generateCompleteSwimSwapTxs({ | ||
| wallet: toWallet, | ||
| interactionId: interaction.id, | ||
| signedVaa: Buffer.from(signedVaa), | ||
| sourceChainConfig: fromChainConfig, | ||
| sourceWormholeChainId: ecosystems[fromEcosystem].wormholeChainId, | ||
| targetTokenNumber: tokenProject.tokenNumber, | ||
| minimumOutputAmount, | ||
| }); | ||
| for await (const result of completeTransferTxGenerator) { | ||
| updateInteractionState(interaction.id, (draft) => { | ||
| if ( | ||
| draft.interactionType !== InteractionType.SwapV2 || | ||
| draft.swapType !== SwapType.CrossChainEvmToSolana | ||
| ) { | ||
| throw new Error("Interaction type mismatch"); | ||
| } | ||
| switch (result.type) { | ||
| case SolanaTxType.SwimCreateSplTokenAccount: { | ||
| const mint = result.tx.original.meta?.preTokenBalances?.[0].mint; | ||
| if (!mint) { | ||
| throw new Error("Token account mint not found"); | ||
| } | ||
| draft.requiredSplTokenAccounts[mint].txId = result.tx.id; | ||
| break; | ||
| } | ||
| case SolanaTxType.WormholeVerifySignatures: | ||
| draft.verifySignaturesTxIds.push(result.tx.id); | ||
| break; | ||
| case SolanaTxType.WormholePostVaa: | ||
| draft.postVaaOnSolanaTxId = result.tx.id; | ||
| draft.auxiliarySignerPublicKey = | ||
| auxiliarySigner.publicKey.toBase58(); | ||
| break; | ||
| case SolanaTxType.SwimCompleteNativeWithPayload: | ||
| draft.completeNativeWithPayloadTxId = result.tx.id; | ||
| break; | ||
| case SolanaTxType.SwimProcessSwimPayload: | ||
| draft.processSwimPayloadTxId = result.tx.id; | ||
| break; | ||
| } | ||
| }); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Moved all the SolanaTx to SDK
22d5e54 to
75a19f3
Compare
wormat
reviewed
Oct 26, 2022
Collaborator
wormat
left a comment
There was a problem hiding this comment.
This is looking so good!
| } | ||
| switch (result.type) { | ||
| case SolanaTxType.SwimCreateSplTokenAccount: { | ||
| const mint = result.tx.original.meta?.preTokenBalances?.[0].mint; |
Collaborator
There was a problem hiding this comment.
Fine for now but Ricky says we can create multiple accounts in one tx.
Comment on lines
+177
to
+220
| const completeTransferTxGenerator = | ||
| solanaClient.generateCompleteSwimSwapTxs({ | ||
| wallet: toWallet, | ||
| interactionId: interaction.id, | ||
| signedVaa: Buffer.from(signedVaa), | ||
| sourceChainConfig: fromChainConfig, | ||
| sourceWormholeChainId: ecosystems[fromEcosystem].wormholeChainId, | ||
| targetTokenNumber: tokenProject.tokenNumber, | ||
| minimumOutputAmount, | ||
| }); | ||
| for await (const result of completeTransferTxGenerator) { | ||
| updateInteractionState(interaction.id, (draft) => { | ||
| if ( | ||
| draft.interactionType !== InteractionType.SwapV2 || | ||
| draft.swapType !== SwapType.CrossChainEvmToSolana | ||
| ) { | ||
| throw new Error("Interaction type mismatch"); | ||
| } | ||
| switch (result.type) { | ||
| case SolanaTxType.SwimCreateSplTokenAccount: { | ||
| const mint = result.tx.original.meta?.preTokenBalances?.[0].mint; | ||
| if (!mint) { | ||
| throw new Error("Token account mint not found"); | ||
| } | ||
| draft.requiredSplTokenAccounts[mint].txId = result.tx.id; | ||
| break; | ||
| } | ||
| case SolanaTxType.WormholeVerifySignatures: | ||
| draft.verifySignaturesTxIds.push(result.tx.id); | ||
| break; | ||
| case SolanaTxType.WormholePostVaa: | ||
| draft.postVaaOnSolanaTxId = result.tx.id; | ||
| draft.auxiliarySignerPublicKey = | ||
| auxiliarySigner.publicKey.toBase58(); | ||
| break; | ||
| case SolanaTxType.SwimCompleteNativeWithPayload: | ||
| draft.completeNativeWithPayloadTxId = result.tx.id; | ||
| break; | ||
| case SolanaTxType.SwimProcessSwimPayload: | ||
| draft.processSwimPayloadTxId = result.tx.id; | ||
| break; | ||
| } | ||
| }); | ||
| } |
wormat
approved these changes
Oct 26, 2022
Collaborator
wormat
left a comment
There was a problem hiding this comment.
Nice, let's send to manual testing then I'll publish.
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.
Testing
evm_to_solana.mov
Checklist