model

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PARAM_ERROR    string = "Params error"
	AMOUNT_ERROR   string = "Amount error"
	PONG           string = "Pong"
	INTERNAL_ERROR string = "Internal error"
)
View Source
const (
	DB_TABLE_ORDER    = "orders"
	DB_TABLE_CONTRACT = "contract_config"
	DB_TABLE_BLOCK    = "block"
)

Variables

This section is empty.

Functions

func GetBlockTableName

func GetBlockTableName() string

func GetContractTableName

func GetContractTableName() string

func GetOrderTableName

func GetOrderTableName() string

func GetPorterTransferedAndCompletion

func GetPorterTransferedAndCompletion(addr string, e *xorm.Engine) (transfered int64, completion float32, err error)

func InitMySQLXorm

func InitMySQLXorm(addr string, showSQL bool) *xorm.Engine

func InsertBlock

func InsertBlock(block *Block, db *xorm.Engine) error

func InsertOrder

func InsertOrder(order *Order, db *xorm.Engine) error

func Keccak256EncodePackedContractOrder

func Keccak256EncodePackedContractOrder(co *contracts.CrossControllerOrder) (orderHash [32]byte)

func UpdateBlock

func UpdateBlock(id int, blockNumber int64, db *xorm.Engine) error

func UpdateOrderProof

func UpdateOrderProof(id int64, proof string, db *xorm.Engine) error

func UpdateOrderReceiptStatus

func UpdateOrderReceiptStatus(receiptTxHash string, order *Order, db *xorm.Engine) error

func UpdateOrderStatus

func UpdateOrderStatus(order *Order, db *xorm.Engine) error

Types

type Block

type Block struct {
	ID          int       `xorm:"'id' pk autoincr"`
	ChainId     int       `xorm:"chain_id" json:"chain_id"`
	Contract    string    `xorm:"contract" json:"contract"`
	BlockNumber int64     `xorm:"block_number" json:"block_number"`
	Created     time.Time `xorm:"created" json:"created"`
	Updated     time.Time `xorm:"updated" json:"updated"`
}

func GetBlock

func GetBlock(chainId int64, contract string, db *xorm.Engine) (bool, *Block)

func (*Block) TableName

func (o *Block) TableName() string

type Chain

type Chain struct {
	ChainName    string   `json:"chain_name"`
	ChainID      uint64   `json:"chain_id"`
	SupportCoins []string `json:"support_coins"`
}

type CostReq

type CostReq struct {
	Coin   string  `json:"coin"`
	Amount float64 `json:"amount"`
}

type CostResp

type CostResp struct {
	Coin      string  `json:"coin"`
	Amount    float64 `json:"amount"`
	RealSend  float64 `json:"real_send"`
	Received  float64 `json:"received"`
	Fixed     float64 `json:"fixed_fee"`
	FloatRate float64 `json:"float_fee_rate"`
	FloatFee  float64 `json:"float_fee"`
}

type CrossChainPair

type CrossChainPair struct {
	SrcChain   *Chain   `json:"src_chain"`
	DestChains []*Chain `json:"dest_chains"`
}

type Fee

type Fee struct {
	Fixed     float64 `json:"fixed"`
	FloatRate float64 `json:"float_rate"`
}

type Message

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

func GetMessage

func GetMessage(m string) *Message

type NextIDResp

type NextIDResp struct {
	NextOrderID int64 `json:"next_order_id"`
}

type Order

