Skip to content
Merged
Changes from all 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
36 changes: 14 additions & 22 deletions ocp/history/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func BuildRecordsForIntent(ctx context.Context, data ocp_data.DatabaseData, inte
case intent.SendPublicPayment:
return buildRecordsForSendPublicPaymentIntent(ctx, data, intentRecord, protoMetadata, actionRecords, withdrawalFeeQuarks)
case intent.ReceivePaymentsPublicly:
return buildRecordsForReceivePaymentsPubliclyIntent(ctx, data, intentRecord)
return buildRecordsForReceivePaymentsPubliclyIntent(intentRecord)
default:
// todo: Support remaining money movement intent types
return nil, nil
Expand Down Expand Up @@ -249,7 +249,7 @@ func buildRecordsForWithdrawalIntent(ctx context.Context, data ocp_data.Database
return []*history.Record{withdrawn, deposited}, nil
}

func buildRecordsForReceivePaymentsPubliclyIntent(ctx context.Context, data ocp_data.DatabaseData, intentRecord *intent.Record) ([]*history.Record, error) {
func buildRecordsForReceivePaymentsPubliclyIntent(intentRecord *intent.Record) ([]*history.Record, error) {
metadata := intentRecord.ReceivePaymentsPubliclyMetadata

// Voids and auto-returns are server-initiated intents that are reflected
Expand All @@ -258,26 +258,18 @@ func buildRecordsForReceivePaymentsPubliclyIntent(ctx context.Context, data ocp_
return nil, nil
}

// The issuer is the claim's counterparty, and is only discoverable through
// the intent that issued the gift card.
giftCardIssuedIntentRecord, err := data.GetOriginalGiftCardIssuedIntent(ctx, metadata.Source)
if err != nil {
return nil, err
}

return []*history.Record{{
ReferenceId: intentRecord.IntentId,
ReferenceType: history.IntentReference,
Type: history.IndirectlyReceived,
OwnerAccount: intentRecord.InitiatorOwnerAccount,
CounterpartyOwnerAccount: pointer.String(giftCardIssuedIntentRecord.InitiatorOwnerAccount),
ExchangeCurrency: metadata.OriginalExchangeCurrency,
NativeAmount: metadata.OriginalNativeAmount,
MintAccount: intentRecord.MintAccount,
Quantity: metadata.Quantity,
GiftCardVault: pointer.String(metadata.Source),
AppMetadata: intentRecord.AppMetadata,
State: history.StateCompleted,
CreatedAt: intentRecord.CreatedAt,
ReferenceId: intentRecord.IntentId,
ReferenceType: history.IntentReference,
Type: history.IndirectlyReceived,
OwnerAccount: intentRecord.InitiatorOwnerAccount,
ExchangeCurrency: metadata.OriginalExchangeCurrency,
NativeAmount: metadata.OriginalNativeAmount,
MintAccount: intentRecord.MintAccount,
Quantity: metadata.Quantity,
GiftCardVault: pointer.String(metadata.Source),
AppMetadata: intentRecord.AppMetadata,
State: history.StateCompleted,
CreatedAt: intentRecord.CreatedAt,
}}, nil
}
Loading