util

package
v2.0.4-rc6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 35 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// IotxDecimalNum defines the number of decimal digits for IoTeX
	IotxDecimalNum = 18
	// GasPriceDecimalNum defines the number of decimal digits for gas price
	GasPriceDecimalNum = 12
)

Variables

View Source
var (
	ErrWrongType = errors.New("wrong data type held by interface{}")
)

vars

Functions

func Address

func Address(in string) (string, error)

Address returns the address corresponding to alias. if 'in' is an IoTeX address, returns 'in'

func AliasIsHdwalletKey

func AliasIsHdwalletKey(addressOrAlias string) bool

AliasIsHdwalletKey check whether to use hdwallet key

func CheckArgs

func CheckArgs(validNum ...int) cobra.PositionalArgs

CheckArgs used for check ioctl cmd arg(s)'s num

func CompileSolidity

func CompileSolidity(solc string, sourcefiles ...string) (map[string]*compiler.Contract, error)

CompileSolidity compiles all given Solidity source files.

func CompileSolidityString

func CompileSolidityString(solc, source string) (map[string]*compiler.Contract, error)

CompileSolidityString builds and returns all the contracts contained within a source string.

func ConnectToEndpoint

func ConnectToEndpoint(secure bool) (*grpc.ClientConn, error)

ConnectToEndpoint starts a new connection

func Decrypt

func Decrypt(data, key []byte) ([]byte, error)

Decrypt Takes two strings, data and key. data is the text to be decrypted and the key is the key to use for the decryption. The function will output the resulting plain text string with an error variable.

func Encrypt

func Encrypt(data, key []byte) ([]byte, error)

Encrypt Takes two string, data and key. data is the text that needs to be encrypted by key. The function will output the resulting crypto text and an error variable.

func ExecuteCmd

func ExecuteCmd(cmd *cobra.Command, args ...string) (string, error)

ExecuteCmd executes cmd with args, and return system output, e.g., help info, and error

func GetAddress

func GetAddress(in string) (string, error)

GetAddress get address from address or alias or context

func GetStakingCandidates

func GetStakingCandidates(chainClient iotexapi.APIServiceClient, offset, limit uint32) (candidateList *iotextypes.CandidateListV2, err error)

GetStakingCandidates returns staking candidates

func HashSHA256

func HashSHA256(input []byte) []byte

HashSHA256 will compute a cryptographically useful hash of the input string.

func JwtAuth

func JwtAuth() (jwt metadata.MD, err error)

JwtAuth used for ioctl set auth and send for every grpc request

func ParseHdwPath

func ParseHdwPath(addressOrAlias string) (uint32, uint32, uint32, error)

ParseHdwPath parse hdwallet path

func RauToString

func RauToString(amount *big.Int, numDecimals int) string

RauToString converts Rau big int into Iotx string

func ReadSecretFromStdin

func ReadSecretFromStdin() (string, error)

ReadSecretFromStdin used to safely get password input

func StringToIOTX

func StringToIOTX(amount string) (string, error)

StringToIOTX converts Rau string to Iotx string

func StringToRau

func StringToRau(amount string, numDecimals int) (*big.Int, error)

StringToRau converts different unit string into Rau big int

func To32Bytes

func To32Bytes(v interface{}) ([32]byte, error)

To32Bytes asserts/converts interface{} to [32]byte

func ToByteSlice

func ToByteSlice(v interface{}) ([]byte, error)

ToByteSlice asserts/converts interface{} to []byte

func TrimHexPrefix

func TrimHexPrefix(s string) string

TrimHexPrefix removes 0x prefix from a string if it has

Types

type Solidity

type Solidity struct {
	Path, Version, FullVersion string
	Major, Minor, Patch        int
	ExtraAllowedPath           []string
}

Solidity contains information about the solidity compiler.

func SolidityVersion

func SolidityVersion(solc string) (*Solidity, error)

SolidityVersion runs solc and parses its version output.

func (*Solidity) CompileFiles

func (s *Solidity) CompileFiles(sourcefiles ...string) (map[string]*compiler.Contract, error)

CompileFiles compiles all given Solidity source files.

func (*Solidity) CompileSource

func (s *Solidity) CompileSource(source string) (map[string]*compiler.Contract, error)

CompileSource builds and returns all the contracts contained within a source string.

Jump to

Keyboard shortcuts

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