@@ -7,8 +7,10 @@ import (
77 "fmt"
88 "strings"
99
10+ bananaValidium "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygonvalidiumetrog"
1011 elderberryValidium "github.com/0xPolygon/cdk-contracts-tooling/contracts/elderberry/polygonvalidiumetrog"
1112 etrogValidium "github.com/0xPolygon/cdk-contracts-tooling/contracts/etrog/polygonvalidiumetrog"
13+ "github.com/0xPolygon/cdk-data-availability/log"
1214 "github.com/ethereum/go-ethereum/accounts/abi"
1315 "github.com/ethereum/go-ethereum/common"
1416 "github.com/ethereum/go-ethereum/crypto"
2426 methodIDSequenceBatchesValidiumElderberry = crypto .Keccak256 (
2527 []byte ("sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)" ),
2628 )[:methodIDLen ]
29+ // methodIDSequenceBatchesValidiumBanana is sequenceBatchesValidium method id in Banana fork (0x165e8a8d)
30+ methodIDSequenceBatchesValidiumBanana = crypto .Keccak256 (
31+ []byte ("sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint32,uint64,bytes32,address,bytes)" ),
32+ )[:methodIDLen ]
2733)
2834
2935const (
@@ -50,6 +56,11 @@ func UnpackTxData(txData []byte) ([]common.Hash, error) {
5056 if err != nil {
5157 return nil , err
5258 }
59+ } else if bytes .Equal (methodID , methodIDSequenceBatchesValidiumBanana ) {
60+ a , err = abi .JSON (strings .NewReader (bananaValidium .PolygonvalidiumetrogMetaData .ABI ))
61+ if err != nil {
62+ return nil , err
63+ }
5364 } else {
5465 return nil , fmt .Errorf ("unrecognized method id: %s" , hex .EncodeToString (methodID ))
5566 }
@@ -61,16 +72,19 @@ func UnpackTxData(txData []byte) ([]common.Hash, error) {
6172
6273 data , err := method .Inputs .Unpack (txData [methodIDLen :])
6374 if err != nil {
75+ log .Errorf ("error Unpack data: %v" , err )
6476 return nil , err
6577 }
6678
6779 bytes , err := json .Marshal (data [0 ])
6880 if err != nil {
81+ log .Errorf ("error marshalling data: %v" , err )
6982 return nil , err
7083 }
7184
7285 var batches []etrogValidium.PolygonValidiumEtrogValidiumBatchData
7386 if err = json .Unmarshal (bytes , & batches ); err != nil {
87+ log .Errorf ("error Unmarshal data: %v" , err )
7488 return nil , err
7589 }
7690
0 commit comments