type Order struct {
	ID         int64   `xorm:"'id' pk" json:"id"`
	PoterId    string  `xorm:"poter_id" json:"poter_id"`
	SrcChainId uint64  `xorm:"src_chain_id" json:"src_chain_id"`
	SrcAddress string  `xorm:"src_address" json:"src_address"`
	SrcToken   string  `xorm:"src_token" json:"src_token"`
	SrcAmount  float64 `xorm:"src_amount" json:"src_amount"`
	SrcTxHash  string  `xorm:"src_tx_hash" json:"src_tx_hash"`

	FixedFee float64 `xorm:"fixed_fee" json:"fixed_fee"`
	FloatFee float64 `xorm:"float_fee" json:"float_fee"`

	DestChainId  uint64  `xorm:"dest_chain_id" json:"dest_chain_id"`
	DestAddress  string  `xorm:"dest_address" json:"dest_address"`
	DestToken    string  `xorm:"dest_token" json:"dest_token"`
	DestAmount   float64 `xorm:"dest_amount" json:"dest_amount"`
	DestTxHash   string  `xorm:"dest_tx_hash" json:"dest_tx_hash"`
	DestTxStatus int     `xorm:"dest_tx_status" json:"dest_tx_status"`

	CommitmentIdx         uint64 `xorm:"commitment_idx" json:"commitment_idx"`
	AddCommitmentTxHash   string `xorm:"addcommitment_tx" json:"addcommitment_tx"`
	AddCommitmentTxStatus int    `xorm:"addcommitment_tx_status" json:"addcommitment_tx_status"`

	Proof           string `xorm:"proof" json:"proof"`
	RawProof        string `xorm:"raw_proof" json:"raw_proof"`
	ReceiptTxHash   string `xorm:"receipt_tx_hash" json:"receipt_tx_hash"`
	ReceiptTxStatus int    `xorm:"receipt_tx_status" json:"receipt_tx_status"`

	Created      time.Time `xorm:"created" json:"created"`
	FinishedTime time.Time `xorm:"finished_time" json:"finish_time"`
	Updated      time.Time `xorm:"updated" json:"updated"`

	Status int `xorm:"status" json:"status"`

	RZKP *RawZkProof `xorm:"-"`
	ZKP  *ZkProof    `xorm:"-"`
}

func GetOrder

func GetOrder(orderId int64, db *xorm.Engine) (bool, *Order)

func GetOrderList

func GetOrderList(src_chain_id uint64, dest_chain_id uint64, db *xorm.Engine) ([]Order, error)

func (*Order) TableName

func (o *Order) TableName() string

type Porter

type Porter struct {
	Address    string  `json:"address"`
	Transfered int64   `json:"transfered"`
	Completion float32 `json:"completion"`
}

type Proof

type Proof struct {
	A [2]*big.Int
	B [2][2]*big.Int
	C [2]*big.Int
}

type ProofReq

type ProofReq struct {
	Addr   string `json:"addr"`
	Url    string `json:"url"`
	TxHash string `json:"txhash"`
	CmtIdx int    `json:"cmtIdx"`
}

type RawProof

type RawProof struct {
	A []string   `json:"a"`
	B [][]string `json:"b"`
	C []string   `json:"c"`
}

type RawZkProof

type RawZkProof struct {
	Proof      *RawProof `json:"proof"`
	PublicInfo []string  `json:"publicInfo"`
}

func (*RawZkProof) RawProofToZkProof

func (rp *RawZkProof) RawProofToZkProof() (zProof *ZkProof)

type Router

type Router struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type RouterReq

type RouterReq struct {
	SrcChain  string  `json:"src_chain"`
	DestChain string  `json:"dest_chain"`
	From      string  `json:"from"`
	To        string  `json:"to"`
	Amount    float64 `json:"amount"`
	Token     string  `json:"token"`
}

type RouterResponse

type RouterResponse struct {
	Porters []*Porter `json:"porters"`
	Routers []*Router `json:"routers"`
}

type SupportCrossChains

type SupportCrossChains struct {
	Pairs []*CrossChainPair `json:"chain_pairs"`
}

type ZkProof

type ZkProof struct {
	Proof      *Proof
	PublicInfo [2]*big.Int
}

func (*ZkProof) Keccak256EncodePackedZkProof

func (zp *ZkProof) Keccak256EncodePackedZkProof() (proofHash [32]byte)

Jump to

Keyboard shortcuts

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