history

package
v1.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyStateTransitionsForIntent

func ApplyStateTransitionsForIntent(ctx context.Context, data ocp_data.DatabaseData, intentRecord *intent.Record) error

ApplyStateTransitionsForIntent applies the state transitions an intent triggers on other flows' history records.

func BuildRecordForExternalDeposit

func BuildRecordForExternalDeposit(intentRecord *intent.Record, signature string) *history.Record

BuildRecordForExternalDeposit builds the transaction history record for an external deposit intent. External deposit intents are created by workers rather than SubmitIntent, so they don't flow through BuildRecordsForIntent, and the transaction signature is provided by the observing worker because the intent doesn't store it.

The record is referenced by the deposit's transaction signature, which maps it directly to the deposit record and the transaction on chain.

func BuildRecordForFundedSwap

func BuildRecordForFundedSwap(swapRecord *swap.Record, exchangeCurrency currency_lib.Code, nativeAmount, fiatExchangeRate float64, launchTerms *CurrencyLaunchTerms) (*history.Record, error)

BuildRecordForFundedSwap builds the transaction history record for a swap whose funding has come through and been validated. The value and the client's verified fiat exchange rate are provided by the swap worker, since their derivation depends on the funding source.

The record is referenced by the swap's ID, mapping it directly to the swap record. The value is the gross amount funding the swap, with fees broken out, so the net value is the gross value less fees. The record is pending until the swap reaches a terminal state.

launchTerms marks a swap as a currency's initial purchase and carries what that launch is charged. It is nil for every other swap. The swap worker resolves it, since neither the fact of the launch nor its terms are on the swap record.

func BuildRecordsForIntent

func BuildRecordsForIntent(ctx context.Context, data ocp_data.DatabaseData, intentRecord *intent.Record, protoMetadata *transactionpb.Metadata, actionRecords []*action.Record, withdrawalFeeQuarks uint64) ([]*history.Record, error)

BuildRecordsForIntent builds the transaction history records for an intent. An intent that isn't a history-visible money movement (eg. account opens, or payments whose history is owned by another flow) yields no records.

Records are created in a completed state, since the sequencer guarantees a submitted intent is eventually fulfilled. The exception is a gift card issuance, which is pending until the gift card is claimed, voided, or auto-returned.

withdrawalFeeQuarks is the fee the server charges to create a withdrawal's destination account, in core mint quarks as a USD value, which is what the charge on the intent was validated against.

func MarkGiftCardIssuanceAsClaimed

func MarkGiftCardIssuanceAsClaimed(ctx context.Context, data ocp_data.DatabaseData, giftCardVault string) error

MarkGiftCardIssuanceAsClaimed completes the issuer's IndirectlySent record after the gift card is claimed.

func MarkGiftCardIssuanceAsReturned

func MarkGiftCardIssuanceAsReturned(ctx context.Context, data ocp_data.DatabaseData, giftCardVault string) error

MarkGiftCardIssuanceAsReturned transitions the issuer's IndirectlySent record after the gift card expires unclaimed and is auto-returned.

func MarkGiftCardIssuanceAsVoided

func MarkGiftCardIssuanceAsVoided(ctx context.Context, data ocp_data.DatabaseData, giftCardVault string) error

MarkGiftCardIssuanceAsVoided transitions the issuer's IndirectlySent record after the issuer voids the gift card.

func MarkSwapAsCompleted

func MarkSwapAsCompleted(ctx context.Context, data ocp_data.DatabaseData, swapId string, destinationQuantity uint64) error

MarkSwapAsCompleted completes a swap's record with the realized destination quantity after the swap transaction is finalized.

func MarkSwapAsFailed

func MarkSwapAsFailed(ctx context.Context, data ocp_data.DatabaseData, swapId string) error

MarkSwapAsFailed fails a swap's record after the swap could not be executed and the funds are refunded.

Types

type CurrencyLaunchTerms

type CurrencyLaunchTerms struct {
	PurchaseQuarks uint64
	FeeQuarks      uint64
}

CurrencyLaunchTerms are the amounts a currency launch is charged, in core mint quarks as USD values, matching what the launch was validated against.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL