Skip to content

Commit

Permalink
fix(evm native -> hedera): proper minted amount (#327)
Browse files Browse the repository at this point in the history
Signed-off-by: failfmi <[email protected]>
  • Loading branch information
failfmi authored Nov 9, 2021
1 parent 5517ed1 commit 5c8c56e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
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

0 comments on commit 5c8c56e

Please sign in to comment.