offer

package
v0.0.0-...-19a5819 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: ISC Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountOffers

func CountOffers(env *jtx.TestEnv, acc *jtx.Account) uint32

CountOffers counts all offer entries owned by an account. Iterates the owner directory and filters for Offer type (0x006f). Equivalent to rippled's offers(account, N) require funclet.

func CountOffersMatching

func CountOffersMatching(env *jtx.TestEnv, acc *jtx.Account, takerPays, takerGets tx.Amount) uint32

CountOffersMatching counts offers with specific TakerPays and TakerGets amounts. Equivalent to rippled's countOffers(env, account, takerPays, takerGets).

func GetOffer

func GetOffer(env *jtx.TestEnv, acc *jtx.Account, offerSeq uint32) *state.LedgerOffer

GetOffer reads and parses a specific offer from the ledger by account and sequence. Returns nil if the offer doesn't exist.

func IsOffer

func IsOffer(env *jtx.TestEnv, acc *jtx.Account, takerPays, takerGets tx.Amount) bool

IsOffer checks if an offer with specific amounts exists for an account. Equivalent to rippled's isOffer(env, account, takerPays, takerGets).

func LastClose

func LastClose(env *jtx.TestEnv) uint32

LastClose returns the parent close time in Ripple epoch seconds. Equivalent to rippled's lastClose(env) in Offer_test.cpp.

func OfferInLedger

func OfferInLedger(env *jtx.TestEnv, acc *jtx.Account, offerSeq uint32) bool

OfferInLedger checks if an offer exists in the ledger by account and sequence. Equivalent to rippled's offerInLedger / ledgerEntryOffer check.

func OffersOnAccount

func OffersOnAccount(env *jtx.TestEnv, acc *jtx.Account) []*state.LedgerOffer

OffersOnAccount returns all parsed offer entries owned by an account.

func RequireIsOffer

func RequireIsOffer(t *testing.T, env *jtx.TestEnv, acc *jtx.Account, takerPays, takerGets tx.Amount)

RequireIsOffer asserts that an offer with specific amounts exists.

func RequireNoOffer

func RequireNoOffer(t *testing.T, env *jtx.TestEnv, acc *jtx.Account, takerPays, takerGets tx.Amount)

RequireNoOffer asserts that an offer with specific amounts does not exist.

func RequireNoOfferInLedger

func RequireNoOfferInLedger(t *testing.T, env *jtx.TestEnv, acc *jtx.Account, offerSeq uint32)

RequireNoOfferInLedger asserts that an offer entry does NOT exist in the ledger by sequence.

func RequireOfferCount

func RequireOfferCount(t *testing.T, env *jtx.TestEnv, acc *jtx.Account, expected uint32)

RequireOfferCount asserts that an account has exactly the expected number of offers.

func RequireOfferInLedger

func RequireOfferInLedger(t *testing.T, env *jtx.TestEnv, acc *jtx.Account, offerSeq uint32)

RequireOfferInLedger asserts that an offer entry exists in the ledger by sequence.

func Reserve

func Reserve(env *jtx.TestEnv, count uint32) uint64

Reserve computes the account reserve for a given owner count. Equivalent to rippled's reserve(env, count) helper in Offer_test.cpp.

func RippleTimeFromUnix

func RippleTimeFromUnix(t time.Time) uint32

RippleTimeFromUnix converts a time.Time to Ripple epoch seconds.

func SortedOffersOnAccount

func SortedOffersOnAccount(env *jtx.TestEnv, acc *jtx.Account) []*state.LedgerOffer

SortedOffersOnAccount returns all offers for an account sorted by sequence number. Equivalent to rippled's sortedOffersOnAccount() in Offer_test.cpp.

Types

type OfferCancelBuilder

type OfferCancelBuilder struct {
	// contains filtered or unexported fields
}

OfferCancelBuilder provides a fluent interface for building OfferCancel transactions.

func OfferCancel

func OfferCancel(account *testing.Account, offerSeq uint32) *OfferCancelBuilder

OfferCancel creates a new OfferCancelBuilder. offerSeq is the sequence number of the OfferCreate transaction to cancel.

func (*OfferCancelBuilder) Build

func (b *OfferCancelBuilder) Build() tx.Transaction

Build constructs the OfferCancel transaction.

