Skip to content

Commit

Permalink
feat: add xdai addresses (#2065)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralph-pichler committed Jun 11, 2021
1 parent 1742618 commit 07f56e1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
13 changes: 10 additions & 3 deletions pkg/postage/listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,24 @@ type priceUpdateEvent struct {
}

var (
GoerliChainID = int64(5)
GoerliPostageStampContractAddress = common.HexToAddress("0x621e455C4a139f5C4e4A8122Ce55Dc21630769E4")
GoerliStartBlock = uint64(4933174)
XDaiChainID = int64(100)
XDaiPostageStampContractAddress = common.HexToAddress("0x6a1a21eca3ab28be85c7ba22b2d6eae5907c900e")
XDaiStartBlock = uint64(16515648)
)

// DiscoverAddresses returns the canonical contracts for this chainID
func DiscoverAddresses(chainID int64) (postageStamp common.Address, startBlock uint64, found bool) {
if chainID == 5 {
// goerli
switch chainID {
case GoerliChainID:
return GoerliPostageStampContractAddress, GoerliStartBlock, true
case XDaiChainID:
return XDaiPostageStampContractAddress, XDaiStartBlock, true
default:
return common.Address{}, 0, false
}
return common.Address{}, 0, false
}

func totalTimeMetric(metric prometheus.Counter, start time.Time) {
Expand Down
21 changes: 17 additions & 4 deletions pkg/settlement/swap/chequebook/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,26 @@ func (c *factory) ERC20Address(ctx context.Context) (common.Address, error) {
return *erc20Address, nil
}

var (
GoerliChainID = int64(5)
GoerliFactoryAddress = common.HexToAddress("0x73c412512E1cA0be3b89b77aB3466dA6A1B9d273")
GoerliLegacyFactoryAddress = common.HexToAddress("0xf0277caffea72734853b834afc9892461ea18474")
XDaiChainID = int64(100)
XDaiFactoryAddress = common.HexToAddress("0xc2d5a532cf69aa9a1378737d8ccdef884b6e7420")
)

// DiscoverFactoryAddress returns the canonical factory for this chainID
func DiscoverFactoryAddress(chainID int64) (currentFactory common.Address, legacyFactories []common.Address, found bool) {
if chainID == 5 {
switch chainID {
case GoerliChainID:
// goerli
return common.HexToAddress("0x73c412512E1cA0be3b89b77aB3466dA6A1B9d273"), []common.Address{
common.HexToAddress("0xf0277caffea72734853b834afc9892461ea18474"),
return GoerliFactoryAddress, []common.Address{
GoerliLegacyFactoryAddress,
}, true
case XDaiChainID:
// xdai
return XDaiFactoryAddress, []common.Address{}, true
default:
return common.Address{}, nil, false
}
return common.Address{}, nil, false
}
16 changes: 12 additions & 4 deletions pkg/settlement/swap/priceoracle/priceoracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import (
)

var (
errDecodeABI = errors.New("could not decode abi data")
goerliContractAddress = common.HexToAddress("0x0c9de531dcb38b758fe8a2c163444a5e54ee0db2")
errDecodeABI = errors.New("could not decode abi data")
)

type service struct {
Expand Down Expand Up @@ -147,11 +146,20 @@ func (s *service) Close() error {
return nil
}

var (
goerliChainID = int64(5)
goerliContractAddress = common.HexToAddress("0x0c9de531dcb38b758fe8a2c163444a5e54ee0db2")
xdaiChainID = int64(100)
xdaiContractAddress = common.HexToAddress("0x0FDc5429C50e2a39066D8A94F3e2D2476fcc3b85")
)

// DiscoverPriceOracleAddress returns the canonical price oracle for this chainID
func DiscoverPriceOracleAddress(chainID int64) (priceOracleAddress common.Address, found bool) {
if chainID == 5 {
// goerli
switch chainID {
case goerliChainID:
return goerliContractAddress, true
case xdaiChainID:
return xdaiContractAddress, true
}
return common.Address{}, false
}

0 comments on commit 07f56e1

Please sign in to comment.