-
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
Add more checks #375
Add more checks #375
Changes from all commits
168520c
826424a
25e9ccd
a986084
8331a73
f781e65
e05f33c
5b0cf8b
25d6733
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,11 +277,20 @@ func (handler *EthereumHandler) IssueAndWhitelistToken(ctx context.Context, para | |
handler.checkEthTxResult(ctx, tx.Hash()) | ||
|
||
if len(params.InitialSupplyValue) > 0 { | ||
initialSupply, ok := big.NewInt(0).SetString(params.InitialSupplyValue, 10) | ||
require.True(handler, ok) | ||
|
||
if params.IsMintBurnOnEth { | ||
mintAmount, ok := big.NewInt(0).SetString(params.InitialSupplyValue, 10) | ||
require.True(handler, ok) | ||
mintAmount := big.NewInt(0) | ||
burnAmount := big.NewInt(0) | ||
|
||
tx, err = handler.SafeContract.InitSupplyMintBurn(auth, erc20Address, mintAmount, zeroValueBigInt) | ||
if params.IsNativeOnEth { | ||
burnAmount = initialSupply | ||
} else { | ||
mintAmount = initialSupply | ||
} | ||
|
||
tx, err = handler.SafeContract.InitSupplyMintBurn(auth, erc20Address, mintAmount, burnAmount) | ||
require.NoError(handler, err) | ||
handler.SimulatedChain.Commit() | ||
handler.checkEthTxResult(ctx, tx.Hash()) | ||
|
@@ -462,6 +471,30 @@ func (handler *EthereumHandler) Mint(ctx context.Context, params TestTokenParams | |
handler.checkEthTxResult(ctx, tx.Hash()) | ||
} | ||
|
||
// GetTotalBalancesForToken will return the total locked balance for the provided token | ||
func (handler *EthereumHandler) GetTotalBalancesForToken(ctx context.Context, address common.Address) *big.Int { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing comment on all new methods |
||
opts := &bind.CallOpts{Context: ctx} | ||
balance, err := handler.SafeContract.TotalBalances(opts, address) | ||
require.NoError(handler, err) | ||
return balance | ||
} | ||
|
||
// GetBurnBalanceForToken will return burn balance for the provided token | ||
func (handler *EthereumHandler) GetBurnBalanceForToken(ctx context.Context, address common.Address) *big.Int { | ||
opts := &bind.CallOpts{Context: ctx} | ||
balance, err := handler.SafeContract.BurnBalances(opts, address) | ||
require.NoError(handler, err) | ||
return balance | ||
} | ||
|
||
// GetMintBalanceForToken will return mint balance for the provided token | ||
func (handler *EthereumHandler) GetMintBalanceForToken(ctx context.Context, address common.Address) *big.Int { | ||
opts := &bind.CallOpts{Context: ctx} | ||
balance, err := handler.SafeContract.MintBalances(opts, address) | ||
require.NoError(handler, err) | ||
return balance | ||
} | ||
|
||
// Close will close the resources allocated | ||
func (handler *EthereumHandler) Close() error { | ||
return handler.SimulatedChain.Close() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,9 @@ const ( | |
getTransactionFeesFunction = "getTransactionFees" | ||
initSupplyMintBurnEsdtSafe = "initSupplyMintBurnEsdtSafe" | ||
initSupplyEsdtSafe = "initSupplyEsdtSafe" | ||
getMintBalances = "getMintBalances" | ||
getBurnBalances = "getBurnBalances" | ||
getTotalBalances = "getTotalBalances" | ||
) | ||
|
||
var ( | ||
|
@@ -800,6 +803,15 @@ func (handler *MultiversxHandler) setInitialSupply(ctx context.Context, params I | |
require.True(handler, okConvert) | ||
|
||
if params.IsMintBurnOnMvX { | ||
mintAmount := big.NewInt(0) | ||
burnAmount := big.NewInt(0) | ||
|
||
if params.IsNativeOnMvX { | ||
burnAmount = initialSupply | ||
} else { | ||
mintAmount = initialSupply | ||
} | ||
|
||
hash, txResult := handler.ChainSimulator.ScCall( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
ctx, | ||
handler.OwnerKeys.MvxSk, | ||
|
@@ -809,12 +821,13 @@ func (handler *MultiversxHandler) setInitialSupply(ctx context.Context, params I | |
initSupplyMintBurnEsdtSafe, | ||
[]string{ | ||
hex.EncodeToString([]byte(tkData.MvxChainSpecificToken)), | ||
hex.EncodeToString(initialSupply.Bytes()), | ||
hex.EncodeToString([]byte{0}), | ||
hex.EncodeToString(mintAmount.Bytes()), | ||
hex.EncodeToString(burnAmount.Bytes()), | ||
}, | ||
) | ||
|
||
log.Info("initial supply tx executed", "hash", hash, "status", txResult.Status, | ||
"initial mint", params.InitialSupplyValue, "initial burned", "0") | ||
"initial mint", mintAmount.String(), "initial burned", burnAmount.String()) | ||
} else { | ||
hash, txResult := handler.ChainSimulator.ScCall( | ||
ctx, | ||
|
@@ -986,6 +999,7 @@ func (handler *MultiversxHandler) withdrawFees(ctx context.Context, | |
hex.EncodeToString([]byte(token)), | ||
} | ||
responseData := handler.ChainSimulator.ExecuteVMQuery(ctx, handler.SafeAddress, getFunction, queryParams) | ||
require.Greater(handler, len(responseData), 0) | ||
value := big.NewInt(0).SetBytes(responseData[0]) | ||
require.Equal(handler, expectedDelta.String(), value.String()) | ||
if expectedDelta.Cmp(zeroValueBigInt) == 0 { | ||
|
@@ -1043,6 +1057,39 @@ func (handler *MultiversxHandler) TransferToken(ctx context.Context, source Keys | |
"hash", hash, "status", txResult.Status) | ||
} | ||
|
||
// GetTotalBalancesForToken will return the total locked balance for the provided token | ||
func (handler *MultiversxHandler) GetTotalBalancesForToken(ctx context.Context, token string) *big.Int { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing comments on new methods |
||
queryParams := []string{ | ||
hex.EncodeToString([]byte(token)), | ||
} | ||
responseData := handler.ChainSimulator.ExecuteVMQuery(ctx, handler.SafeAddress, getTotalBalances, queryParams) | ||
require.Greater(handler, len(responseData), 0) | ||
value := big.NewInt(0).SetBytes(responseData[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any chance that responseData is nil here, resulting in a panic while trying to access index 0? |
||
return value | ||
} | ||
|
||
// GetMintedAmountForToken will return mint balance for token | ||
func (handler *MultiversxHandler) GetMintedAmountForToken(ctx context.Context, token string) *big.Int { | ||
queryParams := []string{ | ||
hex.EncodeToString([]byte(token)), | ||
} | ||
responseData := handler.ChainSimulator.ExecuteVMQuery(ctx, handler.SafeAddress, getMintBalances, queryParams) | ||
require.Greater(handler, len(responseData), 0) | ||
value := big.NewInt(0).SetBytes(responseData[0]) | ||
return value | ||
} | ||
|
||
// GetBurnedAmountForToken will return burn balance of token | ||
func (handler *MultiversxHandler) GetBurnedAmountForToken(ctx context.Context, token string) *big.Int { | ||
queryParams := []string{ | ||
hex.EncodeToString([]byte(token)), | ||
} | ||
responseData := handler.ChainSimulator.ExecuteVMQuery(ctx, handler.SafeAddress, getBurnBalances, queryParams) | ||
require.Greater(handler, len(responseData), 0) | ||
value := big.NewInt(0).SetBytes(responseData[0]) | ||
return value | ||
} | ||
|
||
func getHexBool(input bool) string { | ||
if input { | ||
return hexTrue | ||
|
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.
missing comments on exported items. Here, on L510 & L517