Skip to content

Commit 5ccaef0

Browse files
Fix case where payment is from src to destination and additionally, they are issuer of the asset (#5639)
1 parent 20ee8d6 commit 5ccaef0

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

ingest/processors/token_transfer/token_transfer_processor.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,30 +242,29 @@ func (p *EventsProcessor) mintOrBurnOrTransferEvent(tx ingest.LedgerTransaction,
242242
protoAsset := assetProto.NewProtoAsset(asset)
243243
meta := p.generateEventMeta(tx, opIndex, asset)
244244

245-
// Check for Mint Event
246-
if isMintEvent {
245+
// This means that the payment is a wierd one, where the src == dest AND in addition, the src/dest address is the issuer of the asset
246+
// Check this section out in CAP-67 https://github.com/stellar/stellar-protocol/blob/master/core/cap-0067.md#payment
247+
// We need to issue a TRANSFER event for this.
248+
// Keep in mind though that this wont show up in opeartionMeta as a balance change
249+
// This has happened in ledgerSequence: 4522126 on pubnet
250+
if isMintEvent && isBurnEvent {
251+
return NewTransferEvent(meta, fromAddress, toAddress, amt, protoAsset), nil
252+
} else if isMintEvent {
253+
254+
// Check for Mint Event
247255
if toAddress == "" {
248256
return nil, NewEventError("mint event error: to address is nil")
249257
}
250258
return NewMintEvent(meta, toAddress, amt, protoAsset), nil
251-
}
259+
} else if isBurnEvent {
252260

253-
// Check for Burn Event
254-
if isBurnEvent {
261+
// Check for Burn Event
255262
if fromAddress == "" {
256263
return nil, NewEventError("burn event error: from address is nil")
257264
}
258265
return NewBurnEvent(meta, fromAddress, amt, protoAsset), nil
259266
}
260267

261-
// If you are here, then it's a transfer event
262-
if toAddress == "" {
263-
return nil, NewEventError("transfer event error: to address is nil")
264-
}
265-
if fromAddress == "" {
266-
return nil, NewEventError("transfer event error: from address is nil")
267-
}
268-
269268
// Create transfer event
270269
return NewTransferEvent(meta, fromAddress, toAddress, amt, protoAsset), nil
271270
}

0 commit comments

Comments
 (0)