@@ -67,69 +67,3 @@ func (b OutgoingTxBatch) GetCheckpoint(peggyIDstring string) ([]byte, error) {
67
67
// then need to adjust how many bytes you truncate off the front to get the output of abi.encode()
68
68
return crypto .Keccak256Hash (abiEncodedBatch [4 :]).Bytes (), nil
69
69
}
70
-
71
- // GetCheckpoint gets the checkpoint signature from the given outgoing tx batch
72
- func (c OutgoingLogicCall ) GetCheckpoint (peggyIDstring string ) ([]byte , error ) {
73
-
74
- abi , err := abi .JSON (strings .NewReader (OutgoingLogicCallABIJSON ))
75
- if err != nil {
76
- return nil , sdkerrors .Wrap (err , "bad ABI definition in code" )
77
- }
78
-
79
- // Create the methodName argument which salts the signature
80
- methodNameBytes := []uint8 ("logicCall" )
81
- var logicCallMethodName [32 ]uint8
82
- copy (logicCallMethodName [:], methodNameBytes [:])
83
-
84
- // the contract argument is not a arbitrary length array but a fixed length 32 byte
85
- // array, therefore we have to utf8 encode the string (the default in this case) and
86
- // then copy the variable length encoded data into a fixed length array. This function
87
- // will panic if peggyId is too long to fit in 32 bytes
88
- peggyID , err := strToFixByteArray (peggyIDstring )
89
- if err != nil {
90
- panic (err )
91
- }
92
-
93
- // Run through the elements of the logic call and serialize them
94
- transferAmounts := make ([]* big.Int , len (c .Transfers ))
95
- transferTokenContracts := make ([]gethcommon.Address , len (c .Transfers ))
96
- feeAmounts := make ([]* big.Int , len (c .Fees ))
97
- feeTokenContracts := make ([]gethcommon.Address , len (c .Fees ))
98
- for i , tx := range c .Transfers {
99
- transferAmounts [i ] = tx .Amount .BigInt ()
100
- transferTokenContracts [i ] = gethcommon .HexToAddress (tx .Contract )
101
- }
102
- for i , tx := range c .Fees {
103
- feeAmounts [i ] = tx .Amount .BigInt ()
104
- feeTokenContracts [i ] = gethcommon .HexToAddress (tx .Contract )
105
- }
106
- payload := make ([]byte , len (c .Payload ))
107
- copy (payload , c .Payload )
108
- var invalidationId [32 ]byte
109
- copy (invalidationId [:], c .InvalidationId [:])
110
-
111
- // the methodName needs to be the same as the 'name' above in the checkpointAbiJson
112
- // but other than that it's a constant that has no impact on the output. This is because
113
- // it gets encoded as a function name which we must then discard.
114
- abiEncodedCall , err := abi .Pack ("checkpoint" ,
115
- peggyID ,
116
- logicCallMethodName ,
117
- transferAmounts ,
118
- transferTokenContracts ,
119
- feeAmounts ,
120
- feeTokenContracts ,
121
- gethcommon .HexToAddress (c .LogicContractAddress ),
122
- payload ,
123
- big .NewInt (int64 (c .Timeout )),
124
- invalidationId ,
125
- big .NewInt (int64 (c .InvalidationNonce )),
126
- )
127
-
128
- // this should never happen outside of test since any case that could crash on encoding
129
- // should be filtered above.
130
- if err != nil {
131
- return nil , sdkerrors .Wrap (err , "packing checkpoint" )
132
- }
133
-
134
- return crypto .Keccak256Hash (abiEncodedCall [4 :]).Bytes (), nil
135
- }
0 commit comments