Skip to content

Commit

Permalink
fix_: logic for checking if the route can be established updated
Browse files Browse the repository at this point in the history
  • Loading branch information
saledjenic committed May 7, 2024
1 parent 9c2c638 commit c53b3a5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion services/wallet/bridge/cbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *CBridge) getTransferConfig(isTest bool) (*cbridge.GetTransferConfigsRes
}

func (s *CBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error) {
if from.ChainID == to.ChainID {
if from.ChainID == to.ChainID || toToken != nil {
return false, nil
}

Expand Down
2 changes: 1 addition & 1 deletion services/wallet/bridge/erc1155_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *ERC1155TransferBridge) Name() string {
}

func (s *ERC1155TransferBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error) {
return from.ChainID == to.ChainID, nil
return from.ChainID == to.ChainID && toToken == nil, nil
}

func (s *ERC1155TransferBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error) {
Expand Down
2 changes: 1 addition & 1 deletion services/wallet/bridge/erc721_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *ERC721TransferBridge) Name() string {
}

func (s *ERC721TransferBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error) {
return from.ChainID == to.ChainID, nil
return from.ChainID == to.ChainID && toToken == nil, nil
}

func (s *ERC721TransferBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error) {
Expand Down
2 changes: 1 addition & 1 deletion services/wallet/bridge/hop.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (h *HopBridge) Can(from, to *params.Network, token *token.Token, toToken *t
return false, nil
}

if from.ChainID == to.ChainID {
if from.ChainID == to.ChainID || toToken != nil {
return false, nil
}

Expand Down
2 changes: 1 addition & 1 deletion services/wallet/bridge/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *TransferBridge) Name() string {
}

func (s *TransferBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error) {
return from.ChainID == to.ChainID, nil
return from.ChainID == to.ChainID && token != nil && toToken == nil, nil
}

func (s *TransferBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error) {
Expand Down

0 comments on commit c53b3a5

Please sign in to comment.