Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
397dd37
Merge branch 'v0.1.x' of https://github.com/Peersyst/xrpl-go into v0.1.x
GuillemGarciaDev Jan 21, 2025
416676c
refactor(xrpl/queries): split account queries into api versions
GuillemGarciaDev Jan 22, 2025
b42413a
refactor(xrpl/queries): split channel queries for api versions
GuillemGarciaDev Jan 22, 2025
8db51ec
refactor(xrpl/queries): split clio queries for api versions
GuillemGarciaDev Jan 22, 2025
f8c5e01
refactor(xrpl/queries): split ledger queries for api versions
GuillemGarciaDev Jan 22, 2025
77685f1
refactor(xrpl/queries): split nft queries for api versions
GuillemGarciaDev Jan 22, 2025
a5f6daa
refactor(xrpl/queries): split path queries for api versions
GuillemGarciaDev Jan 22, 2025
d4aeb08
refactor(xrpl/queries): split server queries for api versions
GuillemGarciaDev Jan 22, 2025
9a41cea
refactor(xrpl/queries): split transactions queries for api versions
GuillemGarciaDev Jan 22, 2025
47087d7
refactor(xrpl/queries): split utility queries for api versions
GuillemGarciaDev Jan 22, 2025
9016ad4
refactor(xrpl/queries): split rpc queries for api versions
GuillemGarciaDev Jan 22, 2025
f6e18a8
refactor(xrpl): ws client with api version support
GuillemGarciaDev Jan 22, 2025
1380c56
fix(xrpl): lint
GuillemGarciaDev Jan 22, 2025
2ce2d2c
feat(xrpl/queries): add v1 queries missing fields
GuillemGarciaDev Jan 23, 2025
4497b45
fix(xrpl/queries): linting
GuillemGarciaDev Jan 23, 2025
e8669f8
fix(xrpl/queries): add `DestinationAmount` on `RipplePathFind` tests
GuillemGarciaDev Jan 23, 2025
bea1f7a
refactor(xrpl): rename api versions
GuillemGarciaDev Jan 23, 2025
c42c5ba
chore: update CHANGELOG
GuillemGarciaDev Jan 23, 2025
639ca97
feat(xrpl): add `NoRippleCheck` query
GuillemGarciaDev Jan 23, 2025
bf435a5
chore: update changelog
GuillemGarciaDev Jan 23, 2025
7d454ff
feat(xrpl/queries): add descriptive comments to `NoRippleCheck`query
GuillemGarciaDev Jan 24, 2025
ea6e023
Merge pull request #94 from Peersyst/xrpl/feat/no-ripple-check-query
GuillemGarciaDev Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added `APIVersion` field to the `Client` struct.
- Added `RippledAPIV1` and `RippledAPIV2` constants.
- Added missing `ctid` field on `TxRequest` v1 query.
- Added missing `NoRippleCheck` query (v1 & v2 support).

### Changed

- RippledAPIV2 is set as default API version. Queries and transactions are now compatible with Rippled v2 by default. V1 is still supported. In order to use v1, you need to use the `v1` package of each query type.

## [v0.1.2]

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

accounttypes "github.com/Peersyst/xrpl-go/xrpl/queries/account/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -23,6 +24,7 @@ var (
// the same.) All information retrieved is relative to a particular version of
// the ledger.
type ChannelsRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
DestinationAccount types.Address `json:"destination_account,omitempty"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
Expand All @@ -36,6 +38,10 @@ func (*ChannelsRequest) Method() string {
return "account_channels"
}

func (*ChannelsRequest) APIVersion() int {
return version.RippledAPIV2
}

// Validate method to be added to each request struct
func (r *ChannelsRequest) Validate() error {
if r.Account == "" {
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/currencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package account

import (
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -12,6 +13,7 @@ import (
// The `account_currencies` command retrieves a list of currencies that an
// account can send or receive, based on its trust lines.
type CurrenciesRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
Expand All @@ -22,6 +24,10 @@ func (*CurrenciesRequest) Method() string {
return "account_currencies"
}

func (*CurrenciesRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*CurrenciesRequest) Validate() error {
return nil
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types"
accounttypes "github.com/Peersyst/xrpl-go/xrpl/queries/account/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -15,6 +16,7 @@ import (
// activity, and its XRP balance. All information retrieved is relative to a
// particular version of the ledger.
type InfoRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
Expand All @@ -27,6 +29,10 @@ func (*InfoRequest) Method() string {
return "account_info"
}

func (*InfoRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*InfoRequest) Validate() error {
return nil
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package account
import (
accounttypes "github.com/Peersyst/xrpl-go/xrpl/queries/account/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -14,6 +15,7 @@ import (
// including balances in all non-XRP currencies and assets. All information
// retrieved is relative to a particular version of the ledger.
type LinesRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
Expand All @@ -26,6 +28,10 @@ func (*LinesRequest) Method() string {
return "account_lines"
}

func (*LinesRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*LinesRequest) Validate() error {
return nil
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/nfts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package account
import (
accounttypes "github.com/Peersyst/xrpl-go/xrpl/queries/account/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -13,6 +14,7 @@ import (
// The `account_nfts` method retrieves all of the NFTs currently owned by the
// specified account.
type NFTsRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
Expand All @@ -24,6 +26,10 @@ func (*NFTsRequest) Method() string {
return "account_nfts"
}

func (*NFTsRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*NFTsRequest) Validate() error {
return nil
Expand Down
49 changes: 49 additions & 0 deletions xrpl/queries/account/no_ripple_check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package account

import (
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

// ############################################################################
// Request
// ############################################################################

// The `noripple_check` command provides a quick way to check the status of the
// default ripple field for an account and the No Ripple flag of its trust
// lines, compared with the recommended settings. Expects a response in the form
// of an NoRippleCheckResponse.
type NoRippleCheckRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
Role string `json:"role"`
Transactions bool `json:"transactions,omitempty"`
Limit int `json:"limit,omitempty"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
}

