helper

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestAccountPrivKey      = "aa75e9a7d427efc732f8e4f1a5b7646adcc61fd5bae40f80d13c8419c9f43d6d"
	TestModeFlag            = "test"
	SupernetManagerFlag     = "supernet-manager"
	SupernetManagerFlagDesc = "address of supernet manager contract"
	StakeManagerFlag        = "stake-manager"
	StakeManagerFlagDesc    = "address of stake manager contract"
	NativeRootTokenFlag     = "native-root-token"
	NativeRootTokenFlagDesc = "address of native root token"
	GenesisPathFlag         = "genesis"
	GenesisPathFlagDesc     = "genesis file path, which contains chain configuration"
	DefaultGenesisPath      = "./genesis.json"
	StakeTokenFlag          = "stake-token"
	StakeTokenFlagDesc      = "address of ERC20 token used for staking on rootchain"
	ProxyContractsAdminFlag = "proxy-contracts-admin"
	ProxyContractsAdminDesc = "admin for proxy contracts"
	AddressesFlag           = "addresses"
	AmountsFlag             = "amounts"
	Erc20TokenFlag          = "erc20-token" //nolint:gosec
)

Variables

View Source
var (
	ErrRootchainNotFound   = errors.New("rootchain not found")
	ErrRootchainPortBind   = errors.New("port 8545 is not bind with localhost")
	ErrMandatoryStakeToken = errors.New("stake token address is mandatory")

	ErrNoAddressesProvided = errors.New("no addresses provided")
	ErrInconsistentLength  = errors.New("addresses and amounts must be equal length")

	ErrMandatoryERC20Token = errors.New("erc20 token address is mandatory")
)

Functions

func CreateApproveERC20Txn added in v0.9.0

func CreateApproveERC20Txn(amount *big.Int,
	spender, erc20TokenAddr types.Address, rootchainTx bool) (*ethgo.Transaction, error)

CreateApproveERC20Txn sends approve transaction to ERC20 token for spender so that it is able to spend given tokens

func CreateMintTxn added in v0.9.0

func CreateMintTxn(receiver, erc20TokenAddr types.Address,
	amount *big.Int, rootchainTx bool) (*ethgo.Transaction, error)

CreateMintTxn encodes parameters for mint function on rootchain token contract

func CreateTransaction added in v1.1.1

func CreateTransaction(sender ethgo.Address, receiver *ethgo.Address,
	input []byte, value *big.Int, isDynamicFee bool) *ethgo.Transaction

CreateTransaction is a helper function that creates either dynamic fee or legacy transaction based on provided flag

func DecodePrivateKey added in v1.0.0

func DecodePrivateKey(rawKey string) (ethgo.Key, error)

DecodePrivateKey decodes a private key from provided raw private key

func DeployProxyContract added in v1.3.0

func DeployProxyContract(txRelayer txrelayer.TxRelayer, deployerKey ethgo.Key, proxyContractName string,
	proxyAdmin, logicAddress types.Address) (*ethgo.Receipt, error)

func GetECDSAKey added in v0.9.0

func GetECDSAKey(privateKey, accountDir, accountConfig string) (ethgo.Key, error)

GetECDSAKey returns the key based on provided parameters If private key is provided, it will return that key if not, it will return the key from the secrets manager

func GetRootchainID

func GetRootchainID() (string, error)

func GetValidatorInfo added in v0.9.0

func GetValidatorInfo(validatorAddr ethgo.Address, supernetManagerAddr, stakeManagerAddr types.Address,
	chainID int64, txRelayer txrelayer.TxRelayer) (*polybft.ValidatorInfo, error)

GetValidatorInfo queries SupernetManager smart contract on root and retrieves validator info for given address

func ReadRootchainIP

func ReadRootchainIP() (string, error)

func SendTransaction added in v1.0.0

func SendTransaction(txRelayer txrelayer.TxRelayer, addr ethgo.Address, input []byte, contractName string,
	deployerKey ethgo.Key) (*ethgo.Receipt, error)

SendTransaction sends provided transaction

Types

type MessageResult added in v1.0.0

type MessageResult struct {
	Message string `json:"message"`
}

func (MessageResult) GetOutput added in v1.0.0

func (r MessageResult) GetOutput() string

Jump to

Keyboard shortcuts

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