Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
JukLee0ira committed Dec 13, 2024
1 parent e5481c4 commit 15ef0d8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions XDCx/tradingstate/relayer_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func CheckSubTokenBalance(addr common.Address, value *big.Int, token common.Addr
if value := mapBalances[token][addr]; value != nil {
balance = value
} else {
balance = statedb.GetBalance(addr)
balance = statedb.GetBalance(addr).ToBig()
}
if balance.Cmp(value) < 0 {
return nil, errors.Errorf("value %s in token %s not enough , have : %s , want : %s ", addr.String(), token.String(), balance, value)
Expand Down Expand Up @@ -260,7 +260,7 @@ func CheckAddTokenBalance(addr common.Address, value *big.Int, token common.Addr
if value := mapBalances[token][addr]; value != nil {
balance = value
} else {
balance = statedb.GetBalance(addr)
balance = statedb.GetBalance(addr).ToBig()
}
newBalance := new(big.Int).Add(balance, value)
log.Debug("CheckAddTokenBalance settle balance: ADD XDC NATIVE BALANCE ", "token", token.String(), "address", addr.String(), "balance", balance, "value", value, "newBalance", newBalance)
Expand Down Expand Up @@ -308,7 +308,7 @@ func CheckSubRelayerFee(relayer common.Address, fee *big.Int, statedb *state.Sta
func GetTokenBalance(addr common.Address, token common.Address, statedb *state.StateDB) *big.Int {
// XDC native
if token == common.XDCNativeAddressBinary {
return statedb.GetBalance(addr)
return statedb.GetBalance(addr).ToBig()
}
// TRC tokens
if statedb.Exist(token) {
Expand Down
6 changes: 3 additions & 3 deletions XDCxlending/lendingstate/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func CheckSubTokenBalance(addr common.Address, value *big.Int, token common.Addr
if value := mapBalances[token][addr]; value != nil {
balance = value
} else {
balance = statedb.GetBalance(addr)
balance = statedb.GetBalance(addr).ToBig()
}
if balance.Cmp(value) < 0 {
return nil, errors.Errorf("value %s in token %s not enough , have : %s , want : %s ", addr.String(), common.XDCNativeAddress, balance, value)
Expand Down Expand Up @@ -213,7 +213,7 @@ func CheckAddTokenBalance(addr common.Address, value *big.Int, token common.Addr
if value := mapBalances[token][addr]; value != nil {
balance = value
} else {
balance = statedb.GetBalance(addr)
balance = statedb.GetBalance(addr).ToBig()
}
newBalance := new(big.Int).Add(balance, value)
log.Debug("CheckAddTokenBalance settle balance: ADD XDC NATIVE BALANCE ", "token", common.XDCNativeAddress, "address", addr.String(), "balance", balance, "value", value, "newBalance", newBalance)
Expand Down Expand Up @@ -261,7 +261,7 @@ func CheckSubRelayerFee(relayer common.Address, fee *big.Int, statedb *state.Sta
func GetTokenBalance(addr common.Address, token common.Address, statedb *state.StateDB) *big.Int {
// XDC native
if token == common.XDCNativeAddressBinary {
return statedb.GetBalance(addr)
return statedb.GetBalance(addr).ToBig()
}
// TRC tokens
if statedb.Exist(token) {
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract common.Addres
return nil, errBlockNumberUnsupported
}
statedb, _ := b.blockchain.State()
return statedb.GetBalance(contract), nil
return statedb.GetBalance(contract).ToBig(), nil
}

// NonceAt returns the nonce of a certain account in the blockchain.
Expand Down
8 changes: 7 additions & 1 deletion common/big.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package common

import "math/big"
import (
"math/big"

"github.com/holiman/uint256"
)

// Common big integers often used
var (
Expand All @@ -27,4 +31,6 @@ var (
Big32 = big.NewInt(32)
Big256 = big.NewInt(256)
Big257 = big.NewInt(257)

U2560 = uint256.NewInt(0)
)

0 comments on commit 15ef0d8

Please sign in to comment.