diff --git a/CHANGELOG.md b/CHANGELOG.md index b86ada88..8f049341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +#### xrpl + +- Added `flag` package with `Contains` utility function to check if a flag is fully set within a combined flag value. + ### Fixed #### xrpl diff --git a/docs/docs/xrpl/flag.md b/docs/docs/xrpl/flag.md new file mode 100644 index 00000000..2fd8df0a --- /dev/null +++ b/docs/docs/xrpl/flag.md @@ -0,0 +1,67 @@ +# flag + +## Overview + +The `flag` package provides utility functions for working with bitwise flags in XRPL. + +- `Contains`: Checks whether a flag is fully set within a combined flag value. Useful for inspecting transaction or ledger object flags. + +## Usage + +To import the package, you can use the following code: + +```go +import "github.com/Peersyst/xrpl-go/xrpl/flag" +``` + +## API + +### Contains + +```go +func Contains(currentFlag uint32, flag uint32) bool +``` + +Returns `true` if all bits of `flag` are set in `currentFlag` (`(currentFlag & flag) == flag`). Returns `false` if any bit of `flag` is missing in `currentFlag`, or if `flag` is `0`. + +:::warning + +The comparison is based on the flag value as a `uint32`. Different contexts may use the same numeric values (e.g. a transaction flag and a ledger-state flag), so a match only indicates the bit is set — not that it belongs to a specific context. Always pair `Contains` with the flag constant that matches the context you are checking. + +::: + +### Example + +```go +package main + +import ( + "fmt" + + "github.com/Peersyst/xrpl-go/xrpl/flag" + "github.com/Peersyst/xrpl-go/xrpl/transaction" +) + +func main() { + offer := transaction.OfferCreate{ + BaseTx: transaction.BaseTx{ + Account: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", + }, + TakerGets: nil, + TakerPays: nil, + } + + // Set the sell flag on the offer + offer.SetSellFlag() + + // Check whether the sell flag is set + if flag.Contains(offer.Flags, transaction.TfSell) { + fmt.Println("Offer is a sell offer") + } + + // Check whether the fill-or-kill flag is set (it is not) + if !flag.Contains(offer.Flags, transaction.TfFillOrKill) { + fmt.Println("Offer is not fill-or-kill") + } +} +``` diff --git a/examples/mptoken/rpc/main.go b/examples/mptoken/rpc/main.go index ffb87ae2..e5aa0f26 100644 --- a/examples/mptoken/rpc/main.go +++ b/examples/mptoken/rpc/main.go @@ -72,7 +72,7 @@ func main() { MaximumAmount: &amount, MPTokenMetadata: types.MPTokenMetadata("464F4F"), // "FOO" in hex } - // Since TransferFee is provided, enable the tfMPTCanTransfer flag. + // Since TransferFee is provided, enable the TfMPTCanTransfer flag. issuanceTx.SetMPTCanTransferFlag() // Flatten, autofill, sign, and submit the transaction. diff --git a/examples/mptoken/ws/main.go b/examples/mptoken/ws/main.go index b4c4b281..041d16c9 100644 --- a/examples/mptoken/ws/main.go +++ b/examples/mptoken/ws/main.go @@ -87,7 +87,7 @@ func main() { MaximumAmount: &amount, MPTokenMetadata: types.MPTokenMetadata("464F4F"), // "FOO" in hex } - // Since TransferFee is provided, enable the tfMPTCanTransfer flag. + // Since TransferFee is provided, enable the TfMPTCanTransfer flag. issuanceTx.SetMPTCanTransferFlag() // Flatten, autofill, sign, and submit the transaction. diff --git a/xrpl/flag/flag.go b/xrpl/flag/flag.go new file mode 100644 index 00000000..3b6c72cd --- /dev/null +++ b/xrpl/flag/flag.go @@ -0,0 +1,10 @@ +// Package flag provides utility functions for working with bitwise flags. +package flag + +// Contains checks if all bits of flag are present in currentFlag. +// Returns false if flag is 0. +// Note: It should be taken into account that the comparison is based on the flag value as a uint32. +// Different contexts may use same values, and they will return ok as the value matches. +func Contains(currentFlag, flag uint32) bool { + return flag != 0 && (currentFlag&flag) == flag +} diff --git a/xrpl/flag/flag_test.go b/xrpl/flag/flag_test.go new file mode 100644 index 00000000..98ae7550 --- /dev/null +++ b/xrpl/flag/flag_test.go @@ -0,0 +1,65 @@ +package flag + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +const ( + dummyFlagA = 262144 + dummyFlagB = 131072 + dummyFlagC = 65536 +) + +func TestFlag_Contains(t *testing.T) { + testCases := []struct { + name string + currentFlag uint32 + flag uint32 + expected bool + }{ + { + name: "pass - same flag", + currentFlag: dummyFlagA, + flag: dummyFlagA, + expected: true, + }, + { + name: "pass - containing flag", + currentFlag: dummyFlagA | dummyFlagB, + flag: dummyFlagA, + expected: true, + }, + { + name: "pass - not containing flag", + currentFlag: dummyFlagA | dummyFlagB, + flag: dummyFlagC, + expected: false, + }, + { + name: "pass - zero flag", + currentFlag: dummyFlagA, + flag: 0, + expected: false, + }, + { + name: "pass - zero current flag", + currentFlag: 0, + flag: 0, + expected: false, + }, + { + name: "pass - partial overlap multi-bit flag", + currentFlag: dummyFlagA, + flag: dummyFlagA | dummyFlagB, + expected: false, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + actual := Contains(tc.currentFlag, tc.flag) + assert.Equal(t, tc.expected, actual) + }) + } +} diff --git a/xrpl/ledger-entry-types/account_root.go b/xrpl/ledger-entry-types/account_root.go index ede6aa53..60037fdb 100644 --- a/xrpl/ledger-entry-types/account_root.go +++ b/xrpl/ledger-entry-types/account_root.go @@ -6,36 +6,36 @@ import ( ) const ( - // Enable Clawback for this account. (Requires the Clawback amendment.) - lsfAllowTrustLineClawback uint32 = 0x80000000 - // Allow IOUs to be used as escrow amounts for an issuer - lsfAllowTrustLineLocking uint32 = 0x40000000 - // Enable rippling on this addresses's trust lines by default. Required for issuing addresses; discouraged for others. - lsfDefaultRipple uint32 = 0x00800000 - // This account has DepositAuth enabled, meaning it can only receive funds from transactions it sends, and from preauthorized accounts. (Added by the DepositAuth amendment) - lsfDepositAuth uint32 = 0x01000000 - // Disallows use of the master key to sign transactions for this account. - lsfDisableMaster uint32 = 0x00100000 - // This account blocks incoming Checks. (Added by the DisallowIncoming amendment.) - lsfDisallowIncomingCheck uint32 = 0x08000000 - // This account blocks incoming NFTokenOffers. (Added by the DisallowIncoming amendment.) - lsfDisallowIncomingNFTokenOffer uint32 = 0x04000000 - // This account blocks incoming Payment Channels. (Added by the DisallowIncoming amendment.) - lsfDisallowIncomingPayChan uint32 = 0x10000000 - // This account blocks incoming trust lines. (Added by the DisallowIncoming amendment.) - lsfDisallowIncomingTrustline uint32 = 0x20000000 - // Client applications should not send XRP to this account. (Advisory; not enforced by the protocol.) - lsfDisallowXRP uint32 = 0x00080000 - // All assets issued by this account are frozen. - lsfGlobalFreeze uint32 = 0x00400000 - // This account cannot freeze trust lines connected to it. Once enabled, cannot be disabled. - lsfNoFreeze uint32 = 0x00200000 - // This account has used its free SetRegularKey transaction. - lsfPasswordSpent uint32 = 0x00010000 - // This account must individually approve other users for those users to hold this account's tokens. - lsfRequireAuth uint32 = 0x00040000 - // Requires incoming payments to specify a Destination Tag. - lsfRequireDestTag uint32 = 0x00020000 + // LsfAllowTrustLineClawback enables Clawback for this account. (Requires the Clawback amendment.) + LsfAllowTrustLineClawback uint32 = 0x80000000 + // LsfAllowTrustLineLocking allows IOUs to be used as escrow amounts for an issuer + LsfAllowTrustLineLocking uint32 = 0x40000000 + // LsfDefaultRipple enables rippling on this addresses's trust lines by default. Required for issuing addresses; discouraged for others. + LsfDefaultRipple uint32 = 0x00800000 + // LsfDepositAuth this account has DepositAuth enabled, meaning it can only receive funds from transactions it sends, and from preauthorized accounts. (Added by the DepositAuth amendment) + LsfDepositAuth uint32 = 0x01000000 + // LsfDisableMaster disallows use of the master key to sign transactions for this account. + LsfDisableMaster uint32 = 0x00100000 + // LsfDisallowIncomingCheck this account blocks incoming Checks. (Added by the DisallowIncoming amendment.) + LsfDisallowIncomingCheck uint32 = 0x08000000 + // LsfDisallowIncomingNFTokenOffer this account blocks incoming NFTokenOffers. (Added by the DisallowIncoming amendment.) + LsfDisallowIncomingNFTokenOffer uint32 = 0x04000000 + // LsfDisallowIncomingPayChan this account blocks incoming Payment Channels. (Added by the DisallowIncoming amendment.) + LsfDisallowIncomingPayChan uint32 = 0x10000000 + // LsfDisallowIncomingTrustline this account blocks incoming trust lines. (Added by the DisallowIncoming amendment.) + LsfDisallowIncomingTrustline uint32 = 0x20000000 + // LsfDisallowXRP client applications should not send XRP to this account. (Advisory; not enforced by the protocol.) + LsfDisallowXRP uint32 = 0x00080000 + // LsfGlobalFreeze all assets issued by this account are frozen. + LsfGlobalFreeze uint32 = 0x00400000 + // LsfNoFreeze this account cannot freeze trust lines connected to it. Once enabled, cannot be disabled. + LsfNoFreeze uint32 = 0x00200000 + // LsfPasswordSpent this account has used its free SetRegularKey transaction. + LsfPasswordSpent uint32 = 0x00010000 + // LsfRequireAuth this account must individually approve other users for those users to hold this account's tokens. + LsfRequireAuth uint32 = 0x00040000 + // LsfRequireDestTag requires incoming payments to specify a Destination Tag. + LsfRequireDestTag uint32 = 0x00020000 ) // AccountRoot ledger entry type describes a single account, its settings, and XRP balance. @@ -73,7 +73,7 @@ type AccountRoot struct { Account types.Address // The identifying hash of the transaction most recently sent by this account. // This field must be enabled to use the AccountTxnID transaction field. - // To enable it, send an AccountSet transaction with the asfAccountTxnID flag enabled. + // To enable it, send an AccountSet transaction with the AsfAccountTxnID flag enabled. AccountTxnID types.Hash256 `json:",omitempty"` // (Added by the AMM amendment) The ledger entry ID of the corresponding AMM ledger entry. // Set during account creation; cannot be modified. If present, indicates that this is a @@ -135,75 +135,75 @@ func (*AccountRoot) EntryType() EntryType { // SetLsfAllowTrustLineClawback sets the AllowTrustLineClawback flag. func (a *AccountRoot) SetLsfAllowTrustLineClawback() { - a.Flags |= lsfAllowTrustLineClawback + a.Flags |= LsfAllowTrustLineClawback } // SetLsfAllowTrustLineLocking sets the AllowTrustLineLocking flag. func (a *AccountRoot) SetLsfAllowTrustLineLocking() { - a.Flags |= lsfAllowTrustLineLocking + a.Flags |= LsfAllowTrustLineLocking } // SetLsfDefaultRipple sets the DefaultRipple flag. func (a *AccountRoot) SetLsfDefaultRipple() { - a.Flags |= lsfDefaultRipple + a.Flags |= LsfDefaultRipple } // SetLsfDepositAuth sets the DepositAuth flag. func (a *AccountRoot) SetLsfDepositAuth() { - a.Flags |= lsfDepositAuth + a.Flags |= LsfDepositAuth } // SetLsfDisableMaster sets the DisableMaster flag. func (a *AccountRoot) SetLsfDisableMaster() { - a.Flags |= lsfDisableMaster + a.Flags |= LsfDisableMaster } // SetLsfDisallowIncomingCheck sets the DisallowIncomingCheck flag. func (a *AccountRoot) SetLsfDisallowIncomingCheck() { - a.Flags |= lsfDisallowIncomingCheck + a.Flags |= LsfDisallowIncomingCheck } // SetLsfDisallowIncomingNFTokenOffer sets the DisallowIncomingNFTokenOffer flag. func (a *AccountRoot) SetLsfDisallowIncomingNFTokenOffer() { - a.Flags |= lsfDisallowIncomingNFTokenOffer + a.Flags |= LsfDisallowIncomingNFTokenOffer } // SetLsfDisallowIncomingPayChan sets the DisallowIncomingPayChan flag. func (a *AccountRoot) SetLsfDisallowIncomingPayChan() { - a.Flags |= lsfDisallowIncomingPayChan + a.Flags |= LsfDisallowIncomingPayChan } // SetLsfDisallowIncomingTrustline sets the DisallowIncomingTrustline flag. func (a *AccountRoot) SetLsfDisallowIncomingTrustline() { - a.Flags |= lsfDisallowIncomingTrustline + a.Flags |= LsfDisallowIncomingTrustline } // SetLsfDisallowXRP sets the DisallowXRP flag. func (a *AccountRoot) SetLsfDisallowXRP() { - a.Flags |= lsfDisallowXRP + a.Flags |= LsfDisallowXRP } // SetLsfGlobalFreeze sets the GlobalFreeze flag. func (a *AccountRoot) SetLsfGlobalFreeze() { - a.Flags |= lsfGlobalFreeze + a.Flags |= LsfGlobalFreeze } // SetLsfNoFreeze sets the NoFreeze flag. func (a *AccountRoot) SetLsfNoFreeze() { - a.Flags |= lsfNoFreeze + a.Flags |= LsfNoFreeze } // SetLsfPasswordSpent sets the PasswordSpent flag. func (a *AccountRoot) SetLsfPasswordSpent() { - a.Flags |= lsfPasswordSpent + a.Flags |= LsfPasswordSpent } // SetLsfRequireAuth sets the RequireAuth flag. func (a *AccountRoot) SetLsfRequireAuth() { - a.Flags |= lsfRequireAuth + a.Flags |= LsfRequireAuth } // SetLsfRequireDestTag sets the RequireDestTag flag. func (a *AccountRoot) SetLsfRequireDestTag() { - a.Flags |= lsfRequireDestTag + a.Flags |= LsfRequireDestTag } diff --git a/xrpl/ledger-entry-types/account_root_test.go b/xrpl/ledger-entry-types/account_root_test.go index 2ed5ad6f..62b5e94f 100644 --- a/xrpl/ledger-entry-types/account_root_test.go +++ b/xrpl/ledger-entry-types/account_root_test.go @@ -53,88 +53,88 @@ func TestAccountRoot_EntryType(t *testing.T) { func TestAccountRoot_SetLsfAllowTrustLineClawback(t *testing.T) { ar := &AccountRoot{} ar.SetLsfAllowTrustLineClawback() - require.Equal(t, ar.Flags, lsfAllowTrustLineClawback) + require.Equal(t, ar.Flags, LsfAllowTrustLineClawback) } func TestAccountRoot_SetLsfDefaultRipple(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDefaultRipple() - require.Equal(t, ar.Flags, lsfDefaultRipple) + require.Equal(t, ar.Flags, LsfDefaultRipple) } func TestAccountRoot_SetLsfDepositAuth(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDepositAuth() - require.Equal(t, ar.Flags, lsfDepositAuth) + require.Equal(t, ar.Flags, LsfDepositAuth) } func TestAccountRoot_SetLsfDisableMaster(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDisableMaster() - require.Equal(t, ar.Flags, lsfDisableMaster) + require.Equal(t, ar.Flags, LsfDisableMaster) } func TestAccountRoot_SetLsfDisallowIncomingCheck(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDisallowIncomingCheck() - require.Equal(t, ar.Flags, lsfDisallowIncomingCheck) + require.Equal(t, ar.Flags, LsfDisallowIncomingCheck) } func TestAccountRoot_SetLsfDisallowIncomingNFTokenOffer(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDisallowIncomingNFTokenOffer() - require.Equal(t, ar.Flags, lsfDisallowIncomingNFTokenOffer) + require.Equal(t, ar.Flags, LsfDisallowIncomingNFTokenOffer) } func TestAccountRoot_SetLsfDisallowIncomingPayChan(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDisallowIncomingPayChan() - require.Equal(t, ar.Flags, lsfDisallowIncomingPayChan) + require.Equal(t, ar.Flags, LsfDisallowIncomingPayChan) } func TestAccountRoot_SetLsfDisallowIncomingTrustline(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDisallowIncomingTrustline() - require.Equal(t, ar.Flags, lsfDisallowIncomingTrustline) + require.Equal(t, ar.Flags, LsfDisallowIncomingTrustline) } func TestAccountRoot_SetLsfDisallowXRP(t *testing.T) { ar := &AccountRoot{} ar.SetLsfDisallowXRP() - require.Equal(t, ar.Flags, lsfDisallowXRP) + require.Equal(t, ar.Flags, LsfDisallowXRP) } func TestAccountRoot_SetLsfGlobalFreeze(t *testing.T) { ar := &AccountRoot{} ar.SetLsfGlobalFreeze() - require.Equal(t, ar.Flags, lsfGlobalFreeze) + require.Equal(t, ar.Flags, LsfGlobalFreeze) } func TestAccountRoot_SetLsfNoFreeze(t *testing.T) { ar := &AccountRoot{} ar.SetLsfNoFreeze() - require.Equal(t, ar.Flags, lsfNoFreeze) + require.Equal(t, ar.Flags, LsfNoFreeze) } func TestAccountRoot_SetLsfPasswordSpent(t *testing.T) { ar := &AccountRoot{} ar.SetLsfPasswordSpent() - require.Equal(t, ar.Flags, lsfPasswordSpent) + require.Equal(t, ar.Flags, LsfPasswordSpent) } func TestAccountRoot_SetLsfRequireAuth(t *testing.T) { ar := &AccountRoot{} ar.SetLsfRequireAuth() - require.Equal(t, ar.Flags, lsfRequireAuth) + require.Equal(t, ar.Flags, LsfRequireAuth) } func TestAccountRoot_SetLsfRequireDestTag(t *testing.T) { ar := &AccountRoot{} ar.SetLsfRequireDestTag() - require.Equal(t, ar.Flags, lsfRequireDestTag) + require.Equal(t, ar.Flags, LsfRequireDestTag) } func TestAccountRoot_SetLsfAllowTrustLineLocking(t *testing.T) { ar := &AccountRoot{} ar.SetLsfAllowTrustLineLocking() - require.Equal(t, ar.Flags, lsfAllowTrustLineLocking) + require.Equal(t, ar.Flags, LsfAllowTrustLineLocking) } diff --git a/xrpl/ledger-entry-types/credential.go b/xrpl/ledger-entry-types/credential.go index 58ed6aa4..23382c9c 100644 --- a/xrpl/ledger-entry-types/credential.go +++ b/xrpl/ledger-entry-types/credential.go @@ -3,9 +3,9 @@ package ledger import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" const ( - // If enabled, the subject of the credential has accepted the credential. + // LsfAccepted if enabled, the subject of the credential has accepted the credential. // Otherwise, the issuer created the credential but the subject has not yet accepted it, meaning it is not yet valid. - lsfAccepted uint32 = 0x00010000 + LsfAccepted uint32 = 0x00010000 ) // Credential entry represents a credential, which contains an attestation about a subject account from a credential issuer account. @@ -47,5 +47,5 @@ func (*Credential) EntryType() EntryType { // SetLsfAccepted sets the one owner count flag. func (c *Credential) SetLsfAccepted() { - c.Flags |= lsfAccepted + c.Flags |= LsfAccepted } diff --git a/xrpl/ledger-entry-types/credential_test.go b/xrpl/ledger-entry-types/credential_test.go index 392234eb..4b082523 100644 --- a/xrpl/ledger-entry-types/credential_test.go +++ b/xrpl/ledger-entry-types/credential_test.go @@ -16,7 +16,7 @@ func TestCredential_EntryType(t *testing.T) { func TestCredential_SetLsfAccepted(t *testing.T) { credential := &Credential{} credential.SetLsfAccepted() - require.Equal(t, credential.Flags, lsfAccepted) + require.Equal(t, credential.Flags, LsfAccepted) } func TestCredential_Flatten(t *testing.T) { @@ -30,7 +30,7 @@ func TestCredential_Flatten(t *testing.T) { credential: &Credential{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: CredentialEntry, - Flags: lsfAccepted, + Flags: LsfAccepted, CredentialType: types.CredentialType("6D795F63726564656E7469616C"), Subject: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), Issuer: types.Address("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1"), diff --git a/xrpl/ledger-entry-types/directory_node.go b/xrpl/ledger-entry-types/directory_node.go index eda46e3e..21fd3ead 100644 --- a/xrpl/ledger-entry-types/directory_node.go +++ b/xrpl/ledger-entry-types/directory_node.go @@ -5,10 +5,10 @@ import ( ) const ( - // Flag: This directory contains NFT buy offers. - lsfNFTokenBuyOffers uint32 = 0x00000001 - // Flag: This directory contains NFT sell offers. - lsfNFTokenSellOffers uint32 = 0x00000002 + // LsfNFTokenBuyOffers this directory contains NFT buy offers. + LsfNFTokenBuyOffers uint32 = 0x00000001 + // LsfNFTokenSellOffers this directory contains NFT sell offers. + LsfNFTokenSellOffers uint32 = 0x00000002 ) // DirectoryNode ledger entry type provides a list of links to other entries in the ledger's state data. @@ -17,8 +17,8 @@ const ( // The first DirectoryNode entry is called the root of the directory, and all entries other than the root can be added or deleted as necessary. // // DirectoryNode entries can have the following values in the Flags field: -// - lsfNFTokenBuyOffers: This directory contains NFT buy offers. -// - lsfNFTokenSellOffers: This directory contains NFT sell offers. +// - LsfNFTokenBuyOffers: This directory contains NFT buy offers. +// - LsfNFTokenSellOffers: This directory contains NFT sell offers. // // Owner directories and offer directories for fungible tokens do not use flags; their Flags value is always 0. // @@ -89,10 +89,10 @@ func (*DirectoryNode) EntryType() EntryType { // SetNFTokenBuyOffers sets the directory to contain NFT buy offers. func (d *DirectoryNode) SetNFTokenBuyOffers() { - d.Flags |= lsfNFTokenBuyOffers + d.Flags |= LsfNFTokenBuyOffers } // SetNFTokenSellOffers sets the directory to contain NFT sell offers. func (d *DirectoryNode) SetNFTokenSellOffers() { - d.Flags |= lsfNFTokenSellOffers + d.Flags |= LsfNFTokenSellOffers } diff --git a/xrpl/ledger-entry-types/directory_node_test.go b/xrpl/ledger-entry-types/directory_node_test.go index d775d42e..c539fa4b 100644 --- a/xrpl/ledger-entry-types/directory_node_test.go +++ b/xrpl/ledger-entry-types/directory_node_test.go @@ -72,7 +72,7 @@ func TestOwnerDirectoryNode(t *testing.T) { func TestNFTTokenBuyOffersDirectoryNode(t *testing.T) { var s Object = &DirectoryNode{ - Flags: lsfNFTokenBuyOffers, + Flags: LsfNFTokenBuyOffers, Indexes: []types.Hash256{ "68227B203065DED9EEB8B73FC952494A1DA6A69CEABEAA99923836EB5E77C95A", }, @@ -102,7 +102,7 @@ func TestNFTTokenBuyOffersDirectoryNode(t *testing.T) { func TestNFTTokenSellOffersDirectoryNode(t *testing.T) { var s Object = &DirectoryNode{ - Flags: lsfNFTokenSellOffers, + Flags: LsfNFTokenSellOffers, Indexes: []types.Hash256{ "68227B203065DED9EEB8B73FC952494A1DA6A69CEABEAA99923836EB5E77C95A", }, @@ -138,11 +138,11 @@ func TestDirectoryNode_LedgerEntryType(t *testing.T) { func TestDirectoryNode_SetNFTokenBuyOffers(t *testing.T) { s := &DirectoryNode{} s.SetNFTokenBuyOffers() - require.Equal(t, s.Flags, lsfNFTokenBuyOffers) + require.Equal(t, s.Flags, LsfNFTokenBuyOffers) } func TestDirectoryNode_SetNFTokenSellOffers(t *testing.T) { s := &DirectoryNode{} s.SetNFTokenSellOffers() - require.Equal(t, s.Flags, lsfNFTokenSellOffers) + require.Equal(t, s.Flags, LsfNFTokenSellOffers) } diff --git a/xrpl/ledger-entry-types/loan.go b/xrpl/ledger-entry-types/loan.go index e82bcb84..6b10091e 100644 --- a/xrpl/ledger-entry-types/loan.go +++ b/xrpl/ledger-entry-types/loan.go @@ -6,12 +6,12 @@ import ( // LoanFlags represents flags for Loan ledger entries. const ( - // lsfLoanDefault indicates that the Loan is defaulted. - lsfLoanDefault uint32 = 0x00010000 - // lsfLoanImpaired indicates that the Loan is impaired. - lsfLoanImpaired uint32 = 0x00020000 - // lsfLoanOverpayment indicates that the Loan supports overpayments. - lsfLoanOverpayment uint32 = 0x00040000 + // LsfLoanDefault indicates that the Loan is defaulted. + LsfLoanDefault uint32 = 0x00010000 + // LsfLoanImpaired indicates that the Loan is impaired. + LsfLoanImpaired uint32 = 0x00020000 + // LsfLoanOverpayment indicates that the Loan supports overpayments. + LsfLoanOverpayment uint32 = 0x00040000 ) // Loan represents a Loan ledger entry that captures various Loan terms on-chain. @@ -108,17 +108,17 @@ func (*Loan) EntryType() EntryType { return LoanEntry } -// SetLsfLoanDefault sets the lsfLoanDefault flag, indicating that the Loan is defaulted. +// SetLsfLoanDefault sets the LsfLoanDefault flag, indicating that the Loan is defaulted. func (l *Loan) SetLsfLoanDefault() { - l.Flags |= lsfLoanDefault + l.Flags |= LsfLoanDefault } -// SetLsfLoanImpaired sets the lsfLoanImpaired flag, indicating that the Loan is impaired. +// SetLsfLoanImpaired sets the LsfLoanImpaired flag, indicating that the Loan is impaired. func (l *Loan) SetLsfLoanImpaired() { - l.Flags |= lsfLoanImpaired + l.Flags |= LsfLoanImpaired } -// SetLsfLoanOverpayment sets the lsfLoanOverpayment flag, indicating that the Loan supports overpayments. +// SetLsfLoanOverpayment sets the LsfLoanOverpayment flag, indicating that the Loan supports overpayments. func (l *Loan) SetLsfLoanOverpayment() { - l.Flags |= lsfLoanOverpayment + l.Flags |= LsfLoanOverpayment } diff --git a/xrpl/ledger-entry-types/loan_test.go b/xrpl/ledger-entry-types/loan_test.go index d97d35ed..f3b5529a 100644 --- a/xrpl/ledger-entry-types/loan_test.go +++ b/xrpl/ledger-entry-types/loan_test.go @@ -62,19 +62,19 @@ func TestLoan_EntryType(t *testing.T) { func TestLoan_SetLsfLoanDefault(t *testing.T) { l := &Loan{} l.SetLsfLoanDefault() - require.Equal(t, l.Flags, lsfLoanDefault) + require.Equal(t, l.Flags, LsfLoanDefault) } func TestLoan_SetLsfLoanImpaired(t *testing.T) { l := &Loan{} l.SetLsfLoanImpaired() - require.Equal(t, l.Flags, lsfLoanImpaired) + require.Equal(t, l.Flags, LsfLoanImpaired) } func TestLoan_SetLsfLoanOverpayment(t *testing.T) { l := &Loan{} l.SetLsfLoanOverpayment() - require.Equal(t, l.Flags, lsfLoanOverpayment) + require.Equal(t, l.Flags, LsfLoanOverpayment) } func TestLoan_WithOptionalFields(t *testing.T) { diff --git a/xrpl/ledger-entry-types/mptoken.go b/xrpl/ledger-entry-types/mptoken.go index 150f3a2a..60e999f0 100644 --- a/xrpl/ledger-entry-types/mptoken.go +++ b/xrpl/ledger-entry-types/mptoken.go @@ -3,12 +3,12 @@ package ledger import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" const ( - // If enabled, indicates that the MPT owned by this account is currently locked and cannot be used in any XRP transactions other than sending value back to the issuer. - lsfMPTLocked uint32 = 0x00000001 + // LsfMPTLocked if enabled, indicates that the MPT owned by this account is currently locked and cannot be used in any XRP transactions other than sending value back to the issuer. + LsfMPTLocked uint32 = 0x00000001 - // (Only applicable for allow-listing) If set, indicates that the issuer has authorized the holder for the MPT. - // This flag can be set using a MPTokenAuthorize transaction; it can also be "un-set" using a MPTokenAuthorize transaction specifying the tfMPTUnauthorize flag. - lsfMPTAuthorized uint32 = 0x00000002 + // LsfMPTAuthorized if set, indicates that the issuer has authorized the holder for the MPT. (Only applicable for allow-listing). + // This flag can be set using a MPTokenAuthorize transaction; it can also be "un-set" using a MPTokenAuthorize transaction specifying the TfMPTUnauthorize flag. + LsfMPTAuthorized uint32 = 0x00000002 ) // An MPToken entry tracks MPTs held by an account that is not the token issuer. You can create or delete an empty MPToken entry by sending an MPTokenAuthorize transaction. @@ -43,12 +43,12 @@ func (*MPToken) EntryType() EntryType { return MPTokenEntry } -// SetLsfMPTLocked sets the lsfMPTLocked flag. +// SetLsfMPTLocked sets the LsfMPTLocked flag. func (c *MPToken) SetLsfMPTLocked() { - c.Flags |= lsfMPTLocked + c.Flags |= LsfMPTLocked } -// SetLsfMPTAuthorized sets the lsfMPTAuthorized flag. +// SetLsfMPTAuthorized sets the LsfMPTAuthorized flag. func (c *MPToken) SetLsfMPTAuthorized() { - c.Flags |= lsfMPTAuthorized + c.Flags |= LsfMPTAuthorized } diff --git a/xrpl/ledger-entry-types/mptoken_issuance.go b/xrpl/ledger-entry-types/mptoken_issuance.go index eb8ffe80..bca9d979 100644 --- a/xrpl/ledger-entry-types/mptoken_issuance.go +++ b/xrpl/ledger-entry-types/mptoken_issuance.go @@ -5,20 +5,20 @@ import ( ) const ( - // (Only applicable for allow-listing) If set, indicates that the issuer has authorized the holder for the MPT. - // This flag can be set using a MPTokenAuthorize transaction; it can also be "un-set" using a MPTokenAuthorize transaction specifying the tfMPTUnauthorize flag. - lsfMPTCanLock uint32 = 0x00000002 - // If set, indicates that individual holders must be authorized. This enables issuers to limit who can hold their assets. - lsfMPTRequireAuth uint32 = 0x00000004 - // If set, indicates that individual holders can place their balances into an escrow. - lsfMPTCanEscrow uint32 = 0x00000008 - // If set, indicates that individual holders can trade their balances using the XRP Ledger DEX or AMM. - lsfMPTCanTrade uint32 = 0x00000010 - // If set, indicates that tokens held by non-issuers can be transferred to other accounts. + // LsfMPTCanLock if set, indicates that the issuer has authorized the holder for the MPT. (Only applicable for allow-listing). + // This flag can be set using a MPTokenAuthorize transaction; it can also be "un-set" using a MPTokenAuthorize transaction specifying the TfMPTUnauthorize flag. + LsfMPTCanLock uint32 = 0x00000002 + // LsfMPTRequireAuth if set, indicates that individual holders must be authorized. This enables issuers to limit who can hold their assets. + LsfMPTRequireAuth uint32 = 0x00000004 + // LsfMPTCanEscrow if set, indicates that individual holders can place their balances into an escrow. + LsfMPTCanEscrow uint32 = 0x00000008 + // LsfMPTCanTrade if set, indicates that individual holders can trade their balances using the XRP Ledger DEX or AMM. + LsfMPTCanTrade uint32 = 0x00000010 + // LsfMPTCanTransfer if set, indicates that tokens held by non-issuers can be transferred to other accounts. // If not set, indicates that tokens held by non-issuers cannot be transferred except back to the issuer; this enables use cases such as store credit. - lsfMPTCanTransfer uint32 = 0x00000020 - // If set, indicates that the issuer may use the Clawback transaction to claw back value from individual holders. - lsfMPTCanClawback uint32 = 0x00000040 + LsfMPTCanTransfer uint32 = 0x00000020 + // LsfMPTCanClawback if set, indicates that the issuer may use the Clawback transaction to claw back value from individual holders. + LsfMPTCanClawback uint32 = 0x00000040 ) // An MPTokenIssuance entry represents a single MPT issuance and holds data associated with the issuance itself. @@ -68,37 +68,37 @@ func (*MPTokenIssuance) EntryType() EntryType { return MPTokenIssuanceEntry } -// SetLsfMPTLocked sets the lsfMPTLocked flag. +// SetLsfMPTLocked sets the LsfMPTLocked flag. func (c *MPTokenIssuance) SetLsfMPTLocked() { - c.Flags |= lsfMPTLocked + c.Flags |= LsfMPTLocked } -// SetLsfMPTCanLock sets the lsfMPTCanLock flag. +// SetLsfMPTCanLock sets the LsfMPTCanLock flag. func (c *MPTokenIssuance) SetLsfMPTCanLock() { - c.Flags |= lsfMPTCanLock + c.Flags |= LsfMPTCanLock } -// SetLsfMPTRequireAuth sets the lsfMPTRequireAuth flag. +// SetLsfMPTRequireAuth sets the LsfMPTRequireAuth flag. func (c *MPTokenIssuance) SetLsfMPTRequireAuth() { - c.Flags |= lsfMPTRequireAuth + c.Flags |= LsfMPTRequireAuth } -// SetLsfMPTCanEscrow sets the lsfMPTCanEscrow flag. +// SetLsfMPTCanEscrow sets the LsfMPTCanEscrow flag. func (c *MPTokenIssuance) SetLsfMPTCanEscrow() { - c.Flags |= lsfMPTCanEscrow + c.Flags |= LsfMPTCanEscrow } -// SetLsfMPTCanTrade sets the lsfMPTCanTrade flag. +// SetLsfMPTCanTrade sets the LsfMPTCanTrade flag. func (c *MPTokenIssuance) SetLsfMPTCanTrade() { - c.Flags |= lsfMPTCanTrade + c.Flags |= LsfMPTCanTrade } -// SetLsfMPTCanTransfer sets the lsfMPTCanTransfer flag. +// SetLsfMPTCanTransfer sets the LsfMPTCanTransfer flag. func (c *MPTokenIssuance) SetLsfMPTCanTransfer() { - c.Flags |= lsfMPTCanTransfer + c.Flags |= LsfMPTCanTransfer } -// SetLsfMPTCanClawback sets the lsfMPTCanClawback flag. +// SetLsfMPTCanClawback sets the LsfMPTCanClawback flag. func (c *MPTokenIssuance) SetLsfMPTCanClawback() { - c.Flags |= lsfMPTCanClawback + c.Flags |= LsfMPTCanClawback } diff --git a/xrpl/ledger-entry-types/mptoken_issuance_test.go b/xrpl/ledger-entry-types/mptoken_issuance_test.go index 38a40463..568bf29e 100644 --- a/xrpl/ledger-entry-types/mptoken_issuance_test.go +++ b/xrpl/ledger-entry-types/mptoken_issuance_test.go @@ -16,43 +16,43 @@ func TestMPTokenIssuance_EntryType(t *testing.T) { func TestMPTokenIssuance_SetLsfMPTLocked(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTLocked() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTLocked) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTLocked) } func TestMPTokenIssuance_SetLsfMPTCanLock(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTCanLock() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTCanLock) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTCanLock) } func TestMPTokenIssuance_SetLsfMPTRequireAuth(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTRequireAuth() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTRequireAuth) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTRequireAuth) } func TestMPTokenIssuance_SetLsfMPTCanEscrow(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTCanEscrow() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTCanEscrow) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTCanEscrow) } func TestMPTokenIssuance_SetLsfMPTCanTrade(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTCanTrade() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTCanTrade) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTCanTrade) } func TestMPTokenIssuance_SetLsfMPTCanTransfer(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTCanTransfer() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTCanTransfer) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTCanTransfer) } func TestMPTokenIssuance_SetLsfMPTCanClawback(t *testing.T) { mpTokenIssuance := &MPTokenIssuance{} mpTokenIssuance.SetLsfMPTCanClawback() - require.Equal(t, mpTokenIssuance.Flags, lsfMPTCanClawback) + require.Equal(t, mpTokenIssuance.Flags, LsfMPTCanClawback) } func TestMPTokenIssuanceSerialization(t *testing.T) { @@ -62,11 +62,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { expected string }{ { - name: "pass - valid MPToken with lsfMPTLocked", + name: "pass - valid MPToken with LsfMPTLocked", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTLocked, + Flags: LsfMPTLocked, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, @@ -95,11 +95,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTCanLock", + name: "pass - valid MPToken with LsfMPTCanLock", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTCanLock, + Flags: LsfMPTCanLock, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, @@ -128,11 +128,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTCanLock", + name: "pass - valid MPToken with LsfMPTCanLock", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTRequireAuth, + Flags: LsfMPTRequireAuth, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, @@ -161,11 +161,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTCanEscrow", + name: "pass - valid MPToken with LsfMPTCanEscrow", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTCanEscrow, + Flags: LsfMPTCanEscrow, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, @@ -194,11 +194,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTCanTrade", + name: "pass - valid MPToken with LsfMPTCanTrade", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTCanTrade, + Flags: LsfMPTCanTrade, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, @@ -227,11 +227,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTCanTransfer", + name: "pass - valid MPToken with LsfMPTCanTransfer", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTCanTransfer, + Flags: LsfMPTCanTransfer, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, @@ -260,11 +260,11 @@ func TestMPTokenIssuanceSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTCanClawback", + name: "pass - valid MPToken with LsfMPTCanClawback", mpTokenIssuance: &MPTokenIssuance{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenIssuanceEntry, - Flags: lsfMPTCanClawback, + Flags: LsfMPTCanClawback, Issuer: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), AssetScale: 2, MaximumAmount: 1000, diff --git a/xrpl/ledger-entry-types/mptoken_test.go b/xrpl/ledger-entry-types/mptoken_test.go index 26524e69..938cbdca 100644 --- a/xrpl/ledger-entry-types/mptoken_test.go +++ b/xrpl/ledger-entry-types/mptoken_test.go @@ -16,13 +16,13 @@ func TestMPToken_EntryType(t *testing.T) { func TestMPToken_SetLsfMPTLocked(t *testing.T) { mpToken := &MPToken{} mpToken.SetLsfMPTLocked() - require.Equal(t, mpToken.Flags, lsfMPTLocked) + require.Equal(t, mpToken.Flags, LsfMPTLocked) } func TestMPToken_SetLsfMPTAuthorized(t *testing.T) { mpToken := &MPToken{} mpToken.SetLsfMPTAuthorized() - require.Equal(t, mpToken.Flags, lsfMPTAuthorized) + require.Equal(t, mpToken.Flags, LsfMPTAuthorized) } func TestMPTokenSerialization(t *testing.T) { @@ -32,11 +32,11 @@ func TestMPTokenSerialization(t *testing.T) { expected string }{ { - name: "pass - valid MPToken with lsfMPTLocked", + name: "pass - valid MPToken with LsfMPTLocked", mpToken: &MPToken{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenEntry, - Flags: lsfMPTLocked, + Flags: LsfMPTLocked, Account: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), MPTokenIssuanceID: types.Hash192("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1"), MPTAmount: 1000000, @@ -59,11 +59,11 @@ func TestMPTokenSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTAuthorized", + name: "pass - valid MPToken with LsfMPTAuthorized", mpToken: &MPToken{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenEntry, - Flags: lsfMPTAuthorized, + Flags: LsfMPTAuthorized, Account: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), MPTokenIssuanceID: types.Hash192("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1"), MPTAmount: 1000000, @@ -86,11 +86,11 @@ func TestMPTokenSerialization(t *testing.T) { }`, }, { - name: "pass - valid MPToken with lsfMPTLocked and lsfMPTAuthorized", + name: "pass - valid MPToken with LsfMPTLocked and LsfMPTAuthorized", mpToken: &MPToken{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenEntry, - Flags: lsfMPTLocked | lsfMPTAuthorized, + Flags: LsfMPTLocked | LsfMPTAuthorized, Account: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), MPTokenIssuanceID: types.Hash192("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1"), MPTAmount: 1000000, @@ -117,7 +117,7 @@ func TestMPTokenSerialization(t *testing.T) { mpToken: &MPToken{ Index: types.Hash256("A738A1E6E8505E1FC77BBB9FEF84FF9A9C609F2739E0F9573CDD6367100A0AA9"), LedgerEntryType: MPTokenEntry, - Flags: lsfMPTLocked, + Flags: LsfMPTLocked, Account: types.Address("rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD"), MPTokenIssuanceID: types.Hash192("rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1"), MPTAmount: 1000000, diff --git a/xrpl/ledger-entry-types/nftoken_offer.go b/xrpl/ledger-entry-types/nftoken_offer.go index 7ea69b06..50409c9d 100644 --- a/xrpl/ledger-entry-types/nftoken_offer.go +++ b/xrpl/ledger-entry-types/nftoken_offer.go @@ -34,7 +34,7 @@ type NFTokenOffer struct { Flags uint32 // The value 0x0037, mapped to the string NFTokenOffer, indicates that this is an offer to trade a NFToken. LedgerEntryType EntryType - // Amount expected or offered for the NFToken. If the token has the lsfOnlyXRP flag set, + // Amount expected or offered for the NFToken. If the token has the LsfOnlyXRP flag set, // the amount must be specified in XRP. Sell offers that specify assets other than XRP // must specify a non-zero amount. Sell offers that specify XRP can be 'free' (that is, // the Amount field can be equal to "0"). diff --git a/xrpl/ledger-entry-types/offer.go b/xrpl/ledger-entry-types/offer.go index 473b98b5..54e5370f 100644 --- a/xrpl/ledger-entry-types/offer.go +++ b/xrpl/ledger-entry-types/offer.go @@ -7,16 +7,16 @@ import ( ) const ( - // The offer was placed as "passive". This has no effect after the offer is placed into + // LsfPassive the offer was placed as "passive". This has no effect after the offer is placed into // the ledger. - lsfPassive uint32 = 0x00010000 - // The offer was placed as a "Sell" offer. This has no effect after the offer is placed - // in the ledger, because tfSell only matters if you get a better rate than you asked for + LsfPassive uint32 = 0x00010000 + // LsfSell the offer was placed as a "Sell" offer. This has no effect after the offer is placed + // in the ledger, because TfSell only matters if you get a better rate than you asked for // which can only happen when the offer is initially placed. - lsfSell uint32 = 0x00020000 - // Indicates the offer is hybrid. (meaning it is part of both a domain and open order book) + LsfSell uint32 = 0x00020000 + // LsfHybrid indicates the offer is hybrid. (meaning it is part of both a domain and open order book) // This flag cannot be set if the offer doesn't have a DomainID. - lsfHybrid uint32 = 0x00040000 + LsfHybrid uint32 = 0x00040000 ) // Book represents an offer book. @@ -116,17 +116,17 @@ func (*Offer) EntryType() EntryType { // SetLsfPassive sets the offer as passive. func (o *Offer) SetLsfPassive() { - o.Flags |= lsfPassive + o.Flags |= LsfPassive } // SetLsfSell sets the offer as a sell offer. func (o *Offer) SetLsfSell() { - o.Flags |= lsfSell + o.Flags |= LsfSell } // SetLsfHybrid sets the hybrid flag. func (o *Offer) SetLsfHybrid() { - o.Flags |= lsfHybrid + o.Flags |= LsfHybrid } // UnmarshalJSON unmarshals the offer from a JSON byte slice. diff --git a/xrpl/ledger-entry-types/ripple_state.go b/xrpl/ledger-entry-types/ripple_state.go index a106696e..59099bfc 100644 --- a/xrpl/ledger-entry-types/ripple_state.go +++ b/xrpl/ledger-entry-types/ripple_state.go @@ -3,32 +3,31 @@ package ledger import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" const ( - // This entry consumed AMM liquidity to complete a Payment transaction. - lsfAMMNode uint32 = 0x01000000 - // This entry contributes to the low account's owner reserve. - lsfLowReserve uint32 = 0x00010000 - // This entry contributes to the high account's owner reserve. - lsfHighReserve uint32 = 0x00020000 - // The low account has authorized the high account to hold tokens issued by the low account. - lsfLowAuth uint32 = 0x00040000 - // The high account has authorized the low account to hold tokens issued by the high account. - lsfHighAuth uint32 = 0x00080000 - // The low account has disabled rippling from this trust line. - lsfLowNoRipple uint32 = 0x00100000 - // The high account has disabled rippling from this trust line. - lsfHighNoRipple uint32 = 0x00200000 - // The low account has frozen the trust line, preventing the high account from transferring the asset. - lsfLowFreeze uint32 = 0x00400000 - // The high account has frozen the trust line, preventing the low account from transferring the asset. - lsfHighFreeze uint32 = 0x00800000 - - // XLS-77d Deep freeze - // The low account has deep-frozen the trust line, preventing the high account from sending and + // LsfAMMNode this entry consumed AMM liquidity to complete a Payment transaction. + LsfAMMNode uint32 = 0x01000000 + // LsfLowReserve this entry contributes to the low account's owner reserve. + LsfLowReserve uint32 = 0x00010000 + // LsfHighReserve this entry contributes to the high account's owner reserve. + LsfHighReserve uint32 = 0x00020000 + // LsfLowAuth the low account has authorized the high account to hold tokens issued by the low account. + LsfLowAuth uint32 = 0x00040000 + // LsfHighAuth the high account has authorized the low account to hold tokens issued by the high account. + LsfHighAuth uint32 = 0x00080000 + // LsfLowNoRipple the low account has disabled rippling from this trust line. + LsfLowNoRipple uint32 = 0x00100000 + // LsfHighNoRipple the high account has disabled rippling from this trust line. + LsfHighNoRipple uint32 = 0x00200000 + // LsfLowFreeze the low account has frozen the trust line, preventing the high account from transferring the asset. + LsfLowFreeze uint32 = 0x00400000 + // LsfHighFreeze the high account has frozen the trust line, preventing the low account from transferring the asset. + LsfHighFreeze uint32 = 0x00800000 + + // LsfLowDeepFreeze (XLS-77d Deep freeze) the low account has deep-frozen the trust line, preventing the high account from sending and // receiving the asset. - lsfLowDeepFreeze uint32 = 0x02000000 - // The high account has deep-frozen the trust line, preventing the low account from sending and + LsfLowDeepFreeze uint32 = 0x02000000 + // LsfHighDeepFreeze the high account has deep-frozen the trust line, preventing the low account from sending and // receiving the asset. - lsfHighDeepFreeze uint32 = 0x04000000 + LsfHighDeepFreeze uint32 = 0x04000000 ) // RippleState ledger entry represents a trust line between two accounts. @@ -113,55 +112,55 @@ func (*RippleState) EntryType() EntryType { // SetLsfAMMNode sets the AMM node flag. func (r *RippleState) SetLsfAMMNode() { - r.Flags |= lsfAMMNode + r.Flags |= LsfAMMNode } // SetLsfLowReserve sets the low reserve flag. func (r *RippleState) SetLsfLowReserve() { - r.Flags |= lsfLowReserve + r.Flags |= LsfLowReserve } // SetLsfHighReserve sets the high reserve flag. func (r *RippleState) SetLsfHighReserve() { - r.Flags |= lsfHighReserve + r.Flags |= LsfHighReserve } // SetLsfLowAuth sets the low auth flag. func (r *RippleState) SetLsfLowAuth() { - r.Flags |= lsfLowAuth + r.Flags |= LsfLowAuth } // SetLsfHighAuth sets the high auth flag. func (r *RippleState) SetLsfHighAuth() { - r.Flags |= lsfHighAuth + r.Flags |= LsfHighAuth } // SetLsfLowNoRipple sets the low no ripple flag. func (r *RippleState) SetLsfLowNoRipple() { - r.Flags |= lsfLowNoRipple + r.Flags |= LsfLowNoRipple } // SetLsfHighNoRipple sets the high no ripple flag. func (r *RippleState) SetLsfHighNoRipple() { - r.Flags |= lsfHighNoRipple + r.Flags |= LsfHighNoRipple } // SetLsfLowFreeze sets the low freeze flag. func (r *RippleState) SetLsfLowFreeze() { - r.Flags |= lsfLowFreeze + r.Flags |= LsfLowFreeze } // SetLsfHighFreeze sets the high freeze flag. func (r *RippleState) SetLsfHighFreeze() { - r.Flags |= lsfHighFreeze + r.Flags |= LsfHighFreeze } // SetLsfLowDeepFreeze sets the low deep freeze flag. func (r *RippleState) SetLsfLowDeepFreeze() { - r.Flags |= lsfLowDeepFreeze + r.Flags |= LsfLowDeepFreeze } // SetLsfHighDeepFreeze sets the high deep freeze flag. func (r *RippleState) SetLsfHighDeepFreeze() { - r.Flags |= lsfHighDeepFreeze + r.Flags |= LsfHighDeepFreeze } diff --git a/xrpl/ledger-entry-types/ripple_state_test.go b/xrpl/ledger-entry-types/ripple_state_test.go index 90343eac..f410f95c 100644 --- a/xrpl/ledger-entry-types/ripple_state_test.go +++ b/xrpl/ledger-entry-types/ripple_state_test.go @@ -70,65 +70,65 @@ func TestRippleState_EntryType(t *testing.T) { func TestRippleState_SetLsfAMMNode(t *testing.T) { s := &RippleState{} s.SetLsfAMMNode() - require.Equal(t, s.Flags&lsfAMMNode, lsfAMMNode) + require.Equal(t, s.Flags&LsfAMMNode, LsfAMMNode) } func TestRippleState_SetLsfLowReserve(t *testing.T) { s := &RippleState{} s.SetLsfLowReserve() - require.Equal(t, s.Flags&lsfLowReserve, lsfLowReserve) + require.Equal(t, s.Flags&LsfLowReserve, LsfLowReserve) } func TestRippleState_SetLsfHighReserve(t *testing.T) { s := &RippleState{} s.SetLsfHighReserve() - require.Equal(t, s.Flags&lsfHighReserve, lsfHighReserve) + require.Equal(t, s.Flags&LsfHighReserve, LsfHighReserve) } func TestRippleState_SetLsfLowAuth(t *testing.T) { s := &RippleState{} s.SetLsfLowAuth() - require.Equal(t, s.Flags&lsfLowAuth, lsfLowAuth) + require.Equal(t, s.Flags&LsfLowAuth, LsfLowAuth) } func TestRippleState_SetLsfHighAuth(t *testing.T) { s := &RippleState{} s.SetLsfHighAuth() - require.Equal(t, s.Flags&lsfHighAuth, lsfHighAuth) + require.Equal(t, s.Flags&LsfHighAuth, LsfHighAuth) } func TestRippleState_SetLsfLowNoRipple(t *testing.T) { s := &RippleState{} s.SetLsfLowNoRipple() - require.Equal(t, s.Flags&lsfLowNoRipple, lsfLowNoRipple) + require.Equal(t, s.Flags&LsfLowNoRipple, LsfLowNoRipple) } func TestRippleState_SetLsfHighNoRipple(t *testing.T) { s := &RippleState{} s.SetLsfHighNoRipple() - require.Equal(t, s.Flags&lsfHighNoRipple, lsfHighNoRipple) + require.Equal(t, s.Flags&LsfHighNoRipple, LsfHighNoRipple) } func TestRippleState_SetLsfLowFreeze(t *testing.T) { s := &RippleState{} s.SetLsfLowFreeze() - require.Equal(t, s.Flags&lsfLowFreeze, lsfLowFreeze) + require.Equal(t, s.Flags&LsfLowFreeze, LsfLowFreeze) } func TestRippleState_SetLsfHighFreeze(t *testing.T) { s := &RippleState{} s.SetLsfHighFreeze() - require.Equal(t, s.Flags&lsfHighFreeze, lsfHighFreeze) + require.Equal(t, s.Flags&LsfHighFreeze, LsfHighFreeze) } func TestRippleState_SetLsfLowDeepFreeze(t *testing.T) { s := &RippleState{} s.SetLsfLowDeepFreeze() - require.Equal(t, s.Flags&lsfLowDeepFreeze, lsfLowDeepFreeze) + require.Equal(t, s.Flags&LsfLowDeepFreeze, LsfLowDeepFreeze) } func TestRippleState_SetLsfHighDeepFreeze(t *testing.T) { s := &RippleState{} s.SetLsfHighDeepFreeze() - require.Equal(t, s.Flags&lsfHighDeepFreeze, lsfHighDeepFreeze) + require.Equal(t, s.Flags&LsfHighDeepFreeze, LsfHighDeepFreeze) } diff --git a/xrpl/ledger-entry-types/signer_list.go b/xrpl/ledger-entry-types/signer_list.go index 21c10682..22beb2a4 100644 --- a/xrpl/ledger-entry-types/signer_list.go +++ b/xrpl/ledger-entry-types/signer_list.go @@ -3,10 +3,10 @@ package ledger import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" const ( - // If this flag is enabled, this SignerList counts as one item for purposes of the owner reserve + // LsfOneOwnerCount if this flag is enabled, this SignerList counts as one item for purposes of the owner reserve // Otherwise, this list counts as N+2 items, where N is the number of signers it contains. This // flag is automatically enabled if you add or update a signer list after the MultiSignReserve amendment is enabled. - lsfOneOwnerCount uint32 = 0x00010000 + LsfOneOwnerCount uint32 = 0x00010000 ) // SignerList entry represents a list of parties that, as a group, are authorized to sign a transaction in place of an individual account. @@ -118,5 +118,5 @@ func (*SignerList) EntryType() EntryType { // SetLsfOneOwnerCount sets the one owner count flag. func (s *SignerList) SetLsfOneOwnerCount() { - s.Flags |= lsfOneOwnerCount + s.Flags |= LsfOneOwnerCount } diff --git a/xrpl/ledger-entry-types/signer_list_test.go b/xrpl/ledger-entry-types/signer_list_test.go index 9644c7cc..d4b3dbfe 100644 --- a/xrpl/ledger-entry-types/signer_list_test.go +++ b/xrpl/ledger-entry-types/signer_list_test.go @@ -75,7 +75,7 @@ func TestSignerList(t *testing.T) { func TestSignerList_SetLsfOneOwnerCount(t *testing.T) { s := &SignerList{} s.SetLsfOneOwnerCount() - require.Equal(t, s.Flags&lsfOneOwnerCount, lsfOneOwnerCount) + require.Equal(t, s.Flags&LsfOneOwnerCount, LsfOneOwnerCount) } func TestSignerList_EntryType(t *testing.T) { diff --git a/xrpl/transaction/account_set.go b/xrpl/transaction/account_set.go index 68c44300..19947300 100644 --- a/xrpl/transaction/account_set.go +++ b/xrpl/transaction/account_set.go @@ -9,61 +9,62 @@ const ( // // Account Set Flags // - // Require a destination tag to send transactions to this account. - asfRequireDest uint32 = 1 - // Require authorization for users to hold balances issued by this address. + + // AsfRequireDest requires a destination tag to send transactions to this account. + AsfRequireDest uint32 = 1 + // AsfRequireAuth requires authorization for users to hold balances issued by this address. // Can only be enabled if the address has no trust lines connected to it. - asfRequireAuth uint32 = 2 - // XRP should not be sent to this account. - asfDisallowXRP uint32 = 3 - // Disallow use of the master key pair. Can only be enabled if the account + AsfRequireAuth uint32 = 2 + // AsfDisallowXRP indicates XRP should not be sent to this account. + AsfDisallowXRP uint32 = 3 + // AsfDisableMaster disallows use of the master key pair. Can only be enabled if the account // has configured another way to sign transactions, such as a Regular Key or a // Signer List. - asfDisableMaster uint32 = 4 - // Track the ID of this account's most recent transaction. Required for + AsfDisableMaster uint32 = 4 + // AsfAccountTxnID tracks the ID of this account's most recent transaction. Required for // AccountTxnID. - asfAccountTxnID uint32 = 5 - // Permanently give up the ability to freeze individual trust lines or + AsfAccountTxnID uint32 = 5 + // AsfNoFreeze permanently gives up the ability to freeze individual trust lines or // disable Global Freeze. This flag can never be disabled after being enabled. - asfNoFreeze uint32 = 6 - // Freeze all assets issued by this account. - asfGlobalFreeze uint32 = 7 - // Enable rippling on this account's trust lines by default. - asfDefaultRipple uint32 = 8 - // Enable Deposit Authorization on this account. - asfDepositAuth uint32 = 9 - // Allow another account to mint and burn tokens on behalf of this account. + AsfNoFreeze uint32 = 6 + // AsfGlobalFreeze freezes all assets issued by this account. + AsfGlobalFreeze uint32 = 7 + // AsfDefaultRipple enables rippling on this account's trust lines by default. + AsfDefaultRipple uint32 = 8 + // AsfDepositAuth enables Deposit Authorization on this account. + AsfDepositAuth uint32 = 9 + // AsfAuthorizedNFTokenMinter allows another account to mint and burn tokens on behalf of this account. // To remove an authorized minter, enable this flag and omit the NFTokenMinter field. - asfAuthorizedNFTokenMinter uint32 = 10 - // asf 11 is reserved for Hooks amendment - // Disallow other accounts from creating incoming NFTOffers - asfDisallowIncomingNFTokenOffer uint32 = 12 - // Disallow other accounts from creating incoming Checks - asfDisallowIncomingCheck uint32 = 13 - // Disallow other accounts from creating incoming Payment Channels - asfDisallowIncomingPayChan uint32 = 14 - // Disallow other accounts from creating incoming TrustLines - asfDisallowIncomingTrustLine uint32 = 15 - // Permanently gain the ability to claw back issued IOUs - asfAllowTrustLineClawback uint32 = 16 - // Issuers allow their IOUs to be used as escrow amounts - asfAllowTrustLineLocking uint32 = 17 + AsfAuthorizedNFTokenMinter uint32 = 10 + // AsfDisallowIncomingNFTokenOffer disallows other accounts from creating incoming NFTOffers (note: asf 11 is reserved for Hooks amendment) + AsfDisallowIncomingNFTokenOffer uint32 = 12 + // AsfDisallowIncomingCheck disallows other accounts from creating incoming Checks + AsfDisallowIncomingCheck uint32 = 13 + // AsfDisallowIncomingPayChan disallows other accounts from creating incoming Payment Channels + AsfDisallowIncomingPayChan uint32 = 14 + // AsfDisallowIncomingTrustLine disallows other accounts from creating incoming TrustLines + AsfDisallowIncomingTrustLine uint32 = 15 + // AsfAllowTrustLineClawback permanently gains the ability to claw back issued IOUs + AsfAllowTrustLineClawback uint32 = 16 + // AsfAllowTrustLineLocking allows issuers to use their IOUs as escrow amounts + AsfAllowTrustLineLocking uint32 = 17 // // Transaction Flags // - // The same as SetFlag: asfRequireDest. - tfRequireDestTag uint32 = 65536 // 0x00010000 - // The same as ClearFlag: asfRequireDestTag. - tfOptionalDestTag uint32 = 131072 // 0x00020000 - // The same as SetFlag: asfRequireAuth. - tfRequireAuth uint32 = 262144 // 0x00040000 - // The same as ClearFlag: asfRequireAuth. - tfOptionalAuth uint32 = 524288 // 0x00080000 - // The same as SetFlag: asfDisallowXRP. - tfDisallowXRP uint32 = 1048576 // 0x00100000 - // The same as ClearFlag: asfDisallowXRP. - tfAllowXRP uint32 = 2097152 // 0x00200000 + + // TfRequireDestTag the same as SetFlag: AsfRequireDest. + TfRequireDestTag uint32 = 65536 // 0x00010000 + // TfOptionalDestTag the same as ClearFlag: AsfRequireDestTag. + TfOptionalDestTag uint32 = 131072 // 0x00020000 + // TfRequireAuth the same as SetFlag: AsfRequireAuth. + TfRequireAuth uint32 = 262144 // 0x00040000 + // TfOptionalAuth the same as ClearFlag: AsfRequireAuth. + TfOptionalAuth uint32 = 524288 // 0x00080000 + // TfDisallowXRP the same as SetFlag: AsfDisallowXRP. + TfDisallowXRP uint32 = 1048576 // 0x00100000 + // TfAllowXRP the same as ClearFlag: AsfDisallowXRP. + TfAllowXRP uint32 = 2097152 // 0x00200000 // MinTickSize is the minimum tick size to use for offers involving a currency issued by this address. // Valid values are 3 to 15 inclusive, or 0 to disable. @@ -78,7 +79,7 @@ const ( // Ledger. type AccountSet struct { BaseTx - // ClearFlag: asfRequireDestTag, asfOptionalDestTag, asfRequireAuth, asfOptionalAuth, asfDisallowXRP, asfAllowXRP + // ClearFlag: AsfRequireDestTag, AsfOptionalDestTag, AsfRequireAuth, AsfOptionalAuth, AsfDisallowXRP, AsfAllowXRP ClearFlag uint32 `json:",omitempty"` // The domain that owns this account, as a string of hex representing the. // ASCII for the domain in lowercase. @@ -158,192 +159,192 @@ func (s *AccountSet) Flatten() FlatTransaction { // SetRequireDestTag sets the require destination tag flag. func (s *AccountSet) SetRequireDestTag() { - s.Flags |= tfRequireDestTag + s.Flags |= TfRequireDestTag } // SetRequireAuth sets the require auth flag. func (s *AccountSet) SetRequireAuth() { - s.Flags |= tfRequireAuth + s.Flags |= TfRequireAuth } // SetDisallowXRP sets the disallow XRP flag. func (s *AccountSet) SetDisallowXRP() { - s.Flags |= tfDisallowXRP + s.Flags |= TfDisallowXRP } // SetOptionalDestTag sets the optional destination tag flag. func (s *AccountSet) SetOptionalDestTag() { - s.Flags |= tfOptionalDestTag + s.Flags |= TfOptionalDestTag } // SetOptionalAuth sets the optional auth flag. func (s *AccountSet) SetOptionalAuth() { - s.Flags |= tfOptionalAuth + s.Flags |= TfOptionalAuth } // SetAllowXRP sets the allow XRP flag. func (s *AccountSet) SetAllowXRP() { - s.Flags |= tfAllowXRP + s.Flags |= TfAllowXRP } // SetAsfRequireDest sets the require destination tag flag. func (s *AccountSet) SetAsfRequireDest() { - s.SetFlag = asfRequireDest + s.SetFlag = AsfRequireDest } // ClearAsfRequireDest clears the require destination tag flag. func (s *AccountSet) ClearAsfRequireDest() { - s.ClearFlag = asfRequireDest + s.ClearFlag = AsfRequireDest } // SetAsfRequireAuth sets the require authorization flag. func (s *AccountSet) SetAsfRequireAuth() { - s.SetFlag = asfRequireAuth + s.SetFlag = AsfRequireAuth } // ClearAsfRequireAuth clears the require authorization flag. func (s *AccountSet) ClearAsfRequireAuth() { - s.ClearFlag = asfRequireAuth + s.ClearFlag = AsfRequireAuth } // SetAsfDisallowXRP sets the disallow XRP flag. func (s *AccountSet) SetAsfDisallowXRP() { - s.SetFlag = asfDisallowXRP + s.SetFlag = AsfDisallowXRP } // ClearAsfDisallowXRP clears the disallow XRP flag. func (s *AccountSet) ClearAsfDisallowXRP() { - s.ClearFlag = asfDisallowXRP + s.ClearFlag = AsfDisallowXRP } // SetAsfDisableMaster sets the disable master key flag. func (s *AccountSet) SetAsfDisableMaster() { - s.SetFlag = asfDisableMaster + s.SetFlag = AsfDisableMaster } // ClearAsfDisableMaster clears the disable master key flag. func (s *AccountSet) ClearAsfDisableMaster() { - s.ClearFlag = asfDisableMaster + s.ClearFlag = AsfDisableMaster } // SetAsfAccountTxnID sets the account transaction ID flag. func (s *AccountSet) SetAsfAccountTxnID() { - s.SetFlag = asfAccountTxnID + s.SetFlag = AsfAccountTxnID } // ClearAsfAccountTxnID clears the account transaction ID flag. func (s *AccountSet) ClearAsfAccountTxnID() { - s.ClearFlag = asfAccountTxnID + s.ClearFlag = AsfAccountTxnID } // SetAsfNoFreeze sets the no freeze flag. func (s *AccountSet) SetAsfNoFreeze() { - s.SetFlag = asfNoFreeze + s.SetFlag = AsfNoFreeze } // ClearAsfNoFreeze clears the no freeze flag. func (s *AccountSet) ClearAsfNoFreeze() { - s.ClearFlag = asfNoFreeze + s.ClearFlag = AsfNoFreeze } // SetAsfGlobalFreeze sets the global freeze flag. func (s *AccountSet) SetAsfGlobalFreeze() { - s.SetFlag = asfGlobalFreeze + s.SetFlag = AsfGlobalFreeze } // ClearAsfGlobalFreeze clears the global freeze flag. func (s *AccountSet) ClearAsfGlobalFreeze() { - s.ClearFlag = asfGlobalFreeze + s.ClearFlag = AsfGlobalFreeze } // SetAsfDefaultRipple sets the default ripple flag. func (s *AccountSet) SetAsfDefaultRipple() { - s.SetFlag = asfDefaultRipple + s.SetFlag = AsfDefaultRipple } // ClearAsfDefaultRipple clears the default ripple flag. func (s *AccountSet) ClearAsfDefaultRipple() { - s.ClearFlag = asfDefaultRipple + s.ClearFlag = AsfDefaultRipple } // SetAsfDepositAuth sets the deposit authorization flag. func (s *AccountSet) SetAsfDepositAuth() { - s.SetFlag = asfDepositAuth + s.SetFlag = AsfDepositAuth } // ClearAsfDepositAuth clears the deposit authorization flag. func (s *AccountSet) ClearAsfDepositAuth() { - s.ClearFlag = asfDepositAuth + s.ClearFlag = AsfDepositAuth } // SetAsfAuthorizedNFTokenMinter sets the authorized NFToken minter flag. func (s *AccountSet) SetAsfAuthorizedNFTokenMinter() { - s.SetFlag = asfAuthorizedNFTokenMinter + s.SetFlag = AsfAuthorizedNFTokenMinter } // ClearAsfAuthorizedNFTokenMinter clears the authorized NFToken minter flag. func (s *AccountSet) ClearAsfAuthorizedNFTokenMinter() { - s.ClearFlag = asfAuthorizedNFTokenMinter + s.ClearFlag = AsfAuthorizedNFTokenMinter } // SetAsfDisallowIncomingNFTokenOffer sets the disallow incoming NFToken offer flag. func (s *AccountSet) SetAsfDisallowIncomingNFTokenOffer() { - s.SetFlag = asfDisallowIncomingNFTokenOffer + s.SetFlag = AsfDisallowIncomingNFTokenOffer } // ClearAsfDisallowIncomingNFTokenOffer clears the disallow incoming NFToken offer flag. func (s *AccountSet) ClearAsfDisallowIncomingNFTokenOffer() { - s.ClearFlag = asfDisallowIncomingNFTokenOffer + s.ClearFlag = AsfDisallowIncomingNFTokenOffer } // SetAsfDisallowIncomingCheck sets the disallow incoming check flag. func (s *AccountSet) SetAsfDisallowIncomingCheck() { - s.SetFlag = asfDisallowIncomingCheck + s.SetFlag = AsfDisallowIncomingCheck } // ClearAsfDisallowIncomingCheck clears the disallow incoming check flag. func (s *AccountSet) ClearAsfDisallowIncomingCheck() { - s.ClearFlag = asfDisallowIncomingCheck + s.ClearFlag = AsfDisallowIncomingCheck } // SetAsfDisallowIncomingPayChan sets the disallow incoming payment channel flag. func (s *AccountSet) SetAsfDisallowIncomingPayChan() { - s.SetFlag = asfDisallowIncomingPayChan + s.SetFlag = AsfDisallowIncomingPayChan } // ClearAsfDisallowIncomingPayChan clears the disallow incoming payment channel flag. func (s *AccountSet) ClearAsfDisallowIncomingPayChan() { - s.ClearFlag = asfDisallowIncomingPayChan + s.ClearFlag = AsfDisallowIncomingPayChan } // SetAsfDisallowIncomingTrustLine sets the disallow incoming trust line flag. func (s *AccountSet) SetAsfDisallowIncomingTrustLine() { - s.SetFlag = asfDisallowIncomingTrustLine + s.SetFlag = AsfDisallowIncomingTrustLine } // ClearAsfDisallowIncomingTrustLine clears the disallow incoming trust line flag. func (s *AccountSet) ClearAsfDisallowIncomingTrustLine() { - s.ClearFlag = asfDisallowIncomingTrustLine + s.ClearFlag = AsfDisallowIncomingTrustLine } // SetAsfAllowTrustLineClawback sets the allow trust line clawback flag. func (s *AccountSet) SetAsfAllowTrustLineClawback() { - s.SetFlag = asfAllowTrustLineClawback + s.SetFlag = AsfAllowTrustLineClawback } // ClearAsfAllowTrustLineClawback clears the allow trust line clawback flag. func (s *AccountSet) ClearAsfAllowTrustLineClawback() { - s.ClearFlag = asfAllowTrustLineClawback + s.ClearFlag = AsfAllowTrustLineClawback } // SetAsfAllowTrustLineLocking sets the allow trust line locking flag. func (s *AccountSet) SetAsfAllowTrustLineLocking() { - s.SetFlag = asfAllowTrustLineLocking + s.SetFlag = AsfAllowTrustLineLocking } // ClearAsfAllowTrustLineLocking clears the allow trust line locking flag. func (s *AccountSet) ClearAsfAllowTrustLineLocking() { - s.ClearFlag = asfAllowTrustLineLocking + s.ClearFlag = AsfAllowTrustLineLocking } // Validate the AccountSet transaction fields. @@ -408,7 +409,7 @@ func (s *AccountSet) Validate() (bool, error) { // check if SetFlag is within the valid range if s.SetFlag != 0 { - if s.SetFlag < asfRequireDest || s.SetFlag > asfAllowTrustLineLocking { + if s.SetFlag < AsfRequireDest || s.SetFlag > AsfAllowTrustLineLocking { return false, ErrAccountSetInvalidSetFlag } } diff --git a/xrpl/transaction/account_set_test.go b/xrpl/transaction/account_set_test.go index a2010d7f..29b7fc5d 100644 --- a/xrpl/transaction/account_set_test.go +++ b/xrpl/transaction/account_set_test.go @@ -20,28 +20,28 @@ func TestAccountSetTfFlags(t *testing.T) { setter: func(s *AccountSet) { s.SetRequireDestTag() }, - expected: tfRequireDestTag, + expected: TfRequireDestTag, }, { name: "pass - SetRequireAuth", setter: func(s *AccountSet) { s.SetRequireAuth() }, - expected: tfRequireAuth, + expected: TfRequireAuth, }, { name: "pass - SetDisallowXRP", setter: func(s *AccountSet) { s.SetDisallowXRP() }, - expected: tfDisallowXRP, + expected: TfDisallowXRP, }, { name: "pass - SetOptionalDestTag", setter: func(s *AccountSet) { s.SetOptionalDestTag() }, - expected: tfOptionalDestTag, + expected: TfOptionalDestTag, }, { name: "pass - SetRequireDestTag and SetRequireAuth", @@ -49,7 +49,7 @@ func TestAccountSetTfFlags(t *testing.T) { s.SetRequireDestTag() s.SetRequireAuth() }, - expected: tfRequireDestTag | tfRequireAuth, + expected: TfRequireDestTag | TfRequireAuth, }, { name: "pass - SetDisallowXRP and SetOptionalDestTag", @@ -57,7 +57,7 @@ func TestAccountSetTfFlags(t *testing.T) { s.SetDisallowXRP() s.SetOptionalDestTag() }, - expected: tfDisallowXRP | tfOptionalDestTag, + expected: TfDisallowXRP | TfOptionalDestTag, }, { name: "pass - SetRequireDestTag, SetRequireAuth, and SetDisallowXRP", @@ -66,7 +66,7 @@ func TestAccountSetTfFlags(t *testing.T) { s.SetRequireAuth() s.SetDisallowXRP() }, - expected: tfRequireDestTag | tfRequireAuth | tfDisallowXRP, + expected: TfRequireDestTag | TfRequireAuth | TfDisallowXRP, }, { name: "pass - All flags", @@ -78,7 +78,7 @@ func TestAccountSetTfFlags(t *testing.T) { s.SetOptionalAuth() s.SetAllowXRP() }, - expected: tfRequireDestTag | tfRequireAuth | tfDisallowXRP | tfOptionalDestTag | tfOptionalAuth | tfAllowXRP, + expected: TfRequireDestTag | TfRequireAuth | TfDisallowXRP | TfOptionalDestTag | TfOptionalAuth | TfAllowXRP, }, } @@ -104,112 +104,112 @@ func TestAccountSetAsfFlags(t *testing.T) { setter: func(s *AccountSet) { s.SetAsfRequireDest() }, - expected: asfRequireDest, + expected: AsfRequireDest, }, { name: "pass - SetAsfRequireAuth", setter: func(s *AccountSet) { s.SetAsfRequireAuth() }, - expected: asfRequireAuth, + expected: AsfRequireAuth, }, { name: "pass - SetAsfDisallowXRP", setter: func(s *AccountSet) { s.SetAsfDisallowXRP() }, - expected: asfDisallowXRP, + expected: AsfDisallowXRP, }, { name: "pass - SetAsfDisableMaster", setter: func(s *AccountSet) { s.SetAsfDisableMaster() }, - expected: asfDisableMaster, + expected: AsfDisableMaster, }, { name: "pass - SetAsfAccountTxnID", setter: func(s *AccountSet) { s.SetAsfAccountTxnID() }, - expected: asfAccountTxnID, + expected: AsfAccountTxnID, }, { name: "pass - SetAsfNoFreeze", setter: func(s *AccountSet) { s.SetAsfNoFreeze() }, - expected: asfNoFreeze, + expected: AsfNoFreeze, }, { name: "pass - SetAsfGlobalFreeze", setter: func(s *AccountSet) { s.SetAsfGlobalFreeze() }, - expected: asfGlobalFreeze, + expected: AsfGlobalFreeze, }, { name: "pass - SetAsfDefaultRipple", setter: func(s *AccountSet) { s.SetAsfDefaultRipple() }, - expected: asfDefaultRipple, + expected: AsfDefaultRipple, }, { name: "pass - SetAsfDepositAuth", setter: func(s *AccountSet) { s.SetAsfDepositAuth() }, - expected: asfDepositAuth, + expected: AsfDepositAuth, }, { name: "pass - SetAsfAuthorizedNFTokenMinter", setter: func(s *AccountSet) { s.SetAsfAuthorizedNFTokenMinter() }, - expected: asfAuthorizedNFTokenMinter, + expected: AsfAuthorizedNFTokenMinter, }, { name: "pass - SetAsfDisallowIncomingNFTokenOffer", setter: func(s *AccountSet) { s.SetAsfDisallowIncomingNFTokenOffer() }, - expected: asfDisallowIncomingNFTokenOffer, + expected: AsfDisallowIncomingNFTokenOffer, }, { name: "pass - SetAsfDisallowIncomingCheck", setter: func(s *AccountSet) { s.SetAsfDisallowIncomingCheck() }, - expected: asfDisallowIncomingCheck, + expected: AsfDisallowIncomingCheck, }, { name: "pass - SetAsfDisallowIncomingPayChan", setter: func(s *AccountSet) { s.SetAsfDisallowIncomingPayChan() }, - expected: asfDisallowIncomingPayChan, + expected: AsfDisallowIncomingPayChan, }, { name: "pass - SetAsfDisallowIncomingTrustLine", setter: func(s *AccountSet) { s.SetAsfDisallowIncomingTrustLine() }, - expected: asfDisallowIncomingTrustLine, + expected: AsfDisallowIncomingTrustLine, }, { name: "pass - SetAsfAllowTrustLineClawback", setter: func(s *AccountSet) { s.SetAsfAllowTrustLineClawback() }, - expected: asfAllowTrustLineClawback, + expected: AsfAllowTrustLineClawback, }, { name: "pass - SetAsfAllowTrustLineLocking", setter: func(s *AccountSet) { s.SetAsfAllowTrustLineLocking() }, - expected: asfAllowTrustLineLocking, + expected: AsfAllowTrustLineLocking, }, } @@ -235,112 +235,112 @@ func TestAccountClearAsfFlags(t *testing.T) { setter: func(s *AccountSet) { s.ClearAsfRequireDest() }, - expected: asfRequireDest, + expected: AsfRequireDest, }, { name: "pass - ClearAsfRequireAuth", setter: func(s *AccountSet) { s.ClearAsfRequireAuth() }, - expected: asfRequireAuth, + expected: AsfRequireAuth, }, { name: "pass - ClearAsfDisallowXRP", setter: func(s *AccountSet) { s.ClearAsfDisallowXRP() }, - expected: asfDisallowXRP, + expected: AsfDisallowXRP, }, { name: "pass - ClearAsfDisableMaster", setter: func(s *AccountSet) { s.ClearAsfDisableMaster() }, - expected: asfDisableMaster, + expected: AsfDisableMaster, }, { name: "pass - ClearAsfAccountTxnID", setter: func(s *AccountSet) { s.ClearAsfAccountTxnID() }, - expected: asfAccountTxnID, + expected: AsfAccountTxnID, }, { - name: "pass - asfNoFreeze", + name: "pass - AsfNoFreeze", setter: func(s *AccountSet) { s.ClearAsfNoFreeze() }, - expected: asfNoFreeze, + expected: AsfNoFreeze, }, { - name: "pass - asfGlobalFreeze", + name: "pass - AsfGlobalFreeze", setter: func(s *AccountSet) { s.ClearAsfGlobalFreeze() }, - expected: asfGlobalFreeze, + expected: AsfGlobalFreeze, }, { name: "pass - ClearAsfDefaultRipple", setter: func(s *AccountSet) { s.ClearAsfDefaultRipple() }, - expected: asfDefaultRipple, + expected: AsfDefaultRipple, }, { name: "pass - ClearAsfDepositAuth", setter: func(s *AccountSet) { s.ClearAsfDepositAuth() }, - expected: asfDepositAuth, + expected: AsfDepositAuth, }, { name: "pass - ClearAsfAuthorizedNFTokenMinter", setter: func(s *AccountSet) { s.ClearAsfAuthorizedNFTokenMinter() }, - expected: asfAuthorizedNFTokenMinter, + expected: AsfAuthorizedNFTokenMinter, }, { name: "pass - ClearAsfDisallowIncomingNFTokenOffer", setter: func(s *AccountSet) { s.ClearAsfDisallowIncomingNFTokenOffer() }, - expected: asfDisallowIncomingNFTokenOffer, + expected: AsfDisallowIncomingNFTokenOffer, }, { name: "pass - ClearAsfDisallowIncomingCheck", setter: func(s *AccountSet) { s.ClearAsfDisallowIncomingCheck() }, - expected: asfDisallowIncomingCheck, + expected: AsfDisallowIncomingCheck, }, { name: "pass - ClearAsfDisallowIncomingPayChan", setter: func(s *AccountSet) { s.ClearAsfDisallowIncomingPayChan() }, - expected: asfDisallowIncomingPayChan, + expected: AsfDisallowIncomingPayChan, }, { name: "pass - ClearAsfDisallowIncomingTrustLine", setter: func(s *AccountSet) { s.ClearAsfDisallowIncomingTrustLine() }, - expected: asfDisallowIncomingTrustLine, + expected: AsfDisallowIncomingTrustLine, }, { name: "pass - ClearAsfAllowTrustLineClawback", setter: func(s *AccountSet) { s.ClearAsfAllowTrustLineClawback() }, - expected: asfAllowTrustLineClawback, + expected: AsfAllowTrustLineClawback, }, { name: "pass - ClearAsfAllowTrustLineLocking", setter: func(s *AccountSet) { s.ClearAsfAllowTrustLineLocking() }, - expected: asfAllowTrustLineLocking, + expected: AsfAllowTrustLineLocking, }, } @@ -491,12 +491,12 @@ func TestAccountSet_Flatten(t *testing.T) { SigningPubKey: "ghijk", TxnSignature: "A1B2C3D4E5F6", }, - ClearFlag: asfRequireDest, + ClearFlag: AsfRequireDest, Domain: types.Domain("A5B21758D2318FA2C"), EmailHash: types.EmailHash("1234567890abcdef"), MessageKey: types.MessageKey("messagekey"), NFTokenMinter: types.NFTokenMinter("nftokenminter"), - SetFlag: asfRequireAuth, + SetFlag: AsfRequireAuth, TransferRate: types.TransferRate(1000000001), TickSize: types.TickSize(5), WalletLocator: types.WalletLocator("walletLocator"), @@ -509,12 +509,12 @@ func TestAccountSet_Flatten(t *testing.T) { "Sequence": uint32(1234), "SigningPubKey": "ghijk", "TxnSignature": "A1B2C3D4E5F6", - "ClearFlag": asfRequireDest, + "ClearFlag": AsfRequireDest, "Domain": "A5B21758D2318FA2C", "EmailHash": "1234567890abcdef", "MessageKey": "messagekey", "NFTokenMinter": "nftokenminter", - "SetFlag": asfRequireAuth, + "SetFlag": AsfRequireAuth, "TransferRate": uint32(1000000001), "TickSize": uint8(5), "WalletLocator": "walletLocator", diff --git a/xrpl/transaction/amm_clawback.go b/xrpl/transaction/amm_clawback.go index f7249f79..066473e6 100644 --- a/xrpl/transaction/amm_clawback.go +++ b/xrpl/transaction/amm_clawback.go @@ -6,11 +6,11 @@ import ( ) const ( - // Claw back the specified amount of Asset, and a corresponding amount of Asset2 based on + // TfClawTwoAssets claws back the specified amount of Asset, and a corresponding amount of Asset2 based on // the AMM pool's asset proportion; both assets must be issued by the issuer in the Account // field. If this flag isn't enabled, the issuer claws back the specified amount of Asset, // while a corresponding proportion of Asset2 goes back to the Holder. - tfClawTwoAssets uint32 = 0x00000001 + TfClawTwoAssets uint32 = 0x00000001 ) // AMMClawback claws back tokens from a holder who has deposited issued tokens into an AMM pool. @@ -110,7 +110,7 @@ func (a *AMMClawback) Validate() (bool, error) { return true, nil } -// SetClawTwoAssets sets the tfClawTwoAssets flag to claw back both assets based on the AMM pool proportions. +// SetClawTwoAssets sets the TfClawTwoAssets flag to claw back both assets based on the AMM pool proportions. func (a *AMMClawback) SetClawTwoAssets() { - a.Flags |= tfClawTwoAssets + a.Flags |= TfClawTwoAssets } diff --git a/xrpl/transaction/amm_common.go b/xrpl/transaction/amm_common.go index cd960322..5aba3e82 100644 --- a/xrpl/transaction/amm_common.go +++ b/xrpl/transaction/amm_common.go @@ -2,16 +2,16 @@ package transaction // Common flags for AMM transactions (Deposit and Withdraw). const ( - // Perform a double-asset withdrawal/deposit and receive the specified amount of LP Tokens. - tfLPToken uint32 = 65536 - // Perform a single-asset withdrawal/deposit with a specified amount of the asset to deposit. - tfSingleAsset uint32 = 524288 - // Perform a double-asset withdrawal/deposit with specified amounts of both assets. - tfTwoAsset uint32 = 1048576 - // Perform a single-asset withdrawal/deposit and receive the specified amount of LP Tokens. - tfOneAssetLPToken uint32 = 2097152 - // Perform a single-asset withdrawal/deposit with a specified effective price. - tfLimitLPToken uint32 = 4194304 + // TfLPToken performs a double-asset withdrawal/deposit and receive the specified amount of LP Tokens. + TfLPToken uint32 = 65536 + // TfSingleAsset performs a single-asset withdrawal/deposit with a specified amount of the asset to deposit. + TfSingleAsset uint32 = 524288 + // TfTwoAsset performs a double-asset withdrawal/deposit with specified amounts of both assets. + TfTwoAsset uint32 = 1048576 + // TfOneAssetLPToken performs a single-asset withdrawal/deposit and receive the specified amount of LP Tokens. + TfOneAssetLPToken uint32 = 2097152 + // TfLimitLPToken performs a single-asset withdrawal/deposit with a specified effective price. + TfLimitLPToken uint32 = 4194304 // AmmMaxTradingFee is the maximum trading fee; a value of 1000 corresponds to a 1% fee. AmmMaxTradingFee = 1000 diff --git a/xrpl/transaction/amm_deposit.go b/xrpl/transaction/amm_deposit.go index 95d3554a..437b7ddc 100644 --- a/xrpl/transaction/amm_deposit.go +++ b/xrpl/transaction/amm_deposit.go @@ -58,38 +58,38 @@ type AMMDeposit struct { // You must specify exactly one of these flags, plus any global flags. const ( - // Perform a special double-asset deposit to an AMM with an empty pool. - tfTwoAssetIfEmpty uint32 = 8388608 + // TfTwoAssetIfEmpty performs a special double-asset deposit to an AMM with an empty pool. + TfTwoAssetIfEmpty uint32 = 8388608 ) // SetLPTokentFlag performs a double-asset deposit and receives the specified amount of LP Tokens. func (a *AMMDeposit) SetLPTokentFlag() { - a.Flags |= tfLPToken + a.Flags |= TfLPToken } // SetSingleAssetFlag performs a single-asset deposit with a specified asset amount. func (a *AMMDeposit) SetSingleAssetFlag() { - a.Flags |= tfSingleAsset + a.Flags |= TfSingleAsset } // SetTwoAssetFlag performs a double-asset deposit with specified amounts of both assets. func (a *AMMDeposit) SetTwoAssetFlag() { - a.Flags |= tfTwoAsset + a.Flags |= TfTwoAsset } // SetOneAssetLPTokenFlag performs a single-asset deposit and receives the specified amount of LP Tokens. func (a *AMMDeposit) SetOneAssetLPTokenFlag() { - a.Flags |= tfOneAssetLPToken + a.Flags |= TfOneAssetLPToken } // SetLimitLPTokenFlag performs a single-asset deposit with a specified effective price. func (a *AMMDeposit) SetLimitLPTokenFlag() { - a.Flags |= tfLimitLPToken + a.Flags |= TfLimitLPToken } // SetTwoAssetIfEmptyFlag performs a special double-asset deposit into an empty AMM pool. func (a *AMMDeposit) SetTwoAssetIfEmptyFlag() { - a.Flags |= tfTwoAssetIfEmpty + a.Flags |= TfTwoAssetIfEmpty } // TxType implements the TxType method for the AMMDeposit struct. diff --git a/xrpl/transaction/amm_deposit_test.go b/xrpl/transaction/amm_deposit_test.go index d0f05afb..0997da5e 100644 --- a/xrpl/transaction/amm_deposit_test.go +++ b/xrpl/transaction/amm_deposit_test.go @@ -98,42 +98,42 @@ func TestAMMDeposit_Flags(t *testing.T) { setter: func(a *AMMDeposit) { a.SetLPTokentFlag() }, - expected: tfLPToken, + expected: TfLPToken, }, { name: "pass - SetSingleAssetFlag", setter: func(a *AMMDeposit) { a.SetSingleAssetFlag() }, - expected: tfSingleAsset, + expected: TfSingleAsset, }, { name: "pass - SetTwoAssetFlag", setter: func(a *AMMDeposit) { a.SetTwoAssetFlag() }, - expected: tfTwoAsset, + expected: TfTwoAsset, }, { name: "pass - SetOneAssetLPTokenFlag", setter: func(a *AMMDeposit) { a.SetOneAssetLPTokenFlag() }, - expected: tfOneAssetLPToken, + expected: TfOneAssetLPToken, }, { name: "pass - SetLimitLPTokenFlag", setter: func(a *AMMDeposit) { a.SetLimitLPTokenFlag() }, - expected: tfLimitLPToken, + expected: TfLimitLPToken, }, { name: "pass - SetTwoAssetIfEmptyFlag", setter: func(a *AMMDeposit) { a.SetTwoAssetIfEmptyFlag() }, - expected: tfTwoAssetIfEmpty, + expected: TfTwoAssetIfEmpty, }, } diff --git a/xrpl/transaction/amm_withdraw.go b/xrpl/transaction/amm_withdraw.go index 216168c9..59096e6d 100644 --- a/xrpl/transaction/amm_withdraw.go +++ b/xrpl/transaction/amm_withdraw.go @@ -54,45 +54,45 @@ type AMMWithdraw struct { // **************************** const ( - // Perform a double-asset withdrawal returning all your LP Tokens. - tfWithdrawAll uint32 = 131072 - // Perform a single-asset withdrawal returning all of your LP Tokens. - tfOneAssetWithdrawAll uint32 = 262144 + // TfWithdrawAll performs a double-asset withdrawal returning all your LP Tokens. + TfWithdrawAll uint32 = 131072 + // TfOneAssetWithdrawAll performs a single-asset withdrawal returning all of your LP Tokens. + TfOneAssetWithdrawAll uint32 = 262144 ) // SetLPTokentFlag performs a double-asset withdrawal and receives the specified amount of LP Tokens. func (a *AMMWithdraw) SetLPTokentFlag() { - a.Flags |= tfLPToken + a.Flags |= TfLPToken } // SetWithdrawAllFlag performs a double-asset withdrawal returning all your LP Tokens. func (a *AMMWithdraw) SetWithdrawAllFlag() { - a.Flags |= tfWithdrawAll + a.Flags |= TfWithdrawAll } // SetOneAssetWithdrawAllFlag performs a single-asset withdrawal returning all of your LP Tokens. func (a *AMMWithdraw) SetOneAssetWithdrawAllFlag() { - a.Flags |= tfOneAssetWithdrawAll + a.Flags |= TfOneAssetWithdrawAll } // SetSingleAssetFlag performs a single-asset withdrawal with a specified amount of the asset to withdraw. func (a *AMMWithdraw) SetSingleAssetFlag() { - a.Flags |= tfSingleAsset + a.Flags |= TfSingleAsset } // SetTwoAssetFlag performs a double-asset withdrawal with specified amounts of both assets. func (a *AMMWithdraw) SetTwoAssetFlag() { - a.Flags |= tfTwoAsset + a.Flags |= TfTwoAsset } // SetOneAssetLPTokenFlag performs a single-asset withdrawal and receives the specified amount of LP Tokens. func (a *AMMWithdraw) SetOneAssetLPTokenFlag() { - a.Flags |= tfOneAssetLPToken + a.Flags |= TfOneAssetLPToken } // SetLimitLPTokenFlag performs a single-asset withdrawal with a specified effective price. func (a *AMMWithdraw) SetLimitLPTokenFlag() { - a.Flags |= tfLimitLPToken + a.Flags |= TfLimitLPToken } // TxType returns the type of the transaction (AMMWithdraw). diff --git a/xrpl/transaction/amm_withdraw_test.go b/xrpl/transaction/amm_withdraw_test.go index 4c60cc2a..8fe363cc 100644 --- a/xrpl/transaction/amm_withdraw_test.go +++ b/xrpl/transaction/amm_withdraw_test.go @@ -25,49 +25,49 @@ func TestAMMWithdraw_Flags(t *testing.T) { setter: func(a *AMMWithdraw) { a.SetLPTokentFlag() }, - expected: tfLPToken, + expected: TfLPToken, }, { name: "pass - SetWithdrawAllFlag", setter: func(a *AMMWithdraw) { a.SetWithdrawAllFlag() }, - expected: tfWithdrawAll, + expected: TfWithdrawAll, }, { name: "pass - SetOneAssetWithdrawAllFlag", setter: func(a *AMMWithdraw) { a.SetOneAssetWithdrawAllFlag() }, - expected: tfOneAssetWithdrawAll, + expected: TfOneAssetWithdrawAll, }, { name: "pass - SetSingleAssetFlag", setter: func(a *AMMWithdraw) { a.SetSingleAssetFlag() }, - expected: tfSingleAsset, + expected: TfSingleAsset, }, { name: "pass - SetTwoAssetFlag", setter: func(a *AMMWithdraw) { a.SetTwoAssetFlag() }, - expected: tfTwoAsset, + expected: TfTwoAsset, }, { name: "pass - SetOneAssetLPTokenFlag", setter: func(a *AMMWithdraw) { a.SetOneAssetLPTokenFlag() }, - expected: tfOneAssetLPToken, + expected: TfOneAssetLPToken, }, { name: "pass - SetLimitLPTokenFlag", setter: func(a *AMMWithdraw) { a.SetLimitLPTokenFlag() }, - expected: tfLimitLPToken, + expected: TfLimitLPToken, }, } diff --git a/xrpl/transaction/batch.go b/xrpl/transaction/batch.go index c5e39dda..55849392 100644 --- a/xrpl/transaction/batch.go +++ b/xrpl/transaction/batch.go @@ -5,11 +5,14 @@ import ( ) const ( - // Batch transaction flags - tfAllOrNothing uint32 = 0x00010000 - tfOnlyOne uint32 = 0x00020000 - tfUntilFailure uint32 = 0x00040000 - tfIndependent uint32 = 0x00080000 + // TfAllOrNothing if this flag is set, all transactions in the batch must succeed for any of them to be applied. + TfAllOrNothing uint32 = 0x00010000 + // TfOnlyOne if this flag is set, at most one transaction in the batch will be applied. + TfOnlyOne uint32 = 0x00020000 + // TfUntilFailure if this flag is set, transactions in the batch are applied in order until one fails. + TfUntilFailure uint32 = 0x00040000 + // TfIndependent if this flag is set, each transaction in the batch is applied independently. + TfIndependent uint32 = 0x00080000 ) // Batch represents a Batch transaction that can execute multiple transactions atomically. @@ -57,36 +60,36 @@ func (*Batch) TxType() TxType { // Batch Flags // ********************************** -// SetAllOrNothingFlag sets the AllOrNothing flag. +// SetAllOrNothingFlag sets the TfAllOrNothing flag. // // AllOrNothing: Execute all transactions in the batch or none at all. // If any transaction fails, the entire batch fails. func (b *Batch) SetAllOrNothingFlag() { - b.Flags |= tfAllOrNothing + b.Flags |= TfAllOrNothing } -// SetOnlyOneFlag sets the OnlyOne flag. +// SetOnlyOneFlag sets the TfOnlyOne flag. // // OnlyOne: Execute only the first transaction that succeeds. // Stop execution after the first successful transaction. func (b *Batch) SetOnlyOneFlag() { - b.Flags |= tfOnlyOne + b.Flags |= TfOnlyOne } -// SetUntilFailureFlag sets the UntilFailure flag. +// SetUntilFailureFlag sets the TfUntilFailure flag. // // UntilFailure: Execute transactions until one fails. // Stop execution at the first failed transaction. func (b *Batch) SetUntilFailureFlag() { - b.Flags |= tfUntilFailure + b.Flags |= TfUntilFailure } -// SetIndependentFlag sets the Independent flag. +// SetIndependentFlag sets the TfIndependent flag. // // Independent: Execute all transactions independently. // The failure of one transaction does not affect others. func (b *Batch) SetIndependentFlag() { - b.Flags |= tfIndependent + b.Flags |= TfIndependent } // Flatten returns the flattened map of the Batch transaction. diff --git a/xrpl/transaction/batch_test.go b/xrpl/transaction/batch_test.go index 4b54eea5..8616d519 100644 --- a/xrpl/transaction/batch_test.go +++ b/xrpl/transaction/batch_test.go @@ -101,7 +101,7 @@ func TestBatchFlatten(t *testing.T) { Account: "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2", TransactionType: BatchTx, Fee: types.XRPCurrencyAmount(12), - Flags: tfAllOrNothing, + Flags: TfAllOrNothing, }, RawTransactions: []types.RawTransaction{ { @@ -135,7 +135,7 @@ func TestBatchFlatten(t *testing.T) { Account: "rUserBSM7T3b6nHX3Jjua62wgX9unH8s9b", TransactionType: BatchTx, Fee: types.XRPCurrencyAmount(40), - Flags: tfAllOrNothing, + Flags: TfAllOrNothing, Sequence: 3, SigningPubKey: "022D40673B44C82DEE1DDB8B9BB53DCCE4F97B27404DB850F068DD91D685E337EA", TxnSignature: "3045022100EC5D367FAE2B461679AD446FBBE7BA260506579AF4ED5EFC3EC25F4DD1885B38022018C2327DB281743B12553C7A6DC0E45B07D3FC6983F261D7BCB474D89A0EC5B8", @@ -192,7 +192,7 @@ func TestBatchFlatten(t *testing.T) { Account: "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2", TransactionType: BatchTx, Fee: types.XRPCurrencyAmount(12), - Flags: tfAllOrNothing, + Flags: TfAllOrNothing, }, RawTransactions: []types.RawTransaction{ { @@ -263,7 +263,7 @@ func TestBatch_Validate(t *testing.T) { Account: "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2", TransactionType: BatchTx, Fee: types.XRPCurrencyAmount(12), - Flags: tfAllOrNothing, + Flags: TfAllOrNothing, }, RawTransactions: []types.RawTransaction{ { @@ -280,7 +280,7 @@ func TestBatch_Validate(t *testing.T) { Account: "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2", TransactionType: BatchTx, Fee: types.XRPCurrencyAmount(12), - Flags: tfIndependent, + Flags: TfIndependent, }, RawTransactions: []types.RawTransaction{ { @@ -421,28 +421,28 @@ func TestBatch_Flags(t *testing.T) { setter: func(b *Batch) { b.SetAllOrNothingFlag() }, - expected: tfAllOrNothing, + expected: TfAllOrNothing, }, { name: "pass - SetOnlyOneFlag", setter: func(b *Batch) { b.SetOnlyOneFlag() }, - expected: tfOnlyOne, + expected: TfOnlyOne, }, { name: "pass - SetUntilFailureFlag", setter: func(b *Batch) { b.SetUntilFailureFlag() }, - expected: tfUntilFailure, + expected: TfUntilFailure, }, { name: "pass - SetIndependentFlag", setter: func(b *Batch) { b.SetIndependentFlag() }, - expected: tfIndependent, + expected: TfIndependent, }, { name: "pass - SetAllOrNothingFlag and SetOnlyOneFlag", @@ -450,7 +450,7 @@ func TestBatch_Flags(t *testing.T) { b.SetAllOrNothingFlag() b.SetOnlyOneFlag() }, - expected: tfAllOrNothing | tfOnlyOne, + expected: TfAllOrNothing | TfOnlyOne, }, { name: "pass - all flags", @@ -460,7 +460,7 @@ func TestBatch_Flags(t *testing.T) { b.SetUntilFailureFlag() b.SetIndependentFlag() }, - expected: tfAllOrNothing | tfOnlyOne | tfUntilFailure | tfIndependent, + expected: TfAllOrNothing | TfOnlyOne | TfUntilFailure | TfIndependent, }, } diff --git a/xrpl/transaction/errors.go b/xrpl/transaction/errors.go index 6bf057e5..0bb48f58 100644 --- a/xrpl/transaction/errors.go +++ b/xrpl/transaction/errors.go @@ -133,8 +133,8 @@ var ( // payment - // ErrPartialPaymentFlagRequired is returned when the tfPartialPayment flag is required but not set. - ErrPartialPaymentFlagRequired = errors.New("tfPartialPayment flag required with DeliverMin") + // ErrPartialPaymentFlagRequired is returned when the TfPartialPayment flag is required but not set. + ErrPartialPaymentFlagRequired = errors.New("flag TfPartialPayment required with DeliverMin") // ErrInvalidExpiration indicates the expiration time must be either later than the current time plus the SettleDelay of the channel, or the existing Expiration of the channel. ErrInvalidExpiration = errors.New("expiration time must be either later than the current time plus the SettleDelay of the channel, or the existing Expiration of the channel") @@ -146,8 +146,8 @@ var ( // offer - // ErrTfHybridCannotBeSetWithoutDomainID is returned if a OfferCreate has tfHybrid enabled and no DomainID set. - ErrTfHybridCannotBeSetWithoutDomainID = errors.New("tfHybrid must have a valid DomainID") + // ErrTfHybridCannotBeSetWithoutDomainID is returned if a OfferCreate has TfHybrid enabled and no DomainID set. + ErrTfHybridCannotBeSetWithoutDomainID = errors.New("flag TfHybrid must have a valid DomainID") // nft @@ -155,8 +155,8 @@ var ( ErrInvalidTransferFee = errors.New("transferFee must be between 0 and 50000 inclusive") // ErrIssuerAccountConflict is returned when the issuer is the same as the account. ErrIssuerAccountConflict = errors.New("issuer cannot be the same as the account") - // ErrTransferFeeRequiresTransferableFlag is returned when the transferFee is set without the tfTransferable flag. - ErrTransferFeeRequiresTransferableFlag = errors.New("transferFee can only be set if the tfTransferable flag is enabled") + // ErrTransferFeeRequiresTransferableFlag is returned when the transferFee is set without the TfTransferable flag. + ErrTransferFeeRequiresTransferableFlag = errors.New("transferFee can only be set if the TfTransferable flag is enabled") // ErrAmountRequiredWithExpirationOrDestination is returned when Expiration or Destination is set without Amount. ErrAmountRequiredWithExpirationOrDestination = errors.New("amount is required when Expiration or Destination is present") @@ -180,14 +180,14 @@ var ( // mpt - // ErrMPTokenIssuanceSetFlags is returned when both tfMPTLock and tfMPTUnlock flags are enabled simultaneously. - ErrMPTokenIssuanceSetFlags = errors.New("mptoken issuance set: tfMPTLock and tfMPTUnlock flags cannot both be enabled") + // ErrMPTokenIssuanceSetFlags is returned when both TfMPTLock and TfMPTUnlock flags are enabled simultaneously. + ErrMPTokenIssuanceSetFlags = errors.New("mptoken issuance set: TfMPTLock and TfMPTUnlock flags cannot both be enabled") // ErrInvalidMPTokenIssuanceID is returned when the MPTokenIssuanceID is empty or invalid. ErrInvalidMPTokenIssuanceID = errors.New("mptoken issuance destroy: invalid MPTokenIssuanceID") - // ErrTransferFeeRequiresCanTransfer is returned when TransferFee is set without enabling tfMPTCanTransfer flag. - ErrTransferFeeRequiresCanTransfer = errors.New("mptoken issuance create: TransferFee cannot be provided without enabling tfMPTCanTransfer flag") + // ErrTransferFeeRequiresCanTransfer is returned when TransferFee is set without enabling TfMPTCanTransfer flag. + ErrTransferFeeRequiresCanTransfer = errors.New("mptoken issuance create: TransferFee cannot be provided without enabling TfMPTCanTransfer flag") // ErrInvalidMPTokenMetadata is returned when MPTokenMetadata is not a valid hex string or exceeds size limit. ErrInvalidMPTokenMetadata = errors.New("mptoken issuance create: MPTokenMetadata must be a valid hex string and at most 1024 bytes") @@ -307,7 +307,7 @@ var ( // account // ErrAccountSetInvalidSetFlag is returned when SetFlag is outside the valid range (1 to 16). - ErrAccountSetInvalidSetFlag = errors.New("account set: SetFlag must be an integer between asfRequireDest (1) and asfAllowTrustLineClawback (16)") + ErrAccountSetInvalidSetFlag = errors.New("account set: SetFlag must be an integer between AsfRequireDest (1) and AsfAllowTrustLineClawback (16)") // ErrAccountSetInvalidTickSize is returned when TickSize is outside the valid range (0 to 15 inclusive). ErrAccountSetInvalidTickSize = errors.New("account set: TickSize must be an integer between 0 and 15 inclusive") @@ -355,8 +355,8 @@ var ( ErrLoanManageLoanIDRequired = errors.New("loanManage: LoanID is required") // ErrLoanManageLoanIDInvalid is returned when LoanID is not a valid 64-character hexadecimal string. ErrLoanManageLoanIDInvalid = errors.New("loanManage: LoanID must be 64 characters hexadecimal string") - // ErrLoanManageFlagsConflict is returned when tfLoanImpair and tfLoanUnimpair flags are both set. - ErrLoanManageFlagsConflict = errors.New("loanManage: tfLoanImpair and tfLoanUnimpair cannot both be present") + // ErrLoanManageFlagsConflict is returned when TfLoanImpair and TfLoanUnimpair flags are both set. + ErrLoanManageFlagsConflict = errors.New("loanManage: TfLoanImpair and TfLoanUnimpair cannot both be present") // ErrLoanPayLoanIDRequired is returned when LoanID is not set on a LoanPay transaction. ErrLoanPayLoanIDRequired = errors.New("loanPay: LoanID is required") diff --git a/xrpl/transaction/loan_manage.go b/xrpl/transaction/loan_manage.go index f7f47c17..7e439d68 100644 --- a/xrpl/transaction/loan_manage.go +++ b/xrpl/transaction/loan_manage.go @@ -2,12 +2,12 @@ package transaction // LoanManageFlags represents flags for LoanManage transactions. const ( - // tfLoanDefault indicates that the Loan should be defaulted. - tfLoanDefault uint32 = 0x00010000 - // tfLoanImpair indicates that the Loan should be impaired. - tfLoanImpair uint32 = 0x00020000 - // tfLoanUnimpair indicates that the Loan should be un-impaired. - tfLoanUnimpair uint32 = 0x00040000 + // TfLoanDefault indicates that the Loan should be defaulted. + TfLoanDefault uint32 = 0x00010000 + // TfLoanImpair indicates that the Loan should be impaired. + TfLoanImpair uint32 = 0x00020000 + // TfLoanUnimpair indicates that the Loan should be un-impaired. + TfLoanUnimpair uint32 = 0x00040000 ) // LoanManage modifies an existing Loan object. @@ -33,19 +33,19 @@ func (tx *LoanManage) TxType() TxType { return LoanManageTx } -// SetLoanDefaultFlag sets the tfLoanDefault flag, indicating that the Loan should be defaulted. +// SetLoanDefaultFlag sets the TfLoanDefault flag, indicating that the Loan should be defaulted. func (tx *LoanManage) SetLoanDefaultFlag() { - tx.Flags |= tfLoanDefault + tx.Flags |= TfLoanDefault } -// SetLoanImpairFlag sets the tfLoanImpair flag, indicating that the Loan should be impaired. +// SetLoanImpairFlag sets the TfLoanImpair flag, indicating that the Loan should be impaired. func (tx *LoanManage) SetLoanImpairFlag() { - tx.Flags |= tfLoanImpair + tx.Flags |= TfLoanImpair } -// SetLoanUnimpairFlag sets the tfLoanUnimpair flag, indicating that the Loan should be un-impaired. +// SetLoanUnimpairFlag sets the TfLoanUnimpair flag, indicating that the Loan should be un-impaired. func (tx *LoanManage) SetLoanUnimpairFlag() { - tx.Flags |= tfLoanUnimpair + tx.Flags |= TfLoanUnimpair } // Flatten returns a map representation of the LoanManage transaction for JSON-RPC submission. @@ -77,8 +77,8 @@ func (tx *LoanManage) Validate() (bool, error) { return false, ErrLoanManageLoanIDInvalid } - // Check that tfLoanImpair and tfLoanUnimpair are not both set - if (tx.Flags&tfLoanImpair) != 0 && (tx.Flags&tfLoanUnimpair) != 0 { + // Check that TfLoanImpair and TfLoanUnimpair are not both set + if (tx.Flags&TfLoanImpair) != 0 && (tx.Flags&TfLoanUnimpair) != 0 { return false, ErrLoanManageFlagsConflict } diff --git a/xrpl/transaction/loan_manage_test.go b/xrpl/transaction/loan_manage_test.go index 83e9fe9d..d59ebb0b 100644 --- a/xrpl/transaction/loan_manage_test.go +++ b/xrpl/transaction/loan_manage_test.go @@ -33,7 +33,7 @@ func TestLoanManage_Flatten(t *testing.T) { Fee: 1000000, Sequence: 1, LastLedgerSequence: 3000000, - Flags: uint32(tfLoanDefault), + Flags: uint32(TfLoanDefault), }, LoanID: "B91CD2033E73E0DD17AF043FBD458CE7D996850A83DCED23FB122A3BFAA7F430", }, @@ -43,7 +43,7 @@ func TestLoanManage_Flatten(t *testing.T) { "Fee": "1000000", "Sequence": uint32(1), "LastLedgerSequence": uint32(3000000), - "Flags": uint32(tfLoanDefault), + "Flags": uint32(TfLoanDefault), "LoanID": "B91CD2033E73E0DD17AF043FBD458CE7D996850A83DCED23FB122A3BFAA7F430", }, }, @@ -94,12 +94,12 @@ func TestLoanManage_Validate(t *testing.T) { expected: ErrLoanManageLoanIDInvalid, }, { - name: "fail - tfLoanImpair and tfLoanUnimpair both set", + name: "fail - TfLoanImpair and TfLoanUnimpair both set", tx: &LoanManage{ BaseTx: BaseTx{ Account: "rHLLL3Z7uBLK49yZcMaj8FAP7DU12Nw5A5", TransactionType: LoanManageTx, - Flags: uint32(tfLoanImpair | tfLoanUnimpair), + Flags: uint32(TfLoanImpair | TfLoanUnimpair), }, LoanID: "B91CD2033E73E0DD17AF043FBD458CE7D996850A83DCED23FB122A3BFAA7F430", }, @@ -111,7 +111,7 @@ func TestLoanManage_Validate(t *testing.T) { BaseTx: BaseTx{ Account: "rHLLL3Z7uBLK49yZcMaj8FAP7DU12Nw5A5", TransactionType: LoanManageTx, - Flags: uint32(tfLoanDefault), + Flags: uint32(TfLoanDefault), }, LoanID: "B91CD2033E73E0DD17AF043FBD458CE7D996850A83DCED23FB122A3BFAA7F430", }, @@ -143,21 +143,21 @@ func TestLoanManage_Flags(t *testing.T) { setter: func(lm *LoanManage) { lm.SetLoanDefaultFlag() }, - expected: tfLoanDefault, + expected: TfLoanDefault, }, { name: "pass - SetLoanImpairFlag", setter: func(lm *LoanManage) { lm.SetLoanImpairFlag() }, - expected: tfLoanImpair, + expected: TfLoanImpair, }, { name: "pass - SetLoanUnimpairFlag", setter: func(lm *LoanManage) { lm.SetLoanUnimpairFlag() }, - expected: tfLoanUnimpair, + expected: TfLoanUnimpair, }, { name: "pass - SetLoanDefaultFlag and SetLoanImpairFlag", @@ -165,7 +165,7 @@ func TestLoanManage_Flags(t *testing.T) { lm.SetLoanDefaultFlag() lm.SetLoanImpairFlag() }, - expected: tfLoanDefault | tfLoanImpair, + expected: TfLoanDefault | TfLoanImpair, }, { name: "pass - SetLoanDefaultFlag and SetLoanUnimpairFlag", @@ -173,7 +173,7 @@ func TestLoanManage_Flags(t *testing.T) { lm.SetLoanDefaultFlag() lm.SetLoanUnimpairFlag() }, - expected: tfLoanDefault | tfLoanUnimpair, + expected: TfLoanDefault | TfLoanUnimpair, }, } diff --git a/xrpl/transaction/loan_set.go b/xrpl/transaction/loan_set.go index e501037d..0290cf47 100644 --- a/xrpl/transaction/loan_set.go +++ b/xrpl/transaction/loan_set.go @@ -25,8 +25,8 @@ const ( // LoanSetFlags represents flags for LoanSet transactions. const ( - // tfLoanOverpayment indicates that the loan supports over payments. - tfLoanOverpayment uint32 = 0x00010000 + // TfLoanOverpayment indicates that the loan supports over payments. + TfLoanOverpayment uint32 = 0x00010000 ) // CounterpartySignature represents the signature of the counterparty over the transaction. @@ -115,9 +115,9 @@ func (tx *LoanSet) TxType() TxType { return LoanSetTx } -// SetLoanOverpaymentFlag sets the tfLoanOverpayment flag, indicating that the loan supports over payments. +// SetLoanOverpaymentFlag sets the TfLoanOverpayment flag, indicating that the loan supports over payments. func (tx *LoanSet) SetLoanOverpaymentFlag() { - tx.Flags |= tfLoanOverpayment + tx.Flags |= TfLoanOverpayment } // Flatten returns a map representation of the LoanSet transaction for JSON-RPC submission. diff --git a/xrpl/transaction/loan_set_test.go b/xrpl/transaction/loan_set_test.go index 49952e15..4c6381aa 100644 --- a/xrpl/transaction/loan_set_test.go +++ b/xrpl/transaction/loan_set_test.go @@ -205,7 +205,7 @@ func TestLoanSet_Flags(t *testing.T) { setter: func(ls *LoanSet) { ls.SetLoanOverpaymentFlag() }, - expected: tfLoanOverpayment, + expected: TfLoanOverpayment, }, } diff --git a/xrpl/transaction/mptoken_authorize.go b/xrpl/transaction/mptoken_authorize.go index 831ccd81..f9ad6f35 100644 --- a/xrpl/transaction/mptoken_authorize.go +++ b/xrpl/transaction/mptoken_authorize.go @@ -6,13 +6,13 @@ import ( ) const ( - // If set and transaction is submitted by a holder, it indicates that the holder no + // TfMPTUnauthorize if set and transaction is submitted by a holder, it indicates that the holder no // longer wants to hold the MPToken, which will be deleted as a result. If the the holder's // MPToken has non-zero balance while trying to set this flag, the transaction will fail. On // the other hand, if set and transaction is submitted by an issuer, it would mean that the // issuer wants to unauthorize the holder (only applicable for allow-listing), - // which would unset the lsfMPTAuthorized flag on the MPToken. - tfMPTUnauthorize uint32 = 1 + // which would unset the LsfMPTAuthorized flag on the MPToken. + TfMPTUnauthorize uint32 = 1 ) // MPTokenAuthorize transaction is used to globally lock/unlock a MPTokenIssuance, @@ -28,7 +28,7 @@ type MPTokenAuthorize struct { // SetMPTUnauthorizeFlag toggles the unauthorize flag on the transaction to indicate that the holder no longer wants to hold the token or that the issuer wants to unauthorize a holder. func (m *MPTokenAuthorize) SetMPTUnauthorizeFlag() { - m.Flags |= tfMPTUnauthorize + m.Flags |= TfMPTUnauthorize } // TxType returns the type of the transaction (MPTokenAuthorize). diff --git a/xrpl/transaction/mptoken_issuance_create.go b/xrpl/transaction/mptoken_issuance_create.go index e4ab54d5..3210e795 100644 --- a/xrpl/transaction/mptoken_issuance_create.go +++ b/xrpl/transaction/mptoken_issuance_create.go @@ -2,27 +2,25 @@ package transaction import ( "github.com/Peersyst/xrpl-go/pkg/typecheck" + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( - // If set, indicates that the MPT can be locked both individually and globally. + // TfMPTCanLock if set, indicates that the MPT can be locked both individually and globally. // If not set, the MPT cannot be locked in any way. - tfMPTCanLock uint32 = 0x00000002 - // If set, indicates that individual holders must be authorized. + TfMPTCanLock uint32 = 0x00000002 + // TfMPTRequireAuth if set, indicates that individual holders must be authorized. // This enables issuers to limit who can hold their assets. - tfMPTRequireAuth uint32 = 0x00000004 - // If set, indicates that individual holders can place their balances into an escrow. - tfMPTCanEscrow uint32 = 0x00000008 - // If set, indicates that individual holders can trade their balances - // using the XRP Ledger DEX or AMM. - tfMPTCanTrade uint32 = 0x00000010 - // If set, indicates that tokens may be transferred to other accounts - // that are not the issuer. - tfMPTCanTransfer uint32 = 0x00000020 - // If set, indicates that the issuer may use the Clawback transaction - // to clawback value from individual holders. - tfMPTCanClawback uint32 = 0x00000040 + TfMPTRequireAuth uint32 = 0x00000004 + // TfMPTCanEscrow if set, indicates that individual holders can place their balances into an escrow. + TfMPTCanEscrow uint32 = 0x00000008 + // TfMPTCanTrade if set, indicates that individual holders can trade their balances using the XRP Ledger DEX or AMM. + TfMPTCanTrade uint32 = 0x00000010 + // TfMPTCanTransfer if set, indicates that tokens may be transferred to other accounts that are not the issuer. + TfMPTCanTransfer uint32 = 0x00000020 + // TfMPTCanClawback if set, indicates that the issuer may use the Clawback transaction to claw back value from individual holders. + TfMPTCanClawback uint32 = 0x00000040 ) // MPTokenIssuanceCreateMetadata represents the resulting metadata of a succeeded MPTokenIssuanceCreate transaction. @@ -62,7 +60,7 @@ type MPTokenIssuanceCreate struct { // Specifies the fee to charged by the issuer for secondary sales of the Token, // if such sales are allowed. Valid values for this field are between 0 and 50,000 inclusive, // allowing transfer rates of between 0.000% and 50.000% in increments of 0.001. - // The field must NOT be present if the `tfMPTCanTransfer` flag is not set. + // The field must NOT be present if the `TfMPTCanTransfer` flag is not set. TransferFee *uint16 `json:",omitempty"` // Specifies the maximum asset amount of this token that should ever be issued. // It is a non-negative integer string that can store a range of up to 63 bits. If not set, the max @@ -108,34 +106,34 @@ func (m *MPTokenIssuanceCreate) Flatten() FlatTransaction { return flattened } -// SetMPTCanLockFlag sets the tfMPTCanLock flag to allow the MPT to be locked both individually and globally. +// SetMPTCanLockFlag sets the TfMPTCanLock flag to allow the MPT to be locked both individually and globally. func (m *MPTokenIssuanceCreate) SetMPTCanLockFlag() { - m.Flags |= tfMPTCanLock + m.Flags |= TfMPTCanLock } -// SetMPTRequireAuthFlag sets the tfMPTRequireAuth flag to require individual holders to be authorized. +// SetMPTRequireAuthFlag sets the TfMPTRequireAuth flag to require individual holders to be authorized. func (m *MPTokenIssuanceCreate) SetMPTRequireAuthFlag() { - m.Flags |= tfMPTRequireAuth + m.Flags |= TfMPTRequireAuth } -// SetMPTCanEscrowFlag sets the tfMPTCanEscrow flag to allow individual holders to place their balances into an escrow. +// SetMPTCanEscrowFlag sets the TfMPTCanEscrow flag to allow individual holders to place their balances into an escrow. func (m *MPTokenIssuanceCreate) SetMPTCanEscrowFlag() { - m.Flags |= tfMPTCanEscrow + m.Flags |= TfMPTCanEscrow } -// SetMPTCanTradeFlag sets the tfMPTCanTrade flag to allow individual holders to trade their balances via DEX or AMM. +// SetMPTCanTradeFlag sets the TfMPTCanTrade flag to allow individual holders to trade their balances via DEX or AMM. func (m *MPTokenIssuanceCreate) SetMPTCanTradeFlag() { - m.Flags |= tfMPTCanTrade + m.Flags |= TfMPTCanTrade } -// SetMPTCanTransferFlag sets the tfMPTCanTransfer flag to allow tokens to be transferred to non-issuer accounts. +// SetMPTCanTransferFlag sets the TfMPTCanTransfer flag to allow tokens to be transferred to non-issuer accounts. func (m *MPTokenIssuanceCreate) SetMPTCanTransferFlag() { - m.Flags |= tfMPTCanTransfer + m.Flags |= TfMPTCanTransfer } -// SetMPTCanClawbackFlag sets the tfMPTCanClawback flag to allow the issuer to claw back tokens from individual holders. +// SetMPTCanClawbackFlag sets the TfMPTCanClawback flag to allow the issuer to claw back tokens from individual holders. func (m *MPTokenIssuanceCreate) SetMPTCanClawbackFlag() { - m.Flags |= tfMPTCanClawback + m.Flags |= TfMPTCanClawback } // Validate validates the MPTokenIssuanceCreate transaction ensuring all fields are correct. @@ -145,12 +143,12 @@ func (m *MPTokenIssuanceCreate) Validate() (bool, error) { return false, err } - // Validate TransferFee: must not exceed MAX_TRANSFER_FEE and requires tfMPTCanTransfer flag. + // Validate TransferFee: must not exceed MAX_TRANSFER_FEE and requires TfMPTCanTransfer flag. if m.TransferFee != nil && *m.TransferFee > 0 { if *m.TransferFee > MaxTransferFee { return false, ErrInvalidTransferFee } - if !types.IsFlagEnabled(m.Flags, tfMPTCanTransfer) { + if !flag.Contains(m.Flags, TfMPTCanTransfer) { return false, ErrTransferFeeRequiresCanTransfer } } diff --git a/xrpl/transaction/mptoken_issuance_create_test.go b/xrpl/transaction/mptoken_issuance_create_test.go index 6af6f85f..3db3bbc1 100644 --- a/xrpl/transaction/mptoken_issuance_create_test.go +++ b/xrpl/transaction/mptoken_issuance_create_test.go @@ -81,7 +81,7 @@ func TestMPTokenIssuanceCreate_Validate(t *testing.T) { BaseTx: BaseTx{ Account: "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2", TransactionType: MPTokenIssuanceCreateTx, - Flags: tfMPTCanTransfer, + Flags: TfMPTCanTransfer, }, AssetScale: types.AssetScale(2), TransferFee: types.TransferFee(314), @@ -156,32 +156,32 @@ func TestMPTokenIssuanceCreate_Flags(t *testing.T) { { name: "MPTCanLock", setFlag: (*MPTokenIssuanceCreate).SetMPTCanLockFlag, - flagMask: tfMPTCanLock, + flagMask: TfMPTCanLock, }, { name: "MPTRequireAuth", setFlag: (*MPTokenIssuanceCreate).SetMPTRequireAuthFlag, - flagMask: tfMPTRequireAuth, + flagMask: TfMPTRequireAuth, }, { name: "MPTCanEscrow", setFlag: (*MPTokenIssuanceCreate).SetMPTCanEscrowFlag, - flagMask: tfMPTCanEscrow, + flagMask: TfMPTCanEscrow, }, { name: "MPTCanTrade", setFlag: (*MPTokenIssuanceCreate).SetMPTCanTradeFlag, - flagMask: tfMPTCanTrade, + flagMask: TfMPTCanTrade, }, { name: "MPTCanTransfer", setFlag: (*MPTokenIssuanceCreate).SetMPTCanTransferFlag, - flagMask: tfMPTCanTransfer, + flagMask: TfMPTCanTransfer, }, { name: "MPTCanClawback", setFlag: (*MPTokenIssuanceCreate).SetMPTCanClawbackFlag, - flagMask: tfMPTCanClawback, + flagMask: TfMPTCanClawback, }, } @@ -213,6 +213,6 @@ func TestMPTokenIssuanceCreate_Flags(t *testing.T) { tt.setFlag(tx) } - expectedFlags := tfMPTCanLock | tfMPTRequireAuth | tfMPTCanEscrow | tfMPTCanTrade | tfMPTCanTransfer | tfMPTCanClawback + expectedFlags := TfMPTCanLock | TfMPTRequireAuth | TfMPTCanEscrow | TfMPTCanTrade | TfMPTCanTransfer | TfMPTCanClawback require.Equal(t, uint32(expectedFlags), tx.Flags) } diff --git a/xrpl/transaction/mptoken_issuance_set.go b/xrpl/transaction/mptoken_issuance_set.go index 4641e316..84228ca5 100644 --- a/xrpl/transaction/mptoken_issuance_set.go +++ b/xrpl/transaction/mptoken_issuance_set.go @@ -2,15 +2,16 @@ package transaction import ( addresscodec "github.com/Peersyst/xrpl-go/address-codec" + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) // MPTokenIssuanceSet Flags const ( - // If set, indicates that all MPT balances for this asset should be locked. - tfMPTLock uint32 = 0x00000001 - // If set, indicates that all MPT balances for this asset should be unlocked. - tfMPTUnlock uint32 = 0x00000002 + // TfMPTLock if set, indicates that all MPT balances for this asset should be locked. + TfMPTLock uint32 = 0x00000001 + // TfMPTUnlock if set, indicates that all MPT balances for this asset should be unlocked. + TfMPTUnlock uint32 = 0x00000002 ) // MPTokenIssuanceSet transaction is used to globally lock/unlock a MPTokenIssuance, @@ -54,16 +55,16 @@ func (m *MPTokenIssuanceSet) Flatten() FlatTransaction { return flattened } -// SetMPTLockFlag sets the tfMPTLock flag on the transaction. +// SetMPTLockFlag sets the TfMPTLock flag on the transaction. // Indicates that all MPT balances for this asset should be locked. func (m *MPTokenIssuanceSet) SetMPTLockFlag() { - m.Flags |= tfMPTLock + m.Flags |= TfMPTLock } -// SetMPTUnlockFlag sets the tfMPTUnlock flag on the transaction. +// SetMPTUnlockFlag sets the TfMPTUnlock flag on the transaction. // Indicates that all MPT balances for this asset should be unlocked. func (m *MPTokenIssuanceSet) SetMPTUnlockFlag() { - m.Flags |= tfMPTUnlock + m.Flags |= TfMPTUnlock } // Validate validates the MPTokenIssuanceSet transaction ensuring all fields are correct. @@ -78,9 +79,9 @@ func (m *MPTokenIssuanceSet) Validate() (bool, error) { return false, ErrInvalidAccount } - // Check flag conflict: tfMPTLock and tfMPTUnlock cannot both be enabled - isLock := types.IsFlagEnabled(m.Flags, tfMPTLock) - isUnlock := types.IsFlagEnabled(m.Flags, tfMPTUnlock) + // Check flag conflict: TfMPTLock and TfMPTUnlock cannot both be enabled + isLock := flag.Contains(m.Flags, TfMPTLock) + isUnlock := flag.Contains(m.Flags, TfMPTUnlock) if isLock && isUnlock { return false, ErrMPTokenIssuanceSetFlags diff --git a/xrpl/transaction/mptoken_issuance_set_test.go b/xrpl/transaction/mptoken_issuance_set_test.go index 90f17966..529cc2ae 100644 --- a/xrpl/transaction/mptoken_issuance_set_test.go +++ b/xrpl/transaction/mptoken_issuance_set_test.go @@ -101,7 +101,7 @@ func TestMPTokenIssuanceSet_Validate(t *testing.T) { BaseTx: BaseTx{ Account: "rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD", TransactionType: MPTokenIssuanceSetTx, - Flags: tfMPTLock | tfMPTUnlock, + Flags: TfMPTLock | TfMPTUnlock, }, MPTokenIssuanceID: "00070C4495F14B0E44F78A264E41713C64B5F89242540EE255534400000000000000", }, @@ -130,14 +130,14 @@ func TestMPTokenIssuanceSet_Flags(t *testing.T) { setFlags: func(tx *MPTokenIssuanceSet) { tx.SetMPTLockFlag() }, - want: tfMPTLock, + want: TfMPTLock, }, { name: "pass - set MPTUnlock flag", setFlags: func(tx *MPTokenIssuanceSet) { tx.SetMPTUnlockFlag() }, - want: tfMPTUnlock, + want: TfMPTUnlock, }, { name: "pass - set both flags", @@ -145,7 +145,7 @@ func TestMPTokenIssuanceSet_Flags(t *testing.T) { tx.SetMPTLockFlag() tx.SetMPTUnlockFlag() }, - want: tfMPTLock | tfMPTUnlock, + want: TfMPTLock | TfMPTUnlock, }, } diff --git a/xrpl/transaction/nftoken_burn.go b/xrpl/transaction/nftoken_burn.go index a9f59708..205ddc37 100644 --- a/xrpl/transaction/nftoken_burn.go +++ b/xrpl/transaction/nftoken_burn.go @@ -8,7 +8,7 @@ import ( // The NFTokenBurn transaction is used to remove a NFToken object from the NFTokenPage in which it is being held, effectively removing the token from the ledger (burning it). // -// The sender of this transaction must be the owner of the NFToken to burn; or, if the NFToken has the lsfBurnable flag enabled, can be the issuer or the issuer's authorized NFTokenMinter account instead. +// The sender of this transaction must be the owner of the NFToken to burn; or, if the NFToken has the LsfBurnable flag enabled, can be the issuer or the issuer's authorized NFTokenMinter account instead. // // If this operation succeeds, the corresponding NFToken is removed. // If this operation empties the NFTokenPage holding the NFToken or results in consolidation, thus removing a NFTokenPage, the owner’s reserve requirement is reduced by one. @@ -31,7 +31,7 @@ type NFTokenBurn struct { // The NFToken to be removed by this transaction. NFTokenID types.NFTokenID // (Optional) The owner of the NFToken to burn. Only used if that owner is different than the account sending this transaction. - // The issuer or authorized minter can use this field to burn NFTs that have the lsfBurnable flag enabled. + // The issuer or authorized minter can use this field to burn NFTs that have the LsfBurnable flag enabled. Owner types.Address `json:",omitempty"` } diff --git a/xrpl/transaction/nftoken_create_offer.go b/xrpl/transaction/nftoken_create_offer.go index 9b5501fe..5989c638 100644 --- a/xrpl/transaction/nftoken_create_offer.go +++ b/xrpl/transaction/nftoken_create_offer.go @@ -2,6 +2,7 @@ package transaction import ( addresscodec "github.com/Peersyst/xrpl-go/address-codec" + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) @@ -10,8 +11,8 @@ import ( // ********************************** const ( - // If enabled, indicates that the offer is a sell offer. Otherwise, it is a buy offer. - tfSellNFToken uint32 = 1 + // TfSellNFToken if enabled, indicates that the offer is a sell offer. Otherwise, it is a buy offer. + TfSellNFToken uint32 = 1 ) // NFTokenCreateOfferMetadata represents the resulting metadata of a succeeded NFTokenCreateOffer transaction. @@ -59,7 +60,7 @@ type NFTokenCreateOffer struct { // SetSellNFTokenFlag sets the flag indicating the offer is a sell offer. func (n *NFTokenCreateOffer) SetSellNFTokenFlag() { - n.Flags |= tfSellNFToken + n.Flags |= TfSellNFToken } // TxType returns the type of the transaction (NFTokenCreateOffer). @@ -119,12 +120,12 @@ func (n *NFTokenCreateOffer) Validate() (bool, error) { } // validate Sell Offer Cases - if types.IsFlagEnabled(n.Flags, tfSellNFToken) && n.Owner != "" { + if flag.Contains(n.Flags, TfSellNFToken) && n.Owner != "" { return false, ErrOwnerPresentForSellOffer } // validate Buy Offer Cases - if !types.IsFlagEnabled(n.Flags, tfSellNFToken) && n.Owner == "" { + if !flag.Contains(n.Flags, TfSellNFToken) && n.Owner == "" { return false, ErrOwnerNotPresentForBuyOffer } diff --git a/xrpl/transaction/nftoken_create_offer_test.go b/xrpl/transaction/nftoken_create_offer_test.go index b515c487..91de0324 100644 --- a/xrpl/transaction/nftoken_create_offer_test.go +++ b/xrpl/transaction/nftoken_create_offer_test.go @@ -24,7 +24,7 @@ func TestNFTokenCreateOffer_Flags(t *testing.T) { setter: func(n *NFTokenCreateOffer) { n.SetSellNFTokenFlag() }, - expected: tfSellNFToken, + expected: TfSellNFToken, }, } diff --git a/xrpl/transaction/nftoken_mint.go b/xrpl/transaction/nftoken_mint.go index 2cb0346f..cf6bc754 100644 --- a/xrpl/transaction/nftoken_mint.go +++ b/xrpl/transaction/nftoken_mint.go @@ -3,6 +3,7 @@ package transaction import ( addresscodec "github.com/Peersyst/xrpl-go/address-codec" "github.com/Peersyst/xrpl-go/pkg/typecheck" + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) @@ -55,7 +56,7 @@ type NFTokenMint struct { Issuer types.Address `json:",omitempty"` // (Optional) The value specifies the fee charged by the issuer for secondary sales of the NFToken, if such sales are allowed. // Valid values for this field are between 0 and 50000 inclusive, allowing transfer rates of between 0.00% and 50.00% in increments of 0.001. - // If this field is provided, the transaction MUST have the tfTransferable flag enabled. + // If this field is provided, the transaction MUST have the TfTransferable flag enabled. TransferFee *uint16 `json:",omitempty"` // (Optional) Up to 256 bytes of arbitrary data. In JSON, this should be encoded as a string of hexadecimal. // You can use the xrpl.convertStringToHex utility to convert a URI to its hexadecimal equivalent. @@ -81,41 +82,41 @@ type NFTokenMint struct { // ********************************** const ( - // Allow the issuer (or an entity authorized by the issuer) to destroy the minted NFToken. (The NFToken's owner can always do so.) - tfBurnable uint32 = 1 - // The minted NFToken can only be bought or sold for XRP. This can be desirable if the token has a transfer fee and the issuer does not want to receive fees in non-XRP currencies. - tfOnlyXRP uint32 = 2 - // DEPRECATED Automatically create trust lines from the issuer to hold transfer fees received from transferring the minted NFToken. The fixRemoveNFTokenAutoTrustLine amendment makes it invalid to set this flag. - tfTrustLine uint32 = 4 - // The minted NFToken can be transferred to others. If this flag is not enabled, the token can still be transferred from or to the issuer, but a transfer to the issuer must be made based on a buy offer from the issuer and not a sell offer from the NFT holder. - tfTransferable uint32 = 8 - // The URI field of the minted NFToken can be updated using the NFTokenModify transaction. - tfMutable uint32 = 16 + // TfBurnable allows the issuer (or an entity authorized by the issuer) to destroy the minted NFToken. (The NFToken's owner can always do so.) + TfBurnable uint32 = 1 + // TfOnlyXRP the minted NFToken can only be bought or sold for XRP. This can be desirable if the token has a transfer fee and the issuer does not want to receive fees in non-XRP currencies. + TfOnlyXRP uint32 = 2 + // TfTrustLine DEPRECATED Automatically create trust lines from the issuer to hold transfer fees received from transferring the minted NFToken. The fixRemoveNFTokenAutoTrustLine amendment makes it invalid to set this flag. + TfTrustLine uint32 = 4 + // TfTransferable the minted NFToken can be transferred to others. If this flag is not enabled, the token can still be transferred from or to the issuer, but a transfer to the issuer must be made based on a buy offer from the issuer and not a sell offer from the NFT holder. + TfTransferable uint32 = 8 + // TfMutable the URI field of the minted NFToken can be updated using the NFTokenModify transaction. + TfMutable uint32 = 16 ) // SetBurnableFlag allows the issuer (or an entity authorized by the issuer) to destroy the minted NFToken. (The NFToken's owner can always do so.) func (n *NFTokenMint) SetBurnableFlag() { - n.Flags |= tfBurnable + n.Flags |= TfBurnable } // SetOnlyXRPFlag restricts the minted NFToken to be bought or sold only for XRP. func (n *NFTokenMint) SetOnlyXRPFlag() { - n.Flags |= tfOnlyXRP + n.Flags |= TfOnlyXRP } -// SetTrustlineFlag is deprecated and was used to auto-create trust lines for transfer fees. (Invalid with fixRemoveNFTokenAutoTrustLine amendment.) Deprecated in favor of tfTransferable. +// SetTrustlineFlag is deprecated and was used to auto-create trust lines for transfer fees. (Invalid with fixRemoveNFTokenAutoTrustLine amendment.) Deprecated in favor of TfTransferable. func (n *NFTokenMint) SetTrustlineFlag() { - n.Flags |= tfTrustLine + n.Flags |= TfTrustLine } // SetTransferableFlag allows the minted NFToken to be transferred to others. func (n *NFTokenMint) SetTransferableFlag() { - n.Flags |= tfTransferable + n.Flags |= TfTransferable } // SetMutableFlag allows the URI field of the minted NFToken to be updated using the NFTokenModify transaction. func (n *NFTokenMint) SetMutableFlag() { - n.Flags |= tfMutable + n.Flags |= TfMutable } // TxType returns the type of the transaction (NFTokenMint). @@ -189,8 +190,8 @@ func (n *NFTokenMint) Validate() (bool, error) { return false, ErrInvalidURI } - // check transfer fee can only be set if the tfTransferable flag is enabled - if n.TransferFee != nil && *n.TransferFee > 0 && !types.IsFlagEnabled(n.Flags, tfTransferable) { + // check transfer fee can only be set if the TfTransferable flag is enabled + if n.TransferFee != nil && *n.TransferFee > 0 && !flag.Contains(n.Flags, TfTransferable) { return false, ErrTransferFeeRequiresTransferableFlag } diff --git a/xrpl/transaction/nftoken_mint_test.go b/xrpl/transaction/nftoken_mint_test.go index 061e781b..4bedff02 100644 --- a/xrpl/transaction/nftoken_mint_test.go +++ b/xrpl/transaction/nftoken_mint_test.go @@ -24,35 +24,35 @@ func TestNFTokenMint_Flags(t *testing.T) { setter: func(n *NFTokenMint) { n.SetBurnableFlag() }, - expected: tfBurnable, + expected: TfBurnable, }, { name: "pass - SetOnlyXRPFlag", setter: func(n *NFTokenMint) { n.SetOnlyXRPFlag() }, - expected: tfOnlyXRP, + expected: TfOnlyXRP, }, { name: "pass - SetTrustlineFlag", setter: func(n *NFTokenMint) { n.SetTrustlineFlag() }, - expected: tfTrustLine, + expected: TfTrustLine, }, { name: "pass - SetTransferableFlag", setter: func(n *NFTokenMint) { n.SetTransferableFlag() }, - expected: tfTransferable, + expected: TfTransferable, }, { name: "pass - SetMutableFlag", setter: func(n *NFTokenMint) { n.SetMutableFlag() }, - expected: tfMutable, + expected: TfMutable, }, { name: "pass - SetBurnableFlag and SetTransferableFlag", @@ -60,7 +60,7 @@ func TestNFTokenMint_Flags(t *testing.T) { n.SetBurnableFlag() n.SetTransferableFlag() }, - expected: tfBurnable | tfTransferable, + expected: TfBurnable | TfTransferable, }, { name: "pass - SetBurnableFlag and SetTransferableFlag and SetOnlyXRPFlag", @@ -69,7 +69,7 @@ func TestNFTokenMint_Flags(t *testing.T) { n.SetTransferableFlag() n.SetOnlyXRPFlag() }, - expected: tfBurnable | tfTransferable | tfOnlyXRP, + expected: TfBurnable | TfTransferable | TfOnlyXRP, }, } diff --git a/xrpl/transaction/nftoken_modify.go b/xrpl/transaction/nftoken_modify.go index d48eb7d2..7656fb29 100644 --- a/xrpl/transaction/nftoken_modify.go +++ b/xrpl/transaction/nftoken_modify.go @@ -7,7 +7,7 @@ import ( ) // NFTokenModify is used to change the URI field of an NFT to point to a different URI in order to update the supporting data for the NFT. -// The NFT must have been minted with the tfMutable flag set. See Dynamic Non-Fungible Tokens (https://xrpl.org/docs/concepts/tokens/nfts/dynamic-nfts). +// The NFT must have been minted with the TfMutable flag set. See Dynamic Non-Fungible Tokens (https://xrpl.org/docs/concepts/tokens/nfts/dynamic-nfts). // // # Example // diff --git a/xrpl/transaction/offer_create.go b/xrpl/transaction/offer_create.go index 27b0a775..5ee17762 100644 --- a/xrpl/transaction/offer_create.go +++ b/xrpl/transaction/offer_create.go @@ -1,6 +1,7 @@ package transaction import ( + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) @@ -45,44 +46,44 @@ type OfferCreate struct { // ********************************** const ( - // tfPassive indicates that the offer is passive, meaning it does not consume offers that exactly match it, and instead waits to be consumed by an offer that exactly matches it. - tfPassive uint32 = 65536 - // Treat the Offer as an Immediate or Cancel order. The Offer never creates an Offer object in the ledger: it only trades as much as it can by consuming existing Offers at the time the transaction is processed. If no Offers match, it executes "successfully" without trading anything. In this case, the transaction still uses the result code tesSUCCESS. - tfImmediateOrCancel uint32 = 131072 - // Treat the offer as a Fill or Kill order. The Offer never creates an Offer object in the ledger, and is canceled if it cannot be fully filled at the time of execution. By default, this means that the owner must receive the full TakerPays amount; if the tfSell flag is enabled, the owner must be able to spend the entire TakerGets amount instead. - tfFillOrKill uint32 = 262144 - // tfSell indicates that the offer is selling, not buying. - tfSell uint32 = 524288 - // Indicates the offer is hybrid. (meaning it is part of both a domain and open order book) + // TfPassive indicates that the offer is passive, meaning it does not consume offers that exactly match it, and instead waits to be consumed by an offer that exactly matches it. + TfPassive uint32 = 65536 + // TfImmediateOrCancel treats the Offer as an Immediate or Cancel order. The Offer never creates an Offer object in the ledger: it only trades as much as it can by consuming existing Offers at the time the transaction is processed. If no Offers match, it executes "successfully" without trading anything. In this case, the transaction still uses the result code tesSUCCESS. + TfImmediateOrCancel uint32 = 131072 + // TfFillOrKill treats the offer as a Fill or Kill order. The Offer never creates an Offer object in the ledger, and is canceled if it cannot be fully filled at the time of execution. By default, this means that the owner must receive the full TakerPays amount; if the TfSell flag is enabled, the owner must be able to spend the entire TakerGets amount instead. + TfFillOrKill uint32 = 262144 + // TfSell indicates that the offer is selling, not buying. + TfSell uint32 = 524288 + // TfHybrid indicates the offer is hybrid. (meaning it is part of both a domain and open order book) // This flag cannot be set if the offer doesn't have a DomainID - tfHybrid uint32 = 0x00100000 + TfHybrid uint32 = 0x00100000 ) -// SetPassiveFlag sets the tfPassive flag, indicating the offer is passive and will not consume exactly matching offers. +// SetPassiveFlag sets the TfPassive flag, indicating the offer is passive and will not consume exactly matching offers. func (o *OfferCreate) SetPassiveFlag() { - o.Flags |= tfPassive + o.Flags |= TfPassive } -// SetImmediateOrCancelFlag sets the tfImmediateOrCancel flag, treating the offer as an Immediate or Cancel order. +// SetImmediateOrCancelFlag sets the TfImmediateOrCancel flag, treating the offer as an Immediate or Cancel order. // It executes against existing offers only and never creates a new ledger entry. func (o *OfferCreate) SetImmediateOrCancelFlag() { - o.Flags |= tfImmediateOrCancel + o.Flags |= TfImmediateOrCancel } -// SetFillOrKillFlag sets the tfFillOrKill flag, treating the offer as a Fill or Kill order. +// SetFillOrKillFlag sets the TfFillOrKill flag, treating the offer as a Fill or Kill order. // The offer is canceled if it cannot be fully filled immediately. func (o *OfferCreate) SetFillOrKillFlag() { - o.Flags |= tfFillOrKill + o.Flags |= TfFillOrKill } -// SetSellFlag sets the tfSell flag, indicating the offer is selling rather than buying. +// SetSellFlag sets the TfSell flag, indicating the offer is selling rather than buying. func (o *OfferCreate) SetSellFlag() { - o.Flags |= tfSell + o.Flags |= TfSell } -// SetHybridFlag sets the tfHybrid, indicating the offer is hybrid. +// SetHybridFlag sets the TfHybrid, indicating the offer is hybrid. func (o *OfferCreate) SetHybridFlag() { - o.Flags |= tfHybrid + o.Flags |= TfHybrid } // TxType returns the type of the transaction (OfferCreate). @@ -127,7 +128,7 @@ func (o *OfferCreate) Validate() (bool, error) { return false, err } - if o.DomainID == nil && types.IsFlagEnabled(o.Flags, tfHybrid) { + if o.DomainID == nil && flag.Contains(o.Flags, TfHybrid) { return false, ErrTfHybridCannotBeSetWithoutDomainID } diff --git a/xrpl/transaction/offer_create_test.go b/xrpl/transaction/offer_create_test.go index 797e9f89..1b87c0c7 100644 --- a/xrpl/transaction/offer_create_test.go +++ b/xrpl/transaction/offer_create_test.go @@ -245,7 +245,7 @@ func TestOfferCreate_Validate(t *testing.T) { Fee: types.XRPCurrencyAmount(12), Sequence: 8, LastLedgerSequence: 7108682, - Flags: tfHybrid, + Flags: TfHybrid, }, TakerGets: types.XRPCurrencyAmount(6000000), TakerPays: types.IssuedCurrencyAmount{ @@ -285,7 +285,7 @@ func TestOfferCreate_Validate(t *testing.T) { Fee: types.XRPCurrencyAmount(12), Sequence: 8, LastLedgerSequence: 7108682, - Flags: tfHybrid, + Flags: TfHybrid, }, TakerGets: types.XRPCurrencyAmount(6000000), TakerPays: types.IssuedCurrencyAmount{ @@ -320,35 +320,35 @@ func TestOfferCreate_Flags(t *testing.T) { setter: func(a *OfferCreate) { a.SetPassiveFlag() }, - expected: tfPassive, + expected: TfPassive, }, { name: "pass - SetImmediateOrCancelFlag", setter: func(a *OfferCreate) { a.SetImmediateOrCancelFlag() }, - expected: tfImmediateOrCancel, + expected: TfImmediateOrCancel, }, { name: "pass - SetFillOrKillFlag", setter: func(a *OfferCreate) { a.SetFillOrKillFlag() }, - expected: tfFillOrKill, + expected: TfFillOrKill, }, { name: "pass - SetSellFlag", setter: func(a *OfferCreate) { a.SetSellFlag() }, - expected: tfSell, + expected: TfSell, }, { name: "pass - SetHybridFlag", setter: func(a *OfferCreate) { a.SetHybridFlag() }, - expected: tfHybrid, + expected: TfHybrid, }, } diff --git a/xrpl/transaction/payment.go b/xrpl/transaction/payment.go index 30102650..afb830c6 100644 --- a/xrpl/transaction/payment.go +++ b/xrpl/transaction/payment.go @@ -2,22 +2,23 @@ package transaction import ( addresscodec "github.com/Peersyst/xrpl-go/address-codec" + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( - // Do not use the default path; only use paths included in the Paths field. + // TfRippleNotDirect do not use the default path; only use paths included in the Paths field. // This is intended to force the transaction to take arbitrage opportunities. // Most clients do not need this. - tfRippleNotDirect uint32 = 65536 - // If the specified Amount cannot be sent without spending more than SendMax, + TfRippleNotDirect uint32 = 65536 + // TfPartialPayment if the specified Amount cannot be sent without spending more than SendMax, // reduce the received amount instead of failing outright. See Partial // Payments for more details. - tfPartialPayment uint32 = 131072 - // Only take paths where all the conversions have an input:output ratio that + TfPartialPayment uint32 = 131072 + // TfLimitQuality only take paths where all the conversions have an input:output ratio that // is equal or better than the ratio of Amount:SendMax. See Limit Quality for // details. - tfLimitQuality uint32 = 262144 + TfLimitQuality uint32 = 262144 ) // PaymentMetadata represents the resulting metadata of a succeeded Payment transaction. @@ -32,7 +33,7 @@ type Payment struct { // API v1: Only available in API v1. // The maximum amount of currency to deliver. // For non-XRP amounts, the nested field names MUST be lower-case. - // If the tfPartialPayment flag is set, deliver up to this amount instead. + // If the TfPartialPayment flag is set, deliver up to this amount instead. Amount types.CurrencyAmount // Set of Credentials to authorize a deposit made by this transaction. @@ -43,7 +44,7 @@ type Payment struct { // API v2: Only available in API v2. // The maximum amount of currency to deliver. // For non-XRP amounts, the nested field names MUST be lower-case. - // If the tfPartialPayment flag is set, deliver up to this amount instead. + // If the TfPartialPayment flag is set, deliver up to this amount instead. DeliverMax types.CurrencyAmount `json:",omitempty"` // (Optional) Minimum amount of destination currency this transaction should deliver. @@ -156,7 +157,7 @@ func (p *Payment) Flatten() FlatTransaction { // This is intended to force the transaction to take arbitrage opportunities. // Most clients do not need this. func (p *Payment) SetRippleNotDirectFlag() { - p.Flags |= tfRippleNotDirect + p.Flags |= TfRippleNotDirect } // SetPartialPaymentFlag sets the PartialPayment flag. @@ -165,7 +166,7 @@ func (p *Payment) SetRippleNotDirectFlag() { // reduce the received amount instead of failing outright. See Partial // Payments for more details. func (p *Payment) SetPartialPaymentFlag() { - p.Flags |= tfPartialPayment + p.Flags |= TfPartialPayment } // SetLimitQualityFlag sets the LimitQuality flag. @@ -174,7 +175,7 @@ func (p *Payment) SetPartialPaymentFlag() { // is equal or better than the ratio of Amount:SendMax. See Limit Quality for // details. func (p *Payment) SetLimitQualityFlag() { - p.Flags |= tfLimitQuality + p.Flags |= TfLimitQuality } // Validate validates the Payment struct and make sure all the fields are correct. @@ -245,7 +246,7 @@ func checkPartialPayment(tx *Payment) (bool, error) { return false, ErrPartialPaymentFlagRequired } - if !types.IsFlagEnabled(tx.Flags, tfPartialPayment) { + if !flag.Contains(tx.Flags, TfPartialPayment) { return false, ErrPartialPaymentFlagRequired } diff --git a/xrpl/transaction/payment_channel_claim.go b/xrpl/transaction/payment_channel_claim.go index 63713925..542e88ac 100644 --- a/xrpl/transaction/payment_channel_claim.go +++ b/xrpl/transaction/payment_channel_claim.go @@ -6,11 +6,11 @@ import ( ) const ( - // Clear the channel's Expiration time. (Expiration is different from the + // TfRenew clears the channel's Expiration time. (Expiration is different from the // channel's immutable CancelAfter time.) Only the source address of the // payment channel can use this flag. - tfRenew uint32 = 65536 // 0x00010000 - // Request to close the channel. Only the channel source and destination + TfRenew uint32 = 65536 // 0x00010000 + // TfClose requests to close the channel. Only the channel source and destination // addresses can use this flag. This flag closes the channel immediately if it // has no more XRP allocated to it after processing the current claim, or if // the destination address uses it. If the source address uses this flag when @@ -21,7 +21,7 @@ const ( // time.) If the destination address uses this flag when the channel still // holds XRP, any XRP that remains after processing the claim is returned to // the source address. - tfClose uint32 = 131072 // 0x00020000 + TfClose uint32 = 131072 // 0x00020000 ) // PaymentChannelClaim claims XRP from a payment channel, adjusts the payment channel's expiration, or both. @@ -117,7 +117,7 @@ func (p *PaymentChannelClaim) Flatten() FlatTransaction { // channel's immutable CancelAfter time.) Only the source address of the // payment channel can use this flag. func (p *PaymentChannelClaim) SetRenewFlag() { - p.Flags |= tfRenew + p.Flags |= TfRenew } // SetCloseFlag sets the Close flag. @@ -134,7 +134,7 @@ func (p *PaymentChannelClaim) SetRenewFlag() { // holds XRP, any XRP that remains after processing the claim is returned to // the source address. func (p *PaymentChannelClaim) SetCloseFlag() { - p.Flags |= tfClose + p.Flags |= TfClose } // Validate validates the PaymentChannelFund fields. diff --git a/xrpl/transaction/payment_channel_claim_test.go b/xrpl/transaction/payment_channel_claim_test.go index 1360f342..551cd4de 100644 --- a/xrpl/transaction/payment_channel_claim_test.go +++ b/xrpl/transaction/payment_channel_claim_test.go @@ -24,14 +24,14 @@ func TestPaymentChannelClaimFlags(t *testing.T) { setter: func(p *PaymentChannelClaim) { p.SetRenewFlag() }, - expected: tfRenew, + expected: TfRenew, }, { name: "pass - SetCloseFlag", setter: func(p *PaymentChannelClaim) { p.SetCloseFlag() }, - expected: tfClose, + expected: TfClose, }, { name: "pass - SetRenewFlag and SetCloseFlag", @@ -39,7 +39,7 @@ func TestPaymentChannelClaimFlags(t *testing.T) { p.SetRenewFlag() p.SetCloseFlag() }, - expected: tfRenew | tfClose, + expected: TfRenew | TfClose, }, } diff --git a/xrpl/transaction/payment_test.go b/xrpl/transaction/payment_test.go index 7266f189..d9b374a5 100644 --- a/xrpl/transaction/payment_test.go +++ b/xrpl/transaction/payment_test.go @@ -24,21 +24,21 @@ func TestPaymentFlags(t *testing.T) { setter: func(p *Payment) { p.SetRippleNotDirectFlag() }, - expected: tfRippleNotDirect, + expected: TfRippleNotDirect, }, { name: "pass - SetPartialPaymentFlag", setter: func(p *Payment) { p.SetPartialPaymentFlag() }, - expected: tfPartialPayment, + expected: TfPartialPayment, }, { name: "pass - SetLimitQualityFlag", setter: func(p *Payment) { p.SetLimitQualityFlag() }, - expected: tfLimitQuality, + expected: TfLimitQuality, }, { name: "pass - SetRippleNotDirectFlag and SetPartialPaymentFlag", @@ -46,7 +46,7 @@ func TestPaymentFlags(t *testing.T) { p.SetRippleNotDirectFlag() p.SetPartialPaymentFlag() }, - expected: tfRippleNotDirect | tfPartialPayment, + expected: TfRippleNotDirect | TfPartialPayment, }, { name: "pass - SetRippleNotDirectFlag and SetLimitQualityFlag", @@ -54,7 +54,7 @@ func TestPaymentFlags(t *testing.T) { p.SetRippleNotDirectFlag() p.SetLimitQualityFlag() }, - expected: tfRippleNotDirect | tfLimitQuality, + expected: TfRippleNotDirect | TfLimitQuality, }, { name: "pass - SetPartialPaymentFlag and SetLimitQualityFlag", @@ -62,7 +62,7 @@ func TestPaymentFlags(t *testing.T) { p.SetPartialPaymentFlag() p.SetLimitQualityFlag() }, - expected: tfPartialPayment | tfLimitQuality, + expected: TfPartialPayment | TfLimitQuality, }, { name: "pass - all flags", @@ -71,7 +71,7 @@ func TestPaymentFlags(t *testing.T) { p.SetPartialPaymentFlag() p.SetLimitQualityFlag() }, - expected: tfRippleNotDirect | tfPartialPayment | tfLimitQuality, + expected: TfRippleNotDirect | TfPartialPayment | TfLimitQuality, }, } @@ -341,7 +341,7 @@ func TestPayment_Validate(t *testing.T) { Account: "rLs9Pa3CwsoJTnXf4RzzbGsnD9GeCPAUpj", TransactionType: PaymentTx, Fee: types.XRPCurrencyAmount(1000), - Flags: tfPartialPayment, + Flags: TfPartialPayment, }, Amount: types.IssuedCurrencyAmount{ Issuer: "r3EeETxLb1JwmN2xWuZZdKrrEkqw7qgeYf", @@ -496,7 +496,7 @@ func TestPayment_Flatten(t *testing.T) { Account: "rJwjoukM94WwKwxM428V7b9npHjpkSvif", TransactionType: PaymentTx, Fee: types.XRPCurrencyAmount(1000), - Flags: tfRippleNotDirect | tfPartialPayment, + Flags: TfRippleNotDirect | TfPartialPayment, }, Amount: types.IssuedCurrencyAmount{ Currency: "USD", diff --git a/xrpl/transaction/results.go b/xrpl/transaction/results.go index e8cccf73..e937ed52 100644 --- a/xrpl/transaction/results.go +++ b/xrpl/transaction/results.go @@ -92,7 +92,7 @@ const ( // An invariant check failed when executing this transaction. (EnforceInvariants amendment) TecINVARIANT_FAILED TxResult = "tecINVARIANT_FAILED" - // The OfferCreate transaction specified tfFillOrKill and could not be filled. + // The OfferCreate transaction specified TfFillOrKill and could not be filled. TecKILLED TxResult = "tecKILLED" // A sequence number field is already at its maximum. (Added by NonFungibleTokensV1_1 amendment) @@ -110,7 +110,7 @@ const ( // The transaction tried to remove the only available method of authorizing transactions. (Prior to rippled 0.30.0, this was called tecMASTER_DISABLED.) TecNO_ALTERNATIVE_KEY TxResult = "tecNO_ALTERNATIVE_KEY" - // The transaction failed because it needs to add a balance on a trust line to an account with the lsfRequireAuth flag enabled, and that trust line has not been authorized. + // The transaction failed because it needs to add a balance on a trust line to an account with the LsfRequireAuth flag enabled, and that trust line has not been authorized. TecNO_AUTH TxResult = "tecNO_AUTH" // The account on the receiving end of the transaction does not exist. @@ -293,7 +293,7 @@ const ( // NetworkID field specified incorrectly based on current network rules. TelNETWORK_ID_MAKES_TX_NON_CANONICAL TxResult = "telNETWORK_ID_MAKES_TX_NON_CANONICAL" - // tfPartialPayment improperly used in an XRP payment funding a new account. + // TfPartialPayment improperly used in an XRP payment funding a new account. TelNO_DST_PARTIAL TxResult = "telNO_DST_PARTIAL" // Transaction missing required NetworkID field. @@ -345,16 +345,16 @@ const ( // Payment Paths flagged as a loop. TemBAD_PATH_LOOP TxResult = "temBAD_PATH_LOOP" - // tfLimitQuality improperly used in direct XRP-to-XRP payment. + // TfLimitQuality improperly used in direct XRP-to-XRP payment. TemBAD_SEND_XRP_LIMIT TxResult = "temBAD_SEND_XRP_LIMIT" // SendMax improperly included in direct XRP-to-XRP payment. TemBAD_SEND_XRP_MAX TxResult = "temBAD_SEND_XRP_MAX" - // tfNoDirectRipple improperly used in direct XRP-to-XRP payment. + // TfRippleNotDirect improperly used in direct XRP-to-XRP payment. TemBAD_SEND_XRP_NO_DIRECT TxResult = "temBAD_SEND_XRP_NO_DIRECT" - // tfPartialPayment improperly used in direct XRP-to-XRP payment. + // TfPartialPayment improperly used in direct XRP-to-XRP payment. TemBAD_SEND_XRP_PARTIAL TxResult = "temBAD_SEND_XRP_PARTIAL" // Paths improperly included in direct XRP-to-XRP payment. diff --git a/xrpl/transaction/trust_set.go b/xrpl/transaction/trust_set.go index 04f2bc0d..a59494f3 100644 --- a/xrpl/transaction/trust_set.go +++ b/xrpl/transaction/trust_set.go @@ -5,27 +5,26 @@ import ( ) const ( - // Authorize the other party to hold currency issued by this account. (No - // effect unless using the asfRequireAuth AccountSet flag.) Cannot be unset. - tfSetAuth uint32 = 0x00010000 - // Enable the No Ripple flag, which blocks rippling between two trust lines. + // TfSetAuth authorizes the other party to hold currency issued by this account. (No + // effect unless using the AsfRequireAuth AccountSet flag.) Cannot be unset. + TfSetAuth uint32 = 0x00010000 + // TfSetNoRipple enables the No Ripple flag, which blocks rippling between two trust lines. // of the same currency if this flag is enabled on both. - tfSetNoRipple uint32 = 0x00020000 - // Disable the No Ripple flag, allowing rippling on this trust line. - tfClearNoRipple uint32 = 0x00040000 - // Freeze the trust line. - tfSetFreeze uint32 = 0x00100000 - // Unfreeze the trust line. - tfClearFreeze uint32 = 0x00200000 - - // XLS-77d Deep freeze - // Freeze the trust line, preventing the high account from sending and + TfSetNoRipple uint32 = 0x00020000 + // TfClearNoRipple disables the No Ripple flag, allowing rippling on this trust line. + TfClearNoRipple uint32 = 0x00040000 + // TfSetFreeze freezes the trust line. + TfSetFreeze uint32 = 0x00100000 + // TfClearFreeze unfreezes the trust line. + TfClearFreeze uint32 = 0x00200000 + + // TfSetDeepFreeze (XLS-77d Deep freeze) freezes the trust line, preventing the high account from sending and // receiving the asset. Allowed only if the trustline is already regularly - // frozen, or if tfSetFreeze is set in the same transaction. - tfSetDeepFreeze uint32 = 0x00400000 - // Unfreeze the trust line, allowing the high account to send and + // frozen, or if TfSetFreeze is set in the same transaction. + TfSetDeepFreeze uint32 = 0x00400000 + // TfClearDeepFreeze unfreezes the trust line, allowing the high account to send and // receive the asset. - tfClearDeepFreeze uint32 = 0x00800000 + TfClearDeepFreeze uint32 = 0x00800000 ) // TrustSet creates or modifies a trust line linking two accounts. @@ -69,39 +68,39 @@ func (t *TrustSet) Flatten() FlatTransaction { return flattened } -// SetSetAuthFlag sets the SetAuth flag, authorizing the other party to hold currency issued by this account. Cannot be unset. +// SetSetAuthFlag sets the TfSetAuth flag, authorizing the other party to hold currency issued by this account. Cannot be unset. func (t *TrustSet) SetSetAuthFlag() { - t.Flags |= tfSetAuth + t.Flags |= TfSetAuth } -// SetSetNoRippleFlag sets the SetNoRipple flag, enabling the No Ripple feature on the trust line. +// SetSetNoRippleFlag sets the TfSetNoRipple flag, enabling the No Ripple feature on the trust line. func (t *TrustSet) SetSetNoRippleFlag() { - t.Flags |= tfSetNoRipple + t.Flags |= TfSetNoRipple } -// SetClearNoRippleFlag sets the ClearNoRipple flag, disabling the No Ripple feature on the trust line. +// SetClearNoRippleFlag sets the TfClearNoRipple flag, disabling the No Ripple feature on the trust line. func (t *TrustSet) SetClearNoRippleFlag() { - t.Flags |= tfClearNoRipple + t.Flags |= TfClearNoRipple } -// SetSetFreezeFlag sets the SetFreeze flag to freeze the trust line. +// SetSetFreezeFlag sets the TfSetFreeze flag to freeze the trust line. func (t *TrustSet) SetSetFreezeFlag() { - t.Flags |= tfSetFreeze + t.Flags |= TfSetFreeze } -// SetClearFreezeFlag sets the ClearFreeze flag to unfreeze the trust line. +// SetClearFreezeFlag sets the TfClearFreeze flag to unfreeze the trust line. func (t *TrustSet) SetClearFreezeFlag() { - t.Flags |= tfClearFreeze + t.Flags |= TfClearFreeze } -// SetSetDeepFreezeFlag sets the SetDeepFreeze flag to deep freeze the trust line (XLS-77d). +// SetSetDeepFreezeFlag sets the TfSetDeepFreeze flag to deep freeze the trust line (XLS-77d). func (t *TrustSet) SetSetDeepFreezeFlag() { - t.Flags |= tfSetDeepFreeze + t.Flags |= TfSetDeepFreeze } -// SetClearDeepFreezeFlag sets the ClearDeepFreeze flag to remove deep freeze on the trust line. +// SetClearDeepFreezeFlag sets the TfClearDeepFreeze flag to remove deep freeze on the trust line. func (t *TrustSet) SetClearDeepFreezeFlag() { - t.Flags |= tfClearDeepFreeze + t.Flags |= TfClearDeepFreeze } // Validate checks that the TrustSet transaction has valid fields and flags. diff --git a/xrpl/transaction/trust_set_test.go b/xrpl/transaction/trust_set_test.go index ef7ad9f0..e011d38e 100644 --- a/xrpl/transaction/trust_set_test.go +++ b/xrpl/transaction/trust_set_test.go @@ -57,21 +57,21 @@ func TestTrustSetFlags(t *testing.T) { setter: func(ts *TrustSet) { ts.SetSetAuthFlag() }, - expected: tfSetAuth, + expected: TfSetAuth, }, { name: "pass - SetSetNoRippleFlag", setter: func(ts *TrustSet) { ts.SetSetNoRippleFlag() }, - expected: tfSetNoRipple, + expected: TfSetNoRipple, }, { name: "pass - SetClearNoRippleFlag", setter: func(ts *TrustSet) { ts.SetClearNoRippleFlag() }, - expected: tfClearNoRipple, + expected: TfClearNoRipple, }, { name: "pass - SetSetfAuthFlag and SetSetNoRippleFlag", @@ -79,7 +79,7 @@ func TestTrustSetFlags(t *testing.T) { ts.SetSetAuthFlag() ts.SetSetNoRippleFlag() }, - expected: tfSetAuth | tfSetNoRipple, + expected: TfSetAuth | TfSetNoRipple, }, { name: "pass - SetSetfAuthFlag and SetClearNoRippleFlag", @@ -87,21 +87,21 @@ func TestTrustSetFlags(t *testing.T) { ts.SetSetAuthFlag() ts.SetClearNoRippleFlag() }, - expected: tfSetAuth | tfClearNoRipple, + expected: TfSetAuth | TfClearNoRipple, }, { name: "pass - SetSetFreezeFlag", setter: func(ts *TrustSet) { ts.SetSetFreezeFlag() }, - expected: tfSetFreeze, + expected: TfSetFreeze, }, { name: "pass - SetClearFreezeFlag", setter: func(ts *TrustSet) { ts.SetClearFreezeFlag() }, - expected: tfClearFreeze, + expected: TfClearFreeze, }, { name: "pass - All flags", @@ -114,7 +114,7 @@ func TestTrustSetFlags(t *testing.T) { ts.SetSetDeepFreezeFlag() ts.SetClearDeepFreezeFlag() }, - expected: tfSetAuth | tfSetNoRipple | tfClearNoRipple | tfSetFreeze | tfClearFreeze | tfSetDeepFreeze | tfClearDeepFreeze, + expected: TfSetAuth | TfSetNoRipple | TfClearNoRipple | TfSetFreeze | TfClearFreeze | TfSetDeepFreeze | TfClearDeepFreeze, }, } diff --git a/xrpl/transaction/types/raw_tx.go b/xrpl/transaction/types/raw_tx.go index bef93265..4cd77cad 100644 --- a/xrpl/transaction/types/raw_tx.go +++ b/xrpl/transaction/types/raw_tx.go @@ -1,6 +1,8 @@ //revive:disable:var-naming package types +import "github.com/Peersyst/xrpl-go/xrpl/flag" + const ( // TfInnerBatchTxn flag that must be set on inner transactions within a batch TfInnerBatchTxn uint32 = 0x40000000 @@ -35,7 +37,7 @@ func validateRawTransaction(rawTx map[string]any) (bool, error) { } // Check for the TfInnerBatchTxn flag in the inner transactions - if flags, ok := rawTx["Flags"].(uint32); !ok || !IsFlagEnabled(flags, TfInnerBatchTxn) { + if flags, ok := rawTx["Flags"].(uint32); !ok || !flag.Contains(flags, TfInnerBatchTxn) { return false, ErrBatchMissingInnerFlag } diff --git a/xrpl/transaction/xchain_modify_bridge.go b/xrpl/transaction/xchain_modify_bridge.go index bfe46cfb..03f6f3bc 100644 --- a/xrpl/transaction/xchain_modify_bridge.go +++ b/xrpl/transaction/xchain_modify_bridge.go @@ -1,11 +1,13 @@ package transaction import ( + "github.com/Peersyst/xrpl-go/xrpl/flag" "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( - tfClearAccountCreateAmount uint32 = 0x00010000 + // TfClearAccountCreateAmount if enabled, indicates that the MinAccountCreateAmount field should be cleared from the bridge. + TfClearAccountCreateAmount uint32 = 0x00010000 ) // XChainModifyBridge modifies an existing Bridge ledger object, updating its flags, minimum account create amount, and signature reward. @@ -54,7 +56,7 @@ func (x *XChainModifyBridge) TxType() TxType { // SetClearAccountCreateAmount enables the flag to clear the minimum account create amount. func (x *XChainModifyBridge) SetClearAccountCreateAmount() { - x.Flags |= tfClearAccountCreateAmount + x.Flags |= TfClearAccountCreateAmount } // Flatten returns a flat map representation of the XChainModifyBridge transaction. @@ -89,7 +91,7 @@ func (x *XChainModifyBridge) Validate() (bool, error) { return false, err } - if !types.IsFlagEnabled(x.Flags, tfClearAccountCreateAmount) { + if !flag.Contains(x.Flags, TfClearAccountCreateAmount) { return false, ErrInvalidFlags } diff --git a/xrpl/transaction/xchain_modify_bridge_test.go b/xrpl/transaction/xchain_modify_bridge_test.go index 7998599f..af19df2f 100644 --- a/xrpl/transaction/xchain_modify_bridge_test.go +++ b/xrpl/transaction/xchain_modify_bridge_test.go @@ -15,7 +15,7 @@ func TestXChainModifyBridge_TxType(t *testing.T) { func TestXChainModifyBridge_SetClearAccountCreateAmount(t *testing.T) { tx := &XChainModifyBridge{} tx.SetClearAccountCreateAmount() - require.Equal(t, tx.Flags, tfClearAccountCreateAmount) + require.Equal(t, tx.Flags, TfClearAccountCreateAmount) } func TestXChainModifyBridge_Flatten(t *testing.T) { @@ -30,7 +30,7 @@ func TestXChainModifyBridge_Flatten(t *testing.T) { BaseTx: BaseTx{ Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", }, - Flags: tfClearAccountCreateAmount, + Flags: TfClearAccountCreateAmount, MinAccountCreateAmount: types.XRPCurrencyAmount(100), SignatureReward: types.XRPCurrencyAmount(10), XChainBridge: types.XChainBridge{ @@ -43,7 +43,7 @@ func TestXChainModifyBridge_Flatten(t *testing.T) { expected: FlatTransaction{ "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "TransactionType": "XChainModifyBridge", - "Flags": uint32(tfClearAccountCreateAmount), + "Flags": uint32(TfClearAccountCreateAmount), "MinAccountCreateAmount": "100", "SignatureReward": "10", "XChainBridge": types.FlatXChainBridge{ @@ -94,7 +94,7 @@ func TestXChainModifyBridge_Validate(t *testing.T) { Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", TransactionType: XChainModifyBridgeTx, }, - Flags: tfClearAccountCreateAmount, + Flags: TfClearAccountCreateAmount, MinAccountCreateAmount: types.IssuedCurrencyAmount{ Currency: "XRP", Value: "100", @@ -110,7 +110,7 @@ func TestXChainModifyBridge_Validate(t *testing.T) { Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", TransactionType: XChainModifyBridgeTx, }, - Flags: tfClearAccountCreateAmount, + Flags: TfClearAccountCreateAmount, MinAccountCreateAmount: types.XRPCurrencyAmount(100), SignatureReward: types.IssuedCurrencyAmount{ Currency: "XRP", @@ -127,7 +127,7 @@ func TestXChainModifyBridge_Validate(t *testing.T) { Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", TransactionType: XChainModifyBridgeTx, }, - Flags: tfClearAccountCreateAmount, + Flags: TfClearAccountCreateAmount, }, expected: false, expectedErr: types.ErrInvalidIssuingChainDoorAddress, @@ -139,7 +139,7 @@ func TestXChainModifyBridge_Validate(t *testing.T) { Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", TransactionType: XChainModifyBridgeTx, }, - Flags: tfClearAccountCreateAmount, + Flags: TfClearAccountCreateAmount, XChainBridge: types.XChainBridge{ LockingChainDoor: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", IssuingChainDoor: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", diff --git a/xrpl/wallet/batch_test.go b/xrpl/wallet/batch_test.go index 136ad6be..61f46554 100644 --- a/xrpl/wallet/batch_test.go +++ b/xrpl/wallet/batch_test.go @@ -410,7 +410,7 @@ func TestCombineBatchSigners(t *testing.T) { BaseTx: transaction.BaseTx{ Account: types.Address(submitWallet.ClassicAddress.String()), TransactionType: transaction.BatchTx, - Flags: 1, // tfAllOrNothing + Flags: 1, // TfAllOrNothing LastLedgerSequence: 14973, NetworkID: 21336, Sequence: 215, @@ -679,7 +679,7 @@ func TestCombineBatchSigners(t *testing.T) { tx2 := createOriginalBatchTx() // Change flags on tx2 - tx2.Flags = 4 // tfIndependent + tx2.Flags = 4 // TfIndependent tx1Flat := tx1.Flatten() tx2Flat := tx2.Flatten()