func (*NoRippleCheckRequest) Method() string {
return "noripple_check"
}

func (*NoRippleCheckRequest) APIVersion() int {
return version.RippledAPIV2
}

func (*NoRippleCheckRequest) Validate() error {
return nil
}

// ############################################################################
// Response
// ############################################################################

// Response expected by a NoRippleCheckRequest
type NoRippleCheckResponse struct {
LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"`
Problems []string `json:"problems"`
Transactions []transaction.FlatTransaction `json:"transactions"`
}
69 changes: 69 additions & 0 deletions xrpl/queries/account/no_ripple_check_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package account

import (
"testing"

"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/testutil"
"github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

func TestNoRippleCheckRequest(t *testing.T) {
s := NoRippleCheckRequest{
Account: types.Address("r9cZA1mLK5R5Am25ArfXF7tRp1PeperEvH"),
Role: "gateway",
Transactions: true,
Limit: 10,
LedgerHash: common.LedgerHash("0000000000000000000000000000000000000000000000000000000000000000"),
LedgerIndex: common.Validated,
}

j := `{
"account": "r9cZA1mLK5R5Am25ArfXF7tRp1PeperEvH",
"role": "gateway",
"transactions": true,
"limit": 10,
"ledger_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"ledger_index": "validated"
}`
if err := testutil.Serialize(t, s, j); err != nil {
t.Error(err)
}
}

func TestNoRippleCheckResponse(t *testing.T) {
s := NoRippleCheckResponse{
LedgerCurrentIndex: common.LedgerIndex(1234567890),
Problems: []string{"problem1", "problem2"},
Transactions: []transaction.FlatTransaction{
{
"Account": "r9cZA1mLK5R5Am25ArfXF7tRp1PeperEvH",
"Fee": "1000000000",
"Sequence": 1,
"TransactionType": "Payment",
"Amount": "1000000000",
},
},
}

j := `{
"ledger_current_index": 1234567890,
"problems": [
"problem1",
"problem2"
],
"transactions": [
{
"Account": "r9cZA1mLK5R5Am25ArfXF7tRp1PeperEvH",
"Amount": "1000000000",
"Fee": "1000000000",
"Sequence": 1,
"TransactionType": "Payment"
}
]
}`
if err := testutil.Serialize(t, s, j); err != nil {
t.Error(err)
}
}
6 changes: 6 additions & 0 deletions xrpl/queries/account/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package account
import (
"github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -28,6 +29,7 @@ const (
// owned by an account. For a higher-level view of an account's trust lines and
// balances, see the account_lines method instead.
type ObjectsRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
Type ObjectType `json:"type,omitempty"`
DeletionBlockersOnly bool `json:"deletion_blockers_only,omitempty"`
Expand All @@ -41,6 +43,10 @@ func (*ObjectsRequest) Method() string {
return "account_objects"
}

func (*ObjectsRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*ObjectsRequest) Validate() error {
return nil
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/offers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package account
import (
accounttypes "github.com/Peersyst/xrpl-go/xrpl/queries/account/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

Expand All @@ -13,6 +14,7 @@ import (
// The account_offers method retrieves a list of offers made by a given account
// that are outstanding as of a particular ledger version.
type OffersRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
LedgerIndex common.LedgerSpecifier `json:"ledger_index,omitempty"`
Expand All @@ -25,6 +27,10 @@ func (*OffersRequest) Method() string {
return "account_offers"
}

func (*OffersRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*OffersRequest) Validate() error {
return nil
Expand Down
6 changes: 6 additions & 0 deletions xrpl/queries/account/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package account

import (
"github.com/Peersyst/xrpl-go/xrpl/queries/common"
"github.com/Peersyst/xrpl-go/xrpl/queries/version"
"github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)
Expand All @@ -21,6 +22,7 @@ type Transaction struct {
// The account_tx method retrieves a list of transactions that involved the
// specified account.
type TransactionsRequest struct {
common.BaseRequest
Account types.Address `json:"account"`
LedgerIndexMin int `json:"ledger_index_min,omitempty"`
LedgerIndexMax int `json:"ledger_index_max,omitempty"`
Expand All @@ -36,6 +38,10 @@ func (*TransactionsRequest) Method() string {
return "account_tx"
}

func (*TransactionsRequest) APIVersion() int {
return version.RippledAPIV2
}

// TODO: Implement (V2)
func (*TransactionsRequest) Validate() error {
return nil
Expand Down
7 changes: 7 additions & 0 deletions xrpl/queries/account/types/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package types

import "errors"

var (
ErrNoAccountID = errors.New("no account ID specified")
)
Loading
Loading