Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OperationTypeManageSellOffer operation type to history_assets export #214

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{}
cayod marked this conversation as resolved.
Show resolved Hide resolved
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
Loading