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

Commit

Permalink
Partial update for new LedgerEntries and Transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanhide committed Jan 9, 2024
1 parent 7f73b1f commit 5d1106b
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 109 deletions.
29 changes: 29 additions & 0 deletions data/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
NEGATIVE_UNL LedgerEntryType = 0x4e // 'N'
NFTOKEN_PAGE LedgerEntryType = 0x50 // 'P'
NFTOKEN_OFFER LedgerEntryType = 0x37 // '7'
AMM_LT LedgerEntryType = 0x79

// TransactionType values come from rippled's "TxFormats.h"
PAYMENT TransactionType = 0
Expand All @@ -45,11 +46,18 @@ const (
SET_DEPOSIT_PREAUTH TransactionType = 19
TRUST_SET TransactionType = 20
ACCOUNT_DELETE TransactionType = 21
HOOK_SET TransactionType = 22
NFTOKEN_MINT TransactionType = 25
NFTOKEN_BURN TransactionType = 26
NFTOKEN_CREATE_OFFER TransactionType = 27
NFTOKEN_CANCEL_OFFER TransactionType = 28
NFTOKEN_ACCEPT_OFFER TransactionType = 29
AMM_CREATE TransactionType = 35
AMM_DEPOSIT TransactionType = 36
AMM_WITHDRAW TransactionType = 37
AMM_VOTE TransactionType = 38
AMM_BID TransactionType = 39
AMM_DELETE TransactionType = 40

AMENDMENT TransactionType = 100
SET_FEE TransactionType = 101
Expand Down Expand Up @@ -77,6 +85,7 @@ var LedgerEntryFactory = [...]func() LedgerEntry{
NEGATIVE_UNL: func() LedgerEntry { return &NegativeUNL{leBase: leBase{LedgerEntryType: NEGATIVE_UNL}} },
NFTOKEN_PAGE: func() LedgerEntry { return &NFTokenPage{leBase: leBase{LedgerEntryType: NFTOKEN_PAGE}} },
NFTOKEN_OFFER: func() LedgerEntry { return &NFTokenOffer{leBase: leBase{LedgerEntryType: NFTOKEN_OFFER}} },
AMM_LT: func() LedgerEntry { return &AMM{leBase: leBase{LedgerEntryType: AMM_LT}} },
}

var TxFactory = [...]func() Transaction{
Expand Down Expand Up @@ -107,6 +116,12 @@ var TxFactory = [...]func() Transaction{
NFTOKEN_CREATE_OFFER: func() Transaction { return &NFTokenCreateOffer{TxBase: TxBase{TransactionType: NFTOKEN_CREATE_OFFER}} },
NFTOKEN_CANCEL_OFFER: func() Transaction { return &NFTCancelOffer{TxBase: TxBase{TransactionType: NFTOKEN_CANCEL_OFFER}} },
NFTOKEN_ACCEPT_OFFER: func() Transaction { return &NFTAcceptOffer{TxBase: TxBase{TransactionType: NFTOKEN_ACCEPT_OFFER}} },
AMM_CREATE: func() Transaction { return &AMMCreate{TxBase: TxBase{TransactionType: AMM_CREATE}} },
AMM_DEPOSIT: func() Transaction { return &AMMDeposit{TxBase: TxBase{TransactionType: AMM_DEPOSIT}} },
AMM_WITHDRAW: func() Transaction { return &AMMWithdraw{TxBase: TxBase{TransactionType: AMM_WITHDRAW}} },
AMM_VOTE: func() Transaction { return &AMMVote{TxBase: TxBase{TransactionType: AMM_VOTE}} },
AMM_BID: func() Transaction { return &AMMBid{TxBase: TxBase{TransactionType: AMM_BID}} },
AMM_DELETE: func() Transaction { return &AMMDelete{TxBase: TxBase{TransactionType: AMM_DELETE}} },
}

var ledgerEntryNames = [...]string{
Expand All @@ -126,6 +141,7 @@ var ledgerEntryNames = [...]string{
NEGATIVE_UNL: "NegativeUNL",
NFTOKEN_PAGE: "NFTokenPage",
NFTOKEN_OFFER: "NFTokenOffer",
AMM_LT: "AMM",
}

var ledgerEntryTypes = map[string]LedgerEntryType{
Expand All @@ -145,6 +161,7 @@ var ledgerEntryTypes = map[string]LedgerEntryType{
"NegativeUNL": NEGATIVE_UNL,
"NFTokenPage": NFTOKEN_PAGE,
"NFTokenOffer": NFTOKEN_OFFER,
"AMM": AMM_LT,
}

var txNames = [...]string{
Expand Down Expand Up @@ -175,6 +192,12 @@ var txNames = [...]string{
NFTOKEN_CREATE_OFFER: "NFTokenCreateOffer",
NFTOKEN_CANCEL_OFFER: "NFTokenCancelOffer",
NFTOKEN_ACCEPT_OFFER: "NFTokenAcceptOffer",
AMM_CREATE: "AMMCreate",
AMM_DEPOSIT: "AMMDeposit",
AMM_WITHDRAW: "AMMWithdraw",
AMM_VOTE: "AMMVote",
AMM_BID: "AMMBid",
AMM_DELETE: "AMMDelete",
}

var txTypes = map[string]TransactionType{
Expand Down Expand Up @@ -205,6 +228,12 @@ var txTypes = map[string]TransactionType{
"NFTokenCreateOffer": NFTOKEN_CREATE_OFFER,
"NFTokenCancelOffer": NFTOKEN_CANCEL_OFFER,
"NFTokenAcceptOffer": NFTOKEN_ACCEPT_OFFER,
"AMMCreate": AMM_CREATE,
"AMMDeposit": AMM_DEPOSIT,
"AMMWithdraw": AMM_WITHDRAW,
"AMMVote": AMM_VOTE,
"AMMBid": AMM_BID,
"AMMDelete": AMM_DELETE,
}

var HashableTypes []string
Expand Down
74 changes: 47 additions & 27 deletions data/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,6 @@ const (
TxClose TransactionFlag = 0x00020000
)

// Ledger entry flags
const (
// AccountRoot flags
LsPasswordSpent LedgerEntryFlag = 0x00010000
LsRequireDestTag LedgerEntryFlag = 0x00020000
LsRequireAuth LedgerEntryFlag = 0x00040000
LsDisallowXRP LedgerEntryFlag = 0x00080000
LsDisableMaster LedgerEntryFlag = 0x00100000
LsNoFreeze LedgerEntryFlag = 0x00200000
LsGlobalFreeze LedgerEntryFlag = 0x00400000
LsDefaultRipple LedgerEntryFlag = 0x00800000

// Offer flags
LsPassive LedgerEntryFlag = 0x00010000
LsSell LedgerEntryFlag = 0x00020000

// RippleState flags
LsLowReserve LedgerEntryFlag = 0x00010000
LsHighReserve LedgerEntryFlag = 0x00020000
LsLowAuth LedgerEntryFlag = 0x00040000
LsHighAuth LedgerEntryFlag = 0x00080000
LsLowNoRipple LedgerEntryFlag = 0x00100000
LsHighNoRipple LedgerEntryFlag = 0x00200000
LsLowFreeze LedgerEntryFlag = 0x00400000
LsHighFreeze LedgerEntryFlag = 0x00800000
)

var txFlagNames = map[TransactionType][]struct {
Flag TransactionFlag
Name string
Expand Down Expand Up @@ -121,6 +94,43 @@ var txFlagNames = map[TransactionType][]struct {
},
}

// Ledger entry flags
const (
// AccountRoot flags
LsPasswordSpent LedgerEntryFlag = 0x00010000
LsRequireDestTag LedgerEntryFlag = 0x00020000
LsRequireAuth LedgerEntryFlag = 0x00040000
LsDisallowXRP LedgerEntryFlag = 0x00080000
LsDisableMaster LedgerEntryFlag = 0x00100000
LsNoFreeze LedgerEntryFlag = 0x00200000
LsGlobalFreeze LedgerEntryFlag = 0x00400000
LsDefaultRipple LedgerEntryFlag = 0x00800000

// Offer flags
LsPassive LedgerEntryFlag = 0x00010000
LsSell LedgerEntryFlag = 0x00020000

// RippleState flags
LsLowReserve LedgerEntryFlag = 0x00010000
LsHighReserve LedgerEntryFlag = 0x00020000
LsLowAuth LedgerEntryFlag = 0x00040000
LsHighAuth LedgerEntryFlag = 0x00080000
LsLowNoRipple LedgerEntryFlag = 0x00100000
LsHighNoRipple LedgerEntryFlag = 0x00200000
LsLowFreeze LedgerEntryFlag = 0x00400000
LsHighFreeze LedgerEntryFlag = 0x00800000

// SignerList flags
LsOneOwnerCount LedgerEntryFlag = 0x00010000

// DirNode flags
LsNFTokenBuyOffers LedgerEntryFlag = 0x00000001
LsNFTokenSellOffers LedgerEntryFlag = 0x00000002

// TokenOffer flags
LsSellNFToken LedgerEntryFlag = 0x00000001
)

var leFlagNames = map[LedgerEntryType][]struct {
Flag LedgerEntryFlag
Name string
Expand All @@ -147,6 +157,16 @@ var leFlagNames = map[LedgerEntryType][]struct {
{LsLowFreeze, "LowFreeze"},
{LsHighFreeze, "HighFreeze"},
},
SIGNER_LIST: {
{LsOneOwnerCount, "OneOwnerCount"},
},
DIRECTORY: {
{LsNFTokenBuyOffers, "NFTokenBuyOffers"},
{LsNFTokenSellOffers, "NFTokenSellOffers"},
},
NFTOKEN_OFFER: {
{LsSellNFToken, "SellNFToken"},
},
}

func (f TransactionFlag) String() string {
Expand Down
Loading

0 comments on commit 5d1106b

Please sign in to comment.