Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(cryted string, key string) string
- func AesEncrypt(orig string, key string) string
- func Alert(module, message string)
- func AlertMatchflow()
- func AlertShuttleflow()
- func Alertf(module, format string, a ...interface{})
- func GetNetworkId() uint32
- func InPauseTimeRange() bool
- func Mul(x, y decimal.Decimal) decimal.Decimal
- func MustNewCfx(cfxURL string) *sdk.Client
- func NewLogger(module string, optionalFields ...map[string]interface{}) logrus.FieldLogger
- func Notify(message string)
- func Notifyf(format string, a ...interface{})
- func PKCS7Padding(ciphertext []byte, blocksize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- type AccountBalances
- func (ab *AccountBalances) Add(account string, amount *big.Int)
- func (ab *AccountBalances) Get(account string) *big.Int
- func (ab AccountBalances) GoString() string
- func (ab *AccountBalances) Map() map[string]*big.Int
- func (ab AccountBalances) String() string
- func (ab *AccountBalances) Sum() *big.Int
- type Asset
- type AssetResponse
- type Balance
- type BalanceResponse
- type Client
- type Contract
- func (c *Contract) Address() string
- func (c *Contract) BalanceOf(account string, epoch ...*types.Epoch) (*big.Int, error)
- func (c *Contract) ListAccounts(offset *big.Int, epoch ...*types.Epoch) ([]string, error)
- func (c *Contract) ListAllAccounts(epoch *types.Epoch) []string
- func (c *Contract) MintedTx(txHash string, epoch ...*types.Epoch) (bool, error)
- func (c *Contract) MintedTxList(index int64, epoch ...*types.Epoch) string
- func (c *Contract) MustGetBalanceOf(account string, epoch ...*types.Epoch) *big.Int
- func (c *Contract) MustGetMintedTx(txHash string, epoch ...*types.Epoch) bool
- func (c *Contract) MustGetTotalSupply(epoch ...*types.Epoch) *big.Int
- func (c *Contract) TotalAccount(epoch ...*types.Epoch) (*big.Int, error)
- func (c *Contract) TotalSupply(epoch ...*types.Epoch) (*big.Int, error)
- type MatchflowConfig
Constants ¶
const ( CfxURLMainNet = "http://mainnet-jsonrpc.conflux-chain.org:12537" MatchflowURLTest = "https://dev.matchflow.io" ShuttleflowURLTest = "https://dev.shuttleflow.io" ZeroAddress = "0x0000000000000000000000000000000000000000" EventHashTransfer = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" EventHashDeposit = "0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62" EventHashWithdraw = "0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb" EventHashWrite = "0x3802ba8117dc6bf5de2a857e440679e83bb0f9b68094ede7167234a5f97319ed" )
Public constants in Conflux or DEX.
const ( // FcABI FC ABI FcABI = "./common/build/FC.abi" // CrclABI CRC-L ABI CrclABI = "./common/build/CRCL.abi" // Erc777ABI ERC777 ABI Erc777ABI = "./common/build/ERC777.abi" // BoomflowABI Boomflow ABI BoomflowABI = "./common/build/Boomflow.abi" // CustodianABI Custodian Core ABI CustodianABI = "./common/build/CustodianCore.abi" // Create2ABI Create2Factory ABI Create2ABI = "./common/build/Create2Factory.abi" // Erc20ABI ERC20 ABI Erc20ABI = "./common/build/ERC20.abi" // EthFactoryABI EthFactory ABI EthFactoryABI = "./common/build/EthFactory.abi" )
Variables ¶
var ( Big0 = big.NewInt(0) Big1 = big.NewInt(1) )
Common values often used
var AesSecret = "123456789abcfake"
AesSecret the password of aes encrypt
var CustodianAddress = ""
CustodianAddress is the machine address where custodian node running on
var DexAdmin = "0x0000000000000000000000000000000000000000"
DexAdmin is the conflux address of admin of dex
var DexAdminPrivKey = ""
DexAdminPrivKey the private key of dex admin
var DingDingAccessToken string
DingDingAccessToken is the access token to send message to Dingding.
var MatchflowURL = ""
MatchflowURL is the url of matchflow rest api
var NumEpochsConfirmed *big.Int = big.NewInt(10)
NumEpochsConfirmed is the number of epochs before latest state that treated as confirmed.
Functions ¶
func Alert ¶
func Alert(module, message string)
Alert sends a message of specific module to Dingding.
func Alertf ¶
func Alertf(module, format string, a ...interface{})
Alertf sends a message of specific module to Dingding.
func GetNetworkId ¶
func GetNetworkId() uint32
func InPauseTimeRange ¶
func InPauseTimeRange() bool
InPauseTimeRange check whether current Shanghai time is between 7 a.m. and 11 p.m.
func MustNewCfx ¶
MustNewCfx must creates an instance of CFX client.
Types ¶
type AccountBalances ¶
type AccountBalances struct {
// contains filtered or unexported fields
}
AccountBalances represents a collection of accounts with their balances. Note, the account address is case-insensitive to avoid BIP-155 address.
func NewAccountBalances ¶
func NewAccountBalances() *AccountBalances
NewAccountBalances creates an instance of AccountBalances.
func (*AccountBalances) Add ¶
func (ab *AccountBalances) Add(account string, amount *big.Int)
Add adds a new account with amount as balance if not exists. Otherwise, add amount to the existing balance.
func (*AccountBalances) Get ¶
func (ab *AccountBalances) Get(account string) *big.Int
Get returns the balance of specified account if exists. Otherwise, return zero.
func (AccountBalances) GoString ¶
func (ab AccountBalances) GoString() string
GoString implements the fmt.GoStringer interface.
func (*AccountBalances) Map ¶
func (ab *AccountBalances) Map() map[string]*big.Int
Map returns the underlying account balances data structure. Generally, it is used for iteration purpose, and should never change the data outside of AccountBalances.
func (AccountBalances) String ¶
func (ab AccountBalances) String() string
GoString implements the fmt.Stringer interface.
func (*AccountBalances) Sum ¶
func (ab *AccountBalances) Sum() *big.Int
Sum calculates the sum of balances for all accounts.
type Asset ¶
type Asset struct { ID int `json:"id"` Name string `json:"name"` ContractAddress string `json:"contractAddress"` TokenAddress string `json:"tokenAddress"` DecimalDigits int `json:"decimalDigits"` CrossChain bool `json:"crossChain"` MinimumWithdrawAmount float64 `json:"minimumWithdrawAmount"` }
Asset conflux dex currency Auto-generated by https://mholt.github.io/json-to-go/
type AssetResponse ¶
type AssetResponse struct { Success bool `json:"success"` Message string `json:"message"` Data struct { Total int `json:"total"` Items []Asset `json:"items"` } `json:"data"` }
AssetResponse conflux DEX currencies
type Balance ¶
type Balance struct { ID int `json:"id"` UserID int `json:"userId"` Currency string `json:"currency"` Hold float64 `json:"hold"` Available float64 `json:"available"` Status string `json:"status"` Balance string `json:"balanceString"` }
Balance conflux DEX balance
type BalanceResponse ¶
type BalanceResponse struct { Success bool `json:"success"` Message string `json:"message"` Data struct { Total int `json:"total"` Items []Balance `json:"items"` } `json:"data"` }
BalanceResponse conflux DEX balances of a user
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client resty client wrapper
type Contract ¶
Contract represents an smart contract of Conflux DEX.
func GetContract ¶
GetContract creates an instance of contract.
func (*Contract) ListAccounts ¶
ListAccounts lists account since specified offset in CRCL.
func (*Contract) ListAllAccounts ¶
ListAllAccounts lists all accounts in CRCL.
func (*Contract) MintedTxList ¶
MintedTxList returns the list of all minted transactions.
func (*Contract) MustGetBalanceOf ¶
MustGetBalanceOf returns the balance of specified account.
func (*Contract) MustGetMintedTx ¶
MustGetMintedTx checks if the transaction has been executed.
func (*Contract) MustGetTotalSupply ¶
MustGetTotalSupply returns the specified total supply of this contract.
func (*Contract) TotalAccount ¶
TotalAccount returns total number of accounts in CRCL.