Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TA-3384]: Refactor project structure #29

Merged
merged 16 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions .github/workflows/xrpl-go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: XRPL-GO CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main, 'v*' ]
jobs:
build:
name: Lint and Test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: false
load: true
tags: xrpl-go-ci:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run linter
run: docker run --rm xrpl-go-ci:latest sh -c "make lint"
- name: Run tests
run: docker run --rm xrpl-go-ci:latest sh -c "make test-ci"
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.0
1.22.0
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.22 AS install

WORKDIR /app
COPY go.mod go.sum ./

RUN go mod download
COPY . .

FROM install AS lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
RUN make lint

FROM lint AS test
RUN make test
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,35 @@ lint:
@golangci-lint run
@echo "Linting complete!"

test:
test-all:
@echo "Running Go tests..."
@go test $(shell go list ./... | grep -v /faucet | grep -v /examples)
@go test -v $(shell go list ./... | grep -v /faucet | grep -v /examples)
@echo "Tests complete!"

test-binary-codec:
@echo "Running Go tests for binary codec package..."
@go test -v ./codec/binary/...
@echo "Tests complete!"

test-address-codec:
@echo "Running Go tests for address codec package..."
@go test -v ./codec/address/...
@echo "Tests complete!"

test-keypairs:
@echo "Running Go tests for keypairs package..."
@go test -v ./keypairs/...
@echo "Tests complete!"

test-xrpl:
@echo "Running Go tests for xrpl package..."
@go test -v ./xrpl/...
@echo "Tests complete!"

test-ci:
@echo "Running Go tests..."
@go clean -testcache
@go test -v $(shell go list ./... | grep -v /faucet | grep -v /examples)
@echo "Tests complete!"

benchmark:
Expand Down
2 changes: 1 addition & 1 deletion examples/jsonrpc-client/jsonrpc_client_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Peersyst/xrpl-go/xrpl/model/requests/account"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/rpc"
)

Expand Down
4 changes: 2 additions & 2 deletions examples/transactions/payment/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
transactions "github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down
4 changes: 2 additions & 2 deletions examples/wallet/generate_wallet_and_sign_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

addresscodec "github.com/Peersyst/xrpl-go/address-codec"
"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
transactions "github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/account-info/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/model/requests/account"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/account-objects/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/model/requests/account"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
"github.com/Peersyst/xrpl-go/xrpl/queries/account"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/autofill/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
transactions "github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/clawback/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
addresscodec "github.com/Peersyst/xrpl-go/address-codec"
"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
transactions "github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down
8 changes: 4 additions & 4 deletions examples/websocket/send-payment/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"strconv"

"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/currency"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
"github.com/Peersyst/xrpl-go/xrpl/utils"
transactions "github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down Expand Up @@ -48,7 +48,7 @@ func main() {

fmt.Println("Balance: ", balance)

amount, err := utils.XrpToDrops("1")
amount, err := currency.XrpToDrops("1")
if err != nil {
fmt.Println(err)
return
Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/token-issuance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
addresscodec "github.com/Peersyst/xrpl-go/address-codec"
"github.com/Peersyst/xrpl-go/xrpl"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions"
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
transactions "github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/websocket"
)

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Peersyst/xrpl-go

go 1.21
go 1.22

toolchain go1.22.5

Expand All @@ -16,7 +16,6 @@ require (
require (
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
)

require (
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
Expand Down
47 changes: 0 additions & 47 deletions test/mock_webserver.go

This file was deleted.

38 changes: 0 additions & 38 deletions test/util.go

This file was deleted.

2 changes: 1 addition & 1 deletion xrpl/utils/xrp_drops.go → xrpl/currency/native.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package currency

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package currency

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package currency

import (
"encoding/hex"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package currency

import (
"testing"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions xrpl/hash/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/Peersyst/xrpl-go/keypairs"
)

// HashSignedTx hashes a signed transaction blob
// HashTxBlob hashes a signed transaction blob
// It takes a transaction blob and returns the hash of the signed transaction.
// It returns an error if the transaction blob is invalid.
func HashSignedTx(txBlob string) (string, error) {
func HashTxBlob(txBlob string) (string, error) {
tx, err := binarycodec.Decode(txBlob)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions xrpl/hash/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package hash

import "testing"

func TestHashSignedTx(t *testing.T) {
func TestHashTxBlob(t *testing.T) {
testCases := []struct {
name string
txBlob string
Expand All @@ -25,7 +25,7 @@ func TestHashSignedTx(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got, err := HashSignedTx(tc.txBlob)
got, err := HashTxBlob(tc.txBlob)
if (err != nil) != tc.wantErr {
t.Errorf("HashSignedTx() error = %v, wantErr %v", err, tc.wantErr)
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ledger

import (
"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

type AccountRoot struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ledger
import (
"testing"

"github.com/Peersyst/xrpl-go/xrpl/model/transactions/types"
"github.com/Peersyst/xrpl-go/xrpl/test"
"github.com/Peersyst/xrpl-go/xrpl/testutil"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
)

func TestAccountRoot(t *testing.T) {
Expand Down Expand Up @@ -39,7 +39,7 @@ func TestAccountRoot(t *testing.T) {
"TransferRate": 1004999999
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
if err := testutil.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}
Loading
Loading