Skip to content

Commit

Permalink
final nits
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu committed Feb 4, 2022
1 parent 64878f0 commit 8342086
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions mapper/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ func crossChainTransaction(
avaxAssetID string,
tx *evm.Tx,
) ([]*types.Operation, error) {
var (
ops = []*types.Operation{}
idx = int64(0)
)
ops := []*types.Operation{}

// Prepare transaction for ID calcuation
if err := tx.Sign(evm.Codec, nil); err != nil {
return nil, err
return ops, err
}

switch t := tx.UnsignedAtomicTx.(type) {
Expand All @@ -155,14 +152,14 @@ func crossChainTransaction(
i++
}

for _, out := range t.Outs {
for idx, out := range t.Outs {
if out.AssetID.String() != avaxAssetID {
continue
}

op := &types.Operation{
OperationIdentifier: &types.OperationIdentifier{
Index: idx,
Index: int64(idx),
},
Type: OpImport,
Status: types.String(StatusSuccess),
Expand All @@ -184,17 +181,16 @@ func crossChainTransaction(
},
}
ops = append(ops, op)
idx++
}
case *evm.UnsignedExportTx:
for _, in := range t.Ins {
for idx, in := range t.Ins {
if in.AssetID.String() != avaxAssetID {
continue
}

op := &types.Operation{
OperationIdentifier: &types.OperationIdentifier{
Index: idx,
Index: int64(idx),
},
Type: OpExport,
Status: types.String(StatusSuccess),
Expand All @@ -215,7 +211,6 @@ func crossChainTransaction(
},
}
ops = append(ops, op)
idx++
}
default:
return nil, fmt.Errorf("unsupported transaction: %T", t)
Expand Down

0 comments on commit 8342086

Please sign in to comment.