Skip to content

Commit

Permalink
Add OperationTypeManageSellOffer operation type to history_assets export
Browse files Browse the repository at this point in the history
  • Loading branch information
cayod committed Dec 19, 2023
1 parent ea70499 commit 2f94b7e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/input/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func GetPaymentOperations(start, end uint32, limit int64, isTest bool, isFuture

for txIndex, transaction := range transactionSet {
for opIndex, op := range transaction.Operations() {
if op.Body.Type == xdr.OperationTypePayment {
if op.Body.Type == xdr.OperationTypePayment || op.Body.Type == xdr.OperationTypeManageSellOffer {
assetSlice = append(assetSlice, AssetTransformInput{
Operation: op,
OperationIndex: int32(opIndex),
Expand Down
23 changes: 18 additions & 5 deletions internal/transform/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,29 @@ func TransformAsset(operation xdr.Operation, operationIndex int32, transactionIn
operationID := toid.New(ledgerSeq, int32(transactionIndex), operationIndex).ToInt64()

opType := operation.Body.Type
if opType != xdr.OperationTypePayment {
if opType != xdr.OperationTypePayment && opType != xdr.OperationTypeManageSellOffer {
return AssetOutput{}, fmt.Errorf("operation of type %d cannot issue an asset (id %d)", opType, operationID)
}

op, ok := operation.Body.GetPaymentOp()
if !ok {
return AssetOutput{}, fmt.Errorf("could not access Payment info for this operation (id %d)", operationID)
op := xdr.Asset{}
switch opType {
case xdr.OperationTypeManageSellOffer:
opSellOf, ok := operation.Body.GetManageSellOfferOp()
if ok {
return AssetOutput{}, fmt.Errorf("operation of type ManageSellOfferOp cannot issue an asset (id %d)", operationID)
}
op = opSellOf.Selling

case xdr.OperationTypePayment:
opPayment, ok := operation.Body.GetPaymentOp()
if !ok {
return AssetOutput{}, fmt.Errorf("could not access Payment info for this operation (id %d)", operationID)
}
op = opPayment.Asset

}

outputAsset, err := transformSingleAsset(op.Asset)
outputAsset, err := transformSingleAsset(op)
if err != nil {
return AssetOutput{}, fmt.Errorf("%s (id %d)", err.Error(), operationID)
}
Expand Down

0 comments on commit 2f94b7e

Please sign in to comment.