utils

package
v0.0.0-...-8ff8691 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	N = 4
	T = 1
)

Variables

View Source
var (
	GOPATH   = os.Getenv("GOPATH")
	KEYSTORE = os.Getenv("POA_KEYSTORE")

	EthAddr    = common.HexToAddress("0x0000000000000000000000000000000000000000")
	HbswapAddr = map[string]common.Address{
		"testnet":    common.HexToAddress("0xbc003e9dffe7306e6e414197267581fd732fe8b4"),
		"privatenet": common.HexToAddress("0xf74eb25ab1785d24306ca6b3cbff0d0b0817c5e2"),
	}
	HbSwapTokenAddr = map[string]common.Address{
		"testnet": common.HexToAddress("0x78160ee9e55fd81626f98d059c84d21d8b71bfda"),
	}
	DAIAddr = map[string]common.Address{
		"testnet": common.HexToAddress("0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa"),
	}
	//TODO: delete it after testing
	UserAddr = common.HexToAddress("0xc33a4b5b609fcc294dca060347761226e78c0b7a")

	HttpPort = 8545
	WsPort   = 8546

	TestnetHttpEndpoint = "https://kovan.infura.io/v3/6a82d2519efb4d748c02552e02e369c1"
	TestnetWsEndpoint   = "wss://kovan.infura.io/ws/v3/6a82d2519efb4d748c02552e02e369c1"

	AddLiquidity    = "0xec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c6411"
	InitPool        = "0xfaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf5"
	RemoveLiquidity = "0xa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef9"
	SecretDeposit   = "0x07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf"
	SecretWithdraw  = "0x4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3"
	Trade           = "0x2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6"
)

Functions

func Approve

func Approve(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, receiver common.Address, amt *big.Int)
func Consent(network string, conn *ethclient.Client, auth *bind.TransactOpts, seq *big.Int)

func ExecCmd

func ExecCmd(cmd *exec.Cmd) string

func FundETH

func FundETH(network string, conn *ethclient.Client, toAddr common.Address, amount *big.Int)

func FundToken

func FundToken(conn *ethclient.Client, tokenAddr common.Address, toAddr common.Address, amount *big.Int)

func GetAccount

func GetAccount(account string) *bind.TransactOpts

func GetBalance

func GetBalance(network string, conn *ethclient.Client, token common.Address, user common.Address) *big.Int

func GetBalanceETH

func GetBalanceETH(conn *ethclient.Client, addr common.Address) *big.Int

func GetBalanceToken

func GetBalanceToken(conn *ethclient.Client, addr common.Address, tokenAddr common.Address) *big.Int

func GetEthClient

func GetEthClient(ethInstance string) *ethclient.Client

func GetEthURL

func GetEthURL(hostname string) string

func GetEthWsURL

func GetEthWsURL(hostname string) string

func GetIPAddr

func GetIPAddr(hostname string) net.IP

func GetInputmaskCnt

func GetInputmaskCnt(network string, conn *ethclient.Client) int64

func GetPrice

func GetPrice(network string, conn *ethclient.Client, tokenA common.Address, tokenB common.Address) string

func GetURL

func GetURL(hostname string, port int, scheme string) string

func ParseAddLiquidity

func ParseAddLiquidity(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapAddLiquidity

func ParseInitPool

func ParseInitPool(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapInitPool

func ParseRemoveLiquidity

func ParseRemoveLiquidity(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapRemoveLiquidity

func ParseSecretDeposit

func ParseSecretDeposit(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapSecretDeposit

******* parse event *******

func ParseSecretWithdraw

func ParseSecretWithdraw(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapSecretWithdraw

func ParseTrade

func ParseTrade(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapTrade

func ResetBalance

func ResetBalance(network string, conn *ethclient.Client, auth *bind.TransactOpts, token common.Address, user common.Address)

func ResetPrice

func ResetPrice(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address)

func StrToBig

func StrToBig(st string) *big.Int

func UpdatePrice

func UpdatePrice(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address, checkpointSeq *big.Int, price string)

func WaitMined

func WaitMined(ctx context.Context, ec *ethclient.Client,
	tx *types.Transaction, blockDelay uint64) (*types.Receipt, error)

Types

type EventID

type EventID struct {
	BlockNumber uint64
	TxIndex     uint
	LogIndex    uint
}

func (*EventID) Less

func (a *EventID) Less(b *EventID) bool

type PriorityQueue

type PriorityQueue []*Task

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type Task

type Task struct {
	EventID EventID

	EventName  string
	Parameters []string
}

Jump to

Keyboard shortcuts

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