Skip to content

Commit

Permalink
Merge branch 'main' into wip-binary-encode-txs
Browse files Browse the repository at this point in the history
  • Loading branch information
CreatureDev authored Feb 14, 2024
2 parents 918c80c + 456af3b commit 6094f30
Show file tree
Hide file tree
Showing 300 changed files with 2,175 additions and 635 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Install [pre-commit](https://github.com/pre-commit/pre-commit-hooks)
* Binary Codec
* Address Codec
* Keypairs Generation - **to finish**
* Go Models - **to finish**
* Json Rpc Client - **to finish**
* Webhook Client - **todo**
* Go Models
* Json Rpc Client
* Webhook Client

## Usage
* Keys and Wallets
Expand Down
7 changes: 3 additions & 4 deletions binary-codec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"reflect"
"strings"

"github.com/xyield/xrpl-go/model/transactions"

"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/binary-codec/types"
"github.com/CreatureDev/xrpl-go/model/transactions"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/binary-codec/types"
)

var ErrSigningClaimFieldNotFound = errors.New("'Channel' & 'Amount' fields are both required, but were not found")
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/xyield/xrpl-go/model/transactions"
"github.com/xyield/xrpl-go/model/transactions/types"
"github.com/CreatureDev/xrpl-go/model/transactions"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
)

func TestEncode(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/serdes/binary_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package serdes
import (
"errors"

"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/serdes/binary_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package serdes
import (
"errors"

"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
)

var ErrLengthPrefixTooLong = errors.New("length of value must not exceed 918744 bytes of data")
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/serdes/field_id_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package serdes
import (
"encoding/hex"

"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
)

// Returns the unique field ID for a given field name.
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/serdes/field_id_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
)

func TestEncodeFieldID(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions binary-codec/types/account_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package types
import (
"errors"

addresscodec "github.com/xyield/xrpl-go/address-codec"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/transactions/types"
addresscodec "github.com/CreatureDev/xrpl-go/address-codec"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions binary-codec/types/amount.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"strconv"
"strings"

addresscodec "github.com/xyield/xrpl-go/address-codec"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/transactions/types"
bigdecimal "github.com/xyield/xrpl-go/pkg/big-decimal"
addresscodec "github.com/CreatureDev/xrpl-go/address-codec"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
bigdecimal "github.com/CreatureDev/xrpl-go/pkg/big-decimal"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/amount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/xyield/xrpl-go/model/transactions/types"
bigdecimal "github.com/xyield/xrpl-go/pkg/big-decimal"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
bigdecimal "github.com/CreatureDev/xrpl-go/pkg/big-decimal"
)

func TestVerifyXrpValue(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/types/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"strings"

"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
)

// ErrNoLengthPrefix error is raised when no length prefix size is given.
Expand Down
7 changes: 4 additions & 3 deletions binary-codec/types/pathset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"errors"
"fmt"

addresscodec "github.com/xyield/xrpl-go/address-codec"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/transactions"

addresscodec "github.com/CreatureDev/xrpl-go/address-codec"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/transactions"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/pathset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/transactions"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/transactions"
)

func TestIsPathStep(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/types/serialized_type.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package types

import "github.com/xyield/xrpl-go/binary-codec/serdes"
import "github.com/CreatureDev/xrpl-go/binary-codec/serdes"

// SerializedType is an interface representing any type that can be serialized
// and deserialized to and from JSON.
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/types/st_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"reflect"

"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/st_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sort"

"github.com/mitchellh/mapstructure"
"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
)

// FieldMutation allows values to mutated before being serialized.
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/st_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/xyield/xrpl-go/model/transactions/types"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
)

func TestCreateFieldInstanceMapFromJson(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions binary-codec/types/uint16.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"bytes"
"encoding/binary"

"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/ledger"
"github.com/xyield/xrpl-go/model/transactions"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/ledger"
"github.com/CreatureDev/xrpl-go/model/transactions"
)

// UInt16 represents a 16-bit unsigned integer.
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/uint32.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/binary"
"errors"

"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/transactions/types"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
)

var ErrInvalidUInt32 = errors.New("invalid type for UInt32")
Expand Down
2 changes: 1 addition & 1 deletion binary-codec/types/uint64.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"regexp"
"strings"

"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
)

var UINT64_HEX_REGEX = regexp.MustCompile("^[0-9a-fA-F]{1,16}$")
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/uint8.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"encoding/binary"

"github.com/xyield/xrpl-go/binary-codec/definitions"
"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/binary-codec/definitions"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
)

// UInt8 represents an 8-bit unsigned integer.
Expand Down
4 changes: 2 additions & 2 deletions binary-codec/types/vector256.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strings"

"github.com/xyield/xrpl-go/binary-codec/serdes"
"github.com/xyield/xrpl-go/model/transactions/types"
"github.com/CreatureDev/xrpl-go/binary-codec/serdes"
"github.com/CreatureDev/xrpl-go/model/transactions/types"
)

const HashLengthBytes = 32
Expand Down
94 changes: 89 additions & 5 deletions client/accounts.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package client

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

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.AccountCurrenciesRequest) (*account.AccountCurrenciesResponse, 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
}
10 changes: 7 additions & 3 deletions client/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"errors"
"testing"

"github.com/CreatureDev/xrpl-go/model/client/account"
"github.com/CreatureDev/xrpl-go/model/client/common"
"github.com/mitchellh/mapstructure"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/xyield/xrpl-go/model/client/account"
"github.com/xyield/xrpl-go/model/client/common"
)

type mockClient struct {
Expand All @@ -19,6 +19,10 @@ type mockClientXrplResponse struct {
Result map[string]any
}

func (m *mockClientXrplResponse) GetError() error {
return nil
}

func (m *mockClientXrplResponse) GetResult(v any) error {
dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &v})
if err != nil {
Expand Down Expand Up @@ -118,7 +122,7 @@ func TestGetAccountChannels(t *testing.T) {

cl.On("SendRequest", &tc.input).Return(&tc.sendRequestResult, nil)

res, _, err := a.GetAccountChannels(&tc.input)
res, _, err := a.AccountChannels(&tc.input)

if tc.expectedErr != nil {
require.EqualError(t, err, tc.expectedErr.Error())
Expand Down
Loading

0 comments on commit 6094f30

Please sign in to comment.