@@ -31,6 +31,7 @@ import (
3131const (
3232 AcrossMessage = "AcrossMessage"
3333
34+ ZERO_HASH = "0000000000000000000000000000000000000000000000000000000000000000"
3435 DOMAIN_NAME = "LiquidityPool"
3536 VERSION = "1.0.0"
3637 PROTOCOL_ID = 1
@@ -72,13 +73,18 @@ type TokenPricer interface {
7273 TokenPrice (symbol string ) (float64 , error )
7374}
7475
76+ type TokenMatcher interface {
77+ DestinationToken (destinationChainId * big.Int , symbol string ) (common.Address , error )
78+ }
79+
7580type AcrossMessageHandler struct {
7681 client EventFilterer
7782 chainID uint64
7883
7984 tokens map [string ]evm.TokenConfig
8085 confirmations map [uint64 ]uint64
8186 blocktime time.Duration
87+ tokenMatcher TokenMatcher
8288 tokenPricer TokenPricer
8389 pools map [uint64 ]common.Address
8490
@@ -87,7 +93,7 @@ type AcrossMessageHandler struct {
8793 comm comm.Communication
8894 fetcher signing.SaveDataFetcher
8995
90- sigChn chan interface {}
96+ sigChn chan any
9197}
9298
9399func NewAcrossMessageHandler (
@@ -99,7 +105,8 @@ func NewAcrossMessageHandler(
99105 comm comm.Communication ,
100106 fetcher signing.SaveDataFetcher ,
101107 tokenPricer TokenPricer ,
102- sigChn chan interface {},
108+ tokenMatcher TokenMatcher ,
109+ sigChn chan any ,
103110 tokens map [string ]evm.TokenConfig ,
104111 confirmations map [uint64 ]uint64 ,
105112 blocktime time.Duration ,
@@ -117,6 +124,7 @@ func NewAcrossMessageHandler(
117124 confirmations : confirmations ,
118125 blocktime : blocktime ,
119126 tokenPricer : tokenPricer ,
127+ tokenMatcher : tokenMatcher ,
120128 }
121129}
122130
@@ -237,6 +245,15 @@ func (h *AcrossMessageHandler) minimalConfirmations(d *events.AcrossDeposit) (ui
237245 return 0 , err
238246 }
239247
248+ if common .Bytes2Hex (d .OutputToken [:]) == ZERO_HASH {
249+ address , err := h .tokenMatcher .DestinationToken (d .DestinationChainId , symbol )
250+ if err != nil {
251+ return 0 , err
252+ }
253+
254+ d .OutputToken = common .BytesToHash (address .Bytes ())
255+ }
256+
240257 price , err := h .tokenPricer .TokenPrice (symbol )
241258 if err != nil {
242259 return 0 , err
0 commit comments