diff --git a/.github/workflows/xrpl-go-ci.yml b/.github/workflows/xrpl-go-ci.yml new file mode 100644 index 00000000..07fcfabc --- /dev/null +++ b/.github/workflows/xrpl-go-ci.yml @@ -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" \ No newline at end of file diff --git a/.go-version b/.go-version index e4264e98..57807d6d 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.21.0 \ No newline at end of file +1.22.0 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dbd41750 --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index 21e60e1b..66e51ba7 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/examples/jsonrpc-client/jsonrpc_client_example.go b/examples/jsonrpc-client/jsonrpc_client_example.go index da67ec58..d286c312 100644 --- a/examples/jsonrpc-client/jsonrpc_client_example.go +++ b/examples/jsonrpc-client/jsonrpc_client_example.go @@ -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" ) diff --git a/examples/transactions/payment/main.go b/examples/transactions/payment/main.go index e62f26b4..bf87cef9 100644 --- a/examples/transactions/payment/main.go +++ b/examples/transactions/payment/main.go @@ -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" ) diff --git a/examples/wallet/generate_wallet_and_sign_tx.go b/examples/wallet/generate_wallet_and_sign_tx.go index 10739cd8..1fcdf029 100644 --- a/examples/wallet/generate_wallet_and_sign_tx.go +++ b/examples/wallet/generate_wallet_and_sign_tx.go @@ -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 ( diff --git a/examples/websocket/account-info/main.go b/examples/websocket/account-info/main.go index cf361094..42e7333f 100644 --- a/examples/websocket/account-info/main.go +++ b/examples/websocket/account-info/main.go @@ -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" ) diff --git a/examples/websocket/account-objects/main.go b/examples/websocket/account-objects/main.go index 638fe445..033030bc 100644 --- a/examples/websocket/account-objects/main.go +++ b/examples/websocket/account-objects/main.go @@ -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" ) diff --git a/examples/websocket/autofill/main.go b/examples/websocket/autofill/main.go index fbf09635..441006d9 100644 --- a/examples/websocket/autofill/main.go +++ b/examples/websocket/autofill/main.go @@ -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" ) diff --git a/examples/websocket/clawback/main.go b/examples/websocket/clawback/main.go index d903f2f9..e58b18f9 100644 --- a/examples/websocket/clawback/main.go +++ b/examples/websocket/clawback/main.go @@ -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" ) diff --git a/examples/websocket/send-payment/main.go b/examples/websocket/send-payment/main.go index 8c0b1082..adc06f90 100644 --- a/examples/websocket/send-payment/main.go +++ b/examples/websocket/send-payment/main.go @@ -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" ) @@ -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 diff --git a/examples/websocket/token-issuance/main.go b/examples/websocket/token-issuance/main.go index 88ad5c23..25b20fdc 100644 --- a/examples/websocket/token-issuance/main.go +++ b/examples/websocket/token-issuance/main.go @@ -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" ) diff --git a/go.mod b/go.mod index aa826f90..ee7feede 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Peersyst/xrpl-go -go 1.21 +go 1.22 toolchain go1.22.5 @@ -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 ( diff --git a/go.sum b/go.sum index cbbd9b11..5410ec6d 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/test/mock_webserver.go b/test/mock_webserver.go deleted file mode 100644 index 116943b7..00000000 --- a/test/mock_webserver.go +++ /dev/null @@ -1,47 +0,0 @@ -package test - -import ( - "log" - "net/http" - "net/http/httptest" - "net/url" - - "github.com/gorilla/websocket" -) - -type MockWebSocketServer struct { - Msgs []map[string]any -} - -type connFn func(*websocket.Conn) - -func (ms *MockWebSocketServer) TestWebSocketServer(writeFunc connFn) *httptest.Server { - var upgrader = websocket.Upgrader{} - - s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - upgrader.CheckOrigin = func(r *http.Request) bool { return true } - c, err := upgrader.Upgrade(w, r, nil) - if err != nil { - log.Println("Upgrade:", err) - } - - writeFunc(c) - })) - - return s -} - -func ConvertHttpToWS(u string) (string, error) { - s, err := url.Parse(u) - if err != nil { - return "", err - } - switch s.Scheme { - case "http": - s.Scheme = "ws" - case "https": - s.Scheme = "wss" - } - - return s.String(), nil -} diff --git a/test/util.go b/test/util.go deleted file mode 100644 index 17b525af..00000000 --- a/test/util.go +++ /dev/null @@ -1,38 +0,0 @@ -package test - -import ( - "encoding/json" - "fmt" - "reflect" - "testing" - - "github.com/stretchr/testify/require" -) - -func Deserialize(s interface{}, d string) error { - decode := reflect.New(reflect.TypeOf(s)) - err := json.Unmarshal([]byte(d), decode.Interface()) - if err != nil { - return err - } - if !reflect.DeepEqual(s, decode.Elem().Interface()) { - return fmt.Errorf("json decoding does not match expected struct") - } - return nil - -} - -func SerializeAndDeserialize(t *testing.T, s interface{}, d string) error { - j, err := json.MarshalIndent(s, "", "\t") - if err != nil { - return err - } - require.Equal(t, d, string(j), "json encoding does not match expected string") - decode := reflect.New(reflect.TypeOf(s)) - err = json.Unmarshal(j, decode.Interface()) - if err != nil { - return err - } - require.Equal(t, s, decode.Elem().Interface(), "json decoding does not match expected struct") - return nil -} diff --git a/xrpl/utils/xrp_drops.go b/xrpl/currency/native.go similarity index 98% rename from xrpl/utils/xrp_drops.go rename to xrpl/currency/native.go index fe4cb02a..f3daed68 100644 --- a/xrpl/utils/xrp_drops.go +++ b/xrpl/currency/native.go @@ -1,4 +1,4 @@ -package utils +package currency import ( "errors" diff --git a/xrpl/utils/xrp_drops_test.go b/xrpl/currency/native_test.go similarity index 99% rename from xrpl/utils/xrp_drops_test.go rename to xrpl/currency/native_test.go index c8d82cfe..9609e8f1 100644 --- a/xrpl/utils/xrp_drops_test.go +++ b/xrpl/currency/native_test.go @@ -1,4 +1,4 @@ -package utils +package currency import ( "errors" diff --git a/xrpl/utils/currency_converters.go b/xrpl/currency/non-standard.go similarity index 99% rename from xrpl/utils/currency_converters.go rename to xrpl/currency/non-standard.go index 60cf83bf..8174f532 100644 --- a/xrpl/utils/currency_converters.go +++ b/xrpl/currency/non-standard.go @@ -1,4 +1,4 @@ -package utils +package currency import ( "encoding/hex" diff --git a/xrpl/utils/currency_converters_test.go b/xrpl/currency/non-standard_test.go similarity index 99% rename from xrpl/utils/currency_converters_test.go rename to xrpl/currency/non-standard_test.go index 75e2080a..d1d0feb1 100644 --- a/xrpl/utils/currency_converters_test.go +++ b/xrpl/currency/non-standard_test.go @@ -1,4 +1,4 @@ -package utils +package currency import ( "testing" diff --git a/xrpl/hash/prefix.go b/xrpl/hash/main.go similarity index 100% rename from xrpl/hash/prefix.go rename to xrpl/hash/main.go diff --git a/xrpl/hash/tx.go b/xrpl/hash/tx.go index a852bcd8..002f286e 100644 --- a/xrpl/hash/tx.go +++ b/xrpl/hash/tx.go @@ -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 diff --git a/xrpl/hash/tx_test.go b/xrpl/hash/tx_test.go index f1d3d500..04815c1f 100644 --- a/xrpl/hash/tx_test.go +++ b/xrpl/hash/tx_test.go @@ -2,7 +2,7 @@ package hash import "testing" -func TestHashSignedTx(t *testing.T) { +func TestHashTxBlob(t *testing.T) { testCases := []struct { name string txBlob string @@ -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 diff --git a/xrpl/model/ledger/account_root.go b/xrpl/ledger-entry-types/account_root.go similarity index 94% rename from xrpl/model/ledger/account_root.go rename to xrpl/ledger-entry-types/account_root.go index dedf56fe..97fd5bf9 100644 --- a/xrpl/model/ledger/account_root.go +++ b/xrpl/ledger-entry-types/account_root.go @@ -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 { diff --git a/xrpl/model/ledger/account_root_test.go b/xrpl/ledger-entry-types/account_root_test.go similarity index 88% rename from xrpl/model/ledger/account_root_test.go rename to xrpl/ledger-entry-types/account_root_test.go index 87e455d8..8d3b23ee 100644 --- a/xrpl/model/ledger/account_root_test.go +++ b/xrpl/ledger-entry-types/account_root_test.go @@ -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) { @@ -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) } } diff --git a/xrpl/model/ledger/amendments.go b/xrpl/ledger-entry-types/amendments.go similarity index 87% rename from xrpl/model/ledger/amendments.go rename to xrpl/ledger-entry-types/amendments.go index 3762ad03..e59a0386 100644 --- a/xrpl/model/ledger/amendments.go +++ b/xrpl/ledger-entry-types/amendments.go @@ -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 Amendments struct { diff --git a/xrpl/model/ledger/amendments_test.go b/xrpl/ledger-entry-types/amendments_test.go similarity index 88% rename from xrpl/model/ledger/amendments_test.go rename to xrpl/ledger-entry-types/amendments_test.go index ae91a45d..affa3615 100644 --- a/xrpl/model/ledger/amendments_test.go +++ b/xrpl/ledger-entry-types/amendments_test.go @@ -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 TestAmmendments(t *testing.T) { @@ -46,7 +46,7 @@ func TestAmmendments(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/amm.go b/xrpl/ledger-entry-types/amm.go similarity index 96% rename from xrpl/model/ledger/amm.go rename to xrpl/ledger-entry-types/amm.go index 15d60df0..9eb25251 100644 --- a/xrpl/model/ledger/amm.go +++ b/xrpl/ledger-entry-types/amm.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AMM struct { diff --git a/xrpl/model/ledger/check.go b/xrpl/ledger-entry-types/check.go similarity index 90% rename from xrpl/model/ledger/check.go rename to xrpl/ledger-entry-types/check.go index d1cf3418..c19dd44e 100644 --- a/xrpl/model/ledger/check.go +++ b/xrpl/ledger-entry-types/check.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" // TODO verify format of SendMax type Check struct { diff --git a/xrpl/model/ledger/check_test.go b/xrpl/ledger-entry-types/check_test.go similarity index 91% rename from xrpl/model/ledger/check_test.go rename to xrpl/ledger-entry-types/check_test.go index 98c6aeae..13295da8 100644 --- a/xrpl/model/ledger/check_test.go +++ b/xrpl/ledger-entry-types/check_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestCheck(t *testing.T) { @@ -39,7 +39,7 @@ func TestCheck(t *testing.T) { "Sequence": 2 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/deposit_preauth.go b/xrpl/ledger-entry-types/deposit_preauth.go similarity index 85% rename from xrpl/model/ledger/deposit_preauth.go rename to xrpl/ledger-entry-types/deposit_preauth.go index b239d153..b5b66765 100644 --- a/xrpl/model/ledger/deposit_preauth.go +++ b/xrpl/ledger-entry-types/deposit_preauth.go @@ -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 DepositPreauthObj struct { diff --git a/xrpl/model/ledger/deposit_preauth_test.go b/xrpl/ledger-entry-types/deposit_preauth_test.go similarity index 87% rename from xrpl/model/ledger/deposit_preauth_test.go rename to xrpl/ledger-entry-types/deposit_preauth_test.go index 53cfd0d6..7a92f93e 100644 --- a/xrpl/model/ledger/deposit_preauth_test.go +++ b/xrpl/ledger-entry-types/deposit_preauth_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestDepositPreauth(t *testing.T) { @@ -27,7 +27,7 @@ func TestDepositPreauth(t *testing.T) { "PreviousTxnLgrSeq": 7 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/directory_node.go b/xrpl/ledger-entry-types/directory_node.go similarity index 90% rename from xrpl/model/ledger/directory_node.go rename to xrpl/ledger-entry-types/directory_node.go index aacf880d..a2d73bc7 100644 --- a/xrpl/model/ledger/directory_node.go +++ b/xrpl/ledger-entry-types/directory_node.go @@ -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 DirectoryNode struct { diff --git a/xrpl/model/ledger/directory_node_test.go b/xrpl/ledger-entry-types/directory_node_test.go similarity index 89% rename from xrpl/model/ledger/directory_node_test.go rename to xrpl/ledger-entry-types/directory_node_test.go index 60a109a5..941f3c1f 100644 --- a/xrpl/model/ledger/directory_node_test.go +++ b/xrpl/ledger-entry-types/directory_node_test.go @@ -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 TestOfferDirectoryNode(t *testing.T) { @@ -34,7 +34,7 @@ func TestOfferDirectoryNode(t *testing.T) { "TakerPaysIssuer": "5BBC0F22F61D9224A110650CFE21CC0C4BE13098" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -62,7 +62,7 @@ func TestOwnerDirectoryNode(t *testing.T) { "RootIndex": "193C591BF62482468422313F9D3274B5927CA80B4DD3707E42015DD609E39C94" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/escrow.go b/xrpl/ledger-entry-types/escrow.go similarity index 91% rename from xrpl/model/ledger/escrow.go rename to xrpl/ledger-entry-types/escrow.go index 7383c360..0a89e252 100644 --- a/xrpl/model/ledger/escrow.go +++ b/xrpl/ledger-entry-types/escrow.go @@ -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 Escrow struct { diff --git a/xrpl/model/ledger/escrow_test.go b/xrpl/ledger-entry-types/escrow_test.go similarity index 89% rename from xrpl/model/ledger/escrow_test.go rename to xrpl/ledger-entry-types/escrow_test.go index b35a0e89..9a4be7e2 100644 --- a/xrpl/model/ledger/escrow_test.go +++ b/xrpl/ledger-entry-types/escrow_test.go @@ -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 TestEscrow(t *testing.T) { @@ -42,7 +42,7 @@ func TestEscrow(t *testing.T) { "SourceTag": 11747 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/fee_settings.go b/xrpl/ledger-entry-types/fee_settings.go similarity index 100% rename from xrpl/model/ledger/fee_settings.go rename to xrpl/ledger-entry-types/fee_settings.go diff --git a/xrpl/model/ledger/fee_settings_test.go b/xrpl/ledger-entry-types/fee_settings_test.go similarity index 81% rename from xrpl/model/ledger/fee_settings_test.go rename to xrpl/ledger-entry-types/fee_settings_test.go index 1e851ff2..cc67154c 100644 --- a/xrpl/model/ledger/fee_settings_test.go +++ b/xrpl/ledger-entry-types/fee_settings_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestFeeSettings(t *testing.T) { @@ -25,7 +25,7 @@ func TestFeeSettings(t *testing.T) { "ReserveIncrement": 5000000 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/ledger_hashes.go b/xrpl/ledger-entry-types/ledger_hashes.go similarity index 80% rename from xrpl/model/ledger/ledger_hashes.go rename to xrpl/ledger-entry-types/ledger_hashes.go index ae63dc7d..6a3460c0 100644 --- a/xrpl/model/ledger/ledger_hashes.go +++ b/xrpl/ledger-entry-types/ledger_hashes.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type LedgerHashes struct { FirstLedgerSequence uint diff --git a/xrpl/model/ledger/ledger_hashes_test.go b/xrpl/ledger-entry-types/ledger_hashes_test.go similarity index 87% rename from xrpl/model/ledger/ledger_hashes_test.go rename to xrpl/ledger-entry-types/ledger_hashes_test.go index 291223ff..880aef7e 100644 --- a/xrpl/model/ledger/ledger_hashes_test.go +++ b/xrpl/ledger-entry-types/ledger_hashes_test.go @@ -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 TestLedgerHashes(t *testing.T) { @@ -36,7 +36,7 @@ func TestLedgerHashes(t *testing.T) { "LedgerEntryType": "LedgerHashes" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/ledger_object.go b/xrpl/ledger-entry-types/ledger_object.go similarity index 100% rename from xrpl/model/ledger/ledger_object.go rename to xrpl/ledger-entry-types/ledger_object.go diff --git a/xrpl/model/ledger/negative_unl.go b/xrpl/ledger-entry-types/negative_unl.go similarity index 100% rename from xrpl/model/ledger/negative_unl.go rename to xrpl/ledger-entry-types/negative_unl.go diff --git a/xrpl/model/ledger/negative_unl_test.go b/xrpl/ledger-entry-types/negative_unl_test.go similarity index 86% rename from xrpl/model/ledger/negative_unl_test.go rename to xrpl/ledger-entry-types/negative_unl_test.go index b0e75444..87695cdb 100644 --- a/xrpl/model/ledger/negative_unl_test.go +++ b/xrpl/ledger-entry-types/negative_unl_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestNegativeUNL(t *testing.T) { @@ -33,7 +33,7 @@ func TestNegativeUNL(t *testing.T) { "LedgerEntryType": "NegativeUNL" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/nftoken_offer.go b/xrpl/ledger-entry-types/nftoken_offer.go similarity index 96% rename from xrpl/model/ledger/nftoken_offer.go rename to xrpl/ledger-entry-types/nftoken_offer.go index 05a51c61..9f05bc0e 100644 --- a/xrpl/model/ledger/nftoken_offer.go +++ b/xrpl/ledger-entry-types/nftoken_offer.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenOffer struct { diff --git a/xrpl/model/ledger/nftoken_offer_test.go b/xrpl/ledger-entry-types/nftoken_offer_test.go similarity index 85% rename from xrpl/model/ledger/nftoken_offer_test.go rename to xrpl/ledger-entry-types/nftoken_offer_test.go index 2bb4691a..b552d1c1 100644 --- a/xrpl/model/ledger/nftoken_offer_test.go +++ b/xrpl/ledger-entry-types/nftoken_offer_test.go @@ -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 TestNFTokenOffer(t *testing.T) { @@ -32,7 +32,7 @@ func TestNFTokenOffer(t *testing.T) { "PreviousTxnLgrSeq": 75443565 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/nftoken_page.go b/xrpl/ledger-entry-types/nftoken_page.go similarity index 85% rename from xrpl/model/ledger/nftoken_page.go rename to xrpl/ledger-entry-types/nftoken_page.go index afa25091..b3761287 100644 --- a/xrpl/model/ledger/nftoken_page.go +++ b/xrpl/ledger-entry-types/nftoken_page.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type NFTokenPage struct { LedgerEntryType LedgerEntryType diff --git a/xrpl/model/ledger/nftoken_page_test.go b/xrpl/ledger-entry-types/nftoken_page_test.go similarity index 85% rename from xrpl/model/ledger/nftoken_page_test.go rename to xrpl/ledger-entry-types/nftoken_page_test.go index afa48b24..9ca4abd0 100644 --- a/xrpl/model/ledger/nftoken_page_test.go +++ b/xrpl/ledger-entry-types/nftoken_page_test.go @@ -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 TestNFTokenPage(t *testing.T) { @@ -32,7 +32,7 @@ func TestNFTokenPage(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/offer.go b/xrpl/ledger-entry-types/offer.go similarity index 96% rename from xrpl/model/ledger/offer.go rename to xrpl/ledger-entry-types/offer.go index 6626db2d..3c791182 100644 --- a/xrpl/model/ledger/offer.go +++ b/xrpl/ledger-entry-types/offer.go @@ -3,7 +3,7 @@ package ledger import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type OfferFlags uint diff --git a/xrpl/model/ledger/offer_test.go b/xrpl/ledger-entry-types/offer_test.go similarity index 88% rename from xrpl/model/ledger/offer_test.go rename to xrpl/ledger-entry-types/offer_test.go index f53321a6..afdecf84 100644 --- a/xrpl/model/ledger/offer_test.go +++ b/xrpl/ledger-entry-types/offer_test.go @@ -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 TestOffer(t *testing.T) { @@ -44,7 +44,7 @@ func TestOffer(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/pay_channel.go b/xrpl/ledger-entry-types/pay_channel.go similarity index 91% rename from xrpl/model/ledger/pay_channel.go rename to xrpl/ledger-entry-types/pay_channel.go index 1e8759c8..6eb16039 100644 --- a/xrpl/model/ledger/pay_channel.go +++ b/xrpl/ledger-entry-types/pay_channel.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type PayChannel struct { Account types.Address diff --git a/xrpl/model/ledger/pay_channel_test.go b/xrpl/ledger-entry-types/pay_channel_test.go similarity index 89% rename from xrpl/model/ledger/pay_channel_test.go rename to xrpl/ledger-entry-types/pay_channel_test.go index 6139a8fe..488b1678 100644 --- a/xrpl/model/ledger/pay_channel_test.go +++ b/xrpl/ledger-entry-types/pay_channel_test.go @@ -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 TestPayChannel(t *testing.T) { @@ -44,7 +44,7 @@ func TestPayChannel(t *testing.T) { "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A", "SettleDelay": 3600 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/ripple_state.go b/xrpl/ledger-entry-types/ripple_state.go similarity index 90% rename from xrpl/model/ledger/ripple_state.go rename to xrpl/ledger-entry-types/ripple_state.go index 37f7ccf2..fcc698f4 100644 --- a/xrpl/model/ledger/ripple_state.go +++ b/xrpl/ledger-entry-types/ripple_state.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" // TODO flags diff --git a/xrpl/model/ledger/ripple_state_test.go b/xrpl/ledger-entry-types/ripple_state_test.go similarity index 89% rename from xrpl/model/ledger/ripple_state_test.go rename to xrpl/ledger-entry-types/ripple_state_test.go index 59100247..b428c0ed 100644 --- a/xrpl/model/ledger/ripple_state_test.go +++ b/xrpl/ledger-entry-types/ripple_state_test.go @@ -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 TestRippleState(t *testing.T) { @@ -56,7 +56,7 @@ func TestRippleState(t *testing.T) { "PreviousTxnLgrSeq": 14090896 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/signer_list.go b/xrpl/ledger-entry-types/signer_list.go similarity index 90% rename from xrpl/model/ledger/signer_list.go rename to xrpl/ledger-entry-types/signer_list.go index 8b9129cb..37f050e2 100644 --- a/xrpl/model/ledger/signer_list.go +++ b/xrpl/ledger-entry-types/signer_list.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type SignerListFlags uint32 diff --git a/xrpl/model/ledger/signer_list_test.go b/xrpl/ledger-entry-types/signer_list_test.go similarity index 92% rename from xrpl/model/ledger/signer_list_test.go rename to xrpl/ledger-entry-types/signer_list_test.go index 1701f047..362b7bbe 100644 --- a/xrpl/model/ledger/signer_list_test.go +++ b/xrpl/ledger-entry-types/signer_list_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestSignerList(t *testing.T) { @@ -67,7 +67,7 @@ func TestSignerList(t *testing.T) { "SignerQuorum": 3 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/ledger/ticket.go b/xrpl/ledger-entry-types/ticket.go similarity index 82% rename from xrpl/model/ledger/ticket.go rename to xrpl/ledger-entry-types/ticket.go index 7f16d9c0..e5193ec3 100644 --- a/xrpl/model/ledger/ticket.go +++ b/xrpl/ledger-entry-types/ticket.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type Ticket struct { Account types.Address diff --git a/xrpl/model/ledger/ticket_test.go b/xrpl/ledger-entry-types/ticket_test.go similarity index 86% rename from xrpl/model/ledger/ticket_test.go rename to xrpl/ledger-entry-types/ticket_test.go index a8fc1e79..c3ab7471 100644 --- a/xrpl/model/ledger/ticket_test.go +++ b/xrpl/ledger-entry-types/ticket_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestTicket(t *testing.T) { @@ -27,7 +27,7 @@ func TestTicket(t *testing.T) { "TicketSequence": 3 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/signing/sign_for_request.go b/xrpl/model/requests/admin/signing/sign_for_request.go deleted file mode 100644 index f418c62c..00000000 --- a/xrpl/model/requests/admin/signing/sign_for_request.go +++ /dev/null @@ -1,20 +0,0 @@ -package signing - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" -) - -type SignForRequest struct { - Account types.Address `json:"account"` - TxJson transactions.FlatTransaction `json:"tx_json"` - Secret string `json:"secret,omitempty"` - Seed string `json:"seed,omitempty"` - SeedHex string `json:"seed_hex,omitempty"` - Passphrase string `json:"passphrase,omitempty"` - KeyType string `json:"key_type,omitempty"` -} - -func (*SignForRequest) Method() string { - return "sign_for" -} diff --git a/xrpl/model/requests/admin/signing/sign_for_response.go b/xrpl/model/requests/admin/signing/sign_for_response.go deleted file mode 100644 index d6516a5a..00000000 --- a/xrpl/model/requests/admin/signing/sign_for_response.go +++ /dev/null @@ -1,10 +0,0 @@ -package signing - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" -) - -type SignForResponse struct { - TxBlob string `json:"tx_blob"` - TxJson transactions.FlatTransaction `json:"tx_json"` -} diff --git a/xrpl/model/requests/admin/signing/sign_request.go b/xrpl/model/requests/admin/signing/sign_request.go deleted file mode 100644 index dd4cd980..00000000 --- a/xrpl/model/requests/admin/signing/sign_request.go +++ /dev/null @@ -1,22 +0,0 @@ -package signing - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" -) - -type SignRequest struct { - TxJson transactions.FlatTransaction `json:"tx_json"` - Secret string `json:"secret,omitempty"` - Seed string `json:"seed,omitempty"` - SeedHex string `json:"seed_hex,omitempty"` - Passphrase string `json:"passphrase,omitempty"` - KeyType string `json:"key_type,omitempty"` - Offline bool `json:"offline,omitempty"` - BuildPath bool `json:"build_path,omitempty"` - FeeMultMax int `json:"fee_mult_max,omitempty"` - FeeDivMax int `json:"fee_div_max,omitempty"` -} - -func (*SignRequest) Method() string { - return "sign" -} diff --git a/xrpl/model/requests/admin/signing/sign_response.go b/xrpl/model/requests/admin/signing/sign_response.go deleted file mode 100644 index 535e1999..00000000 --- a/xrpl/model/requests/admin/signing/sign_response.go +++ /dev/null @@ -1,10 +0,0 @@ -package signing - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" -) - -type SignResponse struct { - TxBlob string `json:"tx_blob"` - TxJson transactions.FlatTransaction `json:"tx_json"` -} diff --git a/xrpl/model/requests/transactions/submit_multisigned_request.go b/xrpl/model/requests/transactions/submit_multisigned_request.go deleted file mode 100644 index 84b0e68c..00000000 --- a/xrpl/model/requests/transactions/submit_multisigned_request.go +++ /dev/null @@ -1,14 +0,0 @@ -package transactions - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" -) - -type SubmitMultisignedRequest struct { - Tx transactions.FlatTransaction `json:"tx_json"` - FailHard bool `json:"fail_hard"` -} - -func (*SubmitMultisignedRequest) Method() string { - return "submit_multisigned" -} diff --git a/xrpl/model/requests/transactions/submit_multisigned_response.go b/xrpl/model/requests/transactions/submit_multisigned_response.go deleted file mode 100644 index b626f923..00000000 --- a/xrpl/model/requests/transactions/submit_multisigned_response.go +++ /dev/null @@ -1,13 +0,0 @@ -package transactions - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" -) - -type SubmitMultisignedResponse struct { - EngineResult string `json:"engine_result"` - EngineResultCode int `json:"engine_result_code"` - EngineResultMessage string `json:"engine_result_message"` - TxBlob string `json:"tx_blob"` - Tx transactions.FlatTransaction `json:"tx_json"` -} diff --git a/xrpl/model/requests/transactions/submit_response.go b/xrpl/model/requests/transactions/submit_response.go deleted file mode 100644 index fdbc9c2b..00000000 --- a/xrpl/model/requests/transactions/submit_response.go +++ /dev/null @@ -1,23 +0,0 @@ -package transactions - -import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" -) - -type SubmitResponse struct { - EngineResult string `json:"engine_result"` - EngineResultCode int `json:"engine_result_code"` - EngineResultMessage string `json:"engine_result_message"` - TxBlob string `json:"tx_blob"` - Tx transactions.FlatTransaction `json:"tx_json"` - Accepted bool `json:"accepted"` - AccountSequenceAvailable uint `json:"account_sequence_available"` - AccountSequenceNext uint `json:"account_sequence_next"` - Applied bool `json:"applied"` - Broadcast bool `json:"broadcast"` - Kept bool `json:"kept"` - Queued bool `json:"queued"` - OpenLedgerCost string `json:"open_ledger_cost"` - ValidatedLedgerIndex common.LedgerIndex `json:"validated_ledger_index"` -} diff --git a/xrpl/model/requests/account/account_channels_request.go b/xrpl/queries/account/account_channels_request.go similarity index 93% rename from xrpl/model/requests/account/account_channels_request.go rename to xrpl/queries/account/account_channels_request.go index 35fbe11f..403db3df 100644 --- a/xrpl/model/requests/account/account_channels_request.go +++ b/xrpl/queries/account/account_channels_request.go @@ -4,8 +4,8 @@ import ( "encoding/json" "errors" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountChannelsRequest struct { diff --git a/xrpl/model/requests/account/account_channels_response.go b/xrpl/queries/account/account_channels_response.go similarity index 79% rename from xrpl/model/requests/account/account_channels_response.go rename to xrpl/queries/account/account_channels_response.go index 6918eb72..40307de8 100644 --- a/xrpl/model/requests/account/account_channels_response.go +++ b/xrpl/queries/account/account_channels_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountChannelsResponse struct { diff --git a/xrpl/model/requests/account/account_channels_test.go b/xrpl/queries/account/account_channels_test.go similarity index 86% rename from xrpl/model/requests/account/account_channels_test.go rename to xrpl/queries/account/account_channels_test.go index 59f67261..ebfaa2c6 100644 --- a/xrpl/model/requests/account/account_channels_test.go +++ b/xrpl/queries/account/account_channels_test.go @@ -3,8 +3,8 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" "github.com/stretchr/testify/assert" ) @@ -20,7 +20,7 @@ func TestAccountChannelRequest(t *testing.T) { "destination_account": "rnZvsWuLem5Ha46AZs61jLWR9R5esinkG3", "ledger_index": "validated" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } @@ -60,7 +60,7 @@ func TestAccountChannelsResponse(t *testing.T) { "validated": true, "limit": 1 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_currencies_request.go b/xrpl/queries/account/account_currencies_request.go similarity index 90% rename from xrpl/model/requests/account/account_currencies_request.go rename to xrpl/queries/account/account_currencies_request.go index f996e3f8..6f129ec9 100644 --- a/xrpl/model/requests/account/account_currencies_request.go +++ b/xrpl/queries/account/account_currencies_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountCurrenciesRequest struct { diff --git a/xrpl/model/requests/account/account_currencies_response.go b/xrpl/queries/account/account_currencies_response.go similarity index 86% rename from xrpl/model/requests/account/account_currencies_response.go rename to xrpl/queries/account/account_currencies_response.go index 48eb02f0..374de454 100644 --- a/xrpl/model/requests/account/account_currencies_response.go +++ b/xrpl/queries/account/account_currencies_response.go @@ -1,7 +1,7 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type AccountCurrenciesResponse struct { diff --git a/xrpl/model/requests/account/account_currencies_test.go b/xrpl/queries/account/account_currencies_test.go similarity index 77% rename from xrpl/model/requests/account/account_currencies_test.go rename to xrpl/queries/account/account_currencies_test.go index 192ffe2c..070831d7 100644 --- a/xrpl/model/requests/account/account_currencies_test.go +++ b/xrpl/queries/account/account_currencies_test.go @@ -3,8 +3,8 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestAccountCurrenciesRequest(t *testing.T) { @@ -19,7 +19,7 @@ func TestAccountCurrenciesRequest(t *testing.T) { "ledger_index": 1234, "strict": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -51,7 +51,7 @@ func TestAccountCurrenciesResponse(t *testing.T) { ], "validated": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_info_request.go b/xrpl/queries/account/account_info_request.go similarity index 92% rename from xrpl/model/requests/account/account_info_request.go rename to xrpl/queries/account/account_info_request.go index eb4045a8..c0b37239 100644 --- a/xrpl/model/requests/account/account_info_request.go +++ b/xrpl/queries/account/account_info_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountInfoRequest struct { diff --git a/xrpl/model/requests/account/account_info_response.go b/xrpl/queries/account/account_info_response.go similarity index 81% rename from xrpl/model/requests/account/account_info_response.go rename to xrpl/queries/account/account_info_response.go index d336dc31..d732d7f9 100644 --- a/xrpl/model/requests/account/account_info_response.go +++ b/xrpl/queries/account/account_info_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type AccountInfoResponse struct { diff --git a/xrpl/model/requests/account/account_info_test.go b/xrpl/queries/account/account_info_test.go similarity index 87% rename from xrpl/model/requests/account/account_info_test.go rename to xrpl/queries/account/account_info_test.go index c2776b34..629b4a41 100644 --- a/xrpl/model/requests/account/account_info_test.go +++ b/xrpl/queries/account/account_info_test.go @@ -3,10 +3,10 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestAccountInfoRequest(t *testing.T) { @@ -25,7 +25,7 @@ func TestAccountInfoRequest(t *testing.T) { "queue": true, "strict": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -106,7 +106,7 @@ func TestAccountInfoResponse(t *testing.T) { }, "validated": false }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_lines_request.go b/xrpl/queries/account/account_lines_request.go similarity index 92% rename from xrpl/model/requests/account/account_lines_request.go rename to xrpl/queries/account/account_lines_request.go index e879ce1f..600fb0d0 100644 --- a/xrpl/model/requests/account/account_lines_request.go +++ b/xrpl/queries/account/account_lines_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountLinesRequest struct { diff --git a/xrpl/model/requests/account/account_lines_response.go b/xrpl/queries/account/account_lines_response.go similarity index 79% rename from xrpl/model/requests/account/account_lines_response.go rename to xrpl/queries/account/account_lines_response.go index 94e05713..947bd8b9 100644 --- a/xrpl/model/requests/account/account_lines_response.go +++ b/xrpl/queries/account/account_lines_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountLinesResponse struct { diff --git a/xrpl/model/requests/account/account_lines_test.go b/xrpl/queries/account/account_lines_test.go similarity index 86% rename from xrpl/model/requests/account/account_lines_test.go rename to xrpl/queries/account/account_lines_test.go index fe22d56d..b3b04ea5 100644 --- a/xrpl/model/requests/account/account_lines_test.go +++ b/xrpl/queries/account/account_lines_test.go @@ -3,8 +3,8 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestAccountLinesRequest(t *testing.T) { @@ -28,7 +28,7 @@ func TestAccountLinesRequest(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -70,7 +70,7 @@ func TestAccountLinesResponse(t *testing.T) { "ledger_hash": "abc" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_nfts_request.go b/xrpl/queries/account/account_nfts_request.go similarity index 90% rename from xrpl/model/requests/account/account_nfts_request.go rename to xrpl/queries/account/account_nfts_request.go index 0b7d0144..0c7f4875 100644 --- a/xrpl/model/requests/account/account_nfts_request.go +++ b/xrpl/queries/account/account_nfts_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountNFTsRequest struct { diff --git a/xrpl/model/requests/account/account_nfts_response.go b/xrpl/queries/account/account_nfts_response.go similarity index 79% rename from xrpl/model/requests/account/account_nfts_response.go rename to xrpl/queries/account/account_nfts_response.go index f2c7c104..e71990e8 100644 --- a/xrpl/model/requests/account/account_nfts_response.go +++ b/xrpl/queries/account/account_nfts_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountNFTsResponse struct { diff --git a/xrpl/model/requests/account/account_nfts_test.go b/xrpl/queries/account/account_nfts_test.go similarity index 83% rename from xrpl/model/requests/account/account_nfts_test.go rename to xrpl/queries/account/account_nfts_test.go index 274e457c..57ff96bf 100644 --- a/xrpl/model/requests/account/account_nfts_test.go +++ b/xrpl/queries/account/account_nfts_test.go @@ -3,8 +3,8 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestAccountNFTsRequest(t *testing.T) { @@ -21,7 +21,7 @@ func TestAccountNFTsRequest(t *testing.T) { "ledger_hash": "123", "limit": 2 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -61,7 +61,7 @@ func TestAccountNFTsResponse(t *testing.T) { "ledger_current_index": 1234, "validated": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_objects_request.go b/xrpl/queries/account/account_objects_request.go similarity index 95% rename from xrpl/model/requests/account/account_objects_request.go rename to xrpl/queries/account/account_objects_request.go index d90f53f4..40801e65 100644 --- a/xrpl/model/requests/account/account_objects_request.go +++ b/xrpl/queries/account/account_objects_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountObjectType string diff --git a/xrpl/model/requests/account/account_objects_response.go b/xrpl/queries/account/account_objects_response.go similarity index 81% rename from xrpl/model/requests/account/account_objects_response.go rename to xrpl/queries/account/account_objects_response.go index 4e11b990..41d60ce8 100644 --- a/xrpl/model/requests/account/account_objects_response.go +++ b/xrpl/queries/account/account_objects_response.go @@ -1,9 +1,9 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( diff --git a/xrpl/model/requests/account/account_objects_test.go b/xrpl/queries/account/account_objects_test.go similarity index 69% rename from xrpl/model/requests/account/account_objects_test.go rename to xrpl/queries/account/account_objects_test.go index f68b2182..093bf1e0 100644 --- a/xrpl/model/requests/account/account_objects_test.go +++ b/xrpl/queries/account/account_objects_test.go @@ -3,8 +3,8 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestAccountObjectsRequest(t *testing.T) { @@ -19,7 +19,7 @@ func TestAccountObjectsRequest(t *testing.T) { "type": "signer_list", "ledger_index": 123 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_offers_request.go b/xrpl/queries/account/account_offers_request.go similarity index 91% rename from xrpl/model/requests/account/account_offers_request.go rename to xrpl/queries/account/account_offers_request.go index 686d8c91..0b9006f3 100644 --- a/xrpl/model/requests/account/account_offers_request.go +++ b/xrpl/queries/account/account_offers_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountOffersRequest struct { diff --git a/xrpl/model/requests/account/account_offers_response.go b/xrpl/queries/account/account_offers_response.go similarity index 79% rename from xrpl/model/requests/account/account_offers_response.go rename to xrpl/queries/account/account_offers_response.go index c1b8449b..ef6b2529 100644 --- a/xrpl/model/requests/account/account_offers_response.go +++ b/xrpl/queries/account/account_offers_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountOffersResponse struct { diff --git a/xrpl/model/requests/account/account_offers_test.go b/xrpl/queries/account/account_offers_test.go similarity index 79% rename from xrpl/model/requests/account/account_offers_test.go rename to xrpl/queries/account/account_offers_test.go index 85321491..2f4a5190 100644 --- a/xrpl/model/requests/account/account_offers_test.go +++ b/xrpl/queries/account/account_offers_test.go @@ -3,9 +3,9 @@ package account import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestAccountOffersRequest(t *testing.T) { @@ -19,7 +19,7 @@ func TestAccountOffersRequest(t *testing.T) { "ledger_index": 10, "marker": "123" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } @@ -65,7 +65,7 @@ func TestAccountOffersResponse(t *testing.T) { "ledger_index": 54320, "ledger_hash": "def" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/account/account_transaction.go b/xrpl/queries/account/account_transaction.go similarity index 87% rename from xrpl/model/requests/account/account_transaction.go rename to xrpl/queries/account/account_transaction.go index 98cd9a14..33ce68bd 100644 --- a/xrpl/model/requests/account/account_transaction.go +++ b/xrpl/queries/account/account_transaction.go @@ -1,7 +1,7 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" + transactions "github.com/Peersyst/xrpl-go/xrpl/transaction" ) const ( diff --git a/xrpl/model/requests/account/account_transactions_request.go b/xrpl/queries/account/account_transactions_request.go similarity index 94% rename from xrpl/model/requests/account/account_transactions_request.go rename to xrpl/queries/account/account_transactions_request.go index 74b30190..e32d37f5 100644 --- a/xrpl/model/requests/account/account_transactions_request.go +++ b/xrpl/queries/account/account_transactions_request.go @@ -3,8 +3,8 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountTransactionsRequest struct { diff --git a/xrpl/model/requests/account/account_transactions_response.go b/xrpl/queries/account/account_transactions_response.go similarity index 80% rename from xrpl/model/requests/account/account_transactions_response.go rename to xrpl/queries/account/account_transactions_response.go index dcb3eea1..ebd7500f 100644 --- a/xrpl/model/requests/account/account_transactions_response.go +++ b/xrpl/queries/account/account_transactions_response.go @@ -1,8 +1,8 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountTransactionsResponse struct { diff --git a/xrpl/model/requests/account/channel_result.go b/xrpl/queries/account/channel_result.go similarity index 93% rename from xrpl/model/requests/account/channel_result.go rename to xrpl/queries/account/channel_result.go index 76022b5a..d049bd2e 100644 --- a/xrpl/model/requests/account/channel_result.go +++ b/xrpl/queries/account/channel_result.go @@ -1,7 +1,7 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type ChannelResult struct { diff --git a/xrpl/model/requests/account/nft.go b/xrpl/queries/account/nft.go similarity index 86% rename from xrpl/model/requests/account/nft.go rename to xrpl/queries/account/nft.go index 9ddf9de4..07c8042b 100644 --- a/xrpl/model/requests/account/nft.go +++ b/xrpl/queries/account/nft.go @@ -1,7 +1,7 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( diff --git a/xrpl/model/requests/account/offer_result.go b/xrpl/queries/account/offer_result.go similarity index 95% rename from xrpl/model/requests/account/offer_result.go rename to xrpl/queries/account/offer_result.go index 0cfe07ea..07fccf74 100644 --- a/xrpl/model/requests/account/offer_result.go +++ b/xrpl/queries/account/offer_result.go @@ -3,7 +3,7 @@ package account import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type OfferResultFlags uint diff --git a/xrpl/model/requests/account/queue_data.go b/xrpl/queries/account/queue_data.go similarity index 88% rename from xrpl/model/requests/account/queue_data.go rename to xrpl/queries/account/queue_data.go index 5af905e2..d7f0c8d9 100644 --- a/xrpl/model/requests/account/queue_data.go +++ b/xrpl/queries/account/queue_data.go @@ -1,6 +1,6 @@ package account -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type QueueData struct { TxnCount uint64 `json:"txn_count"` diff --git a/xrpl/model/requests/account/queue_transaction.go b/xrpl/queries/account/queue_transaction.go similarity index 84% rename from xrpl/model/requests/account/queue_transaction.go rename to xrpl/queries/account/queue_transaction.go index 978226f0..fcd8d25f 100644 --- a/xrpl/model/requests/account/queue_transaction.go +++ b/xrpl/queries/account/queue_transaction.go @@ -1,6 +1,6 @@ package account -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type QueueTransaction struct { AuthChange bool `json:"auth_change"` diff --git a/xrpl/model/requests/account/trust_line.go b/xrpl/queries/account/trust_line.go similarity index 92% rename from xrpl/model/requests/account/trust_line.go rename to xrpl/queries/account/trust_line.go index 5294c8a1..ee23bcd7 100644 --- a/xrpl/model/requests/account/trust_line.go +++ b/xrpl/queries/account/trust_line.go @@ -1,7 +1,7 @@ package account import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type TrustLine struct { diff --git a/xrpl/model/requests/admin/data/can_delete_request.go b/xrpl/queries/admin/data/can_delete_request.go similarity index 89% rename from xrpl/model/requests/admin/data/can_delete_request.go rename to xrpl/queries/admin/data/can_delete_request.go index 7dd632a2..6ab24e31 100644 --- a/xrpl/model/requests/admin/data/can_delete_request.go +++ b/xrpl/queries/admin/data/can_delete_request.go @@ -3,7 +3,7 @@ package data import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type CanDeleteRequest struct { diff --git a/xrpl/model/requests/admin/data/can_delete_response.go b/xrpl/queries/admin/data/can_delete_response.go similarity index 100% rename from xrpl/model/requests/admin/data/can_delete_response.go rename to xrpl/queries/admin/data/can_delete_response.go diff --git a/xrpl/model/requests/admin/data/can_delete_test.go b/xrpl/queries/admin/data/can_delete_test.go similarity index 60% rename from xrpl/model/requests/admin/data/can_delete_test.go rename to xrpl/queries/admin/data/can_delete_test.go index 2c24659f..549a2772 100644 --- a/xrpl/model/requests/admin/data/can_delete_test.go +++ b/xrpl/queries/admin/data/can_delete_test.go @@ -3,8 +3,8 @@ package data import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestCanDeleteRequest(t *testing.T) { @@ -16,7 +16,7 @@ func TestCanDeleteRequest(t *testing.T) { "can_delete": "current" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -25,7 +25,7 @@ func TestCanDeleteRequestEmpty(t *testing.T) { j := `{}` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -38,7 +38,7 @@ func TestCanDeleteResponse(t *testing.T) { "can_delete": 54321 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/data/crawl_shards_request.go b/xrpl/queries/admin/data/crawl_shards_request.go similarity index 100% rename from xrpl/model/requests/admin/data/crawl_shards_request.go rename to xrpl/queries/admin/data/crawl_shards_request.go diff --git a/xrpl/model/requests/admin/data/crawl_shards_response.go b/xrpl/queries/admin/data/crawl_shards_response.go similarity index 100% rename from xrpl/model/requests/admin/data/crawl_shards_response.go rename to xrpl/queries/admin/data/crawl_shards_response.go diff --git a/xrpl/model/requests/admin/data/crawl_shards_test.go b/xrpl/queries/admin/data/crawl_shards_test.go similarity index 85% rename from xrpl/model/requests/admin/data/crawl_shards_test.go rename to xrpl/queries/admin/data/crawl_shards_test.go index c1323743..78cefd0b 100644 --- a/xrpl/model/requests/admin/data/crawl_shards_test.go +++ b/xrpl/queries/admin/data/crawl_shards_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestCrawlShardsRequest(t *testing.T) { @@ -17,7 +17,7 @@ func TestCrawlShardsRequest(t *testing.T) { "limit": 1 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -51,7 +51,7 @@ func TestCrawlShardsResponse(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/data/download_shard_request.go b/xrpl/queries/admin/data/download_shard_request.go similarity index 81% rename from xrpl/model/requests/admin/data/download_shard_request.go rename to xrpl/queries/admin/data/download_shard_request.go index ca0924ed..7849a354 100644 --- a/xrpl/model/requests/admin/data/download_shard_request.go +++ b/xrpl/queries/admin/data/download_shard_request.go @@ -1,6 +1,6 @@ package data -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type DownloadShardRequest struct { Shards []ShardDescriptor `json:"shards"` diff --git a/xrpl/model/requests/admin/data/download_shard_response.go b/xrpl/queries/admin/data/download_shard_response.go similarity index 100% rename from xrpl/model/requests/admin/data/download_shard_response.go rename to xrpl/queries/admin/data/download_shard_response.go diff --git a/xrpl/model/requests/admin/data/download_shard_test.go b/xrpl/queries/admin/data/download_shard_test.go similarity index 81% rename from xrpl/model/requests/admin/data/download_shard_test.go rename to xrpl/queries/admin/data/download_shard_test.go index 9b1a24d3..092747af 100644 --- a/xrpl/model/requests/admin/data/download_shard_test.go +++ b/xrpl/queries/admin/data/download_shard_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestDownloadShardsRequest(t *testing.T) { @@ -41,7 +41,7 @@ func TestDownloadShardsRequest(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -54,7 +54,7 @@ func TestDownloadShardsResponse(t *testing.T) { "message": "downloading shards 1-3" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/data/ledger_cleaner_request.go b/xrpl/queries/admin/data/ledger_cleaner_request.go similarity index 89% rename from xrpl/model/requests/admin/data/ledger_cleaner_request.go rename to xrpl/queries/admin/data/ledger_cleaner_request.go index 70c9fc2d..635e9e95 100644 --- a/xrpl/model/requests/admin/data/ledger_cleaner_request.go +++ b/xrpl/queries/admin/data/ledger_cleaner_request.go @@ -1,6 +1,6 @@ package data -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type LedgerCleanerRequest struct { Ledger common.LedgerIndex `json:"ledger,omitempty"` diff --git a/xrpl/model/requests/admin/data/ledger_cleaner_response.go b/xrpl/queries/admin/data/ledger_cleaner_response.go similarity index 100% rename from xrpl/model/requests/admin/data/ledger_cleaner_response.go rename to xrpl/queries/admin/data/ledger_cleaner_response.go diff --git a/xrpl/model/requests/admin/data/ledger_cleaner_test.go b/xrpl/queries/admin/data/ledger_cleaner_test.go similarity index 71% rename from xrpl/model/requests/admin/data/ledger_cleaner_test.go rename to xrpl/queries/admin/data/ledger_cleaner_test.go index 515062e2..71c34609 100644 --- a/xrpl/model/requests/admin/data/ledger_cleaner_test.go +++ b/xrpl/queries/admin/data/ledger_cleaner_test.go @@ -3,7 +3,7 @@ package data import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestLedgerCleanerRequest(t *testing.T) { @@ -21,7 +21,7 @@ func TestLedgerCleanerRequest(t *testing.T) { "stop": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -35,7 +35,7 @@ func TestLedgerCleanerResponse(t *testing.T) { "message": "Cleaner configured" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/data/ledger_request_request.go b/xrpl/queries/admin/data/ledger_request_request.go similarity index 79% rename from xrpl/model/requests/admin/data/ledger_request_request.go rename to xrpl/queries/admin/data/ledger_request_request.go index c17ec846..dc17950d 100644 --- a/xrpl/model/requests/admin/data/ledger_request_request.go +++ b/xrpl/queries/admin/data/ledger_request_request.go @@ -1,6 +1,6 @@ package data -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type LedgerRequestRequest struct { LedgerIndex common.LedgerIndex `json:"ledger_index,omitempty"` diff --git a/xrpl/model/requests/admin/data/ledger_request_response.go b/xrpl/queries/admin/data/ledger_request_response.go similarity index 93% rename from xrpl/model/requests/admin/data/ledger_request_response.go rename to xrpl/queries/admin/data/ledger_request_response.go index e81c1b47..22c5a090 100644 --- a/xrpl/model/requests/admin/data/ledger_request_response.go +++ b/xrpl/queries/admin/data/ledger_request_response.go @@ -3,8 +3,8 @@ package data import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/ledger" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/ledger" ) type LedgerRequestResponse struct { diff --git a/xrpl/model/requests/admin/data/ledger_request_test.go b/xrpl/queries/admin/data/ledger_request_test.go similarity index 93% rename from xrpl/model/requests/admin/data/ledger_request_test.go rename to xrpl/queries/admin/data/ledger_request_test.go index 9a9a41fe..07e63b1b 100644 --- a/xrpl/model/requests/admin/data/ledger_request_test.go +++ b/xrpl/queries/admin/data/ledger_request_test.go @@ -3,9 +3,9 @@ package data import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/ledger" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestLedgerRequestRequest(t *testing.T) { @@ -19,7 +19,7 @@ func TestLedgerRequestRequest(t *testing.T) { "ledger_hash": "abcd" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -43,7 +43,7 @@ func TestLedgerRequestErrorResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -123,7 +123,7 @@ func TestLedgerRequestPartialResponse(t *testing.T) { "timeouts": 1 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -161,7 +161,7 @@ func TestLedgerRequestCompleteResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/requests/admin/data/log_level_request.go b/xrpl/queries/admin/data/log_level_request.go similarity index 100% rename from xrpl/model/requests/admin/data/log_level_request.go rename to xrpl/queries/admin/data/log_level_request.go diff --git a/xrpl/model/requests/admin/data/log_level_response.go b/xrpl/queries/admin/data/log_level_response.go similarity index 100% rename from xrpl/model/requests/admin/data/log_level_response.go rename to xrpl/queries/admin/data/log_level_response.go diff --git a/xrpl/model/requests/admin/data/logrotate_request.go b/xrpl/queries/admin/data/logrotate_request.go similarity index 100% rename from xrpl/model/requests/admin/data/logrotate_request.go rename to xrpl/queries/admin/data/logrotate_request.go diff --git a/xrpl/model/requests/admin/data/logrotate_response.go b/xrpl/queries/admin/data/logrotate_response.go similarity index 100% rename from xrpl/model/requests/admin/data/logrotate_response.go rename to xrpl/queries/admin/data/logrotate_response.go diff --git a/xrpl/model/requests/admin/data/node_to_shard_request.go b/xrpl/queries/admin/data/node_to_shard_request.go similarity index 100% rename from xrpl/model/requests/admin/data/node_to_shard_request.go rename to xrpl/queries/admin/data/node_to_shard_request.go diff --git a/xrpl/model/requests/admin/data/node_to_shard_response.go b/xrpl/queries/admin/data/node_to_shard_response.go similarity index 100% rename from xrpl/model/requests/admin/data/node_to_shard_response.go rename to xrpl/queries/admin/data/node_to_shard_response.go diff --git a/xrpl/model/requests/admin/key/validation_create_request.go b/xrpl/queries/admin/key/validation_create_request.go similarity index 100% rename from xrpl/model/requests/admin/key/validation_create_request.go rename to xrpl/queries/admin/key/validation_create_request.go diff --git a/xrpl/model/requests/admin/key/validation_create_response.go b/xrpl/queries/admin/key/validation_create_response.go similarity index 100% rename from xrpl/model/requests/admin/key/validation_create_response.go rename to xrpl/queries/admin/key/validation_create_response.go diff --git a/xrpl/model/requests/admin/key/validation_create_test.go b/xrpl/queries/admin/key/validation_create_test.go similarity index 80% rename from xrpl/model/requests/admin/key/validation_create_test.go rename to xrpl/queries/admin/key/validation_create_test.go index c1b82454..1cfd973a 100644 --- a/xrpl/model/requests/admin/key/validation_create_test.go +++ b/xrpl/queries/admin/key/validation_create_test.go @@ -3,7 +3,7 @@ package key import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestValidationCreateRequest(t *testing.T) { @@ -14,7 +14,7 @@ func TestValidationCreateRequest(t *testing.T) { j := `{ "secret": "abc" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -32,7 +32,7 @@ func TestValidationCreateResponse(t *testing.T) { "validation_seed": "ssZkdwURFMBXenJPbrpE14b6noJSu" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/requests/admin/key/wallet_propose_request.go b/xrpl/queries/admin/key/wallet_propose_request.go similarity index 100% rename from xrpl/model/requests/admin/key/wallet_propose_request.go rename to xrpl/queries/admin/key/wallet_propose_request.go diff --git a/xrpl/model/requests/admin/key/wallet_propose_response.go b/xrpl/queries/admin/key/wallet_propose_response.go similarity index 85% rename from xrpl/model/requests/admin/key/wallet_propose_response.go rename to xrpl/queries/admin/key/wallet_propose_response.go index 8a66fc9c..28796a4a 100644 --- a/xrpl/model/requests/admin/key/wallet_propose_response.go +++ b/xrpl/queries/admin/key/wallet_propose_response.go @@ -1,6 +1,6 @@ package key -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type WalletProposeResponse struct { KeyType string `json:"key_type"` diff --git a/xrpl/model/requests/admin/key/wallet_propose_test.go b/xrpl/queries/admin/key/wallet_propose_test.go similarity index 85% rename from xrpl/model/requests/admin/key/wallet_propose_test.go rename to xrpl/queries/admin/key/wallet_propose_test.go index ea9aeb4d..685a834b 100644 --- a/xrpl/model/requests/admin/key/wallet_propose_test.go +++ b/xrpl/queries/admin/key/wallet_propose_test.go @@ -3,7 +3,7 @@ package key import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestWalletProposeRequest(t *testing.T) { @@ -17,7 +17,7 @@ func TestWalletProposeRequest(t *testing.T) { "seed": "snoPBrXtMeMyMHUVTgbuqAfg1SUTb" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -41,7 +41,7 @@ func TestWalletProposeResponse(t *testing.T) { "public_key_hex": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/peer/connect_request.go b/xrpl/queries/admin/peer/connect_request.go similarity index 100% rename from xrpl/model/requests/admin/peer/connect_request.go rename to xrpl/queries/admin/peer/connect_request.go diff --git a/xrpl/model/requests/admin/peer/connect_response.go b/xrpl/queries/admin/peer/connect_response.go similarity index 100% rename from xrpl/model/requests/admin/peer/connect_response.go rename to xrpl/queries/admin/peer/connect_response.go diff --git a/xrpl/model/requests/admin/peer/peer_reservation.go b/xrpl/queries/admin/peer/peer_reservation.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservation.go rename to xrpl/queries/admin/peer/peer_reservation.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_add_request.go b/xrpl/queries/admin/peer/peer_reservations_add_request.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservations_add_request.go rename to xrpl/queries/admin/peer/peer_reservations_add_request.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_add_response.go b/xrpl/queries/admin/peer/peer_reservations_add_response.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservations_add_response.go rename to xrpl/queries/admin/peer/peer_reservations_add_response.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_del_request.go b/xrpl/queries/admin/peer/peer_reservations_del_request.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservations_del_request.go rename to xrpl/queries/admin/peer/peer_reservations_del_request.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_del_response.go b/xrpl/queries/admin/peer/peer_reservations_del_response.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservations_del_response.go rename to xrpl/queries/admin/peer/peer_reservations_del_response.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_list_request.go b/xrpl/queries/admin/peer/peer_reservations_list_request.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservations_list_request.go rename to xrpl/queries/admin/peer/peer_reservations_list_request.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_list_response.go b/xrpl/queries/admin/peer/peer_reservations_list_response.go similarity index 100% rename from xrpl/model/requests/admin/peer/peer_reservations_list_response.go rename to xrpl/queries/admin/peer/peer_reservations_list_response.go diff --git a/xrpl/model/requests/admin/peer/peer_reservations_list_test.go b/xrpl/queries/admin/peer/peer_reservations_list_test.go similarity index 84% rename from xrpl/model/requests/admin/peer/peer_reservations_list_test.go rename to xrpl/queries/admin/peer/peer_reservations_list_test.go index a35f892f..9166c870 100644 --- a/xrpl/model/requests/admin/peer/peer_reservations_list_test.go +++ b/xrpl/queries/admin/peer/peer_reservations_list_test.go @@ -3,7 +3,7 @@ package peer import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestPeerReservationsListResponse(t *testing.T) { @@ -31,7 +31,7 @@ func TestPeerReservationsListResponse(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/peer/peers_request.go b/xrpl/queries/admin/peer/peers_request.go similarity index 100% rename from xrpl/model/requests/admin/peer/peers_request.go rename to xrpl/queries/admin/peer/peers_request.go diff --git a/xrpl/model/requests/admin/peer/peers_response.go b/xrpl/queries/admin/peer/peers_response.go similarity index 100% rename from xrpl/model/requests/admin/peer/peers_response.go rename to xrpl/queries/admin/peer/peers_response.go diff --git a/xrpl/model/requests/admin/peer/peers_test.go b/xrpl/queries/admin/peer/peers_test.go similarity index 95% rename from xrpl/model/requests/admin/peer/peers_test.go rename to xrpl/queries/admin/peer/peers_test.go index bf281c65..b5669844 100644 --- a/xrpl/model/requests/admin/peer/peers_test.go +++ b/xrpl/queries/admin/peer/peers_test.go @@ -3,7 +3,7 @@ package peer import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestPeersResponse(t *testing.T) { @@ -81,7 +81,7 @@ func TestPeersResponse(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/server/ledger_accept_request.go b/xrpl/queries/admin/server/ledger_accept_request.go similarity index 100% rename from xrpl/model/requests/admin/server/ledger_accept_request.go rename to xrpl/queries/admin/server/ledger_accept_request.go diff --git a/xrpl/model/requests/admin/server/ledger_accept_response.go b/xrpl/queries/admin/server/ledger_accept_response.go similarity index 65% rename from xrpl/model/requests/admin/server/ledger_accept_response.go rename to xrpl/queries/admin/server/ledger_accept_response.go index 247895db..92b30f63 100644 --- a/xrpl/model/requests/admin/server/ledger_accept_response.go +++ b/xrpl/queries/admin/server/ledger_accept_response.go @@ -1,6 +1,6 @@ package server -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type LedgerAcceptResponse struct { LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"` diff --git a/xrpl/model/requests/admin/server/stop_request.go b/xrpl/queries/admin/server/stop_request.go similarity index 100% rename from xrpl/model/requests/admin/server/stop_request.go rename to xrpl/queries/admin/server/stop_request.go diff --git a/xrpl/model/requests/admin/server/stop_response.go b/xrpl/queries/admin/server/stop_response.go similarity index 100% rename from xrpl/model/requests/admin/server/stop_response.go rename to xrpl/queries/admin/server/stop_response.go diff --git a/xrpl/queries/admin/signing/sign_for_request.go b/xrpl/queries/admin/signing/sign_for_request.go new file mode 100644 index 00000000..39ad9ceb --- /dev/null +++ b/xrpl/queries/admin/signing/sign_for_request.go @@ -0,0 +1,20 @@ +package signing + +import ( + "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" +) + +type SignForRequest struct { + Account types.Address `json:"account"` + TxJson transaction.FlatTransaction `json:"tx_json"` + Secret string `json:"secret,omitempty"` + Seed string `json:"seed,omitempty"` + SeedHex string `json:"seed_hex,omitempty"` + Passphrase string `json:"passphrase,omitempty"` + KeyType string `json:"key_type,omitempty"` +} + +func (*SignForRequest) Method() string { + return "sign_for" +} diff --git a/xrpl/queries/admin/signing/sign_for_response.go b/xrpl/queries/admin/signing/sign_for_response.go new file mode 100644 index 00000000..1c5811ea --- /dev/null +++ b/xrpl/queries/admin/signing/sign_for_response.go @@ -0,0 +1,8 @@ +package signing + +import "github.com/Peersyst/xrpl-go/xrpl/transaction" + +type SignForResponse struct { + TxBlob string `json:"tx_blob"` + TxJson transaction.FlatTransaction `json:"tx_json"` +} diff --git a/xrpl/queries/admin/signing/sign_request.go b/xrpl/queries/admin/signing/sign_request.go new file mode 100644 index 00000000..d1a4b0c2 --- /dev/null +++ b/xrpl/queries/admin/signing/sign_request.go @@ -0,0 +1,20 @@ +package signing + +import "github.com/Peersyst/xrpl-go/xrpl/transaction" + +type SignRequest struct { + TxJson transaction.FlatTransaction `json:"tx_json"` + Secret string `json:"secret,omitempty"` + Seed string `json:"seed,omitempty"` + SeedHex string `json:"seed_hex,omitempty"` + Passphrase string `json:"passphrase,omitempty"` + KeyType string `json:"key_type,omitempty"` + Offline bool `json:"offline,omitempty"` + BuildPath bool `json:"build_path,omitempty"` + FeeMultMax int `json:"fee_mult_max,omitempty"` + FeeDivMax int `json:"fee_div_max,omitempty"` +} + +func (*SignRequest) Method() string { + return "sign" +} diff --git a/xrpl/queries/admin/signing/sign_response.go b/xrpl/queries/admin/signing/sign_response.go new file mode 100644 index 00000000..f18fbf48 --- /dev/null +++ b/xrpl/queries/admin/signing/sign_response.go @@ -0,0 +1,8 @@ +package signing + +import "github.com/Peersyst/xrpl-go/xrpl/transaction" + +type SignResponse struct { + TxBlob string `json:"tx_blob"` + TxJson transaction.FlatTransaction `json:"tx_json"` +} diff --git a/xrpl/model/requests/admin/status/consensus_info_request.go b/xrpl/queries/admin/status/consensus_info_request.go similarity index 100% rename from xrpl/model/requests/admin/status/consensus_info_request.go rename to xrpl/queries/admin/status/consensus_info_request.go diff --git a/xrpl/model/requests/admin/status/consensus_info_response.go b/xrpl/queries/admin/status/consensus_info_response.go similarity index 96% rename from xrpl/model/requests/admin/status/consensus_info_response.go rename to xrpl/queries/admin/status/consensus_info_response.go index 20eb9381..b403d82d 100644 --- a/xrpl/model/requests/admin/status/consensus_info_response.go +++ b/xrpl/queries/admin/status/consensus_info_response.go @@ -1,6 +1,6 @@ package status -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type ConsensusInfoResponse struct { Info ConsensusInfo `json:"info"` diff --git a/xrpl/model/requests/admin/status/consensus_info_test.go b/xrpl/queries/admin/status/consensus_info_test.go similarity index 97% rename from xrpl/model/requests/admin/status/consensus_info_test.go rename to xrpl/queries/admin/status/consensus_info_test.go index 554ac66e..d6e90dc3 100644 --- a/xrpl/model/requests/admin/status/consensus_info_test.go +++ b/xrpl/queries/admin/status/consensus_info_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestConsensusInfoResponse(t *testing.T) { @@ -139,7 +139,7 @@ func TestConsensusInfoResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/status/feature_request.go b/xrpl/queries/admin/status/feature_request.go similarity index 100% rename from xrpl/model/requests/admin/status/feature_request.go rename to xrpl/queries/admin/status/feature_request.go diff --git a/xrpl/model/requests/admin/status/feature_response.go b/xrpl/queries/admin/status/feature_response.go similarity index 100% rename from xrpl/model/requests/admin/status/feature_response.go rename to xrpl/queries/admin/status/feature_response.go diff --git a/xrpl/model/requests/admin/status/feature_test.go b/xrpl/queries/admin/status/feature_test.go similarity index 94% rename from xrpl/model/requests/admin/status/feature_test.go rename to xrpl/queries/admin/status/feature_test.go index 7143c1d4..a9d5e316 100644 --- a/xrpl/model/requests/admin/status/feature_test.go +++ b/xrpl/queries/admin/status/feature_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestFeatureResponse(t *testing.T) { @@ -77,7 +77,7 @@ func TestFeatureResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/status/fetch_info_request.go b/xrpl/queries/admin/status/fetch_info_request.go similarity index 100% rename from xrpl/model/requests/admin/status/fetch_info_request.go rename to xrpl/queries/admin/status/fetch_info_request.go diff --git a/xrpl/model/requests/admin/status/fetch_info_response.go b/xrpl/queries/admin/status/fetch_info_response.go similarity index 100% rename from xrpl/model/requests/admin/status/fetch_info_response.go rename to xrpl/queries/admin/status/fetch_info_response.go diff --git a/xrpl/model/requests/admin/status/fetch_info_test.go b/xrpl/queries/admin/status/fetch_info_test.go similarity index 96% rename from xrpl/model/requests/admin/status/fetch_info_test.go rename to xrpl/queries/admin/status/fetch_info_test.go index 655e2b80..2b0886cb 100644 --- a/xrpl/model/requests/admin/status/fetch_info_test.go +++ b/xrpl/queries/admin/status/fetch_info_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestFetchInfoResponse(t *testing.T) { @@ -67,7 +67,7 @@ func TestFetchInfoResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/status/get_counts_request.go b/xrpl/queries/admin/status/get_counts_request.go similarity index 100% rename from xrpl/model/requests/admin/status/get_counts_request.go rename to xrpl/queries/admin/status/get_counts_request.go diff --git a/xrpl/model/requests/admin/status/get_counts_response.go b/xrpl/queries/admin/status/get_counts_response.go similarity index 100% rename from xrpl/model/requests/admin/status/get_counts_response.go rename to xrpl/queries/admin/status/get_counts_response.go diff --git a/xrpl/model/requests/admin/status/get_counts_test.go b/xrpl/queries/admin/status/get_counts_test.go similarity index 94% rename from xrpl/model/requests/admin/status/get_counts_test.go rename to xrpl/queries/admin/status/get_counts_test.go index e17157ea..81077b03 100644 --- a/xrpl/model/requests/admin/status/get_counts_test.go +++ b/xrpl/queries/admin/status/get_counts_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestGetCountsResponse(t *testing.T) { @@ -69,7 +69,7 @@ func TestGetCountsResponse(t *testing.T) { "write_load": 0 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/status/validator_info_request.go b/xrpl/queries/admin/status/validator_info_request.go similarity index 100% rename from xrpl/model/requests/admin/status/validator_info_request.go rename to xrpl/queries/admin/status/validator_info_request.go diff --git a/xrpl/model/requests/admin/status/validator_info_response.go b/xrpl/queries/admin/status/validator_info_response.go similarity index 100% rename from xrpl/model/requests/admin/status/validator_info_response.go rename to xrpl/queries/admin/status/validator_info_response.go diff --git a/xrpl/model/requests/admin/status/validator_info_test.go b/xrpl/queries/admin/status/validator_info_test.go similarity index 91% rename from xrpl/model/requests/admin/status/validator_info_test.go rename to xrpl/queries/admin/status/validator_info_test.go index 064e8abd..59c9db9a 100644 --- a/xrpl/model/requests/admin/status/validator_info_test.go +++ b/xrpl/queries/admin/status/validator_info_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestValidatorInfoResponse(t *testing.T) { @@ -23,7 +23,7 @@ func TestValidatorInfoResponse(t *testing.T) { "seq": 1 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/requests/admin/status/validator_list_sites_request.go b/xrpl/queries/admin/status/validator_list_sites_request.go similarity index 100% rename from xrpl/model/requests/admin/status/validator_list_sites_request.go rename to xrpl/queries/admin/status/validator_list_sites_request.go diff --git a/xrpl/model/requests/admin/status/validator_list_sites_response.go b/xrpl/queries/admin/status/validator_list_sites_response.go similarity index 100% rename from xrpl/model/requests/admin/status/validator_list_sites_response.go rename to xrpl/queries/admin/status/validator_list_sites_response.go diff --git a/xrpl/model/requests/admin/status/validator_list_sites_test.go b/xrpl/queries/admin/status/validator_list_sites_test.go similarity index 83% rename from xrpl/model/requests/admin/status/validator_list_sites_test.go rename to xrpl/queries/admin/status/validator_list_sites_test.go index d010e6ec..dc443850 100644 --- a/xrpl/model/requests/admin/status/validator_list_sites_test.go +++ b/xrpl/queries/admin/status/validator_list_sites_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestValidatorListSitesResponse(t *testing.T) { @@ -29,7 +29,7 @@ func TestValidatorListSitesResponse(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/admin/status/validators_request.go b/xrpl/queries/admin/status/validators_request.go similarity index 100% rename from xrpl/model/requests/admin/status/validators_request.go rename to xrpl/queries/admin/status/validators_request.go diff --git a/xrpl/model/requests/admin/status/validators_response.go b/xrpl/queries/admin/status/validators_response.go similarity index 100% rename from xrpl/model/requests/admin/status/validators_response.go rename to xrpl/queries/admin/status/validators_response.go diff --git a/xrpl/model/requests/admin/status/validators_test.go b/xrpl/queries/admin/status/validators_test.go similarity index 99% rename from xrpl/model/requests/admin/status/validators_test.go rename to xrpl/queries/admin/status/validators_test.go index 108f14c2..28779d7e 100644 --- a/xrpl/model/requests/admin/status/validators_test.go +++ b/xrpl/queries/admin/status/validators_test.go @@ -3,7 +3,7 @@ package status import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestValidatorsResponse(t *testing.T) { @@ -256,7 +256,7 @@ func TestValidatorsResponse(t *testing.T) { "validator_list_expires": "" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/channel/channel_authorize_request.go b/xrpl/queries/channel/channel_authorize_request.go similarity index 94% rename from xrpl/model/requests/channel/channel_authorize_request.go rename to xrpl/queries/channel/channel_authorize_request.go index aca546e4..108e1223 100644 --- a/xrpl/model/requests/channel/channel_authorize_request.go +++ b/xrpl/queries/channel/channel_authorize_request.go @@ -3,7 +3,7 @@ package channel import ( "fmt" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type ChannelAuthorizeRequest struct { diff --git a/xrpl/model/requests/channel/channel_authorize_response.go b/xrpl/queries/channel/channel_authorize_response.go similarity index 100% rename from xrpl/model/requests/channel/channel_authorize_response.go rename to xrpl/queries/channel/channel_authorize_response.go diff --git a/xrpl/model/requests/channel/channel_authorize_test.go b/xrpl/queries/channel/channel_authorize_test.go similarity index 80% rename from xrpl/model/requests/channel/channel_authorize_test.go rename to xrpl/queries/channel/channel_authorize_test.go index d7165038..59c0de14 100644 --- a/xrpl/model/requests/channel/channel_authorize_test.go +++ b/xrpl/queries/channel/channel_authorize_test.go @@ -3,8 +3,8 @@ package channel 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 TestChannelAuthorizeRequest(t *testing.T) { @@ -21,7 +21,7 @@ func TestChannelAuthorizeRequest(t *testing.T) { "key_type": "secp256k1", "amount": "1000000" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -35,7 +35,7 @@ func TestChannelAuthorizeResponse(t *testing.T) { "signature": "304402204EF0AFB78AC23ED1C472E74F4299C0C21F1B21D07EFC0A3838A420F76D783A400220154FB11B6F54320666E4C36CA7F686C16A3A0456800BBC43746F34AF50290064" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/channel/channel_verify_request.go b/xrpl/queries/channel/channel_verify_request.go similarity index 83% rename from xrpl/model/requests/channel/channel_verify_request.go rename to xrpl/queries/channel/channel_verify_request.go index a03f6bee..c7af5765 100644 --- a/xrpl/model/requests/channel/channel_verify_request.go +++ b/xrpl/queries/channel/channel_verify_request.go @@ -1,6 +1,6 @@ package channel -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type ChannelVerifyRequest struct { Amount types.XRPCurrencyAmount `json:"amount"` diff --git a/xrpl/model/requests/channel/channel_verify_response.go b/xrpl/queries/channel/channel_verify_response.go similarity index 100% rename from xrpl/model/requests/channel/channel_verify_response.go rename to xrpl/queries/channel/channel_verify_response.go diff --git a/xrpl/model/requests/channel/channel_verify_test.go b/xrpl/queries/channel/channel_verify_test.go similarity index 81% rename from xrpl/model/requests/channel/channel_verify_test.go rename to xrpl/queries/channel/channel_verify_test.go index 12a239ad..a77a1c3d 100644 --- a/xrpl/model/requests/channel/channel_verify_test.go +++ b/xrpl/queries/channel/channel_verify_test.go @@ -3,8 +3,8 @@ package channel 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 TestChannelVerifyRequest(t *testing.T) { @@ -22,7 +22,7 @@ func TestChannelVerifyRequest(t *testing.T) { "signature": "304402204EF0AFB78AC23ED1C472E74F4299C0C21F1B21D07EFC0A3838A420F76D783A400220154FB11B6F54320666E4C36CA7F686C16A3A0456800BBC43746F34AF50290064" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -36,7 +36,7 @@ func TestChannelVerifyResponse(t *testing.T) { "signature_verified": false }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/requests/clio/ledger_request.go b/xrpl/queries/clio/ledger_request.go similarity index 96% rename from xrpl/model/requests/clio/ledger_request.go rename to xrpl/queries/clio/ledger_request.go index dc8be1f7..672eab63 100644 --- a/xrpl/model/requests/clio/ledger_request.go +++ b/xrpl/queries/clio/ledger_request.go @@ -3,7 +3,7 @@ package clio import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type LedgerRequest struct { diff --git a/xrpl/model/requests/clio/ledger_response.go b/xrpl/queries/clio/ledger_response.go similarity index 85% rename from xrpl/model/requests/clio/ledger_response.go rename to xrpl/queries/clio/ledger_response.go index 861b74db..fd6da5ee 100644 --- a/xrpl/model/requests/clio/ledger_response.go +++ b/xrpl/queries/clio/ledger_response.go @@ -1,10 +1,10 @@ package clio import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + transactions "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type LedgerResponse struct { diff --git a/xrpl/model/requests/clio/ledger_test.go b/xrpl/queries/clio/ledger_test.go similarity index 89% rename from xrpl/model/requests/clio/ledger_test.go rename to xrpl/queries/clio/ledger_test.go index 030bf6d9..295c7dfb 100644 --- a/xrpl/model/requests/clio/ledger_test.go +++ b/xrpl/queries/clio/ledger_test.go @@ -3,8 +3,8 @@ package clio import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestLedgerRequest(t *testing.T) { @@ -23,7 +23,7 @@ func TestLedgerRequest(t *testing.T) { "diff": false }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -69,7 +69,7 @@ func TestLedgerResponse(t *testing.T) { "validated": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/clio/nft_info_request.go b/xrpl/queries/clio/nft_info_request.go similarity index 87% rename from xrpl/model/requests/clio/nft_info_request.go rename to xrpl/queries/clio/nft_info_request.go index 45c7cca9..890cf85f 100644 --- a/xrpl/model/requests/clio/nft_info_request.go +++ b/xrpl/queries/clio/nft_info_request.go @@ -3,8 +3,8 @@ package clio import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTInfoRequest struct { diff --git a/xrpl/model/requests/clio/nft_info_response.go b/xrpl/queries/clio/nft_info_response.go similarity index 83% rename from xrpl/model/requests/clio/nft_info_response.go rename to xrpl/queries/clio/nft_info_response.go index d117b5a4..e01c880c 100644 --- a/xrpl/model/requests/clio/nft_info_response.go +++ b/xrpl/queries/clio/nft_info_response.go @@ -1,8 +1,8 @@ package clio import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTInfoResponse struct { diff --git a/xrpl/model/requests/clio/nft_info_test.go b/xrpl/queries/clio/nft_info_test.go similarity index 81% rename from xrpl/model/requests/clio/nft_info_test.go rename to xrpl/queries/clio/nft_info_test.go index f45e463c..751af469 100644 --- a/xrpl/model/requests/clio/nft_info_test.go +++ b/xrpl/queries/clio/nft_info_test.go @@ -3,8 +3,8 @@ package clio import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestNFTInfoRequest(t *testing.T) { @@ -18,7 +18,7 @@ func TestNFTInfoRequest(t *testing.T) { "ledger_index": "validated" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -44,7 +44,7 @@ func TestNFTInfoResponse(t *testing.T) { "nft_taxon": 0, "nft_sequence": 0 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/clio/server_info_request.go b/xrpl/queries/clio/server_info_request.go similarity index 100% rename from xrpl/model/requests/clio/server_info_request.go rename to xrpl/queries/clio/server_info_request.go diff --git a/xrpl/model/requests/clio/server_info_response.go b/xrpl/queries/clio/server_info_response.go similarity index 97% rename from xrpl/model/requests/clio/server_info_response.go rename to xrpl/queries/clio/server_info_response.go index a64068e0..5ffa8889 100644 --- a/xrpl/model/requests/clio/server_info_response.go +++ b/xrpl/queries/clio/server_info_response.go @@ -1,6 +1,6 @@ package clio -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type ServerInfoResponse struct { Info ClioServerInfo `json:"info"` diff --git a/xrpl/model/requests/clio/server_info_test.go b/xrpl/queries/clio/server_info_test.go similarity index 98% rename from xrpl/model/requests/clio/server_info_test.go rename to xrpl/queries/clio/server_info_test.go index 7c07dcd2..379096c5 100644 --- a/xrpl/model/requests/clio/server_info_test.go +++ b/xrpl/queries/clio/server_info_test.go @@ -3,7 +3,7 @@ package clio import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestServerInfoResponseLocalhost(t *testing.T) { @@ -392,7 +392,7 @@ func TestServerInfoResponseLocalhost(t *testing.T) { "validated": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -447,7 +447,7 @@ func TestServerInfoResponseRemote(t *testing.T) { "validated": true, "status": "success" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/common/ledger.go b/xrpl/queries/common/ledger.go similarity index 100% rename from xrpl/model/requests/common/ledger.go rename to xrpl/queries/common/ledger.go diff --git a/xrpl/model/requests/ledger/ledger_closed_request.go b/xrpl/queries/ledger/ledger_closed_request.go similarity index 100% rename from xrpl/model/requests/ledger/ledger_closed_request.go rename to xrpl/queries/ledger/ledger_closed_request.go diff --git a/xrpl/model/requests/ledger/ledger_closed_response.go b/xrpl/queries/ledger/ledger_closed_response.go similarity index 71% rename from xrpl/model/requests/ledger/ledger_closed_response.go rename to xrpl/queries/ledger/ledger_closed_response.go index e0d3b734..7dff9195 100644 --- a/xrpl/model/requests/ledger/ledger_closed_response.go +++ b/xrpl/queries/ledger/ledger_closed_response.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type LedgerClosedResponse struct { LedgerHash string `json:"ledger_hash"` diff --git a/xrpl/model/requests/ledger/ledger_closed_test.go b/xrpl/queries/ledger/ledger_closed_test.go similarity index 72% rename from xrpl/model/requests/ledger/ledger_closed_test.go rename to xrpl/queries/ledger/ledger_closed_test.go index ee129761..83d09ca5 100644 --- a/xrpl/model/requests/ledger/ledger_closed_test.go +++ b/xrpl/queries/ledger/ledger_closed_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) // Ledger closed request does not have any fields to test @@ -17,7 +17,7 @@ func TestLedgerClosedResponse(t *testing.T) { "ledger_hash": "abc", "ledger_index": 123 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/ledger/ledger_current_request.go b/xrpl/queries/ledger/ledger_current_request.go similarity index 100% rename from xrpl/model/requests/ledger/ledger_current_request.go rename to xrpl/queries/ledger/ledger_current_request.go diff --git a/xrpl/model/requests/ledger/ledger_current_response.go b/xrpl/queries/ledger/ledger_current_response.go similarity index 65% rename from xrpl/model/requests/ledger/ledger_current_response.go rename to xrpl/queries/ledger/ledger_current_response.go index 070abb0d..409c3910 100644 --- a/xrpl/model/requests/ledger/ledger_current_response.go +++ b/xrpl/queries/ledger/ledger_current_response.go @@ -1,6 +1,6 @@ package ledger -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type LedgerCurrentResponse struct { LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"` diff --git a/xrpl/model/requests/ledger/ledger_current_test.go b/xrpl/queries/ledger/ledger_current_test.go similarity index 69% rename from xrpl/model/requests/ledger/ledger_current_test.go rename to xrpl/queries/ledger/ledger_current_test.go index 3798d45d..db38adbf 100644 --- a/xrpl/model/requests/ledger/ledger_current_test.go +++ b/xrpl/queries/ledger/ledger_current_test.go @@ -3,7 +3,7 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) // Ledger Current request has no fields to test @@ -16,7 +16,7 @@ func TestLedgerCurrentResponse(t *testing.T) { "ledger_current_index": 123 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/ledger/ledger_data_request.go b/xrpl/queries/ledger/ledger_data_request.go similarity index 92% rename from xrpl/model/requests/ledger/ledger_data_request.go rename to xrpl/queries/ledger/ledger_data_request.go index 9f55b97a..b8bdcd68 100644 --- a/xrpl/model/requests/ledger/ledger_data_request.go +++ b/xrpl/queries/ledger/ledger_data_request.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type LedgerDataRequest struct { diff --git a/xrpl/model/requests/ledger/ledger_data_response.go b/xrpl/queries/ledger/ledger_data_response.go similarity index 83% rename from xrpl/model/requests/ledger/ledger_data_response.go rename to xrpl/queries/ledger/ledger_data_response.go index 47736acf..b7c52d1a 100644 --- a/xrpl/model/requests/ledger/ledger_data_response.go +++ b/xrpl/queries/ledger/ledger_data_response.go @@ -1,8 +1,8 @@ package ledger import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type LedgerDataResponse struct { diff --git a/xrpl/model/requests/ledger/ledger_data_test.go b/xrpl/queries/ledger/ledger_data_test.go similarity index 62% rename from xrpl/model/requests/ledger/ledger_data_test.go rename to xrpl/queries/ledger/ledger_data_test.go index 8d9d0fda..3256a8dc 100644 --- a/xrpl/model/requests/ledger/ledger_data_test.go +++ b/xrpl/queries/ledger/ledger_data_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestLedgerDataRequest(t *testing.T) { @@ -18,7 +18,7 @@ func TestLedgerDataRequest(t *testing.T) { "binary": true, "limit": 5 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/ledger/ledger_entry_request.go b/xrpl/queries/ledger/ledger_entry_request.go similarity index 97% rename from xrpl/model/requests/ledger/ledger_entry_request.go rename to xrpl/queries/ledger/ledger_entry_request.go index 37071fee..12d38c09 100644 --- a/xrpl/model/requests/ledger/ledger_entry_request.go +++ b/xrpl/queries/ledger/ledger_entry_request.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type LedgerEntryRequest struct { diff --git a/xrpl/model/requests/ledger/ledger_entry_response.go b/xrpl/queries/ledger/ledger_entry_response.go similarity index 73% rename from xrpl/model/requests/ledger/ledger_entry_response.go rename to xrpl/queries/ledger/ledger_entry_response.go index eeb30106..02bbcddb 100644 --- a/xrpl/model/requests/ledger/ledger_entry_response.go +++ b/xrpl/queries/ledger/ledger_entry_response.go @@ -1,8 +1,8 @@ package ledger import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type LedgerEntryResponse struct { diff --git a/xrpl/model/requests/ledger/ledger_entry_test.go b/xrpl/queries/ledger/ledger_entry_test.go similarity index 64% rename from xrpl/model/requests/ledger/ledger_entry_test.go rename to xrpl/queries/ledger/ledger_entry_test.go index 3f0188cb..9dcb15b5 100644 --- a/xrpl/model/requests/ledger/ledger_entry_test.go +++ b/xrpl/queries/ledger/ledger_entry_test.go @@ -3,8 +3,8 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestLedgerEntryRequest(t *testing.T) { @@ -20,7 +20,7 @@ func TestLedgerEntryRequest(t *testing.T) { "owner": "abc" } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/ledger/ledger_request.go b/xrpl/queries/ledger/ledger_request.go similarity index 94% rename from xrpl/model/requests/ledger/ledger_request.go rename to xrpl/queries/ledger/ledger_request.go index a502ba87..a3c5b72d 100644 --- a/xrpl/model/requests/ledger/ledger_request.go +++ b/xrpl/queries/ledger/ledger_request.go @@ -3,8 +3,8 @@ package ledger import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type LedgerRequest struct { diff --git a/xrpl/model/requests/ledger/ledger_response.go b/xrpl/queries/ledger/ledger_response.go similarity index 90% rename from xrpl/model/requests/ledger/ledger_response.go rename to xrpl/queries/ledger/ledger_response.go index 0b70b980..67dfd056 100644 --- a/xrpl/model/requests/ledger/ledger_response.go +++ b/xrpl/queries/ledger/ledger_response.go @@ -1,10 +1,10 @@ package ledger import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + transactions "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type LedgerResponse struct { diff --git a/xrpl/model/requests/ledger/ledger_test.go b/xrpl/queries/ledger/ledger_test.go similarity index 86% rename from xrpl/model/requests/ledger/ledger_test.go rename to xrpl/queries/ledger/ledger_test.go index 3b3eeeff..892d8195 100644 --- a/xrpl/model/requests/ledger/ledger_test.go +++ b/xrpl/queries/ledger/ledger_test.go @@ -3,9 +3,9 @@ package ledger import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestLedgerRequest(t *testing.T) { @@ -17,7 +17,7 @@ func TestLedgerRequest(t *testing.T) { "ledger_hash": "abc", "ledger_index": 123 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -60,7 +60,7 @@ func TestLedgerResponse(t *testing.T) { "ledger_index": 54300932, "validated": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/path/book_offers_request.go b/xrpl/queries/path/book_offers_request.go similarity index 92% rename from xrpl/model/requests/path/book_offers_request.go rename to xrpl/queries/path/book_offers_request.go index 63e6f4bc..ac4b8a0d 100644 --- a/xrpl/model/requests/path/book_offers_request.go +++ b/xrpl/queries/path/book_offers_request.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type BookOffersRequest struct { diff --git a/xrpl/model/requests/path/book_offers_response.go b/xrpl/queries/path/book_offers_response.go similarity index 90% rename from xrpl/model/requests/path/book_offers_response.go rename to xrpl/queries/path/book_offers_response.go index 9ef788b5..0f957219 100644 --- a/xrpl/model/requests/path/book_offers_response.go +++ b/xrpl/queries/path/book_offers_response.go @@ -3,9 +3,9 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type BookOffersResponse struct { diff --git a/xrpl/model/requests/path/book_offers_test.go b/xrpl/queries/path/book_offers_test.go similarity index 93% rename from xrpl/model/requests/path/book_offers_test.go rename to xrpl/queries/path/book_offers_test.go index ab489f99..1aee374d 100644 --- a/xrpl/model/requests/path/book_offers_test.go +++ b/xrpl/queries/path/book_offers_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestBookOffersRequest(t *testing.T) { @@ -32,7 +32,7 @@ func TestBookOffersRequest(t *testing.T) { "taker": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -141,7 +141,7 @@ func TestBookOffersResponse(t *testing.T) { } ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/path/deposit_authorized_request.go b/xrpl/queries/path/deposit_authorized_request.go similarity index 91% rename from xrpl/model/requests/path/deposit_authorized_request.go rename to xrpl/queries/path/deposit_authorized_request.go index ef8011e9..a895821b 100644 --- a/xrpl/model/requests/path/deposit_authorized_request.go +++ b/xrpl/queries/path/deposit_authorized_request.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type DepositAuthorizedRequest struct { diff --git a/xrpl/model/requests/path/deposit_authorized_response.go b/xrpl/queries/path/deposit_authorized_response.go similarity index 82% rename from xrpl/model/requests/path/deposit_authorized_response.go rename to xrpl/queries/path/deposit_authorized_response.go index 28d0102a..cb351835 100644 --- a/xrpl/model/requests/path/deposit_authorized_response.go +++ b/xrpl/queries/path/deposit_authorized_response.go @@ -1,8 +1,8 @@ package path import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type DepositAuthorizedResponse struct { diff --git a/xrpl/model/requests/path/deposit_authorized_test.go b/xrpl/queries/path/deposit_authorized_test.go similarity index 83% rename from xrpl/model/requests/path/deposit_authorized_test.go rename to xrpl/queries/path/deposit_authorized_test.go index 620dc8cb..61403eb4 100644 --- a/xrpl/model/requests/path/deposit_authorized_test.go +++ b/xrpl/queries/path/deposit_authorized_test.go @@ -3,8 +3,8 @@ package path import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestDepositAuthorizedRequest(t *testing.T) { @@ -20,7 +20,7 @@ func TestDepositAuthorizedRequest(t *testing.T) { "ledger_index": "validated" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -44,7 +44,7 @@ func TestDepositAuthorizedResponse(t *testing.T) { "validated": true }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/path/nftoken_buy_offers_request.go b/xrpl/queries/path/nftoken_buy_offers_request.go similarity index 91% rename from xrpl/model/requests/path/nftoken_buy_offers_request.go rename to xrpl/queries/path/nftoken_buy_offers_request.go index 12dc7a6b..2f883793 100644 --- a/xrpl/model/requests/path/nftoken_buy_offers_request.go +++ b/xrpl/queries/path/nftoken_buy_offers_request.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenBuyOffersRequest struct { diff --git a/xrpl/model/requests/path/nftoken_buy_offers_response.go b/xrpl/queries/path/nftoken_buy_offers_response.go similarity index 80% rename from xrpl/model/requests/path/nftoken_buy_offers_response.go rename to xrpl/queries/path/nftoken_buy_offers_response.go index 6276f15b..bd70c9ac 100644 --- a/xrpl/model/requests/path/nftoken_buy_offers_response.go +++ b/xrpl/queries/path/nftoken_buy_offers_response.go @@ -1,7 +1,7 @@ package path import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenBuyOffersResponse struct { diff --git a/xrpl/model/requests/path/nftoken_buy_offers_test.go b/xrpl/queries/path/nftoken_buy_offers_test.go similarity index 79% rename from xrpl/model/requests/path/nftoken_buy_offers_test.go rename to xrpl/queries/path/nftoken_buy_offers_test.go index 9f89cf9c..bf6351be 100644 --- a/xrpl/model/requests/path/nftoken_buy_offers_test.go +++ b/xrpl/queries/path/nftoken_buy_offers_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestNFTokenBuyOffersRequest(t *testing.T) { @@ -19,7 +19,7 @@ func TestNFTokenBuyOffersRequest(t *testing.T) { "ledger_index": "validated" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -49,7 +49,7 @@ func TestNFTokenBuyOffersResponse(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/path/nftoken_offer.go b/xrpl/queries/path/nftoken_offer.go similarity index 93% rename from xrpl/model/requests/path/nftoken_offer.go rename to xrpl/queries/path/nftoken_offer.go index 5f432415..3b2bbecd 100644 --- a/xrpl/model/requests/path/nftoken_offer.go +++ b/xrpl/queries/path/nftoken_offer.go @@ -3,7 +3,7 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenOffer struct { diff --git a/xrpl/model/requests/path/nftoken_sell_offers_request.go b/xrpl/queries/path/nftoken_sell_offers_request.go similarity index 91% rename from xrpl/model/requests/path/nftoken_sell_offers_request.go rename to xrpl/queries/path/nftoken_sell_offers_request.go index 6aa465d2..eb20f39b 100644 --- a/xrpl/model/requests/path/nftoken_sell_offers_request.go +++ b/xrpl/queries/path/nftoken_sell_offers_request.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenSellOffersRequest struct { diff --git a/xrpl/model/requests/path/nftoken_sell_offers_response.go b/xrpl/queries/path/nftoken_sell_offers_response.go similarity index 80% rename from xrpl/model/requests/path/nftoken_sell_offers_response.go rename to xrpl/queries/path/nftoken_sell_offers_response.go index 29d5df4c..8ea43add 100644 --- a/xrpl/model/requests/path/nftoken_sell_offers_response.go +++ b/xrpl/queries/path/nftoken_sell_offers_response.go @@ -1,7 +1,7 @@ package path import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenSellOffersResponse struct { diff --git a/xrpl/model/requests/path/nftoken_sell_offers_test.go b/xrpl/queries/path/nftoken_sell_offers_test.go similarity index 79% rename from xrpl/model/requests/path/nftoken_sell_offers_test.go rename to xrpl/queries/path/nftoken_sell_offers_test.go index 81cf1d71..292d25ae 100644 --- a/xrpl/model/requests/path/nftoken_sell_offers_test.go +++ b/xrpl/queries/path/nftoken_sell_offers_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestNFTokenSellOffersRequest(t *testing.T) { @@ -18,7 +18,7 @@ func TestNFTokenSellOffersRequest(t *testing.T) { "nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007", "ledger_index": "validated" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -47,7 +47,7 @@ func TestNFTokenSellOffersResponse(t *testing.T) { } ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/path/path_find_request.go b/xrpl/queries/path/path_find_request.go similarity index 50% rename from xrpl/model/requests/path/path_find_request.go rename to xrpl/queries/path/path_find_request.go index cbc338d2..5ec26337 100644 --- a/xrpl/model/requests/path/path_find_request.go +++ b/xrpl/queries/path/path_find_request.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type PathSubCommand string @@ -16,12 +16,12 @@ const ( ) type PathFindRequest struct { - Subcommand PathSubCommand `json:"subcommand"` - SourceAccount types.Address `json:"source_account,omitempty"` - DestinationAccount types.Address `json:"destination_account,omitempty"` - DestinationAmount types.CurrencyAmount `json:"destination_amount,omitempty"` - SendMax types.CurrencyAmount `json:"send_max,omitempty"` - Paths []transactions.PathStep `json:"paths,omitempty"` + Subcommand PathSubCommand `json:"subcommand"` + SourceAccount types.Address `json:"source_account,omitempty"` + DestinationAccount types.Address `json:"destination_account,omitempty"` + DestinationAmount types.CurrencyAmount `json:"destination_amount,omitempty"` + SendMax types.CurrencyAmount `json:"send_max,omitempty"` + Paths []transaction.PathStep `json:"paths,omitempty"` } func (*PathFindRequest) Method() string { @@ -30,12 +30,12 @@ func (*PathFindRequest) Method() string { func (r *PathFindRequest) UnmarshalJSON(data []byte) error { type pfrHelper struct { - Subcommand PathSubCommand `json:"subcommand"` - SourceAccount types.Address `json:"source_account,omitempty"` - DestinationAccount types.Address `json:"destination_account,omitempty"` - DestinationAmount json.RawMessage `json:"destination_amount,omitempty"` - SendMax json.RawMessage `json:"send_max,omitempty"` - Paths []transactions.PathStep `json:"paths,omitempty"` + Subcommand PathSubCommand `json:"subcommand"` + SourceAccount types.Address `json:"source_account,omitempty"` + DestinationAccount types.Address `json:"destination_account,omitempty"` + DestinationAmount json.RawMessage `json:"destination_amount,omitempty"` + SendMax json.RawMessage `json:"send_max,omitempty"` + Paths []transaction.PathStep `json:"paths,omitempty"` } var h pfrHelper if err := json.Unmarshal(data, &h); err != nil { diff --git a/xrpl/model/requests/path/path_find_response.go b/xrpl/queries/path/path_find_response.go similarity index 79% rename from xrpl/model/requests/path/path_find_response.go rename to xrpl/queries/path/path_find_response.go index 166e4e97..dfd6a80e 100644 --- a/xrpl/model/requests/path/path_find_response.go +++ b/xrpl/queries/path/path_find_response.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type PathFindResponse struct { @@ -50,16 +50,16 @@ func (r *PathFindResponse) UnmarshalJSON(data []byte) error { } type PathAlternative struct { - PathsComputed [][]transactions.PathStep `json:"paths_computed"` - SourceAmount types.CurrencyAmount `json:"source_amount"` - DestinationAmount types.CurrencyAmount `json:"destination_amount,omitempty"` + PathsComputed [][]transaction.PathStep `json:"paths_computed"` + SourceAmount types.CurrencyAmount `json:"source_amount"` + DestinationAmount types.CurrencyAmount `json:"destination_amount,omitempty"` } func (p *PathAlternative) UnmarshalJSON(data []byte) error { type paHelper struct { - PathsComputed [][]transactions.PathStep `json:"paths_computed"` - SourceAmount json.RawMessage `json:"source_amount"` - DestinationAmount json.RawMessage `json:"destination_amount,omitempty"` + PathsComputed [][]transaction.PathStep `json:"paths_computed"` + SourceAmount json.RawMessage `json:"source_amount"` + DestinationAmount json.RawMessage `json:"destination_amount,omitempty"` } var h paHelper if err := json.Unmarshal(data, &h); err != nil { diff --git a/xrpl/model/requests/path/path_find_test.go b/xrpl/queries/path/path_find_test.go similarity index 93% rename from xrpl/model/requests/path/path_find_test.go rename to xrpl/queries/path/path_find_test.go index 6cc3b6b6..9009dbd6 100644 --- a/xrpl/model/requests/path/path_find_test.go +++ b/xrpl/queries/path/path_find_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "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" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestPathFindRequest(t *testing.T) { @@ -31,7 +31,7 @@ func TestPathFindRequest(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -40,7 +40,7 @@ func TestPathFindResponse(t *testing.T) { s := PathFindResponse{ Alternatives: []PathAlternative{ { - PathsComputed: [][]transactions.PathStep{ + PathsComputed: [][]transaction.PathStep{ { { Currency: "USD", @@ -81,7 +81,7 @@ func TestPathFindResponse(t *testing.T) { SourceAmount: types.XRPCurrencyAmount(251686), }, { - PathsComputed: [][]transactions.PathStep{ + PathsComputed: [][]transaction.PathStep{ { { Account: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", @@ -126,7 +126,7 @@ func TestPathFindResponse(t *testing.T) { }, }, { - PathsComputed: [][]transactions.PathStep{ + PathsComputed: [][]transaction.PathStep{ { { Account: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", @@ -147,7 +147,7 @@ func TestPathFindResponse(t *testing.T) { }, }, { - PathsComputed: [][]transactions.PathStep{ + PathsComputed: [][]transaction.PathStep{ { { Account: "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA", @@ -343,7 +343,7 @@ func TestPathFindResponse(t *testing.T) { "full_reply": false }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/path/ripple_path_find_request.go b/xrpl/queries/path/ripple_path_find_request.go similarity index 94% rename from xrpl/model/requests/path/ripple_path_find_request.go rename to xrpl/queries/path/ripple_path_find_request.go index 6acca1f2..1d9e4c5e 100644 --- a/xrpl/model/requests/path/ripple_path_find_request.go +++ b/xrpl/queries/path/ripple_path_find_request.go @@ -3,8 +3,8 @@ package path import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type RipplePathFindRequest struct { diff --git a/xrpl/model/requests/path/ripple_path_find_response.go b/xrpl/queries/path/ripple_path_find_response.go similarity index 81% rename from xrpl/model/requests/path/ripple_path_find_response.go rename to xrpl/queries/path/ripple_path_find_response.go index cbd5b88c..582c7fbe 100644 --- a/xrpl/model/requests/path/ripple_path_find_response.go +++ b/xrpl/queries/path/ripple_path_find_response.go @@ -1,7 +1,7 @@ package path import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type RipplePathFindResponse struct { diff --git a/xrpl/model/requests/path/ripple_path_find_test.go b/xrpl/queries/path/ripple_path_find_test.go similarity index 91% rename from xrpl/model/requests/path/ripple_path_find_test.go rename to xrpl/queries/path/ripple_path_find_test.go index f2edc61d..ebebc504 100644 --- a/xrpl/model/requests/path/ripple_path_find_test.go +++ b/xrpl/queries/path/ripple_path_find_test.go @@ -3,9 +3,9 @@ package path import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "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" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestRipplePathFindRequest(t *testing.T) { @@ -44,7 +44,7 @@ func TestRipplePathFindRequest(t *testing.T) { } ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -53,7 +53,7 @@ func TestRipplePathFindResponse(t *testing.T) { s := RipplePathFindResponse{ Alternatives: []PathAlternative{ { - PathsComputed: [][]transactions.PathStep{ + PathsComputed: [][]transaction.PathStep{ { { Currency: "USD", @@ -195,7 +195,7 @@ func TestRipplePathFindResponse(t *testing.T) { "XRP" ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/server/fee_request.go b/xrpl/queries/server/fee_request.go similarity index 100% rename from xrpl/model/requests/server/fee_request.go rename to xrpl/queries/server/fee_request.go diff --git a/xrpl/model/requests/server/fee_response.go b/xrpl/queries/server/fee_response.go similarity index 89% rename from xrpl/model/requests/server/fee_response.go rename to xrpl/queries/server/fee_response.go index 372c373e..40537eab 100644 --- a/xrpl/model/requests/server/fee_response.go +++ b/xrpl/queries/server/fee_response.go @@ -1,8 +1,8 @@ package server import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type FeeResponse struct { diff --git a/xrpl/model/requests/server/fee_test.go b/xrpl/queries/server/fee_test.go similarity index 88% rename from xrpl/model/requests/server/fee_test.go rename to xrpl/queries/server/fee_test.go index 62036d85..78ef3786 100644 --- a/xrpl/model/requests/server/fee_test.go +++ b/xrpl/queries/server/fee_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestFeeResponse(t *testing.T) { @@ -47,7 +47,7 @@ func TestFeeResponse(t *testing.T) { "max_queue_size": "480" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/server/manifest_request.go b/xrpl/queries/server/manifest_request.go similarity index 100% rename from xrpl/model/requests/server/manifest_request.go rename to xrpl/queries/server/manifest_request.go diff --git a/xrpl/model/requests/server/manifest_response.go b/xrpl/queries/server/manifest_response.go similarity index 100% rename from xrpl/model/requests/server/manifest_response.go rename to xrpl/queries/server/manifest_response.go diff --git a/xrpl/model/requests/server/manifest_test.go b/xrpl/queries/server/manifest_test.go similarity index 89% rename from xrpl/model/requests/server/manifest_test.go rename to xrpl/queries/server/manifest_test.go index fdf65294..e90ec834 100644 --- a/xrpl/model/requests/server/manifest_test.go +++ b/xrpl/queries/server/manifest_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestManifestRequest(t *testing.T) { @@ -15,7 +15,7 @@ func TestManifestRequest(t *testing.T) { "public_key": "nHUFE9prPXPrHcG3SkwP1UzAQbSphqyQkQK9ATXLZsfkezhhda3p" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -43,7 +43,7 @@ func TestManifestResponse(t *testing.T) { "requested": "nHUFE9prPXPrHcG3SkwP1UzAQbSphqyQkQK9ATXLZsfkezhhda3p" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/server/server_info_request.go b/xrpl/queries/server/server_info_request.go similarity index 100% rename from xrpl/model/requests/server/server_info_request.go rename to xrpl/queries/server/server_info_request.go diff --git a/xrpl/model/requests/server/server_info_response.go b/xrpl/queries/server/server_info_response.go similarity index 98% rename from xrpl/model/requests/server/server_info_response.go rename to xrpl/queries/server/server_info_response.go index ba917aa7..24c85591 100644 --- a/xrpl/model/requests/server/server_info_response.go +++ b/xrpl/queries/server/server_info_response.go @@ -1,6 +1,6 @@ package server -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type ServerInfoResponse struct { Info ServerInfo `json:"info"` diff --git a/xrpl/model/requests/server/server_info_test.go b/xrpl/queries/server/server_info_test.go similarity index 95% rename from xrpl/model/requests/server/server_info_test.go rename to xrpl/queries/server/server_info_test.go index a77fb50c..44314188 100644 --- a/xrpl/model/requests/server/server_info_test.go +++ b/xrpl/queries/server/server_info_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestServerInfoResponse(t *testing.T) { @@ -111,7 +111,7 @@ func TestServerInfoResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/server/server_state_request.go b/xrpl/queries/server/server_state_request.go similarity index 100% rename from xrpl/model/requests/server/server_state_request.go rename to xrpl/queries/server/server_state_request.go diff --git a/xrpl/model/requests/server/server_state_response.go b/xrpl/queries/server/server_state_response.go similarity index 100% rename from xrpl/model/requests/server/server_state_response.go rename to xrpl/queries/server/server_state_response.go diff --git a/xrpl/model/requests/server/server_state_test.go b/xrpl/queries/server/server_state_test.go similarity index 96% rename from xrpl/model/requests/server/server_state_test.go rename to xrpl/queries/server/server_state_test.go index 3a636494..c0bf920f 100644 --- a/xrpl/model/requests/server/server_state_test.go +++ b/xrpl/queries/server/server_state_test.go @@ -3,7 +3,7 @@ package server import ( "testing" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestServerStateResponse(t *testing.T) { @@ -119,7 +119,7 @@ func TestServerStateResponse(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/subscription/stream/consensus.go b/xrpl/queries/subscription/stream/consensus.go similarity index 100% rename from xrpl/model/requests/subscription/stream/consensus.go rename to xrpl/queries/subscription/stream/consensus.go diff --git a/xrpl/model/requests/subscription/stream/ledger.go b/xrpl/queries/subscription/stream/ledger.go similarity index 90% rename from xrpl/model/requests/subscription/stream/ledger.go rename to xrpl/queries/subscription/stream/ledger.go index 01b62e5c..f02af2e4 100644 --- a/xrpl/model/requests/subscription/stream/ledger.go +++ b/xrpl/queries/subscription/stream/ledger.go @@ -1,6 +1,6 @@ package stream -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type LedgerStream struct { Type StreamType `json:"type"` diff --git a/xrpl/model/requests/subscription/stream/order_book.go b/xrpl/queries/subscription/stream/order_book.go similarity index 100% rename from xrpl/model/requests/subscription/stream/order_book.go rename to xrpl/queries/subscription/stream/order_book.go diff --git a/xrpl/model/requests/subscription/stream/peer.go b/xrpl/queries/subscription/stream/peer.go similarity index 87% rename from xrpl/model/requests/subscription/stream/peer.go rename to xrpl/queries/subscription/stream/peer.go index f432e4aa..41cf8f10 100644 --- a/xrpl/model/requests/subscription/stream/peer.go +++ b/xrpl/queries/subscription/stream/peer.go @@ -1,6 +1,6 @@ package stream -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type PeerStatusStream struct { Type StreamType `json:"type"` diff --git a/xrpl/model/requests/subscription/stream/transaction.go b/xrpl/queries/subscription/stream/transaction.go similarity index 87% rename from xrpl/model/requests/subscription/stream/transaction.go rename to xrpl/queries/subscription/stream/transaction.go index cdd7e3f7..88144934 100644 --- a/xrpl/model/requests/subscription/stream/transaction.go +++ b/xrpl/queries/subscription/stream/transaction.go @@ -1,8 +1,8 @@ package stream import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + transactions "github.com/Peersyst/xrpl-go/xrpl/transaction" ) type TransactionStream struct { diff --git a/xrpl/model/requests/subscription/stream/type.go b/xrpl/queries/subscription/stream/type.go similarity index 100% rename from xrpl/model/requests/subscription/stream/type.go rename to xrpl/queries/subscription/stream/type.go diff --git a/xrpl/model/requests/subscription/stream/validation.go b/xrpl/queries/subscription/stream/validation.go similarity index 95% rename from xrpl/model/requests/subscription/stream/validation.go rename to xrpl/queries/subscription/stream/validation.go index 96e675f2..24467f0b 100644 --- a/xrpl/model/requests/subscription/stream/validation.go +++ b/xrpl/queries/subscription/stream/validation.go @@ -1,7 +1,7 @@ package stream import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type ValidationStream struct { diff --git a/xrpl/model/requests/subscription/subscribe_request.go b/xrpl/queries/subscription/subscribe_request.go similarity index 93% rename from xrpl/model/requests/subscription/subscribe_request.go rename to xrpl/queries/subscription/subscribe_request.go index 247a3efc..ebb97006 100644 --- a/xrpl/model/requests/subscription/subscribe_request.go +++ b/xrpl/queries/subscription/subscribe_request.go @@ -1,6 +1,6 @@ package subscribe -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type SubscribeRequest struct { Streams []string `json:"streams,omitempty"` diff --git a/xrpl/model/requests/subscription/subscribe_response.go b/xrpl/queries/subscription/subscribe_response.go similarity index 89% rename from xrpl/model/requests/subscription/subscribe_response.go rename to xrpl/queries/subscription/subscribe_response.go index 1e9cffa4..26a13fd9 100644 --- a/xrpl/model/requests/subscription/subscribe_response.go +++ b/xrpl/queries/subscription/subscribe_response.go @@ -1,8 +1,8 @@ package subscribe import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type SubscribeResponse struct { diff --git a/xrpl/model/requests/subscription/subscribe_test.go b/xrpl/queries/subscription/subscribe_test.go similarity index 85% rename from xrpl/model/requests/subscription/subscribe_test.go rename to xrpl/queries/subscription/subscribe_test.go index b9d44e0a..275579a8 100644 --- a/xrpl/model/requests/subscription/subscribe_test.go +++ b/xrpl/queries/subscription/subscribe_test.go @@ -3,8 +3,8 @@ package subscribe 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 TestSubscribeRequest(t *testing.T) { @@ -51,7 +51,7 @@ func TestSubscribeRequest(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } @@ -87,7 +87,7 @@ func TestSubscribeResponse(t *testing.T) { "validated_ledgers": "123-456" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/model/requests/subscription/unsubscribe_request.go b/xrpl/queries/subscription/unsubscribe_request.go similarity index 90% rename from xrpl/model/requests/subscription/unsubscribe_request.go rename to xrpl/queries/subscription/unsubscribe_request.go index 52be1a92..30d181c3 100644 --- a/xrpl/model/requests/subscription/unsubscribe_request.go +++ b/xrpl/queries/subscription/unsubscribe_request.go @@ -1,6 +1,6 @@ package subscribe -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type UnsubscribeRequest struct { Streams []string `json:"streams,omitempty"` diff --git a/xrpl/model/requests/subscription/unsubscribe_response.go b/xrpl/queries/subscription/unsubscribe_response.go similarity index 100% rename from xrpl/model/requests/subscription/unsubscribe_response.go rename to xrpl/queries/subscription/unsubscribe_response.go diff --git a/xrpl/model/requests/subscription/unsubscribe_test.go b/xrpl/queries/subscription/unsubscribe_test.go similarity index 86% rename from xrpl/model/requests/subscription/unsubscribe_test.go rename to xrpl/queries/subscription/unsubscribe_test.go index b4f22875..77650d79 100644 --- a/xrpl/model/requests/subscription/unsubscribe_test.go +++ b/xrpl/queries/subscription/unsubscribe_test.go @@ -3,8 +3,8 @@ package subscribe 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 TestUnsubscribeRequest(t *testing.T) { @@ -53,7 +53,7 @@ func TestUnsubscribeRequest(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/queries/transactions/submit_multisigned_request.go b/xrpl/queries/transactions/submit_multisigned_request.go new file mode 100644 index 00000000..dab61db8 --- /dev/null +++ b/xrpl/queries/transactions/submit_multisigned_request.go @@ -0,0 +1,12 @@ +package transaction + +import "github.com/Peersyst/xrpl-go/xrpl/transaction" + +type SubmitMultisignedRequest struct { + Tx transaction.FlatTransaction `json:"tx_json"` + FailHard bool `json:"fail_hard"` +} + +func (*SubmitMultisignedRequest) Method() string { + return "submit_multisigned" +} diff --git a/xrpl/queries/transactions/submit_multisigned_response.go b/xrpl/queries/transactions/submit_multisigned_response.go new file mode 100644 index 00000000..f9cce119 --- /dev/null +++ b/xrpl/queries/transactions/submit_multisigned_response.go @@ -0,0 +1,11 @@ +package transaction + +import "github.com/Peersyst/xrpl-go/xrpl/transaction" + +type SubmitMultisignedResponse struct { + EngineResult string `json:"engine_result"` + EngineResultCode int `json:"engine_result_code"` + EngineResultMessage string `json:"engine_result_message"` + TxBlob string `json:"tx_blob"` + Tx transaction.FlatTransaction `json:"tx_json"` +} diff --git a/xrpl/model/requests/transactions/submit_request.go b/xrpl/queries/transactions/submit_request.go similarity index 93% rename from xrpl/model/requests/transactions/submit_request.go rename to xrpl/queries/transactions/submit_request.go index 891bdc7a..822c377b 100644 --- a/xrpl/model/requests/transactions/submit_request.go +++ b/xrpl/queries/transactions/submit_request.go @@ -1,4 +1,4 @@ -package transactions +package transaction import "errors" diff --git a/xrpl/queries/transactions/submit_response.go b/xrpl/queries/transactions/submit_response.go new file mode 100644 index 00000000..b4574a7d --- /dev/null +++ b/xrpl/queries/transactions/submit_response.go @@ -0,0 +1,23 @@ +package transaction + +import ( + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/transaction" +) + +type SubmitResponse struct { + EngineResult string `json:"engine_result"` + EngineResultCode int `json:"engine_result_code"` + EngineResultMessage string `json:"engine_result_message"` + TxBlob string `json:"tx_blob"` + Tx transaction.FlatTransaction `json:"tx_json"` + Accepted bool `json:"accepted"` + AccountSequenceAvailable uint `json:"account_sequence_available"` + AccountSequenceNext uint `json:"account_sequence_next"` + Applied bool `json:"applied"` + Broadcast bool `json:"broadcast"` + Kept bool `json:"kept"` + Queued bool `json:"queued"` + OpenLedgerCost string `json:"open_ledger_cost"` + ValidatedLedgerIndex common.LedgerIndex `json:"validated_ledger_index"` +} diff --git a/xrpl/model/requests/transactions/submit_test.go b/xrpl/queries/transactions/submit_test.go similarity index 88% rename from xrpl/model/requests/transactions/submit_test.go rename to xrpl/queries/transactions/submit_test.go index fd4588d0..d30b02a5 100644 --- a/xrpl/model/requests/transactions/submit_test.go +++ b/xrpl/queries/transactions/submit_test.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "testing" - "github.com/Peersyst/xrpl-go/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestSubmitRequest(t *testing.T) { @@ -14,7 +14,7 @@ func TestSubmitRequest(t *testing.T) { j := `{ "tx_blob": "1200002280000000240000016861D4838D7EA4C6800000000000000000000000000055534400000000004B4E9C06F24296074F7BC48F92A97916C6DC5EA9684000000000002710732103AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB7446304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F858081144B4E9C06F24296074F7BC48F92A97916C6DC5EA983143E9D4A2B8AA0780F682D136F7A56D6724EF53754" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/requests/transactions/transaction_entry_request.go b/xrpl/queries/transactions/transaction_entry_request.go similarity index 91% rename from xrpl/model/requests/transactions/transaction_entry_request.go rename to xrpl/queries/transactions/transaction_entry_request.go index 7be13cd0..2edcdc26 100644 --- a/xrpl/model/requests/transactions/transaction_entry_request.go +++ b/xrpl/queries/transactions/transaction_entry_request.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" ) type TransactionEntryRequest struct { diff --git a/xrpl/model/requests/transactions/transaction_entry_response.go b/xrpl/queries/transactions/transaction_entry_response.go similarity index 69% rename from xrpl/model/requests/transactions/transaction_entry_response.go rename to xrpl/queries/transactions/transaction_entry_response.go index dadb106d..2e535394 100644 --- a/xrpl/model/requests/transactions/transaction_entry_response.go +++ b/xrpl/queries/transactions/transaction_entry_response.go @@ -1,8 +1,8 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + transactions "github.com/Peersyst/xrpl-go/xrpl/transaction" ) type TransactionEntryResponse struct { diff --git a/xrpl/model/requests/transactions/tx_request.go b/xrpl/queries/transactions/tx_request.go similarity index 78% rename from xrpl/model/requests/transactions/tx_request.go rename to xrpl/queries/transactions/tx_request.go index 52276743..f55778fd 100644 --- a/xrpl/model/requests/transactions/tx_request.go +++ b/xrpl/queries/transactions/tx_request.go @@ -1,6 +1,6 @@ -package transactions +package transaction -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" +import "github.com/Peersyst/xrpl-go/xrpl/queries/common" type TxRequest struct { Transaction string `json:"transaction"` diff --git a/xrpl/model/requests/transactions/tx_response.go b/xrpl/queries/transactions/tx_response.go similarity index 66% rename from xrpl/model/requests/transactions/tx_response.go rename to xrpl/queries/transactions/tx_response.go index c60442ff..a579f274 100644 --- a/xrpl/model/requests/transactions/tx_response.go +++ b/xrpl/queries/transactions/tx_response.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + transactions "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type TxResponse struct { diff --git a/xrpl/model/requests/utility/ping_request.go b/xrpl/queries/utility/ping_request.go similarity index 100% rename from xrpl/model/requests/utility/ping_request.go rename to xrpl/queries/utility/ping_request.go diff --git a/xrpl/model/requests/utility/ping_response.go b/xrpl/queries/utility/ping_response.go similarity index 100% rename from xrpl/model/requests/utility/ping_response.go rename to xrpl/queries/utility/ping_response.go diff --git a/xrpl/model/requests/utility/random_request.go b/xrpl/queries/utility/random_request.go similarity index 100% rename from xrpl/model/requests/utility/random_request.go rename to xrpl/queries/utility/random_request.go diff --git a/xrpl/model/requests/utility/random_response.go b/xrpl/queries/utility/random_response.go similarity index 56% rename from xrpl/model/requests/utility/random_response.go rename to xrpl/queries/utility/random_response.go index db49d02b..bedd8067 100644 --- a/xrpl/model/requests/utility/random_response.go +++ b/xrpl/queries/utility/random_response.go @@ -1,6 +1,6 @@ package utility -import "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" +import "github.com/Peersyst/xrpl-go/xrpl/transaction/types" type RandomResponse struct { Random types.Hash256 `json:"random"` diff --git a/xrpl/model/requests/utility/random_test.go b/xrpl/queries/utility/random_test.go similarity index 72% rename from xrpl/model/requests/utility/random_test.go rename to xrpl/queries/utility/random_test.go index 3cb6146f..d4a66120 100644 --- a/xrpl/model/requests/utility/random_test.go +++ b/xrpl/queries/utility/random_test.go @@ -3,7 +3,7 @@ package utility import ( "testing" - "github.com/Peersyst/xrpl-go/test" + "github.com/Peersyst/xrpl-go/xrpl/testutil" ) func TestRandomResponse(t *testing.T) { @@ -15,7 +15,7 @@ func TestRandomResponse(t *testing.T) { "random": "8ED765AEBBD6767603C2C9375B2679AEC76E6A8133EF59F04F9FC1AAA70E41AF" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } } diff --git a/xrpl/rpc/client.go b/xrpl/rpc/client.go index 6c5d3b15..ea393dc4 100644 --- a/xrpl/rpc/client.go +++ b/xrpl/rpc/client.go @@ -11,8 +11,8 @@ import ( "strings" "time" - requests "github.com/Peersyst/xrpl-go/xrpl/model/requests/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" + requests "github.com/Peersyst/xrpl-go/xrpl/queries/transactions" + "github.com/Peersyst/xrpl-go/xrpl/transaction" jsoniter "github.com/json-iterator/go" ) @@ -123,7 +123,7 @@ func (c *JsonRpcClient) SubmitTransactionBlob(txBlob string, failHard bool) (Jso return response, error } -func (c *JsonRpcClient) Autofill(tx *transactions.FlatTransaction) error { +func (c *JsonRpcClient) Autofill(tx *transaction.FlatTransaction) error { return errors.New("not implemented") } diff --git a/xrpl/rpc/client_test.go b/xrpl/rpc/client_test.go index 090c2967..4cc479d1 100644 --- a/xrpl/rpc/client_test.go +++ b/xrpl/rpc/client_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/utility" + "github.com/Peersyst/xrpl-go/xrpl/queries/account" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/utility" "github.com/Peersyst/xrpl-go/xrpl/rpc/testutil" jsoniter "github.com/json-iterator/go" "github.com/stretchr/testify/assert" diff --git a/xrpl/rpc/queries.go b/xrpl/rpc/queries.go index 5aec5f8b..f0e64d5a 100644 --- a/xrpl/rpc/queries.go +++ b/xrpl/rpc/queries.go @@ -1,6 +1,6 @@ package rpc -import "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" +import "github.com/Peersyst/xrpl-go/xrpl/queries/account" func (r *JsonRpcClient) GetAccountChannels(req *account.AccountChannelsRequest) (*account.AccountChannelsResponse, error) { res, err := r.SendRequest(req) diff --git a/xrpl/rpc/response.go b/xrpl/rpc/response.go index 9cf7db6c..13a6eebf 100644 --- a/xrpl/rpc/response.go +++ b/xrpl/rpc/response.go @@ -1,7 +1,7 @@ package rpc import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" + "github.com/Peersyst/xrpl-go/xrpl/transaction" "github.com/mitchellh/mapstructure" ) @@ -18,7 +18,7 @@ type XRPLResponseWarning struct { Details any `json:"details,omitempty"` } -type AnyJson transactions.FlatTransaction +type AnyJson transaction.FlatTransaction type ApiWarning struct { Id int `json:"id"` diff --git a/xrpl/rpc/response_test.go b/xrpl/rpc/response_test.go index 1991c819..7dc17e6d 100644 --- a/xrpl/rpc/response_test.go +++ b/xrpl/rpc/response_test.go @@ -5,7 +5,7 @@ import ( "strconv" "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" + "github.com/Peersyst/xrpl-go/xrpl/queries/account" "github.com/stretchr/testify/assert" ) diff --git a/xrpl/test/serializer.go b/xrpl/testutil/serializer.go similarity index 98% rename from xrpl/test/serializer.go rename to xrpl/testutil/serializer.go index 17b525af..1a8c829f 100644 --- a/xrpl/test/serializer.go +++ b/xrpl/testutil/serializer.go @@ -1,4 +1,4 @@ -package test +package testutil import ( "encoding/json" diff --git a/xrpl/model/transactions/account_delete.go b/xrpl/transaction/account_delete.go similarity index 77% rename from xrpl/model/transactions/account_delete.go rename to xrpl/transaction/account_delete.go index 1457c928..7d36b0b7 100644 --- a/xrpl/model/transactions/account_delete.go +++ b/xrpl/transaction/account_delete.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type AccountDelete struct { diff --git a/xrpl/model/transactions/account_delete_test.go b/xrpl/transaction/account_delete_test.go similarity index 81% rename from xrpl/model/transactions/account_delete_test.go rename to xrpl/transaction/account_delete_test.go index 5f257aa7..299c5469 100644 --- a/xrpl/model/transactions/account_delete_test.go +++ b/xrpl/transaction/account_delete_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAccountDeleteTransaction(t *testing.T) { @@ -33,7 +33,7 @@ func TestAccountDeleteTransaction(t *testing.T) { "DestinationTag": 10 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/account_set.go b/xrpl/transaction/account_set.go similarity index 99% rename from xrpl/model/transactions/account_set.go rename to xrpl/transaction/account_set.go index 16856677..cad88126 100644 --- a/xrpl/model/transactions/account_set.go +++ b/xrpl/transaction/account_set.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( diff --git a/xrpl/model/transactions/account_set_test.go b/xrpl/transaction/account_set_test.go similarity index 93% rename from xrpl/model/transactions/account_set_test.go rename to xrpl/transaction/account_set_test.go index b4bb3b81..d4e6e9c0 100644 --- a/xrpl/model/transactions/account_set_test.go +++ b/xrpl/transaction/account_set_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAccountSetTransaction(t *testing.T) { @@ -33,7 +33,7 @@ func TestAccountSetTransaction(t *testing.T) { "SetFlag": 10 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/amm_bid.go b/xrpl/transaction/amm_bid.go similarity index 90% rename from xrpl/model/transactions/amm_bid.go rename to xrpl/transaction/amm_bid.go index d719035b..d6a7c799 100644 --- a/xrpl/model/transactions/amm_bid.go +++ b/xrpl/transaction/amm_bid.go @@ -1,4 +1,4 @@ -package transactions +package transaction // TODO: Implement AMMBid type AMMBid struct { diff --git a/xrpl/model/transactions/amm_bid_test.go b/xrpl/transaction/amm_bid_test.go similarity index 79% rename from xrpl/model/transactions/amm_bid_test.go rename to xrpl/transaction/amm_bid_test.go index 57c03f86..fdf46b38 100644 --- a/xrpl/model/transactions/amm_bid_test.go +++ b/xrpl/transaction/amm_bid_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAMMBidTransaction(t *testing.T) { @@ -29,7 +29,7 @@ func TestAMMBidTransaction(t *testing.T) { "TxnSignature": "A1B2C3D4E5F6" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/amm_create.go b/xrpl/transaction/amm_create.go similarity index 89% rename from xrpl/model/transactions/amm_create.go rename to xrpl/transaction/amm_create.go index 863c87e8..bdd1b5ab 100644 --- a/xrpl/model/transactions/amm_create.go +++ b/xrpl/transaction/amm_create.go @@ -1,4 +1,4 @@ -package transactions +package transaction type AMMCreate struct { BaseTx diff --git a/xrpl/model/transactions/amm_create_test.go b/xrpl/transaction/amm_create_test.go similarity index 79% rename from xrpl/model/transactions/amm_create_test.go rename to xrpl/transaction/amm_create_test.go index 190642cb..98f910b2 100644 --- a/xrpl/model/transactions/amm_create_test.go +++ b/xrpl/transaction/amm_create_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAMMCreateTransaction(t *testing.T) { @@ -30,7 +30,7 @@ func TestAMMCreateTransaction(t *testing.T) { "TxnSignature": "A1B2C3D4E5F6" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/amm_deposit.go b/xrpl/transaction/amm_deposit.go similarity index 89% rename from xrpl/model/transactions/amm_deposit.go rename to xrpl/transaction/amm_deposit.go index b79430ca..99103cc0 100644 --- a/xrpl/model/transactions/amm_deposit.go +++ b/xrpl/transaction/amm_deposit.go @@ -1,4 +1,4 @@ -package transactions +package transaction type AMMDeposit struct { BaseTx diff --git a/xrpl/model/transactions/amm_deposit_test.go b/xrpl/transaction/amm_deposit_test.go similarity index 79% rename from xrpl/model/transactions/amm_deposit_test.go rename to xrpl/transaction/amm_deposit_test.go index 27641c9d..37a07cfc 100644 --- a/xrpl/model/transactions/amm_deposit_test.go +++ b/xrpl/transaction/amm_deposit_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAMMDepositTransaction(t *testing.T) { @@ -30,7 +30,7 @@ func TestAMMDepositTransaction(t *testing.T) { "TxnSignature": "A1B2C3D4E5F6" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/amm_vote.go b/xrpl/transaction/amm_vote.go similarity index 89% rename from xrpl/model/transactions/amm_vote.go rename to xrpl/transaction/amm_vote.go index 23dd385c..8e5743c2 100644 --- a/xrpl/model/transactions/amm_vote.go +++ b/xrpl/transaction/amm_vote.go @@ -1,4 +1,4 @@ -package transactions +package transaction type AMMVote struct { BaseTx diff --git a/xrpl/model/transactions/amm_vote_test.go b/xrpl/transaction/amm_vote_test.go similarity index 79% rename from xrpl/model/transactions/amm_vote_test.go rename to xrpl/transaction/amm_vote_test.go index 26d5c777..2add1d74 100644 --- a/xrpl/model/transactions/amm_vote_test.go +++ b/xrpl/transaction/amm_vote_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAMMVoteTransaction(t *testing.T) { @@ -30,7 +30,7 @@ func TestAMMVoteTransaction(t *testing.T) { "TxnSignature": "A1B2C3D4E5F6" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/amm_withdraw.go b/xrpl/transaction/amm_withdraw.go similarity index 90% rename from xrpl/model/transactions/amm_withdraw.go rename to xrpl/transaction/amm_withdraw.go index f1eb37f6..227f63de 100644 --- a/xrpl/model/transactions/amm_withdraw.go +++ b/xrpl/transaction/amm_withdraw.go @@ -1,4 +1,4 @@ -package transactions +package transaction type AMMWithdraw struct { BaseTx diff --git a/xrpl/model/transactions/amm_withdraw_test.go b/xrpl/transaction/amm_withdraw_test.go similarity index 79% rename from xrpl/model/transactions/amm_withdraw_test.go rename to xrpl/transaction/amm_withdraw_test.go index 52d86ba0..18ca41a0 100644 --- a/xrpl/model/transactions/amm_withdraw_test.go +++ b/xrpl/transaction/amm_withdraw_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestAMMWithdrawTransaction(t *testing.T) { @@ -30,7 +30,7 @@ func TestAMMWithdrawTransaction(t *testing.T) { "TxnSignature": "A1B2C3D4E5F6" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/check_cancel.go b/xrpl/transaction/check_cancel.go similarity index 73% rename from xrpl/model/transactions/check_cancel.go rename to xrpl/transaction/check_cancel.go index 5c17bd15..b20acd72 100644 --- a/xrpl/model/transactions/check_cancel.go +++ b/xrpl/transaction/check_cancel.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type CheckCancel struct { diff --git a/xrpl/model/transactions/check_cancel_test.go b/xrpl/transaction/check_cancel_test.go similarity index 80% rename from xrpl/model/transactions/check_cancel_test.go rename to xrpl/transaction/check_cancel_test.go index 655e53f6..d9c3a334 100644 --- a/xrpl/model/transactions/check_cancel_test.go +++ b/xrpl/transaction/check_cancel_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestCheckCancelTransaction(t *testing.T) { @@ -31,7 +31,7 @@ func TestCheckCancelTransaction(t *testing.T) { "CheckID": "A1B2C3D4A6D1" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/check_cash.go b/xrpl/transaction/check_cash.go similarity index 92% rename from xrpl/model/transactions/check_cash.go rename to xrpl/transaction/check_cash.go index 1142991a..fbcfa36b 100644 --- a/xrpl/model/transactions/check_cash.go +++ b/xrpl/transaction/check_cash.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type CheckCash struct { diff --git a/xrpl/model/transactions/check_cash_test.go b/xrpl/transaction/check_cash_test.go similarity index 86% rename from xrpl/model/transactions/check_cash_test.go rename to xrpl/transaction/check_cash_test.go index c09853bb..aaa26c6f 100644 --- a/xrpl/model/transactions/check_cash_test.go +++ b/xrpl/transaction/check_cash_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestCheckCashTransaction(t *testing.T) { @@ -51,7 +51,7 @@ func TestCheckCashTransaction(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/check_create.go b/xrpl/transaction/check_create.go similarity index 93% rename from xrpl/model/transactions/check_create.go rename to xrpl/transaction/check_create.go index af7cb8a6..74d89401 100644 --- a/xrpl/model/transactions/check_create.go +++ b/xrpl/transaction/check_create.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type CheckCreate struct { diff --git a/xrpl/model/transactions/check_create_test.go b/xrpl/transaction/check_create_test.go similarity index 85% rename from xrpl/model/transactions/check_create_test.go rename to xrpl/transaction/check_create_test.go index 5b0b3b2e..501da6e7 100644 --- a/xrpl/model/transactions/check_create_test.go +++ b/xrpl/transaction/check_create_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestCheckCreateTransaction(t *testing.T) { @@ -47,7 +47,7 @@ func TestCheckCreateTransaction(t *testing.T) { "InvoiceID": "A1232452DBC" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/clawback.go b/xrpl/transaction/clawback.go similarity index 96% rename from xrpl/model/transactions/clawback.go rename to xrpl/transaction/clawback.go index f037401b..3e5da4f8 100644 --- a/xrpl/model/transactions/clawback.go +++ b/xrpl/transaction/clawback.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) // Requires the Clawback amendment. diff --git a/xrpl/model/transactions/clawback_test.go b/xrpl/transaction/clawback_test.go similarity index 90% rename from xrpl/model/transactions/clawback_test.go rename to xrpl/transaction/clawback_test.go index 86fd19ca..1f7c30ae 100644 --- a/xrpl/model/transactions/clawback_test.go +++ b/xrpl/transaction/clawback_test.go @@ -1,4 +1,4 @@ -package transactions +package transaction import ( "encoding/json" @@ -6,8 +6,8 @@ import ( "reflect" "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 TestClawbackTransaction(t *testing.T) { @@ -41,7 +41,7 @@ func TestClawbackTransaction(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, clawbackTx, clawbackJSON); err != nil { + if err := testutil.SerializeAndDeserialize(t, clawbackTx, clawbackJSON); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/deposit_preauth.go b/xrpl/transaction/deposit_preauth.go similarity index 79% rename from xrpl/model/transactions/deposit_preauth.go rename to xrpl/transaction/deposit_preauth.go index 9590dc52..1c8c99d0 100644 --- a/xrpl/model/transactions/deposit_preauth.go +++ b/xrpl/transaction/deposit_preauth.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type DepositPreauth struct { diff --git a/xrpl/model/transactions/deposit_preauth_test.go b/xrpl/transaction/deposit_preauth_test.go similarity index 81% rename from xrpl/model/transactions/deposit_preauth_test.go rename to xrpl/transaction/deposit_preauth_test.go index 0926fe08..0a017c39 100644 --- a/xrpl/model/transactions/deposit_preauth_test.go +++ b/xrpl/transaction/deposit_preauth_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestDepositPreauthTransaction(t *testing.T) { @@ -34,7 +34,7 @@ func TestDepositPreauthTransaction(t *testing.T) { "Unauthorize": "loikmn" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/escrow_cancel.go b/xrpl/transaction/escrow_cancel.go similarity index 75% rename from xrpl/model/transactions/escrow_cancel.go rename to xrpl/transaction/escrow_cancel.go index 3446b110..d8d0bb66 100644 --- a/xrpl/model/transactions/escrow_cancel.go +++ b/xrpl/transaction/escrow_cancel.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type EscrowCancel struct { diff --git a/xrpl/model/transactions/escrow_cancel_test.go b/xrpl/transaction/escrow_cancel_test.go similarity index 81% rename from xrpl/model/transactions/escrow_cancel_test.go rename to xrpl/transaction/escrow_cancel_test.go index 816325a0..83b0b193 100644 --- a/xrpl/model/transactions/escrow_cancel_test.go +++ b/xrpl/transaction/escrow_cancel_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestEscrowCancelTransaction(t *testing.T) { @@ -33,7 +33,7 @@ func TestEscrowCancelTransaction(t *testing.T) { "Owner": "abcdef", "OfferSequence": 10 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/escrow_create.go b/xrpl/transaction/escrow_create.go similarity index 84% rename from xrpl/model/transactions/escrow_create.go rename to xrpl/transaction/escrow_create.go index dd1b9ecf..03c5d411 100644 --- a/xrpl/model/transactions/escrow_create.go +++ b/xrpl/transaction/escrow_create.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type EscrowCreate struct { diff --git a/xrpl/model/transactions/escrow_create_test.go b/xrpl/transaction/escrow_create_test.go similarity index 82% rename from xrpl/model/transactions/escrow_create_test.go rename to xrpl/transaction/escrow_create_test.go index 837e7e36..5f8c4068 100644 --- a/xrpl/model/transactions/escrow_create_test.go +++ b/xrpl/transaction/escrow_create_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestEscrowCreateTransaction(t *testing.T) { @@ -36,7 +36,7 @@ func TestEscrowCreateTransaction(t *testing.T) { "CancelAfter": 9000000 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/escrow_finish.go b/xrpl/transaction/escrow_finish.go similarity index 80% rename from xrpl/model/transactions/escrow_finish.go rename to xrpl/transaction/escrow_finish.go index 10def66c..96d288ad 100644 --- a/xrpl/model/transactions/escrow_finish.go +++ b/xrpl/transaction/escrow_finish.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type EscrowFinish struct { diff --git a/xrpl/model/transactions/escrow_finish_test.go b/xrpl/transaction/escrow_finish_test.go similarity index 81% rename from xrpl/model/transactions/escrow_finish_test.go rename to xrpl/transaction/escrow_finish_test.go index 3b1883bd..8b904a90 100644 --- a/xrpl/model/transactions/escrow_finish_test.go +++ b/xrpl/transaction/escrow_finish_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestEscrowFinishTransaction(t *testing.T) { @@ -34,7 +34,7 @@ func TestEscrowFinishTransaction(t *testing.T) { "OfferSequence": 1232 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/utils/flags.go b/xrpl/transaction/flags.go similarity index 96% rename from xrpl/model/utils/flags.go rename to xrpl/transaction/flags.go index 8834b9a9..650a3238 100644 --- a/xrpl/model/utils/flags.go +++ b/xrpl/transaction/flags.go @@ -1,4 +1,4 @@ -package utils +package transaction import "math/big" diff --git a/xrpl/model/utils/flags_test.go b/xrpl/transaction/flags_test.go similarity index 96% rename from xrpl/model/utils/flags_test.go rename to xrpl/transaction/flags_test.go index c44dafa6..885f9ad1 100644 --- a/xrpl/model/utils/flags_test.go +++ b/xrpl/transaction/flags_test.go @@ -1,4 +1,4 @@ -package utils +package transaction import ( "testing" diff --git a/xrpl/model/transactions/flat_tx.go b/xrpl/transaction/flat_tx.go similarity index 91% rename from xrpl/model/transactions/flat_tx.go rename to xrpl/transaction/flat_tx.go index 31df1891..b459c56c 100644 --- a/xrpl/model/transactions/flat_tx.go +++ b/xrpl/transaction/flat_tx.go @@ -1,4 +1,4 @@ -package transactions +package transaction var _ Tx = (*FlatTransaction)(nil) diff --git a/xrpl/model/transactions/memo.go b/xrpl/transaction/memo.go similarity index 97% rename from xrpl/model/transactions/memo.go rename to xrpl/transaction/memo.go index a7f0b303..c2da988b 100644 --- a/xrpl/model/transactions/memo.go +++ b/xrpl/transaction/memo.go @@ -1,4 +1,4 @@ -package transactions +package transaction type MemoWrapper struct { Memo Memo diff --git a/xrpl/model/transactions/nftoken_accept_offer.go b/xrpl/transaction/nftoken_accept_offer.go similarity index 92% rename from xrpl/model/transactions/nftoken_accept_offer.go rename to xrpl/transaction/nftoken_accept_offer.go index 86d2e3e8..6483949f 100644 --- a/xrpl/model/transactions/nftoken_accept_offer.go +++ b/xrpl/transaction/nftoken_accept_offer.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenAcceptOffer struct { diff --git a/xrpl/model/transactions/nftoken_accept_offer_test.go b/xrpl/transaction/nftoken_accept_offer_test.go similarity index 85% rename from xrpl/model/transactions/nftoken_accept_offer_test.go rename to xrpl/transaction/nftoken_accept_offer_test.go index ad8d0945..1c5c9a5f 100644 --- a/xrpl/model/transactions/nftoken_accept_offer_test.go +++ b/xrpl/transaction/nftoken_accept_offer_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestNFTokenAcceptOfferTransaction(t *testing.T) { @@ -44,7 +44,7 @@ func TestNFTokenAcceptOfferTransaction(t *testing.T) { } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/nftoken_burn.go b/xrpl/transaction/nftoken_burn.go similarity index 77% rename from xrpl/model/transactions/nftoken_burn.go rename to xrpl/transaction/nftoken_burn.go index 2a4f0920..f25e6eee 100644 --- a/xrpl/model/transactions/nftoken_burn.go +++ b/xrpl/transaction/nftoken_burn.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenBurn struct { diff --git a/xrpl/model/transactions/nftoken_burn_test.go b/xrpl/transaction/nftoken_burn_test.go similarity index 80% rename from xrpl/model/transactions/nftoken_burn_test.go rename to xrpl/transaction/nftoken_burn_test.go index aa115953..d3d55bd5 100644 --- a/xrpl/model/transactions/nftoken_burn_test.go +++ b/xrpl/transaction/nftoken_burn_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestNFTokenBurnTransaction(t *testing.T) { @@ -32,7 +32,7 @@ func TestNFTokenBurnTransaction(t *testing.T) { "NFTokenID": "B1C2D3" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/nftoken_cancel_offer.go b/xrpl/transaction/nftoken_cancel_offer.go similarity index 76% rename from xrpl/model/transactions/nftoken_cancel_offer.go rename to xrpl/transaction/nftoken_cancel_offer.go index af983df2..815ba1c2 100644 --- a/xrpl/model/transactions/nftoken_cancel_offer.go +++ b/xrpl/transaction/nftoken_cancel_offer.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenCancelOffer struct { diff --git a/xrpl/model/transactions/nftoken_cancel_offer_test.go b/xrpl/transaction/nftoken_cancel_offer_test.go similarity index 77% rename from xrpl/model/transactions/nftoken_cancel_offer_test.go rename to xrpl/transaction/nftoken_cancel_offer_test.go index 644acdb4..bc51c0a4 100644 --- a/xrpl/model/transactions/nftoken_cancel_offer_test.go +++ b/xrpl/transaction/nftoken_cancel_offer_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestNFTokenCancelOfferTx(t *testing.T) { @@ -29,7 +29,7 @@ func TestNFTokenCancelOfferTx(t *testing.T) { ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/nftoken_create_offer.go b/xrpl/transaction/nftoken_create_offer.go similarity index 93% rename from xrpl/model/transactions/nftoken_create_offer.go rename to xrpl/transaction/nftoken_create_offer.go index aca1f3cd..92cdd0db 100644 --- a/xrpl/model/transactions/nftoken_create_offer.go +++ b/xrpl/transaction/nftoken_create_offer.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenCreateOffer struct { diff --git a/xrpl/model/transactions/nftoken_create_offer_test.go b/xrpl/transaction/nftoken_create_offer_test.go similarity index 81% rename from xrpl/model/transactions/nftoken_create_offer_test.go rename to xrpl/transaction/nftoken_create_offer_test.go index 180f8644..ccc69f54 100644 --- a/xrpl/model/transactions/nftoken_create_offer_test.go +++ b/xrpl/transaction/nftoken_create_offer_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestNFTokenCreateOfferTx(t *testing.T) { @@ -27,7 +27,7 @@ func TestNFTokenCreateOfferTx(t *testing.T) { "NFTokenID": "000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007", "Amount": "1000000" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/nftoken_mint.go b/xrpl/transaction/nftoken_mint.go similarity index 82% rename from xrpl/model/transactions/nftoken_mint.go rename to xrpl/transaction/nftoken_mint.go index 81324899..71b49d73 100644 --- a/xrpl/model/transactions/nftoken_mint.go +++ b/xrpl/transaction/nftoken_mint.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type NFTokenMint struct { diff --git a/xrpl/model/transactions/nftoken_mint_test.go b/xrpl/transaction/nftoken_mint_test.go similarity index 87% rename from xrpl/model/transactions/nftoken_mint_test.go rename to xrpl/transaction/nftoken_mint_test.go index 3037e7cc..cf286a8d 100644 --- a/xrpl/model/transactions/nftoken_mint_test.go +++ b/xrpl/transaction/nftoken_mint_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestNFTokenMintTx(t *testing.T) { @@ -48,7 +48,7 @@ func TestNFTokenMintTx(t *testing.T) { "URI": "697066733A2F2F62616679626569676479727A74357366703775646D37687537367568377932366E6634646675796C71616266336F636C67747179353566627A6469" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/offer_cancel.go b/xrpl/transaction/offer_cancel.go similarity index 90% rename from xrpl/model/transactions/offer_cancel.go rename to xrpl/transaction/offer_cancel.go index 76fd9d56..ff125034 100644 --- a/xrpl/model/transactions/offer_cancel.go +++ b/xrpl/transaction/offer_cancel.go @@ -1,4 +1,4 @@ -package transactions +package transaction type OfferCancel struct { BaseTx diff --git a/xrpl/model/transactions/offer_cancel_test.go b/xrpl/transaction/offer_cancel_test.go similarity index 80% rename from xrpl/model/transactions/offer_cancel_test.go rename to xrpl/transaction/offer_cancel_test.go index da69ebd9..ed9d73ec 100644 --- a/xrpl/model/transactions/offer_cancel_test.go +++ b/xrpl/transaction/offer_cancel_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestOfferCancelTx(t *testing.T) { @@ -28,7 +28,7 @@ func TestOfferCancelTx(t *testing.T) { "LastLedgerSequence": 7108629, "OfferSequence": 6 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/offer_create.go b/xrpl/transaction/offer_create.go similarity index 93% rename from xrpl/model/transactions/offer_create.go rename to xrpl/transaction/offer_create.go index 5c999288..6c5adf60 100644 --- a/xrpl/model/transactions/offer_create.go +++ b/xrpl/transaction/offer_create.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type OfferCreate struct { diff --git a/xrpl/model/transactions/offer_create_test.go b/xrpl/transaction/offer_create_test.go similarity index 84% rename from xrpl/model/transactions/offer_create_test.go rename to xrpl/transaction/offer_create_test.go index 8a46491e..53ac332e 100644 --- a/xrpl/model/transactions/offer_create_test.go +++ b/xrpl/transaction/offer_create_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestOfferCreateTx(t *testing.T) { @@ -39,7 +39,7 @@ func TestOfferCreateTx(t *testing.T) { "value": "2" } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/path_step.go b/xrpl/transaction/path_step.go similarity index 69% rename from xrpl/model/transactions/path_step.go rename to xrpl/transaction/path_step.go index 82eb256a..4782a919 100644 --- a/xrpl/model/transactions/path_step.go +++ b/xrpl/transaction/path_step.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type PathStep struct { diff --git a/xrpl/model/transactions/payment.go b/xrpl/transaction/payment.go similarity index 97% rename from xrpl/model/transactions/payment.go rename to xrpl/transaction/payment.go index 45a8bcaf..800ac938 100644 --- a/xrpl/model/transactions/payment.go +++ b/xrpl/transaction/payment.go @@ -1,12 +1,11 @@ -package transactions +package transaction import ( "encoding/json" "errors" "github.com/Peersyst/xrpl-go/pkg/typecheck" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/model/utils" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( @@ -268,7 +267,7 @@ func checkPartialPayment(tx FlatTransaction) error { flagsField, isUint := (tx["Flags"]).(uint) var isTfPartialPayment bool if isUint { - isTfPartialPayment = utils.IsFlagEnabled(flagsField, uint(tfPartialPayment)) + isTfPartialPayment = IsFlagEnabled(flagsField, uint(tfPartialPayment)) } // TODO: check if tfPartialPayment is enabled if/when Flags is an object/map instead of a uint diff --git a/xrpl/model/transactions/payment_channel_claim.go b/xrpl/transaction/payment_channel_claim.go similarity index 97% rename from xrpl/model/transactions/payment_channel_claim.go rename to xrpl/transaction/payment_channel_claim.go index a835c05f..43f256e0 100644 --- a/xrpl/model/transactions/payment_channel_claim.go +++ b/xrpl/transaction/payment_channel_claim.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( diff --git a/xrpl/model/transactions/payment_channel_claim_test.go b/xrpl/transaction/payment_channel_claim_test.go similarity index 91% rename from xrpl/model/transactions/payment_channel_claim_test.go rename to xrpl/transaction/payment_channel_claim_test.go index d62d170c..39833958 100644 --- a/xrpl/model/transactions/payment_channel_claim_test.go +++ b/xrpl/transaction/payment_channel_claim_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestPaymentChannelClaimTx(t *testing.T) { @@ -31,7 +31,7 @@ func TestPaymentChannelClaimTx(t *testing.T) { "Signature": "30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B", "PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/payment_channel_create.go b/xrpl/transaction/payment_channel_create.go similarity index 84% rename from xrpl/model/transactions/payment_channel_create.go rename to xrpl/transaction/payment_channel_create.go index 41baadee..71a05d4f 100644 --- a/xrpl/model/transactions/payment_channel_create.go +++ b/xrpl/transaction/payment_channel_create.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type PaymentChannelCreate struct { diff --git a/xrpl/model/transactions/payment_channel_create_test.go b/xrpl/transaction/payment_channel_create_test.go similarity index 79% rename from xrpl/model/transactions/payment_channel_create_test.go rename to xrpl/transaction/payment_channel_create_test.go index 80a0f3e5..4adaf00e 100644 --- a/xrpl/model/transactions/payment_channel_create_test.go +++ b/xrpl/transaction/payment_channel_create_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestPaymentChannelCreate(t *testing.T) { @@ -30,7 +30,7 @@ func TestPaymentChannelCreate(t *testing.T) { "PublicKey": "abcd" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/payment_channel_fund.go b/xrpl/transaction/payment_channel_fund.go similarity index 80% rename from xrpl/model/transactions/payment_channel_fund.go rename to xrpl/transaction/payment_channel_fund.go index 8ce3cbd6..aaf197e5 100644 --- a/xrpl/model/transactions/payment_channel_fund.go +++ b/xrpl/transaction/payment_channel_fund.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type PaymentChannelFund struct { diff --git a/xrpl/model/transactions/payment_channel_fund_test.go b/xrpl/transaction/payment_channel_fund_test.go similarity index 76% rename from xrpl/model/transactions/payment_channel_fund_test.go rename to xrpl/transaction/payment_channel_fund_test.go index 626b7237..e4e713b5 100644 --- a/xrpl/model/transactions/payment_channel_fund_test.go +++ b/xrpl/transaction/payment_channel_fund_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestPaymentChannelFund(t *testing.T) { @@ -25,7 +25,7 @@ func TestPaymentChannelFund(t *testing.T) { "Channel": "ABACAD", "Amount": "2000" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/payment_test.go b/xrpl/transaction/payment_test.go similarity index 94% rename from xrpl/model/transactions/payment_test.go rename to xrpl/transaction/payment_test.go index afaff3e9..63187a75 100644 --- a/xrpl/model/transactions/payment_test.go +++ b/xrpl/transaction/payment_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestPaymentTx(t *testing.T) { @@ -37,7 +37,7 @@ func TestPaymentTx(t *testing.T) { }, "Destination": "hij" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/set_regular_key.go b/xrpl/transaction/set_regular_key.go similarity index 75% rename from xrpl/model/transactions/set_regular_key.go rename to xrpl/transaction/set_regular_key.go index 15c25c0e..adf11f1e 100644 --- a/xrpl/model/transactions/set_regular_key.go +++ b/xrpl/transaction/set_regular_key.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type SetRegularKey struct { diff --git a/xrpl/model/transactions/set_regular_key_test.go b/xrpl/transaction/set_regular_key_test.go similarity index 76% rename from xrpl/model/transactions/set_regular_key_test.go rename to xrpl/transaction/set_regular_key_test.go index 9f45fd25..bac977e2 100644 --- a/xrpl/model/transactions/set_regular_key_test.go +++ b/xrpl/transaction/set_regular_key_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestSetRegularKeyTx(t *testing.T) { @@ -25,7 +25,7 @@ func TestSetRegularKeyTx(t *testing.T) { "Fee": "10", "RegularKey": "def" }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/signer.go b/xrpl/transaction/signer.go similarity index 90% rename from xrpl/model/transactions/signer.go rename to xrpl/transaction/signer.go index 547f2ad8..f3a5c1a3 100644 --- a/xrpl/model/transactions/signer.go +++ b/xrpl/transaction/signer.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type Signer struct { diff --git a/xrpl/model/transactions/signer_list_set.go b/xrpl/transaction/signer_list_set.go similarity index 78% rename from xrpl/model/transactions/signer_list_set.go rename to xrpl/transaction/signer_list_set.go index 2b0c03eb..21b91e02 100644 --- a/xrpl/model/transactions/signer_list_set.go +++ b/xrpl/transaction/signer_list_set.go @@ -1,7 +1,7 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" ) type SignerListSet struct { diff --git a/xrpl/model/transactions/signer_list_set_test.go b/xrpl/transaction/signer_list_set_test.go similarity index 85% rename from xrpl/model/transactions/signer_list_set_test.go rename to xrpl/transaction/signer_list_set_test.go index f32d5b7f..f86325e6 100644 --- a/xrpl/model/transactions/signer_list_set_test.go +++ b/xrpl/transaction/signer_list_set_test.go @@ -1,13 +1,13 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/testutil" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) func TestSignerListSetTx(t *testing.T) { @@ -66,7 +66,7 @@ func TestSignerListSetTx(t *testing.T) { } ] }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/ticket_create.go b/xrpl/transaction/ticket_create.go similarity index 96% rename from xrpl/model/transactions/ticket_create.go rename to xrpl/transaction/ticket_create.go index c6507dd3..31ac2087 100644 --- a/xrpl/model/transactions/ticket_create.go +++ b/xrpl/transaction/ticket_create.go @@ -1,4 +1,4 @@ -package transactions +package transaction // A TicketCreate transaction sets aside one or more sequence numbers as Tickets. type TicketCreate struct { diff --git a/xrpl/model/transactions/ticket_create_test.go b/xrpl/transaction/ticket_create_test.go similarity index 87% rename from xrpl/model/transactions/ticket_create_test.go rename to xrpl/transaction/ticket_create_test.go index e37ce4fd..ea7232b5 100644 --- a/xrpl/model/transactions/ticket_create_test.go +++ b/xrpl/transaction/ticket_create_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestTicketCreateTx(t *testing.T) { @@ -28,7 +28,7 @@ func TestTicketCreateTx(t *testing.T) { "TicketCount": 5 }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/transaction_metadata.go b/xrpl/transaction/transaction_metadata.go similarity index 92% rename from xrpl/model/transactions/transaction_metadata.go rename to xrpl/transaction/transaction_metadata.go index 1df3d726..b6d42ae2 100644 --- a/xrpl/model/transactions/transaction_metadata.go +++ b/xrpl/transaction/transaction_metadata.go @@ -1,8 +1,8 @@ -package transactions +package transaction import ( - "github.com/Peersyst/xrpl-go/xrpl/model/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/ledger-entry-types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) type TxMeta interface { diff --git a/xrpl/model/transactions/trust_set.go b/xrpl/transaction/trust_set.go similarity index 98% rename from xrpl/model/transactions/trust_set.go rename to xrpl/transaction/trust_set.go index 6c9f7de4..df32b829 100644 --- a/xrpl/model/transactions/trust_set.go +++ b/xrpl/transaction/trust_set.go @@ -1,9 +1,9 @@ -package transactions +package transaction import ( "encoding/json" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) const ( diff --git a/xrpl/model/transactions/trust_set_test.go b/xrpl/transaction/trust_set_test.go similarity index 94% rename from xrpl/model/transactions/trust_set_test.go rename to xrpl/transaction/trust_set_test.go index b714b871..1d80434d 100644 --- a/xrpl/model/transactions/trust_set_test.go +++ b/xrpl/transaction/trust_set_test.go @@ -1,12 +1,12 @@ -package transactions +package transaction import ( "encoding/json" "reflect" "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 TestTrustSetTx(t *testing.T) { @@ -39,7 +39,7 @@ func TestTrustSetTx(t *testing.T) { "value": "100" } }` - if err := test.SerializeAndDeserialize(t, s, j); err != nil { + if err := testutil.SerializeAndDeserialize(t, s, j); err != nil { t.Error(err) } diff --git a/xrpl/model/transactions/tx.go b/xrpl/transaction/tx.go similarity index 98% rename from xrpl/model/transactions/tx.go rename to xrpl/transaction/tx.go index 417fc970..6f9c78ca 100644 --- a/xrpl/model/transactions/tx.go +++ b/xrpl/transaction/tx.go @@ -1,10 +1,10 @@ -package transactions +package transaction import ( "encoding/json" "fmt" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) // TODO: Refactor to use a single interface for all transaction types diff --git a/xrpl/model/transactions/tx_type.go b/xrpl/transaction/tx_type.go similarity index 98% rename from xrpl/model/transactions/tx_type.go rename to xrpl/transaction/tx_type.go index b3429b59..ad62d1c5 100644 --- a/xrpl/model/transactions/tx_type.go +++ b/xrpl/transaction/tx_type.go @@ -1,4 +1,4 @@ -package transactions +package transaction type TxType string diff --git a/xrpl/model/transactions/types/address.go b/xrpl/transaction/types/address.go similarity index 100% rename from xrpl/model/transactions/types/address.go rename to xrpl/transaction/types/address.go diff --git a/xrpl/model/transactions/types/currency_amount.go b/xrpl/transaction/types/currency_amount.go similarity index 100% rename from xrpl/model/transactions/types/currency_amount.go rename to xrpl/transaction/types/currency_amount.go diff --git a/xrpl/model/transactions/types/hash128.go b/xrpl/transaction/types/hash128.go similarity index 100% rename from xrpl/model/transactions/types/hash128.go rename to xrpl/transaction/types/hash128.go diff --git a/xrpl/model/transactions/types/hash256.go b/xrpl/transaction/types/hash256.go similarity index 100% rename from xrpl/model/transactions/types/hash256.go rename to xrpl/transaction/types/hash256.go diff --git a/xrpl/model/transactions/types/nftoken.go b/xrpl/transaction/types/nftoken.go similarity index 100% rename from xrpl/model/transactions/types/nftoken.go rename to xrpl/transaction/types/nftoken.go diff --git a/xrpl/model/transactions/types/nftoken_id.go b/xrpl/transaction/types/nftoken_id.go similarity index 100% rename from xrpl/model/transactions/types/nftoken_id.go rename to xrpl/transaction/types/nftoken_id.go diff --git a/xrpl/model/transactions/types/nftoken_uri.go b/xrpl/transaction/types/nftoken_uri.go similarity index 100% rename from xrpl/model/transactions/types/nftoken_uri.go rename to xrpl/transaction/types/nftoken_uri.go diff --git a/xrpl/model/transactions/validations_commons.go b/xrpl/transaction/validations_commons.go similarity index 99% rename from xrpl/model/transactions/validations_commons.go rename to xrpl/transaction/validations_commons.go index 9e138674..6e0218ce 100644 --- a/xrpl/model/transactions/validations_commons.go +++ b/xrpl/transaction/validations_commons.go @@ -1,4 +1,4 @@ -package transactions +package transaction import ( "fmt" diff --git a/xrpl/model/transactions/validations_xrpl_objects.go b/xrpl/transaction/validations_xrpl_objects.go similarity index 99% rename from xrpl/model/transactions/validations_xrpl_objects.go rename to xrpl/transaction/validations_xrpl_objects.go index 441b8b06..488cd385 100644 --- a/xrpl/model/transactions/validations_xrpl_objects.go +++ b/xrpl/transaction/validations_xrpl_objects.go @@ -1,4 +1,4 @@ -package transactions +package transaction import ( "errors" diff --git a/xrpl/model/transactions/validations_xrpl_objects_test.go b/xrpl/transaction/validations_xrpl_objects_test.go similarity index 99% rename from xrpl/model/transactions/validations_xrpl_objects_test.go rename to xrpl/transaction/validations_xrpl_objects_test.go index 01e868ab..da51b407 100644 --- a/xrpl/model/transactions/validations_xrpl_objects_test.go +++ b/xrpl/transaction/validations_xrpl_objects_test.go @@ -1,4 +1,4 @@ -package transactions +package transaction import ( "testing" diff --git a/xrpl/wallet.go b/xrpl/wallet.go index 4ba01c48..fe888b4f 100644 --- a/xrpl/wallet.go +++ b/xrpl/wallet.go @@ -147,7 +147,7 @@ func (w *Wallet) Sign(tx map[string]interface{}) (string, string, error) { return "", "", err } - txHash, err = hash.HashSignedTx(txBlob) + txHash, err = hash.HashTxBlob(txBlob) if err != nil { return "", "", err } diff --git a/xrpl/websocket/client.go b/xrpl/websocket/client.go index a2e18282..b152b085 100644 --- a/xrpl/websocket/client.go +++ b/xrpl/websocket/client.go @@ -4,14 +4,21 @@ import ( "bytes" "encoding/json" "errors" + "fmt" + "math" "sync/atomic" binarycodec "github.com/Peersyst/xrpl-go/binary-codec" "github.com/Peersyst/xrpl-go/xrpl" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" + "github.com/Peersyst/xrpl-go/xrpl/currency" + transaction "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/mitchellh/mapstructure" - requests "github.com/Peersyst/xrpl-go/xrpl/model/requests/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" + "github.com/Peersyst/xrpl-go/xrpl/queries/account" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/server" + requests "github.com/Peersyst/xrpl-go/xrpl/queries/transactions" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" "github.com/gorilla/websocket" ) @@ -37,7 +44,7 @@ func NewWebsocketClient(cfg WebsocketClientConfig) *WebsocketClient { } } -func (c *WebsocketClient) Autofill(tx *transactions.FlatTransaction) error { +func (c *WebsocketClient) Autofill(tx *transaction.FlatTransaction) error { if err := c.setValidTransactionAddresses(tx); err != nil { return err } @@ -70,14 +77,14 @@ func (c *WebsocketClient) Autofill(tx *transactions.FlatTransaction) error { return err } } - if txType, ok := (*tx)["TransactionType"].(transactions.TxType); ok { - if acc, ok := (*tx)["Account"].(types.Address); txType == transactions.AccountDeleteTx && ok { + if txType, ok := (*tx)["TransactionType"].(transaction.TxType); ok { + if acc, ok := (*tx)["Account"].(types.Address); txType == transaction.AccountDeleteTx && ok { err := c.checkAccountDeleteBlockers(acc) if err != nil { return err } } - if txType == transactions.PaymentTx { + if txType == transaction.PaymentTx { err := c.checkPaymentAmounts(tx) if err != nil { return err @@ -155,7 +162,7 @@ func (c *WebsocketClient) SubmitTransactionBlob(txBlob string, failHard bool) (* _, okTxSig := tx["TxSignature"].(string) _, okPubKey := tx["SigningPubKey"].(string) - signers, okSigners := tx["Signers"].([]transactions.Signer) + signers, okSigners := tx["Signers"].([]transaction.Signer) if okSigners && len(signers) > 0 { for _, signer := range signers { @@ -185,3 +192,197 @@ func (c *WebsocketClient) submitRequest(req *requests.SubmitRequest) (*requests. } return &subRes, nil } + +func (c *WebsocketClient) formatRequest(req WebsocketXRPLRequest, id int, marker any) ([]byte, error) { + m := make(map[string]any) + m["id"] = id + m["command"] = req.Method() + if marker != nil { + m["marker"] = marker + } + dec, _ := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &m}) + err := dec.Decode(req) + if err != nil { + return nil, err + } + + return json.Marshal(m) +} + +// TODO: Implement this when IsValidXAddress is implemented +func (c *WebsocketClient) getClassicAccountAndTag(address string) (string, uint32) { + return address, 0 +} + +func (c *WebsocketClient) convertTransactionAddressToClassicAddress(tx *transaction.FlatTransaction, fieldName string) { + if address, ok := (*tx)[fieldName].(string); ok { + classicAddress, _ := c.getClassicAccountAndTag(address) + (*tx)[fieldName] = classicAddress + } +} + +func (c *WebsocketClient) validateTransactionAddress(tx *transaction.FlatTransaction, addressField, tagField string) error { + classicAddress, tag := c.getClassicAccountAndTag((*tx)[addressField].(string)) + (*tx)[addressField] = classicAddress + + if tag != uint32(0) { + if txTag, ok := (*tx)[tagField].(uint32); ok && txTag != tag { + return fmt.Errorf("the %s, if present, must be equal to the tag of the %s", addressField, tagField) + } + (*tx)[tagField] = tag + } + + return nil +} + +// Sets valid addresses for the transaction. +func (c *WebsocketClient) setValidTransactionAddresses(tx *transaction.FlatTransaction) error { + // Validate if "Account" address is an xAddress + if err := c.validateTransactionAddress(tx, "Account", "SourceTag"); err != nil { + return err + } + + if _, ok := (*tx)["Destination"]; ok { + if err := c.validateTransactionAddress(tx, "Destination", "DestinationTag"); err != nil { + return err + } + } + + // DepositPreuaht + c.convertTransactionAddressToClassicAddress(tx, "Authorize") + c.convertTransactionAddressToClassicAddress(tx, "Unauthorize") + // EscrowCancel, EscrowFinish + c.convertTransactionAddressToClassicAddress(tx, "Owner") + // SetRegularKey + c.convertTransactionAddressToClassicAddress(tx, "RegularKey") + + return nil +} + +// Sets the next valid sequence number for a given transaction. +func (c *WebsocketClient) setTransactionNextValidSequenceNumber(tx *transaction.FlatTransaction) error { + if _, ok := (*tx)["Account"].(string); !ok { + return errors.New("missing Account in transaction") + } + res, err := c.GetAccountInfo(&account.AccountInfoRequest{ + Account: types.Address((*tx)["Account"].(string)), + LedgerIndex: common.LedgerTitle("current"), + }) + + if err != nil { + return err + } + + (*tx)["Sequence"] = int(res.AccountData.Sequence) + return nil +} + +// Calculates the current transaction fee for the ledger. +// Note: This is a public API that can be called directly. +func (c *WebsocketClient) getFeeXrp(cushion float32) (string, error) { + res, err := c.GetServerInfo(&server.ServerInfoRequest{}) + if err != nil { + return "", err + } + + if res.Info.ValidatedLedger.BaseFeeXRP == 0 { + return "", errors.New("getFeeXrp: could not get BaseFeeXrp from ServerInfo") + } + + loadFactor := res.Info.LoadFactor + if res.Info.LoadFactor == 0 { + loadFactor = 1 + } + + fee := res.Info.ValidatedLedger.BaseFeeXRP * float32(loadFactor) * cushion + + if fee > c.cfg.maxFeeXRP { + fee = c.cfg.maxFeeXRP + } + + // Round fee to NUM_DECIMAL_PLACES + roundedFee := float32(math.Round(float64(fee)*math.Pow10(int(currency.MAX_FRACTION_LENGTH)))) / float32(math.Pow10(int(currency.MAX_FRACTION_LENGTH))) + + // Convert the rounded fee back to a string with NUM_DECIMAL_PLACES + return fmt.Sprintf("%.*f", currency.MAX_FRACTION_LENGTH, roundedFee), nil +} + +// Calculates the fee per transaction type. +// +// TODO: Add fee support for `EscrowFinish` `AccountDelete`, `AMMCreate`, and multisigned transactions. +func (c *WebsocketClient) calculateFeePerTransactionType(tx *transaction.FlatTransaction) error { + fee, err := c.getFeeXrp(c.cfg.feeCushion) + if err != nil { + return err + } + + feeDrops, err := currency.XrpToDrops(fee) + if err != nil { + return err + } + + (*tx)["Fee"] = feeDrops + + return nil +} + +// Sets the latest validated ledger sequence for the transaction. +// Modifies the `LastLedgerSequence` field in the tx. +func (c *WebsocketClient) setLastLedgerSequence(tx *transaction.FlatTransaction) error { + index, err := c.GetLedgerIndex() + if err != nil { + return err + } + + (*tx)["LastLedgerSequence"] = index.Int() + int(LEDGER_OFFSET) + return err +} + +// Checks for any blockers that prevent the deletion of an account. +// Returns nil if there are no blockers, otherwise returns an error. +func (c *WebsocketClient) checkAccountDeleteBlockers(address types.Address) error { + accObjects, err := c.GetAccountObjects(&account.AccountObjectsRequest{ + Account: address, + LedgerIndex: common.LedgerTitle("validated"), + DeletionBlockersOnly: true, + }) + if err != nil { + return err + } + + if len(accObjects.AccountObjects) > 0 { + return errors.New("account %s cannot be deleted; there are Escrows, PayChannels, RippleStates, or Checks associated with the account") + } + return nil +} + +func (c *WebsocketClient) checkPaymentAmounts(tx *transaction.FlatTransaction) error { + if _, ok := (*tx)["DeliverMax"]; ok { + if _, ok := (*tx)["Amount"]; !ok { + (*tx)["Amount"] = (*tx)["DeliverMax"] + } else { + if (*tx)["Amount"] != (*tx)["DeliverMax"] { + return errors.New("payment transaction: Amount and DeliverMax fields must be identical when both are provided") + } + } + } + return nil +} + +// Sets a transaction's flags to its numeric representation. +// TODO: Add flag support for AMMDeposit, AMMWithdraw, +// NFTTOkenCreateOffer, NFTokenMint, OfferCreate, XChainModifyBridge (not supported). +func (c *WebsocketClient) setTransactionFlags(tx *transaction.FlatTransaction) error { + flags, ok := (*tx)["Flags"].(uint32) + if !ok && flags > 0 { + (*tx)["Flags"] = int(0) + return nil + } + + _, ok = (*tx)["TransactionType"].(string) + if !ok { + return errors.New("transaction type is missing in transaction") + } + + return nil +} diff --git a/xrpl/websocket/client_test.go b/xrpl/websocket/client_test.go index 24f56f36..5e4094fd 100644 --- a/xrpl/websocket/client_test.go +++ b/xrpl/websocket/client_test.go @@ -2,10 +2,14 @@ package websocket import ( "encoding/json" + "errors" + "reflect" "testing" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" - "github.com/Peersyst/xrpl-go/xrpl/test" + "github.com/Peersyst/xrpl-go/xrpl/queries/account" + "github.com/Peersyst/xrpl-go/xrpl/transaction" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" + "github.com/Peersyst/xrpl-go/xrpl/websocket/testutil" "github.com/gorilla/websocket" "github.com/stretchr/testify/require" ) @@ -165,7 +169,7 @@ func TestSendRequest(t *testing.T) { for _, tc := range tt { t.Run(tc.description, func(t *testing.T) { - ws := &test.MockWebSocketServer{Msgs: tc.serverMessages} + ws := &testutil.MockWebSocketServer{Msgs: tc.serverMessages} s := ws.TestWebSocketServer(func(c *websocket.Conn) { for _, m := range tc.serverMessages { err := c.WriteJSON(m) @@ -175,7 +179,7 @@ func TestSendRequest(t *testing.T) { } }) defer s.Close() - url, _ := test.ConvertHttpToWS(s.URL) + url, _ := testutil.ConvertHttpToWS(s.URL) cl := &WebsocketClient{cfg: WebsocketClientConfig{ host: url, }} @@ -191,3 +195,601 @@ func TestSendRequest(t *testing.T) { }) } } + +func TestWebsocketClient_formatRequest(t *testing.T) { + ws := &WebsocketClient{} + tt := []struct { + description string + req WebsocketXRPLRequest + id int + marker any + expected string + expectedErr error + }{ + { + description: "valid request", + req: &account.AccountChannelsRequest{ + Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + DestinationAccount: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + Limit: 70, + }, + id: 1, + marker: nil, + expected: `{ + "id": 1, + "command":"account_channels", + "account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "destination_account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "limit":70 + }`, + expectedErr: nil, + }, + { + description: "valid request with marker", + req: &account.AccountChannelsRequest{ + Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + DestinationAccount: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + Limit: 70, + }, + id: 1, + marker: "hdsohdaoidhadasd", + expected: `{ + "id": 1, + "command":"account_channels", + "account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "destination_account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "limit":70, + "marker":"hdsohdaoidhadasd" + }`, + expectedErr: nil, + }, + } + + for _, tc := range tt { + t.Run(tc.description, func(t *testing.T) { + a, err := ws.formatRequest(tc.req, tc.id, tc.marker) + + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + } else { + require.NoError(t, err) + require.JSONEq(t, tc.expected, string(a)) + } + }) + } +} + +func TestWebsocketClient_convertTransactionAddressToClassicAddress(t *testing.T) { + ws := &WebsocketClient{} + tests := []struct { + name string + tx transaction.FlatTransaction + fieldName string + expected transaction.FlatTransaction + }{ + { + name: "No conversion for classic address", + tx: transaction.FlatTransaction{ + "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + fieldName: "Destination", + expected: transaction.FlatTransaction{ + "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + }, + { + name: "Field not present in transaction", + tx: transaction.FlatTransaction{ + "Amount": "1000000", + }, + fieldName: "Destination", + expected: transaction.FlatTransaction{ + "Amount": "1000000", + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ws.convertTransactionAddressToClassicAddress(&tt.tx, tt.fieldName) + if reflect.DeepEqual(tt.expected, &tt.tx) { + t.Errorf("expected %+v, result %+v", tt.expected, &tt.tx) + } + }) + } +} + +func TestWebsocketClient_validateTransactionAddress(t *testing.T) { + ws := &WebsocketClient{} + tests := []struct { + name string + tx transaction.FlatTransaction + addressField string + tagField string + expected transaction.FlatTransaction + expectedErr error + }{ + { + name: "Valid classic address without tag", + tx: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + addressField: "Account", + tagField: "SourceTag", + expected: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + expectedErr: nil, + }, + { + name: "Valid classic address with tag", + tx: transaction.FlatTransaction{ + "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "DestinationTag": uint32(12345), + }, + addressField: "Destination", + tagField: "DestinationTag", + expected: transaction.FlatTransaction{ + "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "DestinationTag": uint32(12345), + }, + expectedErr: nil, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := ws.validateTransactionAddress(&tt.tx, tt.addressField, tt.tagField) + + if tt.expectedErr != nil { + if !errors.Is(err, tt.expectedErr) { + t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) + } + } else if err != nil { + t.Errorf("Unexpected error: %v", err) + } + + if !reflect.DeepEqual(tt.expected, tt.tx) { + t.Errorf("Expected %v, but got %v", tt.expected, tt.tx) + } + }) + } +} + +func TestWebsocketClient_setValidTransactionAddresses(t *testing.T) { + tests := []struct { + name string + tx transaction.FlatTransaction + expected transaction.FlatTransaction + expectedErr error + }{ + { + name: "Valid transaction with classic addresses", + tx: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", + }, + expected: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", + }, + expectedErr: nil, + }, + { + name: "Transaction with additional address fields", + tx: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", + "Owner": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "RegularKey": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + expected: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", + "Owner": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "RegularKey": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + expectedErr: nil, + }, + } + + ws := &WebsocketClient{} + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := ws.setValidTransactionAddresses(&tt.tx) + + if tt.expectedErr != nil { + if !errors.Is(err, tt.expectedErr) { + t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) + } + } else if err != nil { + t.Errorf("Unexpected error: %v", err) + } + + if !reflect.DeepEqual(tt.expected, tt.tx) { + t.Errorf("Expected %v, but got %v", tt.expected, tt.tx) + } + }) + } +} + +func TestWebsocketClient_setTransactionNextValidSequenceNumber(t *testing.T) { + tests := []struct { + name string + tx transaction.FlatTransaction + serverMessages []map[string]any + expected transaction.FlatTransaction + expectedErr error + }{ + { + name: "Valid transaction", + tx: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + }, + serverMessages: []map[string]any{ + { + "id": 1, + "result": map[string]any{ + "account_data": map[string]any{ + "Sequence": json.Number("42"), + }, + "ledger_current_index": json.Number("100"), + }, + }, + }, + expected: transaction.FlatTransaction{ + "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", + "Sequence": int(42), + }, + expectedErr: nil, + }, + { + name: "Missing Account", + tx: transaction.FlatTransaction{}, + serverMessages: []map[string]any{}, + expected: transaction.FlatTransaction{}, + expectedErr: errors.New("missing Account in transaction"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ws := &testutil.MockWebSocketServer{Msgs: tt.serverMessages} + s := ws.TestWebSocketServer(func(c *websocket.Conn) { + for _, m := range tt.serverMessages { + err := c.WriteJSON(m) + if err != nil { + t.Errorf("error writing message: %v", err) + } + } + }) + defer s.Close() + + url, _ := testutil.ConvertHttpToWS(s.URL) + cl := &WebsocketClient{ + cfg: WebsocketClientConfig{ + host: url, + }, + } + + err := cl.setTransactionNextValidSequenceNumber(&tt.tx) + + if tt.expectedErr != nil { + if !reflect.DeepEqual(err.Error(), tt.expectedErr.Error()) { + t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) + } + } else { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + + if !reflect.DeepEqual(tt.expected, tt.tx) { + t.Logf("Expected:") + for k, v := range tt.expected { + t.Logf(" %s: %v (type: %T)", k, v, v) + } + t.Logf("Got:") + for k, v := range tt.tx { + t.Logf(" %s: %v (type: %T)", k, v, v) + } + t.Errorf("Expected %v but got %v", tt.expected, tt.tx) + } + }) + } +} + +func TestWebsocket_calculateFeePerTransactionType(t *testing.T) { + tests := []struct { + name string + tx transaction.FlatTransaction + serverMessages []map[string]any + expectedFee string + expectedErr error + feeCushion float32 + }{ + { + name: "Basic fee calculation", + tx: transaction.FlatTransaction{ + "TransactionType": transaction.PaymentTx, + }, + serverMessages: []map[string]any{ + { + "id": 1, + "result": map[string]any{ + "info": map[string]any{ + "validated_ledger": map[string]any{ + "base_fee_xrp": float32(0.00001), + }, + "load_factor": float32(1), + }, + }, + }, + }, + expectedFee: "10", + expectedErr: nil, + feeCushion: 1, + }, + { + name: "Fee calculation with high load factor", + tx: transaction.FlatTransaction{ + "TransactionType": transaction.PaymentTx, + }, + serverMessages: []map[string]any{ + { + "id": 1, + "result": map[string]any{ + "info": map[string]any{ + "validated_ledger": map[string]any{ + "base_fee_xrp": float32(0.00001), + }, + "load_factor": float32(1000), + }, + }, + }, + }, + expectedFee: "10000", + expectedErr: nil, + feeCushion: 1, + }, + { + name: "Fee calculation with max fee limit", + tx: transaction.FlatTransaction{ + "TransactionType": transaction.PaymentTx, + }, + serverMessages: []map[string]any{ + { + "id": 1, + "result": map[string]any{ + "info": map[string]any{ + "validated_ledger": map[string]any{ + "base_fee_xrp": float32(1), + }, + "load_factor": float32(1000), + }, + }, + }, + }, + expectedFee: "2000000", + expectedErr: nil, + feeCushion: 1, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ws := &testutil.MockWebSocketServer{Msgs: tt.serverMessages} + s := ws.TestWebSocketServer(func(c *websocket.Conn) { + for _, m := range tt.serverMessages { + err := c.WriteJSON(m) + if err != nil { + t.Errorf("error writing message: %v", err) + } + } + }) + defer s.Close() + + url, _ := testutil.ConvertHttpToWS(s.URL) + cl := &WebsocketClient{ + cfg: WebsocketClientConfig{ + host: url, + feeCushion: tt.feeCushion, + maxFeeXRP: DEFAULT_MAX_FEE_XRP, + }, + } + + err := cl.calculateFeePerTransactionType(&tt.tx) + + if tt.expectedErr != nil { + if !reflect.DeepEqual(err.Error(), tt.expectedErr.Error()) { + t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) + } + } else { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + if !reflect.DeepEqual(tt.expectedFee, tt.tx["Fee"]) { + t.Errorf("Expected fee %v, but got %v", tt.expectedFee, tt.tx["Fee"]) + } + } + }) + } +} + +func TestWebsocketClient_setLastLedgerSequence(t *testing.T) { + tests := []struct { + name string + serverMessages []map[string]any + tx transaction.FlatTransaction + expectedTx transaction.FlatTransaction + expectedErr error + }{ + { + name: "Successfully set LastLedgerSequence", + serverMessages: []map[string]any{ + { + "id": 1, + "result": transaction.FlatTransaction{ + "ledger_index": 1000, + }, + }, + }, + tx: transaction.FlatTransaction{}, + expectedTx: transaction.FlatTransaction{"LastLedgerSequence": int(1000 + LEDGER_OFFSET)}, + expectedErr: nil, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ws := &testutil.MockWebSocketServer{Msgs: tt.serverMessages} + s := ws.TestWebSocketServer(func(c *websocket.Conn) { + for _, m := range tt.serverMessages { + err := c.WriteJSON(m) + if err != nil { + t.Errorf("error writing message: %v", err) + } + } + }) + defer s.Close() + + url, _ := testutil.ConvertHttpToWS(s.URL) + cl := &WebsocketClient{ + cfg: WebsocketClientConfig{ + host: url, + }, + } + err := cl.setLastLedgerSequence(&tt.tx) + + if tt.expectedErr != nil { + if err == nil || err.Error() != tt.expectedErr.Error() { + t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) + } + } else { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + if !reflect.DeepEqual(tt.expectedTx, tt.tx) { + t.Errorf("Expected tx %v, but got %v", tt.expectedTx, tt.tx) + } + } + }) + } +} + +func TestWebsocketClient_checkAccountDeleteBlockers(t *testing.T) { + tests := []struct { + name string + address types.Address + serverMessages []map[string]any + expectedErr error + }{ + { + name: "No blockers", + address: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + serverMessages: []map[string]any{ + { + "id": 1, + "result": map[string]any{ + "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "account_objects": []any{}, + "ledger_hash": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", + "ledger_index": 30, + "validated": true, + }, + }, + }, + expectedErr: nil, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ws := &testutil.MockWebSocketServer{Msgs: tt.serverMessages} + s := ws.TestWebSocketServer(func(c *websocket.Conn) { + for _, m := range tt.serverMessages { + err := c.WriteJSON(m) + if err != nil { + t.Errorf("error writing message: %v", err) + } + } + }) + defer s.Close() + + url, _ := testutil.ConvertHttpToWS(s.URL) + cl := &WebsocketClient{ + cfg: WebsocketClientConfig{ + host: url, + }, + } + + err := cl.checkAccountDeleteBlockers(tt.address) + + if tt.expectedErr != nil { + if err == nil || err.Error() != tt.expectedErr.Error() { + t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) + } + } else { + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + }) + } +} + +func TestWebsocketClient_setTransactionFlags(t *testing.T) { + tests := []struct { + name string + tx transaction.FlatTransaction + expected uint32 + wantErr bool + }{ + { + name: "No flags set", + tx: transaction.FlatTransaction{ + "TransactionType": string(transaction.PaymentTx), + }, + expected: uint32(0), + wantErr: false, + }, + { + name: "Flags already set", + tx: transaction.FlatTransaction{ + "TransactionType": string(transaction.PaymentTx), + "Flags": uint32(1), + }, + expected: 1, + wantErr: false, + }, + { + name: "Missing TransactionType", + tx: transaction.FlatTransaction{ + "Flags": uint32(1), + }, + expected: 0, + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := &WebsocketClient{} + err := c.setTransactionFlags(&tt.tx) + + if (err != nil) != tt.wantErr { + + t.Errorf("setTransactionFlags() error = %v, wantErr %v", err, tt.wantErr) + return + } + + if !tt.wantErr { + flags, ok := tt.tx["Flags"] + if !ok && tt.expected != 0 { + t.Errorf("setTransactionFlags() got = %v (type %T), want %v (type %T)", flags, flags, tt.expected, tt.expected) + } + } + }) + } +} \ No newline at end of file diff --git a/xrpl/websocket/queries.go b/xrpl/websocket/queries.go index e7873bf8..4ac3145c 100644 --- a/xrpl/websocket/queries.go +++ b/xrpl/websocket/queries.go @@ -1,12 +1,12 @@ package websocket import ( - "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/ledger" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/server" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/utils" + "github.com/Peersyst/xrpl-go/xrpl/currency" + "github.com/Peersyst/xrpl-go/xrpl/queries/account" + "github.com/Peersyst/xrpl-go/xrpl/queries/common" + "github.com/Peersyst/xrpl-go/xrpl/queries/ledger" + "github.com/Peersyst/xrpl-go/xrpl/queries/server" + "github.com/Peersyst/xrpl-go/xrpl/transaction/types" ) // GetAccountInfo retrieves information about an account on the XRP Ledger. @@ -51,7 +51,7 @@ func (c *WebsocketClient) GetXrpBalance(address string) (string, error) { return "", err } - xrpBalance, err := utils.DropsToXrp(res.AccountData.Balance.String()) + xrpBalance, err := currency.DropsToXrp(res.AccountData.Balance.String()) if err != nil { return "", err } diff --git a/xrpl/test/mock-webserver.go b/xrpl/websocket/testutil/mock-webserver.go similarity index 97% rename from xrpl/test/mock-webserver.go rename to xrpl/websocket/testutil/mock-webserver.go index 116943b7..8ba322cb 100644 --- a/xrpl/test/mock-webserver.go +++ b/xrpl/websocket/testutil/mock-webserver.go @@ -1,4 +1,4 @@ -package test +package testutil import ( "log" diff --git a/xrpl/websocket/utils.go b/xrpl/websocket/utils.go deleted file mode 100644 index 92877689..00000000 --- a/xrpl/websocket/utils.go +++ /dev/null @@ -1,210 +0,0 @@ -package websocket - -import ( - "encoding/json" - "errors" - "fmt" - "math" - - "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/common" - "github.com/Peersyst/xrpl-go/xrpl/model/requests/server" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/Peersyst/xrpl-go/xrpl/utils" - "github.com/mitchellh/mapstructure" -) - -func (c *WebsocketClient) formatRequest(req WebsocketXRPLRequest, id int, marker any) ([]byte, error) { - m := make(map[string]any) - m["id"] = id - m["command"] = req.Method() - if marker != nil { - m["marker"] = marker - } - dec, _ := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &m}) - err := dec.Decode(req) - if err != nil { - return nil, err - } - - return json.Marshal(m) -} - -// TODO: Implement this when IsValidXAddress is implemented -func (c *WebsocketClient) getClassicAccountAndTag(address string) (string, uint32) { - return address, 0 -} - -func (c *WebsocketClient) convertTransactionAddressToClassicAddress(tx *transactions.FlatTransaction, fieldName string) { - if address, ok := (*tx)[fieldName].(string); ok { - classicAddress, _ := c.getClassicAccountAndTag(address) - (*tx)[fieldName] = classicAddress - } -} - -func (c *WebsocketClient) validateTransactionAddress(tx *transactions.FlatTransaction, addressField, tagField string) error { - classicAddress, tag := c.getClassicAccountAndTag((*tx)[addressField].(string)) - (*tx)[addressField] = classicAddress - - if tag != uint32(0) { - if txTag, ok := (*tx)[tagField].(uint32); ok && txTag != tag { - return fmt.Errorf("the %s, if present, must be equal to the tag of the %s", addressField, tagField) - } - (*tx)[tagField] = tag - } - - return nil -} - -// Sets valid addresses for the transaction. -func (c *WebsocketClient) setValidTransactionAddresses(tx *transactions.FlatTransaction) error { - // Validate if "Account" address is an xAddress - if err := c.validateTransactionAddress(tx, "Account", "SourceTag"); err != nil { - return err - } - - if _, ok := (*tx)["Destination"]; ok { - if err := c.validateTransactionAddress(tx, "Destination", "DestinationTag"); err != nil { - return err - } - } - - // DepositPreuaht - c.convertTransactionAddressToClassicAddress(tx, "Authorize") - c.convertTransactionAddressToClassicAddress(tx, "Unauthorize") - // EscrowCancel, EscrowFinish - c.convertTransactionAddressToClassicAddress(tx, "Owner") - // SetRegularKey - c.convertTransactionAddressToClassicAddress(tx, "RegularKey") - - return nil -} - -// Sets the next valid sequence number for a given transaction. -func (c *WebsocketClient) setTransactionNextValidSequenceNumber(tx *transactions.FlatTransaction) error { - if _, ok := (*tx)["Account"].(string); !ok { - return errors.New("missing Account in transaction") - } - res, err := c.GetAccountInfo(&account.AccountInfoRequest{ - Account: types.Address((*tx)["Account"].(string)), - LedgerIndex: common.LedgerTitle("current"), - }) - - if err != nil { - return err - } - - (*tx)["Sequence"] = int(res.AccountData.Sequence) - return nil -} - -// Calculates the current transaction fee for the ledger. -// Note: This is a public API that can be called directly. -func (c *WebsocketClient) getFeeXrp(cushion float32) (string, error) { - res, err := c.GetServerInfo(&server.ServerInfoRequest{}) - if err != nil { - return "", err - } - - if res.Info.ValidatedLedger.BaseFeeXRP == 0 { - return "", errors.New("getFeeXrp: could not get BaseFeeXrp from ServerInfo") - } - - loadFactor := res.Info.LoadFactor - if res.Info.LoadFactor == 0 { - loadFactor = 1 - } - - fee := res.Info.ValidatedLedger.BaseFeeXRP * float32(loadFactor) * cushion - - if fee > c.cfg.maxFeeXRP { - fee = c.cfg.maxFeeXRP - } - - // Round fee to NUM_DECIMAL_PLACES - roundedFee := float32(math.Round(float64(fee)*math.Pow10(int(utils.MAX_FRACTION_LENGTH)))) / float32(math.Pow10(int(utils.MAX_FRACTION_LENGTH))) - - // Convert the rounded fee back to a string with NUM_DECIMAL_PLACES - return fmt.Sprintf("%.*f", utils.MAX_FRACTION_LENGTH, roundedFee), nil -} - -// Calculates the fee per transaction type. -// -// TODO: Add fee support for `EscrowFinish` `AccountDelete`, `AMMCreate`, and multisigned transactions. -func (c *WebsocketClient) calculateFeePerTransactionType(tx *transactions.FlatTransaction) error { - fee, err := c.getFeeXrp(c.cfg.feeCushion) - if err != nil { - return err - } - - feeDrops, err := utils.XrpToDrops(fee) - if err != nil { - return err - } - - (*tx)["Fee"] = feeDrops - - return nil -} - -// Sets the latest validated ledger sequence for the transaction. -// Modifies the `LastLedgerSequence` field in the tx. -func (c *WebsocketClient) setLastLedgerSequence(tx *transactions.FlatTransaction) error { - index, err := c.GetLedgerIndex() - if err != nil { - return err - } - - (*tx)["LastLedgerSequence"] = index.Int() + int(LEDGER_OFFSET) - return err -} - -// Checks for any blockers that prevent the deletion of an account. -// Returns nil if there are no blockers, otherwise returns an error. -func (c *WebsocketClient) checkAccountDeleteBlockers(address types.Address) error { - accObjects, err := c.GetAccountObjects(&account.AccountObjectsRequest{ - Account: address, - LedgerIndex: common.LedgerTitle("validated"), - DeletionBlockersOnly: true, - }) - if err != nil { - return err - } - - if len(accObjects.AccountObjects) > 0 { - return errors.New("account %s cannot be deleted; there are Escrows, PayChannels, RippleStates, or Checks associated with the account") - } - return nil -} - -func (c *WebsocketClient) checkPaymentAmounts(tx *transactions.FlatTransaction) error { - if _, ok := (*tx)["DeliverMax"]; ok { - if _, ok := (*tx)["Amount"]; !ok { - (*tx)["Amount"] = (*tx)["DeliverMax"] - } else { - if (*tx)["Amount"] != (*tx)["DeliverMax"] { - return errors.New("payment transaction: Amount and DeliverMax fields must be identical when both are provided") - } - } - } - return nil -} - -// Sets a transaction's flags to its numeric representation. -// TODO: Add flag support for AMMDeposit, AMMWithdraw, -// NFTTOkenCreateOffer, NFTokenMint, OfferCreate, XChainModifyBridge (not supported). -func (c *WebsocketClient) setTransactionFlags(tx *transactions.FlatTransaction) error { - flags, ok := (*tx)["Flags"].(uint32) - if !ok && flags > 0 { - (*tx)["Flags"] = int(0) - return nil - } - - _, ok = (*tx)["TransactionType"].(string) - if !ok { - return errors.New("transaction type is missing in transaction") - } - - return nil -} diff --git a/xrpl/websocket/utils_test.go b/xrpl/websocket/utils_test.go deleted file mode 100644 index 532fe596..00000000 --- a/xrpl/websocket/utils_test.go +++ /dev/null @@ -1,614 +0,0 @@ -package websocket - -import ( - "encoding/json" - "errors" - "reflect" - "testing" - - "github.com/Peersyst/xrpl-go/xrpl/model/requests/account" - "github.com/Peersyst/xrpl-go/xrpl/test" - - "github.com/Peersyst/xrpl-go/xrpl/model/transactions" - "github.com/Peersyst/xrpl-go/xrpl/model/transactions/types" - "github.com/gorilla/websocket" - "github.com/stretchr/testify/require" -) - -func TestWebsocketClient_formatRequest(t *testing.T) { - ws := &WebsocketClient{} - tt := []struct { - description string - req WebsocketXRPLRequest - id int - marker any - expected string - expectedErr error - }{ - { - description: "valid request", - req: &account.AccountChannelsRequest{ - Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - DestinationAccount: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - Limit: 70, - }, - id: 1, - marker: nil, - expected: `{ - "id": 1, - "command":"account_channels", - "account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "destination_account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "limit":70 - }`, - expectedErr: nil, - }, - { - description: "valid request with marker", - req: &account.AccountChannelsRequest{ - Account: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - DestinationAccount: "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - Limit: 70, - }, - id: 1, - marker: "hdsohdaoidhadasd", - expected: `{ - "id": 1, - "command":"account_channels", - "account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "destination_account":"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "limit":70, - "marker":"hdsohdaoidhadasd" - }`, - expectedErr: nil, - }, - } - - for _, tc := range tt { - t.Run(tc.description, func(t *testing.T) { - a, err := ws.formatRequest(tc.req, tc.id, tc.marker) - - if tc.expectedErr != nil { - require.EqualError(t, err, tc.expectedErr.Error()) - } else { - require.NoError(t, err) - require.JSONEq(t, tc.expected, string(a)) - } - }) - } -} - -func TestWebsocketClient_convertTransactionAddressToClassicAddress(t *testing.T) { - ws := &WebsocketClient{} - tests := []struct { - name string - tx transactions.FlatTransaction - fieldName string - expected transactions.FlatTransaction - }{ - { - name: "No conversion for classic address", - tx: transactions.FlatTransaction{ - "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - fieldName: "Destination", - expected: transactions.FlatTransaction{ - "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - }, - { - name: "Field not present in transaction", - tx: transactions.FlatTransaction{ - "Amount": "1000000", - }, - fieldName: "Destination", - expected: transactions.FlatTransaction{ - "Amount": "1000000", - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ws.convertTransactionAddressToClassicAddress(&tt.tx, tt.fieldName) - if reflect.DeepEqual(tt.expected, &tt.tx) { - t.Errorf("expected %+v, result %+v", tt.expected, &tt.tx) - } - }) - } -} - -func TestWebsocketClient_validateTransactionAddress(t *testing.T) { - ws := &WebsocketClient{} - tests := []struct { - name string - tx transactions.FlatTransaction - addressField string - tagField string - expected transactions.FlatTransaction - expectedErr error - }{ - { - name: "Valid classic address without tag", - tx: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - addressField: "Account", - tagField: "SourceTag", - expected: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - expectedErr: nil, - }, - { - name: "Valid classic address with tag", - tx: transactions.FlatTransaction{ - "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "DestinationTag": uint32(12345), - }, - addressField: "Destination", - tagField: "DestinationTag", - expected: transactions.FlatTransaction{ - "Destination": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "DestinationTag": uint32(12345), - }, - expectedErr: nil, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := ws.validateTransactionAddress(&tt.tx, tt.addressField, tt.tagField) - - if tt.expectedErr != nil { - if !errors.Is(err, tt.expectedErr) { - t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) - } - } else if err != nil { - t.Errorf("Unexpected error: %v", err) - } - - if !reflect.DeepEqual(tt.expected, tt.tx) { - t.Errorf("Expected %v, but got %v", tt.expected, tt.tx) - } - }) - } -} - -func TestWebsocketClient_setValidTransactionAddresses(t *testing.T) { - tests := []struct { - name string - tx transactions.FlatTransaction - expected transactions.FlatTransaction - expectedErr error - }{ - { - name: "Valid transaction with classic addresses", - tx: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", - }, - expected: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", - }, - expectedErr: nil, - }, - { - name: "Transaction with additional address fields", - tx: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", - "Owner": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "RegularKey": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - expected: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", - "Owner": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "RegularKey": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - expectedErr: nil, - }, - } - - ws := &WebsocketClient{} - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := ws.setValidTransactionAddresses(&tt.tx) - - if tt.expectedErr != nil { - if !errors.Is(err, tt.expectedErr) { - t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) - } - } else if err != nil { - t.Errorf("Unexpected error: %v", err) - } - - if !reflect.DeepEqual(tt.expected, tt.tx) { - t.Errorf("Expected %v, but got %v", tt.expected, tt.tx) - } - }) - } -} - -func TestWebsocketClient_setTransactionNextValidSequenceNumber(t *testing.T) { - tests := []struct { - name string - tx transactions.FlatTransaction - serverMessages []map[string]any - expected transactions.FlatTransaction - expectedErr error - }{ - { - name: "Valid transaction", - tx: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - }, - serverMessages: []map[string]any{ - { - "id": 1, - "result": map[string]any{ - "account_data": map[string]any{ - "Sequence": json.Number("42"), - }, - "ledger_current_index": json.Number("100"), - }, - }, - }, - expected: transactions.FlatTransaction{ - "Account": "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf", - "Sequence": int(42), - }, - expectedErr: nil, - }, - { - name: "Missing Account", - tx: transactions.FlatTransaction{}, - serverMessages: []map[string]any{}, - expected: transactions.FlatTransaction{}, - expectedErr: errors.New("missing Account in transaction"), - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ws := &test.MockWebSocketServer{Msgs: tt.serverMessages} - s := ws.TestWebSocketServer(func(c *websocket.Conn) { - for _, m := range tt.serverMessages { - err := c.WriteJSON(m) - if err != nil { - t.Errorf("error writing message: %v", err) - } - } - }) - defer s.Close() - - url, _ := test.ConvertHttpToWS(s.URL) - cl := &WebsocketClient{ - cfg: WebsocketClientConfig{ - host: url, - }, - } - - err := cl.setTransactionNextValidSequenceNumber(&tt.tx) - - if tt.expectedErr != nil { - if !reflect.DeepEqual(err.Error(), tt.expectedErr.Error()) { - t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) - } - } else { - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - } - - if !reflect.DeepEqual(tt.expected, tt.tx) { - t.Logf("Expected:") - for k, v := range tt.expected { - t.Logf(" %s: %v (type: %T)", k, v, v) - } - t.Logf("Got:") - for k, v := range tt.tx { - t.Logf(" %s: %v (type: %T)", k, v, v) - } - t.Errorf("Expected %v but got %v", tt.expected, tt.tx) - } - }) - } -} - -func TestWebsocket_calculateFeePerTransactionType(t *testing.T) { - tests := []struct { - name string - tx transactions.FlatTransaction - serverMessages []map[string]any - expectedFee string - expectedErr error - feeCushion float32 - }{ - { - name: "Basic fee calculation", - tx: transactions.FlatTransaction{ - "TransactionType": transactions.PaymentTx, - }, - serverMessages: []map[string]any{ - { - "id": 1, - "result": map[string]any{ - "info": map[string]any{ - "validated_ledger": map[string]any{ - "base_fee_xrp": float32(0.00001), - }, - "load_factor": float32(1), - }, - }, - }, - }, - expectedFee: "10", - expectedErr: nil, - feeCushion: 1, - }, - { - name: "Fee calculation with high load factor", - tx: transactions.FlatTransaction{ - "TransactionType": transactions.PaymentTx, - }, - serverMessages: []map[string]any{ - { - "id": 1, - "result": map[string]any{ - "info": map[string]any{ - "validated_ledger": map[string]any{ - "base_fee_xrp": float32(0.00001), - }, - "load_factor": float32(1000), - }, - }, - }, - }, - expectedFee: "10000", - expectedErr: nil, - feeCushion: 1, - }, - { - name: "Fee calculation with max fee limit", - tx: transactions.FlatTransaction{ - "TransactionType": transactions.PaymentTx, - }, - serverMessages: []map[string]any{ - { - "id": 1, - "result": map[string]any{ - "info": map[string]any{ - "validated_ledger": map[string]any{ - "base_fee_xrp": float32(1), - }, - "load_factor": float32(1000), - }, - }, - }, - }, - expectedFee: "2000000", - expectedErr: nil, - feeCushion: 1, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ws := &test.MockWebSocketServer{Msgs: tt.serverMessages} - s := ws.TestWebSocketServer(func(c *websocket.Conn) { - for _, m := range tt.serverMessages { - err := c.WriteJSON(m) - if err != nil { - t.Errorf("error writing message: %v", err) - } - } - }) - defer s.Close() - - url, _ := test.ConvertHttpToWS(s.URL) - cl := &WebsocketClient{ - cfg: WebsocketClientConfig{ - host: url, - feeCushion: tt.feeCushion, - maxFeeXRP: DEFAULT_MAX_FEE_XRP, - }, - } - - err := cl.calculateFeePerTransactionType(&tt.tx) - - if tt.expectedErr != nil { - if !reflect.DeepEqual(err.Error(), tt.expectedErr.Error()) { - t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) - } - } else { - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - if !reflect.DeepEqual(tt.expectedFee, tt.tx["Fee"]) { - t.Errorf("Expected fee %v, but got %v", tt.expectedFee, tt.tx["Fee"]) - } - } - }) - } -} - -func TestWebsocketClient_setLastLedgerSequence(t *testing.T) { - tests := []struct { - name string - serverMessages []map[string]any - tx transactions.FlatTransaction - expectedTx transactions.FlatTransaction - expectedErr error - }{ - { - name: "Successfully set LastLedgerSequence", - serverMessages: []map[string]any{ - { - "id": 1, - "result": transactions.FlatTransaction{ - "ledger_index": 1000, - }, - }, - }, - tx: transactions.FlatTransaction{}, - expectedTx: transactions.FlatTransaction{"LastLedgerSequence": int(1000 + LEDGER_OFFSET)}, - expectedErr: nil, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ws := &test.MockWebSocketServer{Msgs: tt.serverMessages} - s := ws.TestWebSocketServer(func(c *websocket.Conn) { - for _, m := range tt.serverMessages { - err := c.WriteJSON(m) - if err != nil { - t.Errorf("error writing message: %v", err) - } - } - }) - defer s.Close() - - url, _ := test.ConvertHttpToWS(s.URL) - cl := &WebsocketClient{ - cfg: WebsocketClientConfig{ - host: url, - }, - } - err := cl.setLastLedgerSequence(&tt.tx) - - if tt.expectedErr != nil { - if err == nil || err.Error() != tt.expectedErr.Error() { - t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) - } - } else { - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - if !reflect.DeepEqual(tt.expectedTx, tt.tx) { - t.Errorf("Expected tx %v, but got %v", tt.expectedTx, tt.tx) - } - } - }) - } -} - -func TestWebsocketClient_checkAccountDeleteBlockers(t *testing.T) { - tests := []struct { - name string - address types.Address - serverMessages []map[string]any - expectedErr error - }{ - { - name: "No blockers", - address: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - serverMessages: []map[string]any{ - { - "id": 1, - "result": map[string]any{ - "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "account_objects": []any{}, - "ledger_hash": "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", - "ledger_index": 30, - "validated": true, - }, - }, - }, - expectedErr: nil, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ws := &test.MockWebSocketServer{Msgs: tt.serverMessages} - s := ws.TestWebSocketServer(func(c *websocket.Conn) { - for _, m := range tt.serverMessages { - err := c.WriteJSON(m) - if err != nil { - t.Errorf("error writing message: %v", err) - } - } - }) - defer s.Close() - - url, _ := test.ConvertHttpToWS(s.URL) - cl := &WebsocketClient{ - cfg: WebsocketClientConfig{ - host: url, - }, - } - - err := cl.checkAccountDeleteBlockers(tt.address) - - if tt.expectedErr != nil { - if err == nil || err.Error() != tt.expectedErr.Error() { - t.Errorf("Expected error %v, but got %v", tt.expectedErr, err) - } - } else { - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - } - }) - } -} - -func TestWebsocketClient_setTransactionFlags(t *testing.T) { - tests := []struct { - name string - tx transactions.FlatTransaction - expected uint32 - wantErr bool - }{ - { - name: "No flags set", - tx: transactions.FlatTransaction{ - "TransactionType": string(transactions.PaymentTx), - }, - expected: uint32(0), - wantErr: false, - }, - { - name: "Flags already set", - tx: transactions.FlatTransaction{ - "TransactionType": string(transactions.PaymentTx), - "Flags": uint32(1), - }, - expected: 1, - wantErr: false, - }, - { - name: "Missing TransactionType", - tx: transactions.FlatTransaction{ - "Flags": uint32(1), - }, - expected: 0, - wantErr: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - c := &WebsocketClient{} - err := c.setTransactionFlags(&tt.tx) - - if (err != nil) != tt.wantErr { - - t.Errorf("setTransactionFlags() error = %v, wantErr %v", err, tt.wantErr) - return - } - - if !tt.wantErr { - flags, ok := tt.tx["Flags"] - if !ok && tt.expected != 0 { - t.Errorf("setTransactionFlags() got = %v (type %T), want %v (type %T)", flags, flags, tt.expected, tt.expected) - } - } - }) - } -}