Skip to content

Commit

Permalink
Merge branch 'pr/client-impl' into pr/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
CreatureDev committed Jan 29, 2024
2 parents 7c9fd4f + 0565c16 commit 09c57a2
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 11 deletions.
92 changes: 88 additions & 4 deletions client/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ import (
)

type Account interface {
GetAccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error)
GetAccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error)
AccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error)
AccountCurrencies(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error)
AccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error)
AccountLines(req *account.AccountLinesRequest) (*account.AccountLinesResponse, XRPLResponse, error)
AccountNFTs(req *account.AccountNFTsRequest) (*account.AccountNFTsResponse, XRPLResponse, error)
AccountObjects(req *account.AccountObjectsRequest) (*account.AccountObjectsResponse, XRPLResponse, error)
AccountOffers(req *account.AccountOffersRequest) (*account.AccountOffersResponse, XRPLResponse, error)
AccountTransactions(req *account.AccountTransactionsRequest) (*account.AccountTransactionsResponse, XRPLResponse, error)
}

type accountImpl struct {
client Client
}

func (a *accountImpl) GetAccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) {
func (a *accountImpl) AccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
Expand All @@ -26,7 +32,20 @@ func (a *accountImpl) GetAccountChannels(req *account.AccountChannelsRequest) (*
return &acr, res, nil
}

func (a *accountImpl) GetAccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) {
func (a *accountImpl) AccountCurrencies(req *account.AccountCurrenciesRequest) (*account.AccountCurrenciesResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var acr account.AccountCurrenciesResponse
err = res.GetResult(&acr)
if err != nil {
return nil, nil, err
}
return &acr, res, nil
}

func (a *accountImpl) AccountInfo(req *account.AccountInfoRequest) (*account.AccountInfoResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
Expand All @@ -38,3 +57,68 @@ func (a *accountImpl) GetAccountInfo(req *account.AccountInfoRequest) (*account.
}
return &air, res, nil
}

func (a *accountImpl) AccountLines(req *account.AccountLinesRequest) (*account.AccountLinesResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var alr account.AccountLinesResponse
err = res.GetResult(&alr)
if err != nil {
return nil, nil, err
}
return &alr, res, nil
}

func (a *accountImpl) AccountNFTs(req *account.AccountNFTsRequest) (*account.AccountNFTsResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var anr account.AccountNFTsResponse
err = res.GetResult(&anr)
if err != nil {
return nil, nil, err
}
return &anr, res, nil
}

func (a *accountImpl) AccountObjects(req *account.AccountObjectsRequest) (*account.AccountObjectsResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var aor account.AccountObjectsResponse
err = res.GetResult(&aor)
if err != nil {
return nil, nil, err
}
return &aor, res, nil
}

func (a *accountImpl) AccountOffers(req *account.AccountOffersRequest) (*account.AccountOffersResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var aor account.AccountOffersResponse
err = res.GetResult(&aor)
if err != nil {
return nil, nil, err
}
return &aor, res, nil
}

func (a *accountImpl) AccountTransactions(req *account.AccountTransactionsRequest) (*account.AccountTransactionsResponse, XRPLResponse, error) {
res, err := a.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var atr account.AccountTransactionsResponse
err = res.GetResult(&atr)
if err != nil {
return nil, nil, err
}
return &atr, res, nil
}
40 changes: 40 additions & 0 deletions client/channels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package client

import (
"github.com/xyield/xrpl-go/model/client/channel"
)

type Channel interface {
ChannelAuthorize(req *channel.ChannelAuthorizeRequest) (*channel.ChannelAuthorizeRequest, XRPLResponse, error)
ChannelVerify(req *channel.ChannelVerifyRequest) (*channel.ChannelVerifyResponse, XRPLResponse, error)
}

type channelImpl struct {
client Client
}

func (c *channelImpl) ChannelAuthorize(req *channel.ChannelAuthorizeRequest) (*channel.ChannelAuthorizeResponse, XRPLResponse, error) {
res, err := c.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var car channel.ChannelAuthorizeResponse
err = res.GetResult(&car)
if err != nil {
return nil, nil, err
}
return &car, res, nil
}

func (c *channelImpl) ChannelVerify(req *channel.ChannelVerifyRequest) (*channel.ChannelVerifyResponse, XRPLResponse, error) {
res, err := c.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var cvr channel.ChannelVerifyResponse
err = res.GetResult(&cvr)
if err != nil {
return nil, nil, err
}
return &cvr, res, nil
}
82 changes: 82 additions & 0 deletions client/ledgers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package client

import (
"github.com/xyield/xrpl-go/model/client/ledger"
)

type Ledger interface {
LedgerClosed(req *ledger.LedgerClosedRequest) (*ledger.LedgerClosedRequest, XRPLResponse, error)
LedgerCurrent(req *ledger.LedgerCurrentRequest) (*ledger.LedgerCurrentRequest, XRPLResponse, error)
LedgerData(req *ledger.LedgerDataRequest) (*ledger.LedgerDataRequest, XRPLResponse, error)
LedgerEntry(req *ledger.LedgerEntryRequest) (*ledger.LedgerEntryRequest, XRPLResponse, error)
Ledger(req *ledger.LedgerRequest) (*ledger.LedgerRequest, XRPLResponse, error)
}

type ledgerImpl struct {
client Client
}

func (l *ledgerImpl) LedgerClosed(req *ledger.LedgerClosedRequest) (*ledger.LedgerClosedResponse, XRPLResponse, error) {
res, err := l.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var lcr ledger.LedgerClosedResponse
err = res.GetResult(&lcr)
if err != nil {
return nil, nil, err
}
return &lcr, res, nil
}

func (l *ledgerImpl) LedgerCurrent(req *ledger.LedgerCurrentRequest) (*ledger.LedgerCurrentResponse, XRPLResponse, error) {
res, err := l.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var lcr ledger.LedgerCurrentResponse
err = res.GetResult(&lcr)
if err != nil {
return nil, nil, err
}
return &lcr, res, nil
}

func (l *ledgerImpl) LedgerData(req *ledger.LedgerDataRequest) (*ledger.LedgerDataResponse, XRPLResponse, error) {
res, err := l.client.SendRequest(req)

Check failure on line 46 in client/ledgers.go

View workflow job for this annotation

GitHub Actions / code-quality

cannot use req (variable of type *"github.com/xyield/xrpl-go/model/client/ledger".LedgerDataRequest) as type XRPLRequest in argument to l.client.SendRequest:

Check failure on line 46 in client/ledgers.go

View workflow job for this annotation

GitHub Actions / code-quality

cannot use req (variable of type *"github.com/xyield/xrpl-go/model/client/ledger".LedgerDataRequest) as type XRPLRequest in argument to l.client.SendRequest:

Check failure on line 46 in client/ledgers.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use req (variable of type *"github.com/xyield/xrpl-go/model/client/ledger".LedgerDataRequest) as type XRPLRequest in argument to l.client.SendRequest:

Check failure on line 46 in client/ledgers.go

View workflow job for this annotation

GitHub Actions / golang-ci

cannot use req (variable of type *"github.com/xyield/xrpl-go/model/client/ledger".LedgerDataRequest) as type XRPLRequest in argument to l.client.SendRequest:

Check failure on line 46 in client/ledgers.go

View workflow job for this annotation

GitHub Actions / golang-ci

cannot use req (variable of type *"github.com/xyield/xrpl-go/model/client/ledger".LedgerDataRequest) as type XRPLRequest in argument to l.client.SendRequest:
if err != nil {
return nil, nil, err
}
var ldr ledger.LedgerDataResponse
err = res.GetResult(&ldr)
if err != nil {
return nil, nil, err
}
return &ldr, res, nil
}

func (l *ledgerImpl) LedgerEntry(req *ledger.LedgerEntryRequest) (*ledger.LedgerEntryResponse, XRPLResponse, error) {
res, err := l.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var ler ledger.LedgerEntryResponse
err = res.GetResult(&ler)
if err != nil {
return nil, nil, err
}
return &ler, res, nil
}

func (l *ledgerImpl) Ledger(req *ledger.LedgerRequest) (*ledger.LedgerResponse, XRPLResponse, error) {
res, err := l.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var lr ledger.LedgerResponse
err = res.GetResult(&lr)
if err != nil {
return nil, nil, err
}
return &lr, res, nil
}
94 changes: 94 additions & 0 deletions client/path.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package client

import "github.com/xyield/xrpl-go/model/client/path"

type PathBook interface {
BookOffers(req *path.BookOffersRequest) (*path.BookOffersResponse, XRPLResponse, error)
DepositAuthorized(req *path.DepositAuthorizedRequest) (*path.DepositAuthorizedResponse, XRPLResponse, error)
NFTokenBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error)
NFTokenSellOffers(req *path.NFTokenSellOffersRequest) (*path.NFTokenSellOffersResponse, XRPLResponse, error)
PathFind(req *path.PathFindRequest) (*path.PathFindResponse, XRPLResponse, error)
RipplePathFind(req *path.RipplePathFindRequest) (*path.RipplePathFindResponse, XRPLResponse, error)
}

type pathImpl struct {
client Client
}

func (p *pathImpl) BookOffers(req *path.BookOffersRequest) (*path.BookOffersResponse, XRPLResponse, error) {
res, err := p.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var bor path.BookOffersResponse
err = res.GetResult(&bor)
if err != nil {
return nil, nil, err
}
return &bor, res, nil
}

func (p *pathImpl) DepositAuthorized(req *path.DepositAuthorizedRequest) (*path.DepositAuthorizedResponse, XRPLResponse, error) {
res, err := p.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var dar path.DepositAuthorizedResponse
err = res.GetResult(&dar)
if err != nil {
return nil, nil, err
}
return &dar, res, nil
}

func (p *pathImpl) NFTBuyOffers(req *path.NFTokenBuyOffersRequest) (*path.NFTokenBuyOffersResponse, XRPLResponse, error) {
res, err := p.client.SendRequest(req)

Check failure on line 45 in client/path.go

View workflow job for this annotation

GitHub Actions / code-quality

cannot use req (variable of type *path.NFTokenBuyOffersRequest) as type XRPLRequest in argument to p.client.SendRequest:

Check failure on line 45 in client/path.go

View workflow job for this annotation

GitHub Actions / code-quality

cannot use req (variable of type *path.NFTokenBuyOffersRequest) as type XRPLRequest in argument to p.client.SendRequest:

Check failure on line 45 in client/path.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use req (variable of type *path.NFTokenBuyOffersRequest) as type XRPLRequest in argument to p.client.SendRequest:

Check failure on line 45 in client/path.go

View workflow job for this annotation

GitHub Actions / golang-ci

cannot use req (variable of type *path.NFTokenBuyOffersRequest) as type XRPLRequest in argument to p.client.SendRequest:

Check failure on line 45 in client/path.go

View workflow job for this annotation

GitHub Actions / golang-ci

cannot use req (variable of type *path.NFTokenBuyOffersRequest) as type XRPLRequest in argument to p.client.SendRequest:
if err != nil {
return nil, nil, err
}
var nbr path.NFTokenBuyOffersResponse
err = res.GetResult(&nbr)
if err != nil {
return nil, nil, err
}
return &nbr, res, nil
}

func (p *pathImpl) NFTokenSellOffers(req *path.NFTokenSellOffersRequest) (*path.NFTokenSellOffersResponse, XRPLResponse, error) {
res, err := p.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var nsr path.NFTokenSellOffersResponse
err = res.GetResult(&nsr)
if err != nil {
return nil, nil, err
}
return &nsr, res, nil
}

func (p *pathImpl) PathFind(req *path.PathFindRequest) (*path.PathFindResponse, XRPLResponse, error) {
res, err := p.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var pfr path.PathFindResponse
err = res.GetResult(&pfr)
if err != nil {
return nil, nil, err
}
return &pfr, res, nil
}

func (p *pathImpl) RipplePathFind(req *path.RipplePathFindRequest) (*path.RipplePathFindResponse, XRPLResponse, error) {
res, err := p.client.SendRequest(req)
if err != nil {
return nil, nil, err
}
var rpfr path.RipplePathFindResponse
err = res.GetResult(&rpfr)
if err != nil {
return nil, nil, err
}
return &rpfr, res, nil
}
Loading

0 comments on commit 09c57a2

Please sign in to comment.