-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mx 15181 #292
Mx 15181 #292
Conversation
isNativeOnMultiversX := executor.isNativeOnMultiversX(ctx, convertedToken) | ||
|
||
if isNativeOnEthereum && isNativeOnMultiversX { | ||
return fmt.Errorf("%w isNativeOnEthereum = %v, isNativeOnMultiversX = %v", ErrInvalidSetup, isNativeOnEthereum, isNativeOnMultiversX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
return executor.ethereumClient.CheckRequiredBalance(ctx, token, amount) | ||
} | ||
// transfer to MultiversX | ||
return executor.multiversXClient.CheckRequiredBalance(ctx, convertedToken, amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from linter:
return executor.multiversXClient.CheckRequiredBalance(ctx, convertedToken, amount)
Check failure on line 626 in bridges/ethMultiversX/bridgeExecutor.goGitHub
Actions
/ Unit
executor.multiversXClient.CheckRequiredBalance undefined (type MultiversXClient has no field or method CheckRequiredBalance)
|
||
burnBalances, err := executor.ethereumClient.BurnBalances(ctx, token) | ||
if err != nil { | ||
return big.NewInt(0), err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, err ? Here and on L640
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
burnBalances, err := executor.multiversXClient.BurnBalances(ctx, token) | ||
if err != nil { | ||
return big.NewInt(0), err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, err ? Here and on L659
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
func (executor *bridgeExecutor) isNativeOnEthereum(ctx context.Context, erc20Address common.Address) bool { | ||
isNative, err := executor.ethereumClient.NativeTokens(ctx, erc20Address) | ||
if err != nil { | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this ok to assume here that the erc20 address is not native in case of an error? Also on isMintBurnOnMultiversX
function. I think we should stop the further processing in case of an error as to not force the nodes to work in an undefined way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, refactored to return also error
@@ -29,6 +29,7 @@ func ExtractListMvxToEth(batch *clients.TransferBatch) *ArgListsBatch { | |||
arg.EthTokens = append(arg.EthTokens, token) | |||
|
|||
amount := big.NewInt(0).Set(dt.Amount) | |||
amount = big.NewInt(0).Neg(amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
if isNativeOnEthereum && isNativeOnMultiversX { | ||
return fmt.Errorf("%w isNativeOnEthereum = %v, isNativeOnMultiversX = %v", ErrInvalidSetup, isNativeOnEthereum, isNativeOnMultiversX) | ||
} | ||
return isMintBurnOnEthereum, nil | ||
} | ||
|
||
func (executor *bridgeExecutor) checkRequiredMintBurnBalance(ctx context.Context, ethToken common.Address, mvxToken []byte) error { | ||
ethBalance, err := executor.ethereumClient.TokenMintedBalances(ctx, ethToken) | ||
if err != nil { | ||
return err | ||
if !isMintBurnOnEthereum && !isMintBurnOnMultiversX { | ||
return fmt.Errorf("%w isMintBurnOnEthereum = %v, isMintBurnOnMultiversX = %v", ErrInvalidSetup, isMintBurnOnEthereum, isMintBurnOnMultiversX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be reduced to one if if isMintBurnOnEthereum == isMintBurnOnMultiversX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one cannot be reduce to that because it is allowed to have both as mintBurn tokens
return big.NewInt(0), err | ||
} | ||
|
||
if isNative { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also check if burnBalances >= mintBalances? similar for L64, L662, L664
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
86fb3c9
to
8f7a096
Compare
No description provided.