func (*OfferCancelBuilder) BuildOfferCancel

func (b *OfferCancelBuilder) BuildOfferCancel() *offertx.OfferCancel

BuildOfferCancel is a convenience method that returns the concrete *offertx.OfferCancel type.

func (*OfferCancelBuilder) Fee

Fee sets the transaction fee in drops.

func (*OfferCancelBuilder) Sequence

func (b *OfferCancelBuilder) Sequence(seq uint32) *OfferCancelBuilder

Sequence sets the sequence number explicitly.

func (*OfferCancelBuilder) TicketSeq

func (b *OfferCancelBuilder) TicketSeq(ticketSeq uint32) *OfferCancelBuilder

TicketSeq sets the ticket sequence and sets Sequence to 0.

type OfferCreateBuilder

type OfferCreateBuilder struct {
	// contains filtered or unexported fields
}

OfferCreateBuilder provides a fluent interface for building OfferCreate transactions.

func OfferCreate

func OfferCreate(account *testing.Account, takerPays, takerGets tx.Amount) *OfferCreateBuilder

OfferCreate creates a new OfferCreateBuilder. takerPays is what the offer creator receives, takerGets is what they pay.

func OfferCreateXRP

func OfferCreateXRP(account *testing.Account, xrpAmount uint64, issuedAmount tx.Amount, buyXRP bool) *OfferCreateBuilder

OfferCreateXRP creates an offer where one side is XRP. If buyXRP is true, creates an offer to buy XRP with issued currency. If buyXRP is false, creates an offer to sell XRP for issued currency.

func (*OfferCreateBuilder) Build

func (b *OfferCreateBuilder) Build() tx.Transaction

Build constructs the OfferCreate transaction.

func (*OfferCreateBuilder) BuildOfferCreate

func (b *OfferCreateBuilder) BuildOfferCreate() *offertx.OfferCreate

BuildOfferCreate is a convenience method that returns the concrete *offertx.OfferCreate type.

func (*OfferCreateBuilder) DomainID

func (b *OfferCreateBuilder) DomainID(id [32]byte) *OfferCreateBuilder

DomainID sets the permissioned domain ID for this offer.

func (*OfferCreateBuilder) Expiration

func (b *OfferCreateBuilder) Expiration(exp uint32) *OfferCreateBuilder

Expiration sets the expiration time (in Ripple epoch seconds).

func (*OfferCreateBuilder) Fee

Fee sets the transaction fee in drops.

func (*OfferCreateBuilder) FillOrKill

func (b *OfferCreateBuilder) FillOrKill() *OfferCreateBuilder

FillOrKill makes the offer fill-or-kill. The offer must be fully filled or it will be cancelled entirely.

func (*OfferCreateBuilder) Flags

Flags sets the raw flags value, replacing any previously set flags. Use this for testing malformed flag combinations.

func (*OfferCreateBuilder) Hybrid

Hybrid sets the tfHybrid flag (offer appears in both domain and open book). Requires DomainID to be set.

func (*OfferCreateBuilder) ImmediateOrCancel

func (b *OfferCreateBuilder) ImmediateOrCancel() *OfferCreateBuilder

ImmediateOrCancel makes the offer immediate-or-cancel. The offer will only take what's available immediately and cancel the rest.

func (*OfferCreateBuilder) OfferSequence

func (b *OfferCreateBuilder) OfferSequence(seq uint32) *OfferCreateBuilder

OfferSequence sets an existing offer to cancel when this one is created.

func (*OfferCreateBuilder) Passive

func (b *OfferCreateBuilder) Passive() *OfferCreateBuilder

Passive makes the offer passive (won't consume matching offers).

func (*OfferCreateBuilder) Sell

Sell makes this a sell offer. The taker gets at least as much as TakerGets, possibly more.

func (*OfferCreateBuilder) Sequence

func (b *OfferCreateBuilder) Sequence(seq uint32) *OfferCreateBuilder

Sequence sets the sequence number explicitly.

func (*OfferCreateBuilder) TicketSeq

func (b *OfferCreateBuilder) TicketSeq(ticketSeq uint32) *OfferCreateBuilder

TicketSeq sets the ticket sequence and sets Sequence to 0.

Jump to

Keyboard shortcuts

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