Skip to content
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

Fix(evm native -> hedera): proper minted amount #327

Merged
merged 3 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/process/watcher/evm/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ func (ew *Watcher) handleBurnLog(eventLog *router.RouterBurn, q qi.Queue) {

properAmount := eventLog.Amount
if eventLog.TargetChain.Int64() == 0 {
properAmount, err = ew.contracts.RemoveDecimals(eventLog.Amount, eventLog.Token.String())
properAmount, err = ew.contracts.RemoveDecimals(properAmount, eventLog.Token.String())
if err != nil {
ew.logger.Errorf("[%s] - Failed to adjust [%s] amount [%s] decimals between chains.", eventLog.Raw.TxHash, eventLog.Token, eventLog.Amount)
ew.logger.Errorf("[%s] - Failed to adjust [%s] amount [%s] decimals between chains.", eventLog.Raw.TxHash, eventLog.Token, properAmount)
return
}
}
Expand Down Expand Up @@ -384,9 +384,9 @@ func (ew *Watcher) handleLockLog(eventLog *router.RouterLock, q qi.Queue) {

properAmount := new(big.Int).Sub(eventLog.Amount, eventLog.ServiceFee)
if eventLog.TargetChain.Int64() == 0 {
properAmount, err = ew.contracts.RemoveDecimals(eventLog.Amount, eventLog.Token.String())
properAmount, err = ew.contracts.RemoveDecimals(properAmount, eventLog.Token.String())
if err != nil {
ew.logger.Errorf("[%s] - Failed to adjust [%s] amount [%s] decimals between chains.", eventLog.Raw.TxHash, eventLog.Token, eventLog.Amount)
ew.logger.Errorf("[%s] - Failed to adjust [%s] amount [%s] decimals between chains.", eventLog.Raw.TxHash, eventLog.Token, properAmount)
return
}
}
Expand All @@ -409,7 +409,7 @@ func (ew *Watcher) handleLockLog(eventLog *router.RouterLock, q qi.Queue) {

ew.logger.Infof("[%s] - New Lock Event Log with Amount [%s], Receiver Address [%s], Source Chain [%d] and Target Chain [%d] has been found.",
eventLog.Raw.TxHash.String(),
eventLog.Amount.String(),
properAmount,
recipientAccount,
chain.Int64(),
eventLog.TargetChain.Int64())
Expand Down
5 changes: 3 additions & 2 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func Test_EVM_Hedera_Token(t *testing.T) {

// Test_EVM_Hedera_Native_Token recreates a real life situation of a user who wants to bridge an EVM native token to the Hedera infrastructure. A new wrapped token (corresponding to the native EVM one) gets minted to the bridge account, then gets transferred to the recipient account.
func Test_EVM_Hedera_Native_Token(t *testing.T) {
amount := int64(10000000000)
amount := int64(100000000000)
// Step 1: Initialize setup, smart contracts, etc.
setupEnv := setup.Load()

Expand All @@ -330,7 +330,8 @@ func Test_EVM_Hedera_Native_Token(t *testing.T) {
// Step 3: Validate Lock Event was emitted with correct data
lockEventId := validateLockEvent(receipt, expectedLockEventLog, t)

expectedAmount, err := removeDecimals(amount, common.HexToAddress(setupEnv.NativeEvmToken), evm)
bridgedAmount := new(big.Int).Sub(expectedLockEventLog.Amount, expectedLockEventLog.ServiceFee)
expectedAmount, err := removeDecimals(bridgedAmount.Int64(), common.HexToAddress(setupEnv.NativeEvmToken), evm)
if err != nil {
t.Fatal(err)
}
Expand Down