mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 15:55:18 +00:00
2d07988994
* generate erc20 golang interface * write interchain test that deploys ERC20 * enable deployed erc20 as a conversion pair * convert erc20 to sdk coin! * refactor: move RandomMnemonic() to util * erc20 -> cosmos coin -> ibc e2e test * add NewEvmSignerFromMnemonic to util * ci: update ibc-test cache dependency list * fix ci dependencies
26 lines
671 B
Go
26 lines
671 B
Go
package util
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/go-bip39"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
func SdkToEvmAddress(addr sdk.AccAddress) common.Address {
|
|
return common.BytesToAddress(addr.Bytes())
|
|
}
|
|
|
|
func EvmToSdkAddress(addr common.Address) sdk.AccAddress {
|
|
return sdk.AccAddress(addr.Bytes())
|
|
}
|
|
|
|
// RandomMnemonic generates a random BIP39 mnemonic from 128 bits of entropy
|
|
func RandomMnemonic() (string, error) {
|
|
entropy, err := bip39.NewEntropy(128)
|
|
if err != nil {
|
|
return "", errorsmod.Wrap(err, "failed to generate entropy for new mnemonic")
|
|
}
|
|
return bip39.NewMnemonic(entropy)
|
|
}
|