utils

package
v0.0.0-...-025e626 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccAddrPrefixConvert

func AccAddrPrefixConvert(srcPrefx, srcAccAddrStr, dstPrefix string) (dstAccAddrStr string, err error)

AccAddrPrefixConvert converts the account address between two different prefixes

func BuildOrderItems

func BuildOrderItems(products, sides, prices, quantities []string) ([]ordertypes.OrderItem, error)

BuildOrderItems returns the set of OrderItem params must be checked by function CheckNewOrderParams

func ConvertToDelegatorResponse

func ConvertToDelegatorResponse(delegator stakingtypes.Delegator, undelegation stakingtypes.UndelegationInfo) stakingcli.DelegatorResponse

ConvertToDelegatorResponse builds DelegatorResponse with the info of Delegator and UndelegationInfo

func CreateAccount

func CreateAccount(name, passWd string) (info keys.Info, mnemo string, err error)

CreateAccount creates a random key info with the given name and password

func CreateAccountWithMnemo

func CreateAccountWithMnemo(mnemonic, name, passWd string) (info keys.Info, mnemo string, err error)

CreateAccountWithMnemo creates the key info with the given mnemonic, name and password

func CreateAccountWithPrivateKey

func CreateAccountWithPrivateKey(privateKey, name, passWd string) (info keys.Info, err error)

CreateAccountWithPrivateKey creates the key info with the given privateKey string, name and password

func ErrClientQuery

func ErrClientQuery(errMsg string) error

ErrClientQuery returns an error when client failed in query

func ErrFilterDataFromBaseResponse

func ErrFilterDataFromBaseResponse(kind, errMsg string) error

ErrFilterDataFromBaseResponse returns an error when it failed to filter data from backend base response

func ErrFilterDataFromListResponse

func ErrFilterDataFromListResponse(kind, errMsg string) error

ErrFilterDataFromListResponse returns an error when it failed to filter data from backend list response

func ErrMarshalJSON

func ErrMarshalJSON(errMsg string) error

ErrMarshalJSON returns an error when it failed in marshaling JSON

func ErrUnmarshalJSON

func ErrUnmarshalJSON(errMsg string) error

ErrUnmarshalJSON returns an error when it failed in unmarshaling JSON

func EthAddress

func EthAddress(ethAddrStr string) ethcmn.Address

EthAddress gets the available arg for payload Build

func EthAddresses

func EthAddresses(ethAddrsStr []string) []ethcmn.Address

EthAddresses gets the available arg for payload Build

func FormatKeyToHash

func FormatKeyToHash(keyStr string) string

FormatKeyToHash converts the key string to hash

func GenerateEthPrivateKeyFromMnemo

func GenerateEthPrivateKeyFromMnemo(mnemonic string) (privKey ethsecp256k1.PrivKey, err error)

func GenerateMnemonic

func GenerateMnemonic() (mnemo string, err error)

GenerateMnemonic creates a random mnemonic

func GeneratePrivateKeyFromMnemo

func GeneratePrivateKeyFromMnemo(mnemonic string) (privKey string, err error)

GeneratePrivateKeyFromMnemo converts mnemonic to private key

func GetDataFromBaseResponse

func GetDataFromBaseResponse(bytes []byte, ptr interface{}) error

GetDataFromBaseResponse gets the detail data from the base response bytes

func GetOrderIDsFromResponse

func GetOrderIDsFromResponse(txResp *sdk.TxResponse) (orderIDs []string, err error)

GetOrderIDsFromResponse filters the orderID from the tx response a useful tool

func IsValidHexAdress

func IsValidHexAdress(address string) bool

IsValidHexAdress

func ParseTransfersStr

func ParseTransfersStr(str string) ([]types.TransferUnit, error)

ParseTransfersStr parses the whole multi-send info string into TransferUnit Example: `addr1 1fibo

addr2 2fibo`

func ParseValAddresses

func ParseValAddresses(valAddrsStr []string) ([]sdk.ValAddress, error)

ParseValAddresses parses validator address string to types.ValAddress

func ToCosmosAddress

func ToCosmosAddress(addrStr string) (accAddr sdk.AccAddress, err error)

ToCosmosAddress converts string address of cosmos and ethereum style to cosmos address

func ToHexAddress

func ToHexAddress(addrStr string) (ethAddr ethcmn.Address, err error)

ToHexAddress converts string address of cosmos and ethereum style to ethereum address

func Uint256

func Uint256(i *big.Int) *big.Int

Uint256 gets the available arg for payload Build

func UnmarshalListResponse

func UnmarshalListResponse(bz []byte, ptr interface{}) error

UnmarshalListResponse unmarshals the list response from data bytes

func ValAddrPrefixConvert

func ValAddrPrefixConvert(srcPrefx, srcValAddrStr, dstPrefix string) (dstValAddrStr string, err error)

ValAddrPrefixConvert converts the validator address between two different prefixes

Types

type PayloadBuilder

type PayloadBuilder struct {
	// contains filtered or unexported fields
}

PayloadBuilder - structure of a useful tool to build payload

func NewPayloadBuilder

func NewPayloadBuilder(binStr, abiJSON string) (payloadBuilder PayloadBuilder, err error)

NewPayloadBuilder creates a new instance of PayloadBuilder

func (*PayloadBuilder) Build

func (pb *PayloadBuilder) Build(methodName string, args ...interface{}) (payload []byte, err error)

Build gets the payload data for tx in evm module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL