Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Various LedgerEntry and Format updates
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanhide committed Mar 23, 2024
1 parent b4609e1 commit 17802a7
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 101 deletions.
11 changes: 11 additions & 0 deletions data/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@ func readObject(r Reader, v *reflect.Value) error {
err := readObject(r, &m)
v.Set(m.Elem())
return err
case "AuctionSlot":
var slot AuctionSlot
s := reflect.ValueOf(&slot)
err := readObject(r, &s)
v.Elem().FieldByName("AuctionSlot").Set(s)
if err == errorEndOfObject {
return nil
}
return err
case "VoteEntry":
return fmt.Errorf("VoteEntry not yet implemented...")
case "Memo":
var memo Memo
m := reflect.ValueOf(&memo)
Expand Down
2 changes: 2 additions & 0 deletions data/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ func getFields(v *reflect.Value, depth int) fieldSlice {
fields.Append(encoding, f.Addr().Interface(), nil)
case ST_HASH96, ST_HASH128, ST_HASH160, ST_HASH192, ST_HASH256, ST_HASH384, ST_HASH512, ST_AMOUNT, ST_VL, ST_ACCOUNT, ST_PATHSET, ST_VECTOR256:
fields.Append(encoding, f.Addr().Interface(), nil)
case ST_ISSUE:
fields.Append(encoding, f.Addr().Interface(), nil)
case ST_ARRAY:
var children fieldSlice
for i := 0; i < f.Len(); i++ {
Expand Down
7 changes: 6 additions & 1 deletion data/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ var encodings = map[enc]string{
{ST_UINT8, 1}: "CloseResolution",
{ST_UINT8, 2}: "Method",
{ST_UINT8, 3}: "TransactionResult",
{ST_UINT8, 4}: "Scale",
// 8-bit unsigned integers (uncommon)
{ST_UINT8, 16}: "TickSize",
{ST_UINT8, 17}: "UNLModifyDisabling",
{ST_UINT8, 18}: "HookResult",
{ST_UINT8, 19}: "WasLockingChainSend",
// 16-bit unsigned integers (common)
{ST_UINT16, 1}: "LedgerEntryType",
{ST_UINT16, 2}: "TransactionType",
Expand Down Expand Up @@ -221,7 +223,7 @@ var encodings = map[enc]string{
// {ST_HASH256, 20}: "TicketID",
{ST_HASH256, 21}: "Digest",
{ST_HASH256, 22}: "Channel",
{ST_HASH256, 22}: "ConsensusHash",
{ST_HASH256, 23}: "ConsensusHash",
{ST_HASH256, 24}: "CheckID",
{ST_HASH256, 25}: "ValidatedHash",
{ST_HASH256, 26}: "PreviousPageMin",
Expand All @@ -246,6 +248,7 @@ var encodings = map[enc]string{
{ST_AMOUNT, 11}: "Amount2",
{ST_AMOUNT, 12}: "BidMin",
{ST_AMOUNT, 13}: "BidMax",

// currency amount (uncommon)
{ST_AMOUNT, 16}: "MinimumOffer",
{ST_AMOUNT, 17}: "RippleEscrow",
Expand All @@ -258,6 +261,8 @@ var encodings = map[enc]string{
{ST_AMOUNT, 26}: "LPTokenIn",
{ST_AMOUNT, 27}: "EPrice",
{ST_AMOUNT, 28}: "Price",
{ST_AMOUNT, 29}: "SignatureReward",
{ST_AMOUNT, 30}: "MinAccountCreateAmount",
{ST_AMOUNT, 31}: "LPTokenBalance",

// variable length (common)
Expand Down
25 changes: 16 additions & 9 deletions data/ledgerentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type AccountRoot struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
AMMID *Hash256 `json:",omitempty"`
Sequence *uint32 `json:",omitempty"`
Balance *Value `json:",omitempty"`
OwnerCount *uint32 `json:",omitempty"`
Expand Down Expand Up @@ -224,29 +225,35 @@ type NFTokenOffer struct {
Expiration *uint32 `json:",omitempty"`
}

type VoteEntry struct {
type VoteEntryItem struct {
Account *Account `json:",omitempty"`
TradingFee *uint16 `json:",omitempty"`
VoteWeight *uint32 `json:",omitempty"`
}

type VoteEntry struct {
VoteEntry VoteEntryItem `json:",omitempty"`
}

type AuctionSlot struct {
Account *Account `json:",omitempty"`
AuthAccounts []Account `json:",omitempty"`
DiscountedFee *uint32 `json:",omitempty"`
DiscountedFee *uint16 `json:",omitempty"`
Price *Amount `json:",omitempty"`
Expiration *uint32 `json:",omitempty"`
}

type AMM struct {
leBase
Account *Account `json:",omitempty"`
TradingFee *uint16 `json:",omitempty"`
VoteSlots []VoteEntry `json:",omitempty"`
AuctionSlot *AuctionSlot `json:",omitempty"`
Asset *Hash160 `json:",omitempty"`
Asset2 *Hash160 `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
TradingFee *uint16 `json:",omitempty"`
VoteSlots []VoteEntry `json:",omitempty"`
AuctionSlot *AuctionSlot `json:",omitempty"`
LPTokenBalance *Amount `json:",omitempty"`
Asset *Asset `json:",omitempty"`
Asset2 *Asset `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
}

func (a *AccountRoot) Affects(account Account) bool {
Expand Down
Loading

0 comments on commit 17802a7

Please sign in to comment.