Skip to content

Commit

Permalink
Merge from main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
devfans committed May 7, 2022
2 parents e3d0950 + aa3a4c7 commit db6df73
Show file tree
Hide file tree
Showing 31 changed files with 3,499 additions and 49 deletions.
69 changes: 62 additions & 7 deletions base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func GetChainName(id uint64) string {
return "Poly"
case ETH:
return "Ethereum"
case RINKEBY:
return "Ethereum-Rinkeby"
case ONT:
return "Ontology"
case NEO:
Expand All @@ -98,6 +100,38 @@ func GetChainName(id uint64) string {
return "Arbitrum"
case ZILLIQA:
return "Zilliqa"
case XDAI:
return "Xdai"
case OPTIMISM:
return "Optimism"
case FANTOM:
return "Fantom"
case METIS:
return "Metis"
case AVA:
return "Avalanche"
case BOBA:
return "Boba"
case PIXIE:
return "Pixie"
case OASIS:
return "Oasis"
case HSC:
return "Hsc"
case HARMONY:
return "Harmony"
case BYTOM:
return "Bytom"
case BCSPALETTE:
return "BCS Palette"
case KCC:
return "KCC"
case STARCOIN:
return "Starcoin"
case ONTEVM:
return "ONTEVM"
case MILKO:
return "Milkomeda"
default:
return fmt.Sprintf("Unknown(%d)", id)
}
Expand All @@ -106,15 +140,21 @@ func GetChainName(id uint64) string {
func BlocksToSkip(chainId uint64) uint64 {
switch chainId {
case MATIC:
return 64
return 120
case ETH:
return 3
case BSC, HECO, O3:
return 2
case PLT:
return 8
case BSC, HECO, HSC, BYTOM, KCC:
return 17
case O3:
return 8
case PLT, BCSPALETTE:
return 5
case ONT:
return 0
case PIXIE:
return 2
case STARCOIN:
return 70
default:
return 1
}
Expand All @@ -124,17 +164,32 @@ func BlocksToWait(chainId uint64) uint64 {
switch chainId {
case ETH:
return 12
case BSC, HECO:
case BSC, HECO, HSC, BYTOM, KCC:
return 21
case ONT, NEO, NEO3, OK, SWITCHEO:
return 1
case PLT:
case HARMONY:
return 2
case PLT, BCSPALETTE:
return 4
case O3:
return 12
case MATIC:
return 128
case PIXIE:
return 3
case STARCOIN:
return 72
default:
return 100000000
}
}

func SameAsETH(chainId uint64) bool {
for _, chain := range ETH_CHAINS {
if chain == chainId {
return true
}
}
return false
}
47 changes: 32 additions & 15 deletions base/devnet.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build devnet
// +build devnet

/*
Expand All @@ -19,22 +20,38 @@

package base

var (
POLY uint64 = 0
BTC uint64 = 1
ETH uint64 = 2
ONT uint64 = 3
NEO uint64 = 4
BSC uint64 = 6
HECO uint64 = 7
O3 uint64 = 80
NEO3 uint64 = 88
OK uint64 = 90
MATIC uint64 = 13
ONTEVM uint64 = 5555
const (
POLY uint64 = 0
BTC uint64 = 1
ETH uint64 = 2
ONT uint64 = 3
NEO uint64 = 4
BSC uint64 = 6
HECO uint64 = 7
O3 uint64 = 80
NEO3 uint64 = 88
OK uint64 = 90
MATIC uint64 = 13
METIS uint64 = 300
PIXIE uint64 = 316
RINKEBY uint64 = 402
HSC uint64 = 603
BYTOM uint64 = 701
KCC uint64 = 900
ONTEVM uint64 = 5555

SWITCHEO uint64 = 1000
SWITCHEO uint64 = 1000
HARMONY uint64 = 801
BCSPALETTE uint64 = 1001
STARCOIN uint64 = 318

ENV = "devnet"
)
var CHAINS = []uint64{POLY, ETH, ONT, NEO, BSC, HECO, O3, OK, MATIC, ONTEVM}

var CHAINS = []uint64{
POLY, ETH, ONT, NEO, BSC, HECO, O3, OK, MATIC, METIS, RINKEBY, PIXIE, HSC, HARMONY, BYTOM, STARCOIN, ONTEVM,
}

var ETH_CHAINS = []uint64{
ETH, BSC, HECO, OK, MATIC, O3, METIS, RINKEBY, PIXIE, HSC, HARMONY, BYTOM, KCC, ONTEVM,
}
32 changes: 28 additions & 4 deletions base/mainnet.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build mainnet
// +build mainnet

/*
Expand All @@ -19,7 +20,7 @@

package base

var (
const (
POLY uint64 = 0
BTC uint64 = 1
ETH uint64 = 2
Expand All @@ -31,16 +32,39 @@ var (
PLT uint64 = 8
O3 uint64 = 10
OK uint64 = 12
NEO3 uint64 = 14
HEIMDALL uint64 = 15
MATIC uint64 = 17
ZILLIQA uint64 = 18
ARBITRUM uint64 = 19
NEO3 uint64 = 88
ONTEVM uint64 = 5555
XDAI uint64 = 20
AVA uint64 = 21
FANTOM uint64 = 22
OPTIMISM uint64 = 23
METIS uint64 = 24
BOBA uint64 = 25
OASIS uint64 = 26
HARMONY uint64 = 27
HSC uint64 = 28
BYTOM uint64 = 29
KCC uint64 = 30

// Invalid chain IDs
ONTEVM uint64 = 5555
RINKEBY uint64 = 1000000
PIXIE uint64 = 2000000
BCSPALETTE uint64 = 1001001
STARCOIN uint64 = 1001002
MILKO uint64 = 1001335

ENV = "mainnet"
)

var CHAINS = []uint64{
POLY, ETH, BSC, HECO, OK, ONT, NEO, NEO3, HEIMDALL, MATIC, SWITCHEO, O3, PLT, ARBITRUM, ONTEVM,
POLY, ETH, BSC, HECO, OK, ONT, NEO, NEO3, HEIMDALL, MATIC, SWITCHEO, O3, PLT, ARBITRUM, XDAI, OPTIMISM, FANTOM, AVA,
METIS, BOBA, PIXIE, OASIS, HSC, HARMONY, BYTOM, BCSPALETTE, STARCOIN, ONTEVM, KCC, MILKO,
}

var ETH_CHAINS = []uint64{
ETH, BSC, HECO, OK, MATIC, O3, PLT, ARBITRUM, XDAI, OPTIMISM, FANTOM, AVA, METIS, BOBA, PIXIE, OASIS, HSC, HARMONY, HARMONY, BYTOM, BCSPALETTE, KCC, ONTEVM, MILKO,
}
29 changes: 26 additions & 3 deletions base/testnet.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build testnet
// +build testnet

/*
Expand All @@ -19,7 +20,7 @@

package base

var (
const (
POLY uint64 = 0
BTC uint64 = 1
ETH uint64 = 2
Expand All @@ -35,13 +36,35 @@ var (
HEIMDALL uint64 = 201
MATIC uint64 = 202
ARBITRUM uint64 = 205
XDAI uint64 = 206
OPTIMISM uint64 = 210
FANTOM uint64 = 208
AVA uint64 = 209
METIS uint64 = 300
PIXIE uint64 = 316
BOBA uint64 = 400
RINKEBY uint64 = 402
OASIS uint64 = 500
HSC uint64 = 603
BYTOM uint64 = 701
HARMONY uint64 = 800
KCC uint64 = 900
ONTEVM uint64 = 333
MILKO uint64 = 810

SWITCHEO uint64 = 1000
SWITCHEO uint64 = 1000
BCSPALETTE uint64 = 1001
STARCOIN uint64 = 318

ENV = "testnet"
)

var CHAINS = []uint64{
POLY, ETH, BSC, HECO, OK, ONT, NEO, NEO3, HEIMDALL, MATIC, SWITCHEO, O3, PLT, ARBITRUM, ONTEVM,
POLY, ETH, BSC, HECO, OK, ONT, NEO, NEO3, HEIMDALL, MATIC, SWITCHEO, O3, PLT, ARBITRUM, XDAI, OPTIMISM, FANTOM, AVA,
METIS, RINKEBY, BOBA, PIXIE, OASIS, HSC, HARMONY, BYTOM, BCSPALETTE, STARCOIN, ONTEVM, KCC, MILKO,
}

var ETH_CHAINS = []uint64{
ETH, BSC, HECO, OK, MATIC, O3, PLT, ARBITRUM, XDAI, OPTIMISM, FANTOM, AVA, METIS, RINKEBY, BOBA, PIXIE, OASIS, HSC,
HARMONY, HARMONY, BYTOM, BCSPALETTE, KCC, ONTEVM, MILKO,
}
7 changes: 6 additions & 1 deletion chains/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
)

type Client struct {
address string
address string
explorer string
}

func New(url string) *Client {
Expand All @@ -35,6 +36,10 @@ func New(url string) *Client {
}
}

func (c *Client) SetExplorer(url string) {
c.explorer = url
}

func (c *Client) Address() string {
return c.address
}
Expand Down
27 changes: 27 additions & 0 deletions chains/bridge/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,30 @@ func (r *CheckFeeRequest) Missing() bool {
func (c *Client) CheckFee(req map[string]*CheckFeeRequest) (err error) {
return tools.PostJsonFor(c.address+"/newcheckfee", req, &req)
}

type GetFeeRequest struct {
SrcChainId uint64
DstChainId uint64
SwapTokenHash string
Hash string
}

type GetFeeResponse struct {
SrcChainId uint64
DstChainId uint64
SwapTokenHash string
TokenAmount string
UsdtAmount string
TokenAmountWithPrecision string
Balance string
BalanceWithPrecision string
}

func (c *Client) GetFee(req *GetFeeRequest) (res *GetFeeResponse, err error) {
res = new(GetFeeResponse)
err = tools.PostJsonFor(c.address+"/getfee", req, res)
if err != nil {
return nil, err
}
return
}
Loading

0 comments on commit db6df73

Please sign in to comment.