File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,31 @@ func createBatch(ctx context.Context, k keeper.Keeper) error {
160
160
if err != nil {
161
161
return err
162
162
}
163
+
164
+ lkup := make (map [string ]bool )
163
165
for _ , erc20ToDenom := range denoms {
166
+ pendingAttestation , ok := lkup [erc20ToDenom .ChainReferenceId ]
167
+ if ! ok {
168
+ att , err := k .GetAttestations (ctx , & types.QueryAttestationsRequest {
169
+ ChainReferenceId : erc20ToDenom .ChainReferenceId ,
170
+ OrderBy : "desc" ,
171
+ Height : 1 ,
172
+ })
173
+ if err != nil {
174
+ return fmt .Errorf ("failed to get attestations: %w" , err )
175
+ }
176
+
177
+ pendingAttestation = len (att .Attestations ) > 0 && att .Attestations [0 ].Observed
178
+ lkup [erc20ToDenom .ChainReferenceId ] = pendingAttestation
179
+ }
180
+
181
+ if pendingAttestation {
182
+ // If the latest attestation is not observed,
183
+ // we don't want to create new batches to avoid sending an
184
+ // already sent but not yet acknowleged transaction again.
185
+ return nil
186
+ }
187
+
164
188
tokenContract , err := k .GetERC20OfDenom (ctx , erc20ToDenom .GetChainReferenceId (), erc20ToDenom .Denom )
165
189
if err != nil {
166
190
return err
You can’t perform that action at this time.
0 commit comments