Skip to content

Commit

Permalink
Fixed swap vallues in case of manual dest address
Browse files Browse the repository at this point in the history
  • Loading branch information
babkenmes committed Dec 13, 2024
1 parent 6af9ddb commit ce807cc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 2 additions & 3 deletions components/Swap/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const SwapForm: FC<Props> = ({ partner }) => {
const { selectedSourceAccount } = useSwapDataState()
const { setSelectedSourceAccount } = useSwapDataUpdate()
const { providers, wallets } = useWallet()
console.log(providers, wallets)
const { minAllowedAmount, valuesChanger } = useFee()
const toAsset = values.toCurrency
const fromAsset = values.fromCurrency
Expand Down Expand Up @@ -144,9 +143,9 @@ const SwapForm: FC<Props> = ({ partner }) => {
const newDestinationProvider = (newTo && !toExchange) ? providers.find(p => p.autofillSupportedNetworks?.includes(newTo.name) && p.connectedWallets?.some(w => !w.isNotAvailable && w.addresses.some(a => a.toLowerCase() === selectedSourceAccount?.address.toLowerCase())))
: undefined
const oldDestinationWallet = newDestinationProvider?.connectedWallets?.find(w => w.autofillSupportedNetworks?.some(n => n.toLowerCase() === newTo?.name.toLowerCase()) && w.addresses.some(a => a.toLowerCase() === values.destination_address?.toLowerCase()))
const oldDestinationWalletIsNotCompatible = destinationProvider?.name !== newDestinationProvider?.name || !(newTo && oldDestinationWallet?.autofillSupportedNetworks?.some(n => n.toLowerCase() === newTo?.name.toLowerCase()))
const oldDestinationWalletIsNotCompatible = destinationProvider && (destinationProvider?.name !== newDestinationProvider?.name || !(newTo && oldDestinationWallet?.autofillSupportedNetworks?.some(n => n.toLowerCase() === newTo?.name.toLowerCase())))
const destinationWalletIsAvailable = newTo ? newDestinationProvider?.connectedWallets?.some(w => w.autofillSupportedNetworks?.some(n => n.toLowerCase() === newTo.name.toLowerCase()) && w.addresses.some(a => a.toLowerCase() === selectedSourceAccount?.address.toLowerCase())) : undefined
const oldSourceWalletIsNotCompatible = selectedSourceAccount?.wallet.providerName !== destinationProvider?.name || !(newFrom && selectedSourceAccount?.wallet.withdrawalSupportedNetworks?.some(n => n.toLowerCase() === newFrom.name.toLowerCase()))
const oldSourceWalletIsNotCompatible = destinationProvider && (selectedSourceAccount?.wallet.providerName !== destinationProvider?.name || !(newFrom && selectedSourceAccount?.wallet.withdrawalSupportedNetworks?.some(n => n.toLowerCase() === newFrom.name.toLowerCase())))

const changeDestinationAddress = newTo && (oldDestinationWalletIsNotCompatible || oldSourceWalletIsNotCompatible) && destinationWalletIsAvailable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export class WalletConnectConnector extends PredicateConnector {
public async connect(): Promise<boolean> {
this.createModal();
const result = await new Promise<boolean>((resolve, reject) => {
console.log(this.config)
this.config.wagmiConfig.connectors.find((c) => c.id === 'walletConnect')?.connect()
const wagmiConfig = this.getWagmiConfig();
const unsub = this.appKit.subscribeEvents(async (event) => {
Expand Down

0 comments on commit ce807cc

Please sign in to comment.