Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@swim-io/evm": "^0.40.0",
"@swim-io/evm-contracts": "^0.40.0",
"@swim-io/pool-math": "^0.40.0",
"@swim-io/solana": "^0.40.0",
"@swim-io/solana": "workspace:^",
"@swim-io/solana-contracts": "^0.40.0",
"@swim-io/token-projects": "^0.40.0",
"@swim-io/utils": "^0.40.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
import { EuiLoadingSpinner, EuiText } from "@elastic/eui";
import type { TokenConfig } from "@swim-io/core/types";
import { SOLANA_ECOSYSTEM_ID } from "@swim-io/solana";
import { TOKEN_PROJECTS_BY_ID } from "@swim-io/token-projects";
import type { VFC } from "react";
import { useTranslation } from "react-i18next";

import { useSwimUsd } from "../../hooks";

import { TxEcosystemList } from "./TxList";

interface Props {
readonly isLoading: boolean;
readonly tokenConfig: TokenConfig;
readonly transactions: readonly string[];
}

export const ClaimSwimUsdOnSolana: VFC<Props> = ({
export const ClaimTokenOnSolana: VFC<Props> = ({
isLoading,
tokenConfig,
transactions,
}) => {
const { t } = useTranslation();
const swimUsd = useSwimUsd();

if (swimUsd === null) {
return null;
}

return (
<EuiText size="m">
<span style={{ display: "flex", alignItems: "center" }}>
{isLoading && <EuiLoadingSpinner size="m" style={{ marginRight: 8 }} />}
<span>
{t("recent_interactions.claim_token_on_solana", {
tokenName: TOKEN_PROJECTS_BY_ID[swimUsd.projectId].displayName,
tokenName: TOKEN_PROJECTS_BY_ID[tokenConfig.projectId].displayName,
})}
</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
isTargetChainOperationCompleted,
} from "../../../models";
import { AddTransfer } from "../AddTransfer";
import { ClaimSwimUsdOnSolana } from "../ClaimSwimUsdOnSolana";
import { ClaimTokenOnSolana } from "../ClaimTokenOnSolana";
import { RemoveTransfer } from "../RemoveTransfer";
import { SwapFromSwimUsd } from "../SwapFromSwimUsd";
import { SwapToSwimUsd } from "../SwapToSwimUsd";
Expand Down Expand Up @@ -314,9 +314,10 @@ const buildClaimTokenOnSolanaStep = (
interactionStatus: InteractionStatusV2,
): EuiStepProps => {
const {
claimTokenOnSolanaTxId,
postVaaOnSolanaTxIds,
swapFromSwimUsdTxId,
verifySignaturesTxIds,
postVaaOnSolanaTxId,
completeNativeWithPayloadTxId,
processSwimPayloadTxId,
interaction: {
params: { toTokenData },
},
Expand All @@ -333,21 +334,16 @@ const buildClaimTokenOnSolanaStep = (
status,
children: (
<>
<ClaimSwimUsdOnSolana
isLoading={status === "loading" && claimTokenOnSolanaTxId === null}
<ClaimTokenOnSolana
isLoading={status === "loading"}
tokenConfig={toTokenData.tokenConfig}
transactions={[
...postVaaOnSolanaTxIds,
claimTokenOnSolanaTxId,
...verifySignaturesTxIds,
postVaaOnSolanaTxId,
completeNativeWithPayloadTxId,
processSwimPayloadTxId,
].filter(isNotNull)}
/>
{!isSwimUsd(toTokenData.tokenConfig) && (
<SwapFromSwimUsd
ecosystemId={toTokenData.ecosystemId}
toToken={toTokenData.tokenConfig}
isLoading={status === "loading"}
txId={swapFromSwimUsdTxId}
/>
)}
</>
),
};
Expand Down Expand Up @@ -483,8 +479,8 @@ export const buildEuiStepsForInteraction = (
}
case SwapType.CrossChainEvmToSolana: {
return [
buildPrepareSplTokenAccountStep(state, status),
buildSwapAndTransferStep(state, status),
buildPrepareSplTokenAccountStep(state, status),
buildClaimTokenOnSolanaStep(state, status),
].filter(isNotNull);
}
Expand Down
16 changes: 9 additions & 7 deletions apps/ui/src/fixtures/swim/interactionStateV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ export const CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_INIT: CrossChainEv
requiredSplTokenAccounts: SPL_TOKEN_ACCOUNTS_INIT,
approvalTxIds: [],
crossChainInitiateTxId: null,
signatureSetAddress: null,
postVaaOnSolanaTxIds: [],
claimTokenOnSolanaTxId: null,
swapFromSwimUsdTxId: null,
auxiliarySignerPublicKey: null,
verifySignaturesTxIds: [],
postVaaOnSolanaTxId: null,
completeNativeWithPayloadTxId: null,
processSwimPayloadTxId: null,
};

export const CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_EXISTING_SPL_TOKEN_ACCOUNTS: CrossChainEvmToSolanaSwapInteractionState =
Expand All @@ -398,16 +399,17 @@ export const CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_SWAP_AND_TRANSFER_
export const CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_POST_VAA_COMPLETED: CrossChainEvmToSolanaSwapInteractionState =
{
...CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_SWAP_AND_TRANSFER_COMPLETED,
postVaaOnSolanaTxIds: [
verifySignaturesTxIds: [
"53r98E5EiffkmJ6WVA2VKmq78LVCT4zcRVxo76EWoUFiNpdxbno7UVeUT6oQgsVM3xeU99mQmnUjFVscz7PC1gK8",
"53r98E5EiffkmJ6WVA2VKmq78LVCT4zcRVxo76EWoUFiNpdxbno7UVeUT6oQgsVM3xeU99mQmnUjFVscz7PC1gK9",
],
postVaaOnSolanaTxId:
"53r98E5EiffkmJ6WVA2VKmq78LVCT4zcRVxo76EWoUFiNpdxbno7UVeUT6oQgsVM3xeU99mQmnUjFVscz7PC1gK9",
};

export const CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_COMPLETED: CrossChainEvmToSolanaSwapInteractionState =
{
...CROSS_CHAIN_EVM_TO_SOLANA_SWAP_INTERACTION_STATE_POST_VAA_COMPLETED,
claimTokenOnSolanaTxId:
completeNativeWithPayloadTxId:
"53r98E5EiffkmJ6WVA2VKmq78LVCT4zcRVxo76EWoUFiNpdxbno7UVeUT6oQgsVM3xeU99mQmnUjFVscz7PC1gK8",
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ Object {
exports[`useCreateInteractionStateV2 should create state for Swap from ETHEREUM USDC to SOLANA USDC 1`] = `
Object {
"approvalTxIds": Array [],
"claimTokenOnSolanaTxId": null,
"auxiliarySignerPublicKey": null,
"completeNativeWithPayloadTxId": null,
"crossChainInitiateTxId": null,
"interaction": Object {
"connectedWallets": Object {
Expand Down Expand Up @@ -415,7 +416,8 @@ Object {
"type": 5,
},
"interactionType": 5,
"postVaaOnSolanaTxIds": Array [],
"postVaaOnSolanaTxId": null,
"processSwimPayloadTxId": null,
"requiredSplTokenAccounts": Object {
"3ngTtoyP9GFybFifX1dr7gCFXFiM2Wr6NfXn6EuU7k6C": Object {
"isExistingAccount": false,
Expand All @@ -430,9 +432,8 @@ Object {
"txId": null,
},
},
"signatureSetAddress": null,
"swapFromSwimUsdTxId": null,
"swapType": "CrossChainEvmToSolana",
"verifySignaturesTxIds": Array [],
"version": 2,
}
`;
Expand Down
9 changes: 5 additions & 4 deletions apps/ui/src/hooks/interaction/useCreateInteractionStateV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ const createSwapInteractionState = (
requiredSplTokenAccounts,
approvalTxIds: [],
crossChainInitiateTxId: null,
signatureSetAddress: null,
postVaaOnSolanaTxIds: [],
claimTokenOnSolanaTxId: null,
swapFromSwimUsdTxId: null,
auxiliarySignerPublicKey: null,
verifySignaturesTxIds: [],
postVaaOnSolanaTxId: null,
completeNativeWithPayloadTxId: null,
processSwimPayloadTxId: null,
};
}
};
Expand Down
Loading