From 74fe0de9394a8d6a3d5865113ecf0ead683c5cff Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Thu, 23 Nov 2023 14:14:01 +0100 Subject: [PATCH] feat: remove old logic in favor of the latest one --- webapp/config-overrides.js | 3 +- .../BestBuyingOption.types.ts | 2 +- .../components/BuyPage/BuyPage.container.tsx | 13 - webapp/src/components/BuyPage/BuyPage.tsx | 4 +- .../src/components/BuyPage/BuyPage.types.ts | 4 - .../NotEnoughMana/NotEnoughMana.module.css | 12 +- .../BuyPage/NotEnoughMana/NotEnoughMana.tsx | 14 +- .../NotEnoughMana/NotEnoughMana.types.ts | 1 - .../PriceTooLow/PriceTooLow.module.css | 14 +- .../BuyPage/PriceTooLow/PriceTooLow.tsx | 16 +- .../BuyPage/PriceTooLow/PriceTooLow.types.ts | 1 - webapp/src/components/BuyPage/index.ts | 2 +- .../BuyWithCryptoModal/BuyWithCryptoModal.tsx | 8 +- .../RouteSummary/RouteSummary.module.css | 56 --- .../RouteSummary/RouteSummary.tsx | 88 ----- webapp/src/lib/xchain_v2.ts | 355 ------------------ webapp/src/modules/analytics/track.ts | 2 + webapp/src/modules/item/actions.ts | 2 + webapp/src/modules/item/sagas.ts | 2 +- webapp/src/utils/events.ts | 2 +- 20 files changed, 20 insertions(+), 581 deletions(-) delete mode 100644 webapp/src/components/BuyPage/BuyPage.container.tsx delete mode 100644 webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.module.css delete mode 100644 webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.tsx delete mode 100644 webapp/src/lib/xchain_v2.ts diff --git a/webapp/config-overrides.js b/webapp/config-overrides.js index 6a860e2a68..397c11b3eb 100644 --- a/webapp/config-overrides.js +++ b/webapp/config-overrides.js @@ -29,10 +29,9 @@ const jestConfig = config => { '^react-native$': 'react-native-web', '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy' } - console.log('config: ', config) return config } -overridedConfig.jest = jestConfig +overridedConfig.jest = jestConfig // looks counter-intuitive, but it works module.exports = overridedConfig diff --git a/webapp/src/components/AssetPage/BestBuyingOption/BestBuyingOption.types.ts b/webapp/src/components/AssetPage/BestBuyingOption/BestBuyingOption.types.ts index e3b5e47c11..376c5a2747 100644 --- a/webapp/src/components/AssetPage/BestBuyingOption/BestBuyingOption.types.ts +++ b/webapp/src/components/AssetPage/BestBuyingOption/BestBuyingOption.types.ts @@ -18,4 +18,4 @@ export enum BuyOptions { export type OwnProps = Omit export type MapDispatchProps = Pick -export type MapDispatch = Dispatch \ No newline at end of file +export type MapDispatch = Dispatch diff --git a/webapp/src/components/BuyPage/BuyPage.container.tsx b/webapp/src/components/BuyPage/BuyPage.container.tsx deleted file mode 100644 index 3948e51ac9..0000000000 --- a/webapp/src/components/BuyPage/BuyPage.container.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { connect } from 'react-redux' -import { getIsBuyCrossChainEnabled } from '../../modules/features/selectors' -import { RootState } from '../../modules/reducer' -import { MapStateProps } from './BuyPage.types' -import BuyPage from './BuyPage' - -const mapState = (state: RootState): MapStateProps => { - return { - isBuyCrossChainEnabled: getIsBuyCrossChainEnabled(state) - } -} - -export default connect(mapState)(BuyPage) diff --git a/webapp/src/components/BuyPage/BuyPage.tsx b/webapp/src/components/BuyPage/BuyPage.tsx index 2e9c98245c..141dfe1d7d 100644 --- a/webapp/src/components/BuyPage/BuyPage.tsx +++ b/webapp/src/components/BuyPage/BuyPage.tsx @@ -59,9 +59,9 @@ const BuyPage = (props: Props) => { order={order} {...modalProps} /> - ) : ( + ) : type === AssetType.ITEM ? ( - ) + ) : null }} )} diff --git a/webapp/src/components/BuyPage/BuyPage.types.ts b/webapp/src/components/BuyPage/BuyPage.types.ts index d67c7bf00d..8d0424d510 100644 --- a/webapp/src/components/BuyPage/BuyPage.types.ts +++ b/webapp/src/components/BuyPage/BuyPage.types.ts @@ -2,8 +2,4 @@ import { AssetType } from '../../modules/asset/types' export type Props = { type: AssetType - isBuyCrossChainEnabled: boolean } - -export type OwnProps = Pick -export type MapStateProps = Pick diff --git a/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.module.css b/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.module.css index d5ba2ff660..302b5ec4b2 100644 --- a/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.module.css +++ b/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.module.css @@ -3,21 +3,10 @@ width: 460px !important; } -.card :global(.ui.button + .ui.button) { - /* Override semantic UI's width */ - margin-left: 0; -} - .card:global(.ui.card > .content) { padding: 20px 24px 24px; } -.card - :global(.ui.button:not(.icon) - > .icon:not(.button):not(.dropdown).ethereum.icon) { - margin-right: 2px; -} - .paragraph { margin-bottom: 10px; color: var(--text); @@ -31,6 +20,7 @@ margin-top: 6px; } + @media (max-width: 768px) { .card { /* Override semantic UI's width */ diff --git a/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.tsx b/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.tsx index 7f6dcdcbbe..6c49c33230 100644 --- a/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.tsx +++ b/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.tsx @@ -6,13 +6,7 @@ import { Props } from './NotEnoughMana.types' import styles from './NotEnoughMana.module.css' const NotEnoughMana = (props: Props) => { - const { - asset, - description, - onGetMana, - onBuyWithCard, - onBuyWithAnotherToken - } = props + const { asset, description, onGetMana, onBuyWithCard } = props return ( @@ -38,12 +32,6 @@ const NotEnoughMana = (props: Props) => { {t('asset_page.actions.buy_with_card')} - {onBuyWithAnotherToken ? ( - - ) : null} diff --git a/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.types.ts b/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.types.ts index 8df8204004..81336079ae 100644 --- a/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.types.ts +++ b/webapp/src/components/BuyPage/NotEnoughMana/NotEnoughMana.types.ts @@ -15,7 +15,6 @@ export type Props = { description: React.ReactNode onGetMana: typeof openBuyManaWithFiatModalRequest onBuyWithCard: (asset: Asset) => ReturnType - onBuyWithAnotherToken?: () => void } export type MapDispatchProps = Pick diff --git a/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.module.css b/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.module.css index a12552cb86..6a459bfba4 100644 --- a/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.module.css +++ b/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.module.css @@ -3,17 +3,6 @@ width: 460px !important; } -.card :global(.ui.button + .ui.button) { - /* Override semantic UI's width */ - margin-left: 0; -} - -.card - :global(.ui.button:not(.icon) - > .icon:not(.button):not(.dropdown).ethereum.icon) { - margin-right: 2px; -} - .card.buyWithCard { /* Override semantic UI's width */ width: 416px !important; @@ -31,9 +20,10 @@ padding-left: 0px !important; } + @media (max-width: 768px) { .card { /* Override semantic UI's width */ width: 100% !important; } -} +} \ No newline at end of file diff --git a/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.tsx b/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.tsx index 76725343b6..a51be81d78 100644 --- a/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.tsx +++ b/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.tsx @@ -1,6 +1,6 @@ import React from 'react' import classNames from 'classnames' -import { Button, Card, Icon } from 'decentraland-ui' +import { Button, Card } from 'decentraland-ui' import { T, t } from 'decentraland-dapps/dist/modules/translation/utils' import { getMinSaleValueInWei } from '../utils' import { Price } from '../Price' @@ -8,13 +8,7 @@ import { Props } from './PriceTooLow.types' import styles from './PriceTooLow.module.css' const PriceTooLow = (props: Props) => { - const { - chainId, - network, - isBuyWithCardPage, - onSwitchNetwork, - onBuyWithAnotherToken - } = props + const { chainId, network, isBuyWithCardPage, onSwitchNetwork } = props const humanNetwork = t(`networks.${network.toLowerCase()}`) const humanToken = t(`tokens.${network.toLowerCase()}`) @@ -60,12 +54,6 @@ const PriceTooLow = (props: Props) => { {t('global.learn_more')} ) : null} - {onBuyWithAnotherToken ? ( - - ) : null} diff --git a/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.types.ts b/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.types.ts index 0e685840e0..d5937b32ba 100644 --- a/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.types.ts +++ b/webapp/src/components/BuyPage/PriceTooLow/PriceTooLow.types.ts @@ -10,7 +10,6 @@ export type Props = { network: Network isBuyWithCardPage: boolean onSwitchNetwork: typeof switchNetworkRequest - onBuyWithAnotherToken?: () => void } export type MapStateProps = Pick diff --git a/webapp/src/components/BuyPage/index.ts b/webapp/src/components/BuyPage/index.ts index 7af85b102f..068d2b2507 100644 --- a/webapp/src/components/BuyPage/index.ts +++ b/webapp/src/components/BuyPage/index.ts @@ -1,2 +1,2 @@ -import BuyPage from './BuyPage.container' +import BuyPage from './BuyPage' export { BuyPage } diff --git a/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx b/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx index a1b94749f5..d628b19816 100644 --- a/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx +++ b/webapp/src/components/Modals/BuyWithCryptoModal/BuyWithCryptoModal.tsx @@ -87,7 +87,6 @@ export const BuyWithCryptoModal = (props: Props) => { // useStates const [providerChains, setProviderChains] = useState([]) - console.log('providerChains: ', providerChains) const [providerTokens, setProviderTokens] = useState([]) const [selectedChain, setSelectedChain] = useState(asset.chainId) const [selectedToken, setSelectedToken] = useState() @@ -101,12 +100,12 @@ export const BuyWithCryptoModal = (props: Props) => { const [showChainSelector, setShowChainSelector] = useState(false) const [showTokenSelector, setShowTokenSelector] = useState(false) - // useMemos - useEffect(() => { - crossChainProvider.init() + crossChainProvider.init() // init the provider on the mount }, []) + // useMemos + // if the tx should be done through the provider const shouldUseCrossChainProvider = useMemo( () => @@ -552,7 +551,6 @@ export const BuyWithCryptoModal = (props: Props) => { const onBuyWithCrypto = useCallback(async () => { if (route && crossChainProvider && crossChainProvider.isLibInitialized()) { onBuyItemThroughProvider(route) - // const axelarScanUrl = `https://axelarscan.io/gmp/${tx.transactionHash}` } }, [onBuyItemThroughProvider, route]) diff --git a/webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.module.css b/webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.module.css deleted file mode 100644 index 615f842a42..0000000000 --- a/webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.module.css +++ /dev/null @@ -1,56 +0,0 @@ -.summaryContainer { - display: flex; - flex-direction: column; - font-size: 14px; - color: var(--secondary-text); -} - -@keyframes wave { - 0% { - background-position: 200% 0; - } - 100% { - background-position: -200% 0; - } -} - -.summaryRow { - display: flex; - align-items: center; - margin-bottom: 2px; - align-items: center; -} - -.skeleton { - flex-shrink: 0; - background: var(--dcl-pale-black, #43404a); - margin-right: 16px; - background: linear-gradient(90deg, #43404a 25%, #63616d 50%, #43404a 75%); - background-size: 200% 100%; - animation: wave 1.5s infinite; - border-radius: 4px; -} - -.exchangeSkeleton { - width: 167px; - height: 16px; - margin-left: 6px; -} - -.composeSkeletonConatiner { - display: flex; - flex-direction: row; - align-items: center; -} - -.shortSkeleton { - width: 60px; - height: 16px; - margin-right: 0; -} - -.longSkeleton { - width: 167px; - height: 16px; - margin-left: 8px; -} diff --git a/webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.tsx b/webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.tsx deleted file mode 100644 index 0285f1d017..0000000000 --- a/webapp/src/components/Modals/BuyWithCryptoModal/RouteSummary/RouteSummary.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { ethers } from 'ethers' -import classNames from 'classnames' -import { Token, RouteResponse } from '@0xsquid/sdk/dist/types' -import { t } from 'decentraland-dapps/dist/modules/translation/utils' -import styles from './RouteSummary.module.css' - -export type RouteSummaryProps = { - route: RouteResponse | undefined - selectedToken: Token -} - -const RouteSummary = ({ route, selectedToken }: RouteSummaryProps) => { - return ( - <> -
- {t('buy_with_crypto.summary')} -
- {t('buy_with_crypto.route.exchange_rate')} - {route ? ( - <> - 1 {selectedToken.symbol} ={' '} - {route.route.estimate.exchangeRate?.slice(0, 7)} MANA - - ) : ( -
- )} -
- -
- {t('buy_with_crypto.route.estimated_route_duration')} - {route ? ( - <>{route.route.estimate.estimatedRouteDuration}s - ) : ( -
- )} -
- - {route?.route.estimate.gasCosts.map((gasCost, index) => ( - - {t('buy_with_crypto.route.gas_cost_in_token', { - cost: ethers.utils.formatEther(gasCost.amount).slice(0, 6), - token: gasCost.token.symbol, - costInUSD: gasCost.amountUsd - })} - - )) || ( -
- {[...Array(2).keys()].map((_, index) => ( -
-
- : -
-
- ))} -
- )} - {route?.route.estimate.feeCosts.map(feeCost => ( - - {t('buy_with_crypto.route.fee_cost', { - feeName: feeCost.name, - cost: ethers.utils.formatEther(feeCost.amount).slice(0, 6), - token: feeCost.token.symbol, - costInUSD: feeCost.amountUsd - })} - - )) || ( -
-
- : -
-
- )} -
- - ) -} - -export default RouteSummary diff --git a/webapp/src/lib/xchain_v2.ts b/webapp/src/lib/xchain_v2.ts deleted file mode 100644 index 74599f5622..0000000000 --- a/webapp/src/lib/xchain_v2.ts +++ /dev/null @@ -1,355 +0,0 @@ -// // import { Provider } from 'decentraland-transactions' -// import { ethers } from 'ethers' -// import { Squid } from '@0xsquid/sdk' -// import { -// RouteResponse, -// SquidCallType, -// // SlippageMode, -// ChainType -// } from '@0xsquid/sdk/dist/types' -// import { ChainId } from '@dcl/schemas' -// import { ContractName, getContract } from 'decentraland-transactions' -// import { Provider } from 'decentraland-dapps/dist/modules/wallet/types' -// import { ERC20 } from './abis/ERC20' -// import { MarketplaceV2 } from './abis/MarketplaceV2' -// import { ERC721 } from './abis/ERC721' -// import { CollectionStore } from './abis/CollectionStore' - -// export type BuyNFTXChainData = { -// fromAddress: string -// fromAmount: string -// toAmount: string -// fromToken: string -// fromChain: ChainId -// toChain: ChainId // TODO: Do we need ETH? -// enableExpress?: boolean -// slippage?: number -// nft: { -// collectionAddress: string -// tokenId: string -// price: string -// } -// // toToken: string // it will be MANA -// // toChain: ChainId.MATIC_MAINNET | ChainId.MATIC_MUMBAI // TODO: Do we need ETH? -// // toAddress: string -// } - -// export type MintNFTXChainData = Omit & { -// item: { -// collectionAddress: string -// itemId: string -// price: string -// } -// } - -// export interface XChainProvider { -// buyNFT( -// provider: Provider, -// buyNFTXChainData: BuyNFTXChainData -// ): Promise -// mintNFT(provider: Provider, ChainCallData: MintNFTXChainData): Promise -// } - -// export class AxelarProvider implements XChainProvider { -// private squid: Squid -// private initiated = false -// private squidMulticall = '0x4fd39C9E151e50580779bd04B1f7eCc310079fd3' // Squid calling contract - -// constructor() { -// // Initialize Squid SDK in the constructor -// this.squid = new Squid({ -// baseUrl: 'https://testnet.v2.api.squidrouter.com', -// // baseUrl: 'https://api.squidrouter.com', -// integratorId: 'decentraland-sdk' -// }) -// } - -// private async init() { -// if (!this.initiated) { -// await this.squid.init() -// this.initiated = true -// } -// } - -// private async executeRoute( -// route: RouteResponse, -// provider: Provider -// ): Promise { -// const { route: data } = route -// const signer = await new ethers.providers.Web3Provider(provider).getSigner() - -// // tslint:disable-next-line -// // @ts-ignore -// const txResponse = (await this.squid.executeRoute({ -// route: data, -// signer -// })) as ethers.providers.TransactionResponse -// return txResponse.wait() -// } - -// async buyNFT( -// provider: Provider, -// buyNFTXChainData: BuyNFTXChainData -// ): Promise { -// // const signer = await new ethers.providers.Web3Provider(provider).getSigner() -// const route = await this.getBuyNFTRoute(buyNFTXChainData) -// console.log('route: ', route) -// return '' -// // const tx = await this.executeRoute(route, provider) -// // console.log('tx: ', tx) -// // return tx.transactionHash -// } - -// async getBuyNFTRoute( -// buyNFTXChainData: BuyNFTXChainData -// ): Promise { -// await this.init() -// const { -// fromAddress, -// fromAmount, -// fromChain, -// fromToken, -// // toAddress, -// toChain, -// toAmount, // the item price -// // toToken, -// enableExpress = true, -// slippage = 1, -// nft: { collectionAddress, price, tokenId } -// } = buyNFTXChainData - -// const ERC20ContractInterface = new ethers.utils.Interface(ERC20) -// const marketplaceInterface = new ethers.utils.Interface(MarketplaceV2) -// const ERC721ContractInterface = new ethers.utils.Interface(ERC721) - -// const destinyChainMANA = getContract(ContractName.MANAToken, toChain) -// .address -// const destinyChainMarketplaceV2 = getContract( -// ContractName.MarketplaceV2, -// toChain -// ).address - -// return this.squid.getRoute({ -// fromAddress, -// fromAmount, -// fromToken, -// fromChain: fromChain.toString(), -// toToken: destinyChainMANA, -// toChain: toChain.toString(), -// toAddress: destinyChainMarketplaceV2, -// slippageConfig: { -// autoMode: SlippageMode.NORMAL -// }, -// postHook: { -// chainType: ChainType.EVM, -// fundAmount: '', -// fundToken: '', -// calls: [ -// // =================================== -// // Approve MANA to be spent by Decentraland contract -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.FULL_TOKEN_BALANCE, -// target: destinyChainMANA, -// value: '0', -// callData: ERC20ContractInterface.encodeFunctionData('approve', [ -// getContract(ContractName.MarketplaceV2, toChain).address, -// toAmount -// ]), -// payload: { -// tokenAddress: destinyChainMarketplaceV2, -// inputPos: 1 -// }, -// estimatedGas: '50000' -// }, -// // =================================== -// // EXECUTE ORDER -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.DEFAULT, -// target: destinyChainMANA, -// value: '0', -// callData: marketplaceInterface.encodeFunctionData('executeOrder', [ -// collectionAddress, -// tokenId, -// price -// ]), - -// payload: { -// tokenAddress: '0x', // TODO: what's this? -// inputPos: 0 -// }, -// estimatedGas: '300000' -// }, -// // =================================== -// // Transfer NFT to buyer -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.DEFAULT, -// target: collectionAddress, -// value: '0', -// callData: ERC721ContractInterface.encodeFunctionData( -// 'safeTransferFrom(address, address, uint256)', -// [this.squidMulticall, fromAddress, tokenId] -// ), -// payload: { -// tokenAddress: '0x', -// inputPos: 1 -// }, -// estimatedGas: '50000' -// }, -// // =================================== -// // Transfer remaining MANA to buyer -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.FULL_TOKEN_BALANCE, -// target: destinyChainMANA, -// value: '0', -// callData: ERC20ContractInterface.encodeFunctionData('transfer', [ -// fromAddress, -// '0' -// ]), -// payload: { -// tokenAddress: destinyChainMANA, -// // This will replace the parameter at index 1 in the encoded Function, -// // with FULL_TOKEN_BALANCE (instead of "0") -// inputPos: 1 -// }, -// estimatedGas: '50000' -// } -// ] -// } -// }) -// } - -// // MINT - -// async mintNFT( -// provider: Provider, -// mintNFTXChainData: MintNFTXChainData -// ): Promise { -// // const signer = await new ethers.providers.Web3Provider(provider).getSigner() -// const route = await this.getMintNFTRoute(mintNFTXChainData) -// const tx = await this.executeRoute(route, provider) -// console.log('tx: ', tx) -// return tx.transactionHash -// } - -// async getMintNFTRoute( -// buyNFTXChainData: MintNFTXChainData -// ): Promise { -// await this.init() -// const { -// fromAddress, -// fromAmount, -// fromChain, -// fromToken, -// // toAddress, -// toChain, -// toAmount, // the item price -// // toToken, -// enableExpress = true, -// slippage = 1, -// item: { collectionAddress, price, itemId } -// } = buyNFTXChainData - -// const ERC20ContractInterface = new ethers.utils.Interface(ERC20) -// const collectionStoreInterface = new ethers.utils.Interface(CollectionStore) - -// const destinyChainMANA = getContract(ContractName.MANAToken, toChain) -// .address -// const destinyChaiCollectionStoreAddress = getContract( -// ContractName.CollectionStore, -// toChain -// ).address - -// const args = [collectionAddress, [itemId], [price], [fromAddress]] -// console.log('args: ', args) - -// return this.squid.getRoute({ -// fromAddress, -// fromAmount, -// fromToken, -// fromChain: fromChain.toString(), -// toToken: destinyChainMANA, -// toChain: toChain.toString(), -// toAddress: destinyChaiCollectionStoreAddress, -// slippageConfig: { -// autoMode: SlippageMode.NORMAL -// }, -// postHook: { -// chainType: ChainType.EVM, -// fundAmount: '', -// fundToken: '', -// calls: [ -// // =================================== -// // Approve MANA to be spent by Decentraland contract -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.FULL_TOKEN_BALANCE, -// target: destinyChainMANA, -// value: '0', -// callData: ERC20ContractInterface.encodeFunctionData('approve', [ -// // config.decentralandBuyAddress, -// getContract(ContractName.CollectionStore, toChain).address, -// toAmount -// // config.item.price -// ]), -// payload: { -// tokenAddress: destinyChaiCollectionStoreAddress, -// inputPos: 1 -// }, -// estimatedGas: '50000' -// }, -// // =================================== -// // BUY ITEM -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.DEFAULT, -// target: destinyChainMANA, -// value: '0', // @TODO: WHY 0? -// callData: collectionStoreInterface.encodeFunctionData( -// 'buy((address,uint256[],uint256[],address[])[])', -// [[[collectionAddress, [itemId], [price], [fromAddress]]]] -// ), - -// payload: { -// tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // TODO: what's this? -// inputPos: 0 -// }, -// estimatedGas: '300000' -// }, -// // =================================== -// // Transfer remaining MANA to buyer -// // =================================== -// { -// chainType: ChainType.EVM, -// callType: SquidCallType.FULL_TOKEN_BALANCE, -// target: destinyChainMANA, -// value: '0', -// callData: ERC20ContractInterface.encodeFunctionData('transfer', [ -// fromAddress, -// '0' -// ]), -// payload: { -// tokenAddress: destinyChainMANA, - -// // This will replace the parameter at index 1 in the encoded Function, -// // with FULL_TOKEN_BALANCE (instead of "0") -// inputPos: 1 -// }, -// estimatedGas: '50000' -// } -// ] -// } -// }) -// } -// } - -export default {} \ No newline at end of file diff --git a/webapp/src/modules/analytics/track.ts b/webapp/src/modules/analytics/track.ts index 60e61e4c9c..a1ac1aca61 100644 --- a/webapp/src/modules/analytics/track.ts +++ b/webapp/src/modules/analytics/track.ts @@ -279,6 +279,8 @@ track( BUY_ITEM_CROSS_CHAIN_SUCCESS, events.BUY_ITEM_CROSS_CHAIN, ({ payload }) => ({ + fromToken: payload.route.route.params.fromToken, + fromChain: payload.route.route.params.fromChain, itemId: payload.item.itemId, contractAddress: payload.item.contractAddress, rarity: payload.item.rarity, diff --git a/webapp/src/modules/item/actions.ts b/webapp/src/modules/item/actions.ts index 77a5a3f30b..54547111c9 100644 --- a/webapp/src/modules/item/actions.ts +++ b/webapp/src/modules/item/actions.ts @@ -121,11 +121,13 @@ export const buyItemCrossChainRequest = (item: Item, route: Route) => action(BUY_ITEM_CROSS_CHAIN_REQUEST, { item, route }) export const buyItemCrossChainSuccess = ( + route: Route, chainId: ChainId, txHash: string, item: Item ) => action(BUY_ITEM_CROSS_CHAIN_SUCCESS, { + route, item, txHash, ...buildTransactionWithReceiptPayload(chainId, txHash, { diff --git a/webapp/src/modules/item/sagas.ts b/webapp/src/modules/item/sagas.ts index f0e83a61fc..b31263d858 100644 --- a/webapp/src/modules/item/sagas.ts +++ b/webapp/src/modules/item/sagas.ts @@ -309,7 +309,7 @@ export function* itemSaga(getIdentity: () => AuthIdentity | undefined) { txRespose.wait ) yield put( - buyItemCrossChainSuccess(item.chainId, tx.transactionHash, item) + buyItemCrossChainSuccess(route, item.chainId, tx.transactionHash, item) ) } } catch (error) { diff --git a/webapp/src/utils/events.ts b/webapp/src/utils/events.ts index 32a2657303..30938585c6 100644 --- a/webapp/src/utils/events.ts +++ b/webapp/src/utils/events.ts @@ -76,5 +76,5 @@ export const SEARCH_RESULT_CLICKED = 'Search Result Clicked' export const SEARCH_ALL = 'Search all results' // Buy Cross-chain -export const ERROR_GETTING_ROUTE = 'Error getting Route' export const BUY_ITEM_CROSS_CHAIN = 'Buy Item Cross Chain' +export const ERROR_GETTING_ROUTE = 'Error getting Route'