This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* evm: cleanup, remove atlas/ * rm tparse action * fix lint issue * use cases.NoLower * tidy
- Loading branch information
Showing
18 changed files
with
67 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
*.dll | ||
*.so | ||
*.dylib | ||
.dccache | ||
|
||
# Build | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package types | ||
|
||
import ( | ||
fmt "fmt" | ||
math "math" | ||
"math/big" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
const maxBitLen = 256 | ||
|
||
// SafeInt64 checks for overflows while casting a uint64 to int64 value. | ||
func SafeInt64(value uint64) (int64, error) { | ||
if value > uint64(math.MaxInt64) { | ||
return 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "uint64 value %v cannot exceed %v", value, int64(math.MaxInt64)) | ||
} | ||
|
||
return int64(value), nil | ||
} | ||
|
||
// SafeNewIntFromBigInt constructs Int from big.Int, return error if more than 256bits | ||
func SafeNewIntFromBigInt(i *big.Int) (sdk.Int, error) { | ||
if !IsValidInt256(i) { | ||
return sdk.NewInt(0), fmt.Errorf("big int out of bound: %s", i) | ||
} | ||
return sdk.NewIntFromBigInt(i), nil | ||
} | ||
|
||
// IsValidInt256 check the bound of 256 bit number | ||
func IsValidInt256(i *big.Int) bool { | ||
return i == nil || i.BitLen() <= maxBitLen